Skip to content

Commit 505bbc1

Browse files
committed
自动判断运行时,更新依赖
1 parent c2506cd commit 505bbc1

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

index.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ function emptyDir(dir) {
6363
)
6464
}
6565

66+
// get now user runtime
67+
function detectRuntime() {
68+
// @ts-ignore
69+
if (typeof Bun !== 'undefined') {
70+
return 'bun'
71+
}
72+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
73+
return 'node'
74+
}
75+
// @ts-ignore
76+
if (typeof Deno !== 'undefined') {
77+
return 'deno'
78+
}
79+
return 'unknown'
80+
}
81+
6682
const helpMessage = `\
6783
Usage: create-vue [FEATURE_FLAGS...] [OPTIONS...] [DIRECTORY]
6884
@@ -105,6 +121,9 @@ Available feature flags:
105121
--eslint-with-prettier
106122
Add Prettier for code formatting in addition to ESLint.
107123
124+
--runtime
125+
Show runtime environment selection prompt.
126+
108127
Unstable feature flags:
109128
--tests, --with-tests
110129
Add both unit testing and end-to-end testing support.
@@ -123,6 +142,7 @@ async function init() {
123142
tests: { type: 'boolean' },
124143
'vue-router': { type: 'boolean' },
125144
router: { type: 'boolean' },
145+
runtime: { type: 'boolean' },
126146
} as const
127147

128148
const { values: argv, positionals } = parseArgs({
@@ -209,7 +229,7 @@ async function init() {
209229
[
210230
{
211231
name: 'runtime',
212-
type: () => (isFeatureFlagsUsed ? null : 'select'),
232+
type: () => (argv.runtime ? 'select' : null),
213233
message: language.needsRuntime.message,
214234
initial: 0,
215235
choices: [
@@ -391,7 +411,7 @@ async function init() {
391411
needsPinia = argv.pinia,
392412
needsVitest = argv.vitest || argv.tests,
393413
needsPrettier = argv['eslint-with-prettier'],
394-
runtime = 'node',
414+
runtime = detectRuntime(),
395415
} = result
396416

397417
const needsEslint = Boolean(argv.eslint || argv['eslint-with-prettier'] || result.needsEslint)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

template/others-runtime/bun/config/typescript/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"devDependencies": {
88
"@types/bun": "^1.1.13",
9-
"npm-run-all2": "^7.0.1",
10-
"typescript": "~5.6.3",
11-
"vue-tsc": "^2.1.10"
9+
"npm-run-all2": "^7.0.2",
10+
"typescript": "~5.7.3",
11+
"vue-tsc": "^2.2.0"
1212
}
1313
}

0 commit comments

Comments
 (0)