listpage_cli 0.0.187 → 0.0.189
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
CHANGED
|
@@ -6,12 +6,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const child_process_1 = require("child_process");
|
|
10
9
|
const enquirer_1 = require("enquirer");
|
|
11
10
|
function printHelp() {
|
|
12
11
|
const h = [
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"用法: listpage_cli init",
|
|
13
|
+
"说明: 进入中文引导式交互,按提示填写即可",
|
|
15
14
|
].join("\n");
|
|
16
15
|
console.log(h);
|
|
17
16
|
}
|
|
@@ -101,7 +100,8 @@ function copyDir(src, dest) {
|
|
|
101
100
|
ensureDir(dest);
|
|
102
101
|
for (const entry of fs_1.default.readdirSync(src)) {
|
|
103
102
|
const s = path_1.default.join(src, entry);
|
|
104
|
-
const
|
|
103
|
+
const outEntry = entry === "gitignore" ? ".gitignore" : entry;
|
|
104
|
+
const d = path_1.default.join(dest, outEntry);
|
|
105
105
|
const stat = fs_1.default.statSync(s);
|
|
106
106
|
if (stat.isDirectory())
|
|
107
107
|
copyDir(s, d);
|
|
@@ -117,14 +117,6 @@ function readJsonWithComments(str) {
|
|
|
117
117
|
const noTrailingComma = noLine.replace(/,\s*([}\]])/g, "$1");
|
|
118
118
|
return JSON.parse(noTrailingComma);
|
|
119
119
|
}
|
|
120
|
-
function initGit(targetDir) {
|
|
121
|
-
try {
|
|
122
|
-
(0, child_process_1.execSync)("git init", { stdio: "inherit", cwd: targetDir });
|
|
123
|
-
(0, child_process_1.execSync)("git add -A", { stdio: "inherit", cwd: targetDir });
|
|
124
|
-
(0, child_process_1.execSync)('git commit -m "init"', { stdio: "inherit", cwd: targetDir });
|
|
125
|
-
}
|
|
126
|
-
catch { }
|
|
127
|
-
}
|
|
128
120
|
async function initRush(targetDir, projectName) {
|
|
129
121
|
copyRushSkeleton(targetDir);
|
|
130
122
|
const cfgPath = path_1.default.join(targetDir, "rush.json");
|
|
@@ -151,7 +143,6 @@ async function initRush(targetDir, projectName) {
|
|
|
151
143
|
}
|
|
152
144
|
rushCfg.projects = projects;
|
|
153
145
|
fs_1.default.writeFileSync(cfgPath, JSON.stringify(rushCfg, null, 2));
|
|
154
|
-
initGit(targetDir);
|
|
155
146
|
if (fs_1.default.existsSync(path_1.default.join(targetDir, "common"))) {
|
|
156
147
|
console.log("Skipping rush update in CLI; install manually if needed.");
|
|
157
148
|
}
|
|
@@ -194,7 +185,10 @@ function copyTemplateDir(srcDir, destDir, vars) {
|
|
|
194
185
|
files.forEach((src) => {
|
|
195
186
|
const rel = path_1.default.relative(srcDir, src);
|
|
196
187
|
const isTmpl = rel.endsWith(".tmpl");
|
|
197
|
-
|
|
188
|
+
let outRel = isTmpl ? rel.slice(0, -5) : rel;
|
|
189
|
+
if (path_1.default.basename(outRel) === "gitignore") {
|
|
190
|
+
outRel = path_1.default.join(path_1.default.dirname(outRel), ".gitignore");
|
|
191
|
+
}
|
|
198
192
|
const dest = path_1.default.join(destDir, outRel);
|
|
199
193
|
ensureDir(path_1.default.dirname(dest));
|
|
200
194
|
const buf = fs_1.default.readFileSync(src, "utf8");
|
package/package.json
CHANGED