git-stack-cli 1.0.4 → 1.0.5

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.
@@ -34080,7 +34080,7 @@ async function command() {
34080
34080
  .wrap(null)
34081
34081
  // disallow unknown options
34082
34082
  .strict()
34083
- .version("1.0.4" )
34083
+ .version("1.0.5" )
34084
34084
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34085
34085
  .help("help", "Show usage via `git stack help`").argv);
34086
34086
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -27,6 +27,7 @@
27
27
  "release:npm": "bun run scripts/release-npm.ts",
28
28
  "release:github": "bun run scripts/release-github.ts",
29
29
  "release:brew": "bun run scripts/release-brew.ts",
30
+ "release": "npm run release:npm && npm run release:github && npm run release:brew",
30
31
  "lint:check": "eslint . --cache",
31
32
  "lint": "npm run lint:check -- --fix",
32
33
  "prettier:check": "prettier ./src --check --cache",
@@ -32,5 +32,9 @@ export async function exists(filepath: string) {
32
32
  }
33
33
 
34
34
  export async function rm(filepath: string) {
35
- await fs.rm(filepath);
35
+ return fs.rm(filepath);
36
+ }
37
+
38
+ export async function mv(source: string, destination: string) {
39
+ return fs.rename(source, destination);
36
40
  }
@@ -17,6 +17,47 @@ const package_json = await file.read_json(
17
17
 
18
18
  const version = package_json.version;
19
19
 
20
+ process.chdir(HOMEBREW_DIR);
21
+
22
+ // before creating new formula, mv the previous into a versioned formula name
23
+ const previous_formula_path = path.join(
24
+ HOMEBREW_DIR,
25
+ "Formula",
26
+ "git-stack.rb"
27
+ );
28
+
29
+ // match either version format from core or tap formula
30
+ //
31
+ // version "1.0.4"
32
+ // version = "1.0.4"
33
+ //
34
+ let previous_formula = await file.read_text(previous_formula_path);
35
+ const re_version = /version(?: =)? "(?<version>\d+\.\d+\.\d+)"/m;
36
+ const previous_version_match = previous_formula.match(re_version);
37
+
38
+ if (!previous_version_match?.groups) {
39
+ console.error("previous version missing in formula", previous_formula_path);
40
+ process.exit(3);
41
+ }
42
+
43
+ const previous_version = previous_version_match.groups.version;
44
+ // convert `1.0.4` to `104`
45
+ const not_dot_version = previous_version.replace(/\./g, "");
46
+ const previous_class = `GitStackAt${not_dot_version}`;
47
+ previous_formula = previous_formula.replace(
48
+ "class GitStack",
49
+ `class ${previous_class}`
50
+ );
51
+
52
+ await file.write_text(
53
+ path.join(HOMEBREW_DIR, "Formula", `git-stack@${previous_version}`),
54
+ previous_formula
55
+ );
56
+
57
+ process.chdir(PROJECT_DIR);
58
+
59
+ await spawn(`npm run build:standalone`);
60
+
20
61
  process.chdir(STANDALONE_DIR);
21
62
 
22
63
  const linux_asset = await create_asset("git-stack-cli-linux", { version });
@@ -29,41 +70,49 @@ const re_token = (name: string) => new RegExp(`{{ ${name} }}`, "g");
29
70
 
30
71
  process.chdir(HOMEBREW_DIR);
31
72
 
32
- let formula = await file.read_text("git-stack.rb.template");
33
-
34
- formula = formula.replace(re_token("version"), version);
35
- formula = formula.replace(re_token("mac_bin"), macos_asset.filepath);
36
- formula = formula.replace(re_token("mac_sha256"), macos_asset.sha256);
37
- formula = formula.replace(re_token("linux_bin"), linux_asset.filepath);
38
- formula = formula.replace(re_token("linux_sha256"), linux_asset.sha256);
73
+ let tap = await file.read_text(
74
+ path.join("templates", "git-stack.tap.rb.template")
75
+ );
39
76
 
40
- await file.write_text("git-stack.rb", formula);
77
+ tap = tap.replace(re_token("version"), version);
78
+ tap = tap.replace(re_token("mac_bin"), macos_asset.filepath);
79
+ tap = tap.replace(re_token("mac_sha256"), macos_asset.sha256);
80
+ tap = tap.replace(re_token("linux_bin"), linux_asset.filepath);
81
+ tap = tap.replace(re_token("linux_sha256"), linux_asset.sha256);
41
82
 
42
- await spawn.sync(`git commit -a -m ${version}`);
43
- await spawn.sync(`git push`);
83
+ await file.write_text(path.join("Formula", "git-stack.rb"), tap);
44
84
 
45
- process.chdir(PROJECT_DIR);
46
-
47
- await spawn(`npm i`);
85
+ let core = await file.read_text(
86
+ path.join("templates", "git-stack.core.rb.template")
87
+ );
48
88
 
49
- await spawn.sync(`git commit -a -m ${version}`);
50
- await spawn.sync(`git push`);
89
+ core = core.replace(re_token("version"), version);
90
+ core = core.replace(re_token("mac_bin"), macos_asset.filepath);
91
+ core = core.replace(re_token("mac_sha256"), macos_asset.sha256);
92
+ core = core.replace(re_token("linux_bin"), linux_asset.filepath);
93
+ core = core.replace(re_token("linux_sha256"), linux_asset.sha256);
51
94
 
52
- // -a: create tag on last commit
53
- // -m: message
54
- await spawn.sync(`git tag -a ${version} -m ${version}`);
55
- await spawn.sync(`git push origin ${version}`);
95
+ await file.write_text(path.join("Formula", "git-stack.core.rb"), core);
56
96
 
57
- await spawn.sync(`gh release create ${version} -t ${version} --generate-notes`);
97
+ // // commit homebrew repo changes
98
+ // await spawn.sync(`git commit -a -m ${version}`);
99
+ // await spawn.sync(`git push`);
58
100
 
59
- process.chdir(STANDALONE_DIR);
101
+ // // commmit changes to main repo
102
+ // process.chdir(PROJECT_DIR);
103
+ // await spawn.sync(`git commit -a -m "homebrew-git-stack ${version}"`);
104
+ // await spawn.sync(`git push`);
60
105
 
61
- await spawn.sync(`gh release upload ${version} ${linux_asset.filepath}`);
62
- await spawn.sync(`gh release upload ${version} ${macos_asset.filepath}`);
63
- await spawn.sync(`gh release upload ${version} ${win_asset.filepath}`);
106
+ // // finally upload the assets to the github release
107
+ // process.chdir(STANDALONE_DIR);
108
+ // await spawn.sync(`gh release upload ${version} ${linux_asset.filepath}`);
109
+ // await spawn.sync(`gh release upload ${version} ${macos_asset.filepath}`);
110
+ // await spawn.sync(`gh release upload ${version} ${win_asset.filepath}`);
64
111
 
65
112
  console.debug();
66
113
  console.debug("✅", "published", version);
67
114
  console.debug();
68
115
  console.debug("https://github.com/magus/homebrew-git-stack");
69
116
  console.debug();
117
+ console.debug("https://github.com/magus/git-stack-cli/releases");
118
+ console.debug();