@leitwerk-dev/github-repo-change 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/dist/index.d.ts +39 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -840
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +15 -3
- package/dist/launcher.d.ts.map +1 -1
- package/dist/params.d.ts +3 -23
- package/dist/params.d.ts.map +1 -1
- package/dist/process.d.ts +1 -1
- package/dist/process.d.ts.map +1 -1
- package/dist/profile-bindings.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/launcher.ts +25 -181
- package/src/params.ts +11 -71
- package/src/process.ts +27 -241
- package/src/profile-bindings.ts +4 -34
package/dist/launcher.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
2
2
|
import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
|
|
3
|
-
import {
|
|
3
|
+
import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
|
|
4
4
|
import { type GitHubRepoChangeParams } from "./params.js";
|
|
5
5
|
import { type ProfileBindings } from "./profile-bindings.js";
|
|
6
6
|
/** @public */
|
|
@@ -38,6 +38,18 @@ export declare function createGitHubRepoChangeLauncher(): {
|
|
|
38
38
|
/** @public */
|
|
39
39
|
resolveGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
|
|
40
40
|
/** @public */
|
|
41
|
-
launcher: ProcessLauncherDefinition<GitHubRepoChangeParams
|
|
41
|
+
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
|
|
42
|
+
/** @internal */
|
|
43
|
+
resolveIssueLaunchConfig(event: {
|
|
44
|
+
/** @internal */
|
|
45
|
+
profile: string;
|
|
46
|
+
/** @internal */
|
|
47
|
+
repository: GitHubRepository;
|
|
48
|
+
/** @internal */
|
|
49
|
+
issue: Pick<import("@leitwerk-dev/github").GitHubIssue, "number" | "title" | "body" | "html_url">;
|
|
50
|
+
/** @internal */
|
|
51
|
+
labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
|
|
52
|
+
}): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
|
|
53
|
+
};
|
|
42
54
|
};
|
|
43
55
|
//# sourceMappingURL=launcher.d.ts.map
|
package/dist/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,KAAK,sBAAsB,EAAiB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,uBAAuB,CAAC;AAEpF,cAAc;AACd,eAAO,MAAM,4BAA4B,EAAG,wCAAiD,CAAC;AAE9F,cAAc;AACd,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE;IACN,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc;IACd,UAAU,EAAE,MAAM,CAAC;CACnB,GACC,sBAAsB,CAgBxB;AAED,cAAc;AACd,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,iBAAiB,GAC5B,mBAAmB,CAAC,sBAAsB,CAAC,CA4B7C;AAED,cAAc;AACd,MAAM,WAAW,oBAAoB;IACpC,cAAc;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc;IACd,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,cAAc;AACd,wBAAgB,8BAA8B;IAqE5C,cAAc;uBAjEmC,oBAAoB,GAAG,IAAI,KAAG,IAAI;IAmEnF,cAAc;gCAxDN,OAAO,cACH,mBAAmB,CAAC,sBAAsB,CAAC,KACrD,SAAS,sBAAsB,CAAC,sBAAsB,CAAC,EAAE;IAwD3D,cAAc;+BA3CmB,MAAM;IA6CvC,cAAc;kCAjCkC,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAAC;IAmCnF,cAAc;;;;;;;;;;;;;;EAGf"}
|
package/dist/params.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RepositoryChangeLaunchParams } from "@leitwerk-dev/coding/repository-change-launch";
|
|
1
|
+
import { type RepositoryChangeLaunchParams, type RepositoryIssueOriginParams, type RepositoryUiOriginParams } from "@leitwerk-dev/coding/repository-change-launch";
|
|
2
2
|
/** @public */
|
|
3
3
|
interface GitHubRepoChangeCommonParams {
|
|
4
4
|
/** @public */
|
|
@@ -11,30 +11,10 @@ interface GitHubRepoChangeCommonParams {
|
|
|
11
11
|
repo: string;
|
|
12
12
|
}
|
|
13
13
|
/** @public */
|
|
14
|
-
export interface GitHubIssueOriginParams {
|
|
15
|
-
/** @public */
|
|
16
|
-
origin: "issue";
|
|
17
|
-
/** @public */
|
|
18
|
-
issueNumber: number;
|
|
19
|
-
/** @public */
|
|
20
|
-
issueUrl: string;
|
|
21
|
-
/** @public */
|
|
22
|
-
triggerLabel: string;
|
|
23
|
-
/** @public */
|
|
24
|
-
doneLabel: string;
|
|
14
|
+
export interface GitHubIssueOriginParams extends RepositoryIssueOriginParams {
|
|
25
15
|
}
|
|
26
16
|
/** @public */
|
|
27
|
-
export interface GitHubUiOriginParams {
|
|
28
|
-
/** @public */
|
|
29
|
-
origin: "ui";
|
|
30
|
-
/** @public */
|
|
31
|
-
issueNumber: null;
|
|
32
|
-
/** @public */
|
|
33
|
-
issueUrl: null;
|
|
34
|
-
/** @public */
|
|
35
|
-
triggerLabel: null;
|
|
36
|
-
/** @public */
|
|
37
|
-
doneLabel: null;
|
|
17
|
+
export interface GitHubUiOriginParams extends RepositoryUiOriginParams {
|
|
38
18
|
}
|
|
39
19
|
/** @public */
|
|
40
20
|
export type GitHubRepoChangeParams = RepositoryChangeLaunchParams<GitHubRepoChangeCommonParams & (GitHubIssueOriginParams | GitHubUiOriginParams)>;
|
package/dist/params.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,MAAM,+CAA+C,CAAC;AAEvD,cAAc;AACd,UAAU,4BAA4B;IACrC,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;CACb;AAED,cAAc;AACd,MAAM,WAAW,uBAAwB,SAAQ,2BAA2B;CAAG;AAE/E,cAAc;AACd,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;CAAG;AAEzE,cAAc;AACd,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,CAChE,4BAA4B,GAAG,CAAC,uBAAuB,GAAG,oBAAoB,CAAC,CAC/E,CAAC;AAEF,cAAc;AACd,wBAAgB,aAAa,CAC5B,MAAM,EAAE,sBAAsB,GAC5B,MAAM,IAAI,sBAAsB,GAAG,uBAAuB,CAE5D;AAED,cAAc;AACd,eAAO,MAAM,2BAA2B,mEAUrC,CAAC"}
|
package/dist/process.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
|
|
2
|
-
import {
|
|
2
|
+
import type { createGitHubRepoChangeLauncher } from "./launcher.js";
|
|
3
3
|
import { type GitHubRepoChangeParams } from "./params.js";
|
|
4
4
|
/** @public */
|
|
5
5
|
export declare function createGitHubRepoChangeProcess(launcher: ReturnType<typeof createGitHubRepoChangeLauncher>, docker: boolean): import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<GitHubRepoChangeParams, RepositoryChangeState>;
|
package/dist/process.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACN,KAAK,sBAAsB,EAG3B,MAAM,aAAa,CAAC;AAwBrB,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,iHAkIf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,cAAc;AACd,MAAM,WAAW,cAAc;IAC9B,cAAc;IACd,gBAAgB,EAAE,MAAM,CAAC;CACzB;AACD,cAAc;AACd,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAEjF,cAAc;AACd,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAIlE;AACD,cAAc;AACd,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAIhG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/github-repo-change",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"leitwerk": {
|
|
6
6
|
"extension": {
|
|
@@ -20,12 +20,11 @@
|
|
|
20
20
|
"build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@leitwerk-dev/coding": "0.3.
|
|
24
|
-
"@leitwerk-dev/external-writes": "0.3.
|
|
25
|
-
"@leitwerk-dev/git-ssh": "0.3.
|
|
26
|
-
"@leitwerk-dev/process-sdk": "0.3.
|
|
27
|
-
"@leitwerk-dev/github": "0.3.
|
|
28
|
-
"@leitwerk-dev/repository-rebase": "0.3.0"
|
|
23
|
+
"@leitwerk-dev/coding": "0.3.1",
|
|
24
|
+
"@leitwerk-dev/external-writes": "0.3.1",
|
|
25
|
+
"@leitwerk-dev/git-ssh": "0.3.1",
|
|
26
|
+
"@leitwerk-dev/process-sdk": "0.3.1",
|
|
27
|
+
"@leitwerk-dev/github": "0.3.1"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"tsup": "^8.5.1"
|
package/src/launcher.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
|
|
2
|
-
import { trimString } from "@leitwerk-dev/domain";
|
|
3
|
-
import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
4
|
-
import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
|
|
5
1
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "@leitwerk-dev/process-sdk";
|
|
2
|
+
createRepositoryChangeUiLauncher,
|
|
3
|
+
repositoryVisibilityCheck,
|
|
4
|
+
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
5
|
+
import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
6
|
+
import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
|
|
7
|
+
import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
|
|
12
8
|
import { type GitHubRepoChangeParams, isIssueOrigin } from "./params.js";
|
|
13
9
|
import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
|
|
14
10
|
|
|
@@ -105,70 +101,22 @@ export function createGitHubRepoChangeLauncher() {
|
|
|
105
101
|
return dependencies;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
|
-
function sshPreparationCheck(
|
|
109
|
-
access: "read" | "write",
|
|
110
|
-
params: GitHubRepoChangeParams,
|
|
111
|
-
): LaunchPreparationCheck<GitHubRepoChangeParams> {
|
|
112
|
-
return {
|
|
113
|
-
id: `ssh_${access}`,
|
|
114
|
-
label: `Verify SSH ${access} access`,
|
|
115
|
-
async run({ signal, logger }) {
|
|
116
|
-
signal.throwIfAborted();
|
|
117
|
-
const result = await requireDependencies().gitSsh.preflight({
|
|
118
|
-
credentialRef: params.sshCredentialRef,
|
|
119
|
-
repoLocator: params.repoLocator,
|
|
120
|
-
baseBranch: params.baseBranch,
|
|
121
|
-
requireWrite: access === "write",
|
|
122
|
-
});
|
|
123
|
-
signal.throwIfAborted();
|
|
124
|
-
if (!result.ok) {
|
|
125
|
-
logger.warn(`Git SSH ${result.access} preflight failed: ${result.detail}`);
|
|
126
|
-
throw new SafeLaunchPreparationError(
|
|
127
|
-
`SSH ${result.access} access failed: ${result.detail}`,
|
|
128
|
-
`Authorize Git SSH profile '${params.sshCredentialRef}' for '${params.owner}/${params.repo}' with read/write access, then try again.`,
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
104
|
/** @public */
|
|
136
105
|
function githubRepositoryPreparationChecks(
|
|
137
106
|
_input: unknown,
|
|
138
107
|
{ params }: ProcessLaunchConfig<GitHubRepoChangeParams>,
|
|
139
108
|
): readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] {
|
|
140
109
|
return [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
(candidate) => candidate.full_name === repositoryName,
|
|
149
|
-
);
|
|
150
|
-
signal.throwIfAborted();
|
|
151
|
-
if (!visible) {
|
|
152
|
-
throw new SafeLaunchPreparationError(
|
|
153
|
-
"Repository is not visible",
|
|
154
|
-
"Grant the selected GitHub profile access to the repository, then try again.",
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
sshPreparationCheck("read", params),
|
|
160
|
-
sshPreparationCheck("write", params),
|
|
110
|
+
repositoryVisibilityCheck("GitHub", async () =>
|
|
111
|
+
(await repositories(params.githubProfile)).some(
|
|
112
|
+
(candidate) => candidate.full_name === `${params.owner}/${params.repo}`,
|
|
113
|
+
),
|
|
114
|
+
),
|
|
115
|
+
createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
|
|
116
|
+
createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh),
|
|
161
117
|
];
|
|
162
118
|
}
|
|
163
119
|
|
|
164
|
-
function validationError(
|
|
165
|
-
fieldId: string,
|
|
166
|
-
message: string,
|
|
167
|
-
code: LauncherValidationError["code"] = "required",
|
|
168
|
-
): LauncherValidationError {
|
|
169
|
-
return { code, fieldId, message };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
120
|
/** @public */
|
|
173
121
|
function resolveProfiles(profile: string) {
|
|
174
122
|
const { github, gitSsh, profileBindings = {} } = requireDependencies();
|
|
@@ -194,123 +142,19 @@ export function createGitHubRepoChangeLauncher() {
|
|
|
194
142
|
return github.client(profile).listRepositories();
|
|
195
143
|
}
|
|
196
144
|
|
|
197
|
-
const githubRepoChangeUiLauncher
|
|
145
|
+
const githubRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
|
|
198
146
|
id: githubRepoChangeUiLauncherId,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
fields: [
|
|
211
|
-
{
|
|
212
|
-
id: "githubProfile",
|
|
213
|
-
label: "GitHub profile",
|
|
214
|
-
kind: "select",
|
|
215
|
-
required: true,
|
|
216
|
-
description: "GitHub profile with server-configured CI and Git SSH access.",
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: "repository",
|
|
220
|
-
label: "Repository",
|
|
221
|
-
kind: "select",
|
|
222
|
-
required: true,
|
|
223
|
-
description: "Repository visible to the selected GitHub profile.",
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: "prompt",
|
|
227
|
-
label: "Requested change",
|
|
228
|
-
kind: "textarea",
|
|
229
|
-
required: true,
|
|
230
|
-
placeholder: "Describe the change to plan, implement, review, and publish.",
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
submitLabel: "Start change",
|
|
234
|
-
},
|
|
235
|
-
resolveDefaults() {
|
|
236
|
-
return {
|
|
237
|
-
githubProfile: (requireDependencies().github.profiles?.() ?? [])[0] ?? "",
|
|
238
|
-
repository: "",
|
|
239
|
-
prompt: "",
|
|
240
|
-
};
|
|
241
|
-
},
|
|
242
|
-
async resolveOptions(input) {
|
|
243
|
-
const { github } = requireDependencies();
|
|
244
|
-
const profile = trimString(input.githubProfile);
|
|
245
|
-
return {
|
|
246
|
-
githubProfile: (github.profiles?.() ?? []).map((value) => ({ value, label: value })),
|
|
247
|
-
repository: (await repositories(profile)).map((repository) => ({
|
|
248
|
-
value: repository.full_name,
|
|
249
|
-
label: repository.full_name,
|
|
250
|
-
description: repository.html_url,
|
|
251
|
-
})),
|
|
252
|
-
};
|
|
253
|
-
},
|
|
254
|
-
preparationChecks: githubRepositoryPreparationChecks,
|
|
255
|
-
resolveRelaunchInput(previousInput) {
|
|
256
|
-
return {
|
|
257
|
-
githubProfile: trimString(previousInput.githubProfile),
|
|
258
|
-
repository: trimString(previousInput.repository),
|
|
259
|
-
prompt: trimString(previousInput.prompt),
|
|
260
|
-
};
|
|
261
|
-
},
|
|
262
|
-
async resolveLaunchConfig(input) {
|
|
263
|
-
const profile = trimString(input.githubProfile);
|
|
264
|
-
const repositoryName = trimString(input.repository);
|
|
265
|
-
const prompt = trimString(input.prompt);
|
|
266
|
-
const errors: LauncherValidationError[] = [];
|
|
267
|
-
const invalid = (fieldId: string, message: string) => ({
|
|
268
|
-
ok: false as const,
|
|
269
|
-
errors: [validationError(fieldId, message, "custom_rule")],
|
|
270
|
-
});
|
|
271
|
-
const { github } = requireDependencies();
|
|
272
|
-
if (!profile) errors.push(validationError("githubProfile", "GitHub profile is required"));
|
|
273
|
-
else if (!(github.profiles?.() ?? []).includes(profile))
|
|
274
|
-
errors.push(
|
|
275
|
-
validationError("githubProfile", "GitHub profile is not available", "custom_rule"),
|
|
276
|
-
);
|
|
277
|
-
if (!repositoryName) errors.push(validationError("repository", "Repository is required"));
|
|
278
|
-
if (!prompt) errors.push(validationError("prompt", "Requested change is required"));
|
|
279
|
-
if (errors.length > 0) return { ok: false, errors };
|
|
280
|
-
|
|
281
|
-
const repository = (await repositories(profile)).find(
|
|
282
|
-
(candidate) => candidate.full_name === repositoryName,
|
|
283
|
-
);
|
|
284
|
-
if (!repository)
|
|
285
|
-
return invalid(
|
|
286
|
-
"repository",
|
|
287
|
-
"Repository is not available to the selected GitHub profile",
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
let binding: ReturnType<typeof resolveProfiles>;
|
|
291
|
-
try {
|
|
292
|
-
binding = resolveProfiles(profile);
|
|
293
|
-
} catch (error) {
|
|
294
|
-
return invalid("githubProfile", (error as Error).message);
|
|
295
|
-
}
|
|
296
|
-
const gitIdentity = await resolveGitHubGitIdentity(profile);
|
|
297
|
-
const workBranch = buildAutoWorkBranchFromSeed(
|
|
298
|
-
prompt,
|
|
299
|
-
`${repository.ssh_url}:${repository.default_branch}`,
|
|
300
|
-
);
|
|
301
|
-
const params = githubRepoChangeParams(repository, {
|
|
302
|
-
...binding,
|
|
303
|
-
profile,
|
|
304
|
-
prompt,
|
|
305
|
-
workBranch,
|
|
306
|
-
});
|
|
307
|
-
return {
|
|
308
|
-
ok: true,
|
|
309
|
-
launchConfig: githubRepoChangeLaunchConfig(params, prompt, gitIdentity),
|
|
310
|
-
};
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
};
|
|
147
|
+
provider: "GitHub",
|
|
148
|
+
providerId: "github",
|
|
149
|
+
assertConfigured: requireDependencies,
|
|
150
|
+
profiles: () => requireDependencies().github.profiles?.() ?? [],
|
|
151
|
+
repositories,
|
|
152
|
+
resolveProfiles,
|
|
153
|
+
resolveGitIdentity: resolveGitHubGitIdentity,
|
|
154
|
+
params: githubRepoChangeParams,
|
|
155
|
+
launchConfig: githubRepoChangeLaunchConfig,
|
|
156
|
+
preparationChecks: githubRepositoryPreparationChecks,
|
|
157
|
+
});
|
|
314
158
|
|
|
315
159
|
return {
|
|
316
160
|
/** @public */
|
package/src/params.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRepositoryChangeParamsCodec,
|
|
3
|
-
|
|
3
|
+
normalizeRepositoryIssueChangeParams,
|
|
4
4
|
type RepositoryChangeLaunchParams,
|
|
5
|
-
|
|
5
|
+
type RepositoryIssueOriginParams,
|
|
6
|
+
type RepositoryUiOriginParams,
|
|
6
7
|
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
7
|
-
import { trimString } from "@leitwerk-dev/domain";
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
10
10
|
interface GitHubRepoChangeCommonParams {
|
|
@@ -19,32 +19,10 @@ interface GitHubRepoChangeCommonParams {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** @public */
|
|
22
|
-
export interface GitHubIssueOriginParams {
|
|
23
|
-
/** @public */
|
|
24
|
-
origin: "issue";
|
|
25
|
-
/** @public */
|
|
26
|
-
issueNumber: number;
|
|
27
|
-
/** @public */
|
|
28
|
-
issueUrl: string;
|
|
29
|
-
/** @public */
|
|
30
|
-
triggerLabel: string;
|
|
31
|
-
/** @public */
|
|
32
|
-
doneLabel: string;
|
|
33
|
-
}
|
|
22
|
+
export interface GitHubIssueOriginParams extends RepositoryIssueOriginParams {}
|
|
34
23
|
|
|
35
24
|
/** @public */
|
|
36
|
-
export interface GitHubUiOriginParams {
|
|
37
|
-
/** @public */
|
|
38
|
-
origin: "ui";
|
|
39
|
-
/** @public */
|
|
40
|
-
issueNumber: null;
|
|
41
|
-
/** @public */
|
|
42
|
-
issueUrl: null;
|
|
43
|
-
/** @public */
|
|
44
|
-
triggerLabel: null;
|
|
45
|
-
/** @public */
|
|
46
|
-
doneLabel: null;
|
|
47
|
-
}
|
|
25
|
+
export interface GitHubUiOriginParams extends RepositoryUiOriginParams {}
|
|
48
26
|
|
|
49
27
|
/** @public */
|
|
50
28
|
export type GitHubRepoChangeParams = RepositoryChangeLaunchParams<
|
|
@@ -62,49 +40,11 @@ export function isIssueOrigin(
|
|
|
62
40
|
export const githubRepoChangeParamsCodec =
|
|
63
41
|
createRepositoryChangeParamsCodec<GitHubRepoChangeParams>({
|
|
64
42
|
normalize(value) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const common = {
|
|
74
|
-
...shared,
|
|
75
|
-
githubProfile: text("githubProfile"),
|
|
76
|
-
sshCredentialRef: text("sshCredentialRef"),
|
|
77
|
-
owner: text("owner"),
|
|
78
|
-
repo: text("repo"),
|
|
79
|
-
};
|
|
80
|
-
const origin = trimString(record.origin);
|
|
81
|
-
if (origin === "ui") {
|
|
82
|
-
return {
|
|
83
|
-
...common,
|
|
84
|
-
origin: "ui" as const,
|
|
85
|
-
issueNumber: null,
|
|
86
|
-
issueUrl: null,
|
|
87
|
-
triggerLabel: null,
|
|
88
|
-
doneLabel: null,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
if (origin && origin !== "issue") {
|
|
92
|
-
throw new Error("GitHub Repo Change requires a valid origin");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
typeof record.issueNumber !== "number" ||
|
|
97
|
-
!Number.isInteger(record.issueNumber) ||
|
|
98
|
-
record.issueNumber <= 0
|
|
99
|
-
)
|
|
100
|
-
throw new Error("GitHub Repo Change requires issueNumber");
|
|
101
|
-
return {
|
|
102
|
-
...common,
|
|
103
|
-
origin: "issue" as const,
|
|
104
|
-
issueNumber: record.issueNumber,
|
|
105
|
-
issueUrl: text("issueUrl"),
|
|
106
|
-
triggerLabel: text("triggerLabel"),
|
|
107
|
-
doneLabel: text("doneLabel"),
|
|
108
|
-
};
|
|
43
|
+
return normalizeRepositoryIssueChangeParams(value, "GitHub Repo Change", [
|
|
44
|
+
"githubProfile",
|
|
45
|
+
"sshCredentialRef",
|
|
46
|
+
"owner",
|
|
47
|
+
"repo",
|
|
48
|
+
]);
|
|
109
49
|
},
|
|
110
50
|
});
|