moyan-mfw-cli 1.1.6 → 1.1.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.
@@ -1 +1 @@
1
- {"name": "@internal/{{name}}-frontend", "version": "{{version}}", "type": "module", "main": "./src/index.ts", "exports": {".": {"types": "./src/index.d.ts", "import": "./src/index.mjs", "require": "./src/index.js"}}, "scripts": {"build": "vite build && vue-tsc --emitOnly", "typecheck": "vue-tsc --noEmit", "dev": "vite", "preview": "vite preview"}, "dependencies": {"moyan-mfw-base/frontend": "workspace:*", "@internal/{{name}}-shared": "workspace:*", "vue": "catalog:", "vue-router": "catalog:", "element-plus": "catalog:", "@element-plus/icons-vue": "catalog:"}, "devDependencies": {"@vitejs/plugin-vue": "catalog:", "@vitejs/plugin-vue-jsx": "catalog:", "vite": "catalog:", "vue-tsc": "catalog:", "typescript": "catalog:"}}
1
+ {"name": "@internal/{{name}}-frontend", "version": "{{version}}", "type": "module", "main": "./src/index.ts", "exports": {".": {"types": "./src/index.d.ts", "import": "./src/index.mjs", "require": "./src/index.js"}}, "scripts": {"build": "vite build && vue-tsc --emitOnly", "typecheck": "vue-tsc --noEmit", "dev": "vite", "preview": "vite preview", "verify-dist": "node ../../scripts/verify-dist.mjs"}, "dependencies": {"moyan-mfw-base/frontend": "workspace:*", "@internal/{{name}}-shared": "workspace:*", "vue": "catalog:", "vue-router": "catalog:", "element-plus": "catalog:", "@element-plus/icons-vue": "catalog:"}, "devDependencies": {"@vitejs/plugin-vue": "catalog:", "@vitejs/plugin-vue-jsx": "catalog:", "vite": "catalog:", "vue-tsc": "catalog:", "typescript": "catalog:"}}
@@ -1,13 +1,10 @@
1
1
  /**
2
2
  * @fileoverview {{displayName}}扩展包前端入口
3
+ * @description 从模块配置树构建路由,不依赖 import.meta.glob 扫描
3
4
  */
4
- import { buildExtensionRoutes } from 'moyan-mfw-base/frontend'
5
+ import { buildRoutesFromModuleTree } from 'moyan-mfw-base/frontend'
6
+ import {{pascalCase name}}ModuleConfig from './views/index'
5
7
 
6
- const allConfigs = import.meta.glob('./views/**/index.{ts,tsx}', {
7
- eager: true,
8
- import: 'default',
9
- })
10
-
11
- export const {{pascalCase name}}Routes = buildExtensionRoutes(allConfigs, '{{name}}', {
8
+ export const {{pascalCase name}}Routes = buildRoutesFromModuleTree({{pascalCase name}}ModuleConfig, '{{name}}', {
12
9
  namespaceName: '{{displayName}}',
13
10
  })
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @fileoverview {{displayName}}模块配置
3
+ * @description 树形菜单分组,children 承载子页面配置。新增页面时在此处添加 import。
4
+ */
5
+ import { defineModuleConfig } from 'moyan-mfw-base/frontend'
6
+ import type { PageConfig } from 'moyan-mfw-base/frontend'
7
+
8
+ const config = defineModuleConfig({
9
+ type: 'module',
10
+ name: '{{displayName}}',
11
+ icon: 'Menu',
12
+ order: 50,
13
+ })
14
+
15
+ export default { ...config, children: [] as PageConfig<string>[] }
@@ -2,15 +2,17 @@ import { defineConfig } from 'vite';
2
2
  import vue from '@vitejs/plugin-vue';
3
3
  import vueJsx from '@vitejs/plugin-vue-jsx';
4
4
  import { resolve } from 'path';
5
+ import { fixVueDefaultImport } from 'moyan-mfw-base/frontend/vite-helpers';
5
6
 
6
7
  export default defineConfig({
7
8
  root: '.',
8
- plugins: [vue(), vueJsx()],
9
+ plugins: [vue(), vueJsx(), fixVueDefaultImport()],
9
10
  resolve: {
10
11
  alias: {
11
12
  '@': resolve(__dirname, 'src'),
12
13
  'moyan-mfw-base/frontend/styles': resolve(__dirname, '../../../../base/src/frontend/src/styles'),
13
14
  'moyan-mfw-base/frontend': resolve(__dirname, '../../../../base/src/frontend/src/index.ts'),
15
+ 'moyan-mfw-base/frontend/vite-helpers': resolve(__dirname, '../../../../base/src/frontend/src/vite-helpers.ts'),
14
16
  'moyan-mfw-base/shared': resolve(__dirname, '../../../../base/src/shared/src/index.ts'),
15
17
  'moyan-mfw-extension-{{name}}/shared': resolve(__dirname, '../shared/src/index.ts'),
16
18
  },
@@ -1 +1 @@
1
- {"name": "moyan-mfw-extension-{{name}}", "version": "{{version}}", "description": "{{description}}", "private": true, "type": "module", "exports": {"./backend": {"import": "./src/backend/dist/index.js", "require": "./src/backend/dist/index.js", "types": "./src/backend/dist/index.d.ts"}, "./backend/*": {"import": "./src/backend/dist/*.js", "require": "./src/backend/dist/*", "types": "./src/backend/dist/*.d.ts"}, "./frontend": {"import": "./src/frontend/dist/index.mjs", "require": "./src/frontend/dist/index.mjs", "types": "./src/frontend/dist/index.d.ts"}, "./frontend/*": {"import": "./src/frontend/dist/*", "require": "./src/frontend/dist/*", "types": "./src/frontend/dist/*.d.ts"}, "./shared": {"import": "./src/shared/dist/index.js", "require": "./src/shared/dist/index.js", "types": "./src/shared/dist/index.d.ts"}, "./shared/*": {"import": "./src/shared/dist/*", "require": "./src/shared/dist/*", "types": "./src/shared/dist/*.d.ts"}}, "typesVersions": {"*": {"*": ["./src/*/dist/*.d.ts", "./src/*/dist/index.d.ts"]}}, "scripts": {"build:shared": "pnpm --filter @internal/{{name}}-shared build", "build:backend": "pnpm --filter moyan-mfw-base run build:shared && pnpm --filter moyan-mfw-base run build:backend && pnpm --filter @internal/{{name}}-backend build", "build:frontend": "pnpm --filter @internal/{{name}}-frontend build", "build": "pnpm run build:shared && pnpm run build:backend && pnpm run build:frontend", "dev:backend": "pnpm --filter @internal/{{name}}-backend dev", "dev:frontend": "pnpm --filter @internal/{{name}}-frontend dev", "typecheck:shared": "pnpm --filter @internal/{{name}}-shared typecheck", "typecheck:backend": "pnpm --filter @internal/{{name}}-backend typecheck", "typecheck:frontend": "pnpm --filter @internal/{{name}}-frontend typecheck", "typecheck": "pnpm run typecheck:shared && pnpm run typecheck:backend && pnpm run typecheck:frontend"}, "devDependencies": {"@internal/{{name}}-backend": "workspace:*", "@internal/{{name}}-frontend": "workspace:*", "@internal/{{name}}-shared": "workspace:*", "moyan-mfw-base": "workspace:*", "typescript": "catalog:"}}
1
+ {"name": "moyan-mfw-extension-{{name}}", "version": "{{version}}", "description": "{{description}}", "private": true, "type": "module", "exports": {"./backend": {"import": "./src/backend/dist/index.js", "require": "./src/backend/dist/index.js", "types": "./src/backend/dist/index.d.ts"}, "./backend/*": {"import": "./src/backend/dist/*.js", "require": "./src/backend/dist/*", "types": "./src/backend/dist/*.d.ts"}, "./frontend": {"import": "./src/frontend/dist/index.mjs", "require": "./src/frontend/dist/index.mjs", "types": "./src/frontend/dist/index.d.ts"}, "./frontend/*": {"import": "./src/frontend/dist/*", "require": "./src/frontend/dist/*", "types": "./src/frontend/dist/*.d.ts"}, "./shared": {"import": "./src/shared/dist/index.js", "require": "./src/shared/dist/index.js", "types": "./src/shared/dist/index.d.ts"}, "./shared/*": {"import": "./src/shared/dist/*", "require": "./src/shared/dist/*", "types": "./src/shared/dist/*.d.ts"}}, "typesVersions": {"*": {"*": ["./src/*/dist/*.d.ts", "./src/*/dist/index.d.ts"]}}, "scripts": {"build:shared": "pnpm --filter @internal/{{name}}-shared build", "build:backend": "pnpm --filter moyan-mfw-base run build:shared && pnpm --filter moyan-mfw-base run build:backend && pnpm --filter @internal/{{name}}-backend build", "build:frontend": "pnpm --filter @internal/{{name}}-frontend build", "build": "pnpm run build:shared && pnpm run build:backend && pnpm run build:frontend", "dev:backend": "pnpm --filter @internal/{{name}}-backend dev", "dev:frontend": "pnpm --filter @internal/{{name}}-frontend dev", "typecheck:shared": "pnpm --filter @internal/{{name}}-shared typecheck", "typecheck:backend": "pnpm --filter @internal/{{name}}-backend typecheck", "typecheck:frontend": "pnpm --filter @internal/{{name}}-frontend typecheck", "typecheck": "pnpm run typecheck:shared && pnpm run typecheck:backend && pnpm run typecheck:frontend", "verify:dist": "node scripts/verify-dist.mjs", "verify": "pnpm run verify:dist"}, "devDependencies": {"@internal/{{name}}-backend": "workspace:*", "@internal/{{name}}-frontend": "workspace:*", "@internal/{{name}}-shared": "workspace:*", "moyan-mfw-base": "workspace:*", "typescript": "catalog:"}}
@@ -0,0 +1,43 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const frontendDist = path.resolve(__dirname, '../src/frontend/dist');
7
+
8
+ const FAIL = '\x1b[31mFAIL\x1b[0m';
9
+ const PASS = '\x1b[32mPASS\x1b[0m';
10
+
11
+ const distFile = path.join(frontendDist, 'index.mjs');
12
+
13
+ if (!fs.existsSync(distFile)) {
14
+ console.log(`${FAIL} {{displayName}}: dist/index.mjs 缺失,请先运行 pnpm build`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const content = fs.readFileSync(distFile, 'utf-8');
19
+ let failed = 0;
20
+
21
+ if (/^import\s+\w+,\s*\{[\s\S]*?\}\s*from\s*["']vue["']/m.test(content)) {
22
+ console.log(` ${FAIL} no bare default import from "vue"`);
23
+ console.log(' → 检查 vite.config.mts 中是否配置了 fixVueDefaultImport 插件');
24
+ failed++;
25
+ } else {
26
+ console.log(` ${PASS} no bare default import from "vue"`);
27
+ }
28
+
29
+ if (!/Routes\b/.test(content)) {
30
+ console.log(` ${FAIL} exports Routes`);
31
+ console.log(' → 确保 src/index.ts 中正确导出 xxxRoutes');
32
+ failed++;
33
+ } else {
34
+ console.log(` ${PASS} exports Routes`);
35
+ }
36
+
37
+ console.log('');
38
+ if (failed > 0) {
39
+ console.log(`${FAIL} {{displayName}}: ${failed} 项检查未通过 — 阻塞发布`);
40
+ process.exit(1);
41
+ } else {
42
+ console.log(`${PASS} {{displayName}} dist 产物检查通过`);
43
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "moyan-mfw-cli",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "MFW framework CLI — extension scaffolding, validation, and publishing tools",
5
5
  "type": "module",
6
6
  "bin": {
7
- "mfw": "./bin/mfw.js"
7
+ "mfw": "bin/mfw.js"
8
8
  },
9
9
  "exports": {
10
10
  ".": {