@gx-design-vue/create-gx-cli 0.1.13 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +7 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gx-design-vue/create-gx-cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "a cli to bootstrap gx project",
package/src/cli.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import chalk from 'chalk'
2
2
  import fs from 'node:fs'
3
+ import { fileURLToPath } from 'node:url'
3
4
  import path from 'node:path'
4
5
  import minimist from 'minimist'
5
6
  import prompts from 'prompts'
6
7
  import { blue, green, red, reset, yellow } from 'kolorist'
7
8
  import { createProject } from './main.js'
8
9
 
9
- const cwd = process.cwd()
10
- let packageJSON = fs.readFileSync(path.join(cwd, '../package.json'), 'utf-8')
10
+ const __filename = fileURLToPath(import.meta.url)
11
+ const __dirname = path.dirname(__filename)
12
+ let packageJSON = fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8')
11
13
  packageJSON = JSON.parse(packageJSON)
12
14
  const { version } = packageJSON
13
15
 
@@ -33,7 +35,7 @@ const FRAMEWORKS = [
33
35
  ]
34
36
 
35
37
  const TEMPLATES = FRAMEWORKS.map(
36
- f => (f.variants && f.variants.map(v => v.name)) || [f.name]
38
+ f => (f.variants && f.variants.map(v => v.name)) || [ f.name ]
37
39
  ).reduce((a, b) => a.concat(b), [])
38
40
 
39
41
  function formatTargetDir(targetDir) {
@@ -41,7 +43,7 @@ function formatTargetDir(targetDir) {
41
43
  }
42
44
 
43
45
  function parseArgumentsIntoOptions() {
44
- const argv = minimist(process.argv.slice(2), { string: ['_'] })
46
+ const argv = minimist(process.argv.slice(2), { string: [ '_' ] })
45
47
  const argTargetDir = formatTargetDir(argv._[0])
46
48
  const argTemplate = argv.template || argv.t
47
49
  return {
@@ -101,7 +103,7 @@ async function promptForMissingOptions(options) {
101
103
  export async function cli() {
102
104
  let options = parseArgumentsIntoOptions()
103
105
  if (options.v) {
104
- console.log(chalk.whiteBright(version))
106
+ console.log(chalk.blueBright(version))
105
107
  process.exit(1)
106
108
  }
107
109
  options = await promptForMissingOptions(options)