@dengzhibo/create-vue-template 0.0.3 → 0.0.4

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/CHANGELOG.md CHANGED
@@ -12,4 +12,8 @@
12
12
 
13
13
  ### v0.0.3 (2026-10-22)
14
14
 
15
- * 新增JSX功能,优化代码
15
+ * 新增JSX功能,优化代码
16
+
17
+ ### v0.0.4 (2026-10-22)
18
+
19
+ * 代码优化
package/README.md CHANGED
@@ -61,3 +61,5 @@ node scripts/check-package.mjs
61
61
  ## 发布文件范围
62
62
 
63
63
  `bin/`、`lib/`、`templates/`、README、CHANGELOG、LICENSE 与 package.json 随 npm 包发布。测试、预检脚本、AGENTS.md 和本地缓存仅用于仓库维护,不需要上传 npm。`_gitignore` 在生成项目时恢复为 `.gitignore`。
64
+
65
+ 未指定目录时默认创建 `vue-project`;指定目录时使用目录名作为包名。生成项目版本与本脚手架根 package.json 的版本一致。
package/lib/generate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
- import { assertTarget, featureLabels, normalizeOptions } from './options.js'
4
+ import { assertTarget, normalizeOptions } from './options.js'
5
5
 
6
6
  const templateDir = fileURLToPath(new URL('../templates/', import.meta.url))
7
7
  const skip = new Set(['node_modules', 'dist', '.npmignore', '.git', '.DS_Store', 'pnpm-lock.yaml', '.turbo'])
@@ -53,8 +53,6 @@ export function createPlan(input = {}, cwd = process.cwd()) {
53
53
  if (has('jsx')) {
54
54
  const vite = files.get('vite.config.ts').toString().replace(/\r\n/g, '\n').replace('import vue from \'@vitejs/plugin-vue\'', 'import vue from \'@vitejs/plugin-vue\'\nimport vueJsx from \'@vitejs/plugin-vue-jsx\'').replace(' vue(),', ' vue(),\n vueJsx(),')
55
55
  files.set('vite.config.ts', vite)
56
- const tsconfig = files.get('tsconfig.app.json').toString().replace('"compilerOptions": {', '"compilerOptions": {\n "jsx": "preserve",\n "jsxImportSource": "vue",')
57
- files.set('tsconfig.app.json', tsconfig)
58
56
  }
59
57
  const extensions = parse('.vscode/extensions.json')
60
58
  if (has('unit-test')) {
@@ -75,16 +73,13 @@ export function createPlan(input = {}, cwd = process.cwd()) {
75
73
  }
76
74
  }
77
75
  files.set('eslint.config.ts', eslint)
78
- const oxlint = parse('.oxlintrc.json')
79
- if (!has('unit-test'))
80
- oxlint.plugins = oxlint.plugins.filter(p => p !== 'vitest')
81
- files.set('.oxlintrc.json', encode(oxlint))
82
76
  const settings = JSON.parse(fs.readFileSync(path.join(templateDir, 'features/code-quality/settings.fragment.json'), 'utf8'))
83
77
  files.set('.vscode/settings.json', encode({ ...parse('.vscode/settings.json'), ...settings }))
84
78
  extensions.recommendations.push('dbaeumer.vscode-eslint', 'EditorConfig.EditorConfig', 'oxc.oxc-vscode')
85
79
  }
86
80
  files.set('.vscode/extensions.json', encode(extensions))
87
81
  pkg.name = name
82
+ pkg.version = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version
88
83
  const scriptOrder = ['dev', 'build', 'preview', 'test:unit', 'test:e2e', 'build-only', 'type-check', 'lint', 'lint:oxlint', 'lint:eslint', 'format']
89
84
  pkg.scripts = Object.fromEntries(scriptOrder.filter(key => Object.hasOwn(pkg.scripts, key)).map(key => [key, pkg.scripts[key]]))
90
85
  for (const field of ['dependencies', 'devDependencies'])
@@ -96,7 +91,7 @@ export function createPlan(input = {}, cwd = process.cwd()) {
96
91
  if (!has(feature))
97
92
  readme = readme.replace(new RegExp(`### ${title}[\\s\\S]*?(?=\\n### |$)`), '')
98
93
  }
99
- files.set('README.md', `${readme.replace('# base', `# ${name}`).trimEnd()}\n\n已选功能:${options.features.map(f => featureLabels[f]).join('、') || '无'}\n`)
94
+ files.set('README.md', readme.replace('# base', `# ${name}`))
100
95
  return { target, options, files }
101
96
  }
102
97
  export function writePlan(plan) {
package/lib/options.js CHANGED
@@ -6,7 +6,7 @@ export function normalizeOptions(input = {}) {
6
6
  const features = input.features ?? []
7
7
  if (!Array.isArray(features) || features.some(f => !Object.hasOwn(featureLabels, f)))
8
8
  throw new Error('功能仅支持 code-quality、unit-test、e2e、jsx')
9
- return { location: input.location || '.', features: Object.keys(featureLabels).filter(f => features.includes(f)), install: Boolean(input.install) }
9
+ return { location: input.location || 'vue-project', features: Object.keys(featureLabels).filter(f => features.includes(f)), install: Boolean(input.install) }
10
10
  }
11
11
  export function assertTarget(target) {
12
12
  let current = target
@@ -48,6 +48,6 @@ export function parseArgs(args) {
48
48
  }
49
49
  if (locations.length > 1)
50
50
  throw new Error('只能指定一个创建目录')
51
- options.location = locations[0] || '.'
51
+ options.location = locations[0] || 'vue-project'
52
52
  return { options: normalizeOptions(options), yes }
53
53
  }
package/lib/prompts.js CHANGED
@@ -303,7 +303,7 @@ export function prompt({ title, choices, multiple = false, initial, defaultValue
303
303
 
304
304
  export async function collectOptions(previous = {}, ask = prompt) {
305
305
  const options = normalizeOptions(previous)
306
- options.location = await ask({ title: '项目创建位置', initial: options.location === '.' ? '' : options.location, defaultValue: '.', hint: '输入 my-vue-app:新建项目文件夹;输入 .:在当前目录创建;支持相对或绝对路径' }) || '.'
306
+ options.location = await ask({ title: '项目创建位置', initial: options.location === '.' ? '' : options.location, defaultValue: 'vue-project', hint: '输入 my-vue-app:新建项目文件夹;输入 .:在当前目录创建;支持相对或绝对路径' }) || 'vue-project'
307
307
  options.features = await ask({ title: '选择可选功能', multiple: true, choices: Object.entries(featureLabels).map(([value, label]) => ({ value, label })), initial: options.features, hint: 'Space 勾选,Enter 确认;可全部不选或全部选择' })
308
308
  options.install = await ask({ title: '是否立即安装依赖?', choices: [{ value: false, label: '暂不安装' }, { value: true, label: '立即安装' }], initial: options.install })
309
309
  console.log(summary(options))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dengzhibo/create-vue-template",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "private": false,
6
6
  "description": "Vue + Vite 应用脚手架,可选代码规范、单元测试和端到端测试",
7
7
  "main": "bin/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "base",
3
- "version": "0.0.0",
2
+ "name": "vue-project",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {