This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
meta.js
186 lines (182 loc) · 4.83 KB
/
meta.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const validateAppId = app_id => {
let parts = app_id.split('.')
if (parts.length < 2) {
return 'App ID must contain two or more strings, separated by a dot.'
}
if (
parts.some(part => {
return !/^[a-zA-Z]\w+$/i.test(part)
})
) {
return 'Each string must start with a letter and should contain only letters and numbers.'
}
if (!/^[a-z]/.test(app_id[0])) {
return 'App ID must start with a lowercase letter.'
}
return true
}
const validateVersion = version => {
if (!/^(\d+\.)(\d+\.)(\d)$/.test(version)) {
return 'Version must have major, minor and patch numbers.'
}
return true
}
module.exports = {
prompts: {
update: {
type: 'confirm',
label: 'You are about to update the current project, are you sure?',
default: false,
when: 'inPlace',
},
name: {
type: 'string',
required: true,
label: 'Project name',
when: '!inPlace',
},
description: {
type: 'string',
label: 'Project description',
default: 'A native application built with NativeScript-Vue',
when: '!inPlace',
},
app_name: {
type: 'string',
required: true,
label: 'Application name',
default: 'NativeScript-Vue Application',
when: '!inPlace',
},
app_id: {
type: 'string',
required: true,
label: 'Unique application identifier',
default: 'org.nativescript.application',
validate: validateAppId,
when: '!inPlace',
},
version: {
type: 'string',
required: true,
label: 'Project version',
default: '1.0.0',
validate: validateVersion,
when: '!inPlace',
},
author: {
type: 'string',
label: 'Author',
when: '!inPlace',
},
license: {
type: 'string',
label: 'License',
default: 'MIT',
when: '!inPlace',
},
lang: {
type: 'list',
label: 'Select the programming language',
choices: [
'javascript',
'typescript',
],
default: 'javascript',
when: '!inPlace',
},
preset: {
type: 'list',
label: 'Select a preset (more coming soon)',
choices: [
'Simple',
'TabView',
'SideDrawer',
],
default: 'Simple',
when: '!inPlace',
},
// router: {
// type: 'confirm',
// label: 'Install vue-router? (experimental)',
// default: false,
// when: '!inPlace',
// },
store: {
type: 'confirm',
label: 'Install vuex? (state management)',
default: false,
when: '!inPlace',
},
devtools: {
type: 'confirm',
label: 'Install vue-devtools?',
default: true,
when: '!inPlace',
},
color_scheme: {
type: 'list',
label: 'Color scheme',
choices: [
'none',
'default',
'aqua',
'blue',
'brown',
'forest',
'grey',
'lemon',
'lime',
'orange',
'purple',
'ruby',
'sky',
],
default: 'none',
when: '!inPlace',
},
},
helpers: {
androidVersionCode: version => {
const parts = version.split('.')
return parts[0] + '0' + parts[1] + '0' + parts[2]
},
},
filters: {
'src/**/!(main.ts|main.js)': '!inPlace',
'src/main.js': '!inPlace && lang == "javascript"',
'src/main.ts': '!inPlace && lang == "typescript"',
'package.json': '!inPlace',
'README.md': '!inPlace',
'.gitignore': '!inPlace',
'tsconfig.json': '!inPlace && lang == "typescript"',
'types/**/*': '!inPlace && lang == "typescript"',
'src/router/**/*': '!inPlace && router',
'src/components/Home.vue': '!inPlace && router',
'src/store.js': '!inPlace && store && lang == "javascript"',
'src/store.ts': '!inPlace && store && lang == "typescript"',
'src/components/Counter.vue': '!inPlace && store',
},
complete(data, {logger, chalk}) {
if (data.inPlace) {
logger.log('')
logger.log(chalk.green(`Successfully updated application.`))
logger.log('')
logger.log(`One last step is required to be fully updated`)
logger.log(`You will need to update your ${chalk.underline('package.json')}`)
logger.log(`To match the dependencies from the template`)
logger.log(chalk.yellow(`https://github.com/nativescript-vue/vue-cli-template/blob/master/template/package.json`))
logger.log('')
logger.log(chalk.grey(`-------------------------------------------`))
logger.log(`The reason we don't do this automatically is`)
logger.log(`that you would lose any modifications you've`)
logger.log(`made to ${chalk.underline('package.json')}`)
} else {
logger.log(`cd ${chalk.yellow(data.destDirName)}`)
logger.log(`npm install`)
logger.log(`ns preview`)
logger.log(chalk.grey(`# or`))
logger.log(`ns run`)
}
}
}