git-stack-cli 1.2.7 → 1.3.1

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.
@@ -26197,9 +26197,10 @@ function LogTimestamp() {
26197
26197
  }
26198
26198
 
26199
26199
  const BaseStore = createStore()(immer((set, get) => ({
26200
- argv: null,
26201
- ink: null,
26202
- cwd: null,
26200
+ // set immediately in `index.tsx` so no `null` scenario
26201
+ argv: {},
26202
+ ink: {},
26203
+ cwd: "",
26203
26204
  username: null,
26204
26205
  repo_path: null,
26205
26206
  repo_root: null,
@@ -26675,12 +26676,6 @@ function AutoUpdate(props) {
26675
26676
  status));
26676
26677
  }
26677
26678
 
26678
- function invariant(condition, message) {
26679
- if (!condition) {
26680
- throw new Error(message);
26681
- }
26682
- }
26683
-
26684
26679
  function serialize(obj) {
26685
26680
  if (obj instanceof Map) {
26686
26681
  return {
@@ -26728,7 +26723,6 @@ function Debug() {
26728
26723
  }
26729
26724
  }, [argv]);
26730
26725
  reactExports.useEffect(function syncStateJson() {
26731
- invariant(state.cwd, "state.cwd must exist");
26732
26726
  if (!argv?.["write-state-json"]) {
26733
26727
  return;
26734
26728
  }
@@ -26783,6 +26777,12 @@ function cache(cacheable) {
26783
26777
  return { reset, check, read };
26784
26778
  }
26785
26779
 
26780
+ function invariant(condition, message) {
26781
+ if (!condition) {
26782
+ throw new Error(message);
26783
+ }
26784
+ }
26785
+
26786
26786
  function Await(props) {
26787
26787
  const [display_fallback, set_display_fallback] = reactExports.useState(false);
26788
26788
  // const id = React.useId();
@@ -26983,15 +26983,12 @@ function CheckGitRevise(props) {
26983
26983
  }
26984
26984
 
26985
26985
  function GatherMetadata(props) {
26986
- const argv = Store.useState((state) => state.argv);
26987
- invariant(argv, "argv must exist");
26988
26986
  const fallback = (reactExports.createElement(Text, { color: colors.yellow }, "Gathering local git information..."));
26989
26987
  return (reactExports.createElement(Await, { fallback: fallback, function: gather_metadata$1 }, props.children));
26990
26988
  }
26991
26989
  async function gather_metadata$1() {
26992
26990
  const actions = Store.getState().actions;
26993
26991
  const argv = Store.getState().argv;
26994
- invariant(argv, "argv must exist");
26995
26992
  try {
26996
26993
  // default to master branch, fallback to main
26997
26994
  let master_branch;
@@ -27083,8 +27080,6 @@ function format_time(date) {
27083
27080
  }
27084
27081
 
27085
27082
  function GithubApiError() {
27086
- const argv = Store.useState((state) => state.argv);
27087
- invariant(argv, "argv must exist");
27088
27083
  return reactExports.createElement(Await, { fallback: null, function: run$4 });
27089
27084
  }
27090
27085
  async function run$4() {
@@ -27435,7 +27430,6 @@ const UNASSIGNED = "unassigned";
27435
27430
 
27436
27431
  function LocalCommitStatus(props) {
27437
27432
  const argv = Store.useState((state) => state.argv);
27438
- invariant(argv, "argv must exist");
27439
27433
  const fallback = (reactExports.createElement(Text, { color: colors.yellow }, "Fetching PR status from Github..."));
27440
27434
  if (argv["mock-metadata"]) {
27441
27435
  return (reactExports.createElement(Await, { fallback: fallback, function: mock_metadata }, props.children));
@@ -27541,10 +27535,8 @@ async function run$3() {
27541
27535
  const master_branch = state.master_branch;
27542
27536
  const cwd = state.cwd;
27543
27537
  const repo_root = state.repo_root;
27544
- invariant(argv, "argv must exist");
27545
27538
  invariant(branch_name, "branch_name must exist");
27546
27539
  invariant(commit_range, "commit_range must exist");
27547
- invariant(cwd, "cwd must exist");
27548
27540
  invariant(repo_root, "repo_root must exist");
27549
27541
  // always listen for SIGINT event and restore git state
27550
27542
  process.once("SIGINT", handle_exit);
@@ -27654,7 +27646,6 @@ async function run$3() {
27654
27646
  }
27655
27647
  }
27656
27648
  // restore back to original dir
27657
- invariant(cwd, "cwd must exist");
27658
27649
  if (fs.existsSync(cwd)) {
27659
27650
  process.chdir(cwd);
27660
27651
  }
@@ -27825,10 +27816,10 @@ const RE = {
27825
27816
  })),
27826
27817
  };
27827
27818
 
27828
- function ManualRebase(props) {
27829
- return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits..."), function: () => run$2(props) }));
27819
+ function ManualRebase() {
27820
+ return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits..."), function: run$2 }));
27830
27821
  }
27831
- async function run$2(props) {
27822
+ async function run$2() {
27832
27823
  const state = Store.getState();
27833
27824
  const actions = state.actions;
27834
27825
  const argv = state.argv;
@@ -27837,10 +27828,8 @@ async function run$2(props) {
27837
27828
  const master_branch = state.master_branch;
27838
27829
  const cwd = state.cwd;
27839
27830
  const repo_root = state.repo_root;
27840
- invariant(argv, "argv must exist");
27841
27831
  invariant(branch_name, "branch_name must exist");
27842
27832
  invariant(commit_map, "commit_map must exist");
27843
- invariant(cwd, "cwd must exist");
27844
27833
  invariant(repo_root, "repo_root must exist");
27845
27834
  // always listen for SIGINT event and restore git state
27846
27835
  process.once("SIGINT", handle_exit);
@@ -27897,7 +27886,6 @@ async function run$2(props) {
27897
27886
  handle_exit();
27898
27887
  }
27899
27888
  async function rebase_git_revise() {
27900
- invariant(argv, "argv must exist");
27901
27889
  actions.debug(`rebase_git_revise`);
27902
27890
  actions.output(reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }, "Rebasing\u2026"));
27903
27891
  // generate temporary directory and drop sequence editor script
@@ -27991,7 +27979,6 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
27991
27979
  await update_pr_tables(pr_url_list);
27992
27980
  }
27993
27981
  async function rebase_cherry_pick() {
27994
- invariant(argv, "argv must exist");
27995
27982
  actions.debug("rebase_cherry_pick");
27996
27983
  // create temporary branch based on merge base
27997
27984
  await cli(`git checkout -b ${temp_branch_name} ${rebase_merge_base}`);
@@ -28025,11 +28012,10 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28025
28012
  await update_pr_tables(pr_url_list);
28026
28013
  }
28027
28014
  async function sync_group_github(args) {
28028
- if (props.skipSync) {
28015
+ if (!argv.sync) {
28029
28016
  return;
28030
28017
  }
28031
28018
  const { group, pr_url_list } = args;
28032
- invariant(argv, "argv must exist");
28033
28019
  invariant(group.base, "group.base must exist");
28034
28020
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Syncing {group}\u2026", values: {
28035
28021
  group: (reactExports.createElement(Brackets, null, group.pr?.title || group.title || group.id)),
@@ -28084,6 +28070,9 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28084
28070
  }
28085
28071
  }
28086
28072
  async function update_pr_tables(pr_url_list) {
28073
+ if (!argv.sync) {
28074
+ return;
28075
+ }
28087
28076
  for (let i = 0; i < commit_range.group_list.length; i++) {
28088
28077
  const group = commit_range.group_list[i];
28089
28078
  // use the updated pr_url_list to get the actual selected_url
@@ -28131,7 +28120,6 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28131
28120
  }
28132
28121
  }
28133
28122
  // restore back to original dir
28134
- invariant(cwd, "cwd must exist");
28135
28123
  if (fs.existsSync(cwd)) {
28136
28124
  process.chdir(cwd);
28137
28125
  }
@@ -28330,8 +28318,6 @@ function get_status_bold(row) {
28330
28318
  }
28331
28319
 
28332
28320
  function PostRebaseStatus() {
28333
- const argv = Store.useState((state) => state.argv);
28334
- invariant(argv, "argv must exist");
28335
28321
  return reactExports.createElement(Await, { fallback: null, function: run$1 });
28336
28322
  }
28337
28323
  async function run$1() {
@@ -28349,7 +28335,6 @@ async function run$1() {
28349
28335
  function PreLocalMergeRebase() {
28350
28336
  const actions = Store.useActions();
28351
28337
  const argv = Store.useState((state) => state.argv);
28352
- invariant(argv, "argv must exist");
28353
28338
  reactExports.useEffect(() => {
28354
28339
  if (argv.force) {
28355
28340
  Store.setState((state) => {
@@ -28367,7 +28352,6 @@ function PreLocalMergeRebase() {
28367
28352
  function PreSelectCommitRanges() {
28368
28353
  const actions = Store.useActions();
28369
28354
  const argv = Store.useState((state) => state.argv);
28370
- invariant(argv, "argv must exist");
28371
28355
  reactExports.useEffect(() => {
28372
28356
  if (argv.force) {
28373
28357
  Store.setState((state) => {
@@ -28660,7 +28644,6 @@ function SelectCommitRangesInternal(props) {
28660
28644
  switch (inputLower) {
28661
28645
  case "s":
28662
28646
  state.step = "manual-rebase";
28663
- // state.step = "manual-rebase-no-sync";
28664
28647
  break;
28665
28648
  }
28666
28649
  });
@@ -28767,7 +28750,7 @@ function SelectCommitRangesInternal(props) {
28767
28750
  enter: (reactExports.createElement(Text, { bold: true, color: colors.green }, SYMBOL.enter)),
28768
28751
  } }))));
28769
28752
  function submit_group_input(title) {
28770
- const id = short_id();
28753
+ const id = `gs-${short_id()}`;
28771
28754
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { dimColor: true }), message: "Created new group {group} {note}", values: {
28772
28755
  group: reactExports.createElement(Brackets, null, title),
28773
28756
  note: reactExports.createElement(Parens, null, id),
@@ -28785,12 +28768,12 @@ const SYMBOL = {
28785
28768
  };
28786
28769
 
28787
28770
  function Status() {
28788
- const argv = Store.useState((state) => state.argv);
28789
- invariant(argv, "argv must exist");
28790
- return reactExports.createElement(Await, { fallback: null, function: () => run({ argv }) });
28771
+ return reactExports.createElement(Await, { fallback: null, function: run });
28791
28772
  }
28792
- async function run(args) {
28793
- const actions = Store.getState().actions;
28773
+ async function run() {
28774
+ const state = Store.getState();
28775
+ const actions = state.actions;
28776
+ const argv = state.argv;
28794
28777
  const commit_range = Store.getState().commit_range;
28795
28778
  invariant(commit_range, "commit_range must exist");
28796
28779
  actions.output(reactExports.createElement(StatusTable, null));
@@ -28811,7 +28794,7 @@ async function run(args) {
28811
28794
  needs_rebase = true;
28812
28795
  }
28813
28796
  }
28814
- if (args.argv.check) {
28797
+ if (argv.check) {
28815
28798
  actions.exit(0);
28816
28799
  }
28817
28800
  else if (needs_rebase) {
@@ -28824,7 +28807,7 @@ async function run(args) {
28824
28807
  state.step = "pre-select-commit-ranges";
28825
28808
  });
28826
28809
  }
28827
- else if (args.argv.force) {
28810
+ else if (argv.force) {
28828
28811
  Store.setState((state) => {
28829
28812
  state.step = "select-commit-ranges";
28830
28813
  });
@@ -28842,10 +28825,10 @@ async function run(args) {
28842
28825
  function Main() {
28843
28826
  const step = Store.useState((state) => state.step);
28844
28827
  switch (step) {
28845
- case "github-api-error":
28846
- return reactExports.createElement(GithubApiError, null);
28847
28828
  case "loading":
28848
28829
  return null;
28830
+ case "github-api-error":
28831
+ return reactExports.createElement(GithubApiError, null);
28849
28832
  case "status":
28850
28833
  return reactExports.createElement(Status, null);
28851
28834
  case "local-merge-rebase":
@@ -28858,8 +28841,6 @@ function Main() {
28858
28841
  return reactExports.createElement(SelectCommitRanges, null);
28859
28842
  case "manual-rebase":
28860
28843
  return reactExports.createElement(ManualRebase, null);
28861
- case "manual-rebase-no-sync":
28862
- return reactExports.createElement(ManualRebase, { skipSync: true });
28863
28844
  case "post-rebase-status":
28864
28845
  return reactExports.createElement(PostRebaseStatus, null);
28865
28846
  default:
@@ -28894,8 +28875,6 @@ function reducer(state, patch) {
28894
28875
  }
28895
28876
  function RebaseCheck(props) {
28896
28877
  const actions = Store.useActions();
28897
- const argv = Store.useState((state) => state.argv);
28898
- invariant(argv, "argv must exist");
28899
28878
  const [state, patch] = reactExports.useReducer(reducer, {
28900
28879
  status: "init",
28901
28880
  });
@@ -28914,8 +28893,6 @@ function RebaseCheck(props) {
28914
28893
  }
28915
28894
  async function rebase_check() {
28916
28895
  const actions = Store.getState().actions;
28917
- const argv = Store.getState().argv;
28918
- invariant(argv, "argv must exist");
28919
28896
  try {
28920
28897
  const repo_root = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
28921
28898
  let is_rebase = false;
@@ -34284,12 +34261,18 @@ async function command() {
34284
34261
  type: "boolean",
34285
34262
  alias: ["c"],
34286
34263
  default: false,
34287
- description: "Print status table without syncing",
34264
+ description: "Print status table and exit without syncing",
34265
+ })
34266
+ .option("sync", {
34267
+ type: "boolean",
34268
+ alias: ["s"],
34269
+ default: true,
34270
+ description: "Sync commit ranges to Github, disable with --no-sync",
34288
34271
  })
34289
34272
  .option("verify", {
34290
34273
  type: "boolean",
34291
34274
  default: true,
34292
- description: "Skip git hooks such as pre-commit and pre-push",
34275
+ description: "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
34293
34276
  })
34294
34277
  .option("rebase", {
34295
34278
  type: "string",
@@ -34336,7 +34319,7 @@ async function command() {
34336
34319
  .wrap(123)
34337
34320
  // disallow unknown options
34338
34321
  .strict()
34339
- .version("1.2.7" )
34322
+ .version("1.3.1" )
34340
34323
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34341
34324
  .help("help", "Show usage via `git stack help`").argv);
34342
34325
  }
@@ -34353,6 +34336,7 @@ command()
34353
34336
  state.argv = argv;
34354
34337
  state.cwd = process.cwd();
34355
34338
  });
34339
+ Store.getState().actions.debug(JSON.stringify(argv, null, 2));
34356
34340
  })
34357
34341
  // eslint-disable-next-line no-console
34358
34342
  .catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.2.7",
3
+ "version": "1.3.1",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@ for (const filepath of package_json.files) {
52
52
  process.env.GS_RELEASE_NPM = "true";
53
53
  console.info("Publishing to NPM requires a one-time password");
54
54
  const otp = await input("Enter OTP: ");
55
- await spawn(`npm publish --otp=${otp}`);
55
+ await spawn(["npm", "publish", `--otp=${otp}`]);
56
56
 
57
57
  process.chdir(PROJECT_DIR);
58
58
 
package/src/app/Debug.tsx CHANGED
@@ -7,7 +7,6 @@ import * as Ink from "ink-cjs";
7
7
 
8
8
  import { Store } from "~/app/Store";
9
9
  import { colors } from "~/core/colors";
10
- import { invariant } from "~/core/invariant";
11
10
  import * as json from "~/core/json";
12
11
 
13
12
  export function Debug() {
@@ -29,8 +28,6 @@ export function Debug() {
29
28
 
30
29
  React.useEffect(
31
30
  function syncStateJson() {
32
- invariant(state.cwd, "state.cwd must exist");
33
-
34
31
  if (!argv?.["write-state-json"]) {
35
32
  return;
36
33
  }
@@ -8,7 +8,6 @@ import { FormatText } from "~/app/FormatText";
8
8
  import { Store } from "~/app/Store";
9
9
  import { cli } from "~/core/cli";
10
10
  import { colors } from "~/core/colors";
11
- import { invariant } from "~/core/invariant";
12
11
  import { match_group } from "~/core/match_group";
13
12
 
14
13
  type Props = {
@@ -16,9 +15,6 @@ type Props = {
16
15
  };
17
16
 
18
17
  export function GatherMetadata(props: Props) {
19
- const argv = Store.useState((state) => state.argv);
20
- invariant(argv, "argv must exist");
21
-
22
18
  const fallback = (
23
19
  <Ink.Text color={colors.yellow}>
24
20
  Gathering local git information...
@@ -36,8 +32,6 @@ async function gather_metadata() {
36
32
  const actions = Store.getState().actions;
37
33
  const argv = Store.getState().argv;
38
34
 
39
- invariant(argv, "argv must exist");
40
-
41
35
  try {
42
36
  // default to master branch, fallback to main
43
37
  let master_branch: string;
@@ -9,12 +9,8 @@ import { Store } from "~/app/Store";
9
9
  import { cli } from "~/core/cli";
10
10
  import { colors } from "~/core/colors";
11
11
  import * as date from "~/core/date";
12
- import { invariant } from "~/core/invariant";
13
12
 
14
13
  export function GithubApiError() {
15
- const argv = Store.useState((state) => state.argv);
16
- invariant(argv, "argv must exist");
17
-
18
14
  return <Await fallback={null} function={run} />;
19
15
  }
20
16
 
@@ -6,7 +6,6 @@ import { Await } from "~/app/Await";
6
6
  import { Store } from "~/app/Store";
7
7
  import * as CommitMetadata from "~/core/CommitMetadata";
8
8
  import { colors } from "~/core/colors";
9
- import { invariant } from "~/core/invariant";
10
9
  import * as json from "~/core/json";
11
10
 
12
11
  type Props = {
@@ -15,7 +14,6 @@ type Props = {
15
14
 
16
15
  export function LocalCommitStatus(props: Props) {
17
16
  const argv = Store.useState((state) => state.argv);
18
- invariant(argv, "argv must exist");
19
17
 
20
18
  const fallback = (
21
19
  <Ink.Text color={colors.yellow}>Fetching PR status from Github...</Ink.Text>
@@ -35,10 +35,8 @@ async function run() {
35
35
  const cwd = state.cwd;
36
36
  const repo_root = state.repo_root;
37
37
 
38
- invariant(argv, "argv must exist");
39
38
  invariant(branch_name, "branch_name must exist");
40
39
  invariant(commit_range, "commit_range must exist");
41
- invariant(cwd, "cwd must exist");
42
40
  invariant(repo_root, "repo_root must exist");
43
41
 
44
42
  // always listen for SIGINT event and restore git state
@@ -200,7 +198,6 @@ async function run() {
200
198
  }
201
199
 
202
200
  // restore back to original dir
203
- invariant(cwd, "cwd must exist");
204
201
  if (fs.existsSync(cwd)) {
205
202
  process.chdir(cwd);
206
203
  }
package/src/app/Main.tsx CHANGED
@@ -15,12 +15,12 @@ export function Main() {
15
15
  const step = Store.useState((state) => state.step);
16
16
 
17
17
  switch (step) {
18
- case "github-api-error":
19
- return <GithubApiError />;
20
-
21
18
  case "loading":
22
19
  return null;
23
20
 
21
+ case "github-api-error":
22
+ return <GithubApiError />;
23
+
24
24
  case "status":
25
25
  return <Status />;
26
26
 
@@ -39,9 +39,6 @@ export function Main() {
39
39
  case "manual-rebase":
40
40
  return <ManualRebase />;
41
41
 
42
- case "manual-rebase-no-sync":
43
- return <ManualRebase skipSync />;
44
-
45
42
  case "post-rebase-status":
46
43
  return <PostRebaseStatus />;
47
44
 
@@ -20,20 +20,16 @@ import * as github from "~/core/github";
20
20
  import { invariant } from "~/core/invariant";
21
21
  import { short_id } from "~/core/short_id";
22
22
 
23
- type Props = {
24
- skipSync?: boolean;
25
- };
26
-
27
- export function ManualRebase(props: Props) {
23
+ export function ManualRebase() {
28
24
  return (
29
25
  <Await
30
26
  fallback={<Ink.Text color={colors.yellow}>Rebasing commits...</Ink.Text>}
31
- function={() => run(props)}
27
+ function={run}
32
28
  />
33
29
  );
34
30
  }
35
31
 
36
- async function run(props: Props) {
32
+ async function run() {
37
33
  const state = Store.getState();
38
34
  const actions = state.actions;
39
35
  const argv = state.argv;
@@ -43,10 +39,8 @@ async function run(props: Props) {
43
39
  const cwd = state.cwd;
44
40
  const repo_root = state.repo_root;
45
41
 
46
- invariant(argv, "argv must exist");
47
42
  invariant(branch_name, "branch_name must exist");
48
43
  invariant(commit_map, "commit_map must exist");
49
- invariant(cwd, "cwd must exist");
50
44
  invariant(repo_root, "repo_root must exist");
51
45
 
52
46
  // always listen for SIGINT event and restore git state
@@ -120,8 +114,6 @@ async function run(props: Props) {
120
114
  }
121
115
 
122
116
  async function rebase_git_revise() {
123
- invariant(argv, "argv must exist");
124
-
125
117
  actions.debug(`rebase_git_revise`);
126
118
 
127
119
  actions.output(
@@ -212,8 +204,6 @@ async function run(props: Props) {
212
204
  }
213
205
 
214
206
  async function rebase_cherry_pick() {
215
- invariant(argv, "argv must exist");
216
-
217
207
  actions.debug("rebase_cherry_pick");
218
208
 
219
209
  // create temporary branch based on merge base
@@ -273,13 +263,12 @@ async function run(props: Props) {
273
263
  pr_url_list: Array<string>;
274
264
  skip_checkout: boolean;
275
265
  }) {
276
- if (props.skipSync) {
266
+ if (!argv.sync) {
277
267
  return;
278
268
  }
279
269
 
280
270
  const { group, pr_url_list } = args;
281
271
 
282
- invariant(argv, "argv must exist");
283
272
  invariant(group.base, "group.base must exist");
284
273
 
285
274
  actions.output(
@@ -353,6 +342,10 @@ async function run(props: Props) {
353
342
  }
354
343
 
355
344
  async function update_pr_tables(pr_url_list: Array<string>) {
345
+ if (!argv.sync) {
346
+ return;
347
+ }
348
+
356
349
  for (let i = 0; i < commit_range.group_list.length; i++) {
357
350
  const group = commit_range.group_list[i];
358
351
 
@@ -412,7 +405,6 @@ async function run(props: Props) {
412
405
  }
413
406
 
414
407
  // restore back to original dir
415
- invariant(cwd, "cwd must exist");
416
408
  if (fs.existsSync(cwd)) {
417
409
  process.chdir(cwd);
418
410
  }
@@ -6,12 +6,8 @@ import { Await } from "~/app/Await";
6
6
  import { StatusTable } from "~/app/StatusTable";
7
7
  import { Store } from "~/app/Store";
8
8
  import * as CommitMetadata from "~/core/CommitMetadata";
9
- import { invariant } from "~/core/invariant";
10
9
 
11
10
  export function PostRebaseStatus() {
12
- const argv = Store.useState((state) => state.argv);
13
- invariant(argv, "argv must exist");
14
-
15
11
  return <Await fallback={null} function={run} />;
16
12
  }
17
13
 
@@ -2,12 +2,10 @@ import * as React from "react";
2
2
 
3
3
  import { Store } from "~/app/Store";
4
4
  import { YesNoPrompt } from "~/app/YesNoPrompt";
5
- import { invariant } from "~/core/invariant";
6
5
 
7
6
  export function PreLocalMergeRebase() {
8
7
  const actions = Store.useActions();
9
8
  const argv = Store.useState((state) => state.argv);
10
- invariant(argv, "argv must exist");
11
9
 
12
10
  React.useEffect(() => {
13
11
  if (argv.force) {
@@ -2,12 +2,10 @@ import * as React from "react";
2
2
 
3
3
  import { Store } from "~/app/Store";
4
4
  import { YesNoPrompt } from "~/app/YesNoPrompt";
5
- import { invariant } from "~/core/invariant";
6
5
 
7
6
  export function PreSelectCommitRanges() {
8
7
  const actions = Store.useActions();
9
8
  const argv = Store.useState((state) => state.argv);
10
- invariant(argv, "argv must exist");
11
9
 
12
10
  React.useEffect(() => {
13
11
  if (argv.force) {
@@ -10,7 +10,6 @@ import { Store } from "~/app/Store";
10
10
  import { YesNoPrompt } from "~/app/YesNoPrompt";
11
11
  import { cli } from "~/core/cli";
12
12
  import { colors } from "~/core/colors";
13
- import { invariant } from "~/core/invariant";
14
13
 
15
14
  type Props = {
16
15
  children: React.ReactNode;
@@ -26,8 +25,6 @@ function reducer(state: State, patch: Partial<State>) {
26
25
 
27
26
  export function RebaseCheck(props: Props) {
28
27
  const actions = Store.useActions();
29
- const argv = Store.useState((state) => state.argv);
30
- invariant(argv, "argv must exist");
31
28
 
32
29
  const [state, patch] = React.useReducer(reducer, {
33
30
  status: "init",
@@ -68,9 +65,6 @@ export function RebaseCheck(props: Props) {
68
65
 
69
66
  async function rebase_check() {
70
67
  const actions = Store.getState().actions;
71
- const argv = Store.getState().argv;
72
-
73
- invariant(argv, "argv must exist");
74
68
 
75
69
  try {
76
70
  const repo_root = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
@@ -130,7 +130,6 @@ function SelectCommitRangesInternal(props: Props) {
130
130
  switch (inputLower) {
131
131
  case "s":
132
132
  state.step = "manual-rebase";
133
- // state.step = "manual-rebase-no-sync";
134
133
  break;
135
134
  }
136
135
  });
@@ -346,7 +345,7 @@ function SelectCommitRangesInternal(props: Props) {
346
345
  );
347
346
 
348
347
  function submit_group_input(title: string) {
349
- const id = short_id();
348
+ const id = `gs-${short_id()}`;
350
349
 
351
350
  actions.output(
352
351
  <FormatText
@@ -8,21 +8,15 @@ import { Store } from "~/app/Store";
8
8
  import { colors } from "~/core/colors";
9
9
  import { invariant } from "~/core/invariant";
10
10
 
11
- import type { Argv } from "~/command";
12
-
13
11
  export function Status() {
14
- const argv = Store.useState((state) => state.argv);
15
- invariant(argv, "argv must exist");
16
-
17
- return <Await fallback={null} function={() => run({ argv })} />;
12
+ return <Await fallback={null} function={run} />;
18
13
  }
19
14
 
20
- type Args = {
21
- argv: Argv;
22
- };
15
+ async function run() {
16
+ const state = Store.getState();
17
+ const actions = state.actions;
18
+ const argv = state.argv;
23
19
 
24
- async function run(args: Args) {
25
- const actions = Store.getState().actions;
26
20
  const commit_range = Store.getState().commit_range;
27
21
 
28
22
  invariant(commit_range, "commit_range must exist");
@@ -51,7 +45,7 @@ async function run(args: Args) {
51
45
  }
52
46
  }
53
47
 
54
- if (args.argv.check) {
48
+ if (argv.check) {
55
49
  actions.exit(0);
56
50
  } else if (needs_rebase) {
57
51
  Store.setState((state) => {
@@ -61,7 +55,7 @@ async function run(args: Args) {
61
55
  Store.setState((state) => {
62
56
  state.step = "pre-select-commit-ranges";
63
57
  });
64
- } else if (args.argv.force) {
58
+ } else if (argv.force) {
65
59
  Store.setState((state) => {
66
60
  state.step = "select-commit-ranges";
67
61
  });
package/src/app/Store.tsx CHANGED
@@ -25,10 +25,11 @@ type MutateOutputArgs = {
25
25
  };
26
26
 
27
27
  export type State = {
28
- argv: null | Argv;
29
- ink: null | InkInstance;
28
+ // set immediately in `index.tsx` so no `null` scenario
29
+ argv: Argv;
30
+ ink: InkInstance;
31
+ cwd: string;
30
32
 
31
- cwd: null | string;
32
33
  username: null | string;
33
34
  repo_path: null | string;
34
35
  repo_root: null | string;
@@ -47,7 +48,6 @@ export type State = {
47
48
  | "pre-select-commit-ranges"
48
49
  | "select-commit-ranges"
49
50
  | "manual-rebase"
50
- | "manual-rebase-no-sync"
51
51
  | "post-rebase-status";
52
52
 
53
53
  output: Array<React.ReactNode>;
@@ -85,10 +85,11 @@ export type State = {
85
85
 
86
86
  const BaseStore = createStore<State>()(
87
87
  immer((set, get) => ({
88
- argv: null,
89
- ink: null,
88
+ // set immediately in `index.tsx` so no `null` scenario
89
+ argv: {} as Argv,
90
+ ink: {} as InkInstance,
91
+ cwd: "",
90
92
 
91
- cwd: null,
92
93
  username: null,
93
94
  repo_path: null,
94
95
  repo_root: null,
package/src/command.ts CHANGED
@@ -22,13 +22,21 @@ export async function command() {
22
22
  type: "boolean",
23
23
  alias: ["c"],
24
24
  default: false,
25
- description: "Print status table without syncing",
25
+ description: "Print status table and exit without syncing",
26
+ })
27
+
28
+ .option("sync", {
29
+ type: "boolean",
30
+ alias: ["s"],
31
+ default: true,
32
+ description: "Sync commit ranges to Github, disable with --no-sync",
26
33
  })
27
34
 
28
35
  .option("verify", {
29
36
  type: "boolean",
30
37
  default: true,
31
- description: "Skip git hooks such as pre-commit and pre-push",
38
+ description:
39
+ "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
32
40
  })
33
41
 
34
42
  .option("rebase", {
package/src/index.tsx CHANGED
@@ -17,6 +17,8 @@ command()
17
17
  state.argv = argv;
18
18
  state.cwd = process.cwd();
19
19
  });
20
+
21
+ Store.getState().actions.debug(JSON.stringify(argv, null, 2));
20
22
  })
21
23
  // eslint-disable-next-line no-console
22
24
  .catch(console.error);