@leitwerk-dev/forgejo-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,26 +1,19 @@
1
+ import { type PullRequestChangeLaunchInput } from "@leitwerk-dev/coding/repository-change-launch";
1
2
  import type { ForgejoGitIdentity, ForgejoIntegration, ForgejoRepository } from "@leitwerk-dev/forgejo";
2
- import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
- import { type LaunchPreparationCheck, type ProcessLaunchConfig, type ProcessLauncherDefinition } from "@leitwerk-dev/process-sdk";
3
+ import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
4
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
5
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
5
6
  import { type ForgejoRepoChangeParams } from "./params.js";
6
7
  import { type ProfileBindings } from "./profile-bindings.js";
7
8
  /** @internal */
8
9
  export declare const forgejoRepoChangeUiLauncherId: "forgejo_repo_change_process.ui_launcher";
9
10
  /** @internal */
10
- export declare function forgejoRepoChangeParams(repository: ForgejoRepository, input: {
11
- /** @internal */
12
- profile: string;
11
+ export declare function forgejoRepoChangeParams(repository: ForgejoRepository, input: PullRequestChangeLaunchInput & {
13
12
  /** @internal */
14
13
  woodpeckerProfile: string;
15
- /** @internal */
16
- sshCredentialRef: string;
17
- /** @internal */
18
- prompt: string;
19
- /** @internal */
20
- workBranch: string;
21
14
  }): ForgejoRepoChangeParams;
22
15
  /** @internal */
23
- export declare function forgejoRepoChangeLaunchConfig(params: ForgejoRepoChangeParams, title: string, gitIdentity: ForgejoGitIdentity): ProcessLaunchConfig<ForgejoRepoChangeParams>;
16
+ export declare function forgejoRepoChangeLaunchConfig(params: ForgejoRepoChangeParams, title: string, gitIdentity: ForgejoGitIdentity, repository?: ForgejoRepository): ProcessLaunchConfig<ForgejoRepoChangeParams>;
24
17
  /** @internal */
25
18
  export interface LauncherDependencies {
26
19
  /** @internal */
@@ -34,15 +27,18 @@ export interface LauncherDependencies {
34
27
  }
35
28
  /** @internal */
36
29
  export declare function createForgejoRepoChangeLauncher(): {
37
- /** @internal */
38
- configure: (value: LauncherDependencies | null) => void;
39
- /** @internal */
40
- preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>) => readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[];
41
- /** @internal */
30
+ configure(value: LauncherDependencies | null): void;
31
+ preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>) => import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<ForgejoRepoChangeParams>[];
42
32
  resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
43
- /** @internal */
44
33
  resolveGitIdentity: (profile: string) => Promise<ForgejoGitIdentity>;
45
- /** @internal */
46
- launcher: ProcessLauncherDefinition<ForgejoRepoChangeParams>;
34
+ launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<ForgejoRepoChangeParams> & {
35
+ resolveIssueLaunchConfig(event: {
36
+ profile: string;
37
+ repository: ForgejoRepository;
38
+ issue: Pick<import("@leitwerk-dev/forgejo").ForgejoIssue, "number" | "title" | "body" | "html_url">;
39
+ labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
40
+ }): Promise<ProcessLaunchConfig<ForgejoRepoChangeParams>>;
41
+ };
42
+ workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<ForgejoRepoChangeParams>;
47
43
  };
48
44
  //# sourceMappingURL=launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;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M,EAAE,iBAAiB,CAAC;IAC1B,gBAAgB;IAChB,UAAU,EAAE,qBAAqB,CAAC;IAClC,gBAAgB;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B;;;;;;;;;;;;;;EAwB9C"}
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 ForgejoRepoChangeCommonParams {
4
4
  /** @internal */
@@ -13,30 +13,10 @@ interface ForgejoRepoChangeCommonParams {
13
13
  repo: string;
14
14
  }
15
15
  /** @public */
16
- export interface ForgejoIssueOriginParams {
17
- /** @internal */
18
- origin: "issue";
19
- /** @internal */
20
- issueNumber: number;
21
- /** @internal */
22
- issueUrl: string;
23
- /** @internal */
24
- triggerLabel: string;
25
- /** @internal */
26
- doneLabel: string;
16
+ export interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {
27
17
  }
28
18
  /** @public */
29
- export interface ForgejoUiOriginParams {
30
- /** @internal */
31
- origin: "ui";
32
- /** @internal */
33
- issueNumber: null;
34
- /** @internal */
35
- issueUrl: null;
36
- /** @internal */
37
- triggerLabel: null;
38
- /** @internal */
39
- doneLabel: null;
19
+ export interface ForgejoUiOriginParams extends RepositoryUiOriginParams {
40
20
  }
41
21
  /** @public */
42
22
  export type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<ForgejoRepoChangeCommonParams & (ForgejoIssueOriginParams | ForgejoUiOriginParams)>;
@@ -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,6BAA6B;IACtC,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,6BAA6B;IACtC,gBAAgB;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,cAAc;AACd,MAAM,WAAW,wBAAyB,SAAQ,2BAA2B;CAAG;AAEhF,cAAc;AACd,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;CAAG;AAE1E,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,CACjE,6BAA6B,GAAG,CAAC,wBAAwB,GAAG,qBAAqB,CAAC,CAClF,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa,CAC5B,MAAM,EAAE,uBAAuB,GAC7B,MAAM,IAAI,uBAAuB,GAAG,wBAAwB,CAE9D;AAED,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,oEAWtC,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 createForgejoRepoChangeLauncher } from "./launcher.js";
2
+ import type { createForgejoRepoChangeLauncher } from "./launcher.js";
3
3
  import { type ForgejoRepoChangeParams } from "./params.js";
4
4
  /** @internal */
5
5
  export declare function createForgejoRepoChangeProcess(launcher: ReturnType<typeof createForgejoRepoChangeLauncher>, docker: boolean): import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<ForgejoRepoChangeParams, 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;AAS1F,OAAO,EACN,KAAK,+BAA+B,EAGpC,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AA8DrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHA2Sf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAG1F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAIrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHA+Ef"}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AACD,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAajF,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CA8BlE;AACD,gBAAgB;AAChB,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,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AACD,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAEjF,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAKlE;AACD,gBAAgB;AAChB,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/forgejo-repo-change",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -20,13 +20,12 @@
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/forgejo": "0.3.0",
28
- "@leitwerk-dev/woodpecker": "0.3.0",
29
- "@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/forgejo": "0.4.0",
28
+ "@leitwerk-dev/woodpecker": "0.4.0"
30
29
  },
31
30
  "devDependencies": {
32
31
  "tsup": "^8.5.1"
package/src/launcher.ts CHANGED
@@ -1,18 +1,15 @@
1
- import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
2
- import { trimString } from "@leitwerk-dev/domain";
1
+ import {
2
+ createRepositoryChangeLauncher,
3
+ type PullRequestChangeLaunchInput,
4
+ repositoryIssueChangeLaunchConfig,
5
+ } from "@leitwerk-dev/coding/repository-change-launch";
3
6
  import type {
4
7
  ForgejoGitIdentity,
5
8
  ForgejoIntegration,
6
9
  ForgejoRepository,
7
10
  } from "@leitwerk-dev/forgejo";
8
- import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
9
- import {
10
- type LauncherValidationError,
11
- type LaunchPreparationCheck,
12
- type ProcessLaunchConfig,
13
- type ProcessLauncherDefinition,
14
- SafeLaunchPreparationError,
15
- } from "@leitwerk-dev/process-sdk";
11
+ import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
12
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
16
13
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
17
14
  import { type ForgejoRepoChangeParams, isIssueOrigin } from "./params.js";
18
15
  import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
@@ -23,17 +20,9 @@ export const forgejoRepoChangeUiLauncherId = "forgejo_repo_change_process.ui_lau
23
20
  /** @internal */
24
21
  export function forgejoRepoChangeParams(
25
22
  repository: ForgejoRepository,
26
- input: {
27
- /** @internal */
28
- profile: string;
23
+ input: PullRequestChangeLaunchInput & {
29
24
  /** @internal */
30
25
  woodpeckerProfile: string;
31
- /** @internal */
32
- sshCredentialRef: string;
33
- /** @internal */
34
- prompt: string;
35
- /** @internal */
36
- workBranch: string;
37
26
  },
38
27
  ): ForgejoRepoChangeParams {
39
28
  return {
@@ -59,35 +48,22 @@ export function forgejoRepoChangeLaunchConfig(
59
48
  params: ForgejoRepoChangeParams,
60
49
  title: string,
61
50
  gitIdentity: ForgejoGitIdentity,
51
+ repository?: ForgejoRepository,
62
52
  ): ProcessLaunchConfig<ForgejoRepoChangeParams> {
63
53
  const { owner, repo, forgejoProfile: profile, woodpeckerProfile } = params;
64
54
  const issue = isIssueOrigin(params);
65
- return {
66
- processId: "forgejo_repo_change_process",
55
+ return repositoryIssueChangeLaunchConfig(
56
+ "forgejo",
67
57
  params,
68
58
  title,
69
- startTurnId: "generate_plan",
70
- ...(issue
71
- ? {
72
- externalId: `forgejo:${owner}/${repo}#${params.issueNumber}`,
73
- externalUrl: params.issueUrl,
74
- }
75
- : {}),
76
- projects: [
77
- {
78
- key: "repo",
79
- repoLocator: params.repoLocator,
80
- baseBranch: params.baseBranch,
81
- workBranch: params.workBranch,
82
- ...(issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {}),
83
- metadata: {
84
- forgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
85
- woodpecker: { owner, repo, profile: woodpeckerProfile },
86
- "leitwerk.gitIdentity": gitIdentity,
87
- },
88
- },
89
- ],
90
- };
59
+ `${owner}/${repo}`,
60
+ {
61
+ forgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
62
+ woodpecker: { owner, repo, profile: woodpeckerProfile },
63
+ "leitwerk.gitIdentity": gitIdentity,
64
+ },
65
+ repository,
66
+ );
91
67
  }
92
68
 
93
69
  /** @internal */
@@ -104,238 +80,27 @@ export interface LauncherDependencies {
104
80
 
105
81
  /** @internal */
106
82
  export function createForgejoRepoChangeLauncher() {
107
- let dependencies: LauncherDependencies | null = null;
108
-
109
- /** @internal */
110
- function configureForgejoRepoChangeLauncher(value: LauncherDependencies | null): void {
111
- dependencies = value;
112
- }
113
-
114
- function requireDependencies(): LauncherDependencies {
115
- if (!dependencies) throw new Error("Forgejo repository launcher is not configured");
116
- return dependencies;
117
- }
118
-
119
- function sshPreparationCheck(
120
- access: "read" | "write",
121
- params: ForgejoRepoChangeParams,
122
- ): LaunchPreparationCheck<ForgejoRepoChangeParams> {
123
- return {
124
- id: `ssh_${access}`,
125
- label: `Verify SSH ${access} access`,
126
- async run({ signal, logger }) {
127
- signal.throwIfAborted();
128
- const result = await requireDependencies().gitSsh.preflight({
129
- credentialRef: params.sshCredentialRef,
130
- repoLocator: params.repoLocator,
131
- baseBranch: params.baseBranch,
132
- requireWrite: access === "write",
133
- });
134
- signal.throwIfAborted();
135
- if (!result.ok) {
136
- logger.warn(`Git SSH ${result.access} preflight failed: ${result.detail}`);
137
- throw new SafeLaunchPreparationError(
138
- `SSH ${result.access} access failed: ${result.detail}`,
139
- `Authorize Git SSH profile '${params.sshCredentialRef}' for '${params.owner}/${params.repo}' with read/write access, then try again.`,
140
- );
141
- }
142
- },
143
- };
144
- }
145
-
146
- /** @internal */
147
- function forgejoRepositoryPreparationChecks(
148
- _input: unknown,
149
- { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>,
150
- ): readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[] {
151
- return [
152
- {
153
- id: "repository_visibility",
154
- label: "Check repository visibility",
155
- async run({ signal }) {
156
- signal.throwIfAborted();
157
- const repositoryName = `${params.owner}/${params.repo}`;
158
- const visible = (await repositories(params.forgejoProfile)).some(
159
- (candidate) => candidate.full_name === repositoryName,
160
- );
161
- signal.throwIfAborted();
162
- if (!visible) {
163
- throw new SafeLaunchPreparationError(
164
- "Repository is not visible",
165
- "Grant the selected Forgejo profile access to the repository, then try again.",
166
- );
167
- }
168
- },
169
- },
170
- sshPreparationCheck("read", params),
171
- sshPreparationCheck("write", params),
172
- ];
173
- }
174
-
175
- function validationError(
176
- fieldId: string,
177
- message: string,
178
- code: LauncherValidationError["code"] = "required",
179
- ): LauncherValidationError {
180
- return { code, fieldId, message };
181
- }
182
-
183
- /** @internal */
184
- function resolveProfiles(profile: string) {
185
- const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
186
- if (!forgejo.profiles().includes(profile)) throw new Error("Forgejo profile is not available");
187
- const binding = resolveProfileBinding(profileBindings, profile);
188
- try {
189
- woodpecker.client(binding.woodpeckerProfile);
190
- } catch {
191
- throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
192
- }
193
- if (!gitSsh.profiles().includes(binding.sshCredentialRef))
194
- throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
195
- return binding;
196
- }
197
-
198
- /** @internal */
199
- async function resolveForgejoGitIdentity(profile: string): Promise<ForgejoGitIdentity> {
200
- if (!profile) throw new Error("A Forgejo profile is required to resolve Git identity");
201
- return requireDependencies().forgejo.client(profile).resolveGitIdentity(profile);
202
- }
203
-
204
- async function repositories(profile: string): Promise<readonly ForgejoRepository[]> {
205
- if (!profile) return [];
206
- const { forgejo } = requireDependencies();
207
- if (!forgejo.profiles().includes(profile)) return [];
208
- return forgejo.client(profile).listRepositories();
209
- }
210
-
211
- const forgejoRepoChangeUiLauncher: ProcessLauncherDefinition<ForgejoRepoChangeParams> = {
83
+ return createRepositoryChangeLauncher({
212
84
  id: forgejoRepoChangeUiLauncherId,
213
- label: "Forgejo Repo Change",
214
- description: "Plan, implement, review, and publish a Forgejo change without a source issue",
215
- visibility: "ui",
216
- ui: {
217
- card: {
218
- title: "Forgejo Repo Change",
219
- description: "Start a repository change and publish it as a Forgejo pull request.",
220
- },
221
- launchConfigSchema: {
222
- id: "forgejo_repo_change_form",
223
- title: "Forgejo Repo Change",
224
- fields: [
225
- {
226
- id: "forgejoProfile",
227
- label: "Forgejo profile",
228
- kind: "select",
229
- required: true,
230
- description: "Forgejo profile with server-configured CI and Git SSH access.",
231
- },
232
- {
233
- id: "repository",
234
- label: "Repository",
235
- kind: "select",
236
- required: true,
237
- description: "Repository visible to the selected Forgejo profile.",
238
- },
239
- {
240
- id: "prompt",
241
- label: "Requested change",
242
- kind: "textarea",
243
- required: true,
244
- placeholder: "Describe the change to plan, implement, review, and publish.",
245
- },
246
- ],
247
- submitLabel: "Start change",
248
- },
249
- resolveDefaults() {
250
- return {
251
- forgejoProfile: requireDependencies().forgejo.profiles()[0] ?? "",
252
- repository: "",
253
- prompt: "",
254
- };
255
- },
256
- async resolveOptions(input) {
257
- const { forgejo } = requireDependencies();
258
- const profile = trimString(input.forgejoProfile);
259
- return {
260
- forgejoProfile: forgejo.profiles().map((value) => ({ value, label: value })),
261
- repository: (await repositories(profile)).map((repository) => ({
262
- value: repository.full_name,
263
- label: repository.full_name,
264
- description: repository.html_url,
265
- })),
266
- };
267
- },
268
- preparationChecks: forgejoRepositoryPreparationChecks,
269
- resolveRelaunchInput(previousInput) {
270
- return {
271
- forgejoProfile: trimString(previousInput.forgejoProfile),
272
- repository: trimString(previousInput.repository),
273
- prompt: trimString(previousInput.prompt),
274
- };
275
- },
276
- async resolveLaunchConfig(input) {
277
- const profile = trimString(input.forgejoProfile);
278
- const repositoryName = trimString(input.repository);
279
- const prompt = trimString(input.prompt);
280
- const errors: LauncherValidationError[] = [];
281
- const invalid = (fieldId: string, message: string) => ({
282
- ok: false as const,
283
- errors: [validationError(fieldId, message, "custom_rule")],
284
- });
285
- const { forgejo } = requireDependencies();
286
- if (!profile) errors.push(validationError("forgejoProfile", "Forgejo profile is required"));
287
- else if (!forgejo.profiles().includes(profile))
288
- errors.push(
289
- validationError("forgejoProfile", "Forgejo profile is not available", "custom_rule"),
290
- );
291
- if (!repositoryName) errors.push(validationError("repository", "Repository is required"));
292
- if (!prompt) errors.push(validationError("prompt", "Requested change is required"));
293
- if (errors.length > 0) return { ok: false, errors };
294
-
295
- const repository = (await repositories(profile)).find(
296
- (candidate) => candidate.full_name === repositoryName,
297
- );
298
- if (!repository)
299
- return invalid(
300
- "repository",
301
- "Repository is not available to the selected Forgejo profile",
302
- );
303
-
304
- let binding: ReturnType<typeof resolveProfiles>;
305
- try {
306
- binding = resolveProfiles(profile);
307
- } catch (error) {
308
- return invalid("forgejoProfile", (error as Error).message);
309
- }
310
- const gitIdentity = await resolveForgejoGitIdentity(profile);
311
- const workBranch = buildAutoWorkBranchFromSeed(
312
- prompt,
313
- `${repository.ssh_url}:${repository.default_branch}`,
314
- );
315
- const params = forgejoRepoChangeParams(repository, {
316
- ...binding,
317
- profile,
318
- prompt,
319
- workBranch,
320
- });
321
- return {
322
- ok: true,
323
- launchConfig: forgejoRepoChangeLaunchConfig(params, prompt, gitIdentity),
324
- };
325
- },
85
+ provider: "Forgejo",
86
+ providerId: "forgejo",
87
+ integration: (deps: LauncherDependencies) => deps.forgejo,
88
+ profile: (params: ForgejoRepoChangeParams) => params.forgejoProfile,
89
+ params: forgejoRepoChangeParams,
90
+ launchConfig: forgejoRepoChangeLaunchConfig,
91
+ resolveProfiles(profile, { woodpecker, gitSsh, profileBindings = {} }) {
92
+ const binding = resolveProfileBinding(profileBindings, profile);
93
+ try {
94
+ woodpecker.client(binding.woodpeckerProfile);
95
+ } catch {
96
+ throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
97
+ }
98
+ if (!gitSsh.profiles().includes(binding.sshCredentialRef))
99
+ throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
100
+ return binding;
326
101
  },
327
- };
328
-
329
- return {
330
- /** @internal */
331
- configure: configureForgejoRepoChangeLauncher,
332
- /** @internal */
333
- preparationChecks: forgejoRepositoryPreparationChecks,
334
- /** @internal */
335
- resolveProfiles,
336
- /** @internal */
337
- resolveGitIdentity: resolveForgejoGitIdentity,
338
- /** @internal */
339
- launcher: forgejoRepoChangeUiLauncher,
340
- };
102
+ preparationChecks: (params, dependencies) => [
103
+ createGitSshPreparationCheck("write", params, () => dependencies().gitSsh),
104
+ ],
105
+ });
341
106
  }
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 ForgejoRepoChangeCommonParams {
@@ -21,32 +21,10 @@ interface ForgejoRepoChangeCommonParams {
21
21
  }
22
22
 
23
23
  /** @public */
24
- export interface ForgejoIssueOriginParams {
25
- /** @internal */
26
- origin: "issue";
27
- /** @internal */
28
- issueNumber: number;
29
- /** @internal */
30
- issueUrl: string;
31
- /** @internal */
32
- triggerLabel: string;
33
- /** @internal */
34
- doneLabel: string;
35
- }
24
+ export interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {}
36
25
 
37
26
  /** @public */
38
- export interface ForgejoUiOriginParams {
39
- /** @internal */
40
- origin: "ui";
41
- /** @internal */
42
- issueNumber: null;
43
- /** @internal */
44
- issueUrl: null;
45
- /** @internal */
46
- triggerLabel: null;
47
- /** @internal */
48
- doneLabel: null;
49
- }
27
+ export interface ForgejoUiOriginParams extends RepositoryUiOriginParams {}
50
28
 
51
29
  /** @public */
52
30
  export type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<
@@ -64,50 +42,12 @@ export function isIssueOrigin(
64
42
  export const forgejoRepoChangeParamsCodec =
65
43
  createRepositoryChangeParamsCodec<ForgejoRepoChangeParams>({
66
44
  normalize(value) {
67
- const shared = normalizeRepositoryChangeParamsInput(value, "Forgejo Repo Change");
68
- const record = repositoryChangeParamsRecord(value, "Forgejo Repo Change");
69
- const text = (name: string) => {
70
- const value = trimString(record[name]);
71
- if (!value) throw new Error(`Forgejo Repo Change requires ${name}`);
72
- return value;
73
- };
74
-
75
- const common = {
76
- ...shared,
77
- forgejoProfile: text("forgejoProfile"),
78
- woodpeckerProfile: text("woodpeckerProfile"),
79
- sshCredentialRef: text("sshCredentialRef"),
80
- owner: text("owner"),
81
- repo: text("repo"),
82
- };
83
- const origin = trimString(record.origin);
84
- if (origin === "ui") {
85
- return {
86
- ...common,
87
- origin: "ui" as const,
88
- issueNumber: null,
89
- issueUrl: null,
90
- triggerLabel: null,
91
- doneLabel: null,
92
- };
93
- }
94
- if (origin && origin !== "issue") {
95
- throw new Error("Forgejo Repo Change requires a valid origin");
96
- }
97
-
98
- if (
99
- typeof record.issueNumber !== "number" ||
100
- !Number.isInteger(record.issueNumber) ||
101
- record.issueNumber <= 0
102
- )
103
- throw new Error("Forgejo Repo Change requires issueNumber");
104
- return {
105
- ...common,
106
- origin: "issue" as const,
107
- issueNumber: record.issueNumber,
108
- issueUrl: text("issueUrl"),
109
- triggerLabel: text("triggerLabel"),
110
- doneLabel: text("doneLabel"),
111
- };
45
+ return normalizeRepositoryIssueChangeParams(value, "Forgejo Repo Change", [
46
+ "forgejoProfile",
47
+ "woodpeckerProfile",
48
+ "sshCredentialRef",
49
+ "owner",
50
+ "repo",
51
+ ]);
112
52
  },
113
53
  });