@tnotesjs/core 0.6.1 → 0.8.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/commands/BaseCommand.ts +58 -0
- package/commands/build/BuildCommand.ts +25 -0
- package/commands/build/PreviewCommand.ts +29 -0
- package/commands/build/index.ts +8 -0
- package/commands/dev/DevCommand.ts +75 -0
- package/commands/dev/index.ts +7 -0
- package/commands/git/PullCommand.ts +25 -0
- package/commands/git/PushCommand.ts +64 -0
- package/commands/git/index.ts +8 -0
- package/commands/index.ts +11 -0
- package/commands/init-sub-repo/InitSubRepoCommand.ts +206 -0
- package/commands/init-sub-repo/index.ts +1 -0
- package/commands/misc/HelpCommand.ts +104 -0
- package/commands/misc/index.ts +7 -0
- package/commands/models.ts +87 -0
- package/commands/note/CreateNoteCommand.ts +160 -0
- package/commands/note/RenameNoteCommand.ts +147 -0
- package/commands/note/UpdateNoteConfigCommand.ts +78 -0
- package/commands/note/index.ts +9 -0
- package/commands/registry.ts +47 -0
- package/commands/update/UpdateCommand.ts +219 -0
- package/commands/update/index.ts +7 -0
- package/commands/update-completed-count/UpdateCompletedCountCommand.ts +208 -0
- package/commands/update-completed-count/index.ts +5 -0
- package/config/templates.ts +0 -5
- package/dist/{chunk-5F5RJ2HV.cjs → chunk-7FEANCT6.cjs} +16 -7
- package/dist/chunk-AGVER5MX.cjs +1746 -0
- package/dist/{chunk-TJ4527KA.cjs → chunk-BL22KD4V.cjs} +324 -950
- package/dist/{chunk-56PKXCOX.js → chunk-GWG75A5M.js} +13 -4
- package/dist/{chunk-DUTS75WQ.js → chunk-XNO3PCEH.js} +374 -1000
- package/dist/chunk-ZEQS64PE.js +1746 -0
- package/dist/cli/index.cjs +76 -155
- package/dist/cli/index.js +10 -89
- package/dist/markdown/index.cjs +8 -12
- package/dist/markdown/index.d.cts +1 -1
- package/dist/markdown/index.d.ts +1 -1
- package/dist/markdown/index.js +7 -11
- package/dist/{types-CwBWwNVv.d.ts → types-C_d0fFeD.d.ts} +8 -1
- package/dist/{types-CpsEy8lA.d.cts → types-MRBGgJTX.d.cts} +8 -1
- package/dist/vitepress/config/index.cjs +402 -178
- package/dist/vitepress/config/index.js +392 -168
- package/dist/workspace/index.cjs +4 -1202
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.ts +2 -2
- package/dist/workspace/index.js +4 -1202
- package/markdown/components.ts +86 -0
- package/markdown/index.ts +17 -0
- package/markdown/noteFormatter.test.ts +44 -0
- package/markdown/noteFormatter.ts +237 -0
- package/package.json +7 -3
- package/services/file-watcher/folderChangeHandler.ts +19 -15
- package/services/file-watcher/globalUpdateCoordinator.ts +21 -27
- package/services/file-watcher/service.ts +1 -6
- package/services/index.ts +0 -1
- package/services/note/service.ts +4 -6
- package/services/readme/service.ts +11 -18
- package/services/reconcileToc.ts +20 -0
- package/utils/index.ts +0 -9
- package/{services/toc → utils}/moveTocInside.test.ts +1 -1
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +9 -18
- package/vitepress/components/EnWordList/EnWordList.vue +16 -662
- package/vitepress/components/Footprints/Footprints.vue +15 -537
- package/vitepress/components/Mermaid/Mermaid.vue +13 -588
- package/vitepress/components/MindmapPreview/MindmapPreview.vue +12 -434
- package/vitepress/components/MindmapPreview/markdown.ts +1 -1
- package/vitepress/components/NotesTable/NotesTable.vue +11 -130
- package/vitepress/components/constants.ts +2 -2
- package/vitepress/components/sidebar.data.ts +8 -5
- package/vitepress/configs/markdown.config.ts +170 -26
- package/vitepress/plugins/sidebarStructurePlugin.ts +242 -145
- package/vitepress/theme/index.ts +9 -13
- package/vitepress/theme/styles/base.scss +15 -0
- package/workspace/atomic.ts +113 -0
- package/workspace/errors.ts +27 -0
- package/workspace/index.ts +40 -0
- package/workspace/mutationQueue.ts +28 -0
- package/workspace/paths.ts +64 -0
- package/workspace/reconcile.test.ts +300 -0
- package/workspace/reconcile.ts +95 -0
- package/workspace/scanner.ts +292 -0
- package/workspace/types.ts +224 -0
- package/workspace/workspace.test.ts +333 -0
- package/workspace/workspace.ts +1020 -0
- package/dist/chunk-3R7QSABB.cjs +0 -502
- package/dist/chunk-CZXRQPFJ.js +0 -11
- package/dist/chunk-HXED7KVT.cjs +0 -11
- package/dist/chunk-U6IBLREL.js +0 -502
- package/services/toc/index.ts +0 -5
- package/services/toc/service.ts +0 -759
- package/utils/migrateReadmeToToc.test.ts +0 -111
- package/utils/migrateReadmeToToc.ts +0 -135
- package/vitepress/components/EnWordList/RightClickMenu.vue +0 -93
package/dist/cli/index.cjs
CHANGED
|
@@ -33,9 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _chunkTJ4527KAcjs = require('../chunk-TJ4527KA.cjs');
|
|
36
|
+
var _chunkBL22KD4Vcjs = require('../chunk-BL22KD4V.cjs');
|
|
39
37
|
|
|
40
38
|
|
|
41
39
|
|
|
@@ -43,21 +41,17 @@ var _chunkTJ4527KAcjs = require('../chunk-TJ4527KA.cjs');
|
|
|
43
41
|
var _chunkMZIXIY2Ycjs = require('../chunk-MZIXIY2Y.cjs');
|
|
44
42
|
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var _chunk3R7QSABBcjs = require('../chunk-3R7QSABB.cjs');
|
|
51
|
-
require('../chunk-HXED7KVT.cjs');
|
|
44
|
+
var _chunkAGVER5MXcjs = require('../chunk-AGVER5MX.cjs');
|
|
45
|
+
require('../chunk-7FEANCT6.cjs');
|
|
52
46
|
|
|
53
47
|
// commands/update/UpdateCommand.ts
|
|
54
48
|
var _fs = require('fs');
|
|
55
|
-
var UpdateCommand = class extends
|
|
49
|
+
var UpdateCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
56
50
|
constructor() {
|
|
57
51
|
super("update");
|
|
58
52
|
this.quiet = false;
|
|
59
|
-
this.readmeService =
|
|
60
|
-
this.noteService =
|
|
53
|
+
this.readmeService = _chunkBL22KD4Vcjs.ReadmeService.getInstance();
|
|
54
|
+
this.noteService = _chunkBL22KD4Vcjs.NoteService.getInstance();
|
|
61
55
|
}
|
|
62
56
|
/**
|
|
63
57
|
* 设置 quiet 模式
|
|
@@ -67,9 +61,9 @@ var UpdateCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
67
61
|
setQuiet(quiet) {
|
|
68
62
|
this.quiet = quiet;
|
|
69
63
|
if (quiet) {
|
|
70
|
-
|
|
64
|
+
_chunkBL22KD4Vcjs.logger.setLevel(2 /* WARN */);
|
|
71
65
|
} else {
|
|
72
|
-
|
|
66
|
+
_chunkBL22KD4Vcjs.logger.setLevel(1 /* INFO */);
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
async run() {
|
|
@@ -103,13 +97,13 @@ var UpdateCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
103
97
|
*/
|
|
104
98
|
async updateRootItem() {
|
|
105
99
|
try {
|
|
106
|
-
const configContent = _fs.readFileSync.call(void 0,
|
|
100
|
+
const configContent = _fs.readFileSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_CONFIG_PATH, "utf-8");
|
|
107
101
|
const config = JSON.parse(configContent);
|
|
108
|
-
if (!_fs.existsSync.call(void 0,
|
|
102
|
+
if (!_fs.existsSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_TOC_PATH)) {
|
|
109
103
|
throw new Error("\u6839\u76EE\u5F55 TOC.md \u4E0D\u5B58\u5728");
|
|
110
104
|
}
|
|
111
|
-
const tocContent = _fs.readFileSync.call(void 0,
|
|
112
|
-
const { completedCount } =
|
|
105
|
+
const tocContent = _fs.readFileSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_TOC_PATH, "utf-8");
|
|
106
|
+
const { completedCount } = _chunkAGVER5MXcjs.parseTocCompletedNotes.call(void 0, tocContent);
|
|
113
107
|
const now = /* @__PURE__ */ new Date();
|
|
114
108
|
const yearShort = String(now.getFullYear()).slice(-2);
|
|
115
109
|
const monthStr = String(now.getMonth() + 1).padStart(2, "0");
|
|
@@ -126,7 +120,7 @@ var UpdateCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
126
120
|
_chunkMZIXIY2Ycjs.stripDeprecatedRootItemFields.call(void 0,
|
|
127
121
|
config.root_item
|
|
128
122
|
);
|
|
129
|
-
_fs.writeFileSync.call(void 0,
|
|
123
|
+
_fs.writeFileSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
130
124
|
if (!this.quiet) {
|
|
131
125
|
const filledCount = Object.keys(fixed).length - _countsBeforeFix;
|
|
132
126
|
const filledMsg = filledCount > 0 ? `\uFF0C\u8865\u9F50 ${filledCount} \u4E2A\u7F3A\u5931\u6708\u4EFD` : "";
|
|
@@ -192,11 +186,11 @@ function generateMissingMonthKeys(fromKey, toKey) {
|
|
|
192
186
|
}
|
|
193
187
|
|
|
194
188
|
// commands/git/PushCommand.ts
|
|
195
|
-
var PushCommand = class extends
|
|
189
|
+
var PushCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
196
190
|
constructor() {
|
|
197
191
|
super("push");
|
|
198
|
-
this.gitManager = new (0,
|
|
199
|
-
this.gitService = new (0,
|
|
192
|
+
this.gitManager = new (0, _chunkBL22KD4Vcjs.GitManager)(_chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
193
|
+
this.gitService = new (0, _chunkBL22KD4Vcjs.GitService)();
|
|
200
194
|
}
|
|
201
195
|
async run() {
|
|
202
196
|
try {
|
|
@@ -216,14 +210,14 @@ var PushCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
216
210
|
`\u68C0\u6D4B\u5230 ${status.files.length} \u4E2A\u53D8\u66F4\u6587\u4EF6\uFF0C\u6B63\u5728\u63D0\u4EA4...`
|
|
217
211
|
);
|
|
218
212
|
const commitMessage = this.gitService.generateCommitMessage();
|
|
219
|
-
await
|
|
220
|
-
await
|
|
213
|
+
await _chunkBL22KD4Vcjs.runCommand.call(void 0, "git add -A", _chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
214
|
+
await _chunkBL22KD4Vcjs.runCommand.call(void 0, `git commit -m "${commitMessage}"`, _chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
221
215
|
} else {
|
|
222
216
|
this.logger.info(`\u68C0\u6D4B\u5230 ${status.ahead} \u4E2A\u672A\u63A8\u9001\u7684\u63D0\u4EA4\uFF0C\u76F4\u63A5\u63A8\u9001...`);
|
|
223
217
|
}
|
|
224
218
|
this.logger.info("\u6B63\u5728\u63A8\u9001\u5230\u8FDC\u7A0B\u4ED3\u5E93...");
|
|
225
219
|
const pushCmd = force ? "git push --force" : "git push";
|
|
226
|
-
await
|
|
220
|
+
await _chunkBL22KD4Vcjs.runCommand.call(void 0, pushCmd, _chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
227
221
|
this.logger.success("\u63A8\u9001\u5B8C\u6210");
|
|
228
222
|
} catch (error) {
|
|
229
223
|
this.logger.error("\u63A8\u9001\u5931\u8D25:", error);
|
|
@@ -233,10 +227,10 @@ var PushCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
233
227
|
};
|
|
234
228
|
|
|
235
229
|
// commands/git/PullCommand.ts
|
|
236
|
-
var PullCommand = class extends
|
|
230
|
+
var PullCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
237
231
|
constructor() {
|
|
238
232
|
super("pull");
|
|
239
|
-
this.gitService = new (0,
|
|
233
|
+
this.gitService = new (0, _chunkBL22KD4Vcjs.GitService)();
|
|
240
234
|
}
|
|
241
235
|
async run() {
|
|
242
236
|
this.logger.info("\u6B63\u5728\u4ECE\u8FDC\u7A0B\u4ED3\u5E93\u62C9\u53D6...");
|
|
@@ -246,10 +240,10 @@ var PullCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
246
240
|
};
|
|
247
241
|
|
|
248
242
|
// commands/build/BuildCommand.ts
|
|
249
|
-
var BuildCommand = class extends
|
|
243
|
+
var BuildCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
250
244
|
constructor() {
|
|
251
245
|
super("build");
|
|
252
|
-
this.vitepressService = new (0,
|
|
246
|
+
this.vitepressService = new (0, _chunkBL22KD4Vcjs.VitepressService)();
|
|
253
247
|
}
|
|
254
248
|
async run() {
|
|
255
249
|
this.logger.info("\u5F00\u59CB\u6784\u5EFA\u77E5\u8BC6\u5E93...");
|
|
@@ -259,10 +253,10 @@ var BuildCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
259
253
|
};
|
|
260
254
|
|
|
261
255
|
// commands/build/PreviewCommand.ts
|
|
262
|
-
var PreviewCommand = class extends
|
|
256
|
+
var PreviewCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
263
257
|
constructor() {
|
|
264
258
|
super("preview");
|
|
265
|
-
this.vitepressService = new (0,
|
|
259
|
+
this.vitepressService = new (0, _chunkBL22KD4Vcjs.VitepressService)();
|
|
266
260
|
}
|
|
267
261
|
async run() {
|
|
268
262
|
this.logger.info("\u542F\u52A8\u9884\u89C8\u670D\u52A1\u5668...");
|
|
@@ -276,22 +270,20 @@ var PreviewCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
276
270
|
};
|
|
277
271
|
|
|
278
272
|
// commands/dev/DevCommand.ts
|
|
279
|
-
var DevCommand = class extends
|
|
273
|
+
var DevCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
280
274
|
constructor() {
|
|
281
275
|
super("dev");
|
|
282
276
|
this.configManager = _chunkMZIXIY2Ycjs.ConfigManager.getInstance();
|
|
283
|
-
this.fileWatcherService = new (0,
|
|
284
|
-
this.noteIndexCache =
|
|
285
|
-
this.noteManager =
|
|
286
|
-
this.
|
|
287
|
-
this.vitepressService = new (0, _chunkTJ4527KAcjs.VitepressService)();
|
|
277
|
+
this.fileWatcherService = new (0, _chunkBL22KD4Vcjs.FileWatcherService)();
|
|
278
|
+
this.noteIndexCache = _chunkBL22KD4Vcjs.NoteIndexCache.getInstance();
|
|
279
|
+
this.noteManager = _chunkBL22KD4Vcjs.NoteManager.getInstance();
|
|
280
|
+
this.vitepressService = new (0, _chunkBL22KD4Vcjs.VitepressService)();
|
|
288
281
|
}
|
|
289
282
|
async run() {
|
|
290
283
|
const notes = this.noteManager.scanNotes();
|
|
291
284
|
this.logger.info(`\u626B\u63CF\u5230 ${notes.length} \u7BC7\u7B14\u8BB0`);
|
|
292
285
|
this.noteIndexCache.initialize(notes);
|
|
293
|
-
|
|
294
|
-
await this.tocService.regenerateSidebar(notes);
|
|
286
|
+
await _chunkBL22KD4Vcjs.reconcileTocFromFiles.call(void 0, _chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
295
287
|
const result = await this.vitepressService.startServer();
|
|
296
288
|
if (result) {
|
|
297
289
|
const versionInfo = result.version ? `\uFF08v${result.version}\uFF09` : "";
|
|
@@ -302,7 +294,7 @@ var DevCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
302
294
|
this.fileWatcherService.start();
|
|
303
295
|
const watcherElapsed = Date.now() - watcherStart;
|
|
304
296
|
this.logger.success(`\u6587\u4EF6\u76D1\u542C\u670D\u52A1\u5DF2\u5C31\u7EEA\uFF0C\u8017\u65F6\uFF1A${watcherElapsed} ms`);
|
|
305
|
-
const port2 = this.configManager.get("port") ||
|
|
297
|
+
const port2 = this.configManager.get("port") || _chunkBL22KD4Vcjs.VitepressService.DEFAULT_DEV_PORT;
|
|
306
298
|
const repoName2 = this.configManager.get("repoName");
|
|
307
299
|
this.logger.info(
|
|
308
300
|
`\u672C\u5730\u5F00\u53D1\u670D\u52A1\u5730\u5740\uFF1Ahttp://localhost:${port2}/${repoName2}/`
|
|
@@ -327,20 +319,20 @@ function readCoreVersion() {
|
|
|
327
319
|
try {
|
|
328
320
|
const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf-8"));
|
|
329
321
|
if (pkg.name === "@tnotesjs/core" && pkg.version) return pkg.version;
|
|
330
|
-
} catch (
|
|
322
|
+
} catch (e) {
|
|
331
323
|
}
|
|
332
324
|
dir = _path.dirname.call(void 0, dir);
|
|
333
325
|
}
|
|
334
326
|
return "0.1.28";
|
|
335
327
|
}
|
|
336
|
-
var InitSubRepoCommand = class extends
|
|
328
|
+
var InitSubRepoCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
337
329
|
constructor() {
|
|
338
330
|
super("init-sub-repo");
|
|
339
331
|
this.rootPath = process.cwd();
|
|
340
332
|
}
|
|
341
333
|
async run() {
|
|
342
|
-
if (
|
|
343
|
-
const configPath =
|
|
334
|
+
if (_chunkBL22KD4Vcjs.isAlreadyInitialized.call(void 0, this.rootPath)) {
|
|
335
|
+
const configPath = _chunkBL22KD4Vcjs.getInitializedConfigPath.call(void 0, this.rootPath);
|
|
344
336
|
this.logger.info(
|
|
345
337
|
`\u68C0\u6D4B\u5230 .tnotes.json \u914D\u7F6E\u6587\u4EF6\uFF1A${configPath}\uFF0C\u5F53\u524D\u4ED3\u5E93\u5DF2\u7ECF\u662F\u4E00\u4E2A TNotes \u77E5\u8BC6\u5E93`
|
|
346
338
|
);
|
|
@@ -349,7 +341,7 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
349
341
|
this.logger.info("\u521D\u59CB\u5316 TNotes \u5B50\u77E5\u8BC6\u5E93");
|
|
350
342
|
this.logger.info("");
|
|
351
343
|
const input = await this.promptForInput();
|
|
352
|
-
const ctx =
|
|
344
|
+
const ctx = _chunkBL22KD4Vcjs.buildInitContext.call(void 0, input);
|
|
353
345
|
this.logger.info("");
|
|
354
346
|
this.logger.info("\u5373\u5C06\u521B\u5EFA\u4EE5\u4E0B\u77E5\u8BC6\u5E93\uFF1A");
|
|
355
347
|
this.logger.info(` \u4ED3\u5E93\u540D\uFF1A${ctx.repoName}`);
|
|
@@ -362,7 +354,7 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
362
354
|
this.logger.info("\u5DF2\u53D6\u6D88\u521D\u59CB\u5316");
|
|
363
355
|
return;
|
|
364
356
|
}
|
|
365
|
-
const service =
|
|
357
|
+
const service = _chunkBL22KD4Vcjs.InitSubRepoService.fromModuleUrl(import.meta.url, this.rootPath);
|
|
366
358
|
const result = service.writeScaffold(input);
|
|
367
359
|
if (result.created.length > 0) {
|
|
368
360
|
this.logger.success(`\u5DF2\u521B\u5EFA ${result.created.length} \u4E2A\u6587\u4EF6\uFF1A`);
|
|
@@ -386,11 +378,7 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
386
378
|
try {
|
|
387
379
|
this.logger.info("");
|
|
388
380
|
this.logger.info("\u6B63\u5728\u89C4\u8303\u5316 TOC.md \u5E76\u751F\u6210 sidebar.json...");
|
|
389
|
-
|
|
390
|
-
const tocService = _chunkTJ4527KAcjs.TocService.getInstance();
|
|
391
|
-
const notes = noteService.getAllNotes();
|
|
392
|
-
await tocService.normalizeToc(notes);
|
|
393
|
-
await tocService.regenerateSidebar(notes);
|
|
381
|
+
await _chunkBL22KD4Vcjs.reconcileTocFromFiles.call(void 0, _chunkBL22KD4Vcjs.ROOT_DIR_PATH);
|
|
394
382
|
this.logger.success("sidebar.json \u5DF2\u751F\u6210");
|
|
395
383
|
} catch (error) {
|
|
396
384
|
this.logger.warn(
|
|
@@ -401,7 +389,7 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
401
389
|
this.logger.success("\u5B50\u77E5\u8BC6\u5E93\u521D\u59CB\u5316\u5B8C\u6210\uFF01");
|
|
402
390
|
this.logger.info("");
|
|
403
391
|
this.logger.info("\u8BF7\u624B\u52A8\u5B8C\u6210\u4EE5\u4E0B\u6B65\u9AA4\uFF1A");
|
|
404
|
-
for (const [index, step] of
|
|
392
|
+
for (const [index, step] of _chunkBL22KD4Vcjs.buildManualSteps.call(void 0, ctx).entries()) {
|
|
405
393
|
this.logger.info(` ${index + 1}. ${step}`);
|
|
406
394
|
}
|
|
407
395
|
}
|
|
@@ -423,7 +411,7 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
423
411
|
async promptTopic() {
|
|
424
412
|
while (true) {
|
|
425
413
|
const answer = await this.ask("\u8BF7\u8F93\u5165 topic\uFF08\u5982 react\uFF0C\u5C06\u751F\u6210 TNotes.react\uFF09: ");
|
|
426
|
-
const error =
|
|
414
|
+
const error = _chunkBL22KD4Vcjs.validateTopic.call(void 0, answer);
|
|
427
415
|
if (error) {
|
|
428
416
|
this.logger.warn(error);
|
|
429
417
|
continue;
|
|
@@ -432,23 +420,23 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
432
420
|
}
|
|
433
421
|
}
|
|
434
422
|
async promptDisplayName(topic) {
|
|
435
|
-
const fallback =
|
|
423
|
+
const fallback = _chunkBL22KD4Vcjs.defaultDisplayName.call(void 0, topic);
|
|
436
424
|
const answer = await this.ask(
|
|
437
425
|
`\u8BF7\u8F93\u5165\u5C55\u793A\u540D\uFF08\u7528\u4E8E\u9996\u9875 hero\uFF0C\u9ED8\u8BA4 ${fallback}\uFF09: `
|
|
438
426
|
);
|
|
439
427
|
return answer.trim() || fallback;
|
|
440
428
|
}
|
|
441
429
|
async promptPort() {
|
|
442
|
-
const answer = await this.ask(`\u8BF7\u8F93\u5165 dev \u7AEF\u53E3\uFF08\u9ED8\u8BA4 ${
|
|
443
|
-
const { port: port2, error } =
|
|
430
|
+
const answer = await this.ask(`\u8BF7\u8F93\u5165 dev \u7AEF\u53E3\uFF08\u9ED8\u8BA4 ${_chunkBL22KD4Vcjs.DEFAULT_PORT}\uFF09: `);
|
|
431
|
+
const { port: port2, error } = _chunkBL22KD4Vcjs.validatePort.call(void 0, answer);
|
|
444
432
|
if (error) this.logger.warn(error);
|
|
445
433
|
return port2;
|
|
446
434
|
}
|
|
447
435
|
async promptDescription() {
|
|
448
436
|
const answer = await this.ask(
|
|
449
|
-
`\u8BF7\u8F93\u5165\u4ED3\u5E93\u63CF\u8FF0\uFF08\u9ED8\u8BA4\uFF1A${
|
|
437
|
+
`\u8BF7\u8F93\u5165\u4ED3\u5E93\u63CF\u8FF0\uFF08\u9ED8\u8BA4\uFF1A${_chunkBL22KD4Vcjs.DEFAULT_DESCRIPTION}\uFF09: `
|
|
450
438
|
);
|
|
451
|
-
return answer.trim() ||
|
|
439
|
+
return answer.trim() || _chunkBL22KD4Vcjs.DEFAULT_DESCRIPTION;
|
|
452
440
|
}
|
|
453
441
|
async promptConfirm(question) {
|
|
454
442
|
const answer = await this.ask(question);
|
|
@@ -469,95 +457,32 @@ var InitSubRepoCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
469
457
|
}
|
|
470
458
|
};
|
|
471
459
|
|
|
472
|
-
// commands/init-toc/InitTocCommand.ts
|
|
473
|
-
|
|
474
|
-
var InitTocCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
475
|
-
constructor() {
|
|
476
|
-
super("init-toc");
|
|
477
|
-
this.noteManager = _chunkTJ4527KAcjs.NoteManager.getInstance();
|
|
478
|
-
this.tocService = _chunkTJ4527KAcjs.TocService.getInstance();
|
|
479
|
-
}
|
|
480
|
-
async run() {
|
|
481
|
-
if (!_fs.existsSync.call(void 0, _chunkTJ4527KAcjs.ROOT_README_PATH)) {
|
|
482
|
-
throw new Error(`README.md \u4E0D\u5B58\u5728: ${_chunkTJ4527KAcjs.ROOT_README_PATH}`);
|
|
483
|
-
}
|
|
484
|
-
const readmeContent = _fs.readFileSync.call(void 0, _chunkTJ4527KAcjs.ROOT_README_PATH, "utf-8");
|
|
485
|
-
const notes = this.noteManager.scanNotes();
|
|
486
|
-
const { entries, warnings } = _chunkTJ4527KAcjs.migrateReadmeToToc.call(void 0, readmeContent);
|
|
487
|
-
for (const warning of warnings) {
|
|
488
|
-
this.logger.warn(warning);
|
|
489
|
-
}
|
|
490
|
-
const lines = [];
|
|
491
|
-
let skipped = 0;
|
|
492
|
-
for (const entry of entries) {
|
|
493
|
-
if (entry.kind === "folder") {
|
|
494
|
-
lines.push(_chunk3R7QSABBcjs.buildFolderTocLine.call(void 0, entry.folderTitle, entry.indent));
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
497
|
-
const note = _chunk3R7QSABBcjs.resolveNoteFromIndex.call(void 0, entry.noteIndex, notes);
|
|
498
|
-
if (!note) {
|
|
499
|
-
skipped++;
|
|
500
|
-
this.logger.warn(
|
|
501
|
-
`\u8DF3\u8FC7 README \u4E2D\u5B58\u5728\u4F46 notes/ \u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728\u7684\u7B14\u8BB0: ${entry.noteIndex}`
|
|
502
|
-
);
|
|
503
|
-
continue;
|
|
504
|
-
}
|
|
505
|
-
lines.push(_chunk3R7QSABBcjs.buildTocLine.call(void 0, note, entry.indent, entry.completed));
|
|
506
|
-
}
|
|
507
|
-
if (lines.length === 0) {
|
|
508
|
-
throw new Error(
|
|
509
|
-
"\u672A\u80FD\u4ECE README.md \u89E3\u6790\u5230\u4EFB\u4F55\u6709\u6548\u7B14\u8BB0\u6761\u76EE\uFF0CTOC.md \u672A\u5199\u5165"
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
const content = _chunk3R7QSABBcjs.processTocEmptyLines.call(void 0, lines).join("\n");
|
|
513
|
-
_fs.writeFileSync.call(void 0, _chunkTJ4527KAcjs.ROOT_TOC_PATH, content, "utf-8");
|
|
514
|
-
await this.tocService.regenerateSidebar(notes);
|
|
515
|
-
this.logger.success(
|
|
516
|
-
`TOC.md \u5DF2\u4ECE README.md \u521D\u59CB\u5316\uFF08${lines.length} \u6761\u7B14\u8BB0${skipped > 0 ? `\uFF0C\u8DF3\u8FC7 ${skipped} \u6761` : ""}\uFF09`
|
|
517
|
-
);
|
|
518
|
-
this.logger.info(`\u8F93\u51FA\u8DEF\u5F84: ${_chunkTJ4527KAcjs.ROOT_TOC_PATH}`);
|
|
519
|
-
this.logger.info(
|
|
520
|
-
"\u8FC7\u6E21\u547D\u4EE4 init-toc \u4EC5\u5728 v0.2.x \u63D0\u4F9B\uFF0Cv0.3.x \u5C06\u79FB\u9664\uFF1B\u540E\u7EED\u8BF7\u4F7F\u7528 TOC.md + pnpm tn:update"
|
|
521
|
-
);
|
|
522
|
-
const listedIndexes = new Set(
|
|
523
|
-
entries.filter((e) => e.kind === "note").map((e) => e.noteIndex)
|
|
524
|
-
);
|
|
525
|
-
const missingInReadme = notes.filter((n) => !listedIndexes.has(n.index));
|
|
526
|
-
if (missingInReadme.length > 0) {
|
|
527
|
-
this.logger.info(
|
|
528
|
-
`README \u4E2D\u672A\u5217\u51FA ${missingInReadme.length} \u7BC7\u7B14\u8BB0\uFF0C\u53EF\u6267\u884C pnpm tn:update \u8FFD\u52A0\u5230 TOC.md`
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
|
|
534
460
|
// commands/misc/HelpCommand.ts
|
|
535
461
|
var COMMAND_CATEGORIES = {
|
|
536
|
-
\u5F00\u53D1\u548C\u6784\u5EFA: [
|
|
462
|
+
\u5F00\u53D1\u548C\u6784\u5EFA: [_chunkBL22KD4Vcjs.COMMAND_NAMES.DEV, _chunkBL22KD4Vcjs.COMMAND_NAMES.BUILD, _chunkBL22KD4Vcjs.COMMAND_NAMES.PREVIEW],
|
|
537
463
|
\u5185\u5BB9\u7BA1\u7406: [
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
464
|
+
_chunkBL22KD4Vcjs.COMMAND_NAMES.UPDATE,
|
|
465
|
+
_chunkBL22KD4Vcjs.COMMAND_NAMES.UPDATE_COMPLETED_COUNT,
|
|
466
|
+
_chunkBL22KD4Vcjs.COMMAND_NAMES.CREATE_NOTES
|
|
541
467
|
],
|
|
542
|
-
"Git \u64CD\u4F5C": [
|
|
543
|
-
|
|
544
|
-
\
|
|
545
|
-
\u5176\u4ED6: [_chunkTJ4527KAcjs.COMMAND_NAMES.HELP]
|
|
468
|
+
"Git \u64CD\u4F5C": [_chunkBL22KD4Vcjs.COMMAND_NAMES.PUSH, _chunkBL22KD4Vcjs.COMMAND_NAMES.PULL],
|
|
469
|
+
\u521D\u59CB\u5316: [_chunkBL22KD4Vcjs.COMMAND_NAMES.INIT_SUB_REPO],
|
|
470
|
+
\u5176\u4ED6: [_chunkBL22KD4Vcjs.COMMAND_NAMES.HELP]
|
|
546
471
|
};
|
|
547
472
|
var COMMAND_OPTIONS_INFO = {
|
|
548
|
-
[
|
|
473
|
+
[_chunkBL22KD4Vcjs.COMMAND_OPTIONS.QUIET]: {
|
|
549
474
|
description: "\u9759\u9ED8\u6A21\u5F0F",
|
|
550
475
|
applicableTo: "update"
|
|
551
476
|
},
|
|
552
|
-
[
|
|
477
|
+
[_chunkBL22KD4Vcjs.COMMAND_OPTIONS.FORCE]: {
|
|
553
478
|
description: "\u5F3A\u5236\u63A8\u9001",
|
|
554
479
|
applicableTo: "push"
|
|
555
480
|
}
|
|
556
481
|
};
|
|
557
|
-
var HelpCommand = class extends
|
|
482
|
+
var HelpCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
558
483
|
constructor() {
|
|
559
484
|
super("help");
|
|
560
|
-
this.logger =
|
|
485
|
+
this.logger = _chunkBL22KD4Vcjs.createLogger.call(void 0, "help", {
|
|
561
486
|
timestamp: false,
|
|
562
487
|
level: process.env.DEBUG ? 0 /* DEBUG */ : 1 /* INFO */
|
|
563
488
|
});
|
|
@@ -573,7 +498,7 @@ var HelpCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
573
498
|
for (const [category, cmdNames] of Object.entries(COMMAND_CATEGORIES)) {
|
|
574
499
|
this.logger.info(` ${category}:`);
|
|
575
500
|
for (const cmdName of cmdNames) {
|
|
576
|
-
const description =
|
|
501
|
+
const description = _chunkBL22KD4Vcjs.COMMAND_DESCRIPTIONS[cmdName];
|
|
577
502
|
const paddingLength = Math.max(25 - cmdName.length, 1);
|
|
578
503
|
const padding = " ".repeat(paddingLength);
|
|
579
504
|
this.logger.info(` --${cmdName}${padding}${description}`);
|
|
@@ -585,9 +510,6 @@ var HelpCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
585
510
|
this.logger.info(" pnpm tn:build");
|
|
586
511
|
this.logger.info(" pnpm tn:create-notes # \u6279\u91CF\u521B\u5EFA\u7B14\u8BB0");
|
|
587
512
|
this.logger.info(" pnpm tn:update");
|
|
588
|
-
this.logger.info(
|
|
589
|
-
" pnpm tn:init-toc # v0.1.x \u2192 v0.2.x\uFF1A\u4ECE README.md \u751F\u6210 TOC.md"
|
|
590
|
-
);
|
|
591
513
|
this.logger.info(
|
|
592
514
|
" pnpm tn:update-completed-count # \u751F\u6210\u5F53\u524D\u77E5\u8BC6\u5E93\u6700\u8FD1 12 \u4E2A\u6708\u7684\u5B8C\u6210\u7B14\u8BB0\u6570\u91CF\u7EDF\u8BA1"
|
|
593
515
|
);
|
|
@@ -611,11 +533,11 @@ var HelpCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
611
533
|
// commands/note/CreateNoteCommand.ts
|
|
612
534
|
|
|
613
535
|
|
|
614
|
-
var CreateNoteCommand = class extends
|
|
536
|
+
var CreateNoteCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
615
537
|
constructor() {
|
|
616
538
|
super("create-notes");
|
|
617
|
-
this.noteService =
|
|
618
|
-
this.readmeService =
|
|
539
|
+
this.noteService = _chunkBL22KD4Vcjs.NoteService.getInstance();
|
|
540
|
+
this.readmeService = _chunkBL22KD4Vcjs.ReadmeService.getInstance();
|
|
619
541
|
}
|
|
620
542
|
async run() {
|
|
621
543
|
this.logger.info("\u521B\u5EFA\u65B0\u7B14\u8BB0...");
|
|
@@ -728,7 +650,7 @@ var CreateNoteCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
728
650
|
// commands/update-completed-count/UpdateCompletedCountCommand.ts
|
|
729
651
|
var _child_process = require('child_process');
|
|
730
652
|
|
|
731
|
-
var UpdateCompletedCountCommand = class extends
|
|
653
|
+
var UpdateCompletedCountCommand = class extends _chunkBL22KD4Vcjs.BaseCommand {
|
|
732
654
|
constructor() {
|
|
733
655
|
super("update-completed-count");
|
|
734
656
|
}
|
|
@@ -741,7 +663,7 @@ var UpdateCompletedCountCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
741
663
|
async updateCurrentRepo() {
|
|
742
664
|
const startTime = Date.now();
|
|
743
665
|
try {
|
|
744
|
-
const configContent = _fs.readFileSync.call(void 0,
|
|
666
|
+
const configContent = _fs.readFileSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_CONFIG_PATH, "utf-8");
|
|
745
667
|
const config = JSON.parse(configContent);
|
|
746
668
|
this.logger.info("\u5F00\u59CB\u66F4\u65B0\u5B8C\u6210\u7B14\u8BB0\u6570\u91CF\u5386\u53F2\u8BB0\u5F55...");
|
|
747
669
|
const completedNotesCountHistory = await this.getCompletedNotesCountHistory();
|
|
@@ -752,7 +674,7 @@ var UpdateCompletedCountCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
752
674
|
_chunkMZIXIY2Ycjs.stripDeprecatedRootItemFields.call(void 0,
|
|
753
675
|
config.root_item
|
|
754
676
|
);
|
|
755
|
-
_fs.writeFileSync.call(void 0,
|
|
677
|
+
_fs.writeFileSync.call(void 0, _chunkBL22KD4Vcjs.ROOT_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
756
678
|
const duration = Date.now() - startTime;
|
|
757
679
|
const monthKeys = Object.keys(completedNotesCountHistory);
|
|
758
680
|
const currentKey = monthKeys[monthKeys.length - 1];
|
|
@@ -833,7 +755,7 @@ var UpdateCompletedCountCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
833
755
|
let commitHash = _child_process.execSync.call(void 0,
|
|
834
756
|
`git log --until="${untilDate}" --format=%H -1 -- TOC.md`,
|
|
835
757
|
{
|
|
836
|
-
cwd:
|
|
758
|
+
cwd: _chunkBL22KD4Vcjs.ROOT_DIR_PATH,
|
|
837
759
|
encoding: "utf-8"
|
|
838
760
|
}
|
|
839
761
|
).trim();
|
|
@@ -842,7 +764,7 @@ var UpdateCompletedCountCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
842
764
|
commitHash = _child_process.execSync.call(void 0,
|
|
843
765
|
`git log --until="${untilDate}" --format=%H -1 -- README.md`,
|
|
844
766
|
{
|
|
845
|
-
cwd:
|
|
767
|
+
cwd: _chunkBL22KD4Vcjs.ROOT_DIR_PATH,
|
|
846
768
|
encoding: "utf-8"
|
|
847
769
|
}
|
|
848
770
|
).trim();
|
|
@@ -854,13 +776,13 @@ var UpdateCompletedCountCommand = class extends _chunkTJ4527KAcjs.BaseCommand {
|
|
|
854
776
|
let fileContent;
|
|
855
777
|
try {
|
|
856
778
|
fileContent = _child_process.execSync.call(void 0, `git show ${commitHash}:${filePath}`, {
|
|
857
|
-
cwd:
|
|
779
|
+
cwd: _chunkBL22KD4Vcjs.ROOT_DIR_PATH,
|
|
858
780
|
encoding: "utf-8"
|
|
859
781
|
});
|
|
860
782
|
} catch (error) {
|
|
861
783
|
return fallbackCount;
|
|
862
784
|
}
|
|
863
|
-
const { completedCount } = filePath === "TOC.md" ?
|
|
785
|
+
const { completedCount } = filePath === "TOC.md" ? _chunkAGVER5MXcjs.parseTocCompletedNotes.call(void 0, fileContent) : _chunkBL22KD4Vcjs.parseReadmeCompletedNotes.call(void 0, fileContent);
|
|
864
786
|
return completedCount;
|
|
865
787
|
}
|
|
866
788
|
};
|
|
@@ -871,14 +793,13 @@ var commandFactories = {
|
|
|
871
793
|
"create-notes": () => new CreateNoteCommand(),
|
|
872
794
|
"dev": () => new DevCommand(),
|
|
873
795
|
"init-sub-repo": () => new InitSubRepoCommand(),
|
|
874
|
-
"init-toc": () => new InitTocCommand(),
|
|
875
796
|
"help": () => new HelpCommand(),
|
|
876
797
|
"preview": () => new PreviewCommand(),
|
|
877
798
|
"pull": () => new PullCommand(),
|
|
878
799
|
"push": () => new PushCommand(),
|
|
879
|
-
"rename-note": () => new (0,
|
|
800
|
+
"rename-note": () => new (0, _chunkBL22KD4Vcjs.RenameNoteCommand)(),
|
|
880
801
|
"update-completed-count": () => new UpdateCompletedCountCommand(),
|
|
881
|
-
"update-note-config": () => new (0,
|
|
802
|
+
"update-note-config": () => new (0, _chunkBL22KD4Vcjs.UpdateNoteConfigCommand)(),
|
|
882
803
|
"update": () => new UpdateCommand()
|
|
883
804
|
};
|
|
884
805
|
var commandCache = /* @__PURE__ */ new Map();
|
|
@@ -891,13 +812,13 @@ function getCommand(name) {
|
|
|
891
812
|
// index.ts
|
|
892
813
|
(async () => {
|
|
893
814
|
try {
|
|
894
|
-
const args =
|
|
815
|
+
const args = _chunkBL22KD4Vcjs.parseArgs.call(void 0, process.argv.slice(2));
|
|
895
816
|
const commandName = Object.keys(args).find(
|
|
896
817
|
(key) => key !== "_" && args[key] === true
|
|
897
818
|
);
|
|
898
819
|
const command = commandName ? getCommand(commandName) : null;
|
|
899
820
|
if (!command) {
|
|
900
|
-
const logger2 =
|
|
821
|
+
const logger2 = _chunkBL22KD4Vcjs.createLogger.call(void 0, "command-not-found", {
|
|
901
822
|
timestamp: false
|
|
902
823
|
});
|
|
903
824
|
console.log(`
|
|
@@ -915,22 +836,22 @@ ${"-".repeat(66)}
|
|
|
915
836
|
console.log(`
|
|
916
837
|
${"-".repeat(66)}
|
|
917
838
|
`);
|
|
918
|
-
const helpCommand = getCommand(
|
|
839
|
+
const helpCommand = getCommand(_chunkBL22KD4Vcjs.COMMAND_NAMES.HELP);
|
|
919
840
|
if (helpCommand) {
|
|
920
841
|
console.log("\n\u6B63\u5728\u6267\u884C pnpm tn:help \u6253\u5370\u5E2E\u52A9\u4FE1\u606F...\n");
|
|
921
842
|
await helpCommand.execute();
|
|
922
843
|
}
|
|
923
844
|
return;
|
|
924
845
|
}
|
|
925
|
-
if (commandName ===
|
|
846
|
+
if (commandName === _chunkBL22KD4Vcjs.COMMAND_NAMES.UPDATE) {
|
|
926
847
|
const cmd = command;
|
|
927
848
|
if (args.quiet) cmd.setQuiet(true);
|
|
928
|
-
} else if (commandName ===
|
|
849
|
+
} else if (commandName === _chunkBL22KD4Vcjs.COMMAND_NAMES.PUSH) {
|
|
929
850
|
const cmd = command;
|
|
930
851
|
if (args.force) cmd.setOptions({ force: true });
|
|
931
852
|
}
|
|
932
853
|
await command.execute();
|
|
933
854
|
} catch (error) {
|
|
934
|
-
|
|
855
|
+
_chunkBL22KD4Vcjs.handleError.call(void 0, error, true);
|
|
935
856
|
}
|
|
936
857
|
})();
|