Skip to content

Commit 9c875ab

Browse files
committed
feat: 优化update-packages-to-all-plugins流程
1 parent 5c19629 commit 9c875ab

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"antd": "5.27.0",
3636
"clsx": "2.1.1",
3737
"next-flow-design": "^1.6.6",
38-
"next-flow-interface": "^0.25.13",
38+
"next-flow-interface": "^0.25.14",
3939
"react": "19.2.3",
4040
"react-dom": "19.2.3",
4141
"rhine-var": "0.11.2",

scripts/update-packages-to-all-plugins.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ function createGitTag(pluginPath: string, version: string): void {
200200
}
201201
}
202202

203-
// Git提交和推送
204-
function gitCommitAndPush(pluginPath: string, commitMessage: string, version: string): void {
203+
// Git提交和创建tag
204+
function gitCommitAndTag(pluginPath: string, commitMessage: string, version: string): void {
205205
try {
206206
console.log(`[INFO] Git add...`)
207207
execSync('git add .', { cwd: pluginPath, stdio: 'inherit' })
@@ -211,18 +211,21 @@ function gitCommitAndPush(pluginPath: string, commitMessage: string, version: st
211211

212212
console.log(`[INFO] Creating tag...`)
213213
createGitTag(pluginPath, version)
214+
} catch (error) {
215+
console.error(`[ERROR] Git operations failed in ${pluginPath}`)
216+
throw error
217+
}
218+
}
214219

220+
// Git推送
221+
function gitPush(pluginPath: string): void {
222+
try {
215223
console.log(`[INFO] Git push...`)
216224
execSync('git push --follow-tags', { cwd: pluginPath, stdio: 'inherit' })
217225
} catch (error) {
218-
// 如果是push失败,只记录错误但不中断流程
219-
if (error instanceof Error && error.message.includes('push')) {
220-
console.warn(`[WARNING] Git push failed for ${path.basename(pluginPath)}, skipping...`)
226+
console.warn(`[WARNING] Git push failed for ${path.basename(pluginPath)}, skipping...`)
227+
if (error instanceof Error) {
221228
console.warn(error.message)
222-
} else {
223-
// 其他错误则抛出
224-
console.error(`[ERROR] Git operations failed in ${pluginPath}`)
225-
throw error
226229
}
227230
}
228231
}
@@ -290,7 +293,9 @@ async function main() {
290293

291294
console.log(`\n[INFO] ${pluginsNeedUpdate.length} plugins need updates\n`)
292295

293-
// 处理需要更新的插件
296+
const pluginsReadyToPush: string[] = []
297+
298+
// 第一阶段:处理所有插件(更新、安装、提交)
294299
for (const { path: pluginPath, version } of pluginsNeedUpdate) {
295300
console.log(`\n[INFO] Processing ${path.basename(pluginPath)}...`)
296301

@@ -301,10 +306,11 @@ async function main() {
301306
// 2. 执行bun install
302307
runBunInstall(pluginPath)
303308

304-
// 3. Git提交和推送
305-
gitCommitAndPush(pluginPath, COMMIT_MESSAGE, version)
309+
// 3. Git提交和创建tag
310+
gitCommitAndTag(pluginPath, COMMIT_MESSAGE, version)
306311

307-
console.log(`[SUCCESS] ${path.basename(pluginPath)} updated successfully`)
312+
pluginsReadyToPush.push(pluginPath)
313+
console.log(`[SUCCESS] ${path.basename(pluginPath)} prepared successfully`)
308314
} catch (error) {
309315
console.error(`[ERROR] Failed to process ${path.basename(pluginPath)}`)
310316
console.error(error)
@@ -313,6 +319,17 @@ async function main() {
313319
}
314320
}
315321

322+
// 第二阶段:推送所有准备好的插件
323+
if (pluginsReadyToPush.length > 0) {
324+
console.log(`\n[INFO] Starting push phase for ${pluginsReadyToPush.length} plugins...\n`)
325+
326+
for (const pluginPath of pluginsReadyToPush) {
327+
console.log(`\n[INFO] Pushing ${path.basename(pluginPath)}...`)
328+
gitPush(pluginPath)
329+
console.log(`[SUCCESS] ${path.basename(pluginPath)} pushed successfully`)
330+
}
331+
}
332+
316333
console.log('\n[SUCCESS] All plugins processed!')
317334
}
318335

0 commit comments

Comments
 (0)