listpage_cli 0.0.229 → 0.0.230

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
@@ -62,6 +62,8 @@ function printHelp() {
62
62
  const h = [
63
63
  "用法: listpage_cli init",
64
64
  "说明: 进入中文引导式交互,按提示填写即可",
65
+ "用法: listpage_cli sync-docs",
66
+ "说明: 将模板中的 .trae 和 docs 同步到执行目录的同级目录",
65
67
  ].join("\n");
66
68
  console.log(h);
67
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage_cli",
3
- "version": "0.0.229",
3
+ "version": "0.0.230",
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": [
@@ -23,7 +23,7 @@
23
23
  "class-transformer": "^0.5.1",
24
24
  "class-validator": "~0.14.2",
25
25
  "rxjs": "^7.8.1",
26
- "listpage-next-nest": "~0.0.229"
26
+ "listpage-next-nest": "~0.0.230"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@nestjs/schematics": "^11.0.0",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "react": "^19.2.0",
14
14
  "react-dom": "^19.2.0",
15
- "listpage-next": "~0.0.229",
15
+ "listpage-next": "~0.0.230",
16
16
  "react-router-dom": ">=6.0.0",
17
17
  "@ant-design/v5-patch-for-react-19": "~1.0.3",
18
18
  "ahooks": "^3.9.5",
@@ -9,7 +9,7 @@
9
9
  "publish": "ts-node src/publish.ts"
10
10
  },
11
11
  "dependencies": {
12
- "listpage-next-deploy": "0.0.229"
12
+ "listpage-next-deploy": "0.0.230"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^20.0.0",