@gx-design-vue/create-gx-cli 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/main.js +8 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gx-design-vue/create-gx-cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "description": "a cli to bootstrap gx project",
6
6
  "main": "src/index.js",
package/src/main.js CHANGED
@@ -8,9 +8,7 @@ import { promisify } from 'util'
8
8
  import { createSpinner } from 'nanospinner'
9
9
  import { download } from 'obtain-git-repo'
10
10
 
11
- const access = promisify(fs.access)
12
11
  const copy = promisify(ncp)
13
- const writeFileSync = promisify(fs.writeFileSync)
14
12
 
15
13
  const gitRepositoryList = [
16
14
  {
@@ -31,7 +29,7 @@ async function copyTemplateFiles(templateDir, root) {
31
29
 
32
30
  function writeFile(path, content) {
33
31
  if (Object.keys(content).length > 0) {
34
- writeFileSync(path, content)
32
+ fs.writeFileSync(path, content)
35
33
  }
36
34
  }
37
35
 
@@ -44,9 +42,8 @@ function editPackageJson(root, projectName) {
44
42
  )
45
43
 
46
44
  pkg.name = projectName
45
+ writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
47
46
  }
48
-
49
- writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
50
47
  }
51
48
 
52
49
  function doneLog(cwd, root) {
@@ -75,7 +72,7 @@ export async function createProject(options) {
75
72
  )
76
73
 
77
74
  try {
78
- await access(templateDir, fs.constants.R_OK)
75
+ await fs.access(templateDir, fs.constants.R_OK)
79
76
  } catch (err) {
80
77
  if (!downloadGit) {
81
78
  console.log(chalk.redBright('模版目录不存在'))
@@ -107,20 +104,15 @@ export async function createProject(options) {
107
104
  }
108
105
  })
109
106
  } else {
110
- let pkg = {}
111
-
112
- if (fs.existsSync(path.join(templateDir, `package.json`))) {
113
- pkg = JSON.parse(
114
- fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
115
- )
116
-
117
- pkg.name = options.projectName || getProjectName()
118
- }
119
107
  const tasks = new Listr(
120
108
  [
121
109
  {
122
- title: '项目创建成功,请依次执行以下命令',
110
+ title: '项目创建',
123
111
  task: () => copyTemplateFiles(templateDir, root)
112
+ },
113
+ {
114
+ title: '项目文件修改',
115
+ task: () => editPackageJson(root, options.projectName || getProjectName())
124
116
  }
125
117
  ],
126
118
  {
@@ -130,7 +122,6 @@ export async function createProject(options) {
130
122
 
131
123
  await tasks.run()
132
124
 
133
- await editPackageJson(root)
134
125
  doneLog(cwd, root)
135
126
  }
136
127
  return true