listpage_cli 0.0.190 → 0.0.192
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/bin/cli.js +14 -198
- package/bin/copy.js +99 -0
- package/bin/prompts.js +67 -0
- package/bin/utils.js +20 -0
- package/package.json +2 -2
- package/templates/backend-template/.gitignore.tmpl +56 -0
- package/templates/{app-templates/backend-tempalte → backend-template}/package.json.tmpl +2 -3
- package/templates/backend-template/prisma/schema.prisma +14 -0
- package/templates/frontend-template/.gitignore.tmpl +16 -0
- package/templates/{app-templates/frontend-template → frontend-template}/package.json.tmpl +1 -1
- package/templates/rush-template/.gitignore.tmpl +122 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/.prettierrc +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/README.md +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/nest-cli.json +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/src/app.controller.ts +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/src/app.module.ts +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/src/app.service.ts +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/src/main.ts +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/tsconfig.build.json +0 -0
- /package/templates/{app-templates/backend-tempalte → backend-template}/tsconfig.json +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/.prettierignore +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/.prettierrc +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/AGENTS.md +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/README.md +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/public/favicon.png +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/rsbuild.config.ts +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/App.css +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/App.tsx +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/Layout.tsx +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/api/config.tsx +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/api/index.ts +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/env.d.ts +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/index.tsx +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/src/router/index.tsx +0 -0
- /package/templates/{app-templates/frontend-template → frontend-template}/tsconfig.json +0 -0
- /package/templates/{.gitattributes → rush-template/.gitattributes} +0 -0
- /package/templates/{.github → rush-template/.github}/workflows/ci.yml +0 -0
- /package/templates/{common → rush-template/common}/config/rush/.npmrc-publish +0 -0
- /package/templates/{common → rush-template/common}/config/rush/.pnpmfile.cjs +0 -0
- /package/templates/{common → rush-template/common}/config/rush/artifactory.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/build-cache.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/cobuild.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/command-line.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/common-versions.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/custom-tips.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/experiments.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/pnpm-config.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/rush-plugins.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/subspaces.json +0 -0
- /package/templates/{common → rush-template/common}/config/rush/version-policies.json +0 -0
- /package/templates/{common → rush-template/common}/git-hooks/commit-msg.sample +0 -0
- /package/templates/{rush.json → rush-template/rush.json} +0 -0
package/bin/cli.js
CHANGED
|
@@ -4,225 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const h = [
|
|
12
|
-
"用法: listpage_cli init",
|
|
13
|
-
"说明: 进入中文引导式交互,按提示填写即可",
|
|
14
|
-
].join("\n");
|
|
15
|
-
console.log(h);
|
|
16
|
-
}
|
|
17
|
-
function printVersion() {
|
|
18
|
-
try {
|
|
19
|
-
const p = path_1.default.join(__dirname, "..", "package.json");
|
|
20
|
-
const pkg = JSON.parse(fs_1.default.readFileSync(p, "utf8"));
|
|
21
|
-
console.log(pkg.version || "");
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
console.log("");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function safePkgName(name) {
|
|
28
|
-
return name
|
|
29
|
-
.toLowerCase()
|
|
30
|
-
.replace(/\s+/g, "-")
|
|
31
|
-
.replace(/[^a-z0-9-_.]/g, "-");
|
|
32
|
-
}
|
|
33
|
-
function listFilesRecursive(root) {
|
|
34
|
-
const out = [];
|
|
35
|
-
const stack = [root];
|
|
36
|
-
while (stack.length) {
|
|
37
|
-
const d = stack.pop();
|
|
38
|
-
const items = fs_1.default.readdirSync(d);
|
|
39
|
-
items.forEach((name) => {
|
|
40
|
-
const p = path_1.default.join(d, name);
|
|
41
|
-
const stat = fs_1.default.statSync(p);
|
|
42
|
-
if (stat.isDirectory())
|
|
43
|
-
stack.push(p);
|
|
44
|
-
else
|
|
45
|
-
out.push(p);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
50
|
-
function ensureDir(dir) {
|
|
51
|
-
if (!fs_1.default.existsSync(dir))
|
|
52
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
53
|
-
}
|
|
54
|
-
function isDirEmpty(dir) {
|
|
55
|
-
return !fs_1.default.existsSync(dir) || fs_1.default.readdirSync(dir).length === 0;
|
|
56
|
-
}
|
|
8
|
+
const prompts_1 = require("./prompts");
|
|
9
|
+
const copy_1 = require("./copy");
|
|
57
10
|
async function initCmd() {
|
|
58
|
-
const projectName = await askProjectPath();
|
|
11
|
+
const projectName = await (0, prompts_1.askProjectPath)();
|
|
59
12
|
const targetDir = path_1.default.resolve(process.cwd(), projectName);
|
|
60
|
-
if (!isDirEmpty(targetDir)) {
|
|
61
|
-
|
|
62
|
-
type: "confirm",
|
|
63
|
-
name: "ok",
|
|
64
|
-
message: "目标目录非空,是否覆盖?",
|
|
65
|
-
initial: false,
|
|
66
|
-
});
|
|
67
|
-
if (!ok) {
|
|
68
|
-
console.error("已取消");
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
13
|
+
if (!(0, copy_1.isDirEmpty)(targetDir)) {
|
|
14
|
+
await (0, prompts_1.askOverwrite)();
|
|
71
15
|
}
|
|
72
|
-
ensureDir(targetDir);
|
|
16
|
+
(0, copy_1.ensureDir)(targetDir);
|
|
73
17
|
return initRush(targetDir, projectName);
|
|
74
18
|
}
|
|
75
|
-
async function askRushQuestions() {
|
|
76
|
-
const { name: frontendName } = await (0, enquirer_1.prompt)({
|
|
77
|
-
type: "input",
|
|
78
|
-
name: "name",
|
|
79
|
-
message: "请输入前端项目名称,为空表示不创建前端项目",
|
|
80
|
-
initial: "",
|
|
81
|
-
});
|
|
82
|
-
const { name: backendName } = await (0, enquirer_1.prompt)({
|
|
83
|
-
type: "input",
|
|
84
|
-
name: "name",
|
|
85
|
-
message: "请输入后端项目名称,为空表示不创建后端项目",
|
|
86
|
-
initial: "",
|
|
87
|
-
});
|
|
88
|
-
return { frontendName, backendName };
|
|
89
|
-
}
|
|
90
|
-
function copyRushSkeleton(targetDir) {
|
|
91
|
-
const srcRoot = path_1.default.join(__dirname, "..", "templates");
|
|
92
|
-
const exclude = new Set(["vanilla-js", "app-templates"]);
|
|
93
|
-
const entries = fs_1.default.readdirSync(srcRoot);
|
|
94
|
-
entries.forEach((name) => {
|
|
95
|
-
if (exclude.has(name))
|
|
96
|
-
return;
|
|
97
|
-
const srcPath = path_1.default.join(srcRoot, name);
|
|
98
|
-
const destPath = path_1.default.join(targetDir, name);
|
|
99
|
-
const stat = fs_1.default.statSync(srcPath);
|
|
100
|
-
if (stat.isDirectory()) {
|
|
101
|
-
copyDir(srcPath, destPath);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
ensureDir(path_1.default.dirname(destPath));
|
|
105
|
-
fs_1.default.copyFileSync(srcPath, destPath);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function copyDir(src, dest) {
|
|
110
|
-
ensureDir(dest);
|
|
111
|
-
for (const entry of fs_1.default.readdirSync(src)) {
|
|
112
|
-
const s = path_1.default.join(src, entry);
|
|
113
|
-
const outEntry = entry === "gitignore" ? ".gitignore" : entry;
|
|
114
|
-
const d = path_1.default.join(dest, outEntry);
|
|
115
|
-
const stat = fs_1.default.statSync(s);
|
|
116
|
-
if (stat.isDirectory())
|
|
117
|
-
copyDir(s, d);
|
|
118
|
-
else {
|
|
119
|
-
ensureDir(path_1.default.dirname(d));
|
|
120
|
-
fs_1.default.copyFileSync(s, d);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function readJsonWithComments(str) {
|
|
125
|
-
const noBlock = str.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
126
|
-
const noLine = noBlock.replace(/(^|\s)\/\/.*$/gm, "");
|
|
127
|
-
const noTrailingComma = noLine.replace(/,\s*([}\]])/g, "$1");
|
|
128
|
-
return JSON.parse(noTrailingComma);
|
|
129
|
-
}
|
|
130
19
|
async function initRush(targetDir, projectName) {
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const { frontendName, backendName } = await askRushQuestions();
|
|
135
|
-
const projects = rushCfg.projects || [];
|
|
20
|
+
(0, copy_1.copyRushTemplate)(targetDir);
|
|
21
|
+
const { frontendName, backendName } = await (0, prompts_1.askRushQuestions)();
|
|
22
|
+
(0, copy_1.updateRushJsonProjects)(path_1.default.join(targetDir, "rush.json"), frontendName, backendName);
|
|
136
23
|
if (frontendName) {
|
|
137
|
-
|
|
138
|
-
scaffoldApp(targetDir, "frontend", frontendName, pkg);
|
|
139
|
-
projects.push({
|
|
140
|
-
packageName: pkg,
|
|
141
|
-
projectFolder: `apps/${frontendName}`,
|
|
142
|
-
reviewCategory: "production",
|
|
143
|
-
});
|
|
24
|
+
(0, copy_1.copyFrontendTemplate)(targetDir, frontendName);
|
|
144
25
|
}
|
|
145
26
|
if (backendName) {
|
|
146
|
-
|
|
147
|
-
scaffoldApp(targetDir, "backend", backendName, pkg);
|
|
148
|
-
projects.push({
|
|
149
|
-
packageName: pkg,
|
|
150
|
-
projectFolder: `servers/${backendName}`,
|
|
151
|
-
reviewCategory: "production",
|
|
152
|
-
});
|
|
27
|
+
(0, copy_1.copyBackendTemplate)(targetDir, backendName);
|
|
153
28
|
}
|
|
154
|
-
rushCfg.projects = projects;
|
|
155
|
-
fs_1.default.writeFileSync(cfgPath, JSON.stringify(rushCfg, null, 2));
|
|
156
|
-
if (fs_1.default.existsSync(path_1.default.join(targetDir, "common"))) {
|
|
157
|
-
console.log("Skipping rush update in CLI; install manually if needed.");
|
|
158
|
-
}
|
|
159
|
-
console.log(`Rush repo created at ${targetDir}`);
|
|
160
|
-
console.log("Next:");
|
|
161
29
|
if (projectName !== ".")
|
|
162
30
|
console.log(` cd ${projectName}`);
|
|
163
|
-
console.log("
|
|
164
|
-
}
|
|
165
|
-
async function askProjectPath() {
|
|
166
|
-
const ans = await (0, enquirer_1.prompt)({
|
|
167
|
-
type: "input",
|
|
168
|
-
name: "path",
|
|
169
|
-
message: "请填写项目名称或路径,如果填.表示直接把项目放到当前目录下",
|
|
170
|
-
initial: ".",
|
|
171
|
-
});
|
|
172
|
-
const p = (ans.path || ".").trim();
|
|
173
|
-
return p || ".";
|
|
174
|
-
}
|
|
175
|
-
function composePkgName(name) {
|
|
176
|
-
const n = safePkgName(name);
|
|
177
|
-
return `${n}`;
|
|
178
|
-
}
|
|
179
|
-
function scaffoldApp(repoDir, kind, appName, pkgName) {
|
|
180
|
-
const tplBase = path_1.default.join(__dirname, "..", "templates", "app-templates");
|
|
181
|
-
const dir = kind === "frontend"
|
|
182
|
-
? "frontend-template"
|
|
183
|
-
: kind === "backend"
|
|
184
|
-
? "backend-tempalte"
|
|
185
|
-
: undefined;
|
|
186
|
-
if (!dir)
|
|
187
|
-
throw new Error(`Unknown kind: ${kind}`);
|
|
188
|
-
const srcDir = path_1.default.join(tplBase, dir);
|
|
189
|
-
const destBase = kind === "frontend" ? "apps" : "servers";
|
|
190
|
-
const destDir = path_1.default.join(repoDir, destBase, appName);
|
|
191
|
-
copyTemplateDir(srcDir, destDir, { APP_NAME: appName, PKG_NAME: pkgName });
|
|
192
|
-
}
|
|
193
|
-
function copyTemplateDir(srcDir, destDir, vars) {
|
|
194
|
-
const files = listFilesRecursive(srcDir);
|
|
195
|
-
files.forEach((src) => {
|
|
196
|
-
const rel = path_1.default.relative(srcDir, src);
|
|
197
|
-
const isTmpl = rel.endsWith(".tmpl");
|
|
198
|
-
let outRel = isTmpl ? rel.slice(0, -5) : rel;
|
|
199
|
-
if (path_1.default.basename(outRel) === "gitignore") {
|
|
200
|
-
outRel = path_1.default.join(path_1.default.dirname(outRel), ".gitignore");
|
|
201
|
-
}
|
|
202
|
-
const dest = path_1.default.join(destDir, outRel);
|
|
203
|
-
ensureDir(path_1.default.dirname(dest));
|
|
204
|
-
const buf = fs_1.default.readFileSync(src, "utf8");
|
|
205
|
-
const content = isTmpl ? renderVars(buf, vars) : buf;
|
|
206
|
-
fs_1.default.writeFileSync(dest, content);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function renderVars(str, vars) {
|
|
210
|
-
let out = str;
|
|
211
|
-
for (const [k, v] of Object.entries(vars)) {
|
|
212
|
-
const re = new RegExp(`__${k}__`, "g");
|
|
213
|
-
out = out.replace(re, v);
|
|
214
|
-
}
|
|
215
|
-
return out;
|
|
31
|
+
console.log("请手动执行 rush update 安装依赖");
|
|
216
32
|
}
|
|
217
33
|
async function main() {
|
|
218
34
|
const args = process.argv.slice(2);
|
|
219
35
|
if (args.includes("--version") || args.includes("-V")) {
|
|
220
|
-
printVersion();
|
|
36
|
+
(0, prompts_1.printVersion)();
|
|
221
37
|
return;
|
|
222
38
|
}
|
|
223
39
|
const cmd = args[0];
|
|
224
40
|
if (cmd === "init")
|
|
225
41
|
return initCmd();
|
|
226
|
-
printHelp();
|
|
42
|
+
(0, prompts_1.printHelp)();
|
|
227
43
|
}
|
|
228
44
|
main();
|
package/bin/copy.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.copyRushTemplate = copyRushTemplate;
|
|
7
|
+
exports.updateRushJsonProjects = updateRushJsonProjects;
|
|
8
|
+
exports.copyFrontendTemplate = copyFrontendTemplate;
|
|
9
|
+
exports.copyBackendTemplate = copyBackendTemplate;
|
|
10
|
+
exports.ensureDir = ensureDir;
|
|
11
|
+
exports.isDirEmpty = isDirEmpty;
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
function copyRushTemplate(targetDir) {
|
|
16
|
+
const source = getTemplateDir("rush");
|
|
17
|
+
copyDir(source, targetDir, {});
|
|
18
|
+
}
|
|
19
|
+
function updateRushJsonProjects(filepath, feAppName, beAppName) {
|
|
20
|
+
const projects = [];
|
|
21
|
+
if (feAppName) {
|
|
22
|
+
projects.push({
|
|
23
|
+
packageName: (0, utils_1.composePkgName)(feAppName),
|
|
24
|
+
projectFolder: `apps/${feAppName}`,
|
|
25
|
+
reviewCategory: "production",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (beAppName) {
|
|
29
|
+
const pkg = (0, utils_1.composePkgName)(beAppName);
|
|
30
|
+
projects.push({
|
|
31
|
+
packageName: pkg,
|
|
32
|
+
projectFolder: `servers/${beAppName}`,
|
|
33
|
+
reviewCategory: "production",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const content = (0, fs_1.readFileSync)(filepath, "utf8");
|
|
37
|
+
const json = (0, utils_1.readJsonWithComments)(content);
|
|
38
|
+
json.projects = projects;
|
|
39
|
+
(0, fs_1.writeFileSync)(filepath, JSON.stringify(json, null, 2), { encoding: "utf-8" });
|
|
40
|
+
}
|
|
41
|
+
function copyFrontendTemplate(targetDir, appName) {
|
|
42
|
+
appName = (0, utils_1.composePkgName)(appName);
|
|
43
|
+
targetDir = path_1.default.join(targetDir, `apps/${appName}`);
|
|
44
|
+
const source = getTemplateDir("frontend");
|
|
45
|
+
copyDir(source, targetDir, {
|
|
46
|
+
PKG_NAME: appName,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function copyBackendTemplate(targetDir, appName) {
|
|
50
|
+
appName = (0, utils_1.composePkgName)(appName);
|
|
51
|
+
targetDir = path_1.default.join(targetDir, `servers/${appName}`);
|
|
52
|
+
const source = getTemplateDir("backend");
|
|
53
|
+
copyDir(source, targetDir, {
|
|
54
|
+
PKG_NAME: appName,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function getTemplateDir(type) {
|
|
58
|
+
return path_1.default.join(__dirname, "..", "templates", `${type}-template`);
|
|
59
|
+
}
|
|
60
|
+
function copyDir(source, destination, vars) {
|
|
61
|
+
ensureDir(destination);
|
|
62
|
+
const files = (0, fs_1.readdirSync)(source);
|
|
63
|
+
files.forEach((file) => {
|
|
64
|
+
const s = path_1.default.join(source, file);
|
|
65
|
+
const d = path_1.default.join(destination, file);
|
|
66
|
+
const stat = (0, fs_1.statSync)(s);
|
|
67
|
+
if (stat.isDirectory()) {
|
|
68
|
+
copyDir(s, d, vars);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
ensureDir(path_1.default.dirname(d));
|
|
72
|
+
const isTmpl = file.endsWith(".tmpl");
|
|
73
|
+
// 正常文件直接复制
|
|
74
|
+
if (!isTmpl) {
|
|
75
|
+
(0, fs_1.copyFileSync)(s, d);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// 模板文件替换变量后复制
|
|
79
|
+
const template = (0, fs_1.readFileSync)(s, "utf8");
|
|
80
|
+
const content = compileTemplateContent(template, vars);
|
|
81
|
+
(0, fs_1.writeFileSync)(d.slice(0, -5), content, { encoding: "utf-8" });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function ensureDir(dir) {
|
|
86
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
87
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
88
|
+
}
|
|
89
|
+
function compileTemplateContent(str, vars) {
|
|
90
|
+
let out = str;
|
|
91
|
+
for (const [k, v] of Object.entries(vars)) {
|
|
92
|
+
const re = new RegExp(`__${k}__`, "g");
|
|
93
|
+
out = out.replace(re, v);
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
function isDirEmpty(dir) {
|
|
98
|
+
return !(0, fs_1.existsSync)(dir) || (0, fs_1.readdirSync)(dir).length === 0;
|
|
99
|
+
}
|
package/bin/prompts.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.askRushQuestions = askRushQuestions;
|
|
7
|
+
exports.askProjectPath = askProjectPath;
|
|
8
|
+
exports.askOverwrite = askOverwrite;
|
|
9
|
+
exports.printHelp = printHelp;
|
|
10
|
+
exports.printVersion = printVersion;
|
|
11
|
+
const enquirer_1 = require("enquirer");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
async function askRushQuestions() {
|
|
15
|
+
const { name: frontendName } = await (0, enquirer_1.prompt)({
|
|
16
|
+
type: "input",
|
|
17
|
+
name: "name",
|
|
18
|
+
message: "请输入前端项目名称,为空表示不创建前端项目",
|
|
19
|
+
initial: "",
|
|
20
|
+
});
|
|
21
|
+
const { name: backendName } = await (0, enquirer_1.prompt)({
|
|
22
|
+
type: "input",
|
|
23
|
+
name: "name",
|
|
24
|
+
message: "请输入后端项目名称,为空表示不创建后端项目",
|
|
25
|
+
initial: "",
|
|
26
|
+
});
|
|
27
|
+
return { frontendName, backendName };
|
|
28
|
+
}
|
|
29
|
+
async function askProjectPath() {
|
|
30
|
+
const ans = await (0, enquirer_1.prompt)({
|
|
31
|
+
type: "input",
|
|
32
|
+
name: "path",
|
|
33
|
+
message: "请填写项目名称或路径,如果填.表示直接把项目放到当前目录下",
|
|
34
|
+
initial: ".",
|
|
35
|
+
});
|
|
36
|
+
const p = (ans.path || ".").trim();
|
|
37
|
+
return p || ".";
|
|
38
|
+
}
|
|
39
|
+
async function askOverwrite() {
|
|
40
|
+
const { ok } = await (0, enquirer_1.prompt)({
|
|
41
|
+
type: "confirm",
|
|
42
|
+
name: "ok",
|
|
43
|
+
message: "目标目录非空,是否覆盖?",
|
|
44
|
+
initial: false,
|
|
45
|
+
});
|
|
46
|
+
if (!ok) {
|
|
47
|
+
console.error("已取消");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function printHelp() {
|
|
52
|
+
const h = [
|
|
53
|
+
"用法: listpage_cli init",
|
|
54
|
+
"说明: 进入中文引导式交互,按提示填写即可",
|
|
55
|
+
].join("\n");
|
|
56
|
+
console.log(h);
|
|
57
|
+
}
|
|
58
|
+
function printVersion() {
|
|
59
|
+
try {
|
|
60
|
+
const p = path_1.default.join(__dirname, "..", "package.json");
|
|
61
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(p, "utf8"));
|
|
62
|
+
console.log(pkg.version || "");
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
console.log("");
|
|
66
|
+
}
|
|
67
|
+
}
|
package/bin/utils.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readJsonWithComments = readJsonWithComments;
|
|
4
|
+
exports.composePkgName = composePkgName;
|
|
5
|
+
function readJsonWithComments(str) {
|
|
6
|
+
const noBlock = str.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
7
|
+
const noLine = noBlock.replace(/(^|\s)\/\/.*$/gm, "");
|
|
8
|
+
const noTrailingComma = noLine.replace(/,\s*([}\]])/g, "$1");
|
|
9
|
+
return JSON.parse(noTrailingComma);
|
|
10
|
+
}
|
|
11
|
+
function composePkgName(name) {
|
|
12
|
+
const n = safePkgName(name);
|
|
13
|
+
return n;
|
|
14
|
+
}
|
|
15
|
+
function safePkgName(name) {
|
|
16
|
+
return name
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replace(/\s+/g, "-")
|
|
19
|
+
.replace(/[^a-z0-9-_.]/g, "-");
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage_cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.192",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"listpage_cli": "bin/cli.js"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc -p tsconfig.json",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
|
-
"start": "node bin/cli.js",
|
|
11
|
+
"start": "node bin/cli.js init",
|
|
12
12
|
"test": "node bin/cli.js --help"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# compiled output
|
|
2
|
+
/dist
|
|
3
|
+
/node_modules
|
|
4
|
+
/build
|
|
5
|
+
|
|
6
|
+
# Logs
|
|
7
|
+
logs
|
|
8
|
+
*.log
|
|
9
|
+
npm-debug.log*
|
|
10
|
+
pnpm-debug.log*
|
|
11
|
+
yarn-debug.log*
|
|
12
|
+
yarn-error.log*
|
|
13
|
+
lerna-debug.log*
|
|
14
|
+
|
|
15
|
+
# OS
|
|
16
|
+
.DS_Store
|
|
17
|
+
|
|
18
|
+
# Tests
|
|
19
|
+
/coverage
|
|
20
|
+
/.nyc_output
|
|
21
|
+
|
|
22
|
+
# IDEs and editors
|
|
23
|
+
/.idea
|
|
24
|
+
.project
|
|
25
|
+
.classpath
|
|
26
|
+
.c9/
|
|
27
|
+
*.launch
|
|
28
|
+
.settings/
|
|
29
|
+
*.sublime-workspace
|
|
30
|
+
|
|
31
|
+
# IDE - VSCode
|
|
32
|
+
.vscode/*
|
|
33
|
+
!.vscode/settings.json
|
|
34
|
+
!.vscode/tasks.json
|
|
35
|
+
!.vscode/launch.json
|
|
36
|
+
!.vscode/extensions.json
|
|
37
|
+
|
|
38
|
+
# dotenv environment variable files
|
|
39
|
+
.env
|
|
40
|
+
.env.development.local
|
|
41
|
+
.env.test.local
|
|
42
|
+
.env.production.local
|
|
43
|
+
.env.local
|
|
44
|
+
|
|
45
|
+
# temp directory
|
|
46
|
+
.temp
|
|
47
|
+
.tmp
|
|
48
|
+
|
|
49
|
+
# Runtime data
|
|
50
|
+
pids
|
|
51
|
+
*.pid
|
|
52
|
+
*.seed
|
|
53
|
+
*.pid.lock
|
|
54
|
+
|
|
55
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
56
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
"build": "nest build",
|
|
10
10
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
11
11
|
"start": "nest start",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"start:prod": "node dist/main"
|
|
12
|
+
"dev": "nest start --watch",
|
|
13
|
+
"prisma:gen": "npx prisma generate"
|
|
15
14
|
},
|
|
16
15
|
"dependencies": {
|
|
17
16
|
"@nestjs/common": "^11.0.1",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
*.log
|
|
3
|
+
npm-debug.log*
|
|
4
|
+
yarn-debug.log*
|
|
5
|
+
yarn-error.log*
|
|
6
|
+
.pnpm-debug.log*
|
|
7
|
+
|
|
8
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
9
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
10
|
+
|
|
11
|
+
# Runtime data
|
|
12
|
+
*.pid
|
|
13
|
+
*.seed
|
|
14
|
+
*.pid.lock
|
|
15
|
+
|
|
16
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
17
|
+
lib-cov/
|
|
18
|
+
|
|
19
|
+
# Coverage directory used by tools like istanbul
|
|
20
|
+
coverage/
|
|
21
|
+
|
|
22
|
+
# nyc test coverage
|
|
23
|
+
.nyc_output/
|
|
24
|
+
|
|
25
|
+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
26
|
+
.grunt/
|
|
27
|
+
|
|
28
|
+
# Bower dependency directory (https://bower.io/)
|
|
29
|
+
bower_components/
|
|
30
|
+
|
|
31
|
+
# node-waf configuration
|
|
32
|
+
.lock-wscript/
|
|
33
|
+
|
|
34
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
35
|
+
build/Release/
|
|
36
|
+
|
|
37
|
+
# Dependency directories
|
|
38
|
+
node_modules/
|
|
39
|
+
jspm_packages/
|
|
40
|
+
|
|
41
|
+
# TypeScript cache
|
|
42
|
+
*.tsbuildinfo
|
|
43
|
+
|
|
44
|
+
# Optional npm cache directory
|
|
45
|
+
.npm/
|
|
46
|
+
|
|
47
|
+
# Optional eslint cache
|
|
48
|
+
.eslintcache/
|
|
49
|
+
|
|
50
|
+
# Optional REPL history
|
|
51
|
+
.node_repl_history
|
|
52
|
+
|
|
53
|
+
# Output of 'npm pack'
|
|
54
|
+
*.tgz
|
|
55
|
+
|
|
56
|
+
# Yarn Integrity file
|
|
57
|
+
.yarn-integrity
|
|
58
|
+
|
|
59
|
+
# dotenv environment variables file
|
|
60
|
+
.env
|
|
61
|
+
.env.development.local
|
|
62
|
+
.env.test.local
|
|
63
|
+
.env.production.local
|
|
64
|
+
.env.local
|
|
65
|
+
|
|
66
|
+
# next.js build output
|
|
67
|
+
.next/
|
|
68
|
+
|
|
69
|
+
# Docusaurus cache and generated files
|
|
70
|
+
.docusaurus/
|
|
71
|
+
|
|
72
|
+
# Serverless directories
|
|
73
|
+
.serverless/
|
|
74
|
+
|
|
75
|
+
# FuseBox cache
|
|
76
|
+
.fusebox/
|
|
77
|
+
|
|
78
|
+
# DynamoDB Local files
|
|
79
|
+
.dynamodb/
|
|
80
|
+
|
|
81
|
+
# yarn v2
|
|
82
|
+
.yarn/cache/
|
|
83
|
+
.yarn/unplugged/
|
|
84
|
+
.yarn/build-state.yml
|
|
85
|
+
.yarn/install-state.gz
|
|
86
|
+
.pnp.*
|
|
87
|
+
|
|
88
|
+
# OS X temporary files
|
|
89
|
+
.DS_Store
|
|
90
|
+
|
|
91
|
+
# IntelliJ IDEA project files; if you want to commit IntelliJ settings, this recipe may be helpful:
|
|
92
|
+
# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
93
|
+
.idea/
|
|
94
|
+
*.iml
|
|
95
|
+
|
|
96
|
+
# Visual Studio Code
|
|
97
|
+
.vscode/
|
|
98
|
+
!.vscode/tasks.json
|
|
99
|
+
!.vscode/launch.json
|
|
100
|
+
|
|
101
|
+
# Rush temporary files
|
|
102
|
+
common/deploy/
|
|
103
|
+
common/temp/
|
|
104
|
+
common/autoinstallers/*/.npmrc
|
|
105
|
+
**/.rush/temp/
|
|
106
|
+
*.lock
|
|
107
|
+
|
|
108
|
+
# Common toolchain intermediate files
|
|
109
|
+
temp/
|
|
110
|
+
lib/
|
|
111
|
+
lib-amd/
|
|
112
|
+
lib-es6/
|
|
113
|
+
lib-esnext/
|
|
114
|
+
lib-commonjs/
|
|
115
|
+
lib-shim/
|
|
116
|
+
dist/
|
|
117
|
+
dist-storybook/
|
|
118
|
+
*.tsbuildinfo
|
|
119
|
+
|
|
120
|
+
# Heft temporary files
|
|
121
|
+
.cache/
|
|
122
|
+
.heft/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{app-templates/backend-tempalte → backend-template}/src/app.controller.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{app-templates/frontend-template → frontend-template}/src/router/index.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|