Skip to content

Commit a3f5f26

Browse files
add plugins
1 parent 7574d52 commit a3f5f26

File tree

9 files changed

+101
-20
lines changed

9 files changed

+101
-20
lines changed

generator/index.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = (api, options) => {
88
'vuex': '^3.1.0',
99
'vuex-persistedstate': '^2.5.4',
1010
'@fortawesome/fontawesome-pro': '^5.8.1',
11-
"lodash.clonedeep": "^4.5.0",
11+
'lodash.clonedeep': '^4.5.0',
12+
'css-vars-ponyfill': '^2.1.2',
1213
},
1314
});
1415
if (options.useCrud) {
@@ -17,32 +18,45 @@ module.exports = (api, options) => {
1718
'@kingscode/vuetify-resource': '^1.1.0',
1819
},
1920
});
20-
api.render('./templates/Crud', {
21-
...options,
22-
});
21+
api.render('./templates/Crud', options);
2322
}
2423

25-
api.render('./templates/Default', {
26-
...options,
27-
});
24+
api.render('./templates/Default', options);
2825

2926
if (options.useAuthorisation) {
30-
api.render('./templates/Authorisation', {
31-
...options,
27+
api.render('./templates/Authorisation', options);
28+
}
29+
30+
if (options.plugins.includes('sentry')) {
31+
api.extendPackage({
32+
dependencies: {
33+
'@sentry/browser': '^5.8.0',
34+
'@sentry/integrations': '^5.8.0',
35+
},
36+
});
37+
api.render('./templates/Plugins/sentry', options);
38+
}
39+
40+
if (options.plugins.includes('analytics')) {
41+
api.extendPackage({
42+
dependencies: {
43+
'vue-analytics': '^5.17.4',
44+
},
3245
});
46+
api.render('./templates/Plugins/analytics', options);
3347
}
3448

3549
api.onCreateComplete(() => {
36-
if(fs.existsSync('src/store.js')) {
50+
if (fs.existsSync('src/store.js')) {
3751
fs.unlinkSync(api.resolve('src/store.js'));
3852
}
39-
if(fs.existsSync('src/assets/logo.svg')) {
53+
if (fs.existsSync('src/assets/logo.svg')) {
4054
fs.unlinkSync(api.resolve('src/assets/logo.svg'));
4155
}
42-
if(fs.existsSync('src/components/HelloWorld.vue')) {
56+
if (fs.existsSync('src/components/HelloWorld.vue')) {
4357
fs.unlinkSync(api.resolve('src/components/HelloWorld.vue'));
4458
}
45-
if(fs.existsSync('src/main.js')) {
59+
if (fs.existsSync('src/main.js')) {
4660
fs.unlinkSync(api.resolve('src/main.js'));
4761
}
4862
fs.renameSync(api.resolve('src/newmain.js'), api.resolve('src/main.js'));

generator/templates/Default/_env.development.local

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ VUE_APP_PUBLIC_PATH=
55
VUE_APP_OAUTH_CLIENT_ID=<%= options.oauthClientId %>
66
VUE_APP_OAUTH_CLIENT_SECRET=<%= options.oauthSecret %>
77
<%_ } _%>
8+
<%_ if (options.plugins.includes('analytics')) { _%>
9+
VUE_APP_ANALYTICS=
10+
<%_ } _%>
11+
<%_ if (options.plugins.includes('sentry')) { _%>
12+
VUE_APP_SENTRY=
13+
<%_ } _%>

generator/templates/Default/_env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ VUE_APP_PUBLIC_PATH=
55
VUE_APP_OAUTH_CLIENT_SECRET=
66
VUE_APP_OAUTH_CLIENT_ID=
77
<%_ } _%>
8+
<%_ if (options.plugins.includes('analytics')) { _%>
9+
VUE_APP_ANALYTICS=
10+
<%_ } _%>
11+
<%_ if (options.plugins.includes('sentry')) { _%>
12+
VUE_APP_SENTRY=
13+
<%_ } _%>

generator/templates/Default/src/newmain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@babel/polyfill'
22
import Vue from 'vue'
33
import API from './API.js';
4-
import vuetify from './plugins/vuetify';
4+
import {vuetify} from './plugins';
55
<%_ if (options.useCrud) { _%>
66
import VuetifyResource from '@kingscode/vuetify-resource';
77
<%_ } _%>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import cssVars from 'css-vars-ponyfill';
2+
<%_ if (options.plugins.includes('analytics')) { _%>
3+
import './analytics';
4+
<%_ } _%>
5+
<%_ if (options.plugins.includes('sentry')) { _%>
6+
import './sentry';
7+
<%_ } _%>
8+
import vuetify from './vuetify';
9+
10+
cssVars();
11+
12+
export {vuetify};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import VueAnalytics from 'vue-analytics';
2+
import Vue from 'vue';
3+
import router from './../router';
4+
5+
if (process.env.VUE_APP_ANALYTICS) {
6+
Vue.use(VueAnalytics, {
7+
id: process.env.VUE_APP_SENTRYVUE_APP_SENTRY,
8+
router,
9+
});
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/browser';
2+
import * as Integrations from '@sentry/integrations';
3+
import Vue from 'vue';
4+
5+
if (process.env.VUE_APP_SENTRY) {
6+
Sentry.init({
7+
dsn: process.env.VUE_APP_SENTRY,
8+
integrations: [new Integrations.Vue({Vue, attachProps: true})],
9+
});
10+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-kingscode-scaffold",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

prompts.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function useAuthorisation (answers) {
2-
return answers.useAuthorisation
1+
function useAuthorisation(answers) {
2+
return answers.useAuthorisation;
33
}
44

55
module.exports = [
@@ -15,22 +15,45 @@ module.exports = [
1515
message: 'Do you want to use authorisation (Login/register/invitation/password forgotten)',
1616
default: true,
1717
},
18+
{
19+
name: 'useGithubDeployemnts',
20+
type: 'confirm',
21+
message: 'Do you want to use github actions for deployments?',
22+
default: true,
23+
},
24+
{
25+
name: 'plugins',
26+
type: 'checkbox',
27+
message: 'Which plugins should we install for you?',
28+
choices: [
29+
{
30+
value: 'sentry',
31+
name: 'error logging with sentry',
32+
checked: true,
33+
},
34+
{
35+
value: 'analytics',
36+
name: 'Google Analytics with vue-analytics',
37+
checked: true,
38+
},
39+
],
40+
},
1841
{
1942
name: 'oauthClientId',
2043
type: 'input',
2144
message: 'What is the oauth client id? (run php artisan passport:client --password (you can change this later)',
22-
when: useAuthorisation
45+
when: useAuthorisation,
2346
},
2447
{
2548
name: 'oauthSecret',
2649
type: 'input',
2750
message: 'What is the oauth client secret? (run php artisan passport:client --password (you can change this later)',
28-
when: useAuthorisation
51+
when: useAuthorisation,
2952
},
3053
{
3154
name: 'rootUrl',
3255
type: 'input',
3356
message: 'What is the root API url? (you can change this later)',
3457
default: '//example.local/api',
35-
}
58+
},
3659
];

0 commit comments

Comments
 (0)