@leitwerk-dev/github-repo-change 0.3.0 → 0.4.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.
@@ -1,23 +1,15 @@
1
- import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
1
+ import { type PullRequestChangeLaunchInput } from "@leitwerk-dev/coding/repository-change-launch";
2
+ import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
2
3
  import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
3
- import { type LaunchPreparationCheck, type ProcessLaunchConfig, type ProcessLauncherDefinition } from "@leitwerk-dev/process-sdk";
4
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
5
  import { type GitHubRepoChangeParams } from "./params.js";
5
6
  import { type ProfileBindings } from "./profile-bindings.js";
6
7
  /** @public */
7
8
  export declare const githubRepoChangeUiLauncherId: "github_repo_change_process.ui_launcher";
8
9
  /** @public */
9
- export declare function githubRepoChangeParams(repository: GitHubRepository, input: {
10
- /** @public */
11
- profile: string;
12
- /** @public */
13
- sshCredentialRef: string;
14
- /** @public */
15
- prompt: string;
16
- /** @public */
17
- workBranch: string;
18
- }): GitHubRepoChangeParams;
10
+ export declare function githubRepoChangeParams(repository: GitHubRepository, input: PullRequestChangeLaunchInput): GitHubRepoChangeParams;
19
11
  /** @public */
20
- export declare function githubRepoChangeLaunchConfig(params: GitHubRepoChangeParams, title: string, gitIdentity: GitHubGitIdentity): ProcessLaunchConfig<GitHubRepoChangeParams>;
12
+ export declare function githubRepoChangeLaunchConfig(params: GitHubRepoChangeParams, title: string, gitIdentity: GitHubGitIdentity, repository?: GitHubRepository): ProcessLaunchConfig<GitHubRepoChangeParams>;
21
13
  /** @public */
22
14
  export interface LauncherDependencies {
23
15
  /** @public */
@@ -29,15 +21,29 @@ export interface LauncherDependencies {
29
21
  }
30
22
  /** @public */
31
23
  export declare function createGitHubRepoChangeLauncher(): {
32
- /** @public */
33
- configure: (value: LauncherDependencies | null) => void;
34
- /** @public */
35
- preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) => readonly LaunchPreparationCheck<GitHubRepoChangeParams>[];
36
- /** @public */
24
+ /** @internal */
25
+ configure(value: LauncherDependencies | null): void;
26
+ /** @internal */
27
+ preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) => import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<GitHubRepoChangeParams>[];
28
+ /** @internal */
37
29
  resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
38
- /** @public */
30
+ /** @internal */
39
31
  resolveGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
40
- /** @public */
41
- launcher: ProcessLauncherDefinition<GitHubRepoChangeParams>;
32
+ /** @internal */
33
+ launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
34
+ /** @internal */
35
+ resolveIssueLaunchConfig(event: {
36
+ /** @internal */
37
+ profile: string;
38
+ /** @internal */
39
+ repository: GitHubRepository;
40
+ /** @internal */
41
+ issue: Pick<import("@leitwerk-dev/github").GitHubIssue, "number" | "title" | "body" | "html_url">;
42
+ /** @internal */
43
+ labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
44
+ }): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
45
+ };
46
+ /** @internal */
47
+ workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<GitHubRepoChangeParams>;
42
48
  };
43
49
  //# sourceMappingURL=launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC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"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,4BAA4B,EAEjC,MAAM,+CAA+C,CAAC;AACvD,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,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,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,4BAA4B,GACjC,sBAAsB,CAgBxB;AAED,cAAc;AACd,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,iBAAiB,EAC9B,UAAU,CAAC,EAAE,gBAAgB,GAC3B,mBAAmB,CAAC,sBAAsB,CAAC,CAc7C;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;;;;;;;;;;;;;;;;;;;;;;;;;EAmB7C"}
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)>;
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EAEjC,MAAM,+CAA+C,CAAC;AAGvD,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,uBAAuB;IACvC,cAAc;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,cAAc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;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 { type createGitHubRepoChangeLauncher } from "./launcher.js";
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>;
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAQ1F,OAAO,EACN,KAAK,8BAA8B,EAGnC,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,sBAAsB,EAG3B,MAAM,aAAa,CAAC;AA8DrB,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,iHA0Sf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAOA,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;AAIrB,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,iHAgFf"}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"AAAA,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;AAajF,cAAc;AACd,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAyBlE;AACD,cAAc;AACd,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAIhG"}
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.0",
3
+ "version": "0.4.0",
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.0",
24
- "@leitwerk-dev/external-writes": "0.3.0",
25
- "@leitwerk-dev/git-ssh": "0.3.0",
26
- "@leitwerk-dev/process-sdk": "0.3.0",
27
- "@leitwerk-dev/github": "0.3.0",
28
- "@leitwerk-dev/repository-rebase": "0.3.0"
23
+ "@leitwerk-dev/coding": "0.4.0",
24
+ "@leitwerk-dev/external-writes": "0.4.0",
25
+ "@leitwerk-dev/git-ssh": "0.4.0",
26
+ "@leitwerk-dev/process-sdk": "0.4.0",
27
+ "@leitwerk-dev/github": "0.4.0"
29
28
  },
30
29
  "devDependencies": {
31
30
  "tsup": "^8.5.1"
package/src/index.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { gitSshIntegration } from "@leitwerk-dev/git-ssh";
2
- import { githubIntegration } from "@leitwerk-dev/github";
3
- import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
4
- import { createGitHubRepoChangeLauncher } from "./launcher.js";
2
+ import { type GitHubGitIdentity, githubIntegration } from "@leitwerk-dev/github";
3
+ import type {
4
+ LaunchPreparationCheck,
5
+ LeitwerkExtensionModule,
6
+ ProcessLaunchConfig,
7
+ } from "@leitwerk-dev/process-sdk";
8
+ import { createGitHubRepoChangeLauncher, type LauncherDependencies } from "./launcher.js";
9
+ import type { GitHubRepoChangeParams } from "./params.js";
5
10
  import { createGitHubRepoChangeProcess } from "./process.js";
6
11
  import { parseProfileBindings } from "./profile-bindings.js";
7
12
 
@@ -66,10 +71,17 @@ export const {
66
71
  launcher: defaultGitHubRepoChangeLauncher,
67
72
  } = createGitHubRepoChange({ docker: true });
68
73
  /** @public */
69
- export const {
70
- configure: configureGitHubRepoChangeLauncher,
71
- preparationChecks: githubRepositoryPreparationChecks,
72
- resolveGitIdentity: resolveGitHubGitIdentity,
73
- launcher: githubRepoChangeUiLauncher,
74
- } = defaultGitHubRepoChangeLauncher;
74
+ export const configureGitHubRepoChangeLauncher: (value: LauncherDependencies | null) => void =
75
+ defaultGitHubRepoChangeLauncher.configure;
76
+ /** @public */
77
+ export const githubRepositoryPreparationChecks: (
78
+ input: unknown,
79
+ launch: ProcessLaunchConfig<GitHubRepoChangeParams>,
80
+ ) => readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] =
81
+ defaultGitHubRepoChangeLauncher.preparationChecks;
82
+ /** @public */
83
+ export const resolveGitHubGitIdentity: (profile: string) => Promise<GitHubGitIdentity> =
84
+ defaultGitHubRepoChangeLauncher.resolveGitIdentity;
85
+ /** @public */
86
+ export const githubRepoChangeUiLauncher = defaultGitHubRepoChangeLauncher.launcher;
75
87
  export default defaultExtension;
package/src/launcher.ts CHANGED
@@ -1,14 +1,11 @@
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
- type LauncherValidationError,
7
- type LaunchPreparationCheck,
8
- type ProcessLaunchConfig,
9
- type ProcessLauncherDefinition,
10
- SafeLaunchPreparationError,
11
- } from "@leitwerk-dev/process-sdk";
2
+ createRepositoryChangeLauncher,
3
+ type PullRequestChangeLaunchInput,
4
+ repositoryIssueChangeLaunchConfig,
5
+ } from "@leitwerk-dev/coding/repository-change-launch";
6
+ import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
7
+ import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
8
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
12
9
  import { type GitHubRepoChangeParams, isIssueOrigin } from "./params.js";
13
10
  import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
14
11
 
@@ -18,16 +15,7 @@ export const githubRepoChangeUiLauncherId = "github_repo_change_process.ui_launc
18
15
  /** @public */
19
16
  export function githubRepoChangeParams(
20
17
  repository: GitHubRepository,
21
- input: {
22
- /** @public */
23
- profile: string;
24
- /** @public */
25
- sshCredentialRef: string;
26
- /** @public */
27
- prompt: string;
28
- /** @public */
29
- workBranch: string;
30
- },
18
+ input: PullRequestChangeLaunchInput,
31
19
  ): GitHubRepoChangeParams {
32
20
  return {
33
21
  repoLocator: repository.ssh_url,
@@ -51,34 +39,21 @@ export function githubRepoChangeLaunchConfig(
51
39
  params: GitHubRepoChangeParams,
52
40
  title: string,
53
41
  gitIdentity: GitHubGitIdentity,
42
+ repository?: GitHubRepository,
54
43
  ): ProcessLaunchConfig<GitHubRepoChangeParams> {
55
44
  const { owner, repo, githubProfile: profile } = params;
56
45
  const issue = isIssueOrigin(params);
57
- return {
58
- processId: "github_repo_change_process",
46
+ return repositoryIssueChangeLaunchConfig(
47
+ "github",
59
48
  params,
60
49
  title,
61
- startTurnId: "generate_plan",
62
- ...(issue
63
- ? {
64
- externalId: `github:${owner}/${repo}#${params.issueNumber}`,
65
- externalUrl: params.issueUrl,
66
- }
67
- : {}),
68
- projects: [
69
- {
70
- key: "repo",
71
- repoLocator: params.repoLocator,
72
- baseBranch: params.baseBranch,
73
- workBranch: params.workBranch,
74
- ...(issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {}),
75
- metadata: {
76
- github: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
77
- "leitwerk.gitIdentity": gitIdentity,
78
- },
79
- },
80
- ],
81
- };
50
+ `${owner}/${repo}`,
51
+ {
52
+ github: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
53
+ "leitwerk.gitIdentity": gitIdentity,
54
+ },
55
+ repository,
56
+ );
82
57
  }
83
58
 
84
59
  /** @public */
@@ -93,235 +68,22 @@ export interface LauncherDependencies {
93
68
 
94
69
  /** @public */
95
70
  export function createGitHubRepoChangeLauncher() {
96
- let dependencies: LauncherDependencies | null = null;
97
-
98
- /** @public */
99
- function configureGitHubRepoChangeLauncher(value: LauncherDependencies | null): void {
100
- dependencies = value;
101
- }
102
-
103
- function requireDependencies(): LauncherDependencies {
104
- if (!dependencies) throw new Error("GitHub repository launcher is not configured");
105
- return dependencies;
106
- }
107
-
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
- /** @public */
136
- function githubRepositoryPreparationChecks(
137
- _input: unknown,
138
- { params }: ProcessLaunchConfig<GitHubRepoChangeParams>,
139
- ): readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] {
140
- return [
141
- {
142
- id: "repository_visibility",
143
- label: "Check repository visibility",
144
- async run({ signal }) {
145
- signal.throwIfAborted();
146
- const repositoryName = `${params.owner}/${params.repo}`;
147
- const visible = (await repositories(params.githubProfile)).some(
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),
161
- ];
162
- }
163
-
164
- function validationError(
165
- fieldId: string,
166
- message: string,
167
- code: LauncherValidationError["code"] = "required",
168
- ): LauncherValidationError {
169
- return { code, fieldId, message };
170
- }
171
-
172
- /** @public */
173
- function resolveProfiles(profile: string) {
174
- const { github, gitSsh, profileBindings = {} } = requireDependencies();
175
- if (!(github.profiles?.() ?? []).includes(profile))
176
- throw new Error("GitHub profile is not available");
177
- const binding = resolveProfileBinding(profileBindings, profile);
178
-
179
- if (!gitSsh.profiles().includes(binding.sshCredentialRef))
180
- throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
181
- return binding;
182
- }
183
-
184
- /** @public */
185
- async function resolveGitHubGitIdentity(profile: string): Promise<GitHubGitIdentity> {
186
- if (!profile) throw new Error("A GitHub profile is required to resolve Git identity");
187
- return requireDependencies().github.client(profile).resolveGitIdentity(profile);
188
- }
189
-
190
- async function repositories(profile: string): Promise<readonly GitHubRepository[]> {
191
- if (!profile) return [];
192
- const { github } = requireDependencies();
193
- if (!(github.profiles?.() ?? []).includes(profile)) return [];
194
- return github.client(profile).listRepositories();
195
- }
196
-
197
- const githubRepoChangeUiLauncher: ProcessLauncherDefinition<GitHubRepoChangeParams> = {
71
+ return createRepositoryChangeLauncher({
198
72
  id: githubRepoChangeUiLauncherId,
199
- label: "GitHub Repo Change",
200
- description: "Plan, implement, review, and publish a GitHub change without a source issue",
201
- visibility: "ui",
202
- ui: {
203
- card: {
204
- title: "GitHub Repo Change",
205
- description: "Start a repository change and publish it as a GitHub pull request.",
206
- },
207
- launchConfigSchema: {
208
- id: "github_repo_change_form",
209
- title: "GitHub Repo Change",
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
- },
73
+ provider: "GitHub",
74
+ providerId: "github",
75
+ integration: (deps: LauncherDependencies) => deps.github,
76
+ profile: (params: GitHubRepoChangeParams) => params.githubProfile,
77
+ params: githubRepoChangeParams,
78
+ launchConfig: githubRepoChangeLaunchConfig,
79
+ resolveProfiles(profile, { gitSsh, profileBindings = {} }) {
80
+ const binding = resolveProfileBinding(profileBindings, profile);
81
+ if (!gitSsh.profiles().includes(binding.sshCredentialRef))
82
+ throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
83
+ return binding;
312
84
  },
313
- };
314
-
315
- return {
316
- /** @public */
317
- configure: configureGitHubRepoChangeLauncher,
318
- /** @public */
319
- preparationChecks: githubRepositoryPreparationChecks,
320
- /** @public */
321
- resolveProfiles,
322
- /** @public */
323
- resolveGitIdentity: resolveGitHubGitIdentity,
324
- /** @public */
325
- launcher: githubRepoChangeUiLauncher,
326
- };
85
+ preparationChecks: (params, dependencies) => [
86
+ createGitSshPreparationCheck("write", params, () => dependencies().gitSsh),
87
+ ],
88
+ });
327
89
  }
package/src/params.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createRepositoryChangeParamsCodec,
3
- normalizeRepositoryChangeParamsInput,
3
+ normalizeRepositoryIssueChangeParams,
4
4
  type RepositoryChangeLaunchParams,
5
- repositoryChangeParamsRecord,
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
- const shared = normalizeRepositoryChangeParamsInput(value, "GitHub Repo Change");
66
- const record = repositoryChangeParamsRecord(value, "GitHub Repo Change");
67
- const text = (name: string) => {
68
- const value = trimString(record[name]);
69
- if (!value) throw new Error(`GitHub Repo Change requires ${name}`);
70
- return value;
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
  });