@backstage/plugin-scaffolder-backend-module-gitlab 0.6.0-next.2 → 0.6.1-next.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.
- package/CHANGELOG.md +30 -0
- package/README.md +1 -1
- package/dist/actions/gitlabMergeRequest.cjs.js +74 -24
- package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.6.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.0.2-next.0
|
|
9
|
+
- @backstage/config@1.2.0
|
|
10
|
+
- @backstage/errors@1.2.4
|
|
11
|
+
- @backstage/integration@1.15.1
|
|
12
|
+
- @backstage/plugin-scaffolder-node@0.5.1-next.0
|
|
13
|
+
|
|
14
|
+
## 0.6.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 73f2ccf: declare correct type (number) for publish:gitlab output.projectId
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 9adfe46: GitLab MR: introduce 'skip' commit action.
|
|
23
|
+
- bc71718: Updated installation instructions in README to not include `/alpha`.
|
|
24
|
+
- 094eaa3: Remove references to in-repo backend-common
|
|
25
|
+
- f2f68cf: Updated `gitlab:group:ensureExists` action to instead use oauth client.
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/plugin-scaffolder-node@0.5.0
|
|
28
|
+
- @backstage/integration@1.15.1
|
|
29
|
+
- @backstage/backend-plugin-api@1.0.1
|
|
30
|
+
- @backstage/config@1.2.0
|
|
31
|
+
- @backstage/errors@1.2.4
|
|
32
|
+
|
|
3
33
|
## 0.6.0-next.2
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Then ensure that both the scaffolder and this module are added to your backend:
|
|
|
19
19
|
// In packages/backend/src/index.ts
|
|
20
20
|
const backend = createBackend();
|
|
21
21
|
// ...
|
|
22
|
-
backend.add(import('@backstage/plugin-scaffolder-backend
|
|
22
|
+
backend.add(import('@backstage/plugin-scaffolder-backend'));
|
|
23
23
|
backend.add(import('@backstage/plugin-scaffolder-backend-module-gitlab'));
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -6,15 +6,38 @@ var errors = require('@backstage/errors');
|
|
|
6
6
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
7
7
|
var helpers = require('./helpers.cjs.js');
|
|
8
8
|
var gitlabMergeRequest_examples = require('./gitlabMergeRequest.examples.cjs.js');
|
|
9
|
+
var crypto = require('crypto');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
12
|
|
|
12
13
|
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
13
14
|
|
|
14
|
-
function
|
|
15
|
-
|
|
15
|
+
function computeSha256(file) {
|
|
16
|
+
const hash = crypto.createHash("sha256");
|
|
17
|
+
hash.update(file.content);
|
|
18
|
+
return hash.digest("hex");
|
|
19
|
+
}
|
|
20
|
+
async function getFileAction(fileInfo, target, api, logger, remoteFiles, defaultCommitAction = "auto") {
|
|
21
|
+
if (defaultCommitAction === "auto") {
|
|
16
22
|
const filePath = path__default.default.join(fileInfo.targetPath ?? "", fileInfo.file.path);
|
|
17
|
-
|
|
23
|
+
if (remoteFiles?.some((remoteFile) => remoteFile.path === filePath)) {
|
|
24
|
+
try {
|
|
25
|
+
const targetFile = await api.RepositoryFiles.show(
|
|
26
|
+
target.repoID,
|
|
27
|
+
filePath,
|
|
28
|
+
target.branch
|
|
29
|
+
);
|
|
30
|
+
if (computeSha256(fileInfo.file) === targetFile.content_sha256) {
|
|
31
|
+
return "skip";
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
logger.warn(
|
|
35
|
+
`Unable to retrieve detailed information for remote file ${filePath}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return "update";
|
|
39
|
+
}
|
|
40
|
+
return "create";
|
|
18
41
|
}
|
|
19
42
|
return defaultCommitAction;
|
|
20
43
|
}
|
|
@@ -62,7 +85,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
62
85
|
sourcePath: {
|
|
63
86
|
type: "string",
|
|
64
87
|
title: "Working Subdirectory",
|
|
65
|
-
description:
|
|
88
|
+
description: `Subdirectory of working directory to copy changes from. For reasons of backward compatibility, any specified 'targetPath' input will be applied in place of an absent/falsy value for this input. Circumvent this behavior using '.'`
|
|
66
89
|
},
|
|
67
90
|
targetPath: {
|
|
68
91
|
type: "string",
|
|
@@ -78,7 +101,8 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
78
101
|
title: "Commit action",
|
|
79
102
|
type: "string",
|
|
80
103
|
enum: ["create", "update", "delete", "auto"],
|
|
81
|
-
description:
|
|
104
|
+
description: `The action to be used for git commit. Defaults to the custom 'auto' action provided by backstage,
|
|
105
|
+
which uses additional API calls in order to detect whether to 'create', 'update' or 'skip' each source file.`
|
|
82
106
|
},
|
|
83
107
|
removeSourceBranch: {
|
|
84
108
|
title: "Delete source branch",
|
|
@@ -164,7 +188,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
164
188
|
targetBranch = defaultBranch;
|
|
165
189
|
}
|
|
166
190
|
let remoteFiles = [];
|
|
167
|
-
if (
|
|
191
|
+
if ((ctx.input.commitAction ?? "auto") === "auto") {
|
|
168
192
|
try {
|
|
169
193
|
remoteFiles = await api.Repositories.tree(repoID, {
|
|
170
194
|
ref: targetBranch,
|
|
@@ -177,30 +201,56 @@ const createPublishGitlabMergeRequestAction = (options) => {
|
|
|
177
201
|
);
|
|
178
202
|
}
|
|
179
203
|
}
|
|
180
|
-
const actions =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
204
|
+
const actions = ctx.input.commitAction === "skip" ? [] : (await Promise.all(
|
|
205
|
+
fileContents.map(async (file) => {
|
|
206
|
+
const action = await getFileAction(
|
|
207
|
+
{ file, targetPath },
|
|
208
|
+
{ repoID, branch: targetBranch },
|
|
209
|
+
api,
|
|
210
|
+
ctx.logger,
|
|
211
|
+
remoteFiles,
|
|
212
|
+
ctx.input.commitAction
|
|
213
|
+
);
|
|
214
|
+
return { file, action };
|
|
215
|
+
})
|
|
216
|
+
)).filter((o) => o.action !== "skip").map(({ file, action }) => ({
|
|
217
|
+
action,
|
|
186
218
|
filePath: targetPath ? path__default.default.posix.join(targetPath, file.path) : file.path,
|
|
187
219
|
encoding: "base64",
|
|
188
220
|
content: file.content.toString("base64"),
|
|
189
221
|
execute_filemode: file.executable
|
|
190
222
|
}));
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
223
|
+
let createBranch;
|
|
224
|
+
if (actions.length) {
|
|
225
|
+
createBranch = true;
|
|
226
|
+
} else {
|
|
227
|
+
try {
|
|
228
|
+
await api.Branches.show(repoID, branchName);
|
|
229
|
+
createBranch = false;
|
|
230
|
+
ctx.logger.info(
|
|
231
|
+
`Using existing branch ${branchName} without modification.`
|
|
232
|
+
);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
createBranch = true;
|
|
235
|
+
}
|
|
197
236
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
237
|
+
if (createBranch) {
|
|
238
|
+
try {
|
|
239
|
+
await api.Branches.create(repoID, branchName, String(targetBranch));
|
|
240
|
+
} catch (e) {
|
|
241
|
+
throw new errors.InputError(
|
|
242
|
+
`The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (actions.length) {
|
|
247
|
+
try {
|
|
248
|
+
await api.Commits.create(repoID, branchName, title, actions);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
throw new errors.InputError(
|
|
251
|
+
`Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
204
254
|
}
|
|
205
255
|
try {
|
|
206
256
|
const mergeRequestUrl = await api.MergeRequests.create(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabMergeRequest.cjs.js","sources":["../../src/actions/gitlabMergeRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Types } from '@gitbeaker/core';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabMergeRequest.examples';\n\nfunction getFileAction(\n fileInfo: { file: SerializedFile; targetPath: string | undefined },\n remoteFiles: Types.RepositoryTreeSchema[],\n defaultCommitAction: 'create' | 'delete' | 'update' | 'auto' | undefined,\n): 'create' | 'delete' | 'update' {\n if (!defaultCommitAction || defaultCommitAction === 'auto') {\n const filePath = path.join(fileInfo.targetPath ?? '', fileInfo.file.path);\n return remoteFiles &&\n remoteFiles.some(remoteFile => remoteFile.path === filePath)\n ? 'update'\n : 'create';\n }\n return defaultCommitAction;\n}\n\n/**\n * Create a new action that creates a gitlab merge request.\n *\n * @public\n */\nexport const createPublishGitlabMergeRequestAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n title: string;\n description: string;\n branchName: string;\n targetBranchName?: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update' | 'auto';\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid?: string;\n removeSourceBranch?: boolean;\n assignee?: string;\n }>({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n },\n /** @deprecated projectID is passed as query parameters in the repoUrl */\n projectid: {\n type: 'string',\n title: 'projectid',\n description: 'Project ID/Name(slug) of the Gitlab Project',\n },\n title: {\n type: 'string',\n title: 'Merge Request Name',\n description: 'The name for the merge request',\n },\n description: {\n type: 'string',\n title: 'Merge Request Description',\n description: 'The description of the merge request',\n },\n branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The source branch name of the merge request',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete', 'auto'],\n description:\n 'The action to be used for git commit. Defaults to auto. \"auto\" is custom action provide by backstage, (automatic assign create or update action) /!\\\\ Use more api calls /!\\\\ *',\n },\n removeSourceBranch: {\n title: 'Delete source branch',\n type: 'boolean',\n description:\n 'Option to delete source branch once the MR has been merged. Default: false',\n },\n assignee: {\n title: 'Merge Request Assignee',\n type: 'string',\n description: 'User this merge request will be assigned to',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n mergeRequestUrl: {\n title: 'MergeRequest(MR) URL',\n type: 'string',\n description: 'Link to the merge request in GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n assignee,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\n } = ctx.input;\n\n const { owner, repo, project } = parseRepoUrl(repoUrl, integrations);\n const repoID = project ? project : `${owner}/${repo}`;\n\n const api = createGitlabApi({\n integrations,\n token,\n repoUrl,\n });\n\n let assigneeId = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.username(assignee);\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,\n );\n }\n }\n\n let fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else if (targetPath) {\n // for backward compatibility\n fileRoot = resolveSafeChildPath(ctx.workspacePath, targetPath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let targetBranch = targetBranchName;\n if (!targetBranch) {\n const projects = await api.Projects.show(repoID);\n\n const { default_branch: defaultBranch } = projects;\n targetBranch = defaultBranch!;\n }\n\n let remoteFiles: Types.RepositoryTreeSchema[] = [];\n if (!ctx.input.commitAction || ctx.input.commitAction === 'auto') {\n try {\n remoteFiles = await api.Repositories.tree(repoID, {\n ref: targetBranch,\n recursive: true,\n path: targetPath ?? undefined,\n });\n } catch (e) {\n ctx.logger.warn(\n `Could not retrieve the list of files for ${repoID} (branch: ${targetBranch}) : ${e}`,\n );\n }\n }\n\n const actions: Types.CommitAction[] = fileContents.map(file => ({\n action: getFileAction(\n { file, targetPath },\n remoteFiles,\n ctx.input.commitAction,\n ),\n filePath: targetPath\n ? path.posix.join(targetPath, file.path)\n : file.path,\n encoding: 'base64',\n content: file.content.toString('base64'),\n execute_filemode: file.executable,\n }));\n\n try {\n await api.Branches.create(repoID, branchName, String(targetBranch));\n } catch (e) {\n throw new InputError(\n `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`,\n );\n }\n\n try {\n await api.Commits.create(repoID, branchName, ctx.input.title, actions);\n } catch (e) {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`,\n );\n }\n\n try {\n const mergeRequestUrl = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,\n assigneeId,\n },\n ).then((mergeRequest: { web_url: string }) => {\n return mergeRequest.web_url;\n });\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mergeRequestUrl);\n } catch (e) {\n throw new InputError(`Merge request creation failed${e}`);\n }\n },\n });\n};\n"],"names":["path","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;AA8BA,SAAS,aAAA,CACP,QACA,EAAA,WAAA,EACA,mBACgC,EAAA;AAChC,EAAI,IAAA,CAAC,mBAAuB,IAAA,mBAAA,KAAwB,MAAQ,EAAA;AAC1D,IAAM,MAAA,QAAA,GAAWA,sBAAK,IAAK,CAAA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A;AAAA,UACA,OAAO,YAAY,CAAA;AAAA,UACnB,KAAA;AAAA,UACA;AAAA,YACE,WAAA;AAAA,YACA,kBAAA,EAAoB,qBAAqB,kBAAqB,GAAA,KAAA;AAAA,YAC9D,UAAA;AAAA,WACF;AAAA,SACF,CAAE,IAAK,CAAA,CAAC,YAAsC,KAAA;AAC5C,UAAA,OAAO,YAAa,CAAA,OAAA,CAAA;AAAA,SACrB,CAAA,CAAA;AACD,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,MAAM,CAAA,CAAA;AAC9B,QAAI,GAAA,CAAA,MAAA,CAAO,oBAAoB,YAAY,CAAA,CAAA;AAC3C,QAAI,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,eACtC,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,OAC1D;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabMergeRequest.cjs.js","sources":["../../src/actions/gitlabMergeRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, Types } from '@gitbeaker/core';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabMergeRequest.examples';\nimport { createHash } from 'crypto';\n\nfunction computeSha256(file: SerializedFile): string {\n const hash = createHash('sha256');\n hash.update(file.content);\n return hash.digest('hex');\n}\n\nasync function getFileAction(\n fileInfo: { file: SerializedFile; targetPath?: string },\n target: { repoID: string; branch: string },\n api: Gitlab,\n logger: LoggerService,\n remoteFiles: Types.RepositoryTreeSchema[],\n defaultCommitAction:\n | 'create'\n | 'delete'\n | 'update'\n | 'skip'\n | 'auto' = 'auto',\n): Promise<'create' | 'delete' | 'update' | 'skip'> {\n if (defaultCommitAction === 'auto') {\n const filePath = path.join(fileInfo.targetPath ?? '', fileInfo.file.path);\n\n if (remoteFiles?.some(remoteFile => remoteFile.path === filePath)) {\n try {\n const targetFile = await api.RepositoryFiles.show(\n target.repoID,\n filePath,\n target.branch,\n );\n if (computeSha256(fileInfo.file) === targetFile.content_sha256) {\n return 'skip';\n }\n } catch (error) {\n logger.warn(\n `Unable to retrieve detailed information for remote file ${filePath}`,\n );\n }\n return 'update';\n }\n return 'create';\n }\n return defaultCommitAction;\n}\n\n/**\n * Create a new action that creates a gitlab merge request.\n *\n * @public\n */\nexport const createPublishGitlabMergeRequestAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n title: string;\n description: string;\n branchName: string;\n targetBranchName?: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update' | 'skip' | 'auto';\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid?: string;\n removeSourceBranch?: boolean;\n assignee?: string;\n }>({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\n description: `\\\nAccepts the format 'gitlab.com?repo=project_name&owner=group_name' where \\\n'project_name' is the repository name and 'group_name' is a group or username`,\n },\n /** @deprecated projectID is passed as query parameters in the repoUrl */\n projectid: {\n type: 'string',\n title: 'projectid',\n description: 'Project ID/Name(slug) of the Gitlab Project',\n },\n title: {\n type: 'string',\n title: 'Merge Request Name',\n description: 'The name for the merge request',\n },\n description: {\n type: 'string',\n title: 'Merge Request Description',\n description: 'The description of the merge request',\n },\n branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The source branch name of the merge request',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description: `\\\nSubdirectory of working directory to copy changes from. \\\nFor reasons of backward compatibility, any specified 'targetPath' input will \\\nbe applied in place of an absent/falsy value for this input. \\\nCircumvent this behavior using '.'`,\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete', 'auto'],\n description: `\\\nThe action to be used for git commit. Defaults to the custom 'auto' action provided by backstage,\nwhich uses additional API calls in order to detect whether to 'create', 'update' or 'skip' each source file.`,\n },\n removeSourceBranch: {\n title: 'Delete source branch',\n type: 'boolean',\n description:\n 'Option to delete source branch once the MR has been merged. Default: false',\n },\n assignee: {\n title: 'Merge Request Assignee',\n type: 'string',\n description: 'User this merge request will be assigned to',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n mergeRequestUrl: {\n title: 'MergeRequest(MR) URL',\n type: 'string',\n description: 'Link to the merge request in GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n assignee,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\n } = ctx.input;\n\n const { owner, repo, project } = parseRepoUrl(repoUrl, integrations);\n const repoID = project ? project : `${owner}/${repo}`;\n\n const api = createGitlabApi({\n integrations,\n token,\n repoUrl,\n });\n\n let assigneeId = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.username(assignee);\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,\n );\n }\n }\n\n let fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else if (targetPath) {\n // for backward compatibility\n fileRoot = resolveSafeChildPath(ctx.workspacePath, targetPath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let targetBranch = targetBranchName;\n if (!targetBranch) {\n const projects = await api.Projects.show(repoID);\n\n const { default_branch: defaultBranch } = projects;\n targetBranch = defaultBranch!;\n }\n\n let remoteFiles: Types.RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.tree(repoID, {\n ref: targetBranch,\n recursive: true,\n path: targetPath ?? undefined,\n });\n } catch (e) {\n ctx.logger.warn(\n `Could not retrieve the list of files for ${repoID} (branch: ${targetBranch}) : ${e}`,\n );\n }\n }\n const actions: Types.CommitAction[] =\n ctx.input.commitAction === 'skip'\n ? []\n : (\n (\n await Promise.all(\n fileContents.map(async file => {\n const action = await getFileAction(\n { file, targetPath },\n { repoID, branch: targetBranch! },\n api,\n ctx.logger,\n remoteFiles,\n ctx.input.commitAction,\n );\n return { file, action };\n }),\n )\n ).filter(o => o.action !== 'skip') as {\n file: SerializedFile;\n action: Types.CommitAction['action'];\n }[]\n ).map(({ file, action }) => ({\n action,\n filePath: targetPath\n ? path.posix.join(targetPath, file.path)\n : file.path,\n encoding: 'base64',\n content: file.content.toString('base64'),\n execute_filemode: file.executable,\n }));\n\n let createBranch: boolean;\n if (actions.length) {\n createBranch = true;\n } else {\n try {\n await api.Branches.show(repoID, branchName);\n createBranch = false;\n ctx.logger.info(\n `Using existing branch ${branchName} without modification.`,\n );\n } catch (e) {\n createBranch = true;\n }\n }\n if (createBranch) {\n try {\n await api.Branches.create(repoID, branchName, String(targetBranch));\n } catch (e) {\n throw new InputError(\n `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`,\n );\n }\n }\n if (actions.length) {\n try {\n await api.Commits.create(repoID, branchName, title, actions);\n } catch (e) {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`,\n );\n }\n }\n try {\n const mergeRequestUrl = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,\n assigneeId,\n },\n ).then((mergeRequest: { web_url: string }) => {\n return mergeRequest.web_url;\n });\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mergeRequestUrl);\n } catch (e) {\n throw new InputError(`Merge request creation failed${e}`);\n }\n },\n });\n};\n"],"names":["createHash","path","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;;AAkCA,SAAS,cAAc,IAA8B,EAAA;AACnD,EAAM,MAAA,IAAA,GAAOA,kBAAW,QAAQ,CAAA,CAAA;AAChC,EAAK,IAAA,CAAA,MAAA,CAAO,KAAK,OAAO,CAAA,CAAA;AACxB,EAAO,OAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAC1B,CAAA;AAEA,eAAe,cACb,QACA,EAAA,MAAA,E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,MAAQ,EAAA,UAAA,EAAY,OAAO,OAAO,CAAA,CAAA;AAAA,iBACpD,CAAG,EAAA;AACV,UAAA,MAAM,IAAIA,iBAAA;AAAA,YACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,qFAAA,EAAwF,CAAC,CAAA,CAAA;AAAA,WAClI,CAAA;AAAA,SACF;AAAA,OACF;AACA,MAAI,IAAA;AACF,QAAM,MAAA,eAAA,GAAkB,MAAM,GAAA,CAAI,aAAc,CAAA,MAAA;AAAA,UAC9C,MAAA;AAAA,UACA,UAAA;AAAA,UACA,OAAO,YAAY,CAAA;AAAA,UACnB,KAAA;AAAA,UACA;AAAA,YACE,WAAA;AAAA,YACA,kBAAA,EAAoB,qBAAqB,kBAAqB,GAAA,KAAA;AAAA,YAC9D,UAAA;AAAA,WACF;AAAA,SACF,CAAE,IAAK,CAAA,CAAC,YAAsC,KAAA;AAC5C,UAAA,OAAO,YAAa,CAAA,OAAA,CAAA;AAAA,SACrB,CAAA,CAAA;AACD,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,MAAM,CAAA,CAAA;AAC9B,QAAI,GAAA,CAAA,MAAA,CAAO,oBAAoB,YAAY,CAAA,CAAA;AAC3C,QAAI,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,eACtC,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,OAC1D;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ declare const createPublishGitlabMergeRequestAction: (options: {
|
|
|
175
175
|
sourcePath?: string | undefined;
|
|
176
176
|
targetPath?: string | undefined;
|
|
177
177
|
token?: string | undefined;
|
|
178
|
-
commitAction?: "auto" | "update" | "delete" | "create" | undefined;
|
|
178
|
+
commitAction?: "auto" | "update" | "delete" | "create" | "skip" | undefined;
|
|
179
179
|
/** @deprecated projectID passed as query parameters in the repoUrl */
|
|
180
180
|
projectid?: string | undefined;
|
|
181
181
|
removeSourceBranch?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitlab",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1-next.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "scaffolder",
|
|
@@ -44,22 +44,23 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@backstage/backend-common": "^0.25.0",
|
|
47
|
-
"@backstage/backend-plugin-api": "1.0.
|
|
47
|
+
"@backstage/backend-plugin-api": "1.0.2-next.0",
|
|
48
48
|
"@backstage/config": "1.2.0",
|
|
49
49
|
"@backstage/errors": "1.2.4",
|
|
50
|
-
"@backstage/integration": "1.15.1
|
|
51
|
-
"@backstage/plugin-scaffolder-node": "0.5.
|
|
50
|
+
"@backstage/integration": "1.15.1",
|
|
51
|
+
"@backstage/plugin-scaffolder-node": "0.5.1-next.0",
|
|
52
52
|
"@gitbeaker/core": "^35.8.0",
|
|
53
53
|
"@gitbeaker/node": "^35.8.0",
|
|
54
54
|
"@gitbeaker/rest": "^39.25.0",
|
|
55
55
|
"luxon": "^3.0.0",
|
|
56
|
+
"winston": "^3.2.1",
|
|
56
57
|
"yaml": "^2.0.0",
|
|
57
58
|
"zod": "^3.22.4"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@backstage/backend-test-utils": "1.0.
|
|
61
|
-
"@backstage/cli": "0.
|
|
62
|
-
"@backstage/core-app-api": "1.15.1
|
|
63
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.1.
|
|
61
|
+
"@backstage/backend-test-utils": "1.0.3-next.0",
|
|
62
|
+
"@backstage/cli": "0.29.0-next.0",
|
|
63
|
+
"@backstage/core-app-api": "1.15.1",
|
|
64
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.1.15-next.0"
|
|
64
65
|
}
|
|
65
66
|
}
|