git-stack-cli 1.2.7 → 1.3.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.
@@ -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)),
@@ -28131,7 +28117,6 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28131
28117
  }
28132
28118
  }
28133
28119
  // restore back to original dir
28134
- invariant(cwd, "cwd must exist");
28135
28120
  if (fs.existsSync(cwd)) {
28136
28121
  process.chdir(cwd);
28137
28122
  }
@@ -28330,8 +28315,6 @@ function get_status_bold(row) {
28330
28315
  }
28331
28316
 
28332
28317
  function PostRebaseStatus() {
28333
- const argv = Store.useState((state) => state.argv);
28334
- invariant(argv, "argv must exist");
28335
28318
  return reactExports.createElement(Await, { fallback: null, function: run$1 });
28336
28319
  }
28337
28320
  async function run$1() {
@@ -28349,7 +28332,6 @@ async function run$1() {
28349
28332
  function PreLocalMergeRebase() {
28350
28333
  const actions = Store.useActions();
28351
28334
  const argv = Store.useState((state) => state.argv);
28352
- invariant(argv, "argv must exist");
28353
28335
  reactExports.useEffect(() => {
28354
28336
  if (argv.force) {
28355
28337
  Store.setState((state) => {
@@ -28367,7 +28349,6 @@ function PreLocalMergeRebase() {
28367
28349
  function PreSelectCommitRanges() {
28368
28350
  const actions = Store.useActions();
28369
28351
  const argv = Store.useState((state) => state.argv);
28370
- invariant(argv, "argv must exist");
28371
28352
  reactExports.useEffect(() => {
28372
28353
  if (argv.force) {
28373
28354
  Store.setState((state) => {
@@ -28660,7 +28641,6 @@ function SelectCommitRangesInternal(props) {
28660
28641
  switch (inputLower) {
28661
28642
  case "s":
28662
28643
  state.step = "manual-rebase";
28663
- // state.step = "manual-rebase-no-sync";
28664
28644
  break;
28665
28645
  }
28666
28646
  });
@@ -28767,7 +28747,7 @@ function SelectCommitRangesInternal(props) {
28767
28747
  enter: (reactExports.createElement(Text, { bold: true, color: colors.green }, SYMBOL.enter)),
28768
28748
  } }))));
28769
28749
  function submit_group_input(title) {
28770
- const id = short_id();
28750
+ const id = `gs-${short_id()}`;
28771
28751
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { dimColor: true }), message: "Created new group {group} {note}", values: {
28772
28752
  group: reactExports.createElement(Brackets, null, title),
28773
28753
  note: reactExports.createElement(Parens, null, id),
@@ -28785,12 +28765,12 @@ const SYMBOL = {
28785
28765
  };
28786
28766
 
28787
28767
  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 }) });
28768
+ return reactExports.createElement(Await, { fallback: null, function: run });
28791
28769
  }
28792
- async function run(args) {
28793
- const actions = Store.getState().actions;
28770
+ async function run() {
28771
+ const state = Store.getState();
28772
+ const actions = state.actions;
28773
+ const argv = state.argv;
28794
28774
  const commit_range = Store.getState().commit_range;
28795
28775
  invariant(commit_range, "commit_range must exist");
28796
28776
  actions.output(reactExports.createElement(StatusTable, null));
@@ -28811,7 +28791,7 @@ async function run(args) {
28811
28791
  needs_rebase = true;
28812
28792
  }
28813
28793
  }
28814
- if (args.argv.check) {
28794
+ if (argv.check) {
28815
28795
  actions.exit(0);
28816
28796
  }
28817
28797
  else if (needs_rebase) {
@@ -28824,7 +28804,7 @@ async function run(args) {
28824
28804
  state.step = "pre-select-commit-ranges";
28825
28805
  });
28826
28806
  }
28827
- else if (args.argv.force) {
28807
+ else if (argv.force) {
28828
28808
  Store.setState((state) => {
28829
28809
  state.step = "select-commit-ranges";
28830
28810
  });
@@ -28842,10 +28822,10 @@ async function run(args) {
28842
28822
  function Main() {
28843
28823
  const step = Store.useState((state) => state.step);
28844
28824
  switch (step) {
28845
- case "github-api-error":
28846
- return reactExports.createElement(GithubApiError, null);
28847
28825
  case "loading":
28848
28826
  return null;
28827
+ case "github-api-error":
28828
+ return reactExports.createElement(GithubApiError, null);
28849
28829
  case "status":
28850
28830
  return reactExports.createElement(Status, null);
28851
28831
  case "local-merge-rebase":
@@ -28858,8 +28838,6 @@ function Main() {
28858
28838
  return reactExports.createElement(SelectCommitRanges, null);
28859
28839
  case "manual-rebase":
28860
28840
  return reactExports.createElement(ManualRebase, null);
28861
- case "manual-rebase-no-sync":
28862
- return reactExports.createElement(ManualRebase, { skipSync: true });
28863
28841
  case "post-rebase-status":
28864
28842
  return reactExports.createElement(PostRebaseStatus, null);
28865
28843
  default:
@@ -28894,8 +28872,6 @@ function reducer(state, patch) {
28894
28872
  }
28895
28873
  function RebaseCheck(props) {
28896
28874
  const actions = Store.useActions();
28897
- const argv = Store.useState((state) => state.argv);
28898
- invariant(argv, "argv must exist");
28899
28875
  const [state, patch] = reactExports.useReducer(reducer, {
28900
28876
  status: "init",
28901
28877
  });
@@ -28914,8 +28890,6 @@ function RebaseCheck(props) {
28914
28890
  }
28915
28891
  async function rebase_check() {
28916
28892
  const actions = Store.getState().actions;
28917
- const argv = Store.getState().argv;
28918
- invariant(argv, "argv must exist");
28919
28893
  try {
28920
28894
  const repo_root = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
28921
28895
  let is_rebase = false;
@@ -34284,12 +34258,18 @@ async function command() {
34284
34258
  type: "boolean",
34285
34259
  alias: ["c"],
34286
34260
  default: false,
34287
- description: "Print status table without syncing",
34261
+ description: "Print status table and exit without syncing",
34262
+ })
34263
+ .option("sync", {
34264
+ type: "boolean",
34265
+ alias: ["s"],
34266
+ default: true,
34267
+ description: "Sync commit ranges to Github, disable with --no-sync",
34288
34268
  })
34289
34269
  .option("verify", {
34290
34270
  type: "boolean",
34291
34271
  default: true,
34292
- description: "Skip git hooks such as pre-commit and pre-push",
34272
+ description: "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
34293
34273
  })
34294
34274
  .option("rebase", {
34295
34275
  type: "string",
@@ -34336,7 +34316,7 @@ async function command() {
34336
34316
  .wrap(123)
34337
34317
  // disallow unknown options
34338
34318
  .strict()
34339
- .version("1.2.7" )
34319
+ .version("1.3.0" )
34340
34320
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34341
34321
  .help("help", "Show usage via `git stack help`").argv);
34342
34322
  }
@@ -34353,6 +34333,7 @@ command()
34353
34333
  state.argv = argv;
34354
34334
  state.cwd = process.cwd();
34355
34335
  });
34336
+ Store.getState().actions.debug(JSON.stringify(argv, null, 2));
34356
34337
  })
34357
34338
  // eslint-disable-next-line no-console
34358
34339
  .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.0",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
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(
@@ -412,7 +401,6 @@ async function run(props: Props) {
412
401
  }
413
402
 
414
403
  // restore back to original dir
415
- invariant(cwd, "cwd must exist");
416
404
  if (fs.existsSync(cwd)) {
417
405
  process.chdir(cwd);
418
406
  }
@@ -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);