create-pubinfo 2.0.0-beta.2 → 2.0.0-beta.21
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 +173 -125
- package/dist/index.js +167 -120
- package/package.json +3 -2
- package/templates/pubinfo-template/.browserslistrc +5 -0
- package/templates/pubinfo-template/.editorconfig +10 -0
- package/templates/pubinfo-template/.env +12 -0
- package/templates/pubinfo-template/.env.development +6 -0
- package/templates/pubinfo-template/.env.production +10 -0
- package/templates/pubinfo-template/commitlint.config.js +66 -0
- package/templates/pubinfo-template/eslint.config.ts +3 -0
- package/templates/pubinfo-template/index.html +47 -0
- package/templates/pubinfo-template/openapi.config.ts +33 -0
- package/templates/pubinfo-template/package.json +52 -0
- package/templates/pubinfo-template/pubinfo.config.ts +9 -0
- package/templates/pubinfo-template/public/browser_upgrade/chrome.png +0 -0
- package/templates/pubinfo-template/public/browser_upgrade/edge.png +0 -0
- package/templates/pubinfo-template/public/browser_upgrade/index.css +49 -0
- package/templates/pubinfo-template/public/loading.css +92 -0
- package/templates/pubinfo-template/src/App.vue +15 -0
- package/templates/pubinfo-template/src/api/modules/auth/index.ts +3 -0
- package/templates/pubinfo-template/src/api/modules/auth/renzhengfuwu.ts +145 -0
- package/templates/pubinfo-template/src/api/modules/auth/typings.d.ts +97 -0
- package/templates/pubinfo-template/src/api/request.ts +124 -0
- package/templates/pubinfo-template/src/assets/icons/logo.svg +1 -0
- package/templates/pubinfo-template/src/assets/icons/process-management.svg +1 -0
- package/templates/pubinfo-template/src/assets/icons/workbench.svg +1 -0
- package/templates/pubinfo-template/src/assets/images/login-bg.webp +0 -0
- package/templates/pubinfo-template/src/assets/images/login-bg_dark.webp +0 -0
- package/templates/pubinfo-template/src/assets/images/login-small.png +0 -0
- package/templates/pubinfo-template/src/assets/images/login-small_dark.webp +0 -0
- package/templates/pubinfo-template/src/components/UIProvider/index.vue +47 -0
- package/templates/pubinfo-template/src/layouts/index.vue +38 -0
- package/templates/pubinfo-template/src/main.ts +23 -0
- package/templates/pubinfo-template/src/modules/auth.ts +21 -0
- package/templates/pubinfo-template/src/modules/rbac.ts +52 -0
- package/templates/pubinfo-template/src/routes/index.ts +71 -0
- package/templates/pubinfo-template/src/routes/modules/demo/breadcrumb.example.ts +62 -0
- package/templates/pubinfo-template/src/routes/modules/demo/link.ts +15 -0
- package/templates/pubinfo-template/src/routes/modules/demo/multilevel.menu.example.ts +68 -0
- package/templates/pubinfo-template/src/routes/modules/demo/other.page.ts +37 -0
- package/templates/pubinfo-template/src/routes/modules/demo/single.ts +14 -0
- package/templates/pubinfo-template/src/settings.ts +8 -0
- package/templates/pubinfo-template/src/stores/index.ts +2 -0
- package/templates/pubinfo-template/src/stores/modules/conter.ts +16 -0
- package/templates/pubinfo-template/src/views/demo/breadcrumb_example/detail1.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/breadcrumb_example/detail2.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/breadcrumb_example/list1.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/breadcrumb_example/list2.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/level3/page1.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/level3/page2.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/level2/page.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/multilevel_menu_example/page.vue +11 -0
- package/templates/pubinfo-template/src/views/demo/other_page/des.vue +13 -0
- package/templates/pubinfo-template/src/views/demo/other_page/index.vue +25 -0
- package/templates/pubinfo-template/src/views/demo/preview-empty/index.vue +17 -0
- package/templates/pubinfo-template/src/views/demo/single/index.vue +13 -0
- package/templates/pubinfo-template/src/views/system/index.vue +5 -0
- package/templates/pubinfo-template/src/views/system/login/components/LoginForm.vue +68 -0
- package/templates/pubinfo-template/src/views/system/login/components/LoginWithPhone.vue +213 -0
- package/templates/pubinfo-template/src/views/system/login/components/PasswordLogin.vue +199 -0
- package/templates/pubinfo-template/src/views/system/login/components/Savephone.vue +17 -0
- package/templates/pubinfo-template/src/views/system/login/components/Useragreement.vue +26 -0
- package/templates/pubinfo-template/src/views/system/login/composables.ts +84 -0
- package/templates/pubinfo-template/src/views/system/login/index.vue +165 -0
- package/templates/pubinfo-template/stylelint.config.js +3 -0
- package/templates/pubinfo-template/tsconfig.json +3 -0
- package/templates/pubinfo-template/uno.config.ts +17 -0
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var import_consola6 = __toESM(require("consola"), 1);
|
|
|
30
30
|
var package_default = {
|
|
31
31
|
name: "create-pubinfo",
|
|
32
32
|
type: "module",
|
|
33
|
-
version: "2.0.0-beta.
|
|
33
|
+
version: "2.0.0-beta.21",
|
|
34
34
|
description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
|
|
35
35
|
author: "Werheng <werheng.zhang@gmail.com>",
|
|
36
36
|
license: "MIT",
|
|
@@ -38,7 +38,8 @@ var package_default = {
|
|
|
38
38
|
pubinfo: "./dist/index.js"
|
|
39
39
|
},
|
|
40
40
|
files: [
|
|
41
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"templates"
|
|
42
43
|
],
|
|
43
44
|
scripts: {
|
|
44
45
|
dev: "tsup --watch src",
|
|
@@ -62,19 +63,110 @@ var package_default = {
|
|
|
62
63
|
},
|
|
63
64
|
devDependencies: {
|
|
64
65
|
"@types/node": "^22.13.9",
|
|
65
|
-
tsup: "
|
|
66
|
+
tsup: "catalog:"
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
// src/
|
|
70
|
+
// src/core/generate.ts
|
|
71
|
+
var import_node_path2 = require("path");
|
|
72
|
+
var import_node_process = require("process");
|
|
73
|
+
var import_node_url = require("url");
|
|
74
|
+
|
|
75
|
+
// src/utils.ts
|
|
76
|
+
var import_node_fs = require("fs");
|
|
77
|
+
var fs = __toESM(require("fs"), 1);
|
|
78
|
+
var import_promises = require("fs/promises");
|
|
79
|
+
var import_node_path = require("path");
|
|
80
|
+
var import_confbox = require("confbox");
|
|
81
|
+
var import_consola = __toESM(require("consola"), 1);
|
|
82
|
+
function rewriteFile(path, fn) {
|
|
83
|
+
if (!(0, import_node_fs.existsSync)(path)) {
|
|
84
|
+
import_consola.default.error(`RewriteFile fail: ${path} does not exist`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const content = (0, import_node_fs.readFileSync)(path, { encoding: "utf-8" });
|
|
89
|
+
(0, import_node_fs.writeFileSync)(path, fn(content));
|
|
90
|
+
} catch (error) {
|
|
91
|
+
import_consola.default.error(`RewriteFile fail: ${error}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function copyDir(srcDir, destDir) {
|
|
95
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
96
|
+
for (const file of fs.readdirSync(srcDir)) {
|
|
97
|
+
const srcFile = (0, import_node_path.resolve)(srcDir, file);
|
|
98
|
+
const destFile = (0, import_node_path.resolve)(destDir, file);
|
|
99
|
+
copy(srcFile, destFile);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function copy(src, dest) {
|
|
103
|
+
const stat = fs.statSync(src);
|
|
104
|
+
if (stat.isDirectory()) {
|
|
105
|
+
copyDir(src, dest);
|
|
106
|
+
} else {
|
|
107
|
+
fs.copyFileSync(src, dest);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function readJSON(path) {
|
|
111
|
+
const blob = await (0, import_promises.readFile)(path, "utf-8");
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = (0, import_confbox.parseJSON)(blob);
|
|
115
|
+
} catch {
|
|
116
|
+
parsed = (0, import_confbox.parseJSONC)(blob);
|
|
117
|
+
}
|
|
118
|
+
return parsed;
|
|
119
|
+
}
|
|
120
|
+
async function writeJSON(path, json) {
|
|
121
|
+
await (0, import_promises.writeFile)(path, (0, import_confbox.stringifyJSON)(json));
|
|
122
|
+
}
|
|
123
|
+
function assignValues(target, source) {
|
|
124
|
+
for (const [key, value] of Object.entries(source)) {
|
|
125
|
+
target[key] = value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function validateInput(input2) {
|
|
129
|
+
const forbiddenChars = /[<>:"/\\|?*\s]/;
|
|
130
|
+
if (forbiddenChars.test(input2)) {
|
|
131
|
+
return '\u9519\u8BEF\u63D0\u793A: \u8BE5\u503C\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u8005\u975E\u6CD5\u5B57\u7B26 (\u4F8B\u5982, <>:"/\\|?*).';
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/core/generate.ts
|
|
137
|
+
var import_meta = {};
|
|
138
|
+
function generate(options, version) {
|
|
139
|
+
const root = (0, import_node_process.cwd)();
|
|
140
|
+
const targetPath = (0, import_node_path2.resolve)(root, options.dir);
|
|
141
|
+
const templateDir = (0, import_node_path2.resolve)(
|
|
142
|
+
(0, import_node_url.fileURLToPath)(import_meta.url),
|
|
143
|
+
"../../templates",
|
|
144
|
+
`pubinfo-template`
|
|
145
|
+
);
|
|
146
|
+
copy(templateDir, targetPath);
|
|
147
|
+
rewriteFile((0, import_node_path2.resolve)(targetPath, "src/settings.ts"), (content) => {
|
|
148
|
+
return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${options.key}'`);
|
|
149
|
+
});
|
|
150
|
+
rewriteFile((0, import_node_path2.resolve)(targetPath, "openapi.config.ts"), (content) => {
|
|
151
|
+
return content.replace(/enabled:[^,]+,/g, `enabled: ${options.openapi},`);
|
|
152
|
+
});
|
|
153
|
+
rewriteFile((0, import_node_path2.resolve)(targetPath, "package.json"), (content) => {
|
|
154
|
+
const pattern = /"(@?pubinfo(?:\/module-(?:auth|rbac))?)":\s*"[^"]+"/g;
|
|
155
|
+
return content.replace(pattern, (_match, pkgName) => {
|
|
156
|
+
return `"${pkgName}": "${version}"`;
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/core/init.ts
|
|
70
162
|
var import_node_fs2 = require("fs");
|
|
71
|
-
var
|
|
163
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
72
164
|
var import_prompts = require("@inquirer/prompts");
|
|
73
165
|
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
74
166
|
var import_consola3 = __toESM(require("consola"), 1);
|
|
75
167
|
|
|
76
|
-
// src/constant.ts
|
|
77
|
-
var REMOTE_URL = "http://
|
|
168
|
+
// src/v1/constant.ts
|
|
169
|
+
var REMOTE_URL = "http://43.143.107.174:80/templates";
|
|
78
170
|
var PKG_NAME = "monorepo-project-template";
|
|
79
171
|
var VERSION_FILE = "version.json";
|
|
80
172
|
var SETTING_FILE_PATH = "src/settings.default.ts";
|
|
@@ -82,14 +174,13 @@ var OPENAPI_FILE_PATH = "openapi.config.ts";
|
|
|
82
174
|
var APPS_DIR = "apps";
|
|
83
175
|
var APPS = [
|
|
84
176
|
{ name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
|
|
85
|
-
// { name: '初始化项目模板(admin)', value: 'admin' },
|
|
86
177
|
];
|
|
87
178
|
var METADATA_DIR = "configs/metadata";
|
|
88
179
|
var META_FILENAME = "pubinfo.json";
|
|
89
180
|
|
|
90
|
-
// src/fetch.ts
|
|
91
|
-
var
|
|
92
|
-
var
|
|
181
|
+
// src/v1/fetch.ts
|
|
182
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
183
|
+
var import_consola2 = __toESM(require("consola"), 1);
|
|
93
184
|
var import_ofetch = require("ofetch");
|
|
94
185
|
var import_ora = __toESM(require("ora"), 1);
|
|
95
186
|
var import_semver = require("semver");
|
|
@@ -116,61 +207,18 @@ async function fetchData() {
|
|
|
116
207
|
if (error.message.includes(REMOTE_URL)) {
|
|
117
208
|
error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
|
|
118
209
|
}
|
|
119
|
-
|
|
120
|
-
|
|
210
|
+
import_consola2.default.error(`\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38: ${error.message}`);
|
|
211
|
+
import_node_process2.default.exit(1);
|
|
121
212
|
} finally {
|
|
122
213
|
spinner.stop();
|
|
123
214
|
}
|
|
124
215
|
}
|
|
125
216
|
|
|
126
|
-
// src/
|
|
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
|
|
217
|
+
// src/core/init.ts
|
|
170
218
|
async function init() {
|
|
171
219
|
const { version } = await fetchData();
|
|
172
|
-
const answer = {};
|
|
173
220
|
try {
|
|
221
|
+
const answer = {};
|
|
174
222
|
answer.dir = await (0, import_prompts.input)({ message: "\u76EE\u5F55\u540D\u79F0\uFF08dir\uFF09", default: "my-app", validate: validateInput });
|
|
175
223
|
answer.key = await (0, import_prompts.input)({ message: "\u9879\u76EE\u6807\u8BC6\uFF08key\uFF09", default: answer.dir, validate: validateInput });
|
|
176
224
|
if ((0, import_node_fs2.existsSync)(answer.dir)) {
|
|
@@ -179,39 +227,65 @@ async function init() {
|
|
|
179
227
|
throw Error;
|
|
180
228
|
}
|
|
181
229
|
}
|
|
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
230
|
answer.openapi = await (0, import_prompts.confirm)({
|
|
203
231
|
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
232
|
default: false
|
|
205
233
|
});
|
|
234
|
+
const V1orV2 = await (0, import_prompts.select)({
|
|
235
|
+
message: "\u4F7F\u7528 v1 or v2 \u7248\u672C\uFF1F",
|
|
236
|
+
default: "v2",
|
|
237
|
+
choices: ["v1", "v2"]
|
|
238
|
+
});
|
|
239
|
+
const isV1 = V1orV2 === "v1";
|
|
240
|
+
if (isV1) {
|
|
241
|
+
answer.optionsV1 = JSON.parse(JSON.stringify(answer));
|
|
242
|
+
answer.optionsV1.version = await (0, import_prompts.select)({
|
|
243
|
+
message: "\u6846\u67B6\u7248\u672C\u53F7\uFF08version\uFF09",
|
|
244
|
+
default: version.latest,
|
|
245
|
+
choices: version.list
|
|
246
|
+
});
|
|
247
|
+
answer.optionsV1.apps = await (0, import_prompts.checkbox)({
|
|
248
|
+
message: "\u9009\u62E9\u5E94\u7528\u6A21\u5757\uFF08apps\uFF09",
|
|
249
|
+
choices: APPS,
|
|
250
|
+
validate: (input2) => {
|
|
251
|
+
if (input2.length === 0) {
|
|
252
|
+
return "\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E94\u7528";
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
206
258
|
return answer;
|
|
207
259
|
} catch {
|
|
208
260
|
import_consola3.default.fail("\u64CD\u4F5C\u7EC8\u6B62");
|
|
209
|
-
|
|
261
|
+
import_node_process3.default.exit(1);
|
|
210
262
|
}
|
|
211
263
|
}
|
|
212
264
|
|
|
213
|
-
// src/
|
|
214
|
-
var
|
|
265
|
+
// src/log.ts
|
|
266
|
+
var import_cfonts = __toESM(require("cfonts"), 1);
|
|
267
|
+
function bootstrop() {
|
|
268
|
+
printLoGo("PUBINFO");
|
|
269
|
+
function printLoGo(logo) {
|
|
270
|
+
import_cfonts.default.say(logo, {
|
|
271
|
+
font: "simple3d",
|
|
272
|
+
align: "left",
|
|
273
|
+
background: "transparent",
|
|
274
|
+
letterSpacing: 1,
|
|
275
|
+
lineHeight: 1,
|
|
276
|
+
space: true,
|
|
277
|
+
maxLength: 0,
|
|
278
|
+
spaceless: false,
|
|
279
|
+
gradient: ["blue", "magenta"],
|
|
280
|
+
independentGradient: false,
|
|
281
|
+
transitionGradient: false,
|
|
282
|
+
env: "node"
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/v1/download.ts
|
|
288
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
215
289
|
var import_ansi_colors2 = __toESM(require("ansi-colors"), 1);
|
|
216
290
|
var import_consola4 = __toESM(require("consola"), 1);
|
|
217
291
|
var import_giget = require("giget");
|
|
@@ -233,7 +307,6 @@ async function download(options) {
|
|
|
233
307
|
providers: { pubinfo },
|
|
234
308
|
force: true,
|
|
235
309
|
forceClean: true,
|
|
236
|
-
// auth: options.auth,
|
|
237
310
|
dir: options.dir
|
|
238
311
|
});
|
|
239
312
|
} catch (error) {
|
|
@@ -241,7 +314,7 @@ async function download(options) {
|
|
|
241
314
|
error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
|
|
242
315
|
}
|
|
243
316
|
import_consola4.default.error(`\u4E0B\u8F7D\u5931\u8D25: ${error.message}`);
|
|
244
|
-
|
|
317
|
+
import_node_process4.default.exit(1);
|
|
245
318
|
} finally {
|
|
246
319
|
finish();
|
|
247
320
|
}
|
|
@@ -260,44 +333,22 @@ function loading() {
|
|
|
260
333
|
};
|
|
261
334
|
}
|
|
262
335
|
|
|
263
|
-
// src/
|
|
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
|
|
336
|
+
// src/v1/rewrite.ts
|
|
286
337
|
var import_node_fs3 = require("fs");
|
|
287
|
-
var
|
|
288
|
-
var
|
|
338
|
+
var import_node_path3 = require("path");
|
|
339
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
289
340
|
var import_consola5 = __toESM(require("consola"), 1);
|
|
290
341
|
var import_rimraf = require("rimraf");
|
|
291
342
|
async function rewrite(options) {
|
|
292
343
|
const { dir } = options;
|
|
293
|
-
const root =
|
|
294
|
-
const projectDir = (0,
|
|
295
|
-
writeMetaJSON((0,
|
|
296
|
-
writeApps((0,
|
|
344
|
+
const root = import_node_process5.default.cwd();
|
|
345
|
+
const projectDir = (0, import_node_path3.resolve)(root, dir);
|
|
346
|
+
writeMetaJSON((0, import_node_path3.resolve)(projectDir, METADATA_DIR), options);
|
|
347
|
+
writeApps((0, import_node_path3.resolve)(projectDir, APPS_DIR), options);
|
|
297
348
|
}
|
|
298
349
|
async function writeMetaJSON(metaDir, options) {
|
|
299
350
|
const { key, version, apps, openapi } = options;
|
|
300
|
-
const path = (0,
|
|
351
|
+
const path = (0, import_node_path3.resolve)(metaDir, META_FILENAME);
|
|
301
352
|
try {
|
|
302
353
|
const json = await readJSON(path);
|
|
303
354
|
assignValues(json, {
|
|
@@ -319,9 +370,9 @@ function writeApps(appsDir, options) {
|
|
|
319
370
|
}
|
|
320
371
|
try {
|
|
321
372
|
(0, import_node_fs3.readdirSync)(appsDir).forEach((app) => {
|
|
322
|
-
const appPath = (0,
|
|
323
|
-
const settingPath = (0,
|
|
324
|
-
const openapiPath = (0,
|
|
373
|
+
const appPath = (0, import_node_path3.resolve)(appsDir, app);
|
|
374
|
+
const settingPath = (0, import_node_path3.resolve)(appPath, SETTING_FILE_PATH);
|
|
375
|
+
const openapiPath = (0, import_node_path3.resolve)(appPath, OPENAPI_FILE_PATH);
|
|
325
376
|
if (!apps.includes(app)) {
|
|
326
377
|
(0, import_rimraf.rimrafSync)(appPath);
|
|
327
378
|
return;
|
|
@@ -346,19 +397,16 @@ async function main() {
|
|
|
346
397
|
bootstrop();
|
|
347
398
|
try {
|
|
348
399
|
const answer = await init();
|
|
349
|
-
|
|
350
|
-
|
|
400
|
+
if (answer.optionsV1) {
|
|
401
|
+
await download(answer.optionsV1);
|
|
402
|
+
await rewrite(answer.optionsV1);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
generate(answer, package_default.version);
|
|
351
406
|
} catch (error) {
|
|
352
407
|
import_consola6.default.error(error);
|
|
353
408
|
}
|
|
354
409
|
});
|
|
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
410
|
program.parse();
|
|
363
411
|
}
|
|
364
412
|
main();
|