bstack 1.3.0 → 1.4.0

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.
Files changed (2) hide show
  1. package/dist/bstack.mjs +38 -14
  2. package/package.json +1 -1
package/dist/bstack.mjs CHANGED
@@ -6,7 +6,7 @@ import * as v from "valibot";
6
6
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
7
7
  import { dirname } from "node:path";
8
8
  //#region package.json
9
- var version = "1.3.0";
9
+ var version = "1.4.0";
10
10
  //#endregion
11
11
  //#region src/command.ts
12
12
  var CommandError = class extends Error {
@@ -510,6 +510,25 @@ var GitHubCliPlatform = class {
510
510
  }
511
511
  };
512
512
  //#endregion
513
+ //#region src/output.ts
514
+ function formatSyncResult(result, dryRun) {
515
+ const changeCount = `${result.changes.length} change${result.changes.length === 1 ? "" : "s"}`;
516
+ const lines = [dryRun ? `Would sync ${changeCount} against ${result.base}:` : `Synced stack against ${result.base} (${changeCount}):`];
517
+ if (dryRun) {
518
+ for (const change of result.changes) lines.push(` ${change.oid.slice(0, 8)} ${change.subject}`);
519
+ return lines.join("\n");
520
+ }
521
+ for (const outcome of result.outcomes) {
522
+ if (outcome.outcome === "closed") {
523
+ const { pullRequest } = outcome;
524
+ lines.push(` ${outcome.outcome.padEnd(9)} #${pullRequest.number} ${pullRequest.title} ${pullRequest.url}`);
525
+ continue;
526
+ }
527
+ lines.push(` ${outcome.outcome.padEnd(9)} #${outcome.pullRequest.number} ${outcome.change.subject} ${outcome.pullRequest.url}`);
528
+ }
529
+ return lines.join("\n");
530
+ }
531
+ //#endregion
513
532
  //#region src/reporter.ts
514
533
  var ConsoleReporter = class {
515
534
  progress(message) {
@@ -703,7 +722,8 @@ function syncStack(dependencies, options) {
703
722
  base,
704
723
  remote,
705
724
  rewritten,
706
- changes: [...changes]
725
+ changes: [...changes],
726
+ outcomes: []
707
727
  };
708
728
  }
709
729
  reporter.progress("Reading the previous stack state");
@@ -807,15 +827,25 @@ function syncStack(dependencies, options) {
807
827
  if (stackNumber !== void 0) updatedStack.stackNumber = stackNumber;
808
828
  writeUpdatedState(stateStore, state, previous, updatedStack);
809
829
  reporter.progress("Saved the local stack state");
830
+ const synchronized = changes.map((change, index) => ({
831
+ ...change,
832
+ pullRequest: pullRequests[index]
833
+ }));
834
+ const outcomes = synchronized.map((change, index) => ({
835
+ outcome: changeOutcome(change, index, change.pullRequest, previous, changes, base, createdBranches, pushedBranches),
836
+ change,
837
+ pullRequest: change.pullRequest
838
+ }));
839
+ outcomes.push(...omittedPullRequests.map((pullRequest) => ({
840
+ outcome: "closed",
841
+ pullRequest
842
+ })));
810
843
  return {
811
844
  base,
812
845
  remote,
813
846
  rewritten,
814
- changes: changes.map((change, index) => ({
815
- ...change,
816
- pullRequest: pullRequests[index],
817
- outcome: changeOutcome(change, index, pullRequests[index], previous, changes, base, createdBranches, pushedBranches)
818
- }))
847
+ changes: synchronized,
848
+ outcomes
819
849
  };
820
850
  }
821
851
  function changeOutcome(change, index, pullRequest, previous, changes, base, createdBranches, pushedBranches) {
@@ -939,13 +969,7 @@ function main() {
939
969
  draft: values.draft,
940
970
  dryRun: values["dry-run"]
941
971
  });
942
- const changeCount = `${result.changes.length} change${result.changes.length === 1 ? "" : "s"}`;
943
- console.log(values["dry-run"] ? `Would sync ${changeCount} against ${result.base}:` : `Synced stack against ${result.base} (${changeCount}):`);
944
- for (const change of result.changes) {
945
- const outcome = change.outcome ? `${change.outcome.padEnd(9)} ` : "";
946
- const destination = change.pullRequest ? ` ${change.pullRequest.url}` : "";
947
- console.log(` ${outcome}${change.oid.slice(0, 8)} ${change.subject}${destination}`);
948
- }
972
+ console.log(formatSyncResult(result, values["dry-run"]));
949
973
  }
950
974
  try {
951
975
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bstack",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Create native GitHub stacked pull requests from a linear series of commits",
5
5
  "license": "MIT",
6
6
  "repository": {