@backstage/plugin-scaffolder-backend-module-gitlab 0.11.5 → 0.11.6
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 +23 -0
- package/dist/actions/gitlabRepoPush.cjs.js +12 -2
- package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
- package/dist/actions/gitlabRepoPush.examples.cjs.js +18 -0
- package/dist/actions/gitlabRepoPush.examples.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.11.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8474da5: Added `allowEmpty` input option to the `gitlab:repo:push` action, allowing empty commits. Required from GitLab 18.8 or later.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/errors@1.3.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.9.1
|
|
11
|
+
- @backstage/integration@2.0.2
|
|
12
|
+
- @backstage/plugin-scaffolder-node@0.13.3
|
|
13
|
+
- @backstage/config@1.3.8
|
|
14
|
+
|
|
15
|
+
## 0.11.6-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/errors@1.3.1-next.0
|
|
21
|
+
- @backstage/integration@2.0.2-next.0
|
|
22
|
+
- @backstage/backend-plugin-api@1.9.1-next.0
|
|
23
|
+
- @backstage/config@1.3.8-next.0
|
|
24
|
+
- @backstage/plugin-scaffolder-node@0.13.3-next.0
|
|
25
|
+
|
|
3
26
|
## 0.11.5
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -39,6 +39,9 @@ const createGitlabRepoPushAction = (options) => {
|
|
|
39
39
|
}).optional(),
|
|
40
40
|
commitAction: (z) => z.enum(["create", "update", "delete", "auto"], {
|
|
41
41
|
description: "The action to be used for git commit. Defaults to create, but can be set to update or delete"
|
|
42
|
+
}).optional(),
|
|
43
|
+
allowEmpty: (z) => z.boolean({
|
|
44
|
+
description: "Allow an empty commit to be created."
|
|
42
45
|
}).optional()
|
|
43
46
|
},
|
|
44
47
|
output: {
|
|
@@ -60,7 +63,8 @@ const createGitlabRepoPushAction = (options) => {
|
|
|
60
63
|
targetPath,
|
|
61
64
|
sourcePath,
|
|
62
65
|
token,
|
|
63
|
-
commitAction
|
|
66
|
+
commitAction,
|
|
67
|
+
allowEmpty
|
|
64
68
|
} = ctx.input;
|
|
65
69
|
const { owner, repo, project } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
66
70
|
const repoID = project ? project : `${owner}/${repo}`;
|
|
@@ -148,7 +152,13 @@ const createGitlabRepoPushAction = (options) => {
|
|
|
148
152
|
const commitId = await ctx.checkpoint({
|
|
149
153
|
key: `commit.create.${repoID}.${branchName}`,
|
|
150
154
|
fn: async () => {
|
|
151
|
-
const commit = await api.Commits.create(
|
|
155
|
+
const commit = allowEmpty !== void 0 ? await api.Commits.create(
|
|
156
|
+
repoID,
|
|
157
|
+
branchName,
|
|
158
|
+
ctx.input.commitMessage,
|
|
159
|
+
actions,
|
|
160
|
+
{ allowEmpty }
|
|
161
|
+
) : await api.Commits.create(
|
|
152
162
|
repoID,
|
|
153
163
|
branchName,
|
|
154
164
|
ctx.input.commitMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabRepoPush.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 path from 'node:path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { CommitAction } from '@gitbeaker/rest';\nimport { createGitlabApi, getErrorMessage } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\nimport { getFileAction } from '../util';\nimport { SerializedFile } from '@backstage/plugin-scaffolder-node';\nimport { RepositoryTreeSchema } from '@gitbeaker/rest';\n\n/**\n * Create a new action that commits into a gitlab repository.\n *\n * @public\n */\nexport const createGitlabRepoPushAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:repo:push',\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 branchName: z =>\n z.string({\n description: 'The branch name for the commit',\n }),\n commitMessage: z =>\n z.string({\n description: `The commit message`,\n }),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n commitAction: z =>\n z\n .enum(['create', 'update', 'delete', 'auto'], {\n description:\n 'The action to be used for git commit. Defaults to create, but can be set to update or delete',\n })\n .optional(),\n },\n output: {\n projectid: z =>\n z.string({\n description: 'Gitlab Project id/Name(slug)',\n }),\n projectPath: z =>\n z.string({\n description: 'Gitlab Project path',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the commit',\n }),\n },\n },\n async handler(ctx) {\n const {\n branchName,\n repoUrl,\n targetPath,\n sourcePath,\n token,\n commitAction,\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 fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let remoteFiles: RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.allRepositoryTrees(repoID, {\n ref: branchName,\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: ${branchName}) : ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n const fileActionMap: {\n file: SerializedFile;\n action: 'create' | 'delete' | 'update' | 'skip';\n }[] = [];\n for (const file of fileContents) {\n const action = await getFileAction(\n { file, targetPath },\n { repoID, branch: branchName },\n api,\n ctx.logger,\n remoteFiles,\n ctx.input.commitAction,\n );\n fileActionMap.push({ file, action });\n }\n\n const actions: CommitAction[] = fileActionMap\n .filter(o => o.action !== 'skip')\n .map(({ file, action }) => ({\n action: action as CommitAction['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 const branchExists = await ctx.checkpoint({\n key: `branch.exists.${repoID}.${branchName}`,\n fn: async () => {\n try {\n await api.Branches.show(repoID, branchName);\n return true;\n } catch (e: any) {\n if (e.cause?.response?.status !== 404) {\n throw new InputError(\n `Failed to check status of branch '${branchName}'. Please make sure that branch already exists or Backstage has permissions to create one. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return false;\n },\n });\n\n if (!branchExists) {\n // create a branch using the default branch as ref\n try {\n const projects = await api.Projects.show(repoID);\n const { default_branch: defaultBranch } = projects;\n await api.Branches.create(repoID, branchName, String(defaultBranch));\n } catch (e) {\n throw new InputError(\n `The branch '${branchName}' was not found and creation failed with error. Please make sure that branch already exists or Backstage has permissions to create one. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n try {\n const commitId = await ctx.checkpoint({\n key: `commit.create.${repoID}.${branchName}`,\n fn: async () => {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n return commit.id;\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', commitId);\n } catch (e) {\n if (commitAction !== 'create') {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please verify that all files you're trying to modify exist in the repository. ${getErrorMessage(\n e,\n )}`,\n );\n }\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","getErrorMessage","getFileAction","path","InputError"],"mappings":";;;;;;;;;;;;;;AAqCO,MAAM,0BAAA,GAA6B,CAAC,OAAA,KAErC;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,cACJC,gCAAA;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,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAA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AAU,CAAA,uFAAA,EAA0FH,uBAAA;AAAA,cAC/H;AAAA,aACD,CAAA;AAAA,WACH;AAAA,QACF;AACA,QAAA,MAAM,IAAIG,iBAAA;AAAA,UACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,qFAAA,EAAwFH,uBAAA;AAAA,YAC7H;AAAA,WACD,CAAA;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabRepoPush.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 path from 'node:path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { CommitAction } from '@gitbeaker/rest';\nimport { createGitlabApi, getErrorMessage } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\nimport { getFileAction } from '../util';\nimport { SerializedFile } from '@backstage/plugin-scaffolder-node';\nimport { RepositoryTreeSchema } from '@gitbeaker/rest';\n\n/**\n * Create a new action that commits into a gitlab repository.\n *\n * @public\n */\nexport const createGitlabRepoPushAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:repo:push',\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 branchName: z =>\n z.string({\n description: 'The branch name for the commit',\n }),\n commitMessage: z =>\n z.string({\n description: `The commit message`,\n }),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n commitAction: z =>\n z\n .enum(['create', 'update', 'delete', 'auto'], {\n description:\n 'The action to be used for git commit. Defaults to create, but can be set to update or delete',\n })\n .optional(),\n allowEmpty: z =>\n z\n .boolean({\n description: 'Allow an empty commit to be created.',\n })\n .optional(),\n },\n output: {\n projectid: z =>\n z.string({\n description: 'Gitlab Project id/Name(slug)',\n }),\n projectPath: z =>\n z.string({\n description: 'Gitlab Project path',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the commit',\n }),\n },\n },\n async handler(ctx) {\n const {\n branchName,\n repoUrl,\n targetPath,\n sourcePath,\n token,\n commitAction,\n allowEmpty,\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 fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let remoteFiles: RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.allRepositoryTrees(repoID, {\n ref: branchName,\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: ${branchName}) : ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n const fileActionMap: {\n file: SerializedFile;\n action: 'create' | 'delete' | 'update' | 'skip';\n }[] = [];\n for (const file of fileContents) {\n const action = await getFileAction(\n { file, targetPath },\n { repoID, branch: branchName },\n api,\n ctx.logger,\n remoteFiles,\n ctx.input.commitAction,\n );\n fileActionMap.push({ file, action });\n }\n\n const actions: CommitAction[] = fileActionMap\n .filter(o => o.action !== 'skip')\n .map(({ file, action }) => ({\n action: action as CommitAction['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 const branchExists = await ctx.checkpoint({\n key: `branch.exists.${repoID}.${branchName}`,\n fn: async () => {\n try {\n await api.Branches.show(repoID, branchName);\n return true;\n } catch (e: any) {\n if (e.cause?.response?.status !== 404) {\n throw new InputError(\n `Failed to check status of branch '${branchName}'. Please make sure that branch already exists or Backstage has permissions to create one. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return false;\n },\n });\n\n if (!branchExists) {\n // create a branch using the default branch as ref\n try {\n const projects = await api.Projects.show(repoID);\n const { default_branch: defaultBranch } = projects;\n await api.Branches.create(repoID, branchName, String(defaultBranch));\n } catch (e) {\n throw new InputError(\n `The branch '${branchName}' was not found and creation failed with error. Please make sure that branch already exists or Backstage has permissions to create one. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n try {\n const commitId = await ctx.checkpoint({\n key: `commit.create.${repoID}.${branchName}`,\n fn: async () => {\n const commit =\n allowEmpty !== undefined\n ? await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n { allowEmpty } as any,\n )\n : await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n return commit.id;\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', commitId);\n } catch (e) {\n if (commitAction !== 'create') {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please verify that all files you're trying to modify exist in the repository. ${getErrorMessage(\n e,\n )}`,\n );\n }\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","getErrorMessage","getFileAction","path","InputError"],"mappings":";;;;;;;;;;;;;;AAqCO,MAAM,0BAAA,GAA6B,CAAC,OAAA,KAErC;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,cACJC,gCAAA;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,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,kBAAA;AAAA,SACd,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,OACZ,CAAA,CACG,IAAA,CAAK,CAAC,QAAA,EAAU,QAAA,EAAU,QAAA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H;AAAA,WACD,CAAA;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -60,6 +60,24 @@ const examples = [
|
|
|
60
60
|
}
|
|
61
61
|
]
|
|
62
62
|
})
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
description: "Push an empty commit to gitlab repository (from GitLab 18.8+ on)",
|
|
66
|
+
example: yaml__default.default.stringify({
|
|
67
|
+
steps: [
|
|
68
|
+
{
|
|
69
|
+
id: "pushChanges",
|
|
70
|
+
action: "gitlab:repo:push",
|
|
71
|
+
name: "Push empty commit to gitlab repository",
|
|
72
|
+
input: {
|
|
73
|
+
repoUrl: "gitlab.com?repo=repo&owner=owner",
|
|
74
|
+
commitMessage: "Initial Commit",
|
|
75
|
+
branchName: "feature-branch",
|
|
76
|
+
allowEmpty: true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
})
|
|
63
81
|
}
|
|
64
82
|
];
|
|
65
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabRepoPush.examples.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Push changes to gitlab repository with minimal changes',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific source and target path',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n sourcePath: 'src',\n targetPath: 'dest',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific commit action',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n commitAction: 'update',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,UAAA,EAAY,KAAA;AAAA,YACZ,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabRepoPush.examples.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Push changes to gitlab repository with minimal changes',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific source and target path',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n sourcePath: 'src',\n targetPath: 'dest',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific commit action',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n commitAction: 'update',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push an empty commit to gitlab repository (from GitLab 18.8+ on)',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push empty commit to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n allowEmpty: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,UAAA,EAAY,KAAA;AAAA,YACZ,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,kEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,wCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -303,6 +303,7 @@ declare const createGitlabRepoPushAction: (options: {
|
|
|
303
303
|
targetPath?: string | undefined;
|
|
304
304
|
token?: string | undefined;
|
|
305
305
|
commitAction?: "auto" | "update" | "create" | "delete" | undefined;
|
|
306
|
+
allowEmpty?: boolean | undefined;
|
|
306
307
|
}, {
|
|
307
308
|
projectid: string;
|
|
308
309
|
projectPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitlab",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "scaffolder",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"test": "backstage-cli package test"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@backstage/backend-plugin-api": "^1.9.
|
|
57
|
-
"@backstage/config": "^1.3.
|
|
58
|
-
"@backstage/errors": "^1.3.
|
|
59
|
-
"@backstage/integration": "^2.0.
|
|
60
|
-
"@backstage/plugin-scaffolder-node": "^0.13.
|
|
56
|
+
"@backstage/backend-plugin-api": "^1.9.1",
|
|
57
|
+
"@backstage/config": "^1.3.8",
|
|
58
|
+
"@backstage/errors": "^1.3.1",
|
|
59
|
+
"@backstage/integration": "^2.0.2",
|
|
60
|
+
"@backstage/plugin-scaffolder-node": "^0.13.3",
|
|
61
61
|
"@gitbeaker/core": "^43.8.0",
|
|
62
62
|
"@gitbeaker/requester-utils": "^43.8.0",
|
|
63
63
|
"@gitbeaker/rest": "^43.8.0",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"zod": "^3.25.76 || ^4.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@backstage/backend-test-utils": "^1.11.
|
|
70
|
-
"@backstage/cli": "^0.36.
|
|
71
|
-
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.
|
|
69
|
+
"@backstage/backend-test-utils": "^1.11.3",
|
|
70
|
+
"@backstage/cli": "^0.36.2",
|
|
71
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.11"
|
|
72
72
|
}
|
|
73
73
|
}
|