create-pubinfo 2.0.0-beta.19 → 2.0.0-beta.20
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 +171 -123
- package/dist/index.js +165 -118
- 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.js
CHANGED
|
@@ -8,7 +8,7 @@ import consola6 from "consola";
|
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "create-pubinfo",
|
|
10
10
|
type: "module",
|
|
11
|
-
version: "2.0.0-beta.
|
|
11
|
+
version: "2.0.0-beta.20",
|
|
12
12
|
description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
|
|
13
13
|
author: "Werheng <werheng.zhang@gmail.com>",
|
|
14
14
|
license: "MIT",
|
|
@@ -16,7 +16,8 @@ var package_default = {
|
|
|
16
16
|
pubinfo: "./dist/index.js"
|
|
17
17
|
},
|
|
18
18
|
files: [
|
|
19
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"templates"
|
|
20
21
|
],
|
|
21
22
|
scripts: {
|
|
22
23
|
dev: "tsup --watch src",
|
|
@@ -44,14 +45,104 @@ var package_default = {
|
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
// src/
|
|
48
|
+
// src/core/generate.ts
|
|
49
|
+
import { resolve as resolve2 } from "node:path";
|
|
50
|
+
import { cwd } from "node:process";
|
|
51
|
+
import { fileURLToPath } from "node:url";
|
|
52
|
+
|
|
53
|
+
// src/utils.ts
|
|
54
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
55
|
+
import * as fs from "node:fs";
|
|
56
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
57
|
+
import { resolve } from "node:path";
|
|
58
|
+
import { parseJSON, parseJSONC, stringifyJSON } from "confbox";
|
|
59
|
+
import consola from "consola";
|
|
60
|
+
function rewriteFile(path, fn) {
|
|
61
|
+
if (!existsSync(path)) {
|
|
62
|
+
consola.error(`RewriteFile fail: ${path} does not exist`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const content = readFileSync(path, { encoding: "utf-8" });
|
|
67
|
+
writeFileSync(path, fn(content));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
consola.error(`RewriteFile fail: ${error}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function copyDir(srcDir, destDir) {
|
|
73
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
74
|
+
for (const file of fs.readdirSync(srcDir)) {
|
|
75
|
+
const srcFile = resolve(srcDir, file);
|
|
76
|
+
const destFile = resolve(destDir, file);
|
|
77
|
+
copy(srcFile, destFile);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function copy(src, dest) {
|
|
81
|
+
const stat = fs.statSync(src);
|
|
82
|
+
if (stat.isDirectory()) {
|
|
83
|
+
copyDir(src, dest);
|
|
84
|
+
} else {
|
|
85
|
+
fs.copyFileSync(src, dest);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function readJSON(path) {
|
|
89
|
+
const blob = await readFile(path, "utf-8");
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = parseJSON(blob);
|
|
93
|
+
} catch {
|
|
94
|
+
parsed = parseJSONC(blob);
|
|
95
|
+
}
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
async function writeJSON(path, json) {
|
|
99
|
+
await writeFile(path, stringifyJSON(json));
|
|
100
|
+
}
|
|
101
|
+
function assignValues(target, source) {
|
|
102
|
+
for (const [key, value] of Object.entries(source)) {
|
|
103
|
+
target[key] = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function validateInput(input2) {
|
|
107
|
+
const forbiddenChars = /[<>:"/\\|?*\s]/;
|
|
108
|
+
if (forbiddenChars.test(input2)) {
|
|
109
|
+
return '\u9519\u8BEF\u63D0\u793A: \u8BE5\u503C\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u8005\u975E\u6CD5\u5B57\u7B26 (\u4F8B\u5982, <>:"/\\|?*).';
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/core/generate.ts
|
|
115
|
+
function generate(options, version) {
|
|
116
|
+
const root = cwd();
|
|
117
|
+
const targetPath = resolve2(root, options.dir);
|
|
118
|
+
const templateDir = resolve2(
|
|
119
|
+
fileURLToPath(import.meta.url),
|
|
120
|
+
"../../../templates",
|
|
121
|
+
`pubinfo-template`
|
|
122
|
+
);
|
|
123
|
+
copy(templateDir, targetPath);
|
|
124
|
+
rewriteFile(resolve2(targetPath, "src/settings.ts"), (content) => {
|
|
125
|
+
return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${options.key}'`);
|
|
126
|
+
});
|
|
127
|
+
rewriteFile(resolve2(targetPath, "openapi.config.ts"), (content) => {
|
|
128
|
+
return content.replace(/enabled:[^,]+,/g, `enabled: ${options.openapi},`);
|
|
129
|
+
});
|
|
130
|
+
rewriteFile(resolve2(targetPath, "package.json"), (content) => {
|
|
131
|
+
const pattern = /"(@?pubinfo(?:\/module-(?:auth|rbac))?)":\s*"[^"]+"/g;
|
|
132
|
+
return content.replace(pattern, (_match, pkgName) => {
|
|
133
|
+
return `"${pkgName}": "${version}"`;
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/core/init.ts
|
|
48
139
|
import { existsSync as existsSync2 } from "node:fs";
|
|
49
140
|
import process2 from "node:process";
|
|
50
|
-
import { checkbox, confirm, input } from "@inquirer/prompts";
|
|
141
|
+
import { checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
51
142
|
import colors from "ansi-colors";
|
|
52
143
|
import consola3 from "consola";
|
|
53
144
|
|
|
54
|
-
// src/constant.ts
|
|
145
|
+
// src/v1/constant.ts
|
|
55
146
|
var REMOTE_URL = "http://43.143.107.174:80/templates";
|
|
56
147
|
var PKG_NAME = "monorepo-project-template";
|
|
57
148
|
var VERSION_FILE = "version.json";
|
|
@@ -60,14 +151,13 @@ var OPENAPI_FILE_PATH = "openapi.config.ts";
|
|
|
60
151
|
var APPS_DIR = "apps";
|
|
61
152
|
var APPS = [
|
|
62
153
|
{ name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
|
|
63
|
-
// { name: '初始化项目模板(admin)', value: 'admin' },
|
|
64
154
|
];
|
|
65
155
|
var METADATA_DIR = "configs/metadata";
|
|
66
156
|
var META_FILENAME = "pubinfo.json";
|
|
67
157
|
|
|
68
|
-
// src/fetch.ts
|
|
158
|
+
// src/v1/fetch.ts
|
|
69
159
|
import process from "node:process";
|
|
70
|
-
import
|
|
160
|
+
import consola2 from "consola";
|
|
71
161
|
import { ofetch } from "ofetch";
|
|
72
162
|
import ora from "ora";
|
|
73
163
|
import { compare } from "semver";
|
|
@@ -94,61 +184,18 @@ async function fetchData() {
|
|
|
94
184
|
if (error.message.includes(REMOTE_URL)) {
|
|
95
185
|
error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
|
|
96
186
|
}
|
|
97
|
-
|
|
187
|
+
consola2.error(`\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38: ${error.message}`);
|
|
98
188
|
process.exit(1);
|
|
99
189
|
} finally {
|
|
100
190
|
spinner.stop();
|
|
101
191
|
}
|
|
102
192
|
}
|
|
103
193
|
|
|
104
|
-
// src/
|
|
105
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
106
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
107
|
-
import { parseJSON, parseJSONC, stringifyJSON } from "confbox";
|
|
108
|
-
import consola2 from "consola";
|
|
109
|
-
function rewriteFile(path, fn) {
|
|
110
|
-
if (!existsSync(path)) {
|
|
111
|
-
consola2.error(`RewriteFile fail: ${path} does not exist`);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
const content = readFileSync(path, { encoding: "utf-8" });
|
|
116
|
-
writeFileSync(path, fn(content));
|
|
117
|
-
} catch (error) {
|
|
118
|
-
consola2.error(`RewriteFile fail: ${error}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async function readJSON(path) {
|
|
122
|
-
const blob = await readFile(path, "utf-8");
|
|
123
|
-
let parsed;
|
|
124
|
-
try {
|
|
125
|
-
parsed = parseJSON(blob);
|
|
126
|
-
} catch {
|
|
127
|
-
parsed = parseJSONC(blob);
|
|
128
|
-
}
|
|
129
|
-
return parsed;
|
|
130
|
-
}
|
|
131
|
-
async function writeJSON(path, json) {
|
|
132
|
-
await writeFile(path, stringifyJSON(json));
|
|
133
|
-
}
|
|
134
|
-
function assignValues(target, source) {
|
|
135
|
-
for (const [key, value] of Object.entries(source)) {
|
|
136
|
-
target[key] = value;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function validateInput(input2) {
|
|
140
|
-
const forbiddenChars = /[<>:"/\\|?*\s]/;
|
|
141
|
-
if (forbiddenChars.test(input2)) {
|
|
142
|
-
return '\u9519\u8BEF\u63D0\u793A: \u8BE5\u503C\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u8005\u975E\u6CD5\u5B57\u7B26 (\u4F8B\u5982, <>:"/\\|?*).';
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// src/command/init.ts
|
|
194
|
+
// src/core/init.ts
|
|
148
195
|
async function init() {
|
|
149
196
|
const { version } = await fetchData();
|
|
150
|
-
const answer = {};
|
|
151
197
|
try {
|
|
198
|
+
const answer = {};
|
|
152
199
|
answer.dir = await input({ message: "\u76EE\u5F55\u540D\u79F0\uFF08dir\uFF09", default: "my-app", validate: validateInput });
|
|
153
200
|
answer.key = await input({ message: "\u9879\u76EE\u6807\u8BC6\uFF08key\uFF09", default: answer.dir, validate: validateInput });
|
|
154
201
|
if (existsSync2(answer.dir)) {
|
|
@@ -157,30 +204,34 @@ async function init() {
|
|
|
157
204
|
throw Error;
|
|
158
205
|
}
|
|
159
206
|
}
|
|
160
|
-
answer.version = await input({
|
|
161
|
-
message: "\u6846\u67B6\u7248\u672C\u53F7\uFF08version\uFF09",
|
|
162
|
-
default: version.latest,
|
|
163
|
-
validate: (input2) => {
|
|
164
|
-
if (!version.list.includes(input2)) {
|
|
165
|
-
return `\u7248\u672C\u53F7: ${colors.bold(input2)} \u4E0D\u5B58\u5728, \u5F53\u524D\u6700\u65B0\u7248\u672C\u53F7: ${colors.bold(version.latest)}.`;
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
answer.apps = await checkbox({
|
|
171
|
-
message: "\u9009\u62E9\u5E94\u7528\u6A21\u5757\uFF08apps\uFF09",
|
|
172
|
-
choices: APPS,
|
|
173
|
-
validate: (input2) => {
|
|
174
|
-
if (input2.length === 0) {
|
|
175
|
-
return "\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E94\u7528";
|
|
176
|
-
}
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
207
|
answer.openapi = await confirm({
|
|
181
208
|
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",
|
|
182
209
|
default: false
|
|
183
210
|
});
|
|
211
|
+
const V1orV2 = await select({
|
|
212
|
+
message: "\u4F7F\u7528 v1 or v2 \u7248\u672C\uFF1F",
|
|
213
|
+
default: "v2",
|
|
214
|
+
choices: ["v1", "v2"]
|
|
215
|
+
});
|
|
216
|
+
const isV1 = V1orV2 === "v1";
|
|
217
|
+
if (isV1) {
|
|
218
|
+
answer.optionsV1 = JSON.parse(JSON.stringify(answer));
|
|
219
|
+
answer.optionsV1.version = await select({
|
|
220
|
+
message: "\u6846\u67B6\u7248\u672C\u53F7\uFF08version\uFF09",
|
|
221
|
+
default: version.latest,
|
|
222
|
+
choices: version.list
|
|
223
|
+
});
|
|
224
|
+
answer.optionsV1.apps = await checkbox({
|
|
225
|
+
message: "\u9009\u62E9\u5E94\u7528\u6A21\u5757\uFF08apps\uFF09",
|
|
226
|
+
choices: APPS,
|
|
227
|
+
validate: (input2) => {
|
|
228
|
+
if (input2.length === 0) {
|
|
229
|
+
return "\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E94\u7528";
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
184
235
|
return answer;
|
|
185
236
|
} catch {
|
|
186
237
|
consola3.fail("\u64CD\u4F5C\u7EC8\u6B62");
|
|
@@ -188,7 +239,29 @@ async function init() {
|
|
|
188
239
|
}
|
|
189
240
|
}
|
|
190
241
|
|
|
191
|
-
// src/
|
|
242
|
+
// src/log.ts
|
|
243
|
+
import fonts from "cfonts";
|
|
244
|
+
function bootstrop() {
|
|
245
|
+
printLoGo("PUBINFO");
|
|
246
|
+
function printLoGo(logo) {
|
|
247
|
+
fonts.say(logo, {
|
|
248
|
+
font: "simple3d",
|
|
249
|
+
align: "left",
|
|
250
|
+
background: "transparent",
|
|
251
|
+
letterSpacing: 1,
|
|
252
|
+
lineHeight: 1,
|
|
253
|
+
space: true,
|
|
254
|
+
maxLength: 0,
|
|
255
|
+
spaceless: false,
|
|
256
|
+
gradient: ["blue", "magenta"],
|
|
257
|
+
independentGradient: false,
|
|
258
|
+
transitionGradient: false,
|
|
259
|
+
env: "node"
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/v1/download.ts
|
|
192
265
|
import process3 from "node:process";
|
|
193
266
|
import colors2 from "ansi-colors";
|
|
194
267
|
import consola4 from "consola";
|
|
@@ -211,7 +284,6 @@ async function download(options) {
|
|
|
211
284
|
providers: { pubinfo },
|
|
212
285
|
force: true,
|
|
213
286
|
forceClean: true,
|
|
214
|
-
// auth: options.auth,
|
|
215
287
|
dir: options.dir
|
|
216
288
|
});
|
|
217
289
|
} catch (error) {
|
|
@@ -238,44 +310,22 @@ function loading() {
|
|
|
238
310
|
};
|
|
239
311
|
}
|
|
240
312
|
|
|
241
|
-
// src/
|
|
242
|
-
import
|
|
243
|
-
|
|
244
|
-
printLoGo("PUBINFO");
|
|
245
|
-
function printLoGo(logo) {
|
|
246
|
-
fonts.say(logo, {
|
|
247
|
-
font: "simple3d",
|
|
248
|
-
align: "left",
|
|
249
|
-
background: "transparent",
|
|
250
|
-
letterSpacing: 1,
|
|
251
|
-
lineHeight: 1,
|
|
252
|
-
space: true,
|
|
253
|
-
maxLength: 0,
|
|
254
|
-
spaceless: false,
|
|
255
|
-
gradient: ["blue", "magenta"],
|
|
256
|
-
independentGradient: false,
|
|
257
|
-
transitionGradient: false,
|
|
258
|
-
env: "node"
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// src/rewrite.ts
|
|
264
|
-
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
265
|
-
import { resolve } from "node:path";
|
|
313
|
+
// src/v1/rewrite.ts
|
|
314
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
|
|
315
|
+
import { resolve as resolve3 } from "node:path";
|
|
266
316
|
import process4 from "node:process";
|
|
267
317
|
import consola5 from "consola";
|
|
268
318
|
import { rimrafSync } from "rimraf";
|
|
269
319
|
async function rewrite(options) {
|
|
270
320
|
const { dir } = options;
|
|
271
321
|
const root = process4.cwd();
|
|
272
|
-
const projectDir =
|
|
273
|
-
writeMetaJSON(
|
|
274
|
-
writeApps(
|
|
322
|
+
const projectDir = resolve3(root, dir);
|
|
323
|
+
writeMetaJSON(resolve3(projectDir, METADATA_DIR), options);
|
|
324
|
+
writeApps(resolve3(projectDir, APPS_DIR), options);
|
|
275
325
|
}
|
|
276
326
|
async function writeMetaJSON(metaDir, options) {
|
|
277
327
|
const { key, version, apps, openapi } = options;
|
|
278
|
-
const path =
|
|
328
|
+
const path = resolve3(metaDir, META_FILENAME);
|
|
279
329
|
try {
|
|
280
330
|
const json = await readJSON(path);
|
|
281
331
|
assignValues(json, {
|
|
@@ -296,10 +346,10 @@ function writeApps(appsDir, options) {
|
|
|
296
346
|
return;
|
|
297
347
|
}
|
|
298
348
|
try {
|
|
299
|
-
|
|
300
|
-
const appPath =
|
|
301
|
-
const settingPath =
|
|
302
|
-
const openapiPath =
|
|
349
|
+
readdirSync2(appsDir).forEach((app) => {
|
|
350
|
+
const appPath = resolve3(appsDir, app);
|
|
351
|
+
const settingPath = resolve3(appPath, SETTING_FILE_PATH);
|
|
352
|
+
const openapiPath = resolve3(appPath, OPENAPI_FILE_PATH);
|
|
303
353
|
if (!apps.includes(app)) {
|
|
304
354
|
rimrafSync(appPath);
|
|
305
355
|
return;
|
|
@@ -324,19 +374,16 @@ async function main() {
|
|
|
324
374
|
bootstrop();
|
|
325
375
|
try {
|
|
326
376
|
const answer = await init();
|
|
327
|
-
|
|
328
|
-
|
|
377
|
+
if (answer.optionsV1) {
|
|
378
|
+
await download(answer.optionsV1);
|
|
379
|
+
await rewrite(answer.optionsV1);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
generate(answer, package_default.version);
|
|
329
383
|
} catch (error) {
|
|
330
384
|
consola6.error(error);
|
|
331
385
|
}
|
|
332
386
|
});
|
|
333
|
-
program.command("create").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5E94\u7528").argument("<app-name>", "\u5E94\u7528\u540D\u79F0").action((name) => {
|
|
334
|
-
consola6.info("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5E94\u7528", name);
|
|
335
|
-
});
|
|
336
|
-
program.command("status").description("\u67E5\u770B\u6846\u67B6\u72B6\u6001").action(() => {
|
|
337
|
-
});
|
|
338
|
-
program.command("update").description("\u66F4\u65B0\u6846\u67B6\u7248\u672C").action(() => {
|
|
339
|
-
});
|
|
340
387
|
program.parse();
|
|
341
388
|
}
|
|
342
389
|
main();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pubinfo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.20",
|
|
5
5
|
"description": "初始化项目框架",
|
|
6
6
|
"author": "Werheng <werheng.zhang@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"pubinfo": "./dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"templates"
|
|
13
14
|
],
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@inquirer/prompts": "^5.5.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 接口请求地址,会设置到 axios 的 baseURL 参数上
|
|
2
|
+
VITE_APP_API_BASEURL = /pubinfo-sys
|
|
3
|
+
# 是否在打包时启用 Mock
|
|
4
|
+
VITE_BUILD_MOCK = false
|
|
5
|
+
# 是否在打包时生成 sourcemap
|
|
6
|
+
VITE_BUILD_SOURCEMAP = false
|
|
7
|
+
# 是否在打包时开启压缩,支持 gzip 和 brotli,例如 gzip,brotli
|
|
8
|
+
VITE_BUILD_COMPRESS =
|
|
9
|
+
# 是否在打包时启用传统浏览器兼容,可在 .browserslistrc 中进行具体配置
|
|
10
|
+
VITE_BUILD_LEGACY = false
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
prompt: {
|
|
4
|
+
questions: {
|
|
5
|
+
type: {
|
|
6
|
+
enum: {
|
|
7
|
+
feat: {
|
|
8
|
+
description: '✨ 新增功能 | A new feature',
|
|
9
|
+
title: 'Features',
|
|
10
|
+
emoji: '✨',
|
|
11
|
+
},
|
|
12
|
+
fix: {
|
|
13
|
+
description: '🐛 修复缺陷 | A bug fix',
|
|
14
|
+
title: 'Bug Fixes',
|
|
15
|
+
emoji: '🐛',
|
|
16
|
+
},
|
|
17
|
+
docs: {
|
|
18
|
+
description: '📝 文档更新 | Documentation only changes',
|
|
19
|
+
title: 'Documentation',
|
|
20
|
+
emoji: '📝',
|
|
21
|
+
},
|
|
22
|
+
style: {
|
|
23
|
+
description: '💄 代码格式 | Changes that do not affect the meaning of the code',
|
|
24
|
+
title: 'Styles',
|
|
25
|
+
emoji: '💄',
|
|
26
|
+
},
|
|
27
|
+
refactor: {
|
|
28
|
+
description: '♻️ 代码重构 | A code change that neither fixes a bug nor adds a feature',
|
|
29
|
+
title: 'Code Refactoring',
|
|
30
|
+
emoji: '♻️',
|
|
31
|
+
},
|
|
32
|
+
perf: {
|
|
33
|
+
description: '⚡️ 性能提升 | A code change that improves performance',
|
|
34
|
+
title: 'Performance Improvements',
|
|
35
|
+
emoji: '⚡️',
|
|
36
|
+
},
|
|
37
|
+
test: {
|
|
38
|
+
description: '✅ 测试相关 | Adding missing tests or correcting existing tests',
|
|
39
|
+
title: 'Tests',
|
|
40
|
+
emoji: '✅',
|
|
41
|
+
},
|
|
42
|
+
build: {
|
|
43
|
+
description: '📦️ 构建相关 | Changes that affect the build system or external dependencies',
|
|
44
|
+
title: 'Builds',
|
|
45
|
+
emoji: '📦️',
|
|
46
|
+
},
|
|
47
|
+
ci: {
|
|
48
|
+
description: '🎡 持续集成 | Changes to our CI configuration files and scripts',
|
|
49
|
+
title: 'Continuous Integrations',
|
|
50
|
+
emoji: '🎡',
|
|
51
|
+
},
|
|
52
|
+
chore: {
|
|
53
|
+
description: '🔨 其他修改 | Other changes that do not modify src or test files',
|
|
54
|
+
title: 'Chores',
|
|
55
|
+
emoji: '🔨',
|
|
56
|
+
},
|
|
57
|
+
revert: {
|
|
58
|
+
description: '⏪️ 回退代码 | Revert to a commit',
|
|
59
|
+
title: 'Reverts',
|
|
60
|
+
emoji: '⏪️',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="src/assets/icons/logo.svg" type="image/svg+xml"/>
|
|
6
|
+
<link rel="stylesheet" href="/loading.css" />
|
|
7
|
+
<link rel="stylesheet" href="/browser_upgrade/index.css" />
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
9
|
+
<meta http-equiv="Expires" content="0">
|
|
10
|
+
<meta http-equiv="Pragma" content="no-cache">
|
|
11
|
+
<meta http-equiv="Cache-control" content="no-cache">
|
|
12
|
+
<meta http-equiv="Cache" content="no-cache">
|
|
13
|
+
<title>%VITE_APP_TITLE%</title>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="app">
|
|
17
|
+
<div class="w-admin-home">
|
|
18
|
+
<div class="loading">
|
|
19
|
+
<div class="square"></div>
|
|
20
|
+
<div class="square"></div>
|
|
21
|
+
<div class="square"></div>
|
|
22
|
+
<div class="square"></div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="text">载入中</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div id="browser-upgrade">
|
|
27
|
+
<div class="title">为了您的体验,推荐使用以下浏览器</div>
|
|
28
|
+
<div class="browsers">
|
|
29
|
+
<a href="https://www.microsoft.com/edge" target="_blank" class="browser">
|
|
30
|
+
<img class="browser-icon" src="/browser_upgrade/edge.png" />
|
|
31
|
+
<div class="browser-name">Mircosoft Edge</div>
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://www.google.cn/chrome/" target="_blank" class="browser">
|
|
34
|
+
<img class="browser-icon" src="/browser_upgrade/chrome.png" />
|
|
35
|
+
<div class="browser-name">Google Chrome</div>
|
|
36
|
+
</a>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<script>
|
|
41
|
+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
|
|
42
|
+
document.getElementById('browser-upgrade').style.display = 'block';
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
<script type="module" src="/src/main.ts"></script>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineConfig } from '@pubinfo/openapi';
|
|
2
|
+
import { presetName } from '@pubinfo/preset-openapi';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
enabled: false,
|
|
6
|
+
|
|
7
|
+
presets: [
|
|
8
|
+
// 小驼峰式命名
|
|
9
|
+
presetName({
|
|
10
|
+
functionName: 'camelCase',
|
|
11
|
+
}),
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
imports: { '@/api/request': [{ name: 'basic', as: 'request' }] },
|
|
15
|
+
batch: [
|
|
16
|
+
{
|
|
17
|
+
input: 'http://localhost:9099/pubinfo-sys/v3/api-docs/auth',
|
|
18
|
+
output: './src/api/modules/auth',
|
|
19
|
+
imports: { '@/api/request': [{ name: 'auth', as: 'request' }] },
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
hooks: {
|
|
24
|
+
customType(schema, namespace, defaultFn) {
|
|
25
|
+
// `int64` 在前端会精度丢失,可在此处调整对应字段的 `TS类型`
|
|
26
|
+
if (schema?.type === 'integer' && schema?.format === 'int64') {
|
|
27
|
+
return 'number';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return defaultFn(schema, namespace);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pubinfo-template",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"private": true,
|
|
5
|
+
"packageManager": "pnpm@10.5.2",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "pubinfo dev",
|
|
8
|
+
"build": "pubinfo build",
|
|
9
|
+
"preview": "pubinfo preview",
|
|
10
|
+
"commit": "git-cz",
|
|
11
|
+
"lint:eslint": "eslint . --cache --fix",
|
|
12
|
+
"lint:stylelint": "stylelint \"src/**/*.{css,scss,vue}\" --cache --fix",
|
|
13
|
+
"viewer:eslint-rule": "pnpx @eslint/config-inspector",
|
|
14
|
+
"openapi": "pnpx @pubinfo/openapi generate"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@ant-design/icons-vue": "^7.0.1",
|
|
18
|
+
"@pubinfo/module-auth": "^2.0.0-beta.18",
|
|
19
|
+
"@pubinfo/module-rbac": "^2.0.0-beta.18",
|
|
20
|
+
"@pubinfo/pro-components": "^1.7.0",
|
|
21
|
+
"@vueuse/core": "^12.8.2",
|
|
22
|
+
"alova": "^3.2.9",
|
|
23
|
+
"ant-design-vue": "^4.2.6",
|
|
24
|
+
"pubinfo": "^2.0.0-beta.18"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
28
|
+
"@commitlint/cz-commitlint": "^19.8.0",
|
|
29
|
+
"@pubinfo/openapi": "^0.8.4",
|
|
30
|
+
"@pubinfo/preset-openapi": "^0.8.4",
|
|
31
|
+
"commitizen": "^4.3.1",
|
|
32
|
+
"commitlint": "^19.8.0",
|
|
33
|
+
"eslint": "^9.21.0",
|
|
34
|
+
"lint-staged": "^15.5.0",
|
|
35
|
+
"simple-git-hooks": "^2.11.1",
|
|
36
|
+
"stylelint": "^16.15.0",
|
|
37
|
+
"typescript": "^5.8.2"
|
|
38
|
+
},
|
|
39
|
+
"config": {
|
|
40
|
+
"commitizen": {
|
|
41
|
+
"path": "@commitlint/cz-commitlint"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"simple-git-hooks": {
|
|
45
|
+
"pre-commit": "pnpm lint-staged",
|
|
46
|
+
"commit-msg": "pnpm commitlint --edit"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"*.{vue,js,ts,jsx,tsx,md,json}": "eslint --cache --fix",
|
|
50
|
+
"*.{css,scss,vue}": "stylelint --cache --fix"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
Binary file
|
|
Binary file
|