create-pubinfo 0.4.2 → 0.5.0
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 +16 -7
- package/dist/index.js +16 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_consola6 = __toESM(require("consola"), 1);
|
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "create-pubinfo",
|
|
33
33
|
type: "module",
|
|
34
|
-
version: "0.
|
|
34
|
+
version: "0.5.0",
|
|
35
35
|
description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
|
|
36
36
|
author: "Werheng <werheng.zhang@gmail.com>",
|
|
37
37
|
license: "MIT",
|
|
@@ -54,14 +54,14 @@ var package_default = {
|
|
|
54
54
|
dependencies: {
|
|
55
55
|
"@inquirer/prompts": "^4.3.3",
|
|
56
56
|
"ansi-colors": "^4.1.3",
|
|
57
|
-
cfonts: "^3.
|
|
58
|
-
commander: "^12.
|
|
57
|
+
cfonts: "^3.3.0",
|
|
58
|
+
commander: "^12.1.0",
|
|
59
59
|
confbox: "^0.1.7",
|
|
60
60
|
consola: "^3.2.3",
|
|
61
61
|
giget: "^1.2.3",
|
|
62
62
|
ofetch: "^1.3.4",
|
|
63
63
|
ora: "^8.0.1",
|
|
64
|
-
rimraf: "^5.0.
|
|
64
|
+
rimraf: "^5.0.7",
|
|
65
65
|
semver: "^7.6.2"
|
|
66
66
|
}
|
|
67
67
|
};
|
|
@@ -79,6 +79,7 @@ var REMOTE_URL = "http://124.223.184.245:20000/templates";
|
|
|
79
79
|
var PKG_NAME = "monorepo-project-template";
|
|
80
80
|
var VERSION_FILE = "version.json";
|
|
81
81
|
var SETTING_FILE_PATH = "src/settings.default.ts";
|
|
82
|
+
var OPENAPI_FILE_PATH = "openapi.config.ts";
|
|
82
83
|
var APPS_DIR = "apps";
|
|
83
84
|
var APPS = [
|
|
84
85
|
{ name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
|
|
@@ -181,14 +182,15 @@ async function rewrite(options) {
|
|
|
181
182
|
writeApps((0, import_node_path.resolve)(projectDir, APPS_DIR), options);
|
|
182
183
|
}
|
|
183
184
|
async function writeMetaJSON(metaDir, options) {
|
|
184
|
-
const { key, version, apps } = options;
|
|
185
|
+
const { key, version, apps, openapi } = options;
|
|
185
186
|
const path = (0, import_node_path.resolve)(metaDir, META_FILENAME);
|
|
186
187
|
try {
|
|
187
188
|
const json = await readJSON(path);
|
|
188
189
|
assignValues(json, {
|
|
189
190
|
key,
|
|
190
191
|
version,
|
|
191
|
-
apps
|
|
192
|
+
apps,
|
|
193
|
+
openapi
|
|
192
194
|
});
|
|
193
195
|
await writeJSON(path, json);
|
|
194
196
|
} catch (error) {
|
|
@@ -196,7 +198,7 @@ async function writeMetaJSON(metaDir, options) {
|
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
function writeApps(appsDir, options) {
|
|
199
|
-
const { key, apps = [] } = options;
|
|
201
|
+
const { key, apps = [], openapi } = options;
|
|
200
202
|
if (!(0, import_node_fs2.existsSync)(appsDir)) {
|
|
201
203
|
import_consola3.default.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${appsDir} \u4E0D\u5B58\u5728`);
|
|
202
204
|
return;
|
|
@@ -205,6 +207,7 @@ function writeApps(appsDir, options) {
|
|
|
205
207
|
(0, import_node_fs2.readdirSync)(appsDir).forEach((app) => {
|
|
206
208
|
const appPath = (0, import_node_path.resolve)(appsDir, app);
|
|
207
209
|
const settingPath = (0, import_node_path.resolve)(appPath, SETTING_FILE_PATH);
|
|
210
|
+
const openapiPath = (0, import_node_path.resolve)(appPath, OPENAPI_FILE_PATH);
|
|
208
211
|
if (!apps.includes(app)) {
|
|
209
212
|
(0, import_rimraf.rimrafSync)(appPath);
|
|
210
213
|
return;
|
|
@@ -212,6 +215,9 @@ function writeApps(appsDir, options) {
|
|
|
212
215
|
rewriteFile(settingPath, (content) => {
|
|
213
216
|
return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${key}'`);
|
|
214
217
|
});
|
|
218
|
+
rewriteFile(openapiPath, (content) => {
|
|
219
|
+
return content.replace(/enabled:[^,]+,/g, `enabled: ${openapi},`);
|
|
220
|
+
});
|
|
215
221
|
});
|
|
216
222
|
} catch (error) {
|
|
217
223
|
import_consola3.default.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${error}`);
|
|
@@ -312,6 +318,9 @@ async function init() {
|
|
|
312
318
|
return true;
|
|
313
319
|
}
|
|
314
320
|
});
|
|
321
|
+
answer.openapi = await (0, import_prompts.confirm)({
|
|
322
|
+
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"
|
|
323
|
+
});
|
|
315
324
|
return answer;
|
|
316
325
|
} catch (error) {
|
|
317
326
|
import_consola5.default.fail("\u64CD\u4F5C\u7EC8\u6B62");
|
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: "0.
|
|
11
|
+
version: "0.5.0",
|
|
12
12
|
description: "\u521D\u59CB\u5316\u9879\u76EE\u6846\u67B6",
|
|
13
13
|
author: "Werheng <werheng.zhang@gmail.com>",
|
|
14
14
|
license: "MIT",
|
|
@@ -31,14 +31,14 @@ var package_default = {
|
|
|
31
31
|
dependencies: {
|
|
32
32
|
"@inquirer/prompts": "^4.3.3",
|
|
33
33
|
"ansi-colors": "^4.1.3",
|
|
34
|
-
cfonts: "^3.
|
|
35
|
-
commander: "^12.
|
|
34
|
+
cfonts: "^3.3.0",
|
|
35
|
+
commander: "^12.1.0",
|
|
36
36
|
confbox: "^0.1.7",
|
|
37
37
|
consola: "^3.2.3",
|
|
38
38
|
giget: "^1.2.3",
|
|
39
39
|
ofetch: "^1.3.4",
|
|
40
40
|
ora: "^8.0.1",
|
|
41
|
-
rimraf: "^5.0.
|
|
41
|
+
rimraf: "^5.0.7",
|
|
42
42
|
semver: "^7.6.2"
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -56,6 +56,7 @@ var REMOTE_URL = "http://124.223.184.245:20000/templates";
|
|
|
56
56
|
var PKG_NAME = "monorepo-project-template";
|
|
57
57
|
var VERSION_FILE = "version.json";
|
|
58
58
|
var SETTING_FILE_PATH = "src/settings.default.ts";
|
|
59
|
+
var OPENAPI_FILE_PATH = "openapi.config.ts";
|
|
59
60
|
var APPS_DIR = "apps";
|
|
60
61
|
var APPS = [
|
|
61
62
|
{ name: "\u7528\u6237\u6743\u9650\u7CFB\u7EDF\uFF08rbac\uFF09", value: "rbac" }
|
|
@@ -158,14 +159,15 @@ async function rewrite(options) {
|
|
|
158
159
|
writeApps(resolve(projectDir, APPS_DIR), options);
|
|
159
160
|
}
|
|
160
161
|
async function writeMetaJSON(metaDir, options) {
|
|
161
|
-
const { key, version, apps } = options;
|
|
162
|
+
const { key, version, apps, openapi } = options;
|
|
162
163
|
const path = resolve(metaDir, META_FILENAME);
|
|
163
164
|
try {
|
|
164
165
|
const json = await readJSON(path);
|
|
165
166
|
assignValues(json, {
|
|
166
167
|
key,
|
|
167
168
|
version,
|
|
168
|
-
apps
|
|
169
|
+
apps,
|
|
170
|
+
openapi
|
|
169
171
|
});
|
|
170
172
|
await writeJSON(path, json);
|
|
171
173
|
} catch (error) {
|
|
@@ -173,7 +175,7 @@ async function writeMetaJSON(metaDir, options) {
|
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
function writeApps(appsDir, options) {
|
|
176
|
-
const { key, apps = [] } = options;
|
|
178
|
+
const { key, apps = [], openapi } = options;
|
|
177
179
|
if (!existsSync2(appsDir)) {
|
|
178
180
|
consola3.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${appsDir} \u4E0D\u5B58\u5728`);
|
|
179
181
|
return;
|
|
@@ -182,6 +184,7 @@ function writeApps(appsDir, options) {
|
|
|
182
184
|
readdirSync(appsDir).forEach((app) => {
|
|
183
185
|
const appPath = resolve(appsDir, app);
|
|
184
186
|
const settingPath = resolve(appPath, SETTING_FILE_PATH);
|
|
187
|
+
const openapiPath = resolve(appPath, OPENAPI_FILE_PATH);
|
|
185
188
|
if (!apps.includes(app)) {
|
|
186
189
|
rimrafSync(appPath);
|
|
187
190
|
return;
|
|
@@ -189,6 +192,9 @@ function writeApps(appsDir, options) {
|
|
|
189
192
|
rewriteFile(settingPath, (content) => {
|
|
190
193
|
return content.replace(/storagePrefix:\s*'([^']*)'/g, `storagePrefix: '${key}'`);
|
|
191
194
|
});
|
|
195
|
+
rewriteFile(openapiPath, (content) => {
|
|
196
|
+
return content.replace(/enabled:[^,]+,/g, `enabled: ${openapi},`);
|
|
197
|
+
});
|
|
192
198
|
});
|
|
193
199
|
} catch (error) {
|
|
194
200
|
consola3.error(`\u521D\u59CB\u5316 apps \u5931\u8D25: ${error}`);
|
|
@@ -289,6 +295,9 @@ async function init() {
|
|
|
289
295
|
return true;
|
|
290
296
|
}
|
|
291
297
|
});
|
|
298
|
+
answer.openapi = await confirm({
|
|
299
|
+
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"
|
|
300
|
+
});
|
|
292
301
|
return answer;
|
|
293
302
|
} catch (error) {
|
|
294
303
|
consola5.fail("\u64CD\u4F5C\u7EC8\u6B62");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pubinfo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "初始化项目框架",
|
|
6
6
|
"author": "Werheng <werheng.zhang@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@inquirer/prompts": "^4.3.3",
|
|
20
20
|
"ansi-colors": "^4.1.3",
|
|
21
|
-
"cfonts": "^3.
|
|
22
|
-
"commander": "^12.
|
|
21
|
+
"cfonts": "^3.3.0",
|
|
22
|
+
"commander": "^12.1.0",
|
|
23
23
|
"confbox": "^0.1.7",
|
|
24
24
|
"consola": "^3.2.3",
|
|
25
25
|
"giget": "^1.2.3",
|
|
26
26
|
"ofetch": "^1.3.4",
|
|
27
27
|
"ora": "^8.0.1",
|
|
28
|
-
"rimraf": "^5.0.
|
|
28
|
+
"rimraf": "^5.0.7",
|
|
29
29
|
"semver": "^7.6.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|