gflows 0.1.16 → 0.1.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gflows",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "A lightweight CLI for consistent Git branching workflows (main + dev, feature/bugfix/chore/release/hotfix).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -160,15 +160,16 @@ function writePackageVersion(dir: string, newVersion: string): void {
160
160
  }
161
161
 
162
162
  /**
163
- * Updates version in jsr.json if the file exists; preserves other keys.
163
+ * Updates version in jsr.json if the file exists. Only the version value is changed;
164
+ * the rest of the file (format, commas, spacing) is left unchanged.
164
165
  */
165
166
  function syncJsrVersion(dir: string, newVersion: string): boolean {
166
167
  const path = join(dir, JSR_JSON);
167
168
  if (!existsSync(path)) return false;
168
169
  const raw = readFileSync(path, "utf-8");
169
- const data = JSON.parse(raw) as Record<string, unknown>;
170
- data.version = newVersion;
171
- writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
170
+ const updated = raw.replace(/"version":\s*"[^"]*"/, `"version": "${newVersion}"`);
171
+ if (updated === raw) return false;
172
+ writeFileSync(path, updated, "utf-8");
172
173
  return true;
173
174
  }
174
175
 
@@ -87,10 +87,17 @@ export async function run(args: ParsedArgs): Promise<void> {
87
87
  process.exit(EXIT_OK);
88
88
  }
89
89
 
90
+ const currentBranchForPicker = await getCurrentBranch(root, {
91
+ dryRun,
92
+ verbose: args.verbose,
93
+ });
90
94
  const { select } = await import("@inquirer/prompts");
91
95
  const chosen = await select({
92
96
  message: "Switch to branch",
93
- choices: choices.map((b) => ({ name: b, value: b })),
97
+ choices: choices.map((b) => ({
98
+ name: currentBranchForPicker && b === currentBranchForPicker ? `${b} (current)` : b,
99
+ value: b,
100
+ })),
94
101
  });
95
102
 
96
103
  if (typeof chosen !== "string") {
@@ -181,23 +188,26 @@ export async function run(args: ParsedArgs): Promise<void> {
181
188
  }
182
189
  }
183
190
 
184
- if (whenUncommitted === "restore") {
191
+ const tryRestoreTargetStash = async (): Promise<void> => {
185
192
  const targetStashRef = await findStashRefByBranch(root, targetBranch, gitOpts);
186
- if (targetStashRef) {
187
- try {
188
- await stashPopRef(root, targetStashRef, gitOpts);
189
- } catch (err) {
190
- const msg = err instanceof Error ? err.message : String(err);
191
- console.error(
192
- `gflows switch: conflicts occurred while restoring saved changes for '${targetBranch}'.`,
193
- );
194
- console.error(
195
- "The stash was not dropped. Resolve conflicts, then commit or run `git stash drop` as needed.",
196
- );
197
- if (args.verbose && msg) console.error(msg);
198
- process.exit(EXIT_GIT);
199
- }
193
+ if (!targetStashRef) return;
194
+ try {
195
+ await stashPopRef(root, targetStashRef, gitOpts);
196
+ } catch (err) {
197
+ const msg = err instanceof Error ? err.message : String(err);
198
+ console.error(
199
+ `gflows switch: conflicts occurred while restoring saved changes for '${targetBranch}'.`,
200
+ );
201
+ console.error(
202
+ "The stash was not dropped. Resolve conflicts, then commit or run `git stash drop` as needed.",
203
+ );
204
+ if (args.verbose && msg) console.error(msg);
205
+ process.exit(EXIT_GIT);
200
206
  }
207
+ };
208
+
209
+ if (whenUncommitted === "restore" || whenUncommitted === undefined) {
210
+ await tryRestoreTargetStash();
201
211
  }
202
212
 
203
213
  if (!quiet && !dryRun) {