From 72d02198ff806f14bab50740f58b562e7e162ac8 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 5 Dec 2024 09:33:37 -0800 Subject: [PATCH] Add frontend update script to automate sync with latest frontend release (#435) * Add frontend update script * nit * Update URL --- package.json | 3 ++- scripts/updateFrontend.js | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 scripts/updateFrontend.js diff --git a/package.json b/package.json index 45171ced..4c3cea2f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "typescript": "yarn run tsc", "vite:compile": "vite build --config vite.main.config.ts && vite build --config vite.preload.config.ts", "vite:types": "vite build --config vite.types.config.ts && node scripts/prepareTypes.js", - "release:types": "node scripts/releaseTypes.js" + "release:types": "node scripts/releaseTypes.js", + "update:frontend": "node scripts/updateFrontend.js" }, "devDependencies": { "@electron/fuses": "^1.8.0", diff --git a/scripts/updateFrontend.js b/scripts/updateFrontend.js new file mode 100644 index 00000000..70c311ec --- /dev/null +++ b/scripts/updateFrontend.js @@ -0,0 +1,40 @@ +const { execSync } = require('child_process') +const { readFileSync, writeFileSync } = require('fs') + +async function main() { + try { + // Create a new branch with version-bump prefix + console.log('Creating new branch...') + const date = new Date().toISOString().split('T')[0] + const timestamp = new Date().getTime() + const branchName = `version-bump-${date}-${timestamp}` + execSync(`git checkout -b ${branchName} -t origin/main`, { stdio: 'inherit' }) + + // Get latest frontend release: https://github.com/Comfy-Org/ComfyUI_frontend/releases + const latestRelease = 'https://api.github.com/repos/Comfy-Org/ComfyUI_frontend/releases/latest' + const latestReleaseData = await fetch(latestRelease) + const latestReleaseTag = (await latestReleaseData.json()).tag_name + const version = latestReleaseTag.replace('v', '') + + // Update frontend version in package.json + const packageJson = JSON.parse(readFileSync('./package.json', 'utf8')) + packageJson.config.frontendVersion = version + writeFileSync('./package.json', JSON.stringify(packageJson, null, 2)) + + // Commit the version bump + execSync(`git commit -am "[chore] Update frontend to ${version}"`, { stdio: 'inherit' }) + + // Create the PR + console.log('Creating PR...') + execSync( + `gh pr create --title "[chore] Update frontend to ${version}" --label "dependencies" --body "Automated frontend update to ${version}"`, + { stdio: 'inherit' } + ) + + console.log(`✅ Successfully created PR for frontend ${version}`) + } catch (error) { + console.error('❌ Error during release process:', error.message) + } +} + +main()