create-vue 3.0.0-alpha.2 → 3.0.0-beta.2
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.
- package/README.md +6 -0
- package/index.js +27 -43
- package/outfile.cjs +5693 -0
- package/package.json +22 -14
- package/template/base/package.json +4 -4
- package/template/code/default/cypress/integration/example.spec.js +1 -1
- package/template/code/default/src/App.vue +73 -14
- package/template/code/default/src/assets/base.css +74 -0
- package/template/code/default/src/assets/logo.svg +1 -0
- package/template/code/default/src/components/HelloWorld.vue +28 -41
- package/template/code/default/src/components/Welcome.vue +84 -0
- package/template/code/default/src/components/WelcomeItem.vue +86 -0
- package/template/code/default/src/components/__tests__/HelloWorld.spec.js +0 -9
- package/template/code/default/src/components/icons/IconCommunity.vue +7 -0
- package/template/code/default/src/components/icons/IconDocumentation.vue +7 -0
- package/template/code/default/src/components/icons/IconEcosystem.vue +7 -0
- package/template/code/default/src/components/icons/IconSupport.vue +7 -0
- package/template/code/default/src/components/icons/IconTooling.vue +19 -0
- package/template/code/router/cypress/integration/example.spec.js +1 -1
- package/template/code/router/src/App.vue +102 -14
- package/template/code/router/src/assets/base.css +74 -0
- package/template/code/router/src/assets/logo.svg +1 -0
- package/template/code/router/src/components/HelloWorld.vue +28 -41
- package/template/code/router/src/components/Welcome.vue +84 -0
- package/template/code/router/src/components/WelcomeItem.vue +86 -0
- package/template/code/router/src/components/__tests__/HelloWorld.spec.js +0 -9
- package/template/code/router/src/components/icons/IconCommunity.vue +7 -0
- package/template/code/router/src/components/icons/IconDocumentation.vue +7 -0
- package/template/code/router/src/components/icons/IconEcosystem.vue +7 -0
- package/template/code/router/src/components/icons/IconSupport.vue +7 -0
- package/template/code/router/src/components/icons/IconTooling.vue +19 -0
- package/template/code/router/src/views/About.vue +10 -0
- package/template/code/router/src/views/Home.vue +7 -17
- package/template/code/typescript-default/cypress/integration/example.spec.ts +1 -1
- package/template/code/typescript-default/src/App.vue +73 -11
- package/template/code/typescript-default/src/assets/base.css +74 -0
- package/template/code/typescript-default/src/assets/logo.svg +1 -0
- package/template/code/typescript-default/src/components/HelloWorld.vue +28 -41
- package/template/code/typescript-default/src/components/Welcome.vue +84 -0
- package/template/code/typescript-default/src/components/WelcomeItem.vue +86 -0
- package/template/code/typescript-default/src/components/__tests__/HelloWorld.spec.ts +0 -9
- package/template/code/typescript-default/src/components/icons/IconCommunity.vue +7 -0
- package/template/code/typescript-default/src/components/icons/IconDocumentation.vue +7 -0
- package/template/code/typescript-default/src/components/icons/IconEcosystem.vue +7 -0
- package/template/code/typescript-default/src/components/icons/IconSupport.vue +7 -0
- package/template/code/typescript-default/src/components/icons/IconTooling.vue +19 -0
- package/template/code/typescript-router/cypress/integration/example.spec.ts +1 -1
- package/template/code/typescript-router/src/App.vue +102 -14
- package/template/code/typescript-router/src/assets/base.css +74 -0
- package/template/code/typescript-router/src/assets/logo.svg +1 -0
- package/template/code/typescript-router/src/components/HelloWorld.vue +28 -41
- package/template/code/typescript-router/src/components/Welcome.vue +84 -0
- package/template/code/typescript-router/src/components/WelcomeItem.vue +86 -0
- package/template/code/typescript-router/src/components/__tests__/HelloWorld.spec.ts +0 -9
- package/template/code/typescript-router/src/components/icons/IconCommunity.vue +7 -0
- package/template/code/typescript-router/src/components/icons/IconDocumentation.vue +7 -0
- package/template/code/typescript-router/src/components/icons/IconEcosystem.vue +7 -0
- package/template/code/typescript-router/src/components/icons/IconSupport.vue +7 -0
- package/template/code/typescript-router/src/components/icons/IconTooling.vue +19 -0
- package/template/code/{router/src/main.js → typescript-router/src/main.ts} +0 -0
- package/template/code/typescript-router/src/views/About.vue +10 -0
- package/template/code/typescript-router/src/views/Home.vue +6 -16
- package/template/config/cypress/package.json +4 -4
- package/template/config/jsx/package.json +1 -1
- package/template/config/router/package.json +1 -1
- package/template/{base/vite-env.d.ts → config/typescript/env.d.ts} +0 -0
- package/template/config/typescript/package.json +2 -2
- package/template/{base/jsconfig.json → config/typescript/tsconfig.json} +1 -2
- package/template/code/default/src/assets/logo.png +0 -0
- package/template/code/default/src/main.js +0 -4
- package/template/code/router/src/assets/logo.png +0 -0
- package/template/code/typescript-default/src/assets/logo.png +0 -0
- package/template/code/typescript-default/src/main.ts +0 -4
- package/template/code/typescript-router/src/assets/logo.png +0 -0
- package/template/config/cypress/cypress/.DS_Store +0 -0
- package/utils/deepMerge.js +0 -26
- package/utils/directoryTraverse.js +0 -29
- package/utils/docs/README-TEMPLATE.md +0 -17
- package/utils/docs/SFC-TYPE-SUPPORT.md +0 -5
- package/utils/generateReadme.js +0 -69
- package/utils/getCommand.js +0 -7
- package/utils/renderTemplate.js +0 -47
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -9,17 +9,12 @@ import prompts from 'prompts'
|
|
|
9
9
|
import { red, green, bold } from 'kolorist'
|
|
10
10
|
|
|
11
11
|
import renderTemplate from './utils/renderTemplate.js'
|
|
12
|
-
import {
|
|
13
|
-
postOrderDirectoryTraverse,
|
|
14
|
-
preOrderDirectoryTraverse
|
|
15
|
-
} from './utils/directoryTraverse.js'
|
|
12
|
+
import { postOrderDirectoryTraverse, preOrderDirectoryTraverse } from './utils/directoryTraverse.js'
|
|
16
13
|
import generateReadme from './utils/generateReadme.js'
|
|
17
14
|
import getCommand from './utils/getCommand.js'
|
|
18
15
|
|
|
19
16
|
function isValidPackageName(projectName) {
|
|
20
|
-
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
|
|
21
|
-
projectName
|
|
22
|
-
)
|
|
17
|
+
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName)
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
function toValidPackageName(projectName) {
|
|
@@ -66,14 +61,8 @@ async function init() {
|
|
|
66
61
|
// if any of the feature flags is set, we would skip the feature prompts
|
|
67
62
|
// use `??` instead of `||` once we drop Node.js 12 support
|
|
68
63
|
const isFeatureFlagsUsed =
|
|
69
|
-
typeof (
|
|
70
|
-
|
|
71
|
-
argv.ts ||
|
|
72
|
-
argv.jsx ||
|
|
73
|
-
argv.router ||
|
|
74
|
-
argv.vuex ||
|
|
75
|
-
argv.tests
|
|
76
|
-
) === 'boolean'
|
|
64
|
+
typeof (argv.default || argv.ts || argv.jsx || argv.router || argv.vuex || argv.tests) ===
|
|
65
|
+
'boolean'
|
|
77
66
|
|
|
78
67
|
let targetDir = argv._[0]
|
|
79
68
|
const defaultProjectName = !targetDir ? 'vue-project' : targetDir
|
|
@@ -99,18 +88,14 @@ async function init() {
|
|
|
99
88
|
type: targetDir ? null : 'text',
|
|
100
89
|
message: 'Project name:',
|
|
101
90
|
initial: defaultProjectName,
|
|
102
|
-
onState: (state) =>
|
|
103
|
-
(targetDir = String(state.value).trim() || defaultProjectName)
|
|
91
|
+
onState: (state) => (targetDir = String(state.value).trim() || defaultProjectName)
|
|
104
92
|
},
|
|
105
93
|
{
|
|
106
94
|
name: 'shouldOverwrite',
|
|
107
|
-
type: () =>
|
|
108
|
-
canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm',
|
|
95
|
+
type: () => (canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm'),
|
|
109
96
|
message: () => {
|
|
110
97
|
const dirForPrompt =
|
|
111
|
-
targetDir === '.'
|
|
112
|
-
? 'Current directory'
|
|
113
|
-
: `Target directory "${targetDir}"`
|
|
98
|
+
targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`
|
|
114
99
|
|
|
115
100
|
return `${dirForPrompt} is not empty. Remove existing files and continue?`
|
|
116
101
|
}
|
|
@@ -129,8 +114,7 @@ async function init() {
|
|
|
129
114
|
type: () => (isValidPackageName(targetDir) ? null : 'text'),
|
|
130
115
|
message: 'Package name:',
|
|
131
116
|
initial: () => toValidPackageName(targetDir),
|
|
132
|
-
validate: (dir) =>
|
|
133
|
-
isValidPackageName(dir) || 'Invalid package.json name'
|
|
117
|
+
validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name'
|
|
134
118
|
},
|
|
135
119
|
{
|
|
136
120
|
name: 'needsTypeScript',
|
|
@@ -206,12 +190,13 @@ async function init() {
|
|
|
206
190
|
console.log(`\nScaffolding project in ${root}...`)
|
|
207
191
|
|
|
208
192
|
const pkg = { name: packageName, version: '0.0.0' }
|
|
209
|
-
fs.writeFileSync(
|
|
210
|
-
path.resolve(root, 'package.json'),
|
|
211
|
-
JSON.stringify(pkg, null, 2)
|
|
212
|
-
)
|
|
193
|
+
fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(pkg, null, 2))
|
|
213
194
|
|
|
214
|
-
|
|
195
|
+
// todo:
|
|
196
|
+
// work around the esbuild issue that `import.meta.url` cannot be correctly transpiled
|
|
197
|
+
// when bundling for node and the format is cjs
|
|
198
|
+
// const templateRoot = new URL('./template', import.meta.url).pathname
|
|
199
|
+
const templateRoot = path.resolve(__dirname, 'template')
|
|
215
200
|
const render = function render(templateName) {
|
|
216
201
|
const templateDir = path.resolve(templateRoot, templateName)
|
|
217
202
|
renderTemplate(templateDir, root)
|
|
@@ -267,10 +252,7 @@ async function init() {
|
|
|
267
252
|
if (filepath.endsWith('.js')) {
|
|
268
253
|
fs.renameSync(filepath, filepath.replace(/\.js$/, '.ts'))
|
|
269
254
|
} else if (path.basename(filepath) === 'jsconfig.json') {
|
|
270
|
-
fs.renameSync(
|
|
271
|
-
filepath,
|
|
272
|
-
filepath.replace(/jsconfig\.json$/, 'tsconfig.json')
|
|
273
|
-
)
|
|
255
|
+
fs.renameSync(filepath, filepath.replace(/jsconfig\.json$/, 'tsconfig.json'))
|
|
274
256
|
}
|
|
275
257
|
}
|
|
276
258
|
)
|
|
@@ -278,10 +260,7 @@ async function init() {
|
|
|
278
260
|
// Rename entry in `index.html`
|
|
279
261
|
const indexHtmlPath = path.resolve(root, 'index.html')
|
|
280
262
|
const indexHtmlContent = fs.readFileSync(indexHtmlPath, 'utf8')
|
|
281
|
-
fs.writeFileSync(
|
|
282
|
-
indexHtmlPath,
|
|
283
|
-
indexHtmlContent.replace('src/main.js', 'src/main.ts')
|
|
284
|
-
)
|
|
263
|
+
fs.writeFileSync(indexHtmlPath, indexHtmlContent.replace('src/main.js', 'src/main.ts'))
|
|
285
264
|
}
|
|
286
265
|
|
|
287
266
|
if (!needsTests) {
|
|
@@ -304,6 +283,8 @@ async function init() {
|
|
|
304
283
|
|
|
305
284
|
// Instructions:
|
|
306
285
|
// Supported package managers: pnpm > yarn > npm
|
|
286
|
+
// Note: until <https://github.com/pnpm/pnpm/issues/3505> is resolved,
|
|
287
|
+
// it is not possible to tell if the command is called by `pnpm init`.
|
|
307
288
|
const packageManager = /pnpm/.test(process.env.npm_execpath)
|
|
308
289
|
? 'pnpm'
|
|
309
290
|
: /yarn/.test(process.env.npm_execpath)
|
|
@@ -311,12 +292,15 @@ async function init() {
|
|
|
311
292
|
: 'npm'
|
|
312
293
|
|
|
313
294
|
// README generation
|
|
314
|
-
fs.writeFileSync(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
295
|
+
fs.writeFileSync(
|
|
296
|
+
path.resolve(root, 'README.md'),
|
|
297
|
+
generateReadme({
|
|
298
|
+
projectName: result.projectName || defaultProjectName,
|
|
299
|
+
packageManager,
|
|
300
|
+
needsTypeScript,
|
|
301
|
+
needsTests
|
|
302
|
+
})
|
|
303
|
+
)
|
|
320
304
|
|
|
321
305
|
console.log(`\nDone. Now run:\n`)
|
|
322
306
|
if (root !== cwd) {
|