git-stack-cli
Advanced tools
+2
-1
| { | ||
| "name": "git-stack-cli", | ||
| "version": "1.0.4", | ||
| "version": "1.0.5", | ||
| "description": "", | ||
@@ -30,2 +30,3 @@ "author": "magus", | ||
| "release:brew": "bun run scripts/release-brew.ts", | ||
| "release": "npm run release:npm && npm run release:github && npm run release:brew", | ||
| "lint:check": "eslint . --cache", | ||
@@ -32,0 +33,0 @@ "lint": "npm run lint:check -- --fix", |
@@ -35,3 +35,7 @@ import * as fs from "node:fs/promises"; | ||
| export async function rm(filepath: string) { | ||
| await fs.rm(filepath); | ||
| return fs.rm(filepath); | ||
| } | ||
| export async function mv(source: string, destination: string) { | ||
| return fs.rename(source, destination); | ||
| } |
+73
-24
@@ -20,2 +20,43 @@ import path from "node:path"; | ||
| process.chdir(HOMEBREW_DIR); | ||
| // before creating new formula, mv the previous into a versioned formula name | ||
| const previous_formula_path = path.join( | ||
| HOMEBREW_DIR, | ||
| "Formula", | ||
| "git-stack.rb" | ||
| ); | ||
| // match either version format from core or tap formula | ||
| // | ||
| // version "1.0.4" | ||
| // version = "1.0.4" | ||
| // | ||
| let previous_formula = await file.read_text(previous_formula_path); | ||
| const re_version = /version(?: =)? "(?<version>\d+\.\d+\.\d+)"/m; | ||
| const previous_version_match = previous_formula.match(re_version); | ||
| if (!previous_version_match?.groups) { | ||
| console.error("previous version missing in formula", previous_formula_path); | ||
| process.exit(3); | ||
| } | ||
| const previous_version = previous_version_match.groups.version; | ||
| // convert `1.0.4` to `104` | ||
| const not_dot_version = previous_version.replace(/\./g, ""); | ||
| const previous_class = `GitStackAt${not_dot_version}`; | ||
| previous_formula = previous_formula.replace( | ||
| "class GitStack", | ||
| `class ${previous_class}` | ||
| ); | ||
| await file.write_text( | ||
| path.join(HOMEBREW_DIR, "Formula", `git-stack@${previous_version}`), | ||
| previous_formula | ||
| ); | ||
| process.chdir(PROJECT_DIR); | ||
| await spawn(`npm run build:standalone`); | ||
| process.chdir(STANDALONE_DIR); | ||
@@ -33,35 +74,41 @@ | ||
| let formula = await file.read_text("git-stack.rb.template"); | ||
| let tap = await file.read_text( | ||
| path.join("templates", "git-stack.tap.rb.template") | ||
| ); | ||
| formula = formula.replace(re_token("version"), version); | ||
| formula = formula.replace(re_token("mac_bin"), macos_asset.filepath); | ||
| formula = formula.replace(re_token("mac_sha256"), macos_asset.sha256); | ||
| formula = formula.replace(re_token("linux_bin"), linux_asset.filepath); | ||
| formula = formula.replace(re_token("linux_sha256"), linux_asset.sha256); | ||
| tap = tap.replace(re_token("version"), version); | ||
| tap = tap.replace(re_token("mac_bin"), macos_asset.filepath); | ||
| tap = tap.replace(re_token("mac_sha256"), macos_asset.sha256); | ||
| tap = tap.replace(re_token("linux_bin"), linux_asset.filepath); | ||
| tap = tap.replace(re_token("linux_sha256"), linux_asset.sha256); | ||
| await file.write_text("git-stack.rb", formula); | ||
| await file.write_text(path.join("Formula", "git-stack.rb"), tap); | ||
| await spawn.sync(`git commit -a -m ${version}`); | ||
| await spawn.sync(`git push`); | ||
| let core = await file.read_text( | ||
| path.join("templates", "git-stack.core.rb.template") | ||
| ); | ||
| process.chdir(PROJECT_DIR); | ||
| core = core.replace(re_token("version"), version); | ||
| core = core.replace(re_token("mac_bin"), macos_asset.filepath); | ||
| core = core.replace(re_token("mac_sha256"), macos_asset.sha256); | ||
| core = core.replace(re_token("linux_bin"), linux_asset.filepath); | ||
| core = core.replace(re_token("linux_sha256"), linux_asset.sha256); | ||
| await spawn(`npm i`); | ||
| await file.write_text(path.join("Formula", "git-stack.core.rb"), core); | ||
| await spawn.sync(`git commit -a -m ${version}`); | ||
| await spawn.sync(`git push`); | ||
| // // commit homebrew repo changes | ||
| // await spawn.sync(`git commit -a -m ${version}`); | ||
| // await spawn.sync(`git push`); | ||
| // -a: create tag on last commit | ||
| // -m: message | ||
| await spawn.sync(`git tag -a ${version} -m ${version}`); | ||
| await spawn.sync(`git push origin ${version}`); | ||
| // // commmit changes to main repo | ||
| // process.chdir(PROJECT_DIR); | ||
| // await spawn.sync(`git commit -a -m "homebrew-git-stack ${version}"`); | ||
| // await spawn.sync(`git push`); | ||
| await spawn.sync(`gh release create ${version} -t ${version} --generate-notes`); | ||
| // // finally upload the assets to the github release | ||
| // process.chdir(STANDALONE_DIR); | ||
| // await spawn.sync(`gh release upload ${version} ${linux_asset.filepath}`); | ||
| // await spawn.sync(`gh release upload ${version} ${macos_asset.filepath}`); | ||
| // await spawn.sync(`gh release upload ${version} ${win_asset.filepath}`); | ||
| process.chdir(STANDALONE_DIR); | ||
| await spawn.sync(`gh release upload ${version} ${linux_asset.filepath}`); | ||
| await spawn.sync(`gh release upload ${version} ${macos_asset.filepath}`); | ||
| await spawn.sync(`gh release upload ${version} ${win_asset.filepath}`); | ||
| console.debug(); | ||
@@ -72,1 +119,3 @@ console.debug("✅", "published", version); | ||
| console.debug(); | ||
| console.debug("https://github.com/magus/git-stack-cli/releases"); | ||
| console.debug(); |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1575186
0.12%38670
0.12%