@gx-design-vue/create-gx-cli 0.0.2 → 0.0.3
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/package.json +1 -1
- package/src/cli.js +23 -14
package/package.json
CHANGED
package/src/cli.js
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
+
import fs from 'fs'
|
2
|
+
import path from 'path'
|
1
3
|
import minimist from 'minimist'
|
2
4
|
import prompts from 'prompts'
|
3
|
-
import {
|
5
|
+
import { yellow, reset } from 'kolorist'
|
4
6
|
import { createProject } from './main'
|
5
7
|
|
6
8
|
const defaultTargetDir = 'gx-cli-project'
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
color: yellow
|
12
|
-
},
|
13
|
-
{
|
14
|
-
name: 'mobile',
|
15
|
-
color: blue
|
16
|
-
}
|
17
|
-
]
|
10
|
+
function getTemplate() {
|
11
|
+
const templateList = []
|
12
|
+
const files = fs.readdirSync(path.join(process.cwd(), '../'))
|
18
13
|
|
19
|
-
const
|
20
|
-
|
21
|
-
|
14
|
+
for (const file of files) {
|
15
|
+
if (file.indexOf('template') >= 0) {
|
16
|
+
templateList.push(file)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return templateList.map((el) => {
|
20
|
+
return {
|
21
|
+
name: el.split('-')[1],
|
22
|
+
color: yellow
|
23
|
+
}
|
24
|
+
})
|
25
|
+
}
|
22
26
|
|
23
27
|
function formatTargetDir(targetDir) {
|
24
28
|
return targetDir ? targetDir.trim().replace(/\/+$/g, '') : ''
|
@@ -35,6 +39,11 @@ function parseArgumentsIntoOptions() {
|
|
35
39
|
}
|
36
40
|
|
37
41
|
async function promptForMissingOptions(options) {
|
42
|
+
const FRAMEWORKS = getTemplate()
|
43
|
+
|
44
|
+
const TEMPLATES = FRAMEWORKS.map(
|
45
|
+
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
|
46
|
+
).reduce((a, b) => a.concat(b), [])
|
38
47
|
const answers = await prompts([
|
39
48
|
{
|
40
49
|
type: options.projectName ? null : 'text',
|