listpage_cli 0.0.229 → 0.0.231
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
|
@@ -50,6 +50,18 @@ async function main() {
|
|
|
50
50
|
const cmd = args[0];
|
|
51
51
|
if (cmd === "init")
|
|
52
52
|
return initCmd();
|
|
53
|
+
if (cmd === "sync-docs")
|
|
54
|
+
return syncDocsCmd();
|
|
53
55
|
(0, prompts_1.printHelp)();
|
|
54
56
|
}
|
|
55
57
|
main();
|
|
58
|
+
async function syncDocsCmd() {
|
|
59
|
+
const execDir = process.cwd();
|
|
60
|
+
const sourceTrae = path_1.default.join(__dirname, "..", "templates", "rush-template", ".trae");
|
|
61
|
+
const sourceDocs = path_1.default.join(__dirname, "..", "templates", "rush-template", "docs");
|
|
62
|
+
const destTrae = path_1.default.join(execDir, ".trae");
|
|
63
|
+
const destDocs = path_1.default.join(execDir, "docs");
|
|
64
|
+
(0, copy_1.syncDirWithRename)(sourceTrae, destTrae);
|
|
65
|
+
(0, copy_1.syncDirWithRename)(sourceDocs, destDocs);
|
|
66
|
+
console.log("已同步 .trae 和 docs 到执行目录的同级目录");
|
|
67
|
+
}
|
package/bin/copy.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.copyBackendTemplate = copyBackendTemplate;
|
|
|
10
10
|
exports.copyDeployScriptTemplate = copyDeployScriptTemplate;
|
|
11
11
|
exports.ensureDir = ensureDir;
|
|
12
12
|
exports.isDirEmpty = isDirEmpty;
|
|
13
|
+
exports.syncDirWithRename = syncDirWithRename;
|
|
13
14
|
const fs_1 = require("fs");
|
|
14
15
|
const path_1 = __importDefault(require("path"));
|
|
15
16
|
const utils_1 = require("./utils");
|
|
@@ -99,3 +100,49 @@ function compileTemplateContent(str, vars) {
|
|
|
99
100
|
function isDirEmpty(dir) {
|
|
100
101
|
return !(0, fs_1.existsSync)(dir) || (0, fs_1.readdirSync)(dir).length === 0;
|
|
101
102
|
}
|
|
103
|
+
function syncDirWithRename(source, destination) {
|
|
104
|
+
ensureDir(destination);
|
|
105
|
+
const items = (0, fs_1.readdirSync)(source);
|
|
106
|
+
items.forEach((name) => {
|
|
107
|
+
const s = path_1.default.join(source, name);
|
|
108
|
+
const d = path_1.default.join(destination, name);
|
|
109
|
+
const sStat = (0, fs_1.statSync)(s);
|
|
110
|
+
if (sStat.isDirectory()) {
|
|
111
|
+
if ((0, fs_1.existsSync)(d)) {
|
|
112
|
+
const dStat = (0, fs_1.statSync)(d);
|
|
113
|
+
if (!dStat.isDirectory()) {
|
|
114
|
+
const copyPath = getCopyPath(d);
|
|
115
|
+
(0, fs_1.renameSync)(d, copyPath);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
ensureDir(d);
|
|
119
|
+
syncDirWithRename(s, d);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
ensureDir(path_1.default.dirname(d));
|
|
123
|
+
if ((0, fs_1.existsSync)(d)) {
|
|
124
|
+
const dStat = (0, fs_1.statSync)(d);
|
|
125
|
+
if (dStat.isFile()) {
|
|
126
|
+
const copyPath = getCopyPath(d);
|
|
127
|
+
(0, fs_1.renameSync)(d, copyPath);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
(0, fs_1.copyFileSync)(s, d);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function getCopyPath(filePath) {
|
|
135
|
+
const dir = path_1.default.dirname(filePath);
|
|
136
|
+
const ext = path_1.default.extname(filePath);
|
|
137
|
+
const base = path_1.default.basename(filePath, ext);
|
|
138
|
+
let candidate = path_1.default.join(dir, `${base} copy${ext}`);
|
|
139
|
+
if (!(0, fs_1.existsSync)(candidate))
|
|
140
|
+
return candidate;
|
|
141
|
+
let i = 2;
|
|
142
|
+
while (true) {
|
|
143
|
+
candidate = path_1.default.join(dir, `${base} copy (${i})${ext}`);
|
|
144
|
+
if (!(0, fs_1.existsSync)(candidate))
|
|
145
|
+
return candidate;
|
|
146
|
+
i++;
|
|
147
|
+
}
|
|
148
|
+
}
|
package/bin/prompts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage_cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.231",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"listpage_cli": "bin/cli.js"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"build": "tsc -p tsconfig.json",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
11
|
"start": "node bin/cli.js init",
|
|
12
|
+
"start:sync-docs": "node bin/cli.js sync-docs",
|
|
12
13
|
"test": "node bin/cli.js --help"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|