@@ -6,7 +6,7 @@ import * as path from 'node:path'
6
6
import { parseArgs } from 'node:util'
7
7
8
8
import prompts from 'prompts'
9
- import { red , green , bold } from 'kleur/colors'
9
+ import { red , green , cyan , bold } from 'kleur/colors'
10
10
11
11
import ejs from 'ejs'
12
12
@@ -20,6 +20,8 @@ import getLanguage from './utils/getLanguage'
20
20
import renderEslint from './utils/renderEslint'
21
21
import trimBoilerplate from './utils/trimBoilerplate'
22
22
23
+ import cliPackageJson from './package.json'
24
+
23
25
function isValidPackageName ( projectName ) {
24
26
return / ^ (?: @ [ a - z 0 - 9 - * ~ ] [ a -z 0 -9 -* ._ ~ ] * \/ ) ? [ a - z 0 - 9 - ~ ] [ a - z 0 - 9 - ._ ~ ] * $ / . test ( projectName )
25
27
}
@@ -61,33 +63,56 @@ function emptyDir(dir) {
61
63
)
62
64
}
63
65
64
- async function init ( ) {
65
- console . log ( )
66
- console . log (
67
- process . stdout . isTTY && process . stdout . getColorDepth ( ) > 8
68
- ? banners . gradientBanner
69
- : banners . defaultBanner ,
70
- )
71
- console . log ( )
66
+ const helpMessage = `\
67
+ Usage: create-vue [FEATURE_FLGAS...] [OPTIONS...] [DIRECTORY]
68
+
69
+ Create a new Vue.js project.
70
+ Start the CLI in interactive mode when no FEATURE_FLAGS is provided, or if the DIRECTORY argument is not a valid package name.
71
+
72
+ Options:
73
+ --force
74
+ Create the project even if the directory is not empty.
75
+ --bare
76
+ Create a barebone project without example code.
77
+ --help
78
+ Display this help message.
79
+ --version
80
+ Display the version number of this CLI.
81
+
82
+ Available feature flags:
83
+ --default
84
+ Create a project with the default configuration without any additional features.
85
+ --ts, --typescript
86
+ Add TypeScript support.
87
+ --jsx
88
+ Add JSX support.
89
+ --router, --vue-router
90
+ Add Vue Router for SPA development.
91
+ --pinia
92
+ Add Pinia for state management.
93
+ --vitest
94
+ Add Vitest for unit testing.
95
+ --cypress
96
+ Add Cypress for end-to-end testing.
97
+ If used without ${ cyan ( '--vitest' ) } , it will also add Cypress Component Testing.
98
+ --playwright
99
+ Add Playwright for end-to-end testing.
100
+ --nightwatch
101
+ Add Nightwatch for end-to-end testing.
102
+ If used without ${ cyan ( '--vitest' ) } , it will also add Nightwatch Component Testing.
103
+ --eslint
104
+ Add ESLint for code quality.
105
+ --eslint-with-prettier
106
+ Add Prettier for code formatting in addition to ESLint.
107
+
108
+ Unstable feature flags:
109
+ --tests, --with-tests
110
+ Add both unit testing and end-to-end testing support.
111
+ Currently equivalent to ${ cyan ( '--vitest --cypress' ) } , but may change in the future.
112
+ `
72
113
114
+ async function init ( ) {
73
115
const cwd = process . cwd ( )
74
- // possible options:
75
- // --default
76
- // --typescript / --ts
77
- // --jsx
78
- // --router / --vue-router
79
- // --pinia
80
- // --with-tests / --tests (equals to `--vitest --cypress`)
81
- // --vitest
82
- // --cypress
83
- // --nightwatch
84
- // --playwright
85
- // --eslint
86
- // --eslint-with-prettier (only support prettier through eslint for simplicity)
87
- // in addition to the feature flags, you can also pass the following options:
88
- // --bare (for a barebone template without example code)
89
- // --force (for force overwriting without confirming)
90
-
91
116
const args = process . argv . slice ( 2 )
92
117
93
118
// alias is not supported by parseArgs
@@ -106,6 +131,16 @@ async function init() {
106
131
strict : false ,
107
132
} )
108
133
134
+ if ( argv . help ) {
135
+ console . log ( helpMessage )
136
+ process . exit ( 0 )
137
+ }
138
+
139
+ if ( argv . version ) {
140
+ console . log ( `${ cliPackageJson . name } v${ cliPackageJson . version } ` )
141
+ process . exit ( 0 )
142
+ }
143
+
109
144
// if any of the feature flags is set, we would skip the feature prompts
110
145
const isFeatureFlagsUsed =
111
146
typeof (
@@ -145,6 +180,14 @@ async function init() {
145
180
needsPrettier ? : boolean
146
181
} = { }
147
182
183
+ console . log ( )
184
+ console . log (
185
+ process . stdout . isTTY && process . stdout . getColorDepth ( ) > 8
186
+ ? banners . gradientBanner
187
+ : banners . defaultBanner ,
188
+ )
189
+ console . log ( )
190
+
148
191
try {
149
192
// Prompts:
150
193
// - Project name:
0 commit comments