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.
- package/dist/index.js +187 -129
- package/package.json +8 -7
- 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/_gitignore +37 -0
- package/templates/pubinfo-template/_npmrc +5 -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 +53 -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 +7 -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 +51 -0
- package/templates/pubinfo-template/src/layouts/index.vue +38 -0
- package/templates/pubinfo-template/src/main.ts +25 -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 +214 -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 +0 -364
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.30",
|
|
12
12
|
description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
|
|
13
13
|
author: "Werheng <werheng.zhang@gmail.com>",
|
|
14
14
|
license: "MIT",
|
|
@@ -16,12 +16,13 @@ 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",
|
|
23
24
|
build: "tsup",
|
|
24
|
-
cli: "
|
|
25
|
+
cli: "node dist/index.js",
|
|
25
26
|
"cli:clean": "rimraf ./my-app",
|
|
26
27
|
lint: "eslint . --cache --fix"
|
|
27
28
|
},
|
|
@@ -31,28 +32,129 @@ var package_default = {
|
|
|
31
32
|
cfonts: "^3.3.0",
|
|
32
33
|
commander: "^12.1.0",
|
|
33
34
|
confbox: "^0.1.8",
|
|
34
|
-
consola: "^3.4.
|
|
35
|
+
consola: "^3.4.2",
|
|
35
36
|
giget: "^1.2.5",
|
|
36
37
|
ofetch: "^1.4.1",
|
|
37
38
|
ora: "^8.2.0",
|
|
38
39
|
rimraf: "^6.0.1",
|
|
39
|
-
semver: "^7.7.
|
|
40
|
+
semver: "^7.7.2"
|
|
40
41
|
},
|
|
41
42
|
devDependencies: {
|
|
42
|
-
"@types/node": "^22.
|
|
43
|
-
tsup: "
|
|
43
|
+
"@types/node": "^22.15.27",
|
|
44
|
+
tsup: "catalog:"
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
// src/
|
|
48
|
-
import {
|
|
49
|
-
import
|
|
50
|
-
import {
|
|
48
|
+
// src/core/generate.ts
|
|
49
|
+
import { renameSync } from "fs";
|
|
50
|
+
import { dirname, resolve as resolve2 } from "path";
|
|
51
|
+
import { cwd } from "process";
|
|
52
|
+
import { fileURLToPath } from "url";
|
|
53
|
+
|
|
54
|
+
// src/utils.ts
|
|
55
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
56
|
+
import * as fs from "fs";
|
|
57
|
+
import { readFile, writeFile } from "fs/promises";
|
|
58
|
+
import { resolve } from "path";
|
|
59
|
+
import { parseJSON, parseJSONC, stringifyJSON } from "confbox";
|
|
60
|
+
import consola from "consola";
|
|
61
|
+
function rewriteFile(path, fn) {
|
|
62
|
+
if (!existsSync(path)) {
|
|
63
|
+
consola.error(`RewriteFile fail: ${path} does not exist`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const content = readFileSync(path, { encoding: "utf-8" });
|
|
68
|
+
writeFileSync(path, fn(content));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
consola.error(`RewriteFile fail: ${error}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function copyDir(srcDir, destDir) {
|
|
74
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
75
|
+
for (const file of fs.readdirSync(srcDir)) {
|
|
76
|
+
const srcFile = resolve(srcDir, file);
|
|
77
|
+
const destFile = resolve(destDir, file);
|
|
78
|
+
copy(srcFile, destFile);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function copy(src, dest) {
|
|
82
|
+
const stat = fs.statSync(src);
|
|
83
|
+
if (stat.isDirectory()) {
|
|
84
|
+
copyDir(src, dest);
|
|
85
|
+
} else {
|
|
86
|
+
fs.copyFileSync(src, dest);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function readJSON(path) {
|
|
90
|
+
const blob = await readFile(path, "utf-8");
|
|
91
|
+
let parsed;
|
|
92
|
+
try {
|
|
93
|
+
parsed = parseJSON(blob);
|
|
94
|
+
} catch {
|
|
95
|
+
parsed = parseJSONC(blob);
|
|
96
|
+
}
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
async function writeJSON(path, json) {
|
|
100
|
+
await writeFile(path, stringifyJSON(json));
|
|
101
|
+
}
|
|
102
|
+
function assignValues(target, source) {
|
|
103
|
+
for (const [key, value] of Object.entries(source)) {
|
|
104
|
+
target[key] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function validateInput(input2) {
|
|
108
|
+
const forbiddenChars = /[<>:"/\\|?*\s]/;
|
|
109
|
+
if (forbiddenChars.test(input2)) {
|
|
110
|
+
return '\u9519\u8BEF\u63D0\u793A: \u8BE5\u503C\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u6216\u8005\u975E\u6CD5\u5B57\u7B26 (\u4F8B\u5982, <>:"/\\|?*).';
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/core/generate.ts
|
|
116
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
117
|
+
function generate(options, version) {
|
|
118
|
+
const root = cwd();
|
|
119
|
+
const templateDir = resolve2(
|
|
120
|
+
__dirname,
|
|
121
|
+
"../templates",
|
|
122
|
+
`pubinfo-template`
|
|
123
|
+
);
|
|
124
|
+
const targetPath = resolve2(root, options.dir);
|
|
125
|
+
copy(templateDir, targetPath);
|
|
126
|
+
rewriteFile(resolve2(targetPath, "src/settings.ts"), (content) => {
|
|
127
|
+
return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${options.key}'`);
|
|
128
|
+
});
|
|
129
|
+
rewriteFile(resolve2(targetPath, "openapi.config.ts"), (content) => {
|
|
130
|
+
return content.replace(/enabled:[^,]+,/g, `enabled: ${options.openapi},`);
|
|
131
|
+
});
|
|
132
|
+
rewriteFile(resolve2(targetPath, "package.json"), (content) => {
|
|
133
|
+
const pattern = /"(@?pubinfo(?:\/module-(?:auth|rbac))?)":\s*"[^"]+"/g;
|
|
134
|
+
return content.replace(pattern, (_match, pkgName) => {
|
|
135
|
+
return `"${pkgName}": "${version}"`;
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
const renameFiles = {
|
|
139
|
+
_gitignore: ".gitignore",
|
|
140
|
+
_npmrc: ".npmrc"
|
|
141
|
+
};
|
|
142
|
+
for (const [oldName, newName] of Object.entries(renameFiles)) {
|
|
143
|
+
const oldPath = resolve2(targetPath, oldName);
|
|
144
|
+
const newPath = resolve2(targetPath, newName || oldName);
|
|
145
|
+
renameSync(oldPath, newPath);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/core/init.ts
|
|
150
|
+
import { existsSync as existsSync2 } from "fs";
|
|
151
|
+
import process2 from "process";
|
|
152
|
+
import { checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
51
153
|
import colors from "ansi-colors";
|
|
52
154
|
import consola3 from "consola";
|
|
53
155
|
|
|
54
|
-
// src/constant.ts
|
|
55
|
-
var REMOTE_URL = "http://
|
|
156
|
+
// src/v1/constant.ts
|
|
157
|
+
var REMOTE_URL = "http://106.53.74.49:10000/templates";
|
|
56
158
|
var PKG_NAME = "monorepo-project-template";
|
|
57
159
|
var VERSION_FILE = "version.json";
|
|
58
160
|
var SETTING_FILE_PATH = "src/settings.default.ts";
|
|
@@ -60,14 +162,13 @@ var OPENAPI_FILE_PATH = "openapi.config.ts";
|
|
|
60
162
|
var APPS_DIR = "apps";
|
|
61
163
|
var APPS = [
|
|
62
164
|
{ name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
|
|
63
|
-
// { name: '初始化项目模板(admin)', value: 'admin' },
|
|
64
165
|
];
|
|
65
166
|
var METADATA_DIR = "configs/metadata";
|
|
66
167
|
var META_FILENAME = "pubinfo.json";
|
|
67
168
|
|
|
68
|
-
// src/fetch.ts
|
|
69
|
-
import process from "
|
|
70
|
-
import
|
|
169
|
+
// src/v1/fetch.ts
|
|
170
|
+
import process from "process";
|
|
171
|
+
import consola2 from "consola";
|
|
71
172
|
import { ofetch } from "ofetch";
|
|
72
173
|
import ora from "ora";
|
|
73
174
|
import { compare } from "semver";
|
|
@@ -94,61 +195,18 @@ async function fetchData() {
|
|
|
94
195
|
if (error.message.includes(REMOTE_URL)) {
|
|
95
196
|
error.message = error.message.replace(REMOTE_URL, "[REMOTE_URL]");
|
|
96
197
|
}
|
|
97
|
-
|
|
198
|
+
consola2.error(`\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38: ${error.message}`);
|
|
98
199
|
process.exit(1);
|
|
99
200
|
} finally {
|
|
100
201
|
spinner.stop();
|
|
101
202
|
}
|
|
102
203
|
}
|
|
103
204
|
|
|
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
|
|
205
|
+
// src/core/init.ts
|
|
148
206
|
async function init() {
|
|
149
207
|
const { version } = await fetchData();
|
|
150
|
-
const answer = {};
|
|
151
208
|
try {
|
|
209
|
+
const answer = {};
|
|
152
210
|
answer.dir = await input({ message: "\u76EE\u5F55\u540D\u79F0\uFF08dir\uFF09", default: "my-app", validate: validateInput });
|
|
153
211
|
answer.key = await input({ message: "\u9879\u76EE\u6807\u8BC6\uFF08key\uFF09", default: answer.dir, validate: validateInput });
|
|
154
212
|
if (existsSync2(answer.dir)) {
|
|
@@ -157,30 +215,34 @@ async function init() {
|
|
|
157
215
|
throw Error;
|
|
158
216
|
}
|
|
159
217
|
}
|
|
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
218
|
answer.openapi = await confirm({
|
|
181
219
|
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
220
|
default: false
|
|
183
221
|
});
|
|
222
|
+
const V1orV2 = await select({
|
|
223
|
+
message: "\u4F7F\u7528 v1 or v2 \u7248\u672C\uFF1F",
|
|
224
|
+
default: "v2",
|
|
225
|
+
choices: ["v1", "v2"]
|
|
226
|
+
});
|
|
227
|
+
const isV1 = V1orV2 === "v1";
|
|
228
|
+
if (isV1) {
|
|
229
|
+
answer.optionsV1 = JSON.parse(JSON.stringify(answer));
|
|
230
|
+
answer.optionsV1.version = await select({
|
|
231
|
+
message: "\u6846\u67B6\u7248\u672C\u53F7\uFF08version\uFF09",
|
|
232
|
+
default: version.latest,
|
|
233
|
+
choices: version.list
|
|
234
|
+
});
|
|
235
|
+
answer.optionsV1.apps = await checkbox({
|
|
236
|
+
message: "\u9009\u62E9\u5E94\u7528\u6A21\u5757\uFF08apps\uFF09",
|
|
237
|
+
choices: APPS,
|
|
238
|
+
validate: (input2) => {
|
|
239
|
+
if (input2.length === 0) {
|
|
240
|
+
return "\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u5E94\u7528";
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
184
246
|
return answer;
|
|
185
247
|
} catch {
|
|
186
248
|
consola3.fail("\u64CD\u4F5C\u7EC8\u6B62");
|
|
@@ -188,8 +250,30 @@ async function init() {
|
|
|
188
250
|
}
|
|
189
251
|
}
|
|
190
252
|
|
|
191
|
-
// src/
|
|
192
|
-
import
|
|
253
|
+
// src/log.ts
|
|
254
|
+
import fonts from "cfonts";
|
|
255
|
+
function bootstrop() {
|
|
256
|
+
printLoGo("PUBINFO");
|
|
257
|
+
function printLoGo(logo) {
|
|
258
|
+
fonts.say(logo, {
|
|
259
|
+
font: "simple3d",
|
|
260
|
+
align: "left",
|
|
261
|
+
background: "transparent",
|
|
262
|
+
letterSpacing: 1,
|
|
263
|
+
lineHeight: 1,
|
|
264
|
+
space: true,
|
|
265
|
+
maxLength: 0,
|
|
266
|
+
spaceless: false,
|
|
267
|
+
gradient: ["blue", "magenta"],
|
|
268
|
+
independentGradient: false,
|
|
269
|
+
transitionGradient: false,
|
|
270
|
+
env: "node"
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/v1/download.ts
|
|
276
|
+
import process3 from "process";
|
|
193
277
|
import colors2 from "ansi-colors";
|
|
194
278
|
import consola4 from "consola";
|
|
195
279
|
import { downloadTemplate } from "giget";
|
|
@@ -211,7 +295,6 @@ async function download(options) {
|
|
|
211
295
|
providers: { pubinfo },
|
|
212
296
|
force: true,
|
|
213
297
|
forceClean: true,
|
|
214
|
-
// auth: options.auth,
|
|
215
298
|
dir: options.dir
|
|
216
299
|
});
|
|
217
300
|
} catch (error) {
|
|
@@ -238,44 +321,22 @@ function loading() {
|
|
|
238
321
|
};
|
|
239
322
|
}
|
|
240
323
|
|
|
241
|
-
// src/
|
|
242
|
-
import
|
|
243
|
-
|
|
244
|
-
|
|
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";
|
|
266
|
-
import process4 from "node:process";
|
|
324
|
+
// src/v1/rewrite.ts
|
|
325
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
|
|
326
|
+
import { resolve as resolve3 } from "path";
|
|
327
|
+
import process4 from "process";
|
|
267
328
|
import consola5 from "consola";
|
|
268
329
|
import { rimrafSync } from "rimraf";
|
|
269
330
|
async function rewrite(options) {
|
|
270
331
|
const { dir } = options;
|
|
271
332
|
const root = process4.cwd();
|
|
272
|
-
const projectDir =
|
|
273
|
-
writeMetaJSON(
|
|
274
|
-
writeApps(
|
|
333
|
+
const projectDir = resolve3(root, dir);
|
|
334
|
+
writeMetaJSON(resolve3(projectDir, METADATA_DIR), options);
|
|
335
|
+
writeApps(resolve3(projectDir, APPS_DIR), options);
|
|
275
336
|
}
|
|
276
337
|
async function writeMetaJSON(metaDir, options) {
|
|
277
338
|
const { key, version, apps, openapi } = options;
|
|
278
|
-
const path =
|
|
339
|
+
const path = resolve3(metaDir, META_FILENAME);
|
|
279
340
|
try {
|
|
280
341
|
const json = await readJSON(path);
|
|
281
342
|
assignValues(json, {
|
|
@@ -296,10 +357,10 @@ function writeApps(appsDir, options) {
|
|
|
296
357
|
return;
|
|
297
358
|
}
|
|
298
359
|
try {
|
|
299
|
-
|
|
300
|
-
const appPath =
|
|
301
|
-
const settingPath =
|
|
302
|
-
const openapiPath =
|
|
360
|
+
readdirSync2(appsDir).forEach((app) => {
|
|
361
|
+
const appPath = resolve3(appsDir, app);
|
|
362
|
+
const settingPath = resolve3(appPath, SETTING_FILE_PATH);
|
|
363
|
+
const openapiPath = resolve3(appPath, OPENAPI_FILE_PATH);
|
|
303
364
|
if (!apps.includes(app)) {
|
|
304
365
|
rimrafSync(appPath);
|
|
305
366
|
return;
|
|
@@ -324,19 +385,16 @@ async function main() {
|
|
|
324
385
|
bootstrop();
|
|
325
386
|
try {
|
|
326
387
|
const answer = await init();
|
|
327
|
-
|
|
328
|
-
|
|
388
|
+
if (answer.optionsV1) {
|
|
389
|
+
await download(answer.optionsV1);
|
|
390
|
+
await rewrite(answer.optionsV1);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
generate(answer, package_default.version);
|
|
329
394
|
} catch (error) {
|
|
330
395
|
consola6.error(error);
|
|
331
396
|
}
|
|
332
397
|
});
|
|
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
398
|
program.parse();
|
|
341
399
|
}
|
|
342
400
|
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.30",
|
|
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",
|
|
@@ -17,21 +18,21 @@
|
|
|
17
18
|
"cfonts": "^3.3.0",
|
|
18
19
|
"commander": "^12.1.0",
|
|
19
20
|
"confbox": "^0.1.8",
|
|
20
|
-
"consola": "^3.4.
|
|
21
|
+
"consola": "^3.4.2",
|
|
21
22
|
"giget": "^1.2.5",
|
|
22
23
|
"ofetch": "^1.4.1",
|
|
23
24
|
"ora": "^8.2.0",
|
|
24
25
|
"rimraf": "^6.0.1",
|
|
25
|
-
"semver": "^7.7.
|
|
26
|
+
"semver": "^7.7.2"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^22.
|
|
29
|
-
"tsup": "^8.
|
|
29
|
+
"@types/node": "^22.15.27",
|
|
30
|
+
"tsup": "^8.5.0"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
33
|
"dev": "tsup --watch src",
|
|
33
34
|
"build": "tsup",
|
|
34
|
-
"cli": "
|
|
35
|
+
"cli": "node dist/index.js",
|
|
35
36
|
"cli:clean": "rimraf ./my-app",
|
|
36
37
|
"lint": "eslint . --cache --fix"
|
|
37
38
|
}
|
|
@@ -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,37 @@
|
|
|
1
|
+
.pubinfo
|
|
2
|
+
.eslintcache
|
|
3
|
+
.stylelintcache
|
|
4
|
+
|
|
5
|
+
# auto generated
|
|
6
|
+
auto-imports.d.ts
|
|
7
|
+
components.d.ts
|
|
8
|
+
|
|
9
|
+
.DS_Store
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
cache
|
|
13
|
+
coverage
|
|
14
|
+
.turbo
|
|
15
|
+
.eslintcache
|
|
16
|
+
.stylelintcache
|
|
17
|
+
|
|
18
|
+
# local env files
|
|
19
|
+
.env.local
|
|
20
|
+
.env.*.local
|
|
21
|
+
|
|
22
|
+
# Log files
|
|
23
|
+
npm-debug.log*
|
|
24
|
+
yarn-debug.log*
|
|
25
|
+
yarn-error.log*
|
|
26
|
+
pnpm-debug.log*
|
|
27
|
+
lerna-debug.log*
|
|
28
|
+
|
|
29
|
+
# Editor directories and files
|
|
30
|
+
.idea
|
|
31
|
+
# .vscode
|
|
32
|
+
*.suo
|
|
33
|
+
*.ntvs*
|
|
34
|
+
*.njsproj
|
|
35
|
+
*.sln
|
|
36
|
+
*.sw?
|
|
37
|
+
|
|
@@ -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
|
+
};
|