@reelout/gitlab 0.4.1 → 0.4.3
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 +48 -0
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @reelout/gitlab
|
|
2
|
+
|
|
3
|
+
GitLab Releases integration for [ReelOut](https://github.com/reelout/reelout).
|
|
4
|
+
The plugin creates a GitLab release for each release tag and removes releases
|
|
5
|
+
it created if a later step fails.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
The `reelout` CLI includes this plugin through `@reelout/config`. Install it
|
|
10
|
+
separately only when using it outside the CLI.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @reelout/gitlab
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This ESM-only package requires Node.js `>=24.15`.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Add the plugin to the `plugins` array in your ReelOut configuration:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
export default {
|
|
24
|
+
plugins: [
|
|
25
|
+
'@reelout/core/analyzer',
|
|
26
|
+
'@reelout/core/builder',
|
|
27
|
+
'@reelout/core/changelog',
|
|
28
|
+
'@reelout/npm',
|
|
29
|
+
'@reelout/git',
|
|
30
|
+
'@reelout/gitlab',
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Set the `GITLAB_TOKEN` environment variable to authenticate with GitLab.
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
- `gitlab` (default export) — the release plugin.
|
|
40
|
+
- `createRelease(...)` — create a GitLab release for a tag.
|
|
41
|
+
- `deleteRelease(...)` — delete a release by tag.
|
|
42
|
+
- `isRepositoryPublic(...)` — check project visibility via the GitLab API.
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
- [Getting started](https://github.com/reelout/reelout/blob/main/docs/01-getting-started.md)
|
|
47
|
+
- [Continuous integration](https://github.com/reelout/reelout/blob/main/docs/03-ci.md)
|
|
48
|
+
- [API reference](https://reelout.overview.vercel.app/)
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Gitlab } from "@gitbeaker/rest";
|
|
2
|
-
|
|
2
|
+
// src/createRelease.ts
|
|
3
3
|
/**
|
|
4
4
|
* Create a GitLab release for a package tag.
|
|
5
5
|
*
|
|
@@ -23,8 +23,7 @@ async function createRelease(context, plan, token, repository) {
|
|
|
23
23
|
ref: context.commit.hash
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
//#region src/deleteRelease.ts
|
|
26
|
+
// src/deleteRelease.ts
|
|
28
27
|
/**
|
|
29
28
|
* Delete a GitLab release associated with a package tag.
|
|
30
29
|
*
|
|
@@ -47,11 +46,9 @@ async function deleteRelease(plan, token, repository) {
|
|
|
47
46
|
throw err;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/gitlab.ts
|
|
49
|
+
// package.json
|
|
50
|
+
var version = "0.4.2";
|
|
51
|
+
// src/gitlab.ts
|
|
55
52
|
/**
|
|
56
53
|
* Built-in plugin that creates GitLab releases for finalized release plans.
|
|
57
54
|
*
|
|
@@ -82,8 +79,7 @@ var gitlab = () => ({
|
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
});
|
|
85
|
-
|
|
86
|
-
//#region src/isRepositoryPublic.ts
|
|
82
|
+
// src/isRepositoryPublic.ts
|
|
87
83
|
/**
|
|
88
84
|
* Check if the target GitLab repository is public.
|
|
89
85
|
*
|
|
@@ -99,7 +95,6 @@ async function isRepositoryPublic(token, repository) {
|
|
|
99
95
|
const projectId = encodeURIComponent(`${repository.owner}/${repository.repo}`);
|
|
100
96
|
return (await api.Projects.show(projectId)).visibility === "public";
|
|
101
97
|
}
|
|
102
|
-
//#endregion
|
|
103
98
|
export { createRelease, gitlab as default, deleteRelease, isRepositoryPublic };
|
|
104
99
|
|
|
105
100
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/createRelease.ts","../src/deleteRelease.ts","../
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/createRelease.ts","../src/deleteRelease.ts","../src/gitlab.ts","../src/isRepositoryPublic.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { Gitlab } from '@gitbeaker/rest'\nimport type { GitRepository, ReleaseContext, ReleasePlan } from '@reelout/core'\n\n/**\n * Create a GitLab release for a package tag.\n *\n * Skips creation when the tag has no message. Uses the GitBeaker REST API\n * with the provided token to create the release.\n *\n * @param context Release context containing commit and prerelease information\n * @param plan Release plan containing the tag to publish\n * @param token GitLab authentication token\n * @param repository Target repository\n * @returns Promise that resolves when the release is created\n */\nexport async function createRelease(\n context: ReleaseContext,\n plan: ReleasePlan,\n token: string,\n repository: GitRepository\n): Promise<void> {\n if (!plan.release?.tag?.message) {\n return\n }\n\n const api = new Gitlab({ token })\n\n const projectId = encodeURIComponent(`${repository.owner}/${repository.repo}`)\n\n await api.ProjectReleases.create(projectId, {\n name: plan.release.tag.name,\n tag_name: plan.release.tag.name,\n description: plan.release.tag.message,\n ref: context.commit.hash,\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { Gitlab } from '@gitbeaker/rest'\nimport type { GitRepository, ReleasePlan } from '@reelout/core'\n\n/**\n * Delete a GitLab release associated with a package tag.\n *\n * Skips deletion if the plan does not contain a valid tag name. Resolves gracefully\n * if the release does not exist on GitLab (e.g., 404 status).\n *\n * @param plan Release plan containing the tag associated with the release to delete\n * @param token GitLab authentication token\n * @param repository Target repository\n * @returns Promise that resolves when the release is deleted\n */\nexport async function deleteRelease(\n plan: ReleasePlan,\n token: string,\n repository: GitRepository\n): Promise<void> {\n if (!plan.release?.tag?.name) {\n return\n }\n\n try {\n const api = new Gitlab({ token })\n\n const projectId = encodeURIComponent(\n `${repository.owner}/${repository.repo}`\n )\n\n await api.ProjectReleases.remove(projectId, plan.release.tag.name)\n } catch (err) {\n const status = (err as { cause?: { response?: { status?: number } } })\n ?.cause?.response?.status\n\n if (status === 404) {\n return\n }\n\n throw err\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleasePlugin } from '@reelout/core'\nimport { version } from '../package.json'\nimport { createRelease } from './createRelease'\nimport { deleteRelease } from './deleteRelease'\n\n/**\n * Built-in plugin that creates GitLab releases for finalized release plans.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `publish`: Creates GitLab releases in reverse alphabetical package order (ensuring the root package release\n * is created last). Automatically rolls back and deletes created releases if subsequent publishing stages fail.\n *\n * @throws {Error} If `context.repository` is not configured or `GITLAB_TOKEN` environment variable is missing.\n * @returns A release plugin configured for GitLab release creation.\n */\nconst gitlab = (): ReleasePlugin => ({\n name: '@reelout/gitlab',\n version,\n publish: async (context, next) => {\n if (!context.repository) {\n throw new Error(\n 'A Git repository is required to create a GitLab release.'\n )\n }\n\n if (!context.env.GITLAB_TOKEN) {\n throw new Error('The GITLAB_TOKEN environment variable is required.')\n }\n\n if (context.dryRun) {\n return next(context)\n }\n\n const plans = context.plans.toSorted((a, b) =>\n (a.package.name || '').localeCompare(b.package.name || '')\n )\n\n const token = context.env.GITLAB_TOKEN\n\n const repository = context.repository\n\n // Create releases in reverse order\n // so that the root package release is created last,\n // as it is often the most important one.\n for (const plan of plans.toReversed()) {\n await createRelease(context, plan, token, repository)\n }\n\n try {\n return await next(context)\n } catch (err) {\n await Promise.allSettled(\n plans.map((plan) => deleteRelease(plan, token, repository))\n )\n\n throw err\n }\n },\n})\n\nexport default gitlab\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { Gitlab } from '@gitbeaker/rest'\nimport type { GitRepository } from '@reelout/core'\n\n/**\n * Check if the target GitLab repository is public.\n *\n * Uses the GitBeaker REST API with the provided token to fetch the\n * visibility status of the specified repository.\n *\n * @param token GitLab authentication token\n * @param repository Target repository\n * @returns Promise that resolves to `true` if the repository is public\n */\nexport async function isRepositoryPublic(\n token: string,\n repository: GitRepository\n): Promise<boolean> {\n const api = new Gitlab({ token })\n\n const projectId = encodeURIComponent(`${repository.owner}/${repository.repo}`)\n\n const project = await api.Projects.show(projectId)\n\n return project.visibility === 'public'\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,eAAsB,cACpB,SACA,MACA,OACA,YACe;CACf,IAAI,CAAC,KAAK,SAAS,KAAK,SACtB;CAGF,MAAM,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC;CAEhC,MAAM,YAAY,mBAAmB,GAAG,WAAW,MAAM,GAAG,WAAW,MAAM;CAE7E,MAAM,IAAI,gBAAgB,OAAO,WAAW;EAC1C,MAAM,KAAK,QAAQ,IAAI;EACvB,UAAU,KAAK,QAAQ,IAAI;EAC3B,aAAa,KAAK,QAAQ,IAAI;EAC9B,KAAK,QAAQ,OAAO;CACtB,CAAC;AACH;;;;;;;;;;;;;ACrBA,eAAsB,cACpB,MACA,OACA,YACe;CACf,IAAI,CAAC,KAAK,SAAS,KAAK,MACtB;CAGF,IAAI;EACF,MAAM,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC;EAEhC,MAAM,YAAY,mBAChB,GAAG,WAAW,MAAM,GAAG,WAAW,MACpC;EAEA,MAAM,IAAI,gBAAgB,OAAO,WAAW,KAAK,QAAQ,IAAI,IAAI;CACnE,SAAS,KAAK;EAIZ,IAHgB,KACZ,OAAO,UAAU,WAEN,KACb;EAGF,MAAM;CACR;AACF;;;;;;;;;;;;;;;ACzBA,IAAM,gBAA+B;CACnC,MAAM;CACN;CACA,SAAS,OAAO,SAAS,SAAS;EAChC,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,MACR,0DACF;EAGF,IAAI,CAAC,QAAQ,IAAI,cACf,MAAM,IAAI,MAAM,oDAAoD;EAGtE,IAAI,QAAQ,QACV,OAAO,KAAK,OAAO;EAGrB,MAAM,QAAQ,QAAQ,MAAM,UAAU,GAAG,OACtC,EAAE,QAAQ,QAAQ,GAAA,CAAI,cAAc,EAAE,QAAQ,QAAQ,EAAE,CAC3D;EAEA,MAAM,QAAQ,QAAQ,IAAI;EAE1B,MAAM,aAAa,QAAQ;EAK3B,KAAK,MAAM,QAAQ,MAAM,WAAW,GAClC,MAAM,cAAc,SAAS,MAAM,OAAO,UAAU;EAGtD,IAAI;GACF,OAAO,MAAM,KAAK,OAAO;EAC3B,SAAS,KAAK;GACZ,MAAM,QAAQ,WACZ,MAAM,KAAK,SAAS,cAAc,MAAM,OAAO,UAAU,CAAC,CAC5D;GAEA,MAAM;EACR;CACF;AACF;;;;;;;;;;;;AC9CA,eAAsB,mBACpB,OACA,YACkB;CAClB,MAAM,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC;CAEhC,MAAM,YAAY,mBAAmB,GAAG,WAAW,MAAM,GAAG,WAAW,MAAM;CAI7E,QAAO,MAFe,IAAI,SAAS,KAAK,SAAS,EAAA,CAElC,eAAe;AAChC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reelout/gitlab",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "GitLab
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"description": "GitLab plugin for publishing releases from ReelOut release plans.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/reelout/reelout.git",
|
|
8
8
|
"directory": "packages/gitlab"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@gitbeaker/rest": "^43.8.0",
|
|
36
|
-
"@reelout/core": "^0.5.
|
|
36
|
+
"@reelout/core": "^0.5.2"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=24.15"
|