moyan-mfw-cli 1.1.4 → 1.1.6
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 +14 -4
- package/dist/index.js +14 -4
- package/dist/templates/business/backend/package.json.hbs +2 -2
- package/dist/templates/business/frontend/package.json.hbs +2 -2
- package/dist/templates/business/frontend/src/components/Layout/components/HeaderCommonActions.vue.hbs +93 -0
- package/dist/templates/business/frontend/src/components/Layout/index.ts.hbs +1 -0
- package/dist/templates/business/frontend/src/env.d.ts.hbs +28 -0
- package/dist/templates/business/frontend/src/main.ts.hbs +10 -2
- package/dist/templates/business/package.json.hbs +8 -0
- package/dist/templates/business/shared/package.json.hbs +1 -1
- package/dist/templates/extension/frontend/src/main.ts.hbs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,15 @@ var fsSync = __toESM(require("fs"), 1);
|
|
|
60
60
|
var path2 = __toESM(require("path"), 1);
|
|
61
61
|
var import_node_url = require("url");
|
|
62
62
|
var import_meta = {};
|
|
63
|
+
var _currentDir = path2.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
64
|
+
function getCliVersion() {
|
|
65
|
+
const pkgPathProd = path2.resolve(_currentDir, "../package.json");
|
|
66
|
+
const pkgPathDev = path2.resolve(_currentDir, "../../package.json");
|
|
67
|
+
const pkgPath = fsSync.existsSync(pkgPathProd) ? pkgPathProd : pkgPathDev;
|
|
68
|
+
const raw = fsSync.readFileSync(pkgPath, "utf-8");
|
|
69
|
+
const pkg = JSON.parse(raw);
|
|
70
|
+
return pkg.version;
|
|
71
|
+
}
|
|
63
72
|
import_handlebars.default.registerHelper(
|
|
64
73
|
"pascalCase",
|
|
65
74
|
(str) => str.replace(/(^\w|-\w)/g, (c) => c.slice(-1).toUpperCase())
|
|
@@ -74,9 +83,8 @@ import_handlebars.default.registerHelper("pascalCaseUpper", (str) => {
|
|
|
74
83
|
});
|
|
75
84
|
import_handlebars.default.registerHelper("snakeCase", (str) => str.replace(/-/g, "_"));
|
|
76
85
|
function getTemplateDir(type) {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const srcTemplate = path2.resolve(currentDir, `../templates/${type}`);
|
|
86
|
+
const distTemplate = path2.resolve(_currentDir, `templates/${type}`);
|
|
87
|
+
const srcTemplate = path2.resolve(_currentDir, `../templates/${type}`);
|
|
80
88
|
if (fsSync.existsSync(distTemplate)) return distTemplate;
|
|
81
89
|
if (fsSync.existsSync(srcTemplate)) return srcTemplate;
|
|
82
90
|
return distTemplate;
|
|
@@ -208,6 +216,7 @@ Use --force to overwrite.`));
|
|
|
208
216
|
hasFrontend: answers.hasFrontend,
|
|
209
217
|
hasShared: answers.hasShared,
|
|
210
218
|
version: "0.1.0",
|
|
219
|
+
baseVersion: getCliVersion(),
|
|
211
220
|
year: (/* @__PURE__ */ new Date()).getFullYear()
|
|
212
221
|
};
|
|
213
222
|
const templateDir = getTemplateDir("extension");
|
|
@@ -303,6 +312,7 @@ Use --force to overwrite.`));
|
|
|
303
312
|
frontendPort: Number(answers.frontendPort),
|
|
304
313
|
className,
|
|
305
314
|
version: "0.1.0",
|
|
315
|
+
baseVersion: getCliVersion(),
|
|
306
316
|
year: (/* @__PURE__ */ new Date()).getFullYear()
|
|
307
317
|
};
|
|
308
318
|
const templateDir = getTemplateDir("business");
|
|
@@ -336,7 +346,7 @@ ${import_chalk2.default.yellow("\u26A0 \u9996\u6B21\u5B89\u88C5\u8BF7\u4F7F\u752
|
|
|
336
346
|
|
|
337
347
|
// src/index.ts
|
|
338
348
|
var program = new import_commander3.Command();
|
|
339
|
-
program.name("mfw").description("Moyan MFW Framework CLI").version(
|
|
349
|
+
program.name("mfw").description("Moyan MFW Framework CLI").version(getCliVersion());
|
|
340
350
|
var createCmd = new import_commander3.Command("create").description("Create a new extension or resource");
|
|
341
351
|
createCmd.addCommand(createCommand);
|
|
342
352
|
createCmd.addCommand(createBusinessCommand);
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,15 @@ import * as fs2 from "fs/promises";
|
|
|
36
36
|
import * as fsSync from "fs";
|
|
37
37
|
import * as path2 from "path";
|
|
38
38
|
import { fileURLToPath } from "url";
|
|
39
|
+
var _currentDir = path2.dirname(fileURLToPath(import.meta.url));
|
|
40
|
+
function getCliVersion() {
|
|
41
|
+
const pkgPathProd = path2.resolve(_currentDir, "../package.json");
|
|
42
|
+
const pkgPathDev = path2.resolve(_currentDir, "../../package.json");
|
|
43
|
+
const pkgPath = fsSync.existsSync(pkgPathProd) ? pkgPathProd : pkgPathDev;
|
|
44
|
+
const raw = fsSync.readFileSync(pkgPath, "utf-8");
|
|
45
|
+
const pkg = JSON.parse(raw);
|
|
46
|
+
return pkg.version;
|
|
47
|
+
}
|
|
39
48
|
Handlebars.registerHelper(
|
|
40
49
|
"pascalCase",
|
|
41
50
|
(str) => str.replace(/(^\w|-\w)/g, (c) => c.slice(-1).toUpperCase())
|
|
@@ -50,9 +59,8 @@ Handlebars.registerHelper("pascalCaseUpper", (str) => {
|
|
|
50
59
|
});
|
|
51
60
|
Handlebars.registerHelper("snakeCase", (str) => str.replace(/-/g, "_"));
|
|
52
61
|
function getTemplateDir(type) {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const srcTemplate = path2.resolve(currentDir, `../templates/${type}`);
|
|
62
|
+
const distTemplate = path2.resolve(_currentDir, `templates/${type}`);
|
|
63
|
+
const srcTemplate = path2.resolve(_currentDir, `../templates/${type}`);
|
|
56
64
|
if (fsSync.existsSync(distTemplate)) return distTemplate;
|
|
57
65
|
if (fsSync.existsSync(srcTemplate)) return srcTemplate;
|
|
58
66
|
return distTemplate;
|
|
@@ -184,6 +192,7 @@ Use --force to overwrite.`));
|
|
|
184
192
|
hasFrontend: answers.hasFrontend,
|
|
185
193
|
hasShared: answers.hasShared,
|
|
186
194
|
version: "0.1.0",
|
|
195
|
+
baseVersion: getCliVersion(),
|
|
187
196
|
year: (/* @__PURE__ */ new Date()).getFullYear()
|
|
188
197
|
};
|
|
189
198
|
const templateDir = getTemplateDir("extension");
|
|
@@ -279,6 +288,7 @@ Use --force to overwrite.`));
|
|
|
279
288
|
frontendPort: Number(answers.frontendPort),
|
|
280
289
|
className,
|
|
281
290
|
version: "0.1.0",
|
|
291
|
+
baseVersion: getCliVersion(),
|
|
282
292
|
year: (/* @__PURE__ */ new Date()).getFullYear()
|
|
283
293
|
};
|
|
284
294
|
const templateDir = getTemplateDir("business");
|
|
@@ -312,7 +322,7 @@ ${chalk2.yellow("\u26A0 \u9996\u6B21\u5B89\u88C5\u8BF7\u4F7F\u7528 --no-frozen-l
|
|
|
312
322
|
|
|
313
323
|
// src/index.ts
|
|
314
324
|
var program = new Command3();
|
|
315
|
-
program.name("mfw").description("Moyan MFW Framework CLI").version(
|
|
325
|
+
program.name("mfw").description("Moyan MFW Framework CLI").version(getCliVersion());
|
|
316
326
|
var createCmd = new Command3("create").description("Create a new extension or resource");
|
|
317
327
|
createCmd.addCommand(createCommand);
|
|
318
328
|
createCmd.addCommand(createBusinessCommand);
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"reflect-metadata": "catalog:",
|
|
29
29
|
"rxjs": "catalog:",
|
|
30
30
|
"typeorm": "catalog:",
|
|
31
|
-
"moyan-mfw-base": "^
|
|
32
|
-
"moyan-mfw-extension-ad": "^
|
|
31
|
+
"moyan-mfw-base": "^{{baseVersion}}",
|
|
32
|
+
"moyan-mfw-extension-ad": "^{{baseVersion}}",
|
|
33
33
|
"{{name}}-shared": "workspace:*"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"axios": "catalog:",
|
|
16
16
|
"element-plus": "catalog:",
|
|
17
17
|
"md-editor-v3": "catalog:",
|
|
18
|
-
"moyan-mfw-base": "^
|
|
19
|
-
"moyan-mfw-extension-ad": "^
|
|
18
|
+
"moyan-mfw-base": "^{{baseVersion}}",
|
|
19
|
+
"moyan-mfw-extension-ad": "^{{baseVersion}}",
|
|
20
20
|
"pinia": "catalog:",
|
|
21
21
|
"quill": "catalog:",
|
|
22
22
|
"vue": "catalog:",
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="header-actions">
|
|
3
|
+
<el-space :size="2">
|
|
4
|
+
<!-- 主题切换 -->
|
|
5
|
+
<div class="action-icon-btn" data-testid="header-theme-btn" @click="toggleTheme">
|
|
6
|
+
<el-icon :size="18">
|
|
7
|
+
<component :is="isDark ? Sunny : Moon" />
|
|
8
|
+
</el-icon>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<!-- 全屏切换 -->
|
|
12
|
+
<div class="action-icon-btn" data-testid="header-fullscreen-btn" @click="toggleFullscreen">
|
|
13
|
+
<el-icon :size="18">
|
|
14
|
+
<component :is="isFullscreen ? ScaleToOriginal : FullScreen" />
|
|
15
|
+
</el-icon>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<!-- 布局设置 -->
|
|
19
|
+
<div class="action-icon-btn" data-testid="header-settings-btn" @click="openLayoutSettings">
|
|
20
|
+
<el-icon :size="18"><Setting /></el-icon>
|
|
21
|
+
</div>
|
|
22
|
+
</el-space>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { Setting, Moon, Sunny, FullScreen, ScaleToOriginal } from '@element-plus/icons-vue';
|
|
28
|
+
import { ref, onMounted, onUnmounted } from 'vue';
|
|
29
|
+
|
|
30
|
+
const isDark = ref(false);
|
|
31
|
+
const isFullscreen = ref(false);
|
|
32
|
+
|
|
33
|
+
const toggleTheme = () => {
|
|
34
|
+
isDark.value = !isDark.value;
|
|
35
|
+
document.documentElement.classList.toggle('dark', isDark.value);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const toggleFullscreen = async () => {
|
|
39
|
+
if (!document.fullscreenElement) {
|
|
40
|
+
await document.documentElement.requestFullscreen();
|
|
41
|
+
isFullscreen.value = true;
|
|
42
|
+
} else {
|
|
43
|
+
await document.exitFullscreen();
|
|
44
|
+
isFullscreen.value = false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const openLayoutSettings = () => {
|
|
49
|
+
console.log('Open layout settings');
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
53
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
document.addEventListener('keydown', handleKeydown);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
onUnmounted(() => {
|
|
63
|
+
document.removeEventListener('keydown', handleKeydown);
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style scoped lang="scss">
|
|
68
|
+
.header-actions {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.action-icon-btn {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
color: rgba(255, 255, 255, 0.85);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
transition: all 0.2s ease;
|
|
80
|
+
border-radius: 4px;
|
|
81
|
+
padding: 4px;
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
background: rgba(255, 255, 255, 0.12);
|
|
86
|
+
color: #fff;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:active {
|
|
90
|
+
background: rgba(255, 255, 255, 0.18);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HeaderCommonActions } from './components/HeaderCommonActions.vue';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
import type { RouteRecordRaw } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
declare module 'moyan-mfw-base/frontend' {
|
|
5
|
+
export function createBaseAdminApp(options: unknown): {
|
|
6
|
+
fetchPermissionValues(): Promise<unknown[]>
|
|
7
|
+
initPermissionCache(values: unknown[]): void
|
|
8
|
+
initPermissionValues(values: unknown[]): void
|
|
9
|
+
mount(selector: string): Promise<void>
|
|
10
|
+
}
|
|
11
|
+
export function registerPermissionValues(values: unknown[]): void
|
|
12
|
+
export function definePageConfig(config: unknown): unknown
|
|
13
|
+
export function buildRoutesFromConfigs(configs: unknown[], ctx?: unknown): RouteRecordRaw[]
|
|
14
|
+
export function createBusinessPageConfigFn(permPrefix: string): (page: unknown) => unknown
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module 'moyan-mfw-base/frontend/style.css' {
|
|
18
|
+
const content: string
|
|
19
|
+
export default content
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module 'moyan-mfw-extension-ad/frontend' {
|
|
23
|
+
export const adRoutes: RouteRecordRaw[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module 'moyan-mfw-extension-ad/shared' {
|
|
27
|
+
export const AD_EXTENSION_PERMISSION_VALUES: bigint[]
|
|
28
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { createBaseAdminApp } from 'moyan-mfw-base/frontend'
|
|
1
|
+
import { createBaseAdminApp, registerPermissionValues } from 'moyan-mfw-base/frontend'
|
|
2
|
+
import { HeaderCommonActions } from './components/Layout'
|
|
2
3
|
import { businessRoutes } from './router'
|
|
4
|
+
import { adRoutes } from 'moyan-mfw-extension-ad/frontend'
|
|
5
|
+
import { AD_EXTENSION_PERMISSION_VALUES } from 'moyan-mfw-extension-ad/shared'
|
|
3
6
|
import './permissions'
|
|
4
7
|
|
|
8
|
+
registerPermissionValues([...AD_EXTENSION_PERMISSION_VALUES])
|
|
9
|
+
|
|
5
10
|
const admin = createBaseAdminApp({
|
|
6
11
|
title: '{{displayName}}',
|
|
7
|
-
routes: [...businessRoutes],
|
|
12
|
+
routes: [...businessRoutes, ...adRoutes],
|
|
8
13
|
layout: {
|
|
9
14
|
layoutMode: 'dual',
|
|
10
15
|
showTabs: true,
|
|
@@ -16,6 +21,9 @@ const admin = createBaseAdminApp({
|
|
|
16
21
|
brandTagline: '{{description}}',
|
|
17
22
|
homePath: '/dashboard',
|
|
18
23
|
},
|
|
24
|
+
layoutExtensions: {
|
|
25
|
+
headerCommon: HeaderCommonActions,
|
|
26
|
+
},
|
|
19
27
|
})
|
|
20
28
|
|
|
21
29
|
const values = await admin.fetchPermissionValues()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview {{displayName}}扩展包前端自启动入口
|
|
3
3
|
*/
|
|
4
|
-
import 'moyan-mfw-base/frontend/
|
|
4
|
+
import 'moyan-mfw-base/frontend/style.css'
|
|
5
5
|
import { createExtensionFrontendApp } from 'moyan-mfw-base/frontend'
|
|
6
6
|
import { {{pascalCase name}}Routes } from './index'
|
|
7
7
|
|