@leitwerk-dev/forgejo-repo-change 0.2.1 → 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.
@@ -1,6 +1,6 @@
1
1
  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";
2
+ import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
+ import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
4
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
5
5
  import { type ForgejoRepoChangeParams } from "./params.js";
6
6
  import { type ProfileBindings } from "./profile-bindings.js";
@@ -43,6 +43,13 @@ export declare function createForgejoRepoChangeLauncher(): {
43
43
  /** @internal */
44
44
  resolveGitIdentity: (profile: string) => Promise<ForgejoGitIdentity>;
45
45
  /** @internal */
46
- launcher: ProcessLauncherDefinition<ForgejoRepoChangeParams>;
46
+ launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<ForgejoRepoChangeParams> & {
47
+ resolveIssueLaunchConfig(event: {
48
+ profile: string;
49
+ repository: ForgejoRepository;
50
+ issue: Pick<import("@leitwerk-dev/forgejo").ForgejoIssue, "number" | "title" | "body" | "html_url">;
51
+ labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
52
+ }): Promise<ProcessLaunchConfig<ForgejoRepoChangeParams>>;
53
+ };
47
54
  };
48
55
  //# 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;A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AmB,CAAC,uBAAuB,CAAC,CA6B9C;AAED,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,gBAAgB;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB;IAChB,MAAM,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;IAwE7C,gBAAgB;uBApEkC,oBAAoB,GAAG,IAAI,KAAG,IAAI;IAsEpF,gBAAgB;gCA3DR,OAAO,cACH,mBAAmB,CAAC,uBAAuB,CAAC,KACtD,SAAS,sBAAsB,CAAC,uBAAuB,CAAC,EAAE;IA2D5D,gBAAgB;+BA9CiB,MAAM;IAgDvC,gBAAgB;kCAjCiC,MAAM,KAAG,OAAO,CAAC,kBAAkB,CAAC;IAmCrF,gBAAgB;;;;;;;;;EAGjB"}
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,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,wBAAwB;IACxC,gBAAgB;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,cAAc;AACd,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,gBAAgB;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,gBAAgB;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,gBAAgB;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,gBAAgB;IAChB,SAAS,EAAE,IAAI,CAAC;CAChB;AAED,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,oEAkDtC,CAAC"}
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,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":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAiB1F,OAAO,EACN,KAAK,+BAA+B,EAGpC,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAiNrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHAsgBf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAYA,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;AAwBrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHAmIf"}
@@ -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.2.1",
3
+ "version": "0.3.1",
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.2.1",
24
- "@leitwerk-dev/external-writes": "0.2.1",
25
- "@leitwerk-dev/git-ssh": "0.2.1",
26
- "@leitwerk-dev/process-sdk": "0.2.1",
27
- "@leitwerk-dev/forgejo": "0.2.1",
28
- "@leitwerk-dev/woodpecker": "0.2.1",
29
- "@leitwerk-dev/repository-rebase": "0.2.1"
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/forgejo": "0.3.1",
28
+ "@leitwerk-dev/woodpecker": "0.3.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "tsup": "^8.5.1"
package/src/launcher.ts CHANGED
@@ -1,18 +1,14 @@
1
- import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
2
- import { trimString } from "@leitwerk-dev/domain";
1
+ import {
2
+ createRepositoryChangeUiLauncher,
3
+ repositoryVisibilityCheck,
4
+ } from "@leitwerk-dev/coding/repository-change-launch";
3
5
  import type {
4
6
  ForgejoGitIdentity,
5
7
  ForgejoIntegration,
6
8
  ForgejoRepository,
7
9
  } 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";
10
+ import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
11
+ import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
16
12
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
17
13
  import { type ForgejoRepoChangeParams, isIssueOrigin } from "./params.js";
18
14
  import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
@@ -37,7 +33,6 @@ export function forgejoRepoChangeParams(
37
33
  },
38
34
  ): ForgejoRepoChangeParams {
39
35
  return {
40
- launchKind: "requested_change",
41
36
  repoLocator: repository.ssh_url,
42
37
  baseBranch: repository.default_branch,
43
38
  workBranch: input.workBranch,
@@ -117,70 +112,22 @@ export function createForgejoRepoChangeLauncher() {
117
112
  return dependencies;
118
113
  }
119
114
 
120
- function sshPreparationCheck(
121
- access: "read" | "write",
122
- params: ForgejoRepoChangeParams,
123
- ): LaunchPreparationCheck<ForgejoRepoChangeParams> {
124
- return {
125
- id: `ssh_${access}`,
126
- label: `Verify SSH ${access} access`,
127
- async run({ signal, logger }) {
128
- signal.throwIfAborted();
129
- const result = await requireDependencies().gitSsh.preflight({
130
- credentialRef: params.sshCredentialRef,
131
- repoLocator: params.repoLocator,
132
- baseBranch: params.baseBranch,
133
- requireWrite: access === "write",
134
- });
135
- signal.throwIfAborted();
136
- if (!result.ok) {
137
- logger.warn(`Git SSH ${result.access} preflight failed: ${result.detail}`);
138
- throw new SafeLaunchPreparationError(
139
- `SSH ${result.access} access failed: ${result.detail}`,
140
- `Authorize Git SSH profile '${params.sshCredentialRef}' for '${params.owner}/${params.repo}' with read/write access, then try again.`,
141
- );
142
- }
143
- },
144
- };
145
- }
146
-
147
115
  /** @internal */
148
116
  function forgejoRepositoryPreparationChecks(
149
117
  _input: unknown,
150
118
  { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>,
151
119
  ): readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[] {
152
120
  return [
153
- {
154
- id: "repository_visibility",
155
- label: "Check repository visibility",
156
- async run({ signal }) {
157
- signal.throwIfAborted();
158
- const repositoryName = `${params.owner}/${params.repo}`;
159
- const visible = (await repositories(params.forgejoProfile)).some(
160
- (candidate) => candidate.full_name === repositoryName,
161
- );
162
- signal.throwIfAborted();
163
- if (!visible) {
164
- throw new SafeLaunchPreparationError(
165
- "Repository is not visible",
166
- "Grant the selected Forgejo profile access to the repository, then try again.",
167
- );
168
- }
169
- },
170
- },
171
- sshPreparationCheck("read", params),
172
- sshPreparationCheck("write", params),
121
+ repositoryVisibilityCheck("Forgejo", async () =>
122
+ (await repositories(params.forgejoProfile)).some(
123
+ (candidate) => candidate.full_name === `${params.owner}/${params.repo}`,
124
+ ),
125
+ ),
126
+ createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
127
+ createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh),
173
128
  ];
174
129
  }
175
130
 
176
- function validationError(
177
- fieldId: string,
178
- message: string,
179
- code: LauncherValidationError["code"] = "required",
180
- ): LauncherValidationError {
181
- return { code, fieldId, message };
182
- }
183
-
184
131
  /** @internal */
185
132
  function resolveProfiles(profile: string) {
186
133
  const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
@@ -209,123 +156,19 @@ export function createForgejoRepoChangeLauncher() {
209
156
  return forgejo.client(profile).listRepositories();
210
157
  }
211
158
 
212
- const forgejoRepoChangeUiLauncher: ProcessLauncherDefinition<ForgejoRepoChangeParams> = {
159
+ const forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
213
160
  id: forgejoRepoChangeUiLauncherId,
214
- label: "Forgejo Repo Change",
215
- description: "Plan, implement, review, and publish a Forgejo change without a source issue",
216
- visibility: "ui",
217
- ui: {
218
- card: {
219
- title: "Forgejo Repo Change",
220
- description: "Start a repository change and publish it as a Forgejo pull request.",
221
- },
222
- launchConfigSchema: {
223
- id: "forgejo_repo_change_form",
224
- title: "Forgejo Repo Change",
225
- fields: [
226
- {
227
- id: "forgejoProfile",
228
- label: "Forgejo profile",
229
- kind: "select",
230
- required: true,
231
- description: "Forgejo profile with server-configured CI and Git SSH access.",
232
- },
233
- {
234
- id: "repository",
235
- label: "Repository",
236
- kind: "select",
237
- required: true,
238
- description: "Repository visible to the selected Forgejo profile.",
239
- },
240
- {
241
- id: "prompt",
242
- label: "Requested change",
243
- kind: "textarea",
244
- required: true,
245
- placeholder: "Describe the change to plan, implement, review, and publish.",
246
- },
247
- ],
248
- submitLabel: "Start change",
249
- },
250
- resolveDefaults() {
251
- return {
252
- forgejoProfile: requireDependencies().forgejo.profiles()[0] ?? "",
253
- repository: "",
254
- prompt: "",
255
- };
256
- },
257
- async resolveOptions(input) {
258
- const { forgejo } = requireDependencies();
259
- const profile = trimString(input.forgejoProfile);
260
- return {
261
- forgejoProfile: forgejo.profiles().map((value) => ({ value, label: value })),
262
- repository: (await repositories(profile)).map((repository) => ({
263
- value: repository.full_name,
264
- label: repository.full_name,
265
- description: repository.html_url,
266
- })),
267
- };
268
- },
269
- preparationChecks: forgejoRepositoryPreparationChecks,
270
- resolveRelaunchInput(previousInput) {
271
- return {
272
- forgejoProfile: trimString(previousInput.forgejoProfile),
273
- repository: trimString(previousInput.repository),
274
- prompt: trimString(previousInput.prompt),
275
- };
276
- },
277
- async resolveLaunchConfig(input) {
278
- const profile = trimString(input.forgejoProfile);
279
- const repositoryName = trimString(input.repository);
280
- const prompt = trimString(input.prompt);
281
- const errors: LauncherValidationError[] = [];
282
- const invalid = (fieldId: string, message: string) => ({
283
- ok: false as const,
284
- errors: [validationError(fieldId, message, "custom_rule")],
285
- });
286
- const { forgejo } = requireDependencies();
287
- if (!profile) errors.push(validationError("forgejoProfile", "Forgejo profile is required"));
288
- else if (!forgejo.profiles().includes(profile))
289
- errors.push(
290
- validationError("forgejoProfile", "Forgejo profile is not available", "custom_rule"),
291
- );
292
- if (!repositoryName) errors.push(validationError("repository", "Repository is required"));
293
- if (!prompt) errors.push(validationError("prompt", "Requested change is required"));
294
- if (errors.length > 0) return { ok: false, errors };
295
-
296
- const repository = (await repositories(profile)).find(
297
- (candidate) => candidate.full_name === repositoryName,
298
- );
299
- if (!repository)
300
- return invalid(
301
- "repository",
302
- "Repository is not available to the selected Forgejo profile",
303
- );
304
-
305
- let binding: ReturnType<typeof resolveProfiles>;
306
- try {
307
- binding = resolveProfiles(profile);
308
- } catch (error) {
309
- return invalid("forgejoProfile", (error as Error).message);
310
- }
311
- const gitIdentity = await resolveForgejoGitIdentity(profile);
312
- const workBranch = buildAutoWorkBranchFromSeed(
313
- prompt,
314
- `${repository.ssh_url}:${repository.default_branch}`,
315
- );
316
- const params = forgejoRepoChangeParams(repository, {
317
- ...binding,
318
- profile,
319
- prompt,
320
- workBranch,
321
- });
322
- return {
323
- ok: true,
324
- launchConfig: forgejoRepoChangeLaunchConfig(params, prompt, gitIdentity),
325
- };
326
- },
327
- },
328
- };
161
+ provider: "Forgejo",
162
+ providerId: "forgejo",
163
+ assertConfigured: requireDependencies,
164
+ profiles: () => requireDependencies().forgejo.profiles(),
165
+ repositories,
166
+ resolveProfiles,
167
+ resolveGitIdentity: resolveForgejoGitIdentity,
168
+ params: forgejoRepoChangeParams,
169
+ launchConfig: forgejoRepoChangeLaunchConfig,
170
+ preparationChecks: forgejoRepositoryPreparationChecks,
171
+ });
329
172
 
330
173
  return {
331
174
  /** @internal */
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<
@@ -63,52 +41,13 @@ export function isIssueOrigin(
63
41
  /** @internal */
64
42
  export const forgejoRepoChangeParamsCodec =
65
43
  createRepositoryChangeParamsCodec<ForgejoRepoChangeParams>({
66
- displayName: "Forgejo Repo Change",
67
44
  normalize(value) {
68
- const shared = normalizeRepositoryChangeParamsInput(value, "Forgejo Repo Change");
69
- const record = repositoryChangeParamsRecord(value, "Forgejo Repo Change");
70
- const text = (name: string) => {
71
- const value = trimString(record[name]);
72
- if (!value) throw new Error(`Forgejo Repo Change requires ${name}`);
73
- return value;
74
- };
75
-
76
- const common = {
77
- ...shared,
78
- forgejoProfile: text("forgejoProfile"),
79
- woodpeckerProfile: text("woodpeckerProfile"),
80
- sshCredentialRef: text("sshCredentialRef"),
81
- owner: text("owner"),
82
- repo: text("repo"),
83
- };
84
- const origin = trimString(record.origin);
85
- if (origin === "ui") {
86
- return {
87
- ...common,
88
- origin: "ui" as const,
89
- issueNumber: null,
90
- issueUrl: null,
91
- triggerLabel: null,
92
- doneLabel: null,
93
- };
94
- }
95
- if (origin && origin !== "issue") {
96
- throw new Error("Forgejo Repo Change requires a valid origin");
97
- }
98
-
99
- if (
100
- typeof record.issueNumber !== "number" ||
101
- !Number.isInteger(record.issueNumber) ||
102
- record.issueNumber <= 0
103
- )
104
- throw new Error("Forgejo Repo Change requires issueNumber");
105
- return {
106
- ...common,
107
- origin: "issue" as const,
108
- issueNumber: record.issueNumber,
109
- issueUrl: text("issueUrl"),
110
- triggerLabel: text("triggerLabel"),
111
- doneLabel: text("doneLabel"),
112
- };
45
+ return normalizeRepositoryIssueChangeParams(value, "Forgejo Repo Change", [
46
+ "forgejoProfile",
47
+ "woodpeckerProfile",
48
+ "sshCredentialRef",
49
+ "owner",
50
+ "repo",
51
+ ]);
113
52
  },
114
53
  });