git-stack-cli 0.3.0 → 0.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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # git-stack-cli
2
2
 
3
+ > create stacked diffs (PRs) on Github from a single branch by grouping commits
4
+
3
5
  ## install
4
6
 
5
7
  ```bash
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+ import { Debug } from "./Debug.js";
3
+ import { DependencyCheck } from "./DependencyCheck.js";
4
+ import { GatherMetadata } from "./GatherMetadata.js";
5
+ import { GithubApiError } from "./GithubApiError.js";
6
+ import { Main } from "./Main.js";
7
+ import { Output } from "./Output.js";
8
+ import { Store } from "./Store.js";
9
+ export function App() {
10
+ const ink = Store.useState((state) => state.ink);
11
+ const argv = Store.useState((state) => state.argv);
12
+ if (!ink || !argv) {
13
+ return null;
14
+ }
15
+ // // debug component
16
+ // return (
17
+ // <React.Fragment>
18
+ // <Debug />
19
+ // <Output />
20
+ // <GithubApiError />
21
+ // </React.Fragment>
22
+ // );
23
+ return (React.createElement(Providers, null,
24
+ React.createElement(Debug, null),
25
+ React.createElement(Output, null),
26
+ !argv.debug ? null : React.createElement(GithubApiError, null),
27
+ React.createElement(DependencyCheck, null,
28
+ React.createElement(GatherMetadata, null,
29
+ React.createElement(Main, null)))));
30
+ }
package/dist/app/App.js CHANGED
@@ -5,6 +5,7 @@ import { GatherMetadata } from "./GatherMetadata.js";
5
5
  import { GithubApiError } from "./GithubApiError.js";
6
6
  import { Main } from "./Main.js";
7
7
  import { Output } from "./Output.js";
8
+ import { Providers } from "./Providers.js";
8
9
  import { Store } from "./Store.js";
9
10
  export function App() {
10
11
  const ink = Store.useState((state) => state.ink);
@@ -20,7 +21,7 @@ export function App() {
20
21
  // <GithubApiError />
21
22
  // </React.Fragment>
22
23
  // );
23
- return (React.createElement(React.Fragment, null,
24
+ return (React.createElement(Providers, null,
24
25
  React.createElement(Debug, null),
25
26
  React.createElement(Output, null),
26
27
  !argv.debug ? null : React.createElement(GithubApiError, null),
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { FormattedMessage } from "react-intl";
3
+ export function FormatText(props) {
4
+ return (React.createElement(FormattedMessage, { id: "FormatText", defaultMessage: props.message, values: props.values }, (chunks) => {
5
+ return React.cloneElement(props.wrapper, {}, chunks);
6
+ }));
7
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { IntlProvider } from "react-intl";
3
+ export function Providers(props) {
4
+ return React.createElement(IntlProvider, { locale: "en" }, props.children);
5
+ }
@@ -3,6 +3,7 @@ import * as Ink from "ink";
3
3
  import { v4 as uuid_v4 } from "uuid";
4
4
  import { invariant } from "../core/invariant.js";
5
5
  import { wrap_index } from "../core/wrap_index.js";
6
+ import { FormatText } from "./FormatText.js";
6
7
  import { MultiSelect } from "./MultiSelect.js";
7
8
  import { Parens } from "./Parens.js";
8
9
  import { Store } from "./Store.js";
@@ -47,10 +48,10 @@ function SelectCommitRangesInternal(props) {
47
48
  }
48
49
  group_list.push(...new_group_list);
49
50
  for (const group of props.commit_range.group_list) {
50
- if (group.pr) {
51
+ if (group.id !== props.commit_range.UNASSIGNED) {
51
52
  group_list.push({
52
53
  id: group.id,
53
- title: group.pr.title,
54
+ title: group.pr?.title || group.id,
54
55
  });
55
56
  }
56
57
  }
@@ -59,7 +60,8 @@ function SelectCommitRangesInternal(props) {
59
60
  const current_index = group_list.findIndex((g) => g.id === selected_group_id);
60
61
  Ink.useInput((input, key) => {
61
62
  const inputLower = input.toLowerCase();
62
- if (unassigned_count === 0 && (inputLower === "r" || inputLower === "s")) {
63
+ const hasUnassignedCommits = unassigned_count > 0;
64
+ if (!hasUnassignedCommits && (inputLower === "r" || inputLower === "s")) {
63
65
  actions.set((state) => {
64
66
  state.commit_map = {};
65
67
  for (const [sha, id] of commit_map.entries()) {
@@ -78,7 +80,7 @@ function SelectCommitRangesInternal(props) {
78
80
  return;
79
81
  }
80
82
  // only allow create when on unassigned group
81
- if (isUnassigned && inputLower === "c") {
83
+ if (hasUnassignedCommits && inputLower === "c") {
82
84
  const id = uuid_v4();
83
85
  actions.output(React.createElement(Ink.Box, null,
84
86
  React.createElement(Ink.Text, { dimColor: true }, "Created new group "),
@@ -127,10 +129,10 @@ function SelectCommitRangesInternal(props) {
127
129
  };
128
130
  });
129
131
  items.reverse();
130
- // console.debug({ group, isUnassigned });
132
+ // console.debug({ current_index, group, isUnassigned });
131
133
  return (React.createElement(Ink.Box, { flexDirection: "column" },
132
134
  React.createElement(Ink.Box, { height: 1 }),
133
- React.createElement(MultiSelect, { key: current_index, items: items, onSelect: (args) => {
135
+ React.createElement(MultiSelect, { key: group.id, items: items, onSelect: (args) => {
134
136
  // console.debug("onSelect", args);
135
137
  const key = args.item.sha;
136
138
  let value;
@@ -150,17 +152,13 @@ function SelectCommitRangesInternal(props) {
150
152
  React.createElement(Ink.Text, { wrap: "truncate-end" }, title)),
151
153
  React.createElement(Ink.Text, null, right_arrow)),
152
154
  React.createElement(Ink.Box, { height: 1 }),
153
- unassigned_count > 0 ? (React.createElement(Ink.Text, { color: "gray" },
154
- React.createElement(Ink.Text, { color: "#3b82f6", bold: true }, unassigned_count),
155
- React.createElement(Ink.Text, null, " unassigned commits"),
156
- !isUnassigned ? null : (React.createElement(Ink.Text, { color: "gray" },
157
- React.createElement(Ink.Text, null, ", press "),
158
- React.createElement(Ink.Text, { bold: true, color: "#22c55e" }, "c"),
159
- " to ",
160
- React.createElement(Ink.Text, { bold: true, color: "#22c55e" },
155
+ unassigned_count > 0 ? (React.createElement(FormatText, { wrapper: React.createElement(Ink.Text, { color: "gray" }), message: "{count} unassigned commits, press {c} to {create} a new group", values: {
156
+ count: (React.createElement(Ink.Text, { color: "#3b82f6", bold: true }, unassigned_count)),
157
+ c: (React.createElement(Ink.Text, { bold: true, color: "#22c55e" }, "c")),
158
+ create: (React.createElement(Ink.Text, { bold: true, color: "#22c55e" },
161
159
  React.createElement(Parens, null, "c"),
162
- "reate"),
163
- " a new group")))) : (React.createElement(React.Fragment, null,
160
+ "reate")),
161
+ } })) : (React.createElement(React.Fragment, null,
164
162
  React.createElement(Ink.Text, null,
165
163
  "🎉 Done! Press ",
166
164
  React.createElement(Ink.Text, { bold: true, color: "#22c55e" }, "s"),
@@ -14,6 +14,7 @@ export function StatusTable() {
14
14
  status: "",
15
15
  title: "",
16
16
  url: "",
17
+ id: group.id,
17
18
  };
18
19
  if (group.id === commit_range.UNASSIGNED) {
19
20
  row.icon = "⭑";
@@ -32,6 +33,10 @@ export function StatusTable() {
32
33
  row.status = "SYNCED";
33
34
  }
34
35
  if (group.pr) {
36
+ if (group.pr.state === "MERGED") {
37
+ row.icon = "↗";
38
+ row.status = "MERGED";
39
+ }
35
40
  row.title = group.pr.title;
36
41
  row.count = `${group.pr.commits.length}/${group.commits.length}`;
37
42
  row.url = group.pr.url;
@@ -81,7 +86,7 @@ export function StatusTable() {
81
86
  return (React.createElement(Ink.Box, { flexDirection: "column", width: available_width },
82
87
  React.createElement(Ink.Box, { height: 1 }),
83
88
  row_list.map((row) => {
84
- return (React.createElement(Ink.Box, { key: row.url,
89
+ return (React.createElement(Ink.Box, { key: row.id,
85
90
  // borderStyle="round"
86
91
  flexDirection: "row", columnGap: columnGap, width: available_width },
87
92
  React.createElement(Ink.Box, { width: max_col_width.icon },
@@ -13,13 +13,27 @@ export function YesNoPrompt(props) {
13
13
  return props.onYes();
14
14
  }
15
15
  });
16
+ // prettier-ignore
17
+ const y = React.createElement(Ink.Text, { bold: true, color: "#22c55e" }, "Y");
18
+ const n = React.createElement(Ink.Text, { color: "#ef4444" }, "n");
19
+ let choices;
20
+ switch (answer) {
21
+ case "y":
22
+ choices = y;
23
+ break;
24
+ case "n":
25
+ choices = n;
26
+ break;
27
+ default:
28
+ choices = (React.createElement(React.Fragment, null,
29
+ y,
30
+ React.createElement(Ink.Text, null, "/"),
31
+ n));
32
+ }
16
33
  return (React.createElement(Ink.Box, { flexDirection: "column" },
17
34
  React.createElement(Ink.Box, null,
18
35
  React.createElement(Ink.Text, { color: "yellow" }, props.message),
19
36
  React.createElement(Ink.Text, null, " "),
20
37
  React.createElement(Parens, null,
21
- React.createElement(Ink.Text, { color: "gray" },
22
- answer && answer !== "y" ? null : (React.createElement(Ink.Text, { bold: true, color: "#22c55e" }, "Y")),
23
- answer ? null : React.createElement(Ink.Text, null, "/"),
24
- answer && answer !== "n" ? null : (React.createElement(Ink.Text, { color: "#ef4444" }, "n")))))));
38
+ React.createElement(Ink.Text, { color: "gray" }, choices)))));
25
39
  }
@@ -51,7 +51,7 @@ export async function range(commit_map) {
51
51
  const group = group_value_list[i];
52
52
  if (group.id !== UNASSIGNED) {
53
53
  const pr_result = await github.pr_status(group.id);
54
- if (pr_result && pr_result.state === "OPEN") {
54
+ if (pr_result && pr_result.state !== "CLOSED") {
55
55
  group.pr = pr_result;
56
56
  }
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -29,6 +29,7 @@
29
29
  "immer": "^10.0.3",
30
30
  "ink": "^4.4.1",
31
31
  "react": "^18.2.0",
32
+ "react-intl": "^6.5.5",
32
33
  "uuid": "^9.0.1",
33
34
  "yargs": "^17.7.2",
34
35
  "zustand": "^4.4.4"