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 +1 -1
- package/src/commands/bump.ts +5 -4
- package/src/commands/switch.ts +26 -16
package/package.json
CHANGED
package/src/commands/bump.ts
CHANGED
|
@@ -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
|
|
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
|
|
170
|
-
|
|
171
|
-
writeFileSync(path,
|
|
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
|
|
package/src/commands/switch.ts
CHANGED
|
@@ -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) => ({
|
|
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
|
-
|
|
191
|
+
const tryRestoreTargetStash = async (): Promise<void> => {
|
|
185
192
|
const targetStashRef = await findStashRefByBranch(root, targetBranch, gitOpts);
|
|
186
|
-
if (targetStashRef)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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) {
|