@gx-design-vue/create-gx-cli 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/cli.js +7 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
@@ -1,12 +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
|
-
|
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')
|
10
13
|
packageJSON = JSON.parse(packageJSON)
|
11
14
|
const { version } = packageJSON
|
12
15
|
|
@@ -32,7 +35,7 @@ const FRAMEWORKS = [
|
|
32
35
|
]
|
33
36
|
|
34
37
|
const TEMPLATES = FRAMEWORKS.map(
|
35
|
-
f => (f.variants && f.variants.map(v => v.name)) || [f.name]
|
38
|
+
f => (f.variants && f.variants.map(v => v.name)) || [ f.name ]
|
36
39
|
).reduce((a, b) => a.concat(b), [])
|
37
40
|
|
38
41
|
function formatTargetDir(targetDir) {
|
@@ -40,7 +43,7 @@ function formatTargetDir(targetDir) {
|
|
40
43
|
}
|
41
44
|
|
42
45
|
function parseArgumentsIntoOptions() {
|
43
|
-
const argv = minimist(process.argv.slice(2), { string: ['_'] })
|
46
|
+
const argv = minimist(process.argv.slice(2), { string: [ '_' ] })
|
44
47
|
const argTargetDir = formatTargetDir(argv._[0])
|
45
48
|
const argTemplate = argv.template || argv.t
|
46
49
|
return {
|
@@ -100,7 +103,7 @@ async function promptForMissingOptions(options) {
|
|
100
103
|
export async function cli() {
|
101
104
|
let options = parseArgumentsIntoOptions()
|
102
105
|
if (options.v) {
|
103
|
-
console.log(chalk.
|
106
|
+
console.log(chalk.blueBright(version))
|
104
107
|
process.exit(1)
|
105
108
|
}
|
106
109
|
options = await promptForMissingOptions(options)
|