@mpxjs/cli 3.3.2 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/create.js +19 -12
- package/package.json +1 -1
package/lib/create.js
CHANGED
|
@@ -48,6 +48,21 @@ async function resolvePrompts () {
|
|
|
48
48
|
return inquirer.prompt(prompts).then((answers) => answers)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
async function mergePreset (preset, options) {
|
|
52
|
+
if (options.preset) {
|
|
53
|
+
const remotePreset = await resolvePreset(options)
|
|
54
|
+
merge(preset, remotePreset)
|
|
55
|
+
} else if (options.inlinePreset) {
|
|
56
|
+
try {
|
|
57
|
+
const inlinePreset = JSON.parse(options.inlinePreset)
|
|
58
|
+
merge(preset, inlinePreset)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
error(`CLI inline preset is not valid JSON: ${options.inlinePreset}`)
|
|
61
|
+
exit(1)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return preset
|
|
65
|
+
}
|
|
51
66
|
/**
|
|
52
67
|
* 从vue-cli clone 下来,方便处理creator的创建以及生命周期管理
|
|
53
68
|
* @param {*} projectName
|
|
@@ -58,18 +73,9 @@ async function resolvePrompts () {
|
|
|
58
73
|
async function create (projectName, options, preset = null) {
|
|
59
74
|
// resolve preset
|
|
60
75
|
if (!preset) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
preset = JSON.parse(options.inlinePreset)
|
|
66
|
-
} catch (error) {
|
|
67
|
-
error(`CLI inline preset is not valid JSON: ${options.inlinePreset}`)
|
|
68
|
-
exit(1)
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
preset = await resolvePrompts()
|
|
72
|
-
}
|
|
76
|
+
// 默认回答
|
|
77
|
+
preset = await resolvePrompts()
|
|
78
|
+
await mergePreset(preset, options)
|
|
73
79
|
}
|
|
74
80
|
// css preprocessor
|
|
75
81
|
preset.cssPreprocessor = 'stylus'
|
|
@@ -186,6 +192,7 @@ async function create (projectName, options, preset = null) {
|
|
|
186
192
|
|
|
187
193
|
await creator.create({
|
|
188
194
|
...options,
|
|
195
|
+
preset: undefined,
|
|
189
196
|
inlinePreset: JSON.stringify(preset)
|
|
190
197
|
})
|
|
191
198
|
}
|
package/package.json
CHANGED