/
index.js
88 lines (77 loc) · 1.95 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
module.exports = (api, {
classComponent,
tsLint,
lintOn = [],
convertJsToTs,
allowJs
}, _, invoking) => {
if (typeof lintOn === 'string') {
lintOn = lintOn.split(',')
}
api.extendPackage({
devDependencies: {
typescript: '~3.5.3'
}
})
if (classComponent) {
api.extendPackage({
dependencies: {
'vue-class-component': '^7.0.2',
'vue-property-decorator': '^8.1.0'
}
})
}
if (tsLint) {
api.extendPackage({
scripts: {
lint: 'vue-cli-service lint'
}
})
if (!lintOn.includes('save')) {
api.extendPackage({
vue: {
lintOnSave: false
}
})
}
if (lintOn.includes('commit')) {
api.extendPackage({
devDependencies: {
'lint-staged': '^9.4.2'
},
gitHooks: {
'pre-commit': 'lint-staged'
},
'lint-staged': {
'*.ts': ['vue-cli-service lint', 'git add'],
'*.vue': ['vue-cli-service lint', 'git add']
}
})
}
// lint and fix files on creation complete
api.onCreateComplete(() => {
return require('../lib/tslint')({}, api, true)
})
}
// late invoke compat
if (invoking) {
if (api.hasPlugin('unit-mocha')) {
// eslint-disable-next-line node/no-extraneous-require
require('@vue/cli-plugin-unit-mocha/generator').applyTS(api)
}
if (api.hasPlugin('unit-jest')) {
// eslint-disable-next-line node/no-extraneous-require
require('@vue/cli-plugin-unit-jest/generator').applyTS(api)
}
if (api.hasPlugin('eslint')) {
// eslint-disable-next-line node/no-extraneous-require
require('@vue/cli-plugin-eslint/generator').applyTS(api)
}
}
api.render('./template', {
isTest: process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG,
hasMocha: api.hasPlugin('unit-mocha'),
hasJest: api.hasPlugin('unit-jest')
})
require('./convert')(api, { tsLint, convertJsToTs })
}