Skip to content

Commit f9e5425

Browse files
author
Tdahuyou
committed
📝 Update notes - 2025-11-05 23:30:12
1 parent 60ed6b0 commit f9e5425

File tree

35 files changed

+400
-97
lines changed

35 files changed

+400
-97
lines changed

.tnotes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"details": "Git 笔记",
2424
"link": "https://tnotesjs.github.io/TNotes.git-notes/",
2525
"created_at": 1727172590000,
26-
"updated_at": 1759581959446,
26+
"updated_at": 1762347602293,
2727
"days_since_birth": 9220
2828
},
2929
"port": 9220,

.vitepress/tnotes/commands/misc/HelpCommand.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ export class HelpCommand extends BaseCommand {
4646
this.logger.info(' npx tsx ./.vitepress/tnotes/index.ts --dev')
4747
this.logger.info(' pnpm tn:build')
4848
this.logger.info(' pnpm tn:update')
49+
this.logger.info(' pnpm tn:update --all # 更新所有知识库')
50+
this.logger.info(' pnpm tn:push --all # 推送所有知识库')
51+
this.logger.info('')
52+
this.logger.info('参数:')
53+
this.logger.info(
54+
' --all 批量操作所有知识库 (适用于 update/push/pull/sync)'
55+
)
56+
this.logger.info(' --quiet 静默模式 (适用于 update)')
57+
this.logger.info(' --force 强制推送 (适用于 push)')
58+
this.logger.info(' --no-watch 禁用文件监听 (适用于 dev)')
4959
this.logger.info('')
5060
this.logger.info('环境变量:')
5161
this.logger.info(' DEBUG=1 启用调试模式,显示详细日志')

.vitepress/tnotes/commands/update/UpdateCommand.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class UpdateCommand extends BaseCommand {
2626
private readmeService: ReadmeService
2727
private noteService: NoteService
2828
private quiet: boolean = false
29+
private updateAll: boolean = false
2930

3031
constructor() {
3132
super('update', '根据笔记内容更新知识库')
@@ -46,7 +47,25 @@ export class UpdateCommand extends BaseCommand {
4647
}
4748
}
4849

50+
/**
51+
* 设置是否更新所有知识库
52+
*/
53+
setUpdateAll(updateAll: boolean): void {
54+
this.updateAll = updateAll
55+
}
56+
4957
protected async run(): Promise<void> {
58+
if (this.updateAll) {
59+
await this.updateAllRepos()
60+
} else {
61+
await this.updateCurrentRepo()
62+
}
63+
}
64+
65+
/**
66+
* 更新当前知识库
67+
*/
68+
private async updateCurrentRepo(): Promise<void> {
5069
const startTime = Date.now()
5170

5271
// 先修正所有笔记的标题
@@ -77,6 +96,77 @@ export class UpdateCommand extends BaseCommand {
7796
}
7897
}
7998

99+
/**
100+
* 更新所有知识库
101+
*/
102+
private async updateAllRepos(): Promise<void> {
103+
const { getTargetDirs } = await import('../../utils')
104+
const { EN_WORDS_DIR } = await import('../../config/constants')
105+
const { runCommand } = await import('../../utils/runCommand')
106+
107+
try {
108+
// 获取所有目标知识库
109+
const targetDirs = getTargetDirs(TNOTES_BASE_DIR, 'TNotes.', [
110+
ROOT_DIR_PATH,
111+
EN_WORDS_DIR,
112+
])
113+
114+
if (targetDirs.length === 0) {
115+
this.logger.warn('未找到符合条件的知识库')
116+
return
117+
}
118+
119+
this.logger.info(`正在更新 ${targetDirs.length} 个知识库...`)
120+
121+
// 依次更新每个知识库
122+
let successCount = 0
123+
let failCount = 0
124+
125+
for (let i = 0; i < targetDirs.length; i++) {
126+
const dir = targetDirs[i]
127+
const repoName = dir.split('/').pop() || dir
128+
129+
try {
130+
process.stdout.write(
131+
`\r [${i + 1}/${targetDirs.length}] 正在更新: ${repoName}...`
132+
)
133+
134+
// 执行更新命令
135+
await runCommand('pnpm tn:update --quiet', dir)
136+
successCount++
137+
} catch (error) {
138+
failCount++
139+
console.log() // 换行
140+
this.logger.error(
141+
`更新失败: ${repoName} - ${
142+
error instanceof Error ? error.message : String(error)
143+
}`
144+
)
145+
}
146+
}
147+
148+
console.log() // 换行
149+
150+
// 显示汇总
151+
if (failCount === 0) {
152+
this.logger.success(
153+
`✅ 所有知识库更新完成: ${successCount}/${targetDirs.length}`
154+
)
155+
} else {
156+
this.logger.warn(
157+
`⚠️ 更新完成: ${successCount} 成功, ${failCount} 失败 (共 ${targetDirs.length} 个)`
158+
)
159+
}
160+
} catch (error) {
161+
this.logger.error(
162+
`批量更新失败: ${
163+
error instanceof Error ? error.message : String(error)
164+
}`
165+
)
166+
throw error
167+
}
168+
}
169+
80170
/**
81171
* 更新 root_item 配置
82172
*/

.vitepress/tnotes/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ import { handleError, createError } from './utils/errorHandler'
6565
}
6666
}
6767

68-
// 处理 --all 参数(适用于 push/pull/sync 命令)
68+
// 处理 --all 参数(适用于 update/push/pull/sync 命令)
6969
if (args.all) {
70-
if (commandName === 'push') {
70+
if (commandName === 'update') {
71+
const updateCommand = command as any
72+
if (typeof updateCommand.setUpdateAll === 'function') {
73+
updateCommand.setUpdateAll(true)
74+
}
75+
} else if (commandName === 'push') {
7176
const pushCommand = command as any
7277
if (typeof pushCommand.setPushAll === 'function') {
7378
pushCommand.setPushAll(true)

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<!-- region:toc -->
44

5-
- [git](#git)
65
- [1. git-notes 简介](#1-git-notes-简介)
76
- [2. Github 开源项目](#2-github-开源项目)
87
- [3. Github 基本使用](#3-github-基本使用)
@@ -70,4 +69,4 @@
7069

7170
## 5. ⏰ pending
7271

73-
- [ ] [0026. m2mm](https://github.com/tnotesjs/TNotes.git-notes/tree/main/notes/0026.%20m2mm/README.md)
72+
- [ ] [0026. m2mm](https://github.com/tnotesjs/TNotes.git-notes/tree/main/notes/0026.%20m2mm/README.md)

notes/0001. 修改指定远程仓库的 url/.tnotes.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"tnotes": [],
44
"yuque": [],
55
"done": false,
6+
"deprecated": false,
67
"enableDiscussions": false,
8+
"id": "22b55db9-828d-48b7-8f6f-70bcc9e620c6",
79
"created_at": 1746533408000,
8-
"updated_at": 1758871581445,
9-
"id": "22b55db9-828d-48b7-8f6f-70bcc9e620c6"
10-
}
10+
"updated_at": 1758871581445
11+
}

notes/0002. 尝试变更到远程仓库时遇到 Permission denied (publickey) 错误/.tnotes.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"tnotes": [],
44
"yuque": [],
55
"done": false,
6+
"deprecated": false,
67
"enableDiscussions": false,
8+
"id": "121ff386-9673-4089-bd5a-a57adbcf8cd2",
79
"created_at": 1758172027916,
8-
"updated_at": 1758172027916,
9-
"id": "121ff386-9673-4089-bd5a-a57adbcf8cd2"
10-
}
10+
"updated_at": 1758172027916
11+
}

notes/0003. git clone 报 RPC failed 错误/.tnotes.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"tnotes": [],
44
"yuque": [],
55
"done": false,
6+
"deprecated": false,
67
"enableDiscussions": false,
8+
"id": "2805e175-8a2e-4986-9502-b2ace865b2ed",
79
"created_at": 1758172027917,
8-
"updated_at": 1758172027917,
9-
"id": "2805e175-8a2e-4986-9502-b2ace865b2ed"
10-
}
10+
"updated_at": 1758172027917
11+
}

notes/0004. 处理每次使用 SSH 密钥进行身份验证时都需要输入密码短语(passphrase)的问题/.tnotes.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"tnotes": [],
44
"yuque": [],
55
"done": false,
6+
"deprecated": false,
67
"enableDiscussions": false,
8+
"id": "325bbfb1-16d5-43d0-933e-b6607bb1380b",
79
"created_at": 1758172027918,
8-
"updated_at": 1758172027918,
9-
"id": "325bbfb1-16d5-43d0-933e-b6607bb1380b"
10-
}
10+
"updated_at": 1758172027918
11+
}

notes/0005. git proxy 配置/.tnotes.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"tnotes": [],
44
"yuque": [],
55
"done": false,
6+
"deprecated": false,
67
"enableDiscussions": false,
8+
"id": "43e6fc32-00b5-4624-a88d-61710609d174",
79
"created_at": 1758172027919,
8-
"updated_at": 1758172027919,
9-
"id": "43e6fc32-00b5-4624-a88d-61710609d174"
10-
}
10+
"updated_at": 1758172027919
11+
}

0 commit comments

Comments
 (0)