@leitwerk-dev/gitlab 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.
- package/README.md +27 -5
- package/dist/chunk-TQIZKDAM.js +1160 -0
- package/dist/chunk-TQIZKDAM.js.map +1 -0
- package/dist/client.d.ts +80 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/delivery-tools.d.ts +4 -0
- package/dist/delivery-tools.d.ts.map +1 -0
- package/dist/external.d.ts +58 -6
- package/dist/external.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -45
- package/dist/index.js.map +1 -1
- package/dist/issue-watcher.d.ts +40 -0
- package/dist/issue-watcher.d.ts.map +1 -0
- package/dist/preflight.d.ts +10 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/testing.d.ts +17 -2
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +129 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +9 -2
- package/dist/tools.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/client.ts +169 -22
- package/src/delivery-tools.ts +226 -0
- package/src/external.ts +161 -9
- package/src/index.ts +3 -0
- package/src/issue-watcher.ts +145 -0
- package/src/preflight.ts +70 -0
- package/src/setup.ts +2 -0
- package/src/testing.ts +140 -1
- package/src/tools.ts +32 -9
- package/dist/chunk-64FNBSKH.js +0 -605
- package/dist/chunk-64FNBSKH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4,61 +4,21 @@ import {
|
|
|
4
4
|
gitLabFeedbackReadyAt,
|
|
5
5
|
gitlabExternal,
|
|
6
6
|
gitlabIntegration,
|
|
7
|
+
gitlabIssueExternalId,
|
|
8
|
+
gitlabIssueWatcherSource,
|
|
7
9
|
gitlabRepositoryCredentials,
|
|
8
10
|
observationKey,
|
|
9
11
|
observeMergeRequest,
|
|
10
12
|
parseGitLabProfiles,
|
|
13
|
+
parseGitLabSelection,
|
|
11
14
|
pendingGitLabFeedback,
|
|
12
15
|
resolveGitLabBinding,
|
|
16
|
+
selectGitLabProjects,
|
|
13
17
|
setupGitLabIntegration
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TQIZKDAM.js";
|
|
15
19
|
|
|
16
20
|
// src/index.ts
|
|
17
21
|
import { coreHostCapabilities } from "@leitwerk-dev/process-sdk";
|
|
18
|
-
|
|
19
|
-
// src/selection.ts
|
|
20
|
-
function parseGitLabSelection(raw) {
|
|
21
|
-
const list = (value) => {
|
|
22
|
-
if (value === void 0) return [];
|
|
23
|
-
if (!Array.isArray(value) || value.some(
|
|
24
|
-
(v) => typeof v !== "string" || !/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/.test(v) || v.split("/").some((p) => p === "." || p === "..")
|
|
25
|
-
))
|
|
26
|
-
throw new Error("GitLab selectors require exact namespace paths");
|
|
27
|
-
return [...new Set(value)];
|
|
28
|
-
};
|
|
29
|
-
const pair = (value) => {
|
|
30
|
-
if (value !== void 0 && (!value || typeof value !== "object" || Array.isArray(value)))
|
|
31
|
-
throw new Error("GitLab selectors must be objects");
|
|
32
|
-
const item = value;
|
|
33
|
-
return { include: list(item?.include), exclude: list(item?.exclude) };
|
|
34
|
-
};
|
|
35
|
-
if (raw.all_accessible !== void 0 && typeof raw.all_accessible !== "boolean")
|
|
36
|
-
throw new Error("all_accessible must be a boolean");
|
|
37
|
-
const parsed = {
|
|
38
|
-
projects: pair(raw.projects),
|
|
39
|
-
groups: pair(raw.groups),
|
|
40
|
-
allAccessible: raw.all_accessible === true
|
|
41
|
-
};
|
|
42
|
-
if (!parsed.allAccessible && !parsed.projects.include.length && !parsed.groups.include.length)
|
|
43
|
-
throw new Error("GitLab requires explicit project/group includes or all_accessible: true");
|
|
44
|
-
return parsed;
|
|
45
|
-
}
|
|
46
|
-
function projectExcluded(selection, name) {
|
|
47
|
-
return selection.projects.exclude.includes(name) || selection.groups.exclude.some((group) => name.startsWith(`${group}/`));
|
|
48
|
-
}
|
|
49
|
-
async function selectGitLabProjects(client, selection) {
|
|
50
|
-
const candidates = selection.allAccessible ? await client.listProjects() : [];
|
|
51
|
-
for (const name of selection.projects.include) candidates.push(await client.getProject(name));
|
|
52
|
-
for (const group of selection.groups.include)
|
|
53
|
-
candidates.push(...await client.listGroupProjects(group));
|
|
54
|
-
return [
|
|
55
|
-
...new Map(
|
|
56
|
-
candidates.filter((p) => !p.archived && !projectExcluded(selection, p.path_with_namespace)).map((p) => [p.id, p])
|
|
57
|
-
).values()
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/index.ts
|
|
62
22
|
var manifest = {
|
|
63
23
|
/** @internal */
|
|
64
24
|
id: "gitlab",
|
|
@@ -96,6 +56,8 @@ export {
|
|
|
96
56
|
gitLabFeedbackReadyAt,
|
|
97
57
|
gitlabExternal,
|
|
98
58
|
gitlabIntegration,
|
|
59
|
+
gitlabIssueExternalId,
|
|
60
|
+
gitlabIssueWatcherSource,
|
|
99
61
|
gitlabRepositoryCredentials,
|
|
100
62
|
observationKey,
|
|
101
63
|
observeMergeRequest,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { coreHostCapabilities } from \"@leitwerk-dev/process-sdk\";\nimport { GitLabClient, parseGitLabProfiles } from \"./client.js\";\nimport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @internal */\nconst manifest = {\n\t/** @internal */\n\tid: \"gitlab\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n} as const;\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseGitLabProfiles(config);\n\t\tconst clients = new Map([...profiles].map(([id, profile]) => [id, new GitLabClient(profile)]));\n\t\tsetupGitLabIntegration(api, {\n\t\t\tprofiles: () => [...profiles.keys()],\n\t\t\tclient: (profile) => {\n\t\t\t\tconst client = clients.get(profile);\n\t\t\t\tif (!client) throw new Error(`Unknown GitLab profile '${profile}'`);\n\t\t\t\treturn client;\n\t\t\t},\n\t\t});\n\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\tif (!deps || Array.isArray(deps)) return;\n\t\tdeps.repositoryCredentials.register({\n\t\t\tkind: \"git_https\",\n\t\t\tresolve(ref) {\n\t\t\t\tconst profile = ref.startsWith(\"gitlab:\") ? profiles.get(ref.slice(7)) : undefined;\n\t\t\t\treturn profile\n\t\t\t\t\t? { origin: profile.baseUrl, username: \"oauth2\", password: profile.token }\n\t\t\t\t\t: null;\n\t\t\t},\n\t\t});\n\t},\n};\nexport default extension;\nexport type { GitLabIntegration } from \"./capability.js\";\nexport {\n\tgitlabIntegration,\n\tgitlabRepositoryCredentials,\n} from \"./capability.js\";\nexport type {\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabIdentity,\n\tGitLabJob,\n\tGitLabMergeRequest,\n\tGitLabObservation,\n\tGitLabProject,\n} from \"./client.js\";\nexport { observeMergeRequest } from \"./client.js\";\nexport type { GitLabDeliveryObservation } from \"./external.js\";\nexport {\n\tgitLabFeedbackReadyAt,\n\tgitlabExternal,\n\tobservationKey,\n\tpendingGitLabFeedback,\n} from \"./external.js\";\nexport type { GitLabIssueWatcherEvent } from \"./issue-watcher.js\";\nexport { gitlabIssueExternalId, gitlabIssueWatcherSource } from \"./issue-watcher.js\";\nexport type { GitLabSelection } from \"./selection.js\";\nexport {\n\tparseGitLabSelection,\n\tselectGitLabProjects,\n} from \"./selection.js\";\nexport { ensureGitLabSeenReaction, resolveGitLabBinding } from \"./tools.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,SAAS,4BAA4B;AAKrC,IAAM,WAAW;AAAA;AAAA,EAEhB,IAAI;AAAA;AAAA,EAEJ,SAAS;AACV;AAEA,IAAM,YAAqC;AAAA,EAC1C;AAAA,EACA,YAAY,KAAK,QAAQ;AACxB,UAAM,WAAW,oBAAoB,MAAM;AAC3C,UAAM,UAAU,IAAI,IAAI,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,IAAI,aAAa,OAAO,CAAC,CAAC,CAAC;AAC7F,2BAAuB,KAAK;AAAA,MAC3B,UAAU,MAAM,CAAC,GAAG,SAAS,KAAK,CAAC;AAAA,MACnC,QAAQ,CAAC,YAAY;AACpB,cAAM,SAAS,QAAQ,IAAI,OAAO;AAClC,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,2BAA2B,OAAO,GAAG;AAClE,eAAO;AAAA,MACR;AAAA,IACD,CAAC;AACD,UAAM,OAAO,IAAI,IAAI,qBAAqB,WAAW;AACrD,QAAI,CAAC,QAAQ,MAAM,QAAQ,IAAI,EAAG;AAClC,SAAK,sBAAsB,SAAS;AAAA,MACnC,MAAM;AAAA,MACN,QAAQ,KAAK;AACZ,cAAM,UAAU,IAAI,WAAW,SAAS,IAAI,SAAS,IAAI,IAAI,MAAM,CAAC,CAAC,IAAI;AACzE,eAAO,UACJ,EAAE,QAAQ,QAAQ,SAAS,UAAU,UAAU,UAAU,QAAQ,MAAM,IACvE;AAAA,MACJ;AAAA,IACD,CAAC;AAAA,EACF;AACD;AACA,IAAO,gBAAQ;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CoreServerSetupDeps } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import { type emptyPollResult } from "@leitwerk-dev/watcher-utils";
|
|
3
|
+
import type { GitLabIntegration } from "./capability.js";
|
|
4
|
+
import type { GitLabIssue, GitLabProject } from "./client.js";
|
|
5
|
+
import { type GitLabSelection } from "./selection.js";
|
|
6
|
+
/** @public */
|
|
7
|
+
export interface GitLabIssueWatcherConfig extends GitLabSelection {
|
|
8
|
+
/** @public */
|
|
9
|
+
profile: string;
|
|
10
|
+
/** @public */
|
|
11
|
+
pollInterval: string;
|
|
12
|
+
/** @public */
|
|
13
|
+
labels: {
|
|
14
|
+
/** @public */ trigger: string /** @public */;
|
|
15
|
+
/** @public */
|
|
16
|
+
done: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** @public */
|
|
20
|
+
export interface GitLabIssueWatcherEvent {
|
|
21
|
+
/** @public */
|
|
22
|
+
profile: string;
|
|
23
|
+
/** @public */
|
|
24
|
+
repository: GitLabProject;
|
|
25
|
+
/** @public */
|
|
26
|
+
issue: GitLabIssue;
|
|
27
|
+
/** @public */
|
|
28
|
+
labels: {
|
|
29
|
+
/** @public */ trigger: string /** @public */;
|
|
30
|
+
/** @public */
|
|
31
|
+
done: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** @public */
|
|
35
|
+
export declare const gitlabIssueExternalId: (origin: string, projectId: number, iid: number) => string;
|
|
36
|
+
/** @public */
|
|
37
|
+
export declare const gitlabIssueWatcherSource: import("@leitwerk-dev/process-sdk").ProcessWatcherSource<GitLabIssueWatcherConfig, GitLabIssueWatcherEvent>;
|
|
38
|
+
/** @public */
|
|
39
|
+
export declare function createGitLabIssueDiscovery(deps: CoreServerSetupDeps, integration: GitLabIntegration, now: () => number): (result: ReturnType<typeof emptyPollResult>) => Promise<void>;
|
|
40
|
+
//# sourceMappingURL=issue-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-watcher.d.ts","sourceRoot":"","sources":["../src/issue-watcher.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,eAAe,EAA8C,MAAM,gBAAgB,CAAC;AAClG,cAAc;AACd,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAChE,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,MAAM,EAAE;QACP,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC;QAC9C,cAAc;QACd,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AACD,cAAc;AACd,MAAM,WAAW,uBAAuB;IACvC,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,UAAU,EAAE,aAAa,CAAC;IAC1B,cAAc;IACd,KAAK,EAAE,WAAW,CAAC;IACnB,cAAc;IACd,MAAM,EAAE;QACP,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC;QAC9C,cAAc;QACd,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AACD,cAAc;AACd,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,EAAE,KAAK,MAAM,WAC7C,CAAC;AACxC,cAAc;AACd,eAAO,MAAM,wBAAwB,6GAyCnC,CAAC;AACH,cAAc;AACd,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,iBAAiB,EAC9B,GAAG,EAAE,MAAM,MAAM,IAGH,QAAQ,UAAU,CAAC,OAAO,eAAe,CAAC,mBAqDxD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Credentials stay in the child environment and never appear in URLs or error output. */
|
|
2
|
+
export declare function preflightGitLabRepository(input: {
|
|
3
|
+
url: string;
|
|
4
|
+
origin: string;
|
|
5
|
+
token: string;
|
|
6
|
+
baseBranch: string;
|
|
7
|
+
workBranch: string;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAQA,0FAA0F;AAC1F,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,iBAqDA"}
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,iBAAiB,CAAC;AAK5E,8EAA8E;AAC9E,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,kBAAkB,EACvB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IACR,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACd;;;cAQN"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type { GitLabClientLike, GitLabDiff, GitLabFeedback, GitLabMergeRequest, GitLabNote, GitLabNoteReaction, GitLabPipeline, GitLabProject } from "./client.js";
|
|
1
|
+
import type { GitLabClientLike, GitLabDiff, GitLabFeedback, GitLabIssue, GitLabMergeRequest, GitLabNote, GitLabNoteReaction, GitLabPipeline, GitLabProject } from "./client.js";
|
|
2
|
+
export { GITLAB_MR_KIND } from "./external.js";
|
|
2
3
|
export { setupGitLabIntegration } from "./setup.js";
|
|
3
4
|
/** @public */
|
|
4
5
|
interface LocalState {
|
|
6
|
+
/** @public */
|
|
7
|
+
issues?: GitLabIssue[];
|
|
8
|
+
/** @public */
|
|
9
|
+
issueNotes?: Record<string, GitLabNote[]>;
|
|
10
|
+
/** @public */
|
|
11
|
+
labels?: Record<string, string[]>;
|
|
5
12
|
/** @internal */
|
|
6
13
|
projects: GitLabProject[];
|
|
7
14
|
/** @internal */
|
|
@@ -19,7 +26,8 @@ interface LocalState {
|
|
|
19
26
|
/** @public */
|
|
20
27
|
reactions?: Record<string, GitLabNoteReaction[]>;
|
|
21
28
|
}
|
|
22
|
-
/** Persistent GitLab test boundary. Repository URLs use local Git's file transport.
|
|
29
|
+
/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */
|
|
30
|
+
/** @public */
|
|
23
31
|
export declare class LocalGitLabAdapter {
|
|
24
32
|
/** @internal */
|
|
25
33
|
readonly root: string;
|
|
@@ -30,6 +38,8 @@ export declare class LocalGitLabAdapter {
|
|
|
30
38
|
/** @public */
|
|
31
39
|
loseNextCommentResponse: boolean;
|
|
32
40
|
/** @public */
|
|
41
|
+
loseNextMergeRequestResponse: boolean;
|
|
42
|
+
/** @public */
|
|
33
43
|
loseNextReplyResponse: boolean;
|
|
34
44
|
/** @public */
|
|
35
45
|
loseNextReactionResponse: boolean;
|
|
@@ -51,6 +61,11 @@ export declare class LocalGitLabAdapter {
|
|
|
51
61
|
/** @public */
|
|
52
62
|
pipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline;
|
|
53
63
|
/** @public */
|
|
64
|
+
createIssue(projectId: number, title: string, labels?: string[]): GitLabIssue;
|
|
65
|
+
/** @public */
|
|
66
|
+
merge(request: GitLabMergeRequest): void;
|
|
67
|
+
private conflicts;
|
|
68
|
+
/** @public */
|
|
54
69
|
client(): GitLabClientLike;
|
|
55
70
|
}
|
|
56
71
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,cAAc;AACd,UAAU,UAAU;IACnB,gBAAgB;IAChB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,gBAAgB;IAChB,GAAG,EAAE,kBAAkB,EAAE,CAAC;IAC1B,gBAAgB;IAChB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,cAAc;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACpC,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACpC,cAAc;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IAC5C,cAAc;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/C,cAAc;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;CACjD;AACD
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EAC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Ac;IACd,wBAAwB,UAAS;IACjC,cAAc;;IAEb,gBAAgB;IACP,IAAI,EAAE,MAAM;IACrB,gBAAgB;IACP,OAAO,SAAwB;IAQzC,cAAc;IACd,IAAI;IAGJ,OAAO,CAAC,MAAM;IAed,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,GAAG;IAOX,cAAc;IACd,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa;IAYrD,cAAc;IACd,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB;IAmBlE,cAAc;IACd,QAAQ,CAAC,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc;IAchE,cAAc;IACd,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,EAAqB,GAAG,WAAW;IAkB/F,cAAc;IACd,KAAK,CAAC,OAAO,EAAE,kBAAkB;IA4BjC,OAAO,CAAC,SAAS;IAajB,cAAc;IACd,MAAM,IAAI,gBAAgB;CAsL1B"}
|
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GITLAB_MR_KIND,
|
|
2
3
|
setupGitLabIntegration
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TQIZKDAM.js";
|
|
4
5
|
|
|
5
6
|
// src/testing.ts
|
|
6
7
|
import { execFileSync } from "child_process";
|
|
@@ -22,6 +23,8 @@ var LocalGitLabAdapter = class {
|
|
|
22
23
|
/** @public */
|
|
23
24
|
loseNextCommentResponse = false;
|
|
24
25
|
/** @public */
|
|
26
|
+
loseNextMergeRequestResponse = false;
|
|
27
|
+
/** @public */
|
|
25
28
|
loseNextReplyResponse = false;
|
|
26
29
|
/** @public */
|
|
27
30
|
loseNextReactionResponse = false;
|
|
@@ -105,6 +108,67 @@ var LocalGitLabAdapter = class {
|
|
|
105
108
|
return value;
|
|
106
109
|
}
|
|
107
110
|
/** @public */
|
|
111
|
+
createIssue(projectId, title, labels = ["use-leitwerk"]) {
|
|
112
|
+
this.state.issues ??= [];
|
|
113
|
+
const project = this.project(projectId);
|
|
114
|
+
const iid = this.state.issues.filter((i) => i.project_id === projectId).length + 1;
|
|
115
|
+
const issue = {
|
|
116
|
+
id: this.state.issues.length + 1,
|
|
117
|
+
iid,
|
|
118
|
+
project_id: projectId,
|
|
119
|
+
title,
|
|
120
|
+
description: "",
|
|
121
|
+
web_url: `${project.web_url}/-/issues/${iid}`,
|
|
122
|
+
state: "opened",
|
|
123
|
+
labels
|
|
124
|
+
};
|
|
125
|
+
this.state.issues.push(issue);
|
|
126
|
+
this.save();
|
|
127
|
+
return issue;
|
|
128
|
+
}
|
|
129
|
+
/** @public */
|
|
130
|
+
merge(request) {
|
|
131
|
+
const base = this.git(request.project_id, ["rev-parse", request.target_branch]);
|
|
132
|
+
const head = this.git(request.project_id, ["rev-parse", request.source_branch]);
|
|
133
|
+
const tree = this.git(request.project_id, ["merge-tree", "--write-tree", base, head]);
|
|
134
|
+
const commit = this.git(request.project_id, [
|
|
135
|
+
"-c",
|
|
136
|
+
"user.name=Leitwerk Bot",
|
|
137
|
+
"-c",
|
|
138
|
+
"user.email=bot@gitlab.test",
|
|
139
|
+
"commit-tree",
|
|
140
|
+
tree,
|
|
141
|
+
"-p",
|
|
142
|
+
base,
|
|
143
|
+
"-p",
|
|
144
|
+
head,
|
|
145
|
+
"-m",
|
|
146
|
+
request.title
|
|
147
|
+
]);
|
|
148
|
+
this.git(request.project_id, [
|
|
149
|
+
"update-ref",
|
|
150
|
+
`refs/heads/${request.target_branch}`,
|
|
151
|
+
commit,
|
|
152
|
+
base
|
|
153
|
+
]);
|
|
154
|
+
request.state = "merged";
|
|
155
|
+
request.merge_commit_sha = commit;
|
|
156
|
+
this.save();
|
|
157
|
+
}
|
|
158
|
+
conflicts(request) {
|
|
159
|
+
try {
|
|
160
|
+
this.git(request.project_id, [
|
|
161
|
+
"merge-tree",
|
|
162
|
+
"--write-tree",
|
|
163
|
+
request.target_branch,
|
|
164
|
+
request.source_branch
|
|
165
|
+
]);
|
|
166
|
+
return false;
|
|
167
|
+
} catch {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** @public */
|
|
108
172
|
client() {
|
|
109
173
|
const mr = (id, iid) => {
|
|
110
174
|
const m = this.state.mrs.find((m2) => m2.project_id === id && m2.iid === iid);
|
|
@@ -118,6 +182,68 @@ var LocalGitLabAdapter = class {
|
|
|
118
182
|
});
|
|
119
183
|
return {
|
|
120
184
|
baseUrl: this.baseUrl,
|
|
185
|
+
listIssues: async (id) => structuredClone(
|
|
186
|
+
(this.state.issues ?? []).filter((i) => i.project_id === id && i.state === "opened")
|
|
187
|
+
),
|
|
188
|
+
getIssue: async (id, iid) => {
|
|
189
|
+
const issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);
|
|
190
|
+
if (!issue) throw new Error("Unknown local GitLab issue");
|
|
191
|
+
return structuredClone(issue);
|
|
192
|
+
},
|
|
193
|
+
updateIssue: async (id, iid, patch) => {
|
|
194
|
+
const issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);
|
|
195
|
+
if (!issue) throw new Error("Unknown local GitLab issue");
|
|
196
|
+
if (patch.labels !== void 0) issue.labels = patch.labels ? patch.labels.split(",") : [];
|
|
197
|
+
if (patch.state_event === "close") issue.state = "closed";
|
|
198
|
+
this.save();
|
|
199
|
+
return structuredClone(issue);
|
|
200
|
+
},
|
|
201
|
+
listIssueNotes: async (id, iid) => structuredClone(this.state.issueNotes?.[`${id}:${iid}`] ?? []),
|
|
202
|
+
addIssueNote: async (id, iid, body) => {
|
|
203
|
+
this.state.issueNotes ??= {};
|
|
204
|
+
this.state.issueNotes[`${id}:${iid}`] ??= [];
|
|
205
|
+
const notes = this.state.issueNotes[`${id}:${iid}`];
|
|
206
|
+
return this.append(notes, { id: notes.length + 1, body }, "Comment");
|
|
207
|
+
},
|
|
208
|
+
listLabels: async (id) => (this.state.labels?.[id] ?? []).map((name) => ({ name })),
|
|
209
|
+
createLabel: async (id, name) => {
|
|
210
|
+
this.state.labels ??= {};
|
|
211
|
+
this.state.labels[id] ??= [];
|
|
212
|
+
const labels = this.state.labels[id];
|
|
213
|
+
if (!labels.includes(name)) labels.push(name);
|
|
214
|
+
this.save();
|
|
215
|
+
return { name };
|
|
216
|
+
},
|
|
217
|
+
listBranchMergeRequests: async (id, source, target) => structuredClone(
|
|
218
|
+
this.state.mrs.filter(
|
|
219
|
+
(m) => m.project_id === id && m.source_branch === source && m.target_branch === target
|
|
220
|
+
)
|
|
221
|
+
),
|
|
222
|
+
createMergeRequest: async (id, input) => {
|
|
223
|
+
const request = this.openMr(this.project(id), input.source_branch);
|
|
224
|
+
Object.assign(request, {
|
|
225
|
+
title: input.title,
|
|
226
|
+
description: input.description,
|
|
227
|
+
target_branch: input.target_branch,
|
|
228
|
+
labels: []
|
|
229
|
+
});
|
|
230
|
+
this.save();
|
|
231
|
+
if (this.loseNextMergeRequestResponse) {
|
|
232
|
+
this.loseNextMergeRequestResponse = false;
|
|
233
|
+
throw new Error("Response lost after merge request creation");
|
|
234
|
+
}
|
|
235
|
+
return structuredClone(request);
|
|
236
|
+
},
|
|
237
|
+
preflightRepository: async (id, baseBranch, workBranch) => {
|
|
238
|
+
this.git(id, ["rev-parse", `refs/heads/${baseBranch}`]);
|
|
239
|
+
this.git(id, ["check-ref-format", `refs/heads/${workBranch}`]);
|
|
240
|
+
this.git(id, [
|
|
241
|
+
"push",
|
|
242
|
+
"--dry-run",
|
|
243
|
+
this.project(id).http_url_to_repo,
|
|
244
|
+
`${baseBranch}:refs/heads/${workBranch}`
|
|
245
|
+
]);
|
|
246
|
+
},
|
|
121
247
|
getProject: async (id) => structuredClone(this.project(id)),
|
|
122
248
|
listProjects: async () => structuredClone(this.state.projects),
|
|
123
249
|
getGroup: async (id) => ({ id: 1, full_path: String(id) }),
|
|
@@ -126,6 +252,7 @@ var LocalGitLabAdapter = class {
|
|
|
126
252
|
),
|
|
127
253
|
getMergeRequest: async (id, iid) => ({
|
|
128
254
|
...structuredClone(mr(id, iid)),
|
|
255
|
+
has_conflicts: this.conflicts(mr(id, iid)),
|
|
129
256
|
sha: commit(mr(id, iid).source_project_id, mr(id, iid).source_branch).id
|
|
130
257
|
}),
|
|
131
258
|
listMergeRequests: async (id, label) => structuredClone(
|
|
@@ -213,6 +340,7 @@ var LocalGitLabAdapter = class {
|
|
|
213
340
|
}
|
|
214
341
|
};
|
|
215
342
|
export {
|
|
343
|
+
GITLAB_MR_KIND,
|
|
216
344
|
LocalGitLabAdapter,
|
|
217
345
|
setupGitLabIntegration
|
|
218
346
|
};
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tGitLabClientLike,\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\n\nexport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @public */\ninterface LocalState {\n\t/** @internal */\n\tprojects: GitLabProject[];\n\t/** @internal */\n\tmrs: GitLabMergeRequest[];\n\t/** @internal */\n\tpipelines: GitLabPipeline[];\n\t/** @public */\n\tnotes: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiffs: Record<string, GitLabDiff[]>;\n\t/** @public */\n\tfeedback?: Record<string, GitLabFeedback[]>;\n\t/** @public */\n\tdiscussionNotes?: Record<string, GitLabNote[]>;\n\t/** @public */\n\treactions?: Record<string, GitLabNoteReaction[]>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. @public */\nexport class LocalGitLabAdapter {\n\t/** @public */\n\tstate: LocalState;\n\t/** @public */\n\tloseNextCommentResponse = false;\n\t/** @public */\n\tloseNextReplyResponse = false;\n\t/** @public */\n\tloseNextReactionResponse = false;\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t\t/** @internal */\n\t\treadonly baseUrl = \"https://gitlab.test\",\n\t) {\n\t\tmkdirSync(root, { recursive: true });\n\t\tconst file = path.join(root, \"gitlab.json\");\n\t\tthis.state = existsSync(file)\n\t\t\t? JSON.parse(readFileSync(file, \"utf8\"))\n\t\t\t: { projects: [], mrs: [], pipelines: [], notes: {}, diffs: {} };\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteFileSync(path.join(this.root, \"gitlab.json\"), JSON.stringify(this.state), { mode: 0o600 });\n\t}\n\tprivate append<T>(items: T[], item: T, kind: \"Comment\" | \"Reply\" | \"Reaction\"): T {\n\t\titems.push(item);\n\t\tthis.save();\n\t\tconst flag = `loseNext${kind}Response` as const;\n\t\tif (this[flag]) {\n\t\t\tthis[flag] = false;\n\t\t\tconst action = {\n\t\t\t\tComment: \"comment write\",\n\t\t\t\tReply: \"discussion reply\",\n\t\t\t\tReaction: \"reaction write\",\n\t\t\t};\n\t\t\tthrow new Error(`Response lost after ${action[kind]}`);\n\t\t}\n\t\treturn item;\n\t}\n\tprivate project(id: number | string) {\n\t\tconst p = this.state.projects.find((p) => p.id === id || p.path_with_namespace === id);\n\t\tif (!p) throw new Error(\"Unknown test project\");\n\t\treturn p;\n\t}\n\tprivate git(id: number, args: string[]) {\n\t\treturn execFileSync(\n\t\t\t\"git\",\n\t\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"--git-dir\", this.project(id).http_url_to_repo, ...args],\n\t\t\t{ encoding: \"utf8\" },\n\t\t).trim();\n\t}\n\t/** @public */\n\taddProject(name: string, bare: string): GitLabProject {\n\t\tconst project: GitLabProject = {\n\t\t\tid: this.state.projects.length + 1,\n\t\t\tpath_with_namespace: name,\n\t\t\thttp_url_to_repo: bare,\n\t\t\tweb_url: `${this.baseUrl}/${name}`,\n\t\t\tdefault_branch: \"main\",\n\t\t};\n\t\tthis.state.projects.push(project);\n\t\tthis.save();\n\t\treturn project;\n\t}\n\t/** @public */\n\topenMr(project: GitLabProject, branch: string): GitLabMergeRequest {\n\t\tconst mr: GitLabMergeRequest = {\n\t\t\tiid: this.state.mrs.length + 1,\n\t\t\tproject_id: project.id,\n\t\t\ttarget_project_id: project.id,\n\t\t\tsource_project_id: project.id,\n\t\t\ttitle: \"Update dependency\",\n\t\t\tdescription: \"Renovate upgrade\",\n\t\t\tstate: \"opened\",\n\t\t\tlabels: [\"renovate\"],\n\t\t\tsha: this.git(project.id, [\"rev-parse\", branch]),\n\t\t\tsource_branch: branch,\n\t\t\ttarget_branch: \"main\",\n\t\t\tweb_url: `${project.web_url}/-/merge_requests/${this.state.mrs.length + 1}`,\n\t\t};\n\t\tthis.state.mrs.push(mr);\n\t\tthis.save();\n\t\treturn mr;\n\t}\n\t/** @public */\n\tpipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline {\n\t\tconst value: GitLabPipeline = {\n\t\t\tid: this.state.pipelines.length + 1,\n\t\t\tproject_id: mr.source_project_id,\n\t\t\tsha: this.git(mr.source_project_id, [\"rev-parse\", mr.source_branch]),\n\t\t\tref: mr.source_branch,\n\t\t\tstatus,\n\t\t\tsource: \"merge_request_event\",\n\t\t\tweb_url: `${this.project(mr.source_project_id).web_url}/-/pipelines/${this.state.pipelines.length + 1}`,\n\t\t};\n\t\tthis.state.pipelines.push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tclient(): GitLabClientLike {\n\t\tconst mr = (id: number, iid: number) => {\n\t\t\tconst m = this.state.mrs.find((m) => m.project_id === id && m.iid === iid);\n\t\t\tif (!m) throw new Error(\"Unknown test MR\");\n\t\t\treturn m;\n\t\t};\n\t\tconst commit = (id: number, ref: string) => ({\n\t\t\tid: this.git(id, [\"rev-parse\", ref]),\n\t\t\tparent_ids: this.git(id, [\"show\", \"-s\", \"--format=%P\", ref]).split(\" \").filter(Boolean),\n\t\t\tmessage: this.git(id, [\"show\", \"-s\", \"--format=%B\", ref]),\n\t\t});\n\t\treturn {\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tgetGroup: async (id) => ({ id: 1, full_path: String(id) }),\n\t\t\tlistGroupProjects: async (group) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects.filter((p) => p.path_with_namespace.startsWith(`${group}/`)),\n\t\t\t\t),\n\t\t\tgetMergeRequest: async (id, iid) => ({\n\t\t\t\t...structuredClone(mr(id, iid)),\n\t\t\t\tsha: commit(mr(id, iid).source_project_id, mr(id, iid).source_branch).id,\n\t\t\t}),\n\t\t\tlistMergeRequests: async (id, label) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.state === \"opened\" && m.labels.includes(label),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetBranch: async (id, branch) => ({\n\t\t\t\tname: branch,\n\t\t\t\tcan_push: true,\n\t\t\t\tprotected: false,\n\t\t\t\tcommit: commit(id, branch),\n\t\t\t}),\n\t\t\tgetCommit: async (id, ref) => commit(id, ref),\n\t\t\tgetChanges: async (id, iid) => structuredClone(this.state.diffs[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestPipelines: async (id, iid) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) =>\n\t\t\t\t\t\t\tp.project_id === mr(id, iid).source_project_id && p.ref === mr(id, iid).source_branch,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistBranchPipelines: async (id, branch, sha) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) => p.project_id === id && p.ref === branch && p.sha === sha && p.source === \"push\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetPipeline: async (id, pipeline) => {\n\t\t\t\tconst p = this.state.pipelines.find((p) => p.project_id === id && p.id === pipeline);\n\t\t\t\tif (!p) throw new Error(\"Unknown test pipeline\");\n\t\t\t\treturn structuredClone(p);\n\t\t\t},\n\t\t\tlistFailedJobs: async (id, pipeline) => [\n\t\t\t\t{\n\t\t\t\t\tid: pipeline * 100,\n\t\t\t\t\tname: \"test\",\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tweb_url: `${this.project(id).web_url}/-/jobs/${pipeline * 100}`,\n\t\t\t\t\tfailure_reason: \"script_failure\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgetJobTrace: async () => ({\n\t\t\t\ttext: \"Expected new dependency API; test failed\",\n\t\t\t\ttruncated: false,\n\t\t\t}),\n\t\t\tresolveGitIdentity: async () => ({\n\t\t\t\tname: \"Leitwerk Bot\",\n\t\t\t\temail: \"bot@gitlab.test\",\n\t\t\t\tusername: \"bot\",\n\t\t\t}),\n\t\t\tlistNotes: async (id, iid) => structuredClone(this.state.notes[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestFeedback: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.feedback?.[`${id}:${iid}`] ?? []),\n\t\t\tgetDiscussion: async (id, iid, discussionId) => ({\n\t\t\t\tid: discussionId,\n\t\t\t\tnotes: (this.state.discussionNotes?.[`${id}:${iid}:${discussionId}`] ?? []).map((note) => ({\n\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t})),\n\t\t\t}),\n\t\t\treplyToDiscussion: async (id, iid, discussionId, body) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tthis.state.discussionNotes[key] ??= [];\n\t\t\t\tconst notes = this.state.discussionNotes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Reply\");\n\t\t\t},\n\t\t\tlistNoteReactions: async (id, iid, noteId) =>\n\t\t\t\tstructuredClone(this.state.reactions?.[`${id}:${iid}:${noteId}`] ?? []),\n\t\t\taddNoteReaction: async (id, iid, noteId, name) => {\n\t\t\t\tconst key = `${id}:${iid}:${noteId}`;\n\t\t\t\tthis.state.reactions ??= {};\n\t\t\t\tthis.state.reactions[key] ??= [];\n\t\t\t\tconst reactions = this.state.reactions[key];\n\t\t\t\tif (\n\t\t\t\t\treactions.some((reaction) => reaction.name === name && reaction.user.username === \"bot\")\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Reaction already exists\");\n\t\t\t\tconst reaction = { id: reactions.length + 1, name, user: { username: \"bot\" } };\n\t\t\t\treturn this.append(reactions, reaction, \"Reaction\");\n\t\t\t},\n\t\t\taddNote: async (id, iid, body) => {\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tthis.state.notes[key] ??= [];\n\t\t\t\tconst notes = this.state.notes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,OAAO,UAAU;AAkCV,IAAM,qBAAN,MAAyB;AAAA;AAAA,EAU/B,YAEU,MAEA,UAAU,uBAClB;AAHQ;AAEA;AAET,cAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AACnC,UAAM,OAAO,KAAK,KAAK,MAAM,aAAa;AAC1C,SAAK,QAAQ,WAAW,IAAI,IACzB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,IACrC,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EACjE;AAAA,E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AAW,EAAE,IAAI,UAAU,SAAS,GAAG,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE;AAC7E,eAAO,KAAK,OAAO,WAAW,UAAU,UAAU;AAAA,MACnD;AAAA,MACA,SAAS,OAAO,IAAI,KAAK,SAAS;AACjC,cAAM,MAAM,GAAG,EAAE,IAAI,GAAG;AACxB,aAAK,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,cAAM,QAAQ,KAAK,MAAM,MAAM,GAAG;AAClC,eAAO,KAAK,OAAO,OAAO,EAAE,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS;AAAA,MACpE;AAAA,IACD;AAAA,EACD;AACD;","names":["p","m","reaction"]}
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tGitLabClientLike,\n\tGitLabDiff,\n\tGitLabFeedback,\n\tGitLabIssue,\n\tGitLabMergeRequest,\n\tGitLabNote,\n\tGitLabNoteReaction,\n\tGitLabPipeline,\n\tGitLabProject,\n} from \"./client.js\";\n\nexport { GITLAB_MR_KIND } from \"./external.js\";\nexport { setupGitLabIntegration } from \"./setup.js\";\n\n/** @public */\ninterface LocalState {\n\t/** @public */\n\tissues?: GitLabIssue[];\n\t/** @public */\n\tissueNotes?: Record<string, GitLabNote[]>;\n\t/** @public */\n\tlabels?: Record<string, string[]>;\n\t/** @internal */\n\tprojects: GitLabProject[];\n\t/** @internal */\n\tmrs: GitLabMergeRequest[];\n\t/** @internal */\n\tpipelines: GitLabPipeline[];\n\t/** @public */\n\tnotes: Record<string, GitLabNote[]>;\n\t/** @internal */\n\tdiffs: Record<string, GitLabDiff[]>;\n\t/** @public */\n\tfeedback?: Record<string, GitLabFeedback[]>;\n\t/** @public */\n\tdiscussionNotes?: Record<string, GitLabNote[]>;\n\t/** @public */\n\treactions?: Record<string, GitLabNoteReaction[]>;\n}\n/** Persistent GitLab test boundary. Repository URLs use local Git's file transport. */\n/** @public */\nexport class LocalGitLabAdapter {\n\t/** @public */\n\tstate: LocalState;\n\t/** @public */\n\tloseNextCommentResponse = false;\n\t/** @public */\n\tloseNextMergeRequestResponse = false;\n\t/** @public */\n\tloseNextReplyResponse = false;\n\t/** @public */\n\tloseNextReactionResponse = false;\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t\t/** @internal */\n\t\treadonly baseUrl = \"https://gitlab.test\",\n\t) {\n\t\tmkdirSync(root, { recursive: true });\n\t\tconst file = path.join(root, \"gitlab.json\");\n\t\tthis.state = existsSync(file)\n\t\t\t? JSON.parse(readFileSync(file, \"utf8\"))\n\t\t\t: { projects: [], mrs: [], pipelines: [], notes: {}, diffs: {} };\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteFileSync(path.join(this.root, \"gitlab.json\"), JSON.stringify(this.state), { mode: 0o600 });\n\t}\n\tprivate append<T>(items: T[], item: T, kind: \"Comment\" | \"Reply\" | \"Reaction\"): T {\n\t\titems.push(item);\n\t\tthis.save();\n\t\tconst flag = `loseNext${kind}Response` as const;\n\t\tif (this[flag]) {\n\t\t\tthis[flag] = false;\n\t\t\tconst action = {\n\t\t\t\tComment: \"comment write\",\n\t\t\t\tReply: \"discussion reply\",\n\t\t\t\tReaction: \"reaction write\",\n\t\t\t};\n\t\t\tthrow new Error(`Response lost after ${action[kind]}`);\n\t\t}\n\t\treturn item;\n\t}\n\tprivate project(id: number | string) {\n\t\tconst p = this.state.projects.find((p) => p.id === id || p.path_with_namespace === id);\n\t\tif (!p) throw new Error(\"Unknown test project\");\n\t\treturn p;\n\t}\n\tprivate git(id: number, args: string[]) {\n\t\treturn execFileSync(\n\t\t\t\"git\",\n\t\t\t[\"-c\", \"core.hooksPath=/dev/null\", \"--git-dir\", this.project(id).http_url_to_repo, ...args],\n\t\t\t{ encoding: \"utf8\" },\n\t\t).trim();\n\t}\n\t/** @public */\n\taddProject(name: string, bare: string): GitLabProject {\n\t\tconst project: GitLabProject = {\n\t\t\tid: this.state.projects.length + 1,\n\t\t\tpath_with_namespace: name,\n\t\t\thttp_url_to_repo: bare,\n\t\t\tweb_url: `${this.baseUrl}/${name}`,\n\t\t\tdefault_branch: \"main\",\n\t\t};\n\t\tthis.state.projects.push(project);\n\t\tthis.save();\n\t\treturn project;\n\t}\n\t/** @public */\n\topenMr(project: GitLabProject, branch: string): GitLabMergeRequest {\n\t\tconst mr: GitLabMergeRequest = {\n\t\t\tiid: this.state.mrs.length + 1,\n\t\t\tproject_id: project.id,\n\t\t\ttarget_project_id: project.id,\n\t\t\tsource_project_id: project.id,\n\t\t\ttitle: \"Update dependency\",\n\t\t\tdescription: \"Renovate upgrade\",\n\t\t\tstate: \"opened\",\n\t\t\tlabels: [\"renovate\"],\n\t\t\tsha: this.git(project.id, [\"rev-parse\", branch]),\n\t\t\tsource_branch: branch,\n\t\t\ttarget_branch: \"main\",\n\t\t\tweb_url: `${project.web_url}/-/merge_requests/${this.state.mrs.length + 1}`,\n\t\t};\n\t\tthis.state.mrs.push(mr);\n\t\tthis.save();\n\t\treturn mr;\n\t}\n\t/** @public */\n\tpipeline(mr: GitLabMergeRequest, status: string): GitLabPipeline {\n\t\tconst value: GitLabPipeline = {\n\t\t\tid: this.state.pipelines.length + 1,\n\t\t\tproject_id: mr.source_project_id,\n\t\t\tsha: this.git(mr.source_project_id, [\"rev-parse\", mr.source_branch]),\n\t\t\tref: mr.source_branch,\n\t\t\tstatus,\n\t\t\tsource: \"merge_request_event\",\n\t\t\tweb_url: `${this.project(mr.source_project_id).web_url}/-/pipelines/${this.state.pipelines.length + 1}`,\n\t\t};\n\t\tthis.state.pipelines.push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tcreateIssue(projectId: number, title: string, labels: string[] = [\"use-leitwerk\"]): GitLabIssue {\n\t\tthis.state.issues ??= [];\n\t\tconst project = this.project(projectId);\n\t\tconst iid = this.state.issues.filter((i) => i.project_id === projectId).length + 1;\n\t\tconst issue: GitLabIssue = {\n\t\t\tid: this.state.issues.length + 1,\n\t\t\tiid,\n\t\t\tproject_id: projectId,\n\t\t\ttitle,\n\t\t\tdescription: \"\",\n\t\t\tweb_url: `${project.web_url}/-/issues/${iid}`,\n\t\t\tstate: \"opened\",\n\t\t\tlabels,\n\t\t};\n\t\tthis.state.issues.push(issue);\n\t\tthis.save();\n\t\treturn issue;\n\t}\n\t/** @public */\n\tmerge(request: GitLabMergeRequest) {\n\t\tconst base = this.git(request.project_id, [\"rev-parse\", request.target_branch]);\n\t\tconst head = this.git(request.project_id, [\"rev-parse\", request.source_branch]);\n\t\tconst tree = this.git(request.project_id, [\"merge-tree\", \"--write-tree\", base, head]);\n\t\tconst commit = this.git(request.project_id, [\n\t\t\t\"-c\",\n\t\t\t\"user.name=Leitwerk Bot\",\n\t\t\t\"-c\",\n\t\t\t\"user.email=bot@gitlab.test\",\n\t\t\t\"commit-tree\",\n\t\t\ttree,\n\t\t\t\"-p\",\n\t\t\tbase,\n\t\t\t\"-p\",\n\t\t\thead,\n\t\t\t\"-m\",\n\t\t\trequest.title,\n\t\t]);\n\t\tthis.git(request.project_id, [\n\t\t\t\"update-ref\",\n\t\t\t`refs/heads/${request.target_branch}`,\n\t\t\tcommit,\n\t\t\tbase,\n\t\t]);\n\t\trequest.state = \"merged\";\n\t\trequest.merge_commit_sha = commit;\n\t\tthis.save();\n\t}\n\tprivate conflicts(request: GitLabMergeRequest): boolean {\n\t\ttry {\n\t\t\tthis.git(request.project_id, [\n\t\t\t\t\"merge-tree\",\n\t\t\t\t\"--write-tree\",\n\t\t\t\trequest.target_branch,\n\t\t\t\trequest.source_branch,\n\t\t\t]);\n\t\t\treturn false;\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t}\n\t/** @public */\n\tclient(): GitLabClientLike {\n\t\tconst mr = (id: number, iid: number) => {\n\t\t\tconst m = this.state.mrs.find((m) => m.project_id === id && m.iid === iid);\n\t\t\tif (!m) throw new Error(\"Unknown test MR\");\n\t\t\treturn m;\n\t\t};\n\t\tconst commit = (id: number, ref: string) => ({\n\t\t\tid: this.git(id, [\"rev-parse\", ref]),\n\t\t\tparent_ids: this.git(id, [\"show\", \"-s\", \"--format=%P\", ref]).split(\" \").filter(Boolean),\n\t\t\tmessage: this.git(id, [\"show\", \"-s\", \"--format=%B\", ref]),\n\t\t});\n\t\treturn {\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tlistIssues: async (id) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\t(this.state.issues ?? []).filter((i) => i.project_id === id && i.state === \"opened\"),\n\t\t\t\t),\n\t\t\tgetIssue: async (id, iid) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tupdateIssue: async (id, iid, patch) => {\n\t\t\t\tconst issue = (this.state.issues ?? []).find((i) => i.project_id === id && i.iid === iid);\n\t\t\t\tif (!issue) throw new Error(\"Unknown local GitLab issue\");\n\t\t\t\tif (patch.labels !== undefined) issue.labels = patch.labels ? patch.labels.split(\",\") : [];\n\t\t\t\tif (patch.state_event === \"close\") issue.state = \"closed\";\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(issue);\n\t\t\t},\n\t\t\tlistIssueNotes: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.issueNotes?.[`${id}:${iid}`] ?? []),\n\t\t\taddIssueNote: async (id, iid, body) => {\n\t\t\t\tthis.state.issueNotes ??= {};\n\t\t\t\tthis.state.issueNotes[`${id}:${iid}`] ??= [];\n\t\t\t\tconst notes = this.state.issueNotes[`${id}:${iid}`];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t\tlistLabels: async (id) => (this.state.labels?.[id] ?? []).map((name) => ({ name })),\n\t\t\tcreateLabel: async (id, name) => {\n\t\t\t\tthis.state.labels ??= {};\n\t\t\t\tthis.state.labels[id] ??= [];\n\t\t\t\tconst labels = this.state.labels[id];\n\t\t\t\tif (!labels.includes(name)) labels.push(name);\n\t\t\t\tthis.save();\n\t\t\t\treturn { name };\n\t\t\t},\n\t\t\tlistBranchMergeRequests: async (id, source, target) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.source_branch === source && m.target_branch === target,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcreateMergeRequest: async (id, input) => {\n\t\t\t\tconst request = this.openMr(this.project(id), input.source_branch);\n\t\t\t\tObject.assign(request, {\n\t\t\t\t\ttitle: input.title,\n\t\t\t\t\tdescription: input.description,\n\t\t\t\t\ttarget_branch: input.target_branch,\n\t\t\t\t\tlabels: [],\n\t\t\t\t});\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextMergeRequestResponse) {\n\t\t\t\t\tthis.loseNextMergeRequestResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after merge request creation\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(request);\n\t\t\t},\n\t\t\tpreflightRepository: async (id, baseBranch, workBranch) => {\n\t\t\t\tthis.git(id, [\"rev-parse\", `refs/heads/${baseBranch}`]);\n\t\t\t\tthis.git(id, [\"check-ref-format\", `refs/heads/${workBranch}`]);\n\t\t\t\tthis.git(id, [\n\t\t\t\t\t\"push\",\n\t\t\t\t\t\"--dry-run\",\n\t\t\t\t\tthis.project(id).http_url_to_repo,\n\t\t\t\t\t`${baseBranch}:refs/heads/${workBranch}`,\n\t\t\t\t]);\n\t\t\t},\n\n\t\t\tgetProject: async (id) => structuredClone(this.project(id)),\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tgetGroup: async (id) => ({ id: 1, full_path: String(id) }),\n\t\t\tlistGroupProjects: async (group) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.projects.filter((p) => p.path_with_namespace.startsWith(`${group}/`)),\n\t\t\t\t),\n\t\t\tgetMergeRequest: async (id, iid) => ({\n\t\t\t\t...structuredClone(mr(id, iid)),\n\t\t\t\thas_conflicts: this.conflicts(mr(id, iid)),\n\t\t\t\tsha: commit(mr(id, iid).source_project_id, mr(id, iid).source_branch).id,\n\t\t\t}),\n\t\t\tlistMergeRequests: async (id, label) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.mrs.filter(\n\t\t\t\t\t\t(m) => m.project_id === id && m.state === \"opened\" && m.labels.includes(label),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetBranch: async (id, branch) => ({\n\t\t\t\tname: branch,\n\t\t\t\tcan_push: true,\n\t\t\t\tprotected: false,\n\t\t\t\tcommit: commit(id, branch),\n\t\t\t}),\n\t\t\tgetCommit: async (id, ref) => commit(id, ref),\n\t\t\tgetChanges: async (id, iid) => structuredClone(this.state.diffs[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestPipelines: async (id, iid) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) =>\n\t\t\t\t\t\t\tp.project_id === mr(id, iid).source_project_id && p.ref === mr(id, iid).source_branch,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tlistBranchPipelines: async (id, branch, sha) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.pipelines.filter(\n\t\t\t\t\t\t(p) => p.project_id === id && p.ref === branch && p.sha === sha && p.source === \"push\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetPipeline: async (id, pipeline) => {\n\t\t\t\tconst p = this.state.pipelines.find((p) => p.project_id === id && p.id === pipeline);\n\t\t\t\tif (!p) throw new Error(\"Unknown test pipeline\");\n\t\t\t\treturn structuredClone(p);\n\t\t\t},\n\t\t\tlistFailedJobs: async (id, pipeline) => [\n\t\t\t\t{\n\t\t\t\t\tid: pipeline * 100,\n\t\t\t\t\tname: \"test\",\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tweb_url: `${this.project(id).web_url}/-/jobs/${pipeline * 100}`,\n\t\t\t\t\tfailure_reason: \"script_failure\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgetJobTrace: async () => ({\n\t\t\t\ttext: \"Expected new dependency API; test failed\",\n\t\t\t\ttruncated: false,\n\t\t\t}),\n\t\t\tresolveGitIdentity: async () => ({\n\t\t\t\tname: \"Leitwerk Bot\",\n\t\t\t\temail: \"bot@gitlab.test\",\n\t\t\t\tusername: \"bot\",\n\t\t\t}),\n\t\t\tlistNotes: async (id, iid) => structuredClone(this.state.notes[`${id}:${iid}`] ?? []),\n\t\t\tlistMergeRequestFeedback: async (id, iid) =>\n\t\t\t\tstructuredClone(this.state.feedback?.[`${id}:${iid}`] ?? []),\n\t\t\tgetDiscussion: async (id, iid, discussionId) => ({\n\t\t\t\tid: discussionId,\n\t\t\t\tnotes: (this.state.discussionNotes?.[`${id}:${iid}:${discussionId}`] ?? []).map((note) => ({\n\t\t\t\t\t...structuredClone(note),\n\t\t\t\t\tsystem: false,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\tauthor: { username: \"bot\" },\n\t\t\t\t})),\n\t\t\t}),\n\t\t\treplyToDiscussion: async (id, iid, discussionId, body) => {\n\t\t\t\tconst key = `${id}:${iid}:${discussionId}`;\n\t\t\t\tthis.state.discussionNotes ??= {};\n\t\t\t\tthis.state.discussionNotes[key] ??= [];\n\t\t\t\tconst notes = this.state.discussionNotes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Reply\");\n\t\t\t},\n\t\t\tlistNoteReactions: async (id, iid, noteId) =>\n\t\t\t\tstructuredClone(this.state.reactions?.[`${id}:${iid}:${noteId}`] ?? []),\n\t\t\taddNoteReaction: async (id, iid, noteId, name) => {\n\t\t\t\tconst key = `${id}:${iid}:${noteId}`;\n\t\t\t\tthis.state.reactions ??= {};\n\t\t\t\tthis.state.reactions[key] ??= [];\n\t\t\t\tconst reactions = this.state.reactions[key];\n\t\t\t\tif (\n\t\t\t\t\treactions.some((reaction) => reaction.name === name && reaction.user.username === \"bot\")\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Reaction already exists\");\n\t\t\t\tconst reaction = { id: reactions.length + 1, name, user: { username: \"bot\" } };\n\t\t\t\treturn this.append(reactions, reaction, \"Reaction\");\n\t\t\t},\n\t\t\taddNote: async (id, iid, body) => {\n\t\t\t\tconst key = `${id}:${iid}`;\n\t\t\t\tthis.state.notes[key] ??= [];\n\t\t\t\tconst notes = this.state.notes[key];\n\t\t\t\treturn this.append(notes, { id: notes.length + 1, body }, \"Comment\");\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,OAAO,UAAU;AA2CV,IAAM,qBAAN,MAAyB;AAAA;AAAA,EAY/B,YAEU,MAEA,UAAU,uBAClB;AAHQ;AAEA;AAET,cAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AACnC,UAAM,OAAO,KAAK,KAAK,MAAM,aAAa;AAC1C,SAAK,QAAQ,WAAW,IAAI,IACzB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,IACrC,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EACjE;AAAA,EATU;AAAA,EAEA;AAAA;AAAA,EAdV;AAAA;AAAA,EAEA,0BAA0B;AAAA;AAAA,EAE1B,+BAA+B;AAAA;AAAA,EAE/B,wBAAwB;AAAA;AAAA,EAExB,2BAA2B;AAAA;AAAA,EAe3B,OAAO;AACN,kBAAc,KAAK,KAAK,KAAK,MAAM,aAAa,GAAG,KAAK,UAAU,KAAK,KAAK,GAAG,EAAE,MAAM,IAAM,CAAC;AAAA,EAC/F;AAAA,EACQ,OAAU,OAAY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S,OAAO,IAAI,KAAK,SAAS;AACjC,cAAM,MAAM,GAAG,EAAE,IAAI,GAAG;AACxB,aAAK,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,cAAM,QAAQ,KAAK,MAAM,MAAM,GAAG;AAClC,eAAO,KAAK,OAAO,OAAO,EAAE,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS;AAAA,MACpE;AAAA,IACD;AAAA,EACD;AACD;","names":["p","m","reaction"]}
|
package/dist/tools.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ import { type IntegrationToolExecutionContext, type ServerExtensionAPI } from "@
|
|
|
3
3
|
import type { GitLabIntegration } from "./capability.js";
|
|
4
4
|
import { type GitLabClientLike } from "./client.js";
|
|
5
5
|
/** @public */
|
|
6
|
+
export declare function resolveGitLabRepositoryBinding(ctx: Pick<IntegrationToolExecutionContext, "project" | "process">): {
|
|
7
|
+
/** @public */
|
|
8
|
+
profile: string;
|
|
9
|
+
/** @public */
|
|
10
|
+
projectId: number;
|
|
11
|
+
};
|
|
12
|
+
/** @public */
|
|
6
13
|
export declare function resolveGitLabBinding(ctx: Pick<IntegrationToolExecutionContext, "project" | "process">): {
|
|
7
14
|
/** @public */
|
|
8
15
|
profile: string;
|
|
@@ -43,9 +50,9 @@ export declare function ensureGitLabSeenReaction(input: {
|
|
|
43
50
|
writes: ExternalWrites;
|
|
44
51
|
/** @public */
|
|
45
52
|
instanceId: string;
|
|
46
|
-
/** @
|
|
53
|
+
/** @internal */
|
|
47
54
|
projectId: number;
|
|
48
|
-
/** @
|
|
55
|
+
/** @internal */
|
|
49
56
|
iid: number;
|
|
50
57
|
/** @public */
|
|
51
58
|
noteId: number;
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAC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AU,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;CAErB,GAAG,OAAO,CAAC;IACX,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC,CA0BD;AACD,cAAc;AACd,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACrD,cAAc;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,cAAc;IACd,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBhB;AACD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,QA0E1F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/gitlab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"leitwerk": {
|
|
6
6
|
"extension": {
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@leitwerk-dev/domain": "0.
|
|
29
|
-
"@leitwerk-dev/external-writes": "0.
|
|
30
|
-
"@leitwerk-dev/process-sdk": "0.
|
|
31
|
-
"@leitwerk-dev/watcher-utils": "0.
|
|
32
|
-
"@leitwerk-dev/test-support": "0.
|
|
28
|
+
"@leitwerk-dev/domain": "0.3.1",
|
|
29
|
+
"@leitwerk-dev/external-writes": "0.3.1",
|
|
30
|
+
"@leitwerk-dev/process-sdk": "0.3.1",
|
|
31
|
+
"@leitwerk-dev/watcher-utils": "0.3.1",
|
|
32
|
+
"@leitwerk-dev/test-support": "0.3.1",
|
|
33
|
+
"@leitwerk-dev/coding": "0.3.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"tsup": "^8.5.1",
|