@backstage/plugin-scaffolder-backend-module-gitlab 0.11.4-next.1 → 0.11.4
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 +26 -0
- package/dist/actions/gitlab.cjs.js +32 -0
- package/dist/actions/gitlab.cjs.js.map +1 -1
- package/dist/actions/gitlab.examples.cjs.js +34 -0
- package/dist/actions/gitlab.examples.cjs.js.map +1 -1
- package/dist/commonGitlabConfig.cjs.js +4 -4
- package/dist/commonGitlabConfig.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/util.cjs.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.11.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5730c8e: Added `maskedAndHidden` option to `gitlab:projectVariable:create` and `publish:gitlab` action to support creating GitLab project variables that are both masked and hidden. Updated gitbeaker to version 43.8.0 for proper type support.
|
|
8
|
+
- 0c1726a: Added new `gitlab:group:access` scaffolder action to add or remove users and groups as members of GitLab groups. The action supports specifying members via `userIds` and/or `groupIds` array parameters, configurable access levels (Guest, Reporter, Developer, Maintainer, Owner), and defaults to the 'add' action when not specified.
|
|
9
|
+
- 4b8fcf0: Added two optional inputs to the `publish:gitlab` action:
|
|
10
|
+
|
|
11
|
+
- `settings.name`: set a custom human-readable project title that differs from the repository slug.
|
|
12
|
+
- `ownerUsername`: add a specific GitLab user as project owner (access level 50) of the newly created repository. Requires a privileged token in the integration configuration.
|
|
13
|
+
|
|
14
|
+
- a49a40d: Updated dependency `zod` to `^3.25.76 || ^4.0.0` & migrated to `/v3` or `/v4` imports.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/backend-plugin-api@1.8.0
|
|
17
|
+
- @backstage/plugin-scaffolder-node@0.13.0
|
|
18
|
+
- @backstage/integration@2.0.0
|
|
19
|
+
|
|
20
|
+
## 0.11.4-next.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @backstage/backend-plugin-api@1.8.0-next.1
|
|
26
|
+
- @backstage/integration@2.0.0-next.2
|
|
27
|
+
- @backstage/plugin-scaffolder-node@0.13.0-next.2
|
|
28
|
+
|
|
3
29
|
## 0.11.4-next.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -46,10 +46,16 @@ function createPublishGitlabAction(options) {
|
|
|
46
46
|
setUserAsOwner: (z) => z.boolean({
|
|
47
47
|
description: "Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host"
|
|
48
48
|
}).optional(),
|
|
49
|
+
ownerUsername: (z) => z.string({
|
|
50
|
+
description: "Username of a GitLab user to add as owner (access level 50) of the newly created project. Requires a privileged token in the integration configuration for the matching host."
|
|
51
|
+
}).optional(),
|
|
49
52
|
topics: (z) => z.array(z.string(), {
|
|
50
53
|
description: "Topic labels to apply on the repository. (deprecated, use settings.topics instead)"
|
|
51
54
|
}).optional(),
|
|
52
55
|
settings: (z) => z.object({
|
|
56
|
+
name: z.string({
|
|
57
|
+
description: "Human-readable project name (title). If not provided, the repository name from repoUrl is used."
|
|
58
|
+
}).optional(),
|
|
53
59
|
path: z.string({
|
|
54
60
|
description: "Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes)."
|
|
55
61
|
}).optional(),
|
|
@@ -189,6 +195,7 @@ function createPublishGitlabAction(options) {
|
|
|
189
195
|
const { id: projectId, http_url_to_repo } = await client.Projects.create({
|
|
190
196
|
namespaceId: targetNamespaceId,
|
|
191
197
|
name: repo,
|
|
198
|
+
path: repo,
|
|
192
199
|
visibility: repoVisibility,
|
|
193
200
|
...topics.length ? { topics } : {},
|
|
194
201
|
...Object.keys(settings).length ? { ...settings } : {}
|
|
@@ -200,6 +207,31 @@ function createPublishGitlabAction(options) {
|
|
|
200
207
|
});
|
|
201
208
|
await adminClient.ProjectMembers.add(projectId, 50, { userId });
|
|
202
209
|
}
|
|
210
|
+
if (ctx.input.ownerUsername && integrationConfig.config.token) {
|
|
211
|
+
try {
|
|
212
|
+
const adminClient = new rest.Gitlab({
|
|
213
|
+
host: integrationConfig.config.baseUrl,
|
|
214
|
+
token: integrationConfig.config.token
|
|
215
|
+
});
|
|
216
|
+
const users = await adminClient.Users.all({
|
|
217
|
+
username: ctx.input.ownerUsername
|
|
218
|
+
});
|
|
219
|
+
if (users.length > 0) {
|
|
220
|
+
await adminClient.ProjectMembers.add(projectId, 50, {
|
|
221
|
+
userId: users[0].id
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
ctx.logger.warn(
|
|
225
|
+
`Could not find GitLab user with username '${ctx.input.ownerUsername}'. Skipping owner assignment.`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {
|
|
229
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
230
|
+
ctx.logger.warn(
|
|
231
|
+
`Failed to add user '${ctx.input.ownerUsername}' as owner: ${errorMessage}. Proceeding without owner assignment.`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
203
235
|
const remoteUrl = http_url_to_repo.replace(/\.git$/, "");
|
|
204
236
|
const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;
|
|
205
237
|
const gitAuthorInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n masked_and_hidden: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, 50, { userId });\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n masked_and_hidden: variable.masked_and_hidden ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n masked_and_hidden: variableWithDefaults.masked_and_hidden,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAGvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAA,EAAO,GAAI,OAAA;AAEjC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,2FAAA;AAAA,cACFC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,cAAA,EAAgB,OACd,CAAA,CACG,IAAA,CAAK,CAAC,SAAA,EAAW,QAAA,EAAU,UAAU,CAAA,EAAG;AAAA,UACvC,WAAA,EAAa,CAAA,oHAAA;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,MAAA,CAAO;AAAA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;AAC7C,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,IAAI,CAAA;AAAA,MAC5B,WAAW,eAAA,EAAiB;AAC1B,QAAA,GAAA,CAAI,OAAO,IAAA,CAAK,CAAA,KAAA,EAAQ,IAAI,CAAA,6BAAA,EAAgC,KAAK,CAAA,CAAA,CAAG,CAAA;AACpE,QAAA,MAAM;AAAA,UACJ,EAAA,EAAI,SAAA;AAAA,UACJ,gBAAA;AAAA,UACA;AAAA,SACF,GAAI,eAAA;AACJ,QAAA,MAAM,SAAA,GAAa,gBAAA,CAA4B,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAA;AACnE,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,OAAO,iBAAA,EAAmB,CAAA,EAAG,SAAS,CAAA,QAAA,EAAW,cAAc,CAAA,CAAE,CAAA;AACrE,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,MAC7B;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAEA,SAAS,iBAAiB,KAAA,EAAoB;AAC5C,EAAA,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\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 repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n ownerUsername: z =>\n z\n .string({\n description:\n 'Username of a GitLab user to add as owner (access level 50) of the newly created project. Requires a privileged token in the integration configuration for the matching host.',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n name: z\n .string({\n description:\n 'Human-readable project name (title). If not provided, the repository name from repoUrl is used.',\n })\n .optional(),\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n masked_and_hidden: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n path: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, 50, { userId });\n }\n\n if (ctx.input.ownerUsername && integrationConfig.config.token) {\n try {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n const users = await adminClient.Users.all({\n username: ctx.input.ownerUsername,\n });\n if (users.length > 0) {\n await adminClient.ProjectMembers.add(projectId, 50, {\n userId: users[0].id,\n });\n } else {\n ctx.logger.warn(\n `Could not find GitLab user with username '${ctx.input.ownerUsername}'. Skipping owner assignment.`,\n );\n }\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n ctx.logger.warn(\n `Failed to add user '${ctx.input.ownerUsername}' as owner: ${errorMessage}. Proceeding without owner assignment.`,\n );\n }\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n masked_and_hidden: variable.masked_and_hidden ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n masked_and_hidden: variableWithDefaults.masked_and_hidden,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AAkCO,SAAS,0BAA0B,OAAA,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ACrE,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,MAC7B;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAEA,SAAS,iBAAiB,KAAA,EAAoB;AAC5C,EAAA,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
|
|
@@ -203,6 +203,40 @@ const examples = [
|
|
|
203
203
|
}
|
|
204
204
|
]
|
|
205
205
|
})
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
description: "Initializes a GitLab repository with a custom project title that differs from the repository slug.",
|
|
209
|
+
example: yaml__default.default.stringify({
|
|
210
|
+
steps: [
|
|
211
|
+
{
|
|
212
|
+
id: "publish",
|
|
213
|
+
action: "publish:gitlab",
|
|
214
|
+
name: "Publish to GitLab",
|
|
215
|
+
input: {
|
|
216
|
+
repoUrl: "gitlab.com?repo=my-project-slug&owner=group_name",
|
|
217
|
+
settings: {
|
|
218
|
+
name: "My Project Title"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
description: "Initializes a GitLab repository and adds a specific user as project owner.",
|
|
227
|
+
example: yaml__default.default.stringify({
|
|
228
|
+
steps: [
|
|
229
|
+
{
|
|
230
|
+
id: "publish",
|
|
231
|
+
action: "publish:gitlab",
|
|
232
|
+
name: "Publish to GitLab",
|
|
233
|
+
input: {
|
|
234
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
235
|
+
ownerUsername: "john.doe"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
})
|
|
206
240
|
}
|
|
207
241
|
];
|
|
208
242
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.examples.cjs.js","sources":["../../src/actions/gitlab.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitLab with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n },\n },\n ],\n }),\n },\n {\n description: 'Add a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with an initial commit message, if not set defaults to `initial commit`.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n gitCommitMessage: 'Started a project.',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with additional settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n ci_config_path: '.gitlab-ci.yml',\n visibility: 'public',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with fast forward merge and always squash settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n merge_method: 'ff',\n squash_option: 'always',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with branch settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n branches: [\n {\n name: 'dev',\n create: true,\n protect: true,\n ref: 'master',\n },\n {\n name: 'master',\n protect: true,\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with environment variables.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n projectVariables: [\n {\n key: 'key1',\n value: 'value1',\n protected: true,\n masked: false,\n },\n {\n key: 'key2',\n value: 'value2',\n protected: true,\n masked: false,\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with pipeline must succeed and allow merge on skipped pipeline settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n only_allow_merge_if_pipeline_succeeds: true,\n allow_merge_on_skipped_pipeline: true,\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with setting to require all threads (discussions) on merge request to be resolved before merging.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n only_allow_merge_if_all_discussions_are_resolved: true,\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with the default readme and no files from workspace only if this repository does not exist yet.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n skipExisting: true,\n initialize_with_readme: true,\n sourcePath: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,+CAAA;AAAA,YACT,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,0GAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,+CAAA;AAAA,YACT,WAAA,EAAa,6BAAA;AAAA,YACb,gBAAA,EAAkB;AAAA;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AAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,+CAAA;AAAA,YACT,QAAA,EAAU;AAAA,cACR,gDAAA,EAAkD;AAAA;AACpD;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,iIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,+CAAA;AAAA,YACT,YAAA,EAAc,IAAA;AAAA,YACd,sBAAA,EAAwB,IAAA;AAAA,YACxB,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlab.examples.cjs.js","sources":["../../src/actions/gitlab.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitLab with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n },\n },\n ],\n }),\n },\n {\n description: 'Add a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with an initial commit message, if not set defaults to `initial commit`.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n gitCommitMessage: 'Started a project.',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with additional settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n ci_config_path: '.gitlab-ci.yml',\n visibility: 'public',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with fast forward merge and always squash settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n merge_method: 'ff',\n squash_option: 'always',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with branch settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n branches: [\n {\n name: 'dev',\n create: true,\n protect: true,\n ref: 'master',\n },\n {\n name: 'master',\n protect: true,\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitLab repository with environment variables.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n projectVariables: [\n {\n key: 'key1',\n value: 'value1',\n protected: true,\n masked: false,\n },\n {\n key: 'key2',\n value: 'value2',\n protected: true,\n masked: false,\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with pipeline must succeed and allow merge on skipped pipeline settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n only_allow_merge_if_pipeline_succeeds: true,\n allow_merge_on_skipped_pipeline: true,\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with setting to require all threads (discussions) on merge request to be resolved before merging.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n only_allow_merge_if_all_discussions_are_resolved: true,\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with the default readme and no files from workspace only if this repository does not exist yet.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n skipExisting: true,\n initialize_with_readme: true,\n sourcePath: false,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository with a custom project title that differs from the repository slug.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=my-project-slug&owner=group_name',\n settings: {\n name: 'My Project Title',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitLab repository and adds a specific user as project owner.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n ownerUsername: 'john.doe',\n },\n },\n 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.string({ description: "Repository Location" }),
|
|
7
|
+
token: v3.z.string({ description: "The token to use for authorization to GitLab" }).optional()
|
|
8
8
|
});
|
|
9
9
|
const commonGitlabConfigExample = {
|
|
10
10
|
repoUrl: "gitlab.com?owner=namespace-or-owner&repo=project-name",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonGitlabConfig.cjs.js","sources":["../src/commonGitlabConfig.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/* We want to maintain the same information as an enum, so we disable the redeclaration warning */\n/* eslint-disable @typescript-eslint/no-redeclare */\n\nimport { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n\nexport const commonGitlabConfigExample = {\n repoUrl: 'gitlab.com?owner=namespace-or-owner&repo=project-name',\n token: '${{ secrets.USER_OAUTH_TOKEN }}',\n};\n\n/**\n * Gitlab issue types as specified by gitlab api\n *\n * @public\n */\nexport const IssueType = {\n ISSUE: 'issue',\n INCIDENT: 'incident',\n TEST: 'test_case',\n TASK: 'task',\n} as const;\n\n/**\n * @public\n */\nexport type IssueType = (typeof IssueType)[keyof typeof IssueType];\n\n/**\n * @public\n */\nexport namespace IssueType {\n export type ISSUE = typeof IssueType.ISSUE;\n export type INCIDENT = typeof IssueType.INCIDENT;\n export type TEST = typeof IssueType.TEST;\n export type TASK = typeof IssueType.TASK;\n}\n\n/**\n * Gitlab issue state events for modifications\n *\n * @public\n */\nexport const IssueStateEvent = {\n CLOSE: 'close',\n REOPEN: 'reopen',\n} as const;\n\n/**\n * @public\n */\nexport type IssueStateEvent =\n (typeof IssueStateEvent)[keyof typeof IssueStateEvent];\n\n/**\n * @public\n */\nexport namespace IssueStateEvent {\n export type CLOSE = typeof IssueStateEvent.CLOSE;\n export type REOPEN = typeof IssueStateEvent.REOPEN;\n}\n"],"names":["z"],"mappings":";;;;AAoB2BA,
|
|
1
|
+
{"version":3,"file":"commonGitlabConfig.cjs.js","sources":["../src/commonGitlabConfig.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/* We want to maintain the same information as an enum, so we disable the redeclaration warning */\n/* eslint-disable @typescript-eslint/no-redeclare */\n\nimport { z } from 'zod/v3';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n\nexport const commonGitlabConfigExample = {\n repoUrl: 'gitlab.com?owner=namespace-or-owner&repo=project-name',\n token: '${{ secrets.USER_OAUTH_TOKEN }}',\n};\n\n/**\n * Gitlab issue types as specified by gitlab api\n *\n * @public\n */\nexport const IssueType = {\n ISSUE: 'issue',\n INCIDENT: 'incident',\n TEST: 'test_case',\n TASK: 'task',\n} as const;\n\n/**\n * @public\n */\nexport type IssueType = (typeof IssueType)[keyof typeof IssueType];\n\n/**\n * @public\n */\nexport namespace IssueType {\n export type ISSUE = typeof IssueType.ISSUE;\n export type INCIDENT = typeof IssueType.INCIDENT;\n export type TEST = typeof IssueType.TEST;\n export type TASK = typeof IssueType.TASK;\n}\n\n/**\n * Gitlab issue state events for modifications\n *\n * @public\n */\nexport const IssueStateEvent = {\n CLOSE: 'close',\n REOPEN: 'reopen',\n} as const;\n\n/**\n * @public\n */\nexport type IssueStateEvent =\n (typeof IssueStateEvent)[keyof typeof IssueStateEvent];\n\n/**\n * @public\n */\nexport namespace IssueStateEvent {\n export type CLOSE = typeof IssueStateEvent.CLOSE;\n export type REOPEN = typeof IssueStateEvent.REOPEN;\n}\n"],"names":["z"],"mappings":";;;;AAoB2BA,KAAE,MAAA,CAAO;AAAA,EAClC,SAASA,IAAA,CAAE,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,KACJ,MAAA,CAAO,EAAE,aAAa,8CAAA,EAAgD,EACtE,QAAA;AACL,CAAC;AAIM,MAAM,yBAAA,GAA4B;AAAA,EACvC,OAAA,EAAS,uDAAA;AAAA,EACT,KAAA,EAAO;AACT;AAOO,MAAM,SAAA,GAAY;AAAA,EACvB,KAAA,EAAO,OAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,WAAA;AAAA,EACN,IAAA,EAAM;AACR;AAsBO,MAAM,eAAA,GAAkB;AAAA,EAC7B,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ;AACV;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,10 @@ declare function createPublishGitlabAction(options: {
|
|
|
24
24
|
skipExisting?: boolean | undefined;
|
|
25
25
|
token?: string | undefined;
|
|
26
26
|
setUserAsOwner?: boolean | undefined;
|
|
27
|
+
ownerUsername?: string | undefined;
|
|
27
28
|
topics?: string[] | undefined;
|
|
28
29
|
settings?: {
|
|
30
|
+
name?: string | undefined;
|
|
29
31
|
visibility?: "internal" | "private" | "public" | undefined;
|
|
30
32
|
path?: string | undefined;
|
|
31
33
|
description?: string | undefined;
|
|
@@ -189,7 +191,7 @@ declare const createPublishGitlabMergeRequestAction: (options: {
|
|
|
189
191
|
sourcePath?: string | undefined;
|
|
190
192
|
targetPath?: string | undefined;
|
|
191
193
|
token?: string | undefined;
|
|
192
|
-
commitAction?: "auto" | "update" | "
|
|
194
|
+
commitAction?: "auto" | "update" | "create" | "delete" | "skip" | undefined;
|
|
193
195
|
projectid?: string | undefined;
|
|
194
196
|
removeSourceBranch?: boolean | undefined;
|
|
195
197
|
assignee?: string | undefined;
|
|
@@ -300,7 +302,7 @@ declare const createGitlabRepoPushAction: (options: {
|
|
|
300
302
|
sourcePath?: string | undefined;
|
|
301
303
|
targetPath?: string | undefined;
|
|
302
304
|
token?: string | undefined;
|
|
303
|
-
commitAction?: "auto" | "update" | "
|
|
305
|
+
commitAction?: "auto" | "update" | "create" | "delete" | undefined;
|
|
304
306
|
}, {
|
|
305
307
|
projectid: string;
|
|
306
308
|
projectPath: string;
|
package/dist/util.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.cjs.js","sources":["../src/util.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Gitlab, GroupSchema, RepositoryTreeSchema } from '@gitbeaker/rest';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\n\nimport { SerializedFile } from '@backstage/plugin-scaffolder-node';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n config: z.infer<typeof commonGitlabConfig>,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(config.repoUrl);\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const token = config.token || integrationConfig.config.token!;\n\n return { token: token, integrationConfig: integrationConfig };\n};\n\nexport type RepoSpec = {\n repo: string;\n host: string;\n owner?: string;\n};\n\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): RepoSpec => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const repo: string = parsed.searchParams.get('repo')!;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n return { host, owner, repo };\n};\n\nexport function getClient(props: {\n host: string;\n token?: string;\n integrations: ScmIntegrationRegistry;\n}): InstanceType<typeof Gitlab> {\n const { host, token, integrations } = props;\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const { config } = integrationConfig;\n\n if (!config.token && !token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const requestToken = token || config.token!;\n const tokenType = token ? 'oauthToken' : 'token';\n\n const gitlabOptions: any = {\n host: config.baseUrl,\n };\n\n gitlabOptions[tokenType] = requestToken;\n return new Gitlab(gitlabOptions);\n}\n\nexport function convertDate(\n inputDate: string | undefined,\n defaultDate: string,\n) {\n try {\n return inputDate\n ? new Date(inputDate).toISOString()\n : new Date(defaultDate).toISOString();\n } catch (error) {\n throw new InputError(`Error converting input date - ${error}`);\n }\n}\n\nexport async function getTopLevelParentGroup(\n client: InstanceType<typeof Gitlab>,\n groupId: number,\n): Promise<GroupSchema> {\n try {\n const topParentGroup = await client.Groups.show(groupId);\n if (topParentGroup.parent_id) {\n return getTopLevelParentGroup(client, topParentGroup.parent_id as number);\n }\n return topParentGroup as GroupSchema;\n } catch (error: any) {\n throw new InputError(\n `Error finding top-level parent group ID: ${error.message}`,\n );\n }\n}\n\nexport async function checkEpicScope(\n client: InstanceType<typeof Gitlab>,\n projectId: number,\n epicId: number,\n) {\n try {\n // If project exists, get the top level group id\n const project = await client.Projects.show(projectId);\n if (!project) {\n throw new InputError(\n `Project with id ${projectId} not found. Check your GitLab instance.`,\n );\n }\n const topParentGroup = await getTopLevelParentGroup(\n client,\n project.namespace.id,\n );\n if (!topParentGroup) {\n throw new InputError(`Couldn't find a suitable top-level parent group.`);\n }\n // Get the epic\n const epic = (await client.Epics.all(topParentGroup.id)).find(\n (x: any) => x.id === epicId,\n );\n if (!epic) {\n throw new InputError(\n `Epic with id ${epicId} not found in the top-level parent group ${topParentGroup.name}.`,\n );\n }\n\n const epicGroup = await client.Groups.show(epic.group_id as number);\n const projectNamespace: string = project.path_with_namespace as string;\n return projectNamespace.startsWith(epicGroup.full_path as string);\n } catch (error: any) {\n throw new InputError(`Could not find epic scope: ${error.message}`);\n }\n}\n\nfunction computeSha256(file: SerializedFile): string {\n const hash = createHash('sha256');\n hash.update(file.content);\n return hash.digest('hex');\n}\n\nexport async function getFileAction(\n fileInfo: { file: SerializedFile; targetPath?: string },\n target: { repoID: string; branch: string },\n api: InstanceType<typeof Gitlab>,\n logger: LoggerService,\n remoteFiles: 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"],"names":["InputError","Gitlab","createHash","path"],"mappings":";;;;;;;;;;;AA+BO,MAAM,aAAA,GAAgB,CAAC,OAAA,KAA4B;AACxD,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,KAChE;AAAA,EACF;AACA,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB;AAEO,MAAM,QAAA,GAAW,CACtB,MAAA,EACA,YAAA,KAC4D;AAC5D,EAAA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,CAAO,OAAO,CAAA;AACzC,EAAA,MAAM,iBAAA,GAAoB,YAAA,CAAa,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA;AAEzD,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA,EACF;AAEA,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,IAAS,iBAAA,CAAkB,MAAA,CAAO,KAAA;AAEvD,EAAA,OAAO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AO,CAAA;AACxB,EAAA,OAAO,IAAA,CAAK,OAAO,KAAK,CAAA;AAC1B;AAEA,eAAsB,cACpB,QAAA,EACA,MAAA,EACA,KACA,MAAA,EACA,WAAA,EACA,sBAKa,MAAA,EACqC;AAClD,EAAA,IAAI,wBAAwB,MAAA,EAAQ;AAClC,IAAA,MAAM,QAAA,GAAWC,sBAAK,IAAA,CAAK,QAAA,CAAS,cAAc,EAAA,EAAI,QAAA,CAAS,KAAK,IAAI,CAAA;AAExE,IAAA,IAAI,aAAa,IAAA,CAAK,CAAA,UAAA,KAAc,UAAA,CAAW,IAAA,KAAS,QAAQ,CAAA,EAAG;AACjE,MAAA,IAAI;AACF,QAAA,MAAM,UAAA,GAAa,MAAM,GAAA,CAAI,eAAA,CAAgB,IAAA;AAAA,UAC3C,MAAA,CAAO,MAAA;AAAA,UACP,QAAA;AAAA,UACA,MAAA,CAAO;AAAA,SACT;AACA,QAAA,IAAI,aAAA,CAAc,QAAA,CAAS,IAAI,CAAA,KAAM,WAAW,cAAA,EAAgB;AAC9D,UAAA,OAAO,MAAA;AAAA,QACT;AAAA,MACF,SAAS,KAAA,EAAO;AACd,QAAA,MAAA,CAAO,IAAA;AAAA,UACL,2DAA2D,QAAQ,CAAA;AAAA,SACrE;AAAA,MACF;AACA,MAAA,OAAO,QAAA;AAAA,IACT;AACA,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,mBAAA;AACT;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"util.cjs.js","sources":["../src/util.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Gitlab, GroupSchema, RepositoryTreeSchema } from '@gitbeaker/rest';\nimport { z } from 'zod/v3';\nimport commonGitlabConfig from './commonGitlabConfig';\n\nimport { SerializedFile } from '@backstage/plugin-scaffolder-node';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n config: z.infer<typeof commonGitlabConfig>,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(config.repoUrl);\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const token = config.token || integrationConfig.config.token!;\n\n return { token: token, integrationConfig: integrationConfig };\n};\n\nexport type RepoSpec = {\n repo: string;\n host: string;\n owner?: string;\n};\n\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): RepoSpec => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const repo: string = parsed.searchParams.get('repo')!;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n return { host, owner, repo };\n};\n\nexport function getClient(props: {\n host: string;\n token?: string;\n integrations: ScmIntegrationRegistry;\n}): InstanceType<typeof Gitlab> {\n const { host, token, integrations } = props;\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const { config } = integrationConfig;\n\n if (!config.token && !token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const requestToken = token || config.token!;\n const tokenType = token ? 'oauthToken' : 'token';\n\n const gitlabOptions: any = {\n host: config.baseUrl,\n };\n\n gitlabOptions[tokenType] = requestToken;\n return new Gitlab(gitlabOptions);\n}\n\nexport function convertDate(\n inputDate: string | undefined,\n defaultDate: string,\n) {\n try {\n return inputDate\n ? new Date(inputDate).toISOString()\n : new Date(defaultDate).toISOString();\n } catch (error) {\n throw new InputError(`Error converting input date - ${error}`);\n }\n}\n\nexport async function getTopLevelParentGroup(\n client: InstanceType<typeof Gitlab>,\n groupId: number,\n): Promise<GroupSchema> {\n try {\n const topParentGroup = await client.Groups.show(groupId);\n if (topParentGroup.parent_id) {\n return getTopLevelParentGroup(client, topParentGroup.parent_id as number);\n }\n return topParentGroup as GroupSchema;\n } catch (error: any) {\n throw new InputError(\n `Error finding top-level parent group ID: ${error.message}`,\n );\n }\n}\n\nexport async function checkEpicScope(\n client: InstanceType<typeof Gitlab>,\n projectId: number,\n epicId: number,\n) {\n try {\n // If project exists, get the top level group id\n const project = await client.Projects.show(projectId);\n if (!project) {\n throw new InputError(\n `Project with id ${projectId} not found. Check your GitLab instance.`,\n );\n }\n const topParentGroup = await getTopLevelParentGroup(\n client,\n project.namespace.id,\n );\n if (!topParentGroup) {\n throw new InputError(`Couldn't find a suitable top-level parent group.`);\n }\n // Get the epic\n const epic = (await client.Epics.all(topParentGroup.id)).find(\n (x: any) => x.id === epicId,\n );\n if (!epic) {\n throw new InputError(\n `Epic with id ${epicId} not found in the top-level parent group ${topParentGroup.name}.`,\n );\n }\n\n const epicGroup = await client.Groups.show(epic.group_id as number);\n const projectNamespace: string = project.path_with_namespace as string;\n return projectNamespace.startsWith(epicGroup.full_path as string);\n } catch (error: any) {\n throw new InputError(`Could not find epic scope: ${error.message}`);\n }\n}\n\nfunction computeSha256(file: SerializedFile): string {\n const hash = createHash('sha256');\n hash.update(file.content);\n return hash.digest('hex');\n}\n\nexport async function getFileAction(\n fileInfo: { file: SerializedFile; targetPath?: string },\n target: { repoID: string; branch: string },\n api: InstanceType<typeof Gitlab>,\n logger: LoggerService,\n remoteFiles: 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"],"names":["InputError","Gitlab","createHash","path"],"mappings":";;;;;;;;;;;AA+BO,MAAM,aAAA,GAAgB,CAAC,OAAA,KAA4B;AACxD,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,KAChE;AAAA,EACF;AACA,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB;AAEO,MAAM,QAAA,GAAW,CACtB,MAAA,EACA,YAAA,KAC4D;AAC5D,EAAA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,CAAO,OAAO,CAAA;AACzC,EAA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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitlab",
|
|
3
|
-
"version": "0.11.4
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "scaffolder",
|
|
@@ -53,21 +53,21 @@
|
|
|
53
53
|
"test": "backstage-cli package test"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@backstage/backend-plugin-api": "1.
|
|
57
|
-
"@backstage/config": "1.3.6",
|
|
58
|
-
"@backstage/errors": "1.2.7",
|
|
59
|
-
"@backstage/integration": "2.0.0
|
|
60
|
-
"@backstage/plugin-scaffolder-node": "0.13.0
|
|
56
|
+
"@backstage/backend-plugin-api": "^1.8.0",
|
|
57
|
+
"@backstage/config": "^1.3.6",
|
|
58
|
+
"@backstage/errors": "^1.2.7",
|
|
59
|
+
"@backstage/integration": "^2.0.0",
|
|
60
|
+
"@backstage/plugin-scaffolder-node": "^0.13.0",
|
|
61
61
|
"@gitbeaker/core": "^43.8.0",
|
|
62
62
|
"@gitbeaker/requester-utils": "^43.8.0",
|
|
63
63
|
"@gitbeaker/rest": "^43.8.0",
|
|
64
64
|
"luxon": "^3.0.0",
|
|
65
65
|
"yaml": "^2.0.0",
|
|
66
|
-
"zod": "^3.25.76"
|
|
66
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@backstage/backend-test-utils": "1.11.1
|
|
70
|
-
"@backstage/cli": "0.36.0
|
|
71
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.3.9
|
|
69
|
+
"@backstage/backend-test-utils": "^1.11.1",
|
|
70
|
+
"@backstage/cli": "^0.36.0",
|
|
71
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.9"
|
|
72
72
|
}
|
|
73
73
|
}
|