mvframe 1.0.5 → 1.0.7

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.cn.md CHANGED
@@ -163,7 +163,7 @@ yarn build
163
163
 
164
164
  ## 命令行:项目目录雏形(推荐)
165
165
 
166
- 在**空目录或已有 Vite 工程根目录**执行,生成 `src/views`、`src/component`、`src/api`、`src/assets/img`、`src/assets/style`、`src/router`、`src/pinia/chip`、`src/config` 及示例 `main.js` / `App.vue`(已 `app.use(mvframe, …)` 挂好路由、Pinia `storeChips`、config)。若不存在则附带 `index.html` 与 `vite.config.js`。
166
+ 在**空目录或已有 Vite 工程根目录**执行,生成 `src/views`、`src/component`、`src/api`、`src/assets/img`、`src/assets/style`、`src/router`、`src/pinia/chip`、`src/config` 及示例 `main.js` / `App.vue`(已 `app.use(mvframe, …)` 挂好路由、Pinia `storeChips`、config)。若不存在则附带 `index.html` 与 `vite.config.js`。会**合并** `package.json` 的 `dependencies` / `devDependencies`(与 Vite 模板一致;**同名包保留你原有版本**),最后请执行 **`yarn install`**;加 `--no-package-json` 可不改动 `package.json`。
167
167
 
168
168
  ```bash
169
169
  cd /path/to/your-app
@@ -171,6 +171,9 @@ node /path/to/mvframe/scripts/scaffold-app.js
171
171
  # 覆盖已有同名文件:
172
172
  node /path/to/mvframe/scripts/scaffold-app.js --force
173
173
 
174
+ # 不修改 package.json(仅生成源码与配置):
175
+ node /path/to/mvframe/scripts/scaffold-app.js --no-package-json
176
+
174
177
  # 安装 mvframe 后:
175
178
  yarn exec mvframe-init-app
176
179
  # 或:npx mvframe-init-app
package/README.md CHANGED
@@ -163,13 +163,16 @@ Production uses **library mode** with entry `src/index.js` and obfuscation-relat
163
163
 
164
164
  ## CLI: project skeleton
165
165
 
166
- From an **empty folder or existing Vite root**, generates `src/views`, `src/component`, `src/api`, `src/assets/img`, `src/assets/style`, `src/router`, `src/pinia/chip`, `src/config`, plus starter `main.js` / `App.vue` with `app.use(mvframe, …)` (routes, Pinia `storeChips`, config). Adds `index.html` and `vite.config.js` only if missing (use `--force` to overwrite).
166
+ From an **empty folder or existing Vite root**, generates `src/views`, `src/component`, `src/api`, `src/assets/img`, `src/assets/style`, `src/router`, `src/pinia/chip`, `src/config`, plus starter `main.js` / `App.vue` with `app.use(mvframe, …)` (routes, Pinia `storeChips`, config). Adds `index.html` and `vite.config.js` only if missing (use `--force` to overwrite). **Merges** `dependencies` / `devDependencies` into `package.json` (existing versions win for shared keys); use `--no-package-json` to skip. Then run **`yarn install`**.
167
167
 
168
168
  ```bash
169
169
  cd /path/to/your-app
170
170
  node /path/to/mvframe/scripts/scaffold-app.js
171
171
  node /path/to/mvframe/scripts/scaffold-app.js --force
172
172
 
173
+ # Skip package.json (only scaffold sources + Vite config):
174
+ node /path/to/mvframe/scripts/scaffold-app.js --no-package-json
175
+
173
176
  yarn exec mvframe-init-app
174
177
  # or: npx mvframe-init-app
175
178
  ```
package/dist/vendor.js CHANGED
@@ -63,7 +63,7 @@ const _ = /* @__PURE__ */ Object.assign({ "../component/BtnGroup/index.vue": v,
63
63
  }, w = {
64
64
  name: "Matt Avias Frame",
65
65
  copyright: "©2026",
66
- version: "1.0.5",
66
+ version: "1.0.7",
67
67
  author: "Matt Avias",
68
68
  date: "2026-02-26",
69
69
  /** Table 等表格默认;业务在 app.use(mvframe, { config }) 里覆盖 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mvframe",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "author": "matt avis",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -7,12 +7,15 @@
7
7
  * yarn exec mvframe-init-app
8
8
  *
9
9
  * 环境变量:MVFRAME_SCAFFOLD_TARGET=/path/to/project
10
+ *
11
+ * 选项:--no-package-json 不读不写 package.json(仅生成源码与 Vite 配置)
10
12
  */
11
13
 
12
14
  const fs = require("fs");
13
15
  const path = require("path");
14
16
 
15
17
  const FORCE = process.argv.includes("--force");
18
+ const NO_PKG = process.argv.includes("--no-package-json");
16
19
  const argPath = process.argv.find(
17
20
  (a, i) => i >= 2 && a !== "--force" && !a.startsWith("--"),
18
21
  );
@@ -31,6 +34,69 @@ function write(rel, content) {
31
34
  console.log("[mvframe-init] 写入", rel);
32
35
  }
33
36
 
37
+ /** 与 main.js / vite.config 模板一致;版本号与 mvframe 本仓库对齐思路,可随发布调整 */
38
+ // @vue/shared 为 Vue 3 内部包,传递依赖在部分包管理器下未提升时 Vite 解析失败,故写入直连依赖
39
+ const SCAFFOLD_DEPENDENCIES = {
40
+ vue: "^3.5.0",
41
+ "@vue/shared": "^3.5.0",
42
+ "vue-router": "^4.6.0",
43
+ pinia: "^3.0.0",
44
+ mvframe: "^1.0.0",
45
+ "element-plus": "^2.13.0",
46
+ };
47
+
48
+ const SCAFFOLD_DEV_DEPENDENCIES = {
49
+ vite: "^6.0.0",
50
+ "@vitejs/plugin-vue": "^5.2.0",
51
+ "sass-embedded": "^1.97.0",
52
+ "unplugin-auto-import": "^0.18.2",
53
+ };
54
+
55
+ /**
56
+ * 合并 package.json:保留原有字段与其它依赖;仅补足脚手架所需包。
57
+ * 同名依赖以目标项目已有版本为准({ ...建议, ...已有 })。
58
+ */
59
+ function mergePackageJson(projectRoot) {
60
+ const pkgPath = path.join(projectRoot, "package.json");
61
+ let pkg;
62
+
63
+ if (fs.existsSync(pkgPath)) {
64
+ try {
65
+ pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
66
+ } catch (e) {
67
+ console.warn("[mvframe-init] package.json 解析失败,跳过合并:", e.message);
68
+ return;
69
+ }
70
+ } else {
71
+ pkg = {
72
+ name: path.basename(projectRoot).replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "mvframe-app",
73
+ version: "0.1.0",
74
+ private: true,
75
+ type: "module",
76
+ scripts: {
77
+ dev: "vite",
78
+ build: "vite build",
79
+ preview: "vite preview",
80
+ },
81
+ };
82
+ console.log("[mvframe-init] 新建 package.json");
83
+ }
84
+
85
+ pkg.dependencies = {
86
+ ...SCAFFOLD_DEPENDENCIES,
87
+ ...(pkg.dependencies && typeof pkg.dependencies === "object" ? pkg.dependencies : {}),
88
+ };
89
+ pkg.devDependencies = {
90
+ ...SCAFFOLD_DEV_DEPENDENCIES,
91
+ ...(pkg.devDependencies && typeof pkg.devDependencies === "object"
92
+ ? pkg.devDependencies
93
+ : {}),
94
+ };
95
+
96
+ fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
97
+ console.log("[mvframe-init] 已合并 package.json 的 dependencies / devDependencies(已有版本优先)");
98
+ }
99
+
34
100
  function main() {
35
101
  if (!fs.existsSync(target)) {
36
102
  console.error("[mvframe-init] 目录不存在:", target);
@@ -351,14 +417,21 @@ export default defineConfig({
351
417
  "MVFRAME-SCAFFOLD.md",
352
418
  `# MVFrame 雏形已生成
353
419
 
354
- ## 依赖(若尚未安装)
420
+ ## 依赖
421
+
422
+ 初始化脚本会**合并**(不整文件覆盖)\`package.json\` 的 \`dependencies\` / \`devDependencies\`:**已声明的包保留你的版本号**,仅补上缺失项。然后执行:
355
423
 
356
424
  \`\`\`bash
357
- yarn add vue vue-router pinia mvframe element-plus
358
- yarn add -D vite @vitejs/plugin-vue sass-embedded unplugin-auto-import
425
+ yarn install
359
426
  \`\`\`
360
427
 
361
- 自动生成的 \`vite.config.js\` 已包含 \`unplugin-auto-import\`(与 mvframe 一致的 vue / vue-router 自动导入);类型声明默认输出为项目根目录 \`auto-imports.d.ts\`(\`dts: true\`)。
428
+ 若需跳过对 \`package.json\` 的修改:\`node scripts/scaffold-app.js --no-package-json\`。
429
+
430
+ 自动生成的 \`vite.config.js\` 已包含 \`unplugin-auto-import\`;\`dts: true\` 时类型默认写在项目根 \`auto-imports.d.ts\`。
431
+
432
+ ### 报错 \`Could not resolve '@vue/shared'\`
433
+
434
+ 这是 **Vue 3 自带的底层包**,一般不必手写;在 **pnpm / 严格 node_modules** 等环境下可能未被提升到可被 Vite 解析的位置。脚手架已在 \`dependencies\` 中合并 \`@vue/shared\`(与 \`vue\` 同主版本);老项目可手动执行 \`yarn add @vue/shared@^3.5\`。
362
435
 
363
436
  ## 样式
364
437
 
@@ -388,7 +461,13 @@ yarn exec mvframe-install-cursor-skill
388
461
  `,
389
462
  );
390
463
 
391
- console.log("[mvframe-init] 完成。请阅读 MVFRAME-SCAFFOLD.md 并安装依赖。");
464
+ if (!NO_PKG) {
465
+ mergePackageJson(target);
466
+ }
467
+
468
+ console.log(
469
+ "[mvframe-init] 完成。请阅读 MVFRAME-SCAFFOLD.md 并在项目根执行 yarn install(或 npm install)。",
470
+ );
392
471
  }
393
472
 
394
473
  main();