git-stack-cli 0.8.7 → 1.0.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 +32 -3
- package/dist/cjs/index.cjs +34770 -0
- package/package.json +21 -7
- package/dist/__fixtures__/metadata.js +0 -666
- package/dist/__fixtures__/metadata.json +0 -186
- package/dist/app/App copy.js +0 -30
- package/dist/app/App.js +0 -42
- package/dist/app/ArgCheck.js +0 -21
- package/dist/app/AutoUpdate.js +0 -128
- package/dist/app/Await.js +0 -45
- package/dist/app/Brackets copy.js +0 -10
- package/dist/app/Brackets.js +0 -11
- package/dist/app/Command.js +0 -7
- package/dist/app/Counter.js +0 -19
- package/dist/app/Debug.js +0 -33
- package/dist/app/DependencyCheck.js +0 -89
- package/dist/app/Exit.js +0 -14
- package/dist/app/FormatText.js +0 -9
- package/dist/app/GatherMetadata copy.js +0 -91
- package/dist/app/GatherMetadata.js +0 -100
- package/dist/app/GithubApiError.js +0 -50
- package/dist/app/InitMetadata.js +0 -14
- package/dist/app/Input.js +0 -15
- package/dist/app/KeepAlive.js +0 -11
- package/dist/app/LocalCommitStatus.js +0 -43
- package/dist/app/LocalMergeRebase.js +0 -157
- package/dist/app/Main copy.js +0 -200
- package/dist/app/ManualRebase copy.js +0 -127
- package/dist/app/ManualRebase.js +0 -220
- package/dist/app/MultiSelect copy.js +0 -76
- package/dist/app/MultiSelect.js +0 -143
- package/dist/app/NPMAutoUpdate.js +0 -34
- package/dist/app/Output.js +0 -19
- package/dist/app/Parens copy.js +0 -9
- package/dist/app/Parens.js +0 -10
- package/dist/app/PostRebaseStatus copy.js +0 -23
- package/dist/app/PostRebaseStatus.js +0 -23
- package/dist/app/PreLocalMergeRebase.js +0 -21
- package/dist/app/PreSelectCommitRanges copy.js +0 -21
- package/dist/app/PreSelectCommitRanges.js +0 -21
- package/dist/app/Providers.js +0 -5
- package/dist/app/RebaseCheck.js +0 -56
- package/dist/app/SelectCommitRange.js +0 -1
- package/dist/app/SelectCommitRanges.js +0 -207
- package/dist/app/Status copy.js +0 -46
- package/dist/app/Status.js +0 -61
- package/dist/app/StatusTable.js +0 -115
- package/dist/app/Store.js +0 -136
- package/dist/app/Table.js +0 -65
- package/dist/app/TextInput.js +0 -51
- package/dist/app/Url copy.js +0 -6
- package/dist/app/Url.js +0 -6
- package/dist/app/Waterfall.js +0 -20
- package/dist/app/YesNoPrompt copy.js +0 -24
- package/dist/app/YesNoPrompt.js +0 -40
- package/dist/app/main.js +0 -39
- package/dist/cli.js +0 -9
- package/dist/command.js +0 -60
- package/dist/core/CommitMetadata.js +0 -159
- package/dist/core/Metadata copy.js +0 -37
- package/dist/core/Metadata.js +0 -36
- package/dist/core/Metadata.test.js +0 -34
- package/dist/core/StackSummaryTable.js +0 -86
- package/dist/core/StackSummaryTable.test.js +0 -134
- package/dist/core/StackTable.js +0 -38
- package/dist/core/SummaryTable.js +0 -38
- package/dist/core/ZustandStore.js +0 -23
- package/dist/core/assertNever.js +0 -4
- package/dist/core/cache.js +0 -39
- package/dist/core/capitalize.js +0 -5
- package/dist/core/chalk.js +0 -83
- package/dist/core/clamp.js +0 -6
- package/dist/core/cli copy.js +0 -44
- package/dist/core/cli.js +0 -86
- package/dist/core/color.js +0 -83
- package/dist/core/colors.js +0 -15
- package/dist/core/date.js +0 -18
- package/dist/core/dependency_check.js +0 -27
- package/dist/core/env.js +0 -4
- package/dist/core/exit.js +0 -4
- package/dist/core/fetch_json.js +0 -24
- package/dist/core/get_commit_metadata.js +0 -61
- package/dist/core/github.js +0 -118
- package/dist/core/id.js +0 -61
- package/dist/core/invariant copy.js +0 -5
- package/dist/core/invariant.js +0 -5
- package/dist/core/isFiniteValue.js +0 -3
- package/dist/core/is_command_available.js +0 -15
- package/dist/core/is_dev.js +0 -1
- package/dist/core/is_finite_value.js +0 -3
- package/dist/core/json.js +0 -35
- package/dist/core/match_group.js +0 -9
- package/dist/core/readJson.js +0 -3
- package/dist/core/read_json.js +0 -12
- package/dist/core/safe_quote.js +0 -9
- package/dist/core/semver_compare.js +0 -26
- package/dist/core/serialize_json.js +0 -17
- package/dist/core/short_id.js +0 -60
- package/dist/core/sleep copy.js +0 -3
- package/dist/core/sleep.js +0 -3
- package/dist/core/wrap_index.js +0 -10
- package/dist/index.js +0 -13
- package/dist/main copy.js +0 -266
- package/dist/main.backup.js +0 -266
- package/dist/main.js +0 -265
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"head": "cc09b96b823d9dde77188e675d3090be7c1d625a",
|
|
3
|
-
"merge_base": "9528176b12abf81c779bc5244afc7d760f6fa422",
|
|
4
|
-
"branch_name": "dev/noah/a-test",
|
|
5
|
-
"commit_range": {
|
|
6
|
-
"invalid": true,
|
|
7
|
-
"group_map": {},
|
|
8
|
-
"commit_list": [
|
|
9
|
-
{
|
|
10
|
-
"sha": "a28f1ef080b56b56699bc420b200968e793702a9",
|
|
11
|
-
"message": "more remove",
|
|
12
|
-
"raw_message": "more remove\n\ngit-multi-diff-id: 14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
|
|
13
|
-
"pr": {
|
|
14
|
-
"baseRefName": "master",
|
|
15
|
-
"commits": [
|
|
16
|
-
{
|
|
17
|
-
"authoredDate": "2023-10-22T23:13:20Z",
|
|
18
|
-
"authors": [
|
|
19
|
-
{
|
|
20
|
-
"email": "noah@iamnoah.com",
|
|
21
|
-
"id": "MDQ6VXNlcjI5MDA4NA==",
|
|
22
|
-
"login": "magus",
|
|
23
|
-
"name": "magus"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"committedDate": "2023-10-28T19:16:29Z",
|
|
27
|
-
"messageBody": "git-multi-diff-id: 14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
|
|
28
|
-
"messageHeadline": "more remove",
|
|
29
|
-
"oid": "a28f1ef080b56b56699bc420b200968e793702a9"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"headRefName": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
|
|
33
|
-
"number": 28,
|
|
34
|
-
"state": "OPEN",
|
|
35
|
-
"title": "more remove",
|
|
36
|
-
"url": "https://github.com/magus/git-multi-diff-playground/pull/28"
|
|
37
|
-
},
|
|
38
|
-
"metadata": {
|
|
39
|
-
"id": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"sha": "7454ce81940f2a0964ff06c7a98c7fa1892f82bf",
|
|
44
|
-
"message": "remove num",
|
|
45
|
-
"raw_message": "remove num\n\ngit-multi-diff-id: 3d1d890d-11c9-4569-83c3-e3aff6426e37",
|
|
46
|
-
"pr": {
|
|
47
|
-
"baseRefName": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
|
|
48
|
-
"commits": [
|
|
49
|
-
{
|
|
50
|
-
"authoredDate": "2023-10-22T23:13:14Z",
|
|
51
|
-
"authors": [
|
|
52
|
-
{
|
|
53
|
-
"email": "noah@iamnoah.com",
|
|
54
|
-
"id": "MDQ6VXNlcjI5MDA4NA==",
|
|
55
|
-
"login": "magus",
|
|
56
|
-
"name": "magus"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
"committedDate": "2023-10-28T19:16:33Z",
|
|
60
|
-
"messageBody": "git-multi-diff-id: 3d1d890d-11c9-4569-83c3-e3aff6426e37",
|
|
61
|
-
"messageHeadline": "remove num",
|
|
62
|
-
"oid": "7454ce81940f2a0964ff06c7a98c7fa1892f82bf"
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
"headRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
|
|
66
|
-
"number": 27,
|
|
67
|
-
"state": "OPEN",
|
|
68
|
-
"title": "remove num",
|
|
69
|
-
"url": "https://github.com/magus/git-multi-diff-playground/pull/27"
|
|
70
|
-
},
|
|
71
|
-
"metadata": {
|
|
72
|
-
"id": "3d1d890d-11c9-4569-83c3-e3aff6426e37"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"sha": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0",
|
|
77
|
-
"message": "strawberry",
|
|
78
|
-
"raw_message": "strawberry\n\ngit-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
79
|
-
"pr": {
|
|
80
|
-
"baseRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
|
|
81
|
-
"commits": [
|
|
82
|
-
{
|
|
83
|
-
"authoredDate": "2023-10-25T09:29:30Z",
|
|
84
|
-
"authors": [
|
|
85
|
-
{
|
|
86
|
-
"email": "noah@iamnoah.com",
|
|
87
|
-
"id": "MDQ6VXNlcjI5MDA4NA==",
|
|
88
|
-
"login": "magus",
|
|
89
|
-
"name": "magus"
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"committedDate": "2023-10-28T19:16:37Z",
|
|
93
|
-
"messageBody": "git-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
94
|
-
"messageHeadline": "strawberry",
|
|
95
|
-
"oid": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0"
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"headRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
99
|
-
"number": 30,
|
|
100
|
-
"state": "OPEN",
|
|
101
|
-
"title": "strawberry",
|
|
102
|
-
"url": "https://github.com/magus/git-multi-diff-playground/pull/30"
|
|
103
|
-
},
|
|
104
|
-
"metadata": {
|
|
105
|
-
"id": "53d15f9a-2451-492c-a831-642d41ad3ef4"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"sha": "24fa3301563d40b42f698bff92b8a805412a4a69",
|
|
110
|
-
"message": "orange color",
|
|
111
|
-
"raw_message": "orange color",
|
|
112
|
-
"pr": null,
|
|
113
|
-
"metadata": {
|
|
114
|
-
"id": null
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"sha": "dea1b85bdbcec0b27f1c5b2cc675e47fd9f51005",
|
|
119
|
-
"message": "cantaloupe",
|
|
120
|
-
"raw_message": "cantaloupe\nline2 changed\nline3 'abc'\nline4\nline5 \"hello world\"\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\ngit-multi-diff-id: 398c0ead-77ad-41a4-af6e-280f99998c28",
|
|
121
|
-
"pr": {
|
|
122
|
-
"baseRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
123
|
-
"commits": [
|
|
124
|
-
{
|
|
125
|
-
"authoredDate": "2023-10-22T23:13:35Z",
|
|
126
|
-
"authors": [
|
|
127
|
-
{
|
|
128
|
-
"email": "noah@iamnoah.com",
|
|
129
|
-
"id": "MDQ6VXNlcjI5MDA4NA==",
|
|
130
|
-
"login": "magus",
|
|
131
|
-
"name": "magus"
|
|
132
|
-
}
|
|
133
|
-
],
|
|
134
|
-
"committedDate": "2023-10-28T19:16:40Z",
|
|
135
|
-
"messageBody": "line2 changed\nline3 'abc'\nline4\nline5 \"hello world\"\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\ngit-multi-diff-id: 398c0ead-77ad-41a4-af6e-280f99998c28",
|
|
136
|
-
"messageHeadline": "cantaloupe",
|
|
137
|
-
"oid": "86d0b3cf5dcbd94963f2839818734c3b0e13d2fc"
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
"headRefName": "398c0ead-77ad-41a4-af6e-280f99998c28",
|
|
141
|
-
"number": 29,
|
|
142
|
-
"state": "OPEN",
|
|
143
|
-
"title": "cantaloupe line2 line3 'abc' line4 line5 \"hello world\" Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
144
|
-
"url": "https://github.com/magus/git-multi-diff-playground/pull/29"
|
|
145
|
-
},
|
|
146
|
-
"metadata": {
|
|
147
|
-
"id": "398c0ead-77ad-41a4-af6e-280f99998c28"
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"sha": "cc09b96b823d9dde77188e675d3090be7c1d625a",
|
|
152
|
-
"message": "pineapple",
|
|
153
|
-
"raw_message": "pineapple\n\ngit-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
154
|
-
"pr": {
|
|
155
|
-
"baseRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
|
|
156
|
-
"commits": [
|
|
157
|
-
{
|
|
158
|
-
"authoredDate": "2023-10-25T09:29:30Z",
|
|
159
|
-
"authors": [
|
|
160
|
-
{
|
|
161
|
-
"email": "noah@iamnoah.com",
|
|
162
|
-
"id": "MDQ6VXNlcjI5MDA4NA==",
|
|
163
|
-
"login": "magus",
|
|
164
|
-
"name": "magus"
|
|
165
|
-
}
|
|
166
|
-
],
|
|
167
|
-
"committedDate": "2023-10-28T19:16:37Z",
|
|
168
|
-
"messageBody": "git-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
169
|
-
"messageHeadline": "strawberry",
|
|
170
|
-
"oid": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0"
|
|
171
|
-
}
|
|
172
|
-
],
|
|
173
|
-
"headRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
|
|
174
|
-
"number": 30,
|
|
175
|
-
"state": "OPEN",
|
|
176
|
-
"title": "strawberry",
|
|
177
|
-
"url": "https://github.com/magus/git-multi-diff-playground/pull/30"
|
|
178
|
-
},
|
|
179
|
-
"metadata": {
|
|
180
|
-
"id": "53d15f9a-2451-492c-a831-642d41ad3ef4"
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
],
|
|
184
|
-
"UNASSIGNED": "unassigned"
|
|
185
|
-
}
|
|
186
|
-
}
|
package/dist/app/App copy.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { AutoUpdate } from "./AutoUpdate.js";
|
|
3
|
-
import { Debug } from "./Debug.js";
|
|
4
|
-
import { DependencyCheck } from "./DependencyCheck.js";
|
|
5
|
-
import { GatherMetadata } from "./GatherMetadata.js";
|
|
6
|
-
import { GithubApiError } from "./GithubApiError.js";
|
|
7
|
-
import { LocalCommitStatus } from "./LocalCommitStatus.js";
|
|
8
|
-
import { Main } from "./Main.js";
|
|
9
|
-
import { Output } from "./Output.js";
|
|
10
|
-
import { Providers } from "./Providers.js";
|
|
11
|
-
import { RebaseCheck } from "./RebaseCheck.js";
|
|
12
|
-
import { Store } from "./Store.js";
|
|
13
|
-
export function App() {
|
|
14
|
-
const actions = Store.useActions();
|
|
15
|
-
const ink = Store.useState((state) => state.ink);
|
|
16
|
-
const argv = Store.useState((state) => state.argv);
|
|
17
|
-
if (!ink || !argv) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
// // debug component
|
|
21
|
-
// return (
|
|
22
|
-
// <React.Fragment>
|
|
23
|
-
// <Debug />
|
|
24
|
-
// <Output />
|
|
25
|
-
// <GithubApiError />
|
|
26
|
-
// </React.Fragment>
|
|
27
|
-
// );
|
|
28
|
-
return (React.createElement(Providers, null,
|
|
29
|
-
React.createElement(Debug, null),
|
|
30
|
-
React.createElement(Output, null),
|
|
31
|
-
React.createElement(AutoUpdate, { name: "git-stack-cli", verbose: argv.verbose || argv.update, timeoutMs: argv.update ? 30 * 1000 : 2 * 1000, onOutput: actions.output, onDone: () => {
|
|
32
|
-
if (argv.update) {
|
|
33
|
-
actions.exit(0);
|
|
34
|
-
}
|
|
35
|
-
} },
|
|
36
|
-
React.createElement(RebaseCheck, null,
|
|
37
|
-
React.createElement(DependencyCheck, null,
|
|
38
|
-
!argv.verbose ? null : React.createElement(GithubApiError, null),
|
|
39
|
-
React.createElement(GatherMetadata, null,
|
|
40
|
-
React.createElement(LocalCommitStatus, null,
|
|
41
|
-
React.createElement(Main, null))))))));
|
|
42
|
-
}
|
package/dist/app/ArgCheck.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { invariant } from "../core/invariant.js";
|
|
3
|
-
import { GithubApiError } from "./GithubApiError.js";
|
|
4
|
-
import { Store } from "./Store.js";
|
|
5
|
-
export function ArgCheck(props) {
|
|
6
|
-
const argv = Store.useState((state) => state.argv);
|
|
7
|
-
invariant(argv, "argv must exist");
|
|
8
|
-
// if (argv.debug) {
|
|
9
|
-
// return (
|
|
10
|
-
// <Await
|
|
11
|
-
// fallback={<Ink.Text>Checking Github API quota...</Ink.Text>}
|
|
12
|
-
// function={github_quota}
|
|
13
|
-
// >
|
|
14
|
-
// {props.children}
|
|
15
|
-
// </Await>
|
|
16
|
-
// );
|
|
17
|
-
// }
|
|
18
|
-
return (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement(GithubApiError, null),
|
|
20
|
-
props.children));
|
|
21
|
-
}
|
package/dist/app/AutoUpdate.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import * as Ink from "ink";
|
|
5
|
-
import { cli } from "../core/cli.js";
|
|
6
|
-
import { colors } from "../core/colors.js";
|
|
7
|
-
import { fetch_json } from "../core/fetch_json.js";
|
|
8
|
-
import { is_finite_value } from "../core/is_finite_value.js";
|
|
9
|
-
import { read_json } from "../core/read_json.js";
|
|
10
|
-
import { semver_compare } from "../core/semver_compare.js";
|
|
11
|
-
import { sleep } from "../core/sleep.js";
|
|
12
|
-
import { Brackets } from "./Brackets.js";
|
|
13
|
-
import { FormatText } from "./FormatText.js";
|
|
14
|
-
import { YesNoPrompt } from "./YesNoPrompt.js";
|
|
15
|
-
function reducer(state, patch) {
|
|
16
|
-
return { ...state, ...patch };
|
|
17
|
-
}
|
|
18
|
-
export function AutoUpdate(props) {
|
|
19
|
-
const props_ref = React.useRef(props);
|
|
20
|
-
props_ref.current = props;
|
|
21
|
-
const [output, set_output] = React.useState([]);
|
|
22
|
-
const [state, patch] = React.useReducer(reducer, {
|
|
23
|
-
error: null,
|
|
24
|
-
local_version: null,
|
|
25
|
-
latest_version: null,
|
|
26
|
-
status: "init",
|
|
27
|
-
});
|
|
28
|
-
function handle_output(node) {
|
|
29
|
-
if (typeof props.onOutput === "function") {
|
|
30
|
-
props.onOutput(node);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
set_output((current) => {
|
|
34
|
-
return [...current, node];
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
let status = "done";
|
|
40
|
-
let local_version = null;
|
|
41
|
-
let latest_version = null;
|
|
42
|
-
async function auto_update() {
|
|
43
|
-
if (props_ref.current.verbose) {
|
|
44
|
-
handle_output(React.createElement(Ink.Text, { key: "init" }, "Checking for latest version..."));
|
|
45
|
-
}
|
|
46
|
-
const timeout_ms = is_finite_value(props.timeoutMs)
|
|
47
|
-
? props.timeoutMs
|
|
48
|
-
: 2 * 1000;
|
|
49
|
-
const npm_json = await Promise.race([
|
|
50
|
-
fetch_json(`https://registry.npmjs.org/${props.name}`),
|
|
51
|
-
sleep(timeout_ms).then(() => {
|
|
52
|
-
throw new Error("Timeout");
|
|
53
|
-
}),
|
|
54
|
-
]);
|
|
55
|
-
latest_version = npm_json?.["dist-tags"]?.latest;
|
|
56
|
-
if (!latest_version) {
|
|
57
|
-
throw new Error("Unable to retrieve latest version from npm");
|
|
58
|
-
}
|
|
59
|
-
const script_dir = path.dirname(fs.realpathSync(process.argv[1]));
|
|
60
|
-
const package_json_path = path.join(script_dir, "..", "package.json");
|
|
61
|
-
const package_json = read_json(package_json_path);
|
|
62
|
-
if (!package_json) {
|
|
63
|
-
// unable to find read package.json, skip auto update
|
|
64
|
-
throw new Error(`Unable to find read package.json [${package_json_path}]`);
|
|
65
|
-
}
|
|
66
|
-
local_version = package_json.version;
|
|
67
|
-
if (props_ref.current.verbose) {
|
|
68
|
-
handle_output(React.createElement(FormatText, { key: "versions", wrapper: React.createElement(Ink.Text, null), message: "Auto update found latest version {latest_version} and current local version {local_version}", values: {
|
|
69
|
-
latest_version: React.createElement(Brackets, null, latest_version),
|
|
70
|
-
local_version: React.createElement(Brackets, null, local_version),
|
|
71
|
-
} }));
|
|
72
|
-
}
|
|
73
|
-
const semver_result = semver_compare(latest_version, local_version);
|
|
74
|
-
if (semver_result === 0) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (semver_result === -1) {
|
|
78
|
-
// latest version is less than or equal to local version, skip auto update
|
|
79
|
-
throw new Error(`latest version < local_version, skipping auto update [${latest_version} < ${local_version}]`);
|
|
80
|
-
}
|
|
81
|
-
// trigger yes no prompt
|
|
82
|
-
status = "prompt";
|
|
83
|
-
}
|
|
84
|
-
const onError = props_ref.current.onError || (() => { });
|
|
85
|
-
auto_update()
|
|
86
|
-
.then(() => {
|
|
87
|
-
patch({ status, local_version, latest_version });
|
|
88
|
-
})
|
|
89
|
-
.catch((error) => {
|
|
90
|
-
patch({ status, error, local_version, latest_version });
|
|
91
|
-
onError(error);
|
|
92
|
-
if (props_ref.current.verbose) {
|
|
93
|
-
handle_output(React.createElement(Ink.Text, { key: "error", color: colors.red }, error?.message));
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
.finally(() => {
|
|
97
|
-
props.onDone?.();
|
|
98
|
-
});
|
|
99
|
-
}, []);
|
|
100
|
-
const status = (function render_status() {
|
|
101
|
-
switch (state.status) {
|
|
102
|
-
case "init":
|
|
103
|
-
return null;
|
|
104
|
-
case "prompt":
|
|
105
|
-
return (React.createElement(YesNoPrompt, { message: React.createElement(Ink.Text, { color: colors.yellow }, "New version available, would you like to update?"), onYes: async () => {
|
|
106
|
-
handle_output(React.createElement(FormatText, { key: "install", wrapper: React.createElement(Ink.Text, null), message: "Installing {name}@{version}...", values: {
|
|
107
|
-
name: (React.createElement(Ink.Text, { color: colors.yellow }, props.name)),
|
|
108
|
-
version: (React.createElement(Ink.Text, { color: colors.blue }, state.latest_version)),
|
|
109
|
-
} }));
|
|
110
|
-
patch({ status: "install" });
|
|
111
|
-
await cli(`npm install -g ${props.name}@latest`);
|
|
112
|
-
patch({ status: "exit" });
|
|
113
|
-
handle_output(React.createElement(Ink.Text, { key: "done" }, "Auto update done."));
|
|
114
|
-
}, onNo: () => {
|
|
115
|
-
patch({ status: "done" });
|
|
116
|
-
} }));
|
|
117
|
-
case "install":
|
|
118
|
-
return null;
|
|
119
|
-
case "exit":
|
|
120
|
-
return null;
|
|
121
|
-
case "done":
|
|
122
|
-
return props.children;
|
|
123
|
-
}
|
|
124
|
-
})();
|
|
125
|
-
return (React.createElement(React.Fragment, null,
|
|
126
|
-
output,
|
|
127
|
-
status));
|
|
128
|
-
}
|
package/dist/app/Await.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cache } from "../core/cache.js";
|
|
3
|
-
import { invariant } from "../core/invariant.js";
|
|
4
|
-
export function Await(props) {
|
|
5
|
-
const [display_fallback, set_display_fallback] = React.useState(false);
|
|
6
|
-
// const id = React.useId();
|
|
7
|
-
const cacheRef = React.useRef(null);
|
|
8
|
-
if (!cacheRef.current) {
|
|
9
|
-
// console.debug("setting cacheRef.current", { id });
|
|
10
|
-
cacheRef.current = cache(props.function);
|
|
11
|
-
}
|
|
12
|
-
let delayFallbackMs;
|
|
13
|
-
if ("delayFallbackMs" in props && typeof props.delayFallbackMs === "number") {
|
|
14
|
-
delayFallbackMs = props.delayFallbackMs;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
delayFallbackMs = 1000;
|
|
18
|
-
}
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
const cache = cacheRef.current;
|
|
21
|
-
if (!cache) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
let timeoutId;
|
|
25
|
-
timeoutId = setTimeout(() => {
|
|
26
|
-
// only display fallback if we are still pending
|
|
27
|
-
if (cache.check() === "pending") {
|
|
28
|
-
set_display_fallback(true);
|
|
29
|
-
}
|
|
30
|
-
}, delayFallbackMs);
|
|
31
|
-
return function cleanup() {
|
|
32
|
-
clearTimeout(timeoutId);
|
|
33
|
-
};
|
|
34
|
-
}, [delayFallbackMs]);
|
|
35
|
-
invariant(cacheRef.current, "cache must exist");
|
|
36
|
-
if ("fallback" in props) {
|
|
37
|
-
return (React.createElement(React.Suspense, { fallback: !display_fallback ? null : props.fallback },
|
|
38
|
-
React.createElement(ReadCache, { cache: cacheRef.current }, props.children)));
|
|
39
|
-
}
|
|
40
|
-
return React.createElement(ReadCache, { cache: cacheRef.current });
|
|
41
|
-
}
|
|
42
|
-
function ReadCache(props) {
|
|
43
|
-
props.cache.read();
|
|
44
|
-
return props.children;
|
|
45
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
export function Brackets(props) {
|
|
4
|
-
const color = "#f97316";
|
|
5
|
-
const text_color = "#06b6d4";
|
|
6
|
-
return (React.createElement(Ink.Text, { color: text_color },
|
|
7
|
-
React.createElement(Ink.Text, { color: color }, "["),
|
|
8
|
-
props.children,
|
|
9
|
-
React.createElement(Ink.Text, { color: color }, "]")));
|
|
10
|
-
}
|
package/dist/app/Brackets.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
import { colors } from "../core/colors.js";
|
|
4
|
-
export function Brackets(props) {
|
|
5
|
-
const color = colors.orange;
|
|
6
|
-
const text_color = colors.blue;
|
|
7
|
-
return (React.createElement(Ink.Text, { color: text_color },
|
|
8
|
-
React.createElement(Ink.Text, { color: color }, "["),
|
|
9
|
-
props.children,
|
|
10
|
-
React.createElement(Ink.Text, { color: color }, "]")));
|
|
11
|
-
}
|
package/dist/app/Command.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
import { colors } from "../core/colors.js";
|
|
4
|
-
export function Command(props) {
|
|
5
|
-
const text_color = colors.orange;
|
|
6
|
-
return (React.createElement(Ink.Text, { bold: true, color: text_color }, props.children));
|
|
7
|
-
}
|
package/dist/app/Counter.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
export function Counter() {
|
|
4
|
-
const { isFocused } = Ink.useFocus();
|
|
5
|
-
const [counter, setCounter] = React.useState(0);
|
|
6
|
-
React.useEffect(() => {
|
|
7
|
-
const timer = setInterval(() => {
|
|
8
|
-
setCounter((prevCounter) => prevCounter + 1);
|
|
9
|
-
}, 100);
|
|
10
|
-
return () => {
|
|
11
|
-
clearInterval(timer);
|
|
12
|
-
};
|
|
13
|
-
}, []);
|
|
14
|
-
return (React.createElement(Ink.Text, { color: "green" },
|
|
15
|
-
counter,
|
|
16
|
-
" tests passed (focus:",
|
|
17
|
-
String(isFocused),
|
|
18
|
-
")"));
|
|
19
|
-
}
|
package/dist/app/Debug.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import * as Ink from "ink";
|
|
5
|
-
import { colors } from "../core/colors.js";
|
|
6
|
-
import { invariant } from "../core/invariant.js";
|
|
7
|
-
import * as json from "../core/json.js";
|
|
8
|
-
import { Store } from "./Store.js";
|
|
9
|
-
export function Debug() {
|
|
10
|
-
const actions = Store.useActions();
|
|
11
|
-
const state = Store.useState((state) => state);
|
|
12
|
-
const argv = Store.useState((state) => state.argv);
|
|
13
|
-
const debug = Store.useState((state) => state.select.debug(state));
|
|
14
|
-
React.useEffect(function debugMessageOnce() {
|
|
15
|
-
if (debug) {
|
|
16
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow }, "Debug mode enabled"));
|
|
17
|
-
}
|
|
18
|
-
}, [argv]);
|
|
19
|
-
React.useEffect(function syncStateJson() {
|
|
20
|
-
invariant(state.cwd, "state.cwd must exist");
|
|
21
|
-
if (!argv?.["write-state-json"]) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const output_file = path.join(state.cwd, "git-stack-state.json");
|
|
25
|
-
if (fs.existsSync(output_file)) {
|
|
26
|
-
fs.rmSync(output_file);
|
|
27
|
-
}
|
|
28
|
-
const serialized = json.serialize(state);
|
|
29
|
-
const content = JSON.stringify(serialized, null, 2);
|
|
30
|
-
fs.writeFileSync(output_file, content);
|
|
31
|
-
}, [argv, state]);
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
import { cli } from "../core/cli.js";
|
|
4
|
-
import { colors } from "../core/colors.js";
|
|
5
|
-
import { is_command_available } from "../core/is_command_available.js";
|
|
6
|
-
import { match_group } from "../core/match_group.js";
|
|
7
|
-
import { semver_compare } from "../core/semver_compare.js";
|
|
8
|
-
import { Await } from "./Await.js";
|
|
9
|
-
import { Command } from "./Command.js";
|
|
10
|
-
import { Parens } from "./Parens.js";
|
|
11
|
-
import { Store } from "./Store.js";
|
|
12
|
-
import { Url } from "./Url.js";
|
|
13
|
-
export function DependencyCheck(props) {
|
|
14
|
-
const actions = Store.useActions();
|
|
15
|
-
return (React.createElement(Await, { fallback: React.createElement(Ink.Text, { color: colors.yellow },
|
|
16
|
-
"Checking ",
|
|
17
|
-
React.createElement(Command, null, "git"),
|
|
18
|
-
" install..."), function: async () => {
|
|
19
|
-
// await Promise.all([
|
|
20
|
-
// cli(`for i in $(seq 1 5); do echo $i; sleep 1; done`),
|
|
21
|
-
// cli(`for i in $(seq 5 1); do printf "$i "; sleep 1; done; echo`),
|
|
22
|
-
// ]);
|
|
23
|
-
if (is_command_available("git")) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
|
27
|
-
React.createElement(Command, null, "git"),
|
|
28
|
-
" must be installed."));
|
|
29
|
-
actions.exit(2);
|
|
30
|
-
} },
|
|
31
|
-
React.createElement(Await, { fallback: React.createElement(Ink.Text, { color: colors.yellow },
|
|
32
|
-
"Checking ",
|
|
33
|
-
React.createElement(Command, null, "node"),
|
|
34
|
-
" install..."), function: async () => {
|
|
35
|
-
const process_version = process.version.substring(1);
|
|
36
|
-
const semver_result = semver_compare(process_version, "14.0.0");
|
|
37
|
-
if (semver_result >= 0) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
|
41
|
-
React.createElement(Command, null, "node"),
|
|
42
|
-
" must be installed."));
|
|
43
|
-
actions.exit(2);
|
|
44
|
-
} },
|
|
45
|
-
React.createElement(Await, { fallback: React.createElement(Ink.Text, { color: colors.yellow },
|
|
46
|
-
React.createElement(Ink.Text, null,
|
|
47
|
-
"Checking ",
|
|
48
|
-
React.createElement(Command, null, "gh"),
|
|
49
|
-
" install...")), function: async () => {
|
|
50
|
-
if (is_command_available("gh")) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
|
54
|
-
React.createElement(Command, null, "gh"),
|
|
55
|
-
" must be installed."));
|
|
56
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
|
57
|
-
React.createElement(Ink.Text, null, "Visit "),
|
|
58
|
-
React.createElement(Url, null, "https://cli.github.com"),
|
|
59
|
-
React.createElement(Ink.Text, null, " to install the github cli "),
|
|
60
|
-
React.createElement(Parens, null,
|
|
61
|
-
React.createElement(Command, null, "gh"))));
|
|
62
|
-
actions.exit(3);
|
|
63
|
-
} },
|
|
64
|
-
React.createElement(Await, { fallback: React.createElement(Ink.Text, { color: colors.yellow },
|
|
65
|
-
React.createElement(Ink.Text, null,
|
|
66
|
-
"Checking ",
|
|
67
|
-
React.createElement(Command, null, "gh auth status"),
|
|
68
|
-
"...")), function: async () => {
|
|
69
|
-
const auth_status = await cli(`gh auth status`, {
|
|
70
|
-
ignoreExitCode: true,
|
|
71
|
-
});
|
|
72
|
-
if (auth_status.code === 0) {
|
|
73
|
-
const username = match_group(auth_status.stdout, RE.auth_username, "username");
|
|
74
|
-
actions.set((state) => {
|
|
75
|
-
state.username = username;
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
|
80
|
-
React.createElement(Command, null, "gh"),
|
|
81
|
-
React.createElement(Ink.Text, null, " requires login, please run "),
|
|
82
|
-
React.createElement(Command, null, "gh auth login")));
|
|
83
|
-
actions.exit(4);
|
|
84
|
-
} }, props.children)))));
|
|
85
|
-
}
|
|
86
|
-
const RE = {
|
|
87
|
-
// Logged in to github.com as magus
|
|
88
|
-
auth_username: /Logged in to github.com as (?<username>[^\s]+)/,
|
|
89
|
-
};
|
package/dist/app/Exit.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Store } from "./Store.js";
|
|
3
|
-
export function Exit(props) {
|
|
4
|
-
const actions = Store.useActions();
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
if (props.clear) {
|
|
7
|
-
actions.clear();
|
|
8
|
-
}
|
|
9
|
-
actions.unmount();
|
|
10
|
-
process.exitCode = props.code;
|
|
11
|
-
process.exit();
|
|
12
|
-
}, [props.clear, props.code]);
|
|
13
|
-
return null;
|
|
14
|
-
}
|
package/dist/app/FormatText.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Ink from "ink";
|
|
3
|
-
import { FormattedMessage } from "react-intl";
|
|
4
|
-
export function FormatText(props) {
|
|
5
|
-
const wrapper = props.wrapper || React.createElement(Ink.Text, null);
|
|
6
|
-
return (React.createElement(FormattedMessage, { id: "FormatText", defaultMessage: props.message, values: props.values }, (chunks) => {
|
|
7
|
-
return React.cloneElement(wrapper, {}, chunks);
|
|
8
|
-
}));
|
|
9
|
-
}
|