create-pubinfo 2.0.0-beta.3 → 2.0.0-beta.30

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.
Files changed (69) hide show
  1. package/dist/index.js +187 -129
  2. package/package.json +8 -7
  3. package/templates/pubinfo-template/.browserslistrc +5 -0
  4. package/templates/pubinfo-template/.editorconfig +10 -0
  5. package/templates/pubinfo-template/.env +12 -0
  6. package/templates/pubinfo-template/.env.development +6 -0
  7. package/templates/pubinfo-template/.env.production +10 -0
  8. package/templates/pubinfo-template/_gitignore +37 -0
  9. package/templates/pubinfo-template/_npmrc +5 -0
  10. package/templates/pubinfo-template/commitlint.config.js +66 -0
  11. package/templates/pubinfo-template/eslint.config.ts +3 -0
  12. package/templates/pubinfo-template/index.html +47 -0
  13. package/templates/pubinfo-template/openapi.config.ts +33 -0
  14. package/templates/pubinfo-template/package.json +53 -0
  15. package/templates/pubinfo-template/pubinfo.config.ts +9 -0
  16. package/templates/pubinfo-template/public/browser_upgrade/chrome.png +0 -0
  17. package/templates/pubinfo-template/public/browser_upgrade/edge.png +0 -0
  18. package/templates/pubinfo-template/public/browser_upgrade/index.css +49 -0
  19. package/templates/pubinfo-template/public/loading.css +92 -0
  20. package/templates/pubinfo-template/src/App.vue +7 -0
  21. package/templates/pubinfo-template/src/api/modules/auth/index.ts +3 -0
  22. package/templates/pubinfo-template/src/api/modules/auth/renzhengfuwu.ts +145 -0
  23. package/templates/pubinfo-template/src/api/modules/auth/typings.d.ts +97 -0
  24. package/templates/pubinfo-template/src/api/request.ts +124 -0
  25. package/templates/pubinfo-template/src/assets/icons/logo.svg +1 -0
  26. package/templates/pubinfo-template/src/assets/icons/process-management.svg +1 -0
  27. package/templates/pubinfo-template/src/assets/icons/workbench.svg +1 -0
  28. package/templates/pubinfo-template/src/assets/images/login-bg.webp +0 -0
  29. package/templates/pubinfo-template/src/assets/images/login-bg_dark.webp +0 -0
  30. package/templates/pubinfo-template/src/assets/images/login-small.png +0 -0
  31. package/templates/pubinfo-template/src/assets/images/login-small_dark.webp +0 -0
  32. package/templates/pubinfo-template/src/components/UIProvider/index.vue +51 -0
  33. package/templates/pubinfo-template/src/layouts/index.vue +38 -0
  34. package/templates/pubinfo-template/src/main.ts +25 -0
  35. package/templates/pubinfo-template/src/modules/auth.ts +21 -0
  36. package/templates/pubinfo-template/src/modules/rbac.ts +52 -0
  37. package/templates/pubinfo-template/src/routes/index.ts +71 -0
  38. package/templates/pubinfo-template/src/routes/modules/demo/breadcrumb.example.ts +62 -0
  39. package/templates/pubinfo-template/src/routes/modules/demo/link.ts +15 -0
  40. package/templates/pubinfo-template/src/routes/modules/demo/multilevel.menu.example.ts +68 -0
  41. package/templates/pubinfo-template/src/routes/modules/demo/other.page.ts +37 -0
  42. package/templates/pubinfo-template/src/routes/modules/demo/single.ts +14 -0
  43. package/templates/pubinfo-template/src/settings.ts +8 -0
  44. package/templates/pubinfo-template/src/stores/index.ts +2 -0
  45. package/templates/pubinfo-template/src/stores/modules/conter.ts +16 -0
  46. package/templates/pubinfo-template/src/views/demo/breadcrumb_example/detail1.vue +11 -0
  47. package/templates/pubinfo-template/src/views/demo/breadcrumb_example/detail2.vue +11 -0
  48. package/templates/pubinfo-template/src/views/demo/breadcrumb_example/list1.vue +11 -0
  49. package/templates/pubinfo-template/src/views/demo/breadcrumb_example/list2.vue +11 -0
  50. package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/level3/page1.vue +11 -0
  51. package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/level3/page2.vue +11 -0
  52. package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/page.vue +11 -0
  53. package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/page.vue +11 -0
  54. package/templates/pubinfo-template/src/views/demo/other_page/des.vue +13 -0
  55. package/templates/pubinfo-template/src/views/demo/other_page/index.vue +25 -0
  56. package/templates/pubinfo-template/src/views/demo/preview-empty/index.vue +17 -0
  57. package/templates/pubinfo-template/src/views/demo/single/index.vue +13 -0
  58. package/templates/pubinfo-template/src/views/system/index.vue +5 -0
  59. package/templates/pubinfo-template/src/views/system/login/components/LoginForm.vue +68 -0
  60. package/templates/pubinfo-template/src/views/system/login/components/LoginWithPhone.vue +213 -0
  61. package/templates/pubinfo-template/src/views/system/login/components/PasswordLogin.vue +214 -0
  62. package/templates/pubinfo-template/src/views/system/login/components/Savephone.vue +17 -0
  63. package/templates/pubinfo-template/src/views/system/login/components/Useragreement.vue +26 -0
  64. package/templates/pubinfo-template/src/views/system/login/composables.ts +84 -0
  65. package/templates/pubinfo-template/src/views/system/login/index.vue +165 -0
  66. package/templates/pubinfo-template/stylelint.config.js +3 -0
  67. package/templates/pubinfo-template/tsconfig.json +3 -0
  68. package/templates/pubinfo-template/uno.config.ts +17 -0
  69. package/dist/index.cjs +0 -364
@@ -0,0 +1,165 @@
1
+ <script setup lang="ts">
2
+ import LoginFrom from './components/LoginForm.vue';
3
+
4
+ defineOptions({
5
+ name: 'Login',
6
+ });
7
+
8
+ const title = ref(import.meta.env.VITE_APP_TITLE);
9
+
10
+ const designDescription = [
11
+ {
12
+ title: '快速',
13
+ description: '快速搭建技术中台系统',
14
+ },
15
+ {
16
+ title: '灵活',
17
+ description: '灵活配置系统功能',
18
+ },
19
+ {
20
+ title: '便捷',
21
+ description: '高效提升系统开发效率',
22
+ },
23
+ ];
24
+ </script>
25
+
26
+ <template>
27
+ <div class="warp">
28
+ <div class="warp-blank">
29
+ <div
30
+ relative
31
+ top="7vh"
32
+ left="5vw"
33
+ scale="100 sm:100 smd:100 md:100 xl:110 2xl:120"
34
+ transform-origin="top-left"
35
+ transition-all
36
+ hidden
37
+ smd:block
38
+ >
39
+ <div class="logo-group">
40
+ <PubinfoIcon
41
+ name="logo"
42
+ color="transparent"
43
+ mr="10px"
44
+ :size="32"
45
+ />
46
+ <span text="black dark:[#C9D6EF]">{{ title }}</span>
47
+ </div>
48
+ <div class="title-group">
49
+ <span text="black dark:[#C9D6EF]">一体化技术架构 一站式技术支撑</span>
50
+ <div flex="~ row" mt="30px">
51
+ <div
52
+ v-for="(item, index) in designDescription"
53
+ :key="index"
54
+ w-84px
55
+ h-36px
56
+ bg="#2F6BFF"
57
+ rounded-20px
58
+ text="20px #F7F7F7 dark:[#fff]"
59
+ font-normal
60
+ flex="~ center"
61
+ mr="15px"
62
+ >
63
+ {{ item.title }}
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <div
70
+ h-full
71
+ bg="[rgba(255,255,255,0.1)] smd:[rgba(255,255,255,1)] dark:[#0F1E3B]"
72
+ backdrop-blur-sm
73
+ w="full smd:1/2 xl:800px 2xl:900px"
74
+ transition-all
75
+ flex="~ col"
76
+ justify-between
77
+ pb="40px"
78
+ relative
79
+ >
80
+ <div
81
+ smd:hidden
82
+ flex="~ row center"
83
+ w-full
84
+ h-200px
85
+ absolute
86
+ disable="none"
87
+ >
88
+ <PubinfoIcon
89
+ name="logo"
90
+ color="transparent"
91
+ :size="42"
92
+ mr-15px
93
+ />
94
+ <span text="33px" font="bold">{{ title }}</span>
95
+ </div>
96
+ <div
97
+ w-full
98
+ flex="~"
99
+ justify-center
100
+ pt="20vh"
101
+ >
102
+ <LoginFrom />
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </template>
107
+
108
+ <style lang="scss" scoped>
109
+ .warp {
110
+ position: relative;
111
+ display: flex;
112
+ flex-direction: row;
113
+ width: 100%;
114
+ height: 100%;
115
+ overflow: hidden;
116
+ background: url("@/assets/images/login-bg.webp") no-repeat;
117
+ background-size: cover;
118
+
119
+ .warp-blank {
120
+ flex: auto;
121
+ flex-basis: 0;
122
+ overflow: hidden;
123
+ }
124
+
125
+ .logo-group {
126
+ display: flex;
127
+ flex-direction: row;
128
+ align-items: center;
129
+ height: 33px;
130
+ margin-bottom: 35px;
131
+ font-size: 24px;
132
+ font-weight: 400;
133
+ color: #151e26;
134
+ }
135
+
136
+ .title-group {
137
+ height: 52px;
138
+ font-size: 38px;
139
+ font-weight: 800;
140
+ color: #072347;
141
+ letter-spacing: 1.5px;
142
+ }
143
+ }
144
+
145
+ @media (width < 1024px) {
146
+ .warp {
147
+ background: url("@/assets/images/login-small.png") no-repeat left;
148
+ background-size: cover;
149
+ }
150
+ }
151
+
152
+ [data-theme="dark"] {
153
+ .warp {
154
+ background: url("@/assets/images/login-bg_dark.webp") no-repeat;
155
+ background-size: cover;
156
+ }
157
+
158
+ @media (width < 1024px) {
159
+ .warp {
160
+ background: url("@/assets/images/login-small_dark.webp") no-repeat left;
161
+ background-size: cover;
162
+ }
163
+ }
164
+ }
165
+ </style>
@@ -0,0 +1,3 @@
1
+ export default {
2
+ extends: ['pubinfo/stylelint'],
3
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./.pubinfo/tsconfig.app.json"
3
+ }
@@ -0,0 +1,17 @@
1
+ import { presetUnocss } from 'pubinfo/node';
2
+ import { defineConfig } from 'unocss';
3
+
4
+ export default defineConfig({
5
+ presets: [
6
+ presetUnocss(),
7
+ ],
8
+
9
+ content: {
10
+ pipeline: {
11
+ include: [
12
+ /\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
13
+ 'src/routes/**/*.ts',
14
+ ],
15
+ },
16
+ },
17
+ });
package/dist/index.cjs DELETED
@@ -1,364 +0,0 @@
1
- #!/usr/bin/env node
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
- // src/index.ts
26
- var import_commander = require("commander");
27
- var import_consola6 = __toESM(require("consola"), 1);
28
-
29
- // package.json
30
- var package_default = {
31
- name: "create-pubinfo",
32
- type: "module",
33
- version: "2.0.0-beta.3",
34
- description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
35
- author: "Werheng <werheng.zhang@gmail.com>",
36
- license: "MIT",
37
- bin: {
38
- pubinfo: "./dist/index.js"
39
- },
40
- files: [
41
- "dist"
42
- ],
43
- scripts: {
44
- dev: "tsup --watch src",
45
- build: "tsup",
46
- cli: "tsx src/index.ts",
47
- "cli:clean": "rimraf ./my-app",
48
- lint: "eslint . --cache --fix"
49
- },
50
- dependencies: {
51
- "@inquirer/prompts": "^5.5.0",
52
- "ansi-colors": "^4.1.3",
53
- cfonts: "^3.3.0",
54
- commander: "^12.1.0",
55
- confbox: "^0.1.8",
56
- consola: "^3.4.0",
57
- giget: "^1.2.5",
58
- ofetch: "^1.4.1",
59
- ora: "^8.2.0",
60
- rimraf: "^6.0.1",
61
- semver: "^7.7.1"
62
- },
63
- devDependencies: {
64
- "@types/node": "^22.13.9",
65
- tsup: "^8.4.0"
66
- }
67
- };
68
-
69
- // src/command/init.ts
70
- var import_node_fs2 = require("fs");
71
- var import_node_process2 = __toESM(require("process"), 1);
72
- var import_prompts = require("@inquirer/prompts");
73
- var import_ansi_colors = __toESM(require("ansi-colors"), 1);
74
- var import_consola3 = __toESM(require("consola"), 1);
75
-
76
- // src/constant.ts
77
- var REMOTE_URL = "http://124.223.184.245:20000/templates";
78
- var PKG_NAME = "monorepo-project-template";
79
- var VERSION_FILE = "version.json";
80
- var SETTING_FILE_PATH = "src/settings.default.ts";
81
- var OPENAPI_FILE_PATH = "openapi.config.ts";
82
- var APPS_DIR = "apps";
83
- var APPS = [
84
- { name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
85
- // { name: '初始化项目模板(admin)', value: 'admin' },
86
- ];
87
- var METADATA_DIR = "configs/metadata";
88
- var META_FILENAME = "pubinfo.json";
89
-
90
- // src/fetch.ts
91
- var import_node_process = __toESM(require("process"), 1);
92
- var import_consola = __toESM(require("consola"), 1);
93
- var import_ofetch = require("ofetch");
94
- var import_ora = __toESM(require("ora"), 1);
95
- var import_semver = require("semver");
96
- async function fetchVersion() {
97
- const versions = await (0, import_ofetch.ofetch)(`${REMOTE_URL}/${VERSION_FILE}`);
98
- versions.sort((v1, v2) => -(0, import_semver.compare)(v1, v2));
99
- return {
100
- latest: versions[0],
101
- list: versions
102
- };
103
- }
104
- async function fetchData() {
105
- const spinner = (0, import_ora.default)({
106
- text: "\u68C0\u6D4B\u7F51\u7EDC\u8FDE\u63A5...",
107
- color: "blue"
108
- });
109
- spinner.start();
110
- try {
111
- const version = await fetchVersion();
112
- return {
113
- version
114
- };
115
- } catch (error) {
116
- if (error.message.includes(REMOTE_URL)) {
117
- error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
118
- }
119
- import_consola.default.error(`\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38: ${error.message}`);
120
- import_node_process.default.exit(1);
121
- } finally {
122
- spinner.stop();
123
- }
124
- }
125
-
126
- // src/utils.ts
127
- var import_node_fs = require("fs");
128
- var import_promises = require("fs/promises");
129
- var import_confbox = require("confbox");
130
- var import_consola2 = __toESM(require("consola"), 1);
131
- function rewriteFile(path, fn) {
132
- if (!(0, import_node_fs.existsSync)(path)) {
133
- import_consola2.default.error(`RewriteFile fail: ${path} does not exist`);
134
- return;
135
- }
136
- try {
137
- const content = (0, import_node_fs.readFileSync)(path, { encoding: "utf-8" });
138
- (0, import_node_fs.writeFileSync)(path, fn(content));
139
- } catch (error) {
140
- import_consola2.default.error(`RewriteFile fail: ${error}`);
141
- }
142
- }
143
- async function readJSON(path) {
144
- const blob = await (0, import_promises.readFile)(path, "utf-8");
145
- let parsed;
146
- try {
147
- parsed = (0, import_confbox.parseJSON)(blob);
148
- } catch {
149
- parsed = (0, import_confbox.parseJSONC)(blob);
150
- }
151
- return parsed;
152
- }
153
- async function writeJSON(path, json) {
154
- await (0, import_promises.writeFile)(path, (0, import_confbox.stringifyJSON)(json));
155
- }
156
- function assignValues(target, source) {
157
- for (const [key, value] of Object.entries(source)) {
158
- target[key] = value;
159
- }
160
- }
161
- function validateInput(input2) {
162
- const forbiddenChars = /[<>:"/\\|?*\s]/;
163
- if (forbiddenChars.test(input2)) {
164
- return '\u9519\u8BEF\u63D0\u793A: \u8BE5\u503C\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u8005\u975E\u6CD5\u5B57\u7B26 (\u4F8B\u5982, <>:"/\\|?*).';
165
- }
166
- return true;
167
- }
168
-
169
- // src/command/init.ts
170
- async function init() {
171
- const { version } = await fetchData();
172
- const answer = {};
173
- try {
174
- answer.dir = await (0, import_prompts.input)({ message: "\u76EE\u5F55\u540D\u79F0\uFF08dir\uFF09", default: "my-app", validate: validateInput });
175
- answer.key = await (0, import_prompts.input)({ message: "\u9879\u76EE\u6807\u8BC6\uFF08key\uFF09", default: answer.dir, validate: validateInput });
176
- if ((0, import_node_fs2.existsSync)(answer.dir)) {
177
- const overwrite = await (0, import_prompts.confirm)({ message: `\u76EE\u5F55 ${import_ansi_colors.default.cyan(answer.dir)} \u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6\uFF1F` });
178
- if (!overwrite) {
179
- throw Error;
180
- }
181
- }
182
- answer.version = await (0, import_prompts.input)({
183
- message: "\u6846\u67B6\u7248\u672C\u53F7\uFF08version\uFF09",
184
- default: version.latest,
185
- validate: (input2) => {
186
- if (!version.list.includes(input2)) {
187
- return `\u7248\u672C\u53F7: ${import_ansi_colors.default.bold(input2)} \u4E0D\u5B58\u5728, \u5F53\u524D\u6700\u65B0\u7248\u672C\u53F7: ${import_ansi_colors.default.bold(version.latest)}.`;
188
- }
189
- return true;
190
- }
191
- });
192
- answer.apps = await (0, import_prompts.checkbox)({
193
- message: "\u9009\u62E9\u5E94\u7528\u6A21\u5757\uFF08apps\uFF09",
194
- choices: APPS,
195
- validate: (input2) => {
196
- if (input2.length === 0) {
197
- return "\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E94\u7528";
198
- }
199
- return true;
200
- }
201
- });
202
- answer.openapi = await (0, import_prompts.confirm)({
203
- message: "\u8FD0\u884C\u65F6\u81EA\u52A8\u751F\u6210\u63A5\u53E3\u5BF9\u63A5\u6587\u4EF6\uFF0C\u82E5\u5173\u95ED\u53EF\u901A\u8FC7\u6307\u4EE4\u751F\u6210\uFF08openapi\uFF09",
204
- default: false
205
- });
206
- return answer;
207
- } catch {
208
- import_consola3.default.fail("\u64CD\u4F5C\u7EC8\u6B62");
209
- import_node_process2.default.exit(1);
210
- }
211
- }
212
-
213
- // src/download.ts
214
- var import_node_process3 = __toESM(require("process"), 1);
215
- var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
216
- var import_consola4 = __toESM(require("consola"), 1);
217
- var import_giget = require("giget");
218
- var import_ora2 = __toESM(require("ora"), 1);
219
- var import_semver2 = require("semver");
220
- var pubinfo = async (input2, { auth }) => {
221
- const semver = (0, import_semver2.coerce)(input2);
222
- return {
223
- name: "pubinfo",
224
- version: input2,
225
- headers: { Authorization: `token ${auth}` },
226
- tar: `${REMOTE_URL}/${PKG_NAME}-${semver?.version}.tar.gz`
227
- };
228
- };
229
- async function download(options) {
230
- const finish = loading();
231
- try {
232
- await (0, import_giget.downloadTemplate)(`pubinfo:${PKG_NAME}-${options.version}`, {
233
- providers: { pubinfo },
234
- force: true,
235
- forceClean: true,
236
- // auth: options.auth,
237
- dir: options.dir
238
- });
239
- } catch (error) {
240
- if (error.message.includes(REMOTE_URL)) {
241
- error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
242
- }
243
- import_consola4.default.error(`\u4E0B\u8F7D\u5931\u8D25: ${error.message}`);
244
- import_node_process3.default.exit(1);
245
- } finally {
246
- finish();
247
- }
248
- }
249
- function loading() {
250
- const startTime = Date.now();
251
- const spinner = (0, import_ora2.default)({
252
- text: "\u4E0B\u8F7D\u4E2D...",
253
- color: "green"
254
- });
255
- spinner.start();
256
- return () => {
257
- const { green, yellow } = import_ansi_colors2.default;
258
- spinner.stop();
259
- import_consola4.default.success(`${green("\u4E0B\u8F7D\u5B8C\u6210, \u7528\u65F6")} ${yellow(`${Date.now() - startTime}`)} ${green("ms.")}`);
260
- };
261
- }
262
-
263
- // src/log.ts
264
- var import_cfonts = __toESM(require("cfonts"), 1);
265
- function bootstrop() {
266
- printLoGo("PUBINFO");
267
- function printLoGo(logo) {
268
- import_cfonts.default.say(logo, {
269
- font: "simple3d",
270
- align: "left",
271
- background: "transparent",
272
- letterSpacing: 1,
273
- lineHeight: 1,
274
- space: true,
275
- maxLength: 0,
276
- spaceless: false,
277
- gradient: ["blue", "magenta"],
278
- independentGradient: false,
279
- transitionGradient: false,
280
- env: "node"
281
- });
282
- }
283
- }
284
-
285
- // src/rewrite.ts
286
- var import_node_fs3 = require("fs");
287
- var import_node_path = require("path");
288
- var import_node_process4 = __toESM(require("process"), 1);
289
- var import_consola5 = __toESM(require("consola"), 1);
290
- var import_rimraf = require("rimraf");
291
- async function rewrite(options) {
292
- const { dir } = options;
293
- const root = import_node_process4.default.cwd();
294
- const projectDir = (0, import_node_path.resolve)(root, dir);
295
- writeMetaJSON((0, import_node_path.resolve)(projectDir, METADATA_DIR), options);
296
- writeApps((0, import_node_path.resolve)(projectDir, APPS_DIR), options);
297
- }
298
- async function writeMetaJSON(metaDir, options) {
299
- const { key, version, apps, openapi } = options;
300
- const path = (0, import_node_path.resolve)(metaDir, META_FILENAME);
301
- try {
302
- const json = await readJSON(path);
303
- assignValues(json, {
304
- key,
305
- version,
306
- apps,
307
- openapi
308
- });
309
- await writeJSON(path, json);
310
- } catch (error) {
311
- import_consola5.default.error(`\u521D\u59CB\u5316 metadata \u5931\u8D25: ${error}`);
312
- }
313
- }
314
- function writeApps(appsDir, options) {
315
- const { key, apps = [], openapi } = options;
316
- if (!(0, import_node_fs3.existsSync)(appsDir)) {
317
- import_consola5.default.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${appsDir} \u4E0D\u5B58\u5728`);
318
- return;
319
- }
320
- try {
321
- (0, import_node_fs3.readdirSync)(appsDir).forEach((app) => {
322
- const appPath = (0, import_node_path.resolve)(appsDir, app);
323
- const settingPath = (0, import_node_path.resolve)(appPath, SETTING_FILE_PATH);
324
- const openapiPath = (0, import_node_path.resolve)(appPath, OPENAPI_FILE_PATH);
325
- if (!apps.includes(app)) {
326
- (0, import_rimraf.rimrafSync)(appPath);
327
- return;
328
- }
329
- rewriteFile(settingPath, (content) => {
330
- return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${key}'`);
331
- });
332
- rewriteFile(openapiPath, (content) => {
333
- return content.replace(/enabled:[^,]+,/g, `enabled: ${openapi},`);
334
- });
335
- });
336
- } catch (error) {
337
- import_consola5.default.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${error}`);
338
- }
339
- }
340
-
341
- // src/index.ts
342
- async function main() {
343
- const program = new import_commander.Command();
344
- program.name(package_default.name).description(package_default.description).version(package_default.version);
345
- program.description("\u521D\u59CB\u5316\u6846\u67B6").action(async () => {
346
- bootstrop();
347
- try {
348
- const answer = await init();
349
- await download(answer);
350
- await rewrite(answer);
351
- } catch (error) {
352
- import_consola6.default.error(error);
353
- }
354
- });
355
- program.command("create").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5E94\u7528").argument("<app-name>", "\u5E94\u7528\u540D\u79F0").action((name) => {
356
- import_consola6.default.info("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5E94\u7528", name);
357
- });
358
- program.command("status").description("\u67E5\u770B\u6846\u67B6\u72B6\u6001").action(() => {
359
- });
360
- program.command("update").description("\u66F4\u65B0\u6846\u67B6\u7248\u672C").action(() => {
361
- });
362
- program.parse();
363
- }
364
- main();