@gx-design-vue/create-gx-cli 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -2
- package/src/cli.js +4 -3
- package/src/main.js +9 -8
- package/template-mobile-vant-cli/package.json +5 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gx-design-vue/create-gx-cli",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.9",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "a cli to bootstrap gx project",
|
6
6
|
"main": "src/index.js",
|
@@ -23,7 +23,7 @@
|
|
23
23
|
"nanospinner": "^1.1.0",
|
24
24
|
"ncp": "^2.0.0",
|
25
25
|
"obtain-git-repo": "^1.0.2",
|
26
|
-
"prompts": "^2.4.
|
26
|
+
"prompts": "^2.4.1"
|
27
27
|
},
|
28
28
|
"files": [
|
29
29
|
"bin/",
|
package/src/cli.js
CHANGED
@@ -43,6 +43,7 @@ function parseArgumentsIntoOptions() {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
async function promptForMissingOptions(options) {
|
46
|
+
console.log(typeof options.template === 'string' && !TEMPLATES.includes(options.template))
|
46
47
|
const answers = await prompts([
|
47
48
|
{
|
48
49
|
type: options.projectName ? null : 'text',
|
@@ -51,7 +52,7 @@ async function promptForMissingOptions(options) {
|
|
51
52
|
initial: defaultTargetDir
|
52
53
|
},
|
53
54
|
{
|
54
|
-
type:
|
55
|
+
type: 'select',
|
55
56
|
name: 'template',
|
56
57
|
message:
|
57
58
|
typeof options.template === 'string' && !TEMPLATES.includes(options.template)
|
@@ -65,8 +66,7 @@ async function promptForMissingOptions(options) {
|
|
65
66
|
title: frameworkColor(framework.name),
|
66
67
|
value: framework
|
67
68
|
}
|
68
|
-
})
|
69
|
-
default: 'vue'
|
69
|
+
})
|
70
70
|
}
|
71
71
|
])
|
72
72
|
|
@@ -80,6 +80,7 @@ async function promptForMissingOptions(options) {
|
|
80
80
|
export async function cli() {
|
81
81
|
let options = parseArgumentsIntoOptions()
|
82
82
|
options = await promptForMissingOptions(options)
|
83
|
+
console.log(options)
|
83
84
|
if (options.template && options.projectName) {
|
84
85
|
await createProject(options)
|
85
86
|
}
|
package/src/main.js
CHANGED
@@ -41,6 +41,8 @@ function editPackageJson(root, projectName) {
|
|
41
41
|
fs.readFileSync(path.join(root, `package.json`), 'utf-8')
|
42
42
|
)
|
43
43
|
|
44
|
+
console.log(projectName)
|
45
|
+
|
44
46
|
pkg.name = projectName
|
45
47
|
writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
|
46
48
|
}
|
@@ -71,9 +73,9 @@ export async function createProject(options) {
|
|
71
73
|
`template-${options.template}`
|
72
74
|
)
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
76
|
+
const dirIsTemplate = fs.existsSync(templateDir)
|
77
|
+
|
78
|
+
if (!dirIsTemplate) {
|
77
79
|
if (!downloadGit) {
|
78
80
|
console.log(chalk.redBright('模版目录不存在'))
|
79
81
|
process.exit(1)
|
@@ -91,7 +93,7 @@ export async function createProject(options) {
|
|
91
93
|
if (downloadGit) {
|
92
94
|
const spinner = createSpinner(`开始下载...${downloadGit.git}`).start()
|
93
95
|
// 下载git代码
|
94
|
-
download(`direct:${downloadGit.git}`, root, { clone: true }, async function(err) {
|
96
|
+
download(`direct:${downloadGit.git}`, root, { clone: true }, async function (err) {
|
95
97
|
if (err) {
|
96
98
|
spinner.error({ text: '下载失败' })
|
97
99
|
} else {
|
@@ -99,8 +101,7 @@ export async function createProject(options) {
|
|
99
101
|
spinner.success({
|
100
102
|
text: '项目创建成功,请依次执行以下命令'
|
101
103
|
})
|
102
|
-
fs.
|
103
|
-
doneLog(cwd, root)
|
104
|
+
fs.doneLog(cwd, root)
|
104
105
|
}
|
105
106
|
})
|
106
107
|
} else {
|
@@ -110,10 +111,10 @@ export async function createProject(options) {
|
|
110
111
|
title: '项目创建',
|
111
112
|
task: () => copyTemplateFiles(templateDir, root)
|
112
113
|
},
|
113
|
-
{
|
114
|
+
options.template !== 'mobile-vant-html' ? {
|
114
115
|
title: '项目文件修改',
|
115
116
|
task: () => editPackageJson(root, options.projectName || getProjectName())
|
116
|
-
}
|
117
|
+
} : {}
|
117
118
|
],
|
118
119
|
{
|
119
120
|
exitOnError: false
|
@@ -8,8 +8,8 @@
|
|
8
8
|
"preview": "vite preview"
|
9
9
|
},
|
10
10
|
"dependencies": {
|
11
|
-
"@gx-design-vue/pro-hooks": "^0.
|
12
|
-
"@gx-design-vue/pro-utils": "^0.
|
11
|
+
"@gx-design-vue/pro-hooks": "^0.1.1",
|
12
|
+
"@gx-design-vue/pro-utils": "^0.1.1",
|
13
13
|
"@vueuse/core": "^9.10.0",
|
14
14
|
"@vueuse/shared": "^9.10.0",
|
15
15
|
"axios": "^1.1.3",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"qs": "^6.11.0",
|
23
23
|
"unocss": "^0.48.2",
|
24
24
|
"vant": "^4.0.8",
|
25
|
-
"vue": "^3.2.
|
25
|
+
"vue": "^3.2.45",
|
26
26
|
"vue-router": "^4.1.6"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
@@ -54,11 +54,11 @@
|
|
54
54
|
"typescript": "^4.6.4",
|
55
55
|
"unplugin-auto-import": "^0.11.4",
|
56
56
|
"unplugin-vue-components": "^0.22.9",
|
57
|
-
"vite": "^4.0.
|
57
|
+
"vite": "^4.0.4",
|
58
58
|
"vite-plugin-html": "^3.2.0",
|
59
59
|
"vite-plugin-mock": "^2.9.6",
|
60
60
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
61
61
|
"vue-eslint-parser": "^9.1.0",
|
62
62
|
"vue-tsc": "^1.0.9"
|
63
63
|
}
|
64
|
-
}
|
64
|
+
}
|