diff --git a/generator/index.js b/generator/index.js index 8e2e933..86947c4 100644 --- a/generator/index.js +++ b/generator/index.js @@ -10,6 +10,7 @@ module.exports = (api, options) => { 'vuex-persistedstate': '^2.5.4', 'lodash.clonedeep': '^4.5.0', 'css-vars-ponyfill': '^2.1.2', + 'qs': '^6.9.4', 'vue-router': '3.3.4', }, }); @@ -19,12 +20,18 @@ module.exports = (api, options) => { '@fortawesome/fontawesome-pro': '^5.8.1', }, }); + } else { + api.extendPackage({ + dependencies: { + '@fortawesome/fontawesome-free': '^5.14.0', + }, + }); } if (options.useCrud) { api.extendPackage({ dependencies: { - '@kingscode/vuetify-resource': '^1.4.1', + '@kingscode/vuetify-resource': '^2.0.3', }, }); api.render('./templates/Crud', options); diff --git a/generator/templates/Authorisation/src/api/endpoints/authorisation/login.js b/generator/templates/Authorisation/src/api/endpoints/authorisation/login.js index 42e28bb..d7919fa 100644 --- a/generator/templates/Authorisation/src/api/endpoints/authorisation/login.js +++ b/generator/templates/Authorisation/src/api/endpoints/authorisation/login.js @@ -1,4 +1,4 @@ -import {post} from '../../implementation/app/wrapper'; +import {post} from '../../implementation/app'; export default function (email, password) { return post('auth/login', { diff --git a/generator/templates/Authorisation/src/api/endpoints/authorisation/logout.js b/generator/templates/Authorisation/src/api/endpoints/authorisation/logout.js index 8f4931a..fbc1259 100644 --- a/generator/templates/Authorisation/src/api/endpoints/authorisation/logout.js +++ b/generator/templates/Authorisation/src/api/endpoints/authorisation/logout.js @@ -1,4 +1,4 @@ -import {post} from '../../implementation/app/wrapper.js'; +import {post} from '../../implementation/app'; export default function () { return post('auth/logout'); diff --git a/generator/templates/Authorisation/src/api/endpoints/authorisation/password.js b/generator/templates/Authorisation/src/api/endpoints/authorisation/password.js index 19db457..98bbf24 100644 --- a/generator/templates/Authorisation/src/api/endpoints/authorisation/password.js +++ b/generator/templates/Authorisation/src/api/endpoints/authorisation/password.js @@ -1,4 +1,4 @@ -import {post} from '../../implementation/app/wrapper.js'; +import {post} from '../../implementation/app'; function passwordForgotten(email) { return post('password/forgotten', { diff --git a/generator/templates/Authorisation/src/api/endpoints/authorisation/register.js b/generator/templates/Authorisation/src/api/endpoints/authorisation/register.js index d5b155e..d09072e 100644 --- a/generator/templates/Authorisation/src/api/endpoints/authorisation/register.js +++ b/generator/templates/Authorisation/src/api/endpoints/authorisation/register.js @@ -1,7 +1,21 @@ -import {post} from '../../implementation/app/wrapper.js'; +import {post} from '../../implementation/app'; -export default function (email, name) { +function register(email, name) { return post('registration', { email, name, }); } + +function verify(token, email, password, passwordConfirmation) { + return post('registration/verify', { + token: token, + email: email, + password: password, + password_confirmation: passwordConfirmation, + }); +} + +export { + register, + verify, +}; diff --git a/generator/templates/Authorisation/src/api/endpoints/password/forgotten.js b/generator/templates/Authorisation/src/api/endpoints/password/forgotten.js index 3644853..f76f541 100644 --- a/generator/templates/Authorisation/src/api/endpoints/password/forgotten.js +++ b/generator/templates/Authorisation/src/api/endpoints/password/forgotten.js @@ -1,4 +1,4 @@ -import {post} from '../../implementation/app/wrapper.js'; +import {post} from '../../implementation/app'; export default function (email) { return post('password/forgotten', { diff --git a/generator/templates/Authorisation/src/api/endpoints/password/reset.js b/generator/templates/Authorisation/src/api/endpoints/password/reset.js index b32be24..83caf14 100644 --- a/generator/templates/Authorisation/src/api/endpoints/password/reset.js +++ b/generator/templates/Authorisation/src/api/endpoints/password/reset.js @@ -1,10 +1,10 @@ -import {post} from '../../implementation/app/wrapper.js'; +import {post} from '../../implementation/app'; export default async function (email, token, password, passwordConfirmation) { return post('registration', { email: email, token: token, password: password, - password_confirmation: passwordConfirmation + password_confirmation: passwordConfirmation, }); } diff --git a/generator/templates/Authorisation/src/api/endpoints/user.js b/generator/templates/Authorisation/src/api/endpoints/user.js new file mode 100644 index 0000000..00ba992 --- /dev/null +++ b/generator/templates/Authorisation/src/api/endpoints/user.js @@ -0,0 +1,28 @@ +import axios from '../implementation/app'; + +/** + * @param user {User} + */ +function create(user) { + return axios.post('user', user); +} + +/** + * @param user {User} + */ +function update(user) { + return axios.put(`user/${user.id}`, user); +} + +/** + * @param userId {number} + */ +function destroy(userId) { + return axios.delete(`user/${userId}`); +} + +export { + create, + update, + destroy, +}; diff --git a/generator/templates/Authorisation/src/components/Authorisation/LoginCard.vue b/generator/templates/Authorisation/src/components/Authorisation/LoginCard.vue index 9d66b95..9f3d869 100644 --- a/generator/templates/Authorisation/src/components/Authorisation/LoginCard.vue +++ b/generator/templates/Authorisation/src/components/Authorisation/LoginCard.vue @@ -43,6 +43,7 @@ - - diff --git a/generator/templates/Authorisation/src/views/AuthorisationCallback.vue b/generator/templates/Authorisation/src/views/AuthorisationCallback.vue index 7bec31d..2e3d7a0 100644 --- a/generator/templates/Authorisation/src/views/AuthorisationCallback.vue +++ b/generator/templates/Authorisation/src/views/AuthorisationCallback.vue @@ -1,23 +1,26 @@ - diff --git a/generator/templates/Authorisation/src/views/Login.vue b/generator/templates/Authorisation/src/views/Login.vue index ca603e4..c0a541b 100644 --- a/generator/templates/Authorisation/src/views/Login.vue +++ b/generator/templates/Authorisation/src/views/Login.vue @@ -9,16 +9,15 @@ - - - diff --git a/generator/templates/Authorisation/src/views/PasswordForgotten.vue b/generator/templates/Authorisation/src/views/PasswordForgotten.vue index adc7704..7c91d38 100644 --- a/generator/templates/Authorisation/src/views/PasswordForgotten.vue +++ b/generator/templates/Authorisation/src/views/PasswordForgotten.vue @@ -7,7 +7,6 @@ diff --git a/generator/templates/Authorisation/src/views/Verify.vue b/generator/templates/Authorisation/src/views/Verify.vue new file mode 100644 index 0000000..36befd5 --- /dev/null +++ b/generator/templates/Authorisation/src/views/Verify.vue @@ -0,0 +1,115 @@ + + + += diff --git a/generator/templates/Crud/src/components/Resource.vue b/generator/templates/Crud/src/components/Resource.vue index ea9c700..d376f24 100644 --- a/generator/templates/Crud/src/components/Resource.vue +++ b/generator/templates/Crud/src/components/Resource.vue @@ -7,6 +7,7 @@ :deleteCallback="deleteEvent" :getDataCallback="getDataFromApi" :getItemCallback="getItemFromApi" + @row-click="onRowClick" :meta="meta" :tableContent="tableContent" :texts="require('../VuetifyResourceTexts.js').default" @@ -17,14 +18,14 @@ >
@@ -35,15 +36,14 @@ + diff --git a/generator/templates/Crud/src/mixins/formDataValues.js b/generator/templates/Crud/src/mixins/formDataValues.js index 54a6a5c..e5e1e25 100644 --- a/generator/templates/Crud/src/mixins/formDataValues.js +++ b/generator/templates/Crud/src/mixins/formDataValues.js @@ -2,8 +2,8 @@ export default { methods: { appendFormData(form_data, values, startKey = '') { if (typeof values === 'object') { - for (let key in values) { - let currentKey = startKey.length ? startKey + '[' + key + ']' : key; + for (const key in values) { + const currentKey = startKey.length ? startKey + '[' + key + ']' : key; if (typeof values[key] === 'object' && !(values[key] instanceof File)) { this.appendFormData(form_data, values[key], currentKey); @@ -14,4 +14,4 @@ export default { } }, }, -}; \ No newline at end of file +}; diff --git a/generator/templates/Crud/src/views/UserResource.vue b/generator/templates/Crud/src/views/UserResource.vue index 7030391..1cada20 100644 --- a/generator/templates/Crud/src/views/UserResource.vue +++ b/generator/templates/Crud/src/views/UserResource.vue @@ -1,42 +1,47 @@ - - - +export default { + name: 'UserResource', + components: { + Resource, + }, + computed: { + updateHandler: () => update, + deleteHandler: () => destroy, + createHandler: () => create, + modelType: () => User, + tableContent: () => [ + { + text: 'Naam', + align: 'left', + sortable: true, + value: 'name', + }, + { + text: 'E-mail', + align: 'left', + sortable: true, + value: 'email', + }, + ], + }, +}; + diff --git a/generator/templates/Default/src/App.vue b/generator/templates/Default/src/App.vue index 48ed9ce..c0b1ce4 100644 --- a/generator/templates/Default/src/App.vue +++ b/generator/templates/Default/src/App.vue @@ -4,14 +4,8 @@ - diff --git a/generator/templates/Default/src/Views/PageForbidden.vue b/generator/templates/Default/src/Views/PageForbidden.vue deleted file mode 100644 index 321fbe0..0000000 --- a/generator/templates/Default/src/Views/PageForbidden.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - - - diff --git a/generator/templates/Default/src/Views/PageNotFound.vue b/generator/templates/Default/src/Views/PageNotFound.vue deleted file mode 100644 index 13062fd..0000000 --- a/generator/templates/Default/src/Views/PageNotFound.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - - - diff --git a/generator/templates/Default/src/api/implementation/app/index.js b/generator/templates/Default/src/api/implementation/app/index.js index 9f0a86f..c3b55b8 100644 --- a/generator/templates/Default/src/api/implementation/app/index.js +++ b/generator/templates/Default/src/api/implementation/app/index.js @@ -1,7 +1,8 @@ import axios from 'axios'; import {onRequestFulFilled, onRequestRejected, onResponseFulFilled, onResponseRejected} from './interceptor'; -import {destroy, get, getPaginated, post, put} from './wrapper' +import {getPaginated} from './wrapper'; +import {transformParams, transformRequest, transformResponse} from './transformer'; /** * Returns an axios instance @@ -16,6 +17,9 @@ const config = { headers: { Accept: 'application/json', }, + transformRequest: [transformRequest], + transformResponse: [transformResponse], + paramsSerializer: transformParams, }; const instance = axios.create(config); @@ -23,12 +27,17 @@ const instance = axios.create(config); instance.interceptors.request.use(onRequestFulFilled, onRequestRejected); instance.interceptors.response.use(onResponseFulFilled, onResponseRejected); +const get = instance.get; +const post = instance.post; +const destroy = instance.delete; +const put = instance.put; + export { - get, getPaginated, + get, post, - put, destroy, -} + put, +}; export default instance; diff --git a/generator/templates/Default/src/api/implementation/app/interceptor.js b/generator/templates/Default/src/api/implementation/app/interceptor.js index 06a8ffb..ca4732a 100644 --- a/generator/templates/Default/src/api/implementation/app/interceptor.js +++ b/generator/templates/Default/src/api/implementation/app/interceptor.js @@ -26,8 +26,8 @@ function onRequestFulFilled(request) { function computeHeaders() { return { - Authorization: store.getters['Authorisation/isLoggedIn'] - ? `Bearer ${store.state.Authorisation.token}` + Authorization: store.getters['authorisation/isLoggedIn'] + ? `Bearer ${store.state.authorisation.token}` : undefined, }; } @@ -50,23 +50,21 @@ function onResponseFulFilled(response) { * @param error {AxiosError} */ function onResponseRejected(error) { + const response = error.response; - if (typeof error === 'string' || !error.response) return Promise.reject(error); + if (!response) return Promise.reject(error); // network error, not axios related - const status = error.response.status; + const status = response.status; + const errors = response.data.errors; - const data = error.response.data; - /* Now we know there was an error during submitting */ - if (data.errors && status === 422) { - /* For now, all errors will be removed on route change - * We might need to add global errors later on */ - Object.keys(data.errors).forEach(key => store.commit('Error/add', { + if (errors && status === 422) { + Object.keys(errors).forEach(key => store.commit('error/add', { key: key, - message: data.errors[key][0], + message: errors[key][0], })); } - return Promise.reject(error.response); + return Promise.reject(error); } export { diff --git a/generator/templates/Default/src/api/implementation/app/transformer.js b/generator/templates/Default/src/api/implementation/app/transformer.js index d0c78b0..ecd22b8 100644 --- a/generator/templates/Default/src/api/implementation/app/transformer.js +++ b/generator/templates/Default/src/api/implementation/app/transformer.js @@ -1,8 +1,11 @@ -import {snakeToCamel} from '../../../util/keyConverter'; +import {camelToSnake, snakeToCamel} from '../../util/keyConverter'; +import objectToFormData from '../../util/objectToFormDataConverter.js'; +import Qs from 'qs'; +import Model from '../../../application/models/model.js'; /** - * @param response {} - * @returns {{}, string} + * @param response + * @returns {{}} */ function transformResponse(response) { if (typeof response === 'string' && response.length > 0) { @@ -17,6 +20,35 @@ function transformResponse(response) { return response; } +/** + * @param data {undefined|*} + * @return {FormData} + */ +function transformRequest(data) { + if (data instanceof Model) { + const isPutRequest = data._method === 'put'; + + data = data.mapForRequest(); + + if (isPutRequest) { + data._method = 'put'; + } + } + + if (data) { + data = camelToSnake(data); + data = objectToFormData(data); + } + + return data; +} + +function transformParams(params) { + return Qs.stringify(camelToSnake(params)); +} + export { transformResponse, + transformRequest, + transformParams, }; diff --git a/generator/templates/Default/src/api/implementation/app/wrapper.js b/generator/templates/Default/src/api/implementation/app/wrapper.js index f6b8a7e..d0b0df4 100644 --- a/generator/templates/Default/src/api/implementation/app/wrapper.js +++ b/generator/templates/Default/src/api/implementation/app/wrapper.js @@ -1,61 +1,32 @@ import handle from './index'; -async function get(url, params = {}) { - const result = await handle.get(url, { - params: params, - }); - - return result.data; -} - -async function getPaginated(url, page = 1, perPage = 10, search, sortBy, descending, params) { - const result = await handle.get(url, { +/** + * @param url + * @param page + * @param perPage + * @param search + * @param sortBy + * @param descending + * @param params + * @return {Promise} + */ +function getPaginated(url, page = 1, perPage = 10, search, sortBy, descending, params) { + if (search) + params.search = search; + if (sortBy) + params.sortBy = sortBy; + if (typeof descending !== 'undefined') + params.desc = descending ? '1' : '0'; + + return handle.get(url, { params: { page: page, perPage: perPage, - /* undefined to exclude them out of the request */ - search: search ? search : undefined, - sortBy: sortBy ? sortBy : undefined, - desc: typeof descending === 'undefined' ? undefined : (descending ? '1' : '0'), ...params, }, }); - - return result.data; -} - -async function post(url, data = {}, params = {}) { - const result = await handle.post(url, data, { - params: params, - }); - - /* Not all of our post requests will get a body back */ - if (result.data.data) return result.data; - - return result; -} - -async function put(url, data = {}, params = {}) { - const result = await handle.put(url, data, { - params: params, - }); - - /* Not all of our post requests will get a body back */ - if (result.data.data) return result.data; - - return result; -} - -function destroy(url, params = {}) { - return handle.delete(url, { - params: params, - }); } export { - get, getPaginated, - post, - put, - destroy, }; diff --git a/generator/templates/Default/src/api/util/keyConverter.js b/generator/templates/Default/src/api/util/keyConverter.js index 3cb6486..6d22b40 100644 --- a/generator/templates/Default/src/api/util/keyConverter.js +++ b/generator/templates/Default/src/api/util/keyConverter.js @@ -1,11 +1,13 @@ function camelToSnake(data) { - const target = Array.isArray(data) ? [] : {}; + if (!isIterableObject(data)) { + throw new Error('keyConverter::camelToSnake data is not iterable'); + } - if (typeof data !== 'object') return; + const target = Array.isArray(data) ? [] : {}; Object.keys(data).forEach(key => { Object.assign(target, { - [convertCamelToSnake(key)]: isObject(data[key]) ? camelToSnake(data[key]) : data[key], + [convertCamelToSnake(key)]: isIterableObject(data[key]) ? camelToSnake(data[key]) : data[key], }); }); @@ -19,13 +21,15 @@ function convertCamelToSnake(key) { } function snakeToCamel(data) { - const target = Array.isArray(data) ? [] : {}; + if (!isIterableObject(data)) { + throw new Error('keyConverter::snakeToCamel data is not iterable'); + } - if (typeof data !== 'object') return; + const target = Array.isArray(data) ? [] : {}; Object.keys(data).forEach(key => { Object.assign(target, { - [convertSnakeToCamel(key)]: isObject(data[key]) ? snakeToCamel(data[key]) : data[key], + [convertSnakeToCamel(key)]: isIterableObject(data[key]) ? snakeToCamel(data[key]) : data[key], }); }); @@ -38,8 +42,8 @@ function convertSnakeToCamel(key) { }); } -function isObject(target) { - return typeof target === 'object' && target !== null; +function isIterableObject(target) { + return typeof target === 'object' && target !== null && !(target instanceof Blob) && !(target instanceof Date); } export { diff --git a/generator/templates/Default/src/api/util/objectToFormDataConverter.js b/generator/templates/Default/src/api/util/objectToFormDataConverter.js index 43b0539..3cf3249 100644 --- a/generator/templates/Default/src/api/util/objectToFormDataConverter.js +++ b/generator/templates/Default/src/api/util/objectToFormDataConverter.js @@ -1,11 +1,13 @@ -function isObject(input) { +function isIterableObject(input) { return typeof input === 'object' && input !== null && !(input instanceof Blob) && !(input instanceof Date); } function objectToFormData(obj) { - const data = new FormData(); + if (!isIterableObject(obj)) { + throw new Error('objectToFormDataConverter::objectToFormData data is not iterable'); + } - if (!isObject(obj)) return data; + const data = new FormData(); return convert(obj, data); } @@ -18,10 +20,9 @@ function convert(obj, data, parent) { if (parent) { if (Array.isArray(obj)) finalName = `${parent}[${i}]`; - else if (isObject(obj)) + else if (isIterableObject(obj)) finalName = `${parent}[${key}]`; } - if (val instanceof Blob) data.append(finalName, val, val.name); else if (val instanceof Date) @@ -29,11 +30,15 @@ function convert(obj, data, parent) { else if (val instanceof FileList) for (let x = 0; x < val.length; x++) data.append(`${finalName}[${x}]`, val.item(x)); - else if (isObject(val)) + else if (isIterableObject(val)) convert(val, data, finalName); else if (typeof val === 'boolean') data.append(finalName, val ? '1' : '0'); - else if (val !== undefined) + else if (val === '' || val === null) + data.append(finalName, ''); + else if (typeof val === 'number') + data.append(finalName, val); + else if (val) data.append(finalName, val); }); diff --git a/generator/templates/Default/src/api/util/response.js b/generator/templates/Default/src/api/util/response.js new file mode 100644 index 0000000..aaa4d3b --- /dev/null +++ b/generator/templates/Default/src/api/util/response.js @@ -0,0 +1,12 @@ +import dayjs from '../../plugins/dayJs.js'; + +function getRateLimitMinutes(response, defaultMinutes = 15) { + const remainingMilliseconds = (+response.headers['retry-after']) * 1000; + const unlockTime = Date.now() + remainingMilliseconds; + + return dayjs(unlockTime).diff(dayjs(), 'minute') || defaultMinutes; +} + +export { + getRateLimitMinutes, +}; diff --git a/generator/templates/Default/src/api/utils/handleTooManyRequestsError.js b/generator/templates/Default/src/api/utils/handleTooManyRequestsError.js deleted file mode 100644 index d17eaff..0000000 --- a/generator/templates/Default/src/api/utils/handleTooManyRequestsError.js +++ /dev/null @@ -1,10 +0,0 @@ -import dayjs from '../../plugins/dayJs.js'; - -export default function handleTooManyRequestsError(result) { - const timestamp = result.headers['x-ratelimit-reset'] * 1000; - const minutes = dayjs(timestamp).diff(dayjs(), 'minute') || 15; - return { - message: `Je hebt te vaak een foutieve login poging gehad. Probeer het over ${minutes} minuten opnieuw.`, - success: false, - }; -} diff --git a/generator/templates/Default/src/application/models/model.js b/generator/templates/Default/src/application/models/model.js new file mode 100644 index 0000000..d699321 --- /dev/null +++ b/generator/templates/Default/src/application/models/model.js @@ -0,0 +1,20 @@ +/** + * + */ +class Model { + /** + * @return {{}}; + */ + mapForRequest() { + throw new Error(`${this.constructor.name}::mapForRequest unset`); + } + + /** + * @param data {{}} + */ + mapResponse(data) { + throw new Error(`${this.constructor.name}::mapResponse unset, keys: ${Object.keys(data).join(', ')}`); + } +} + +export default Model; diff --git a/generator/templates/Default/src/application/models/user.js b/generator/templates/Default/src/application/models/user.js new file mode 100644 index 0000000..27ceefe --- /dev/null +++ b/generator/templates/Default/src/application/models/user.js @@ -0,0 +1,22 @@ +import Model from './model.js'; + +class User extends Model { + id = 0; + name = ''; + email = ''; + + mapForRequest() { + return { + name: this.name, + email: this.email, + }; + } + + mapResponse(data) { + this.id = data.id; + this.name = data.name; + this.email = data.email; + } +} + +export default User; diff --git a/generator/templates/Default/src/application/util/url.js b/generator/templates/Default/src/application/util/url.js new file mode 100644 index 0000000..2448455 --- /dev/null +++ b/generator/templates/Default/src/application/util/url.js @@ -0,0 +1,14 @@ +function getFragment(key, defaultValue = '') { + const fragmentRegExp = new RegExp(`[\\#&]${key}=([^&#]*)`); + const result = fragmentRegExp.exec(location.hash); + + if (result && result.length >= 2) { + return decodeURIComponent(result[1]); + } + + return defaultValue; +} + +export { + getFragment, +}; diff --git a/generator/templates/Default/src/components/AppBarMenu.vue b/generator/templates/Default/src/components/AppBarMenu.vue index 3eb97d6..307deb1 100644 --- a/generator/templates/Default/src/components/AppBarMenu.vue +++ b/generator/templates/Default/src/components/AppBarMenu.vue @@ -21,13 +21,14 @@ diff --git a/generator/templates/Default/src/components/BaseForm.vue b/generator/templates/Default/src/components/BaseForm.vue index dfec9b3..cc90b06 100644 --- a/generator/templates/Default/src/components/BaseForm.vue +++ b/generator/templates/Default/src/components/BaseForm.vue @@ -1,11 +1,18 @@ + diff --git a/generator/templates/Default/src/views/PageForbidden.vue b/generator/templates/Default/src/views/PageForbidden.vue new file mode 100644 index 0000000..f03d014 --- /dev/null +++ b/generator/templates/Default/src/views/PageForbidden.vue @@ -0,0 +1,13 @@ + + + diff --git a/generator/templates/Default/src/views/PageNotFound.vue b/generator/templates/Default/src/views/PageNotFound.vue new file mode 100644 index 0000000..f82d218 --- /dev/null +++ b/generator/templates/Default/src/views/PageNotFound.vue @@ -0,0 +1,13 @@ + + + diff --git a/generator/templates/Default/vue.config.js b/generator/templates/Default/vue.config.js index 1722bae..8796b8d 100644 --- a/generator/templates/Default/vue.config.js +++ b/generator/templates/Default/vue.config.js @@ -1,5 +1,5 @@ module.exports = { - 'transpileDependencies': [ + transpileDependencies: [ 'vuetify', ], publicPath: process.env.VUE_APP_PUBLIC_PATH, @@ -9,8 +9,8 @@ module.exports = { skipWaiting: true, clientsClaim: true, exclude: [ - /\.htaccess$/ - ] + /\.htaccess$/, + ], }, }, }; diff --git a/generator/templates/Plugins/sentry/src/plugins/sentry.js b/generator/templates/Plugins/sentry/src/plugins/sentry.js index 07f31a9..863e0c4 100644 --- a/generator/templates/Plugins/sentry/src/plugins/sentry.js +++ b/generator/templates/Plugins/sentry/src/plugins/sentry.js @@ -1,12 +1,12 @@ -import * as Sentry from '@sentry/browser'; -import * as Integrations from '@sentry/integrations'; +import {init} from '@sentry/browser'; +import {Vue as SentryVue} from '@sentry/integrations'; import Vue from 'vue'; if (process.env.VUE_APP_SENTRY) { - Sentry.init({ + init({ environment: process.env.VUE_APP_ENV, release: process.env.VUE_APP_RELEASE, dsn: process.env.VUE_APP_SENTRY, - integrations: [new Integrations.Vue({Vue, attachProps: true})], + integrations: [new SentryVue({Vue, attachProps: true})], }); } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c95749e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,35 @@ +{ + "name": "vue-cli-plugin-kingscode-scaffold", + "version": "0.8.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "file-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/file-match/-/file-match-1.0.2.tgz", + "integrity": "sha1-ycrSZdLIrfOoFHWw30dYWQafrvc=", + "requires": { + "utils-extend": "^1.0.6" + } + }, + "file-system": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/file-system/-/file-system-2.2.2.tgz", + "integrity": "sha1-fWWDPjojR9zZVqgTxncVPtPt2Yc=", + "requires": { + "file-match": "^1.0.1", + "utils-extend": "^1.0.4" + } + }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + }, + "utils-extend": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/utils-extend/-/utils-extend-1.0.8.tgz", + "integrity": "sha1-zP17ZFQPjpDuIe7Fd2nQZRyril8=" + } + } +} diff --git a/package.json b/package.json index a5a3f61..5f96731 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "vue-cli-plugin-kingscode-scaffold", - "version": "0.8.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "MIT", - "dependencies": { - "file-system": "^2.2.2" - } + "name": "vue-cli-plugin-kingscode-scaffold", + "version": "0.8.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "dependencies": { + "file-system": "^2.2.2" + } } diff --git a/prompts.js b/prompts.js index 4d4917e..fef72ba 100644 --- a/prompts.js +++ b/prompts.js @@ -29,8 +29,8 @@ module.exports = [ message: 'Which plugins should we install for you?', choices: [ { - value: 'sentry', - name: 'error logging with sentry', + value: 'Sentry', + name: 'error logging with Sentry', checked: true, }, { @@ -40,7 +40,7 @@ module.exports = [ }, { value: 'fontawesomepro', - name: 'Font awesome pro', + name: 'Font Awesome Pro', checked: false, }, ],