@gonovus-ai/spec-flow-cli 0.6.3 → 1.0.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.
- package/README.md +58 -7
- package/dist/authentication-command-topology.js.map +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +864 -287
- package/dist/cli.js.map +1 -1
- package/dist/client-identity.d.ts +1 -1
- package/dist/client-identity.js +3 -1
- package/dist/client-identity.js.map +1 -1
- package/dist/commands/client-compatibility.d.ts +3 -0
- package/dist/commands/client-compatibility.js +191 -0
- package/dist/commands/client-compatibility.js.map +1 -0
- package/dist/commands/guide.d.ts +2 -0
- package/dist/commands/guide.js +35 -0
- package/dist/commands/guide.js.map +1 -0
- package/dist/commands/work-item-output.d.ts +15 -5
- package/dist/commands/work-item-output.js +47 -9
- package/dist/commands/work-item-output.js.map +1 -1
- package/dist/credential-store.js +6 -7
- package/dist/credential-store.js.map +1 -1
- package/dist/custom-field-color-commands.js +13 -3
- package/dist/custom-field-color-commands.js.map +1 -1
- package/dist/default-api-origin.js.map +1 -1
- package/dist/github-account-commands.js +116 -20
- package/dist/github-account-commands.js.map +1 -1
- package/dist/github-connection-commands.js +284 -36
- package/dist/github-connection-commands.js.map +1 -1
- package/dist/github-import-commands.js +41 -11
- package/dist/github-import-commands.js.map +1 -1
- package/dist/http-origin.js +1 -1
- package/dist/http-origin.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +125 -35
- package/dist/index.js.map +1 -1
- package/dist/input/text-source.js +8 -2
- package/dist/input/text-source.js.map +1 -1
- package/dist/node-version.js.map +1 -1
- package/dist/product-map-commands.js +220 -37
- package/dist/product-map-commands.js.map +1 -1
- package/dist/program.js +9 -3
- package/dist/program.js.map +1 -1
- package/dist/project-administration-commands.js +36 -8
- package/dist/project-administration-commands.js.map +1 -1
- package/dist/runtime/client-compatibility.d.ts +13 -0
- package/dist/runtime/client-compatibility.js +79 -0
- package/dist/runtime/client-compatibility.js.map +1 -0
- package/dist/runtime/errors.js +21 -3
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/execute.js +16 -2
- package/dist/runtime/execute.js.map +1 -1
- package/dist/runtime/identity.d.ts +8 -80
- package/dist/runtime/identity.js +21 -4
- package/dist/runtime/identity.js.map +1 -1
- package/dist/runtime/npm-upgrade.d.ts +32 -0
- package/dist/runtime/npm-upgrade.js +132 -0
- package/dist/runtime/npm-upgrade.js.map +1 -0
- package/dist/runtime/output.js +6 -1
- package/dist/runtime/output.js.map +1 -1
- package/dist/runtime/session.js +44 -11
- package/dist/runtime/session.js.map +1 -1
- package/dist/screen-image-commands.js +66 -14
- package/dist/screen-image-commands.js.map +1 -1
- package/dist/spec-discussion-commands.js +87 -24
- package/dist/spec-discussion-commands.js.map +1 -1
- package/dist/spec-owner-commands.js +22 -7
- package/dist/spec-owner-commands.js.map +1 -1
- package/dist/user-api-key-commands.js +92 -20
- package/dist/user-api-key-commands.js.map +1 -1
- package/dist/work-item-asset-commands.js +23 -6
- package/dist/work-item-asset-commands.js.map +1 -1
- package/dist/work-item-delivery-commands.js +97 -31
- package/dist/work-item-delivery-commands.js.map +1 -1
- package/dist/work-item-exchange-file.js +22 -8
- package/dist/work-item-exchange-file.js.map +1 -1
- package/dist/work-item-query-commands.js +403 -35
- package/dist/work-item-query-commands.js.map +1 -1
- package/dist/work-item-resource-link-commands.js +105 -28
- package/dist/work-item-resource-link-commands.js.map +1 -1
- package/dist/work-item-thread-commands.d.ts +3 -0
- package/dist/work-item-thread-commands.js +101 -0
- package/dist/work-item-thread-commands.js.map +1 -0
- package/dist/work-item-watcher-commands.d.ts +20 -0
- package/dist/work-item-watcher-commands.js +93 -0
- package/dist/work-item-watcher-commands.js.map +1 -0
- package/guides/authoring.md +178 -0
- package/guides/delivery.md +60 -0
- package/guides/discussions-audit.md +32 -0
- package/guides/errors.md +41 -0
- package/guides/glossary.md +40 -0
- package/guides/map-and-screens.md +31 -0
- package/guides/search.md +9 -0
- package/guides/work-items.md +195 -0
- package/guides/workspace-admin.md +130 -0
- package/package.json +8 -3
|
@@ -3,8 +3,18 @@ import { z } from "zod";
|
|
|
3
3
|
import { registerGitHubConnectionCommands } from "./github-connection-commands.js";
|
|
4
4
|
import { registerGitHubImportCommands } from "./github-import-commands.js";
|
|
5
5
|
const identity = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
6
|
-
const metadata = z.object({
|
|
7
|
-
|
|
6
|
+
const metadata = z.object({
|
|
7
|
+
accountId: identity,
|
|
8
|
+
login: z.string(),
|
|
9
|
+
status: z.enum(["connected", "disconnected", "credential-invalid"]),
|
|
10
|
+
expiresAt: z.iso.datetime().nullable(),
|
|
11
|
+
version: z.string().regex(/^"[1-9]\d*"$/),
|
|
12
|
+
});
|
|
13
|
+
const read = z.object({
|
|
14
|
+
enabled: z.boolean(),
|
|
15
|
+
account: metadata.nullable(),
|
|
16
|
+
browserAuthorizationUrl: z.url().nullable(),
|
|
17
|
+
});
|
|
8
18
|
const page = (value) => {
|
|
9
19
|
const result = z.coerce.number().int().min(1).max(10_000).safeParse(value);
|
|
10
20
|
if (!result.success)
|
|
@@ -29,7 +39,12 @@ const uuid = (value) => {
|
|
|
29
39
|
};
|
|
30
40
|
function browserEntry(value) {
|
|
31
41
|
const url = new URL(value);
|
|
32
|
-
if ((url.protocol !== "https:" && !(url.protocol === "http:" && url.hostname === "127.0.0.1")) ||
|
|
42
|
+
if ((url.protocol !== "https:" && !(url.protocol === "http:" && url.hostname === "127.0.0.1")) ||
|
|
43
|
+
url.username !== "" ||
|
|
44
|
+
url.password !== "" ||
|
|
45
|
+
url.pathname !== "/account/github" ||
|
|
46
|
+
url.search !== "" ||
|
|
47
|
+
url.hash !== "")
|
|
33
48
|
throw new Error("Invalid browser entry");
|
|
34
49
|
return url.toString();
|
|
35
50
|
}
|
|
@@ -37,14 +52,18 @@ export function registerGitHubAccountCommands(program, runtime) {
|
|
|
37
52
|
const github = program.command("github").description("Manage the supported GitHub integration");
|
|
38
53
|
registerGitHubConnectionCommands(github, runtime);
|
|
39
54
|
registerGitHubImportCommands(github, runtime);
|
|
40
|
-
const account = github
|
|
55
|
+
const account = github
|
|
56
|
+
.command("account")
|
|
57
|
+
.description("Manage your separately authorized GitHub account using a User Session");
|
|
41
58
|
account.command("status").action(async () => {
|
|
42
59
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
43
60
|
const result = await client.GET("/v1/github/account");
|
|
44
61
|
return result.response.ok ? { ...result, data: read.parse(result.data) } : result;
|
|
45
62
|
}, { requireUserSession: true }));
|
|
46
63
|
});
|
|
47
|
-
account
|
|
64
|
+
account
|
|
65
|
+
.command("authorize")
|
|
66
|
+
.description("Open the normal SpecFlow browser flow; use the same User as this CLI Session")
|
|
48
67
|
.option("--no-open", "Print only the credential-free account page for opening manually")
|
|
49
68
|
.action(async (options) => {
|
|
50
69
|
let failed = false;
|
|
@@ -64,30 +83,61 @@ export function registerGitHubAccountCommands(program, runtime) {
|
|
|
64
83
|
await runtime.dependencies.open(url);
|
|
65
84
|
browserOpened = true;
|
|
66
85
|
}
|
|
67
|
-
catch {
|
|
86
|
+
catch {
|
|
87
|
+
/* A manual entry contains no one-time credentials. */
|
|
88
|
+
}
|
|
68
89
|
}
|
|
69
90
|
return { ...result, data: { browserOpened, browserAuthorizationUrl: url } };
|
|
70
|
-
}, {
|
|
91
|
+
}, {
|
|
92
|
+
requireUserSession: true,
|
|
93
|
+
validateSuccess: () => failed
|
|
94
|
+
? {
|
|
95
|
+
message: "GitHub integration is not enabled on this server",
|
|
96
|
+
reason: "Temporary Failure",
|
|
97
|
+
retryable: false,
|
|
98
|
+
}
|
|
99
|
+
: null,
|
|
100
|
+
}));
|
|
71
101
|
});
|
|
72
|
-
account
|
|
102
|
+
account
|
|
103
|
+
.command("disconnect")
|
|
104
|
+
.description("Disconnect the observed authorization; preserve command identity when retrying")
|
|
73
105
|
.requiredOption("--expected-version <version>", "Quoted version from account status", version)
|
|
74
106
|
.requiredOption("--idempotency-key <id>", "Same UUID for same-intent retry", uuid)
|
|
75
107
|
.action(async (options) => {
|
|
76
108
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
77
|
-
const result = await client.DELETE("/v1/github/account", {
|
|
109
|
+
const result = await client.DELETE("/v1/github/account", {
|
|
110
|
+
params: {
|
|
111
|
+
header: {
|
|
112
|
+
"if-match": options.expectedVersion,
|
|
113
|
+
"idempotency-key": options.idempotencyKey,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
78
117
|
return result.response.ok ? { ...result, data: metadata.parse(result.data) } : result;
|
|
79
118
|
}, { requireUserSession: true }));
|
|
80
119
|
});
|
|
81
|
-
github
|
|
120
|
+
github
|
|
121
|
+
.command("install")
|
|
122
|
+
.description("Open the configured GitHub App installation page; return and reread accessible repositories afterwards")
|
|
82
123
|
.option("--no-open", "Print the credential-free GitHub installation page for opening manually")
|
|
83
124
|
.action(async (options) => {
|
|
84
125
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
85
126
|
const result = await client.GET("/v1/github/application");
|
|
86
127
|
if (!result.response.ok)
|
|
87
128
|
return result;
|
|
88
|
-
const application = z
|
|
129
|
+
const application = z
|
|
130
|
+
.object({ id: identity, name: z.string().min(1).max(200), installationUrl: z.url() })
|
|
131
|
+
.parse(result.data);
|
|
89
132
|
const url = new URL(application.installationUrl);
|
|
90
|
-
if (url.protocol !== "https:" ||
|
|
133
|
+
if (url.protocol !== "https:" ||
|
|
134
|
+
url.hostname !== "github.com" ||
|
|
135
|
+
url.port !== "" ||
|
|
136
|
+
url.username !== "" ||
|
|
137
|
+
url.password !== "" ||
|
|
138
|
+
url.search !== "" ||
|
|
139
|
+
url.hash !== "" ||
|
|
140
|
+
!/^\/apps\/[A-Za-z0-9_-][A-Za-z0-9_.-]{0,199}\/installations\/new$/.test(url.pathname))
|
|
91
141
|
throw new Error("Invalid installation entry");
|
|
92
142
|
let browserOpened = false;
|
|
93
143
|
if (options.open && runtime.dependencies.open !== undefined) {
|
|
@@ -95,22 +145,68 @@ export function registerGitHubAccountCommands(program, runtime) {
|
|
|
95
145
|
await runtime.dependencies.open(url.toString());
|
|
96
146
|
browserOpened = true;
|
|
97
147
|
}
|
|
98
|
-
catch {
|
|
148
|
+
catch {
|
|
149
|
+
/* Print the public installation URL for manual opening. */
|
|
150
|
+
}
|
|
99
151
|
}
|
|
100
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
...result,
|
|
154
|
+
data: { ...application, installationUrl: url.toString(), browserOpened },
|
|
155
|
+
};
|
|
101
156
|
}, { requireUserSession: true }));
|
|
102
157
|
});
|
|
103
|
-
github
|
|
158
|
+
github
|
|
159
|
+
.command("installations")
|
|
160
|
+
.option("--page <page>", "Page number", page, 1)
|
|
161
|
+
.action(async (options) => {
|
|
104
162
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
105
|
-
const result = await client.GET("/v1/github/installations", {
|
|
106
|
-
|
|
163
|
+
const result = await client.GET("/v1/github/installations", {
|
|
164
|
+
params: { query: options },
|
|
165
|
+
});
|
|
166
|
+
return result.response.ok
|
|
167
|
+
? {
|
|
168
|
+
...result,
|
|
169
|
+
data: z
|
|
170
|
+
.object({
|
|
171
|
+
installations: z.array(z.object({
|
|
172
|
+
id: identity,
|
|
173
|
+
account: z.object({ id: identity, login: z.string() }),
|
|
174
|
+
})),
|
|
175
|
+
})
|
|
176
|
+
.parse(result.data),
|
|
177
|
+
}
|
|
178
|
+
: result;
|
|
107
179
|
}, { requireUserSession: true }));
|
|
108
180
|
});
|
|
109
|
-
github
|
|
181
|
+
github
|
|
182
|
+
.command("repositories")
|
|
183
|
+
.requiredOption("--installation-id <id>", "Installation identity", installationId)
|
|
184
|
+
.option("--page <page>", "Page number", page, 1)
|
|
110
185
|
.action(async (options) => {
|
|
111
186
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
112
|
-
const result = await client.GET("/v1/github/installations/{installationId}/repositories", {
|
|
113
|
-
|
|
187
|
+
const result = await client.GET("/v1/github/installations/{installationId}/repositories", {
|
|
188
|
+
params: {
|
|
189
|
+
path: { installationId: options.installationId },
|
|
190
|
+
query: { page: options.page },
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
return result.response.ok
|
|
194
|
+
? {
|
|
195
|
+
...result,
|
|
196
|
+
data: z
|
|
197
|
+
.object({
|
|
198
|
+
repositories: z.array(z.object({
|
|
199
|
+
installationId: identity,
|
|
200
|
+
repositoryId: identity,
|
|
201
|
+
owner: z.string(),
|
|
202
|
+
name: z.string(),
|
|
203
|
+
private: z.boolean(),
|
|
204
|
+
administrator: z.boolean(),
|
|
205
|
+
})),
|
|
206
|
+
})
|
|
207
|
+
.parse(result.data),
|
|
208
|
+
}
|
|
209
|
+
: result;
|
|
114
210
|
}, { requireUserSession: true }));
|
|
115
211
|
});
|
|
116
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-account-commands.js","sourceRoot":"","sources":["../src/github-account-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"github-account-commands.js","sourceRoot":"","sources":["../src/github-account-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAwB3E,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,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wDAAwD,EACxD;gBACE,MAAM,EAAE;oBACN,IAAI,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;oBAChD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;iBAC9B;aACF,CACF,CAAC;YACF,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE;gBACvB,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,IAAI,EAAE,CAAC;yBACJ,MAAM,CAAC;wBACN,YAAY,EAAE,CAAC,CAAC,KAAK,CACnB,CAAC,CAAC,MAAM,CAAC;4BACP,cAAc,EAAE,QAAQ;4BACxB,YAAY,EAAE,QAAQ;4BACtB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;4BACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;4BAChB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;4BACpB,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;yBAC3B,CAAC,CACH;qBACF,CAAC;yBACD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;iBACtB;gBACH,CAAC,CAAC,MAAM,CAAC;QACb,CAAC,EACD,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC7B,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { InvalidArgumentError } from "commander";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
const identity = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
4
|
-
const rule = z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const rule = z
|
|
5
|
+
.object({
|
|
6
|
+
event: z.enum(["branch_push", "pr_opened", "pr_merged", "issue_opened", "issue_closed"]),
|
|
7
|
+
columnId: z.string().min(1).max(200),
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
const rules = z
|
|
11
|
+
.array(rule)
|
|
12
|
+
.max(5)
|
|
13
|
+
.refine((values) => new Set(values.map((value) => value.event)).size === values.length);
|
|
14
|
+
const branchPatterns = [
|
|
15
|
+
"{slug}-{number}",
|
|
16
|
+
"{slug}-{number}-{title}",
|
|
17
|
+
"{number}",
|
|
18
|
+
"{number}-{title}",
|
|
19
|
+
"feature/{slug}-{number}",
|
|
20
|
+
"feature/{number}-{title}",
|
|
21
|
+
"fix/{slug}-{number}",
|
|
22
|
+
"fix/{number}-{title}",
|
|
23
|
+
];
|
|
24
|
+
const branchPattern = (value) => {
|
|
25
|
+
const parsed = z.enum(branchPatterns).safeParse(value);
|
|
26
|
+
if (!parsed.success)
|
|
27
|
+
throw new InvalidArgumentError("Choose a supported GitHub branch template");
|
|
28
|
+
return parsed.data;
|
|
29
|
+
};
|
|
9
30
|
const customBranchRegex = (value) => {
|
|
10
31
|
if (!value || value.length > 500)
|
|
11
32
|
throw new InvalidArgumentError("A custom branch regexp must contain 1 to 500 characters");
|
|
@@ -17,16 +38,56 @@ const customBranchRegex = (value) => {
|
|
|
17
38
|
}
|
|
18
39
|
return value;
|
|
19
40
|
};
|
|
20
|
-
const metadata = z.object({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
const metadata = z.object({
|
|
42
|
+
id: z.uuid(),
|
|
43
|
+
projectId: z.string(),
|
|
44
|
+
installationId: identity,
|
|
45
|
+
repositoryId: identity,
|
|
46
|
+
owner: z.string(),
|
|
47
|
+
name: z.string(),
|
|
48
|
+
status: z
|
|
49
|
+
.enum([
|
|
50
|
+
"connected",
|
|
51
|
+
"importing",
|
|
52
|
+
"import-failed",
|
|
53
|
+
"reauthorization-required",
|
|
54
|
+
"off",
|
|
55
|
+
"disconnected",
|
|
56
|
+
])
|
|
57
|
+
.optional(),
|
|
58
|
+
active: z.boolean(),
|
|
59
|
+
outbound: z.boolean().optional(),
|
|
60
|
+
disconnected: z.boolean().optional(),
|
|
61
|
+
commentTaskLink: z.boolean(),
|
|
62
|
+
branchPattern: z.enum(branchPatterns),
|
|
63
|
+
customBranchRegex: z.string().min(1).max(500).nullable(),
|
|
64
|
+
version: z.string().regex(/^"[1-9]\d*"$/),
|
|
65
|
+
rules,
|
|
66
|
+
createdAt: z.iso.datetime(),
|
|
67
|
+
updatedAt: z.iso.datetime(),
|
|
68
|
+
});
|
|
69
|
+
const positiveIdentity = (value) => {
|
|
70
|
+
const parsed = z.coerce.number().pipe(identity).safeParse(value);
|
|
71
|
+
if (!parsed.success)
|
|
72
|
+
throw new InvalidArgumentError("GitHub identities must be positive safe integers");
|
|
73
|
+
return parsed.data;
|
|
74
|
+
};
|
|
75
|
+
const uuid = (value) => {
|
|
76
|
+
if (!z.uuid().safeParse(value).success)
|
|
77
|
+
throw new InvalidArgumentError("Command and connection identities must be UUIDs");
|
|
78
|
+
return value.toLowerCase();
|
|
79
|
+
};
|
|
80
|
+
const version = (value) => {
|
|
81
|
+
if (!/^"[1-9]\d{0,9}"$/.test(value) || Number(value.slice(1, -1)) > 2_147_483_647)
|
|
82
|
+
throw new InvalidArgumentError("Use the quoted observed connection version");
|
|
83
|
+
return value;
|
|
84
|
+
};
|
|
85
|
+
const observed = (value) => (value === "none" ? value : version(value));
|
|
86
|
+
const boolean = (value) => {
|
|
87
|
+
if (value !== "true" && value !== "false")
|
|
88
|
+
throw new InvalidArgumentError("Use true or false");
|
|
89
|
+
return value === "true";
|
|
90
|
+
};
|
|
30
91
|
const workflowRules = (value) => {
|
|
31
92
|
try {
|
|
32
93
|
return rules.parse(JSON.parse(value));
|
|
@@ -37,17 +98,37 @@ const workflowRules = (value) => {
|
|
|
37
98
|
};
|
|
38
99
|
/** Team configuration uses the same Session and Project operation boundary. */
|
|
39
100
|
export function registerGitHubConnectionCommands(github, runtime) {
|
|
40
|
-
const connection = github
|
|
41
|
-
|
|
42
|
-
|
|
101
|
+
const connection = github
|
|
102
|
+
.command("connection")
|
|
103
|
+
.description("Manage a Project's GitHub repository connection");
|
|
104
|
+
connection
|
|
105
|
+
.command("list")
|
|
106
|
+
.requiredOption("--project-id <projectId>")
|
|
107
|
+
.action(async (options) => {
|
|
108
|
+
runtime.setExitCode(await runtime.run((client) => client.GET("/v1/projects/{projectId}/github/connections", {
|
|
109
|
+
params: { path: options },
|
|
110
|
+
}), {}));
|
|
43
111
|
});
|
|
44
|
-
connection
|
|
112
|
+
connection
|
|
113
|
+
.command("status")
|
|
114
|
+
.requiredOption("--project-id <projectId>")
|
|
115
|
+
.requiredOption("--connection-id <id>", "Explicit repository connection", uuid)
|
|
116
|
+
.action(async (options) => {
|
|
45
117
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
46
118
|
const result = await client.GET("/v1/projects/{projectId}/github/connections/{connectionId}", { params: { path: options } });
|
|
47
|
-
return result.response.ok
|
|
119
|
+
return result.response.ok
|
|
120
|
+
? {
|
|
121
|
+
...result,
|
|
122
|
+
data: z
|
|
123
|
+
.object({ enabled: z.boolean(), connection: metadata.nullable() })
|
|
124
|
+
.parse(result.data),
|
|
125
|
+
}
|
|
126
|
+
: result;
|
|
48
127
|
}, {}));
|
|
49
128
|
});
|
|
50
|
-
connection
|
|
129
|
+
connection
|
|
130
|
+
.command("connect-batch")
|
|
131
|
+
.requiredOption("--project-id <projectId>")
|
|
51
132
|
.requiredOption("--repository <owner/name:installationId:repositoryId>", "Repeat for each repository", (value, previous) => [...previous, value], [])
|
|
52
133
|
.option("--outbound-repository-id <id>", "Choose the one repository for new Issues", positiveIdentity)
|
|
53
134
|
.option("--no-outbound", "Do not select an outbound repository")
|
|
@@ -59,17 +140,46 @@ export function registerGitHubConnectionCommands(github, runtime) {
|
|
|
59
140
|
const match = /^([^/:]+)\/([^/:]+):([0-9]+):([0-9]+)$/.exec(value);
|
|
60
141
|
if (match === null)
|
|
61
142
|
throw new InvalidArgumentError("Use owner/name:installationId:repositoryId");
|
|
62
|
-
return {
|
|
143
|
+
return {
|
|
144
|
+
owner: match[1] ?? "",
|
|
145
|
+
name: match[2] ?? "",
|
|
146
|
+
installationId: positiveIdentity(match[3] ?? ""),
|
|
147
|
+
repositoryId: positiveIdentity(match[4] ?? ""),
|
|
148
|
+
};
|
|
63
149
|
});
|
|
64
|
-
if (repositories.length < 1 ||
|
|
150
|
+
if (repositories.length < 1 ||
|
|
151
|
+
repositories.length > 50 ||
|
|
152
|
+
new Set(repositories.map((value) => value.repositoryId)).size !== repositories.length)
|
|
65
153
|
throw new InvalidArgumentError("Select 1 to 50 unique repositories");
|
|
66
154
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
67
|
-
const result = await client.POST("/v1/projects/{projectId}/github/connections/batch", {
|
|
68
|
-
|
|
155
|
+
const result = await client.POST("/v1/projects/{projectId}/github/connections/batch", {
|
|
156
|
+
body: {
|
|
157
|
+
repositories,
|
|
158
|
+
...(options.outbound === false
|
|
159
|
+
? { outboundRepositoryId: null }
|
|
160
|
+
: options.outboundRepositoryId === undefined
|
|
161
|
+
? {}
|
|
162
|
+
: { outboundRepositoryId: options.outboundRepositoryId }),
|
|
163
|
+
},
|
|
164
|
+
params: {
|
|
165
|
+
path: { projectId: options.projectId },
|
|
166
|
+
header: { "idempotency-key": options.idempotencyKey },
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
return result.response.ok
|
|
170
|
+
? {
|
|
171
|
+
...result,
|
|
172
|
+
data: z.object({ connections: z.array(metadata) }).parse(result.data),
|
|
173
|
+
}
|
|
174
|
+
: result;
|
|
69
175
|
}, { requireUserSession: true }));
|
|
70
176
|
});
|
|
71
|
-
connection
|
|
72
|
-
.
|
|
177
|
+
connection
|
|
178
|
+
.command("connect")
|
|
179
|
+
.requiredOption("--project-id <projectId>")
|
|
180
|
+
.option("--outbound <true|false>", "Create new Issues here", boolean)
|
|
181
|
+
.requiredOption("--owner <owner>")
|
|
182
|
+
.requiredOption("--repository <name>")
|
|
73
183
|
.requiredOption("--installation-id <id>", "Verified GitHub App installation", positiveIdentity)
|
|
74
184
|
.requiredOption("--repository-id <id>", "Stable numeric repository identity", positiveIdentity)
|
|
75
185
|
.requiredOption("--expected-version <version|none>", "Quoted version, or none only after observing no connection", observed)
|
|
@@ -77,13 +187,32 @@ export function registerGitHubConnectionCommands(github, runtime) {
|
|
|
77
187
|
.action(async (options) => {
|
|
78
188
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
79
189
|
const result = await client.POST("/v1/projects/{projectId}/github/connections", {
|
|
80
|
-
body: {
|
|
81
|
-
|
|
190
|
+
body: {
|
|
191
|
+
...(options.outbound === undefined ? {} : { outbound: options.outbound }),
|
|
192
|
+
binding: {
|
|
193
|
+
owner: options.owner,
|
|
194
|
+
name: options.repository,
|
|
195
|
+
installationId: options.installationId,
|
|
196
|
+
repositoryId: options.repositoryId,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
params: {
|
|
200
|
+
path: { projectId: options.projectId },
|
|
201
|
+
header: {
|
|
202
|
+
"idempotency-key": options.idempotencyKey,
|
|
203
|
+
...(options.expectedVersion === "none"
|
|
204
|
+
? { "if-none-match": "*" }
|
|
205
|
+
: { "if-match": options.expectedVersion }),
|
|
206
|
+
},
|
|
207
|
+
},
|
|
82
208
|
});
|
|
83
209
|
return result.response.ok ? { ...result, data: metadata.parse(result.data) } : result;
|
|
84
210
|
}, { requireUserSession: true }));
|
|
85
211
|
});
|
|
86
|
-
connection
|
|
212
|
+
connection
|
|
213
|
+
.command("update")
|
|
214
|
+
.requiredOption("--project-id <projectId>")
|
|
215
|
+
.requiredOption("--connection-id <id>", "Explicit repository connection", uuid)
|
|
87
216
|
.requiredOption("--expected-version <version>", "Observed quoted connection version", version)
|
|
88
217
|
.requiredOption("--idempotency-key <id>", "Same UUID for the same intent", uuid)
|
|
89
218
|
.option("--outbound <true|false>", "Use this repository for new Issues", boolean)
|
|
@@ -94,25 +223,144 @@ export function registerGitHubConnectionCommands(github, runtime) {
|
|
|
94
223
|
.option("--clear-custom-branch-regex", "Return to the configured branch template")
|
|
95
224
|
.option("--rules-json <json>", "Replace the five supported event-to-column mappings", workflowRules)
|
|
96
225
|
.action(async (options) => {
|
|
97
|
-
if (options.outbound === undefined &&
|
|
226
|
+
if (options.outbound === undefined &&
|
|
227
|
+
options.active === undefined &&
|
|
228
|
+
options.commentTaskLink === undefined &&
|
|
229
|
+
options.rulesJson === undefined &&
|
|
230
|
+
options.branchPattern === undefined &&
|
|
231
|
+
options.customBranchRegex === undefined &&
|
|
232
|
+
!options.clearCustomBranchRegex)
|
|
98
233
|
throw new InvalidArgumentError("Specify an explicit connection setting to update");
|
|
99
234
|
if (options.clearCustomBranchRegex && options.customBranchRegex !== undefined)
|
|
100
235
|
throw new InvalidArgumentError("Choose a custom regexp or clear it");
|
|
101
236
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
102
237
|
const result = await client.PATCH("/v1/projects/{projectId}/github/connections/{connectionId}", {
|
|
103
|
-
body: {
|
|
104
|
-
|
|
238
|
+
body: {
|
|
239
|
+
...(options.outbound === undefined ? {} : { outbound: options.outbound }),
|
|
240
|
+
...(options.active === undefined ? {} : { active: options.active }),
|
|
241
|
+
...(options.commentTaskLink === undefined
|
|
242
|
+
? {}
|
|
243
|
+
: { commentTaskLink: options.commentTaskLink }),
|
|
244
|
+
...(options.rulesJson === undefined ? {} : { rules: options.rulesJson }),
|
|
245
|
+
...(options.branchPattern === undefined
|
|
246
|
+
? {}
|
|
247
|
+
: { branchPattern: options.branchPattern }),
|
|
248
|
+
...(options.clearCustomBranchRegex
|
|
249
|
+
? { customBranchRegex: null }
|
|
250
|
+
: options.customBranchRegex === undefined
|
|
251
|
+
? {}
|
|
252
|
+
: { customBranchRegex: options.customBranchRegex }),
|
|
253
|
+
},
|
|
254
|
+
params: {
|
|
255
|
+
path: { projectId: options.projectId, connectionId: options.connectionId },
|
|
256
|
+
header: {
|
|
257
|
+
"if-match": options.expectedVersion,
|
|
258
|
+
"idempotency-key": options.idempotencyKey,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
105
261
|
});
|
|
106
262
|
return result.response.ok ? { ...result, data: metadata.parse(result.data) } : result;
|
|
107
263
|
}, { requireUserSession: true }));
|
|
108
264
|
});
|
|
109
|
-
connection
|
|
265
|
+
connection
|
|
266
|
+
.command("disconnect")
|
|
267
|
+
.requiredOption("--project-id <projectId>")
|
|
268
|
+
.requiredOption("--connection-id <id>", "Explicit repository connection", uuid)
|
|
110
269
|
.requiredOption("--expected-version <version>", "Observed quoted connection version", version)
|
|
111
270
|
.requiredOption("--idempotency-key <id>", "Same UUID for the same intent", uuid)
|
|
112
271
|
.action(async (options) => {
|
|
113
272
|
runtime.setExitCode(await runtime.run(async (client) => {
|
|
114
|
-
const result = await client.DELETE("/v1/projects/{projectId}/github/connections/{connectionId}", {
|
|
115
|
-
|
|
273
|
+
const result = await client.DELETE("/v1/projects/{projectId}/github/connections/{connectionId}", {
|
|
274
|
+
params: {
|
|
275
|
+
path: { projectId: options.projectId, connectionId: options.connectionId },
|
|
276
|
+
header: {
|
|
277
|
+
"if-match": options.expectedVersion,
|
|
278
|
+
"idempotency-key": options.idempotencyKey,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
return result.response.ok
|
|
283
|
+
? {
|
|
284
|
+
...result,
|
|
285
|
+
data: z
|
|
286
|
+
.object({ id: z.uuid(), version: z.string().regex(/^"[1-9]\d*"$/) })
|
|
287
|
+
.parse(result.data),
|
|
288
|
+
}
|
|
289
|
+
: result;
|
|
290
|
+
}, { requireUserSession: true }));
|
|
291
|
+
});
|
|
292
|
+
connection
|
|
293
|
+
.command("sync-health")
|
|
294
|
+
.requiredOption("--project-id <projectId>")
|
|
295
|
+
.requiredOption("--connection-id <connectionId>", "Explicit repository connection", uuid)
|
|
296
|
+
.action(async (options) => {
|
|
297
|
+
runtime.setExitCode(await runtime.run(async (client) => {
|
|
298
|
+
const result = await client.GET("/v1/projects/{projectId}/github/connections/{connectionId}/sync", { params: { path: options } });
|
|
299
|
+
return result.response.ok
|
|
300
|
+
? {
|
|
301
|
+
...result,
|
|
302
|
+
data: z
|
|
303
|
+
.object({
|
|
304
|
+
enabled: z.boolean(),
|
|
305
|
+
health: z.array(z.unknown()),
|
|
306
|
+
metrics: z.array(z.unknown()),
|
|
307
|
+
})
|
|
308
|
+
.parse(result.data),
|
|
309
|
+
}
|
|
310
|
+
: result;
|
|
311
|
+
}, { requireUserSession: true }));
|
|
312
|
+
});
|
|
313
|
+
const intents = connection
|
|
314
|
+
.command("sync-intents")
|
|
315
|
+
.description("Inspect and resolve uncertain installation writes");
|
|
316
|
+
intents
|
|
317
|
+
.command("list")
|
|
318
|
+
.requiredOption("--project-id <projectId>")
|
|
319
|
+
.requiredOption("--connection-id <connectionId>", "Explicit repository connection", uuid)
|
|
320
|
+
.action(async (options) => {
|
|
321
|
+
runtime.setExitCode(await runtime.run(async (client) => {
|
|
322
|
+
const result = await client.GET("/v1/projects/{projectId}/github/connections/{connectionId}/sync/intents", { params: { path: options } });
|
|
323
|
+
return result.response.ok
|
|
324
|
+
? {
|
|
325
|
+
...result,
|
|
326
|
+
data: z
|
|
327
|
+
.object({ enabled: z.boolean(), intents: z.array(z.unknown()) })
|
|
328
|
+
.parse(result.data),
|
|
329
|
+
}
|
|
330
|
+
: result;
|
|
331
|
+
}, { requireUserSession: true }));
|
|
332
|
+
});
|
|
333
|
+
intents
|
|
334
|
+
.command("resolve")
|
|
335
|
+
.requiredOption("--project-id <projectId>")
|
|
336
|
+
.requiredOption("--connection-id <connectionId>", "Explicit repository connection", uuid)
|
|
337
|
+
.requiredOption("--intent-id <intentId>")
|
|
338
|
+
.requiredOption("--action <action>", "bind, abandon or confirm-resend")
|
|
339
|
+
.requiredOption("--idempotency-key <id>", "Same UUID for the same human-confirmed intent", uuid)
|
|
340
|
+
.option("--resource-id <id>", "Existing GitHub resource identity", positiveIdentity)
|
|
341
|
+
.action(async (options) => {
|
|
342
|
+
if (!["bind", "abandon", "confirm-resend"].includes(options.action))
|
|
343
|
+
throw new InvalidArgumentError("Action must be bind, abandon or confirm-resend");
|
|
344
|
+
if (options.action === "bind" && options.resourceId === undefined)
|
|
345
|
+
throw new InvalidArgumentError("Bind requires --resource-id for the existing GitHub resource");
|
|
346
|
+
runtime.setExitCode(await runtime.run(async (client) => {
|
|
347
|
+
const result = await client.POST("/v1/projects/{projectId}/github/connections/{connectionId}/sync/intents/{intentId}/resolve", {
|
|
348
|
+
params: {
|
|
349
|
+
path: {
|
|
350
|
+
projectId: options.projectId,
|
|
351
|
+
connectionId: options.connectionId,
|
|
352
|
+
intentId: options.intentId,
|
|
353
|
+
},
|
|
354
|
+
header: { "idempotency-key": options.idempotencyKey },
|
|
355
|
+
},
|
|
356
|
+
body: {
|
|
357
|
+
action: options.action,
|
|
358
|
+
...(options.resourceId === undefined ? {} : { resourceId: options.resourceId }),
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
return result.response.ok
|
|
362
|
+
? { ...result, data: z.object({ resolved: z.boolean() }).parse(result.data) }
|
|
363
|
+
: result;
|
|
116
364
|
}, { requireUserSession: true }));
|
|
117
365
|
});
|
|
118
366
|
}
|