moyan-mfw-cli 0.1.3 → 1.1.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/dist/index.cjs CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
@@ -1,27 +1,27 @@
1
- # {{displayName}}
2
-
3
- {{description}}
4
-
5
- ## 快速开始
6
-
7
- ```bash
8
- # 安装依赖
9
- pnpm install
10
-
11
- # 启动后端开发服务器
12
- pnpm dev:backend
13
-
14
- # 启动前端开发服务器
15
- pnpm dev:frontend
16
- ```
17
-
18
- ## 目录结构
19
-
20
- ```
21
- extension-{{name}}/
22
- ├── src/
23
- │ ├── backend/ # NestJS 后端
24
- │ ├── frontend/ # Vue3 前端
25
- │ └── shared/ # 共享类型与常量
26
- ├── database/migrations/
27
- ```
1
+ # {{displayName}}
2
+
3
+ {{description}}
4
+
5
+ ## 快速开始
6
+
7
+ ```bash
8
+ # 安装依赖
9
+ pnpm install
10
+
11
+ # 启动后端开发服务器
12
+ pnpm dev:backend
13
+
14
+ # 启动前端开发服务器
15
+ pnpm dev:frontend
16
+ ```
17
+
18
+ ## 目录结构
19
+
20
+ ```
21
+ extension-{{name}}/
22
+ ├── src/
23
+ │ ├── backend/ # NestJS 后端
24
+ │ ├── frontend/ # Vue3 前端
25
+ │ └── shared/ # 共享类型与常量
26
+ ├── database/migrations/
27
+ ```
@@ -1,10 +1,10 @@
1
- DB_HOST=localhost
2
- DB_PORT=3306
3
- DB_USERNAME=root
4
- DB_PASSWORD=root
5
- DB_NAME=moyan_{{name}}
6
- REDIS_HOST=localhost
7
- REDIS_PORT=6379
8
- JWT_SECRET=change-me-{{name}}-jwt-secret
9
- JWT_EXPIRES_IN=7d
10
- PORT=3001
1
+ DB_HOST=localhost
2
+ DB_PORT=3306
3
+ DB_USERNAME=root
4
+ DB_PASSWORD=root
5
+ DB_NAME=moyan_{{name}}
6
+ REDIS_HOST=localhost
7
+ REDIS_PORT=6379
8
+ JWT_SECRET=change-me-{{name}}-jwt-secret
9
+ JWT_EXPIRES_IN=7d
10
+ PORT=3001
@@ -1 +1 @@
1
- export * from './{{name}}.module'
1
+ export * from './{{name}}.module'
@@ -1,34 +1,34 @@
1
- /**
2
- * @fileoverview {{displayName}}扩展包后端独立启动入口
3
- */
4
- import { NestFactory } from '@nestjs/core'
5
- import { {{pascalCase name}}Module } from './{{name}}.module'
6
- import { createExtensionBackendApp } from 'moyan-mfw-base/backend'
7
-
8
- async function bootstrap() {
9
- const startTime = Date.now()
10
-
11
- console.log('[{{pascalCase name}}] ====== Bootstrap Start ======')
12
- console.log(`[{{pascalCase name}}] Node.js: ${process.version}`)
13
- console.log(`[{{pascalCase name}}] ENV: ${process.env.NODE_ENV ?? 'development'}`)
14
- console.log(`[{{pascalCase name}}] PORT: ${process.env.PORT ?? '3001 (default)'}`)
15
-
16
- try {
17
- const app = await createExtensionBackendApp({
18
- name: '{{name}}',
19
- module: {{pascalCase name}}Module,
20
- })
21
-
22
- const port = Number(process.env.PORT) || 3001
23
- await app.listen(port)
24
-
25
- const elapsed = ((Date.now() - startTime) / 1000).toFixed(2)
26
- console.log(`\n[{{pascalCase name}}] ✅ Server listening on http://localhost:${port} (${elapsed}s)`)
27
- } catch (error) {
28
- console.error('\n[{{pascalCase name}}] ❌ Bootstrap failed:')
29
- console.error(error)
30
- process.exit(1)
31
- }
32
- }
33
-
34
- bootstrap()
1
+ /**
2
+ * @fileoverview {{displayName}}扩展包后端独立启动入口
3
+ */
4
+ import { NestFactory } from '@nestjs/core'
5
+ import { {{pascalCase name}}Module } from './{{name}}.module'
6
+ import { createExtensionBackendApp } from 'moyan-mfw-base/backend'
7
+
8
+ async function bootstrap() {
9
+ const startTime = Date.now()
10
+
11
+ console.log('[{{pascalCase name}}] ====== Bootstrap Start ======')
12
+ console.log(`[{{pascalCase name}}] Node.js: ${process.version}`)
13
+ console.log(`[{{pascalCase name}}] ENV: ${process.env.NODE_ENV ?? 'development'}`)
14
+ console.log(`[{{pascalCase name}}] PORT: ${process.env.PORT ?? '3001 (default)'}`)
15
+
16
+ try {
17
+ const app = await createExtensionBackendApp({
18
+ name: '{{name}}',
19
+ module: {{pascalCase name}}Module,
20
+ })
21
+
22
+ const port = Number(process.env.PORT) || 3001
23
+ await app.listen(port)
24
+
25
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(2)
26
+ console.log(`\n[{{pascalCase name}}] ✅ Server listening on http://localhost:${port} (${elapsed}s)`)
27
+ } catch (error) {
28
+ console.error('\n[{{pascalCase name}}] ❌ Bootstrap failed:')
29
+ console.error(error)
30
+ process.exit(1)
31
+ }
32
+ }
33
+
34
+ bootstrap()
@@ -1,4 +1,4 @@
1
- import { Module } from '@nestjs/common'
2
-
3
- @Module({})
4
- export class {{pascalCase name}}Module {}
1
+ import { Module } from '@nestjs/common'
2
+
3
+ @Module({})
4
+ export class {{pascalCase name}}Module {}
@@ -1,8 +1,8 @@
1
- // @ts-check
2
- const { defineConfig } = require('moyan-api/config')
3
-
4
- module.exports = defineConfig({
5
- backendUrl: process.env.API_BASE_URL || 'http://localhost:3001',
6
- outputDir: './src/apis',
7
- namespace: '{{name}}',
8
- })
1
+ // @ts-check
2
+ const { defineConfig } = require('moyan-api/config')
3
+
4
+ module.exports = defineConfig({
5
+ backendUrl: process.env.API_BASE_URL || 'http://localhost:3001',
6
+ outputDir: './src/apis',
7
+ namespace: '{{name}}',
8
+ })
@@ -1,12 +1,12 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>{{displayName}}</title>
7
- </head>
8
- <body>
9
- <div id="app"></div>
10
- <script type="module" src="/src/main.ts"></script>
11
- </body>
12
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{displayName}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -1 +1 @@
1
- /// <reference types="vite/client" />
1
+ /// <reference types="vite/client" />
@@ -1,13 +1,13 @@
1
- /**
2
- * @fileoverview {{displayName}}扩展包前端入口
3
- */
4
- import { buildExtensionRoutes } from 'moyan-mfw-base/frontend'
5
-
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}}', {
12
- namespaceName: '{{displayName}}',
13
- })
1
+ /**
2
+ * @fileoverview {{displayName}}扩展包前端入口
3
+ */
4
+ import { buildExtensionRoutes } from 'moyan-mfw-base/frontend'
5
+
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}}', {
12
+ namespaceName: '{{displayName}}',
13
+ })
@@ -1,13 +1,13 @@
1
- /**
2
- * @fileoverview {{displayName}}扩展包前端自启动入口
3
- */
4
- import 'moyan-mfw-base/frontend/styles/base-admin.scss'
5
- import { createExtensionFrontendApp } from 'moyan-mfw-base/frontend'
6
- import { {{pascalCase name}}Routes } from './index'
7
-
8
- const app = createExtensionFrontendApp({
9
- name: '{{displayName}}',
10
- routes: {{pascalCase name}}Routes,
11
- })
12
-
13
- app.mount('#app')
1
+ /**
2
+ * @fileoverview {{displayName}}扩展包前端自启动入口
3
+ */
4
+ import 'moyan-mfw-base/frontend/styles/base-admin.scss'
5
+ import { createExtensionFrontendApp } from 'moyan-mfw-base/frontend'
6
+ import { {{pascalCase name}}Routes } from './index'
7
+
8
+ const app = createExtensionFrontendApp({
9
+ name: '{{displayName}}',
10
+ routes: {{pascalCase name}}Routes,
11
+ })
12
+
13
+ app.mount('#app')
@@ -1,30 +1,30 @@
1
- import { defineConfig } from 'vite';
2
- import vue from '@vitejs/plugin-vue';
3
- import vueJsx from '@vitejs/plugin-vue-jsx';
4
- import { resolve } from 'path';
5
-
6
- export default defineConfig({
7
- root: '.',
8
- plugins: [vue(), vueJsx()],
9
- resolve: {
10
- alias: {
11
- '@': resolve(__dirname, 'src'),
12
- 'moyan-mfw-base/frontend/styles': resolve(__dirname, '../../../../base/src/frontend/src/styles'),
13
- 'moyan-mfw-base/frontend': resolve(__dirname, '../../../../base/src/frontend/src/index.ts'),
14
- 'moyan-mfw-base/shared': resolve(__dirname, '../../../../base/src/shared/src/index.ts'),
15
- 'moyan-mfw-extension-{{name}}/shared': resolve(__dirname, '../shared/src/index.ts'),
16
- },
17
- },
18
- build: {
19
- outDir: '../../dist/frontend',
20
- lib: {
21
- entry: resolve(__dirname, 'src/index.ts'),
22
- formats: ['es'],
23
- fileName: () => 'index.mjs',
24
- },
25
- rollupOptions: {
26
- external: ['vue', 'vue-router', 'element-plus', '@element-plus/icons-vue', 'moyan-mfw-base/frontend', 'moyan-mfw-base/shared'],
27
- output: { exports: 'named' },
28
- },
29
- },
30
- });
1
+ import { defineConfig } from 'vite';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import vueJsx from '@vitejs/plugin-vue-jsx';
4
+ import { resolve } from 'path';
5
+
6
+ export default defineConfig({
7
+ root: '.',
8
+ plugins: [vue(), vueJsx()],
9
+ resolve: {
10
+ alias: {
11
+ '@': resolve(__dirname, 'src'),
12
+ 'moyan-mfw-base/frontend/styles': resolve(__dirname, '../../../../base/src/frontend/src/styles'),
13
+ 'moyan-mfw-base/frontend': resolve(__dirname, '../../../../base/src/frontend/src/index.ts'),
14
+ 'moyan-mfw-base/shared': resolve(__dirname, '../../../../base/src/shared/src/index.ts'),
15
+ 'moyan-mfw-extension-{{name}}/shared': resolve(__dirname, '../shared/src/index.ts'),
16
+ },
17
+ },
18
+ build: {
19
+ outDir: '../../dist/frontend',
20
+ lib: {
21
+ entry: resolve(__dirname, 'src/index.ts'),
22
+ formats: ['es'],
23
+ fileName: () => 'index.mjs',
24
+ },
25
+ rollupOptions: {
26
+ external: ['vue', 'vue-router', 'element-plus', '@element-plus/icons-vue', 'moyan-mfw-base/frontend', 'moyan-mfw-base/shared'],
27
+ output: { exports: 'named' },
28
+ },
29
+ },
30
+ });
@@ -1,12 +1,12 @@
1
- /**
2
- * @fileoverview {{displayName}}常量定义
3
- */
4
- export const LINK_TYPE = {
5
- IMAGE: 'image',
6
- URL: 'url',
7
- } as const
8
- export type LinkType = (typeof LINK_TYPE)[keyof typeof LINK_TYPE]
9
- export const LINK_TYPE_LABELS: Record<LinkType, string> = {
10
- image: '图片',
11
- url: '链接',
12
- }
1
+ /**
2
+ * @fileoverview {{displayName}}常量定义
3
+ */
4
+ export const LINK_TYPE = {
5
+ IMAGE: 'image',
6
+ URL: 'url',
7
+ } as const
8
+ export type LinkType = (typeof LINK_TYPE)[keyof typeof LINK_TYPE]
9
+ export const LINK_TYPE_LABELS: Record<LinkType, string> = {
10
+ image: '图片',
11
+ url: '链接',
12
+ }
@@ -1,8 +1,8 @@
1
- /**
2
- * @fileoverview {{displayName}}字典定义
3
- */
4
- import { DictMeta } from 'moyan-mfw-base/shared'
5
-
6
- export const {{pascalCase name}}Dict: DictMeta[] = [
7
- // TODO: 添加字典定义
8
- ]
1
+ /**
2
+ * @fileoverview {{displayName}}字典定义
3
+ */
4
+ import { DictMeta } from 'moyan-mfw-base/shared'
5
+
6
+ export const {{pascalCase name}}Dict: DictMeta[] = [
7
+ // TODO: 添加字典定义
8
+ ]
@@ -1,10 +1,10 @@
1
- /**
2
- * @fileoverview {{displayName}}共享类型定义
3
- */
4
- export type { LinkType } from './constants'
5
- export { LINK_TYPE, LINK_TYPE_LABELS } from './constants'
6
- export type { {{pascalCase name}}ItemType } from './types'
7
- export { {{pascalCase name}}Dict } from './dict'
8
- export { {{pascalCaseUpper name}}_PATHS } from './paths'
9
- export { {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES } from './permission-values'
10
- export type { {{pascalCase name}}PermissionName } from './permission-values'
1
+ /**
2
+ * @fileoverview {{displayName}}共享类型定义
3
+ */
4
+ export type { LinkType } from './constants'
5
+ export { LINK_TYPE, LINK_TYPE_LABELS } from './constants'
6
+ export type { {{pascalCase name}}ItemType } from './types'
7
+ export { {{pascalCase name}}Dict } from './dict'
8
+ export { {{pascalCaseUpper name}}_PATHS } from './paths'
9
+ export { {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES } from './permission-values'
10
+ export type { {{pascalCase name}}PermissionName } from './permission-values'
@@ -1,5 +1,5 @@
1
- /** {{displayName}} 路径常量 */
2
- export const {{pascalCaseUpper name}}_PATHS = {
3
- LIST: '/{{name}}',
4
- DETAIL: '/{{name}}/:id',
5
- } as const
1
+ /** {{displayName}} 路径常量 */
2
+ export const {{pascalCaseUpper name}}_PATHS = {
3
+ LIST: '/{{name}}',
4
+ DETAIL: '/{{name}}/:id',
5
+ } as const
@@ -1,3 +1,3 @@
1
- /** {{displayName}} 权限标签 */
2
- export const {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES = [] as const
3
- export type {{pascalCase name}}PermissionName = (typeof {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES)[number]
1
+ /** {{displayName}} 权限标签 */
2
+ export const {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES = [] as const
3
+ export type {{pascalCase name}}PermissionName = (typeof {{pascalCaseUpper name}}_EXTENSION_PERMISSION_VALUES)[number]
@@ -1,5 +1,5 @@
1
- /** {{displayName}} 业务类型定义 */
2
- export interface {{pascalCase name}}Item {
3
- id: number
4
- // TODO: 添加业务字段
5
- }
1
+ /** {{displayName}} 业务类型定义 */
2
+ export interface {{pascalCase name}}Item {
3
+ id: number
4
+ // TODO: 添加业务字段
5
+ }
package/package.json CHANGED
@@ -1,52 +1,48 @@
1
- {
2
- "name": "moyan-mfw-cli",
3
- "version": "0.1.3",
4
- "description": "MFW framework CLI — extension scaffolding, validation, and publishing tools",
5
- "type": "module",
6
- "bin": {
7
- "mfw": "./bin/mfw.js"
8
- },
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
14
- }
15
- },
16
- "files": [
17
- "bin/",
18
- "dist/",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "private": false,
23
- "scripts": {
24
- "dev": "tsx watch src/index.ts",
25
- "copy-templates": "node --input-type=module -e \"import fs from 'node:fs'; fs.cpSync('src/templates','dist/templates',{recursive:true})\"",
26
- "build": "tsup src/index.ts --format esm,cjs --dts --clean && pnpm copy-templates",
27
- "typecheck": "tsc --noEmit",
28
- "release:patch": "npm version patch && pnpm build && npm publish",
29
- "release:minor": "npm version minor && pnpm build && npm publish",
30
- "release:major": "npm version major && pnpm build && npm publish"
31
- },
32
- "dependencies": {
33
- "commander": "^12.0.0",
34
- "inquirer": "^9.2.0",
35
- "chalk": "^5.3.0",
36
- "handlebars": "^4.7.8",
37
- "semver": "^7.6.0",
38
- "glob": "^10.3.0",
39
- "execa": "^9.3.0",
40
- "prettier": "^3.4.0"
41
- },
42
- "devDependencies": {
43
- "tsup": "^8.0.0",
44
- "tsx": "^4.7.0",
45
- "typescript": "^5.7.3",
46
- "@types/inquirer": "^9.0.0",
47
- "@types/prettier": "^3.0.0"
48
- },
49
- "engines": {
50
- "node": ">=20.0.0"
51
- }
52
- }
1
+ {
2
+ "name": "moyan-mfw-cli",
3
+ "version": "1.1.2",
4
+ "description": "MFW framework CLI — extension scaffolding, validation, and publishing tools",
5
+ "type": "module",
6
+ "bin": {
7
+ "mfw": "./bin/mfw.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "bin/",
18
+ "dist/",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "dev": "tsx watch src/index.ts",
24
+ "copy-templates": "node --input-type=module -e \"import fs from 'node:fs'; fs.cpSync('src/templates','dist/templates',{recursive:true})\"",
25
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean && pnpm copy-templates",
26
+ "typecheck": "tsc --noEmit"
27
+ },
28
+ "dependencies": {
29
+ "commander": "^12.0.0",
30
+ "inquirer": "^9.2.0",
31
+ "chalk": "^5.3.0",
32
+ "handlebars": "^4.7.8",
33
+ "semver": "^7.6.0",
34
+ "glob": "^10.3.0",
35
+ "execa": "^9.3.0",
36
+ "prettier": "^3.4.0"
37
+ },
38
+ "devDependencies": {
39
+ "tsup": "^8.0.0",
40
+ "tsx": "^4.7.0",
41
+ "typescript": "^5.7.3",
42
+ "@types/inquirer": "^9.0.0",
43
+ "@types/prettier": "^3.0.0"
44
+ },
45
+ "engines": {
46
+ "node": ">=20.0.0"
47
+ }
48
+ }