@backstage/plugin-scaffolder-backend-module-gitlab 0.9.2-next.1 → 0.9.2
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 +106 -235
- package/dist/actions/gitlab.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupEnsureExists.cjs.js +24 -20
- package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueCreate.cjs.js +75 -52
- package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueEdit.cjs.js +86 -68
- package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -1
- package/dist/actions/gitlabPipelineTrigger.cjs.js +26 -21
- package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js +18 -13
- package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js +27 -15
- package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectMigrate.cjs.js +21 -46
- package/dist/actions/gitlabProjectMigrate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectVariableCreate.cjs.js +32 -20
- package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabRepoPush.cjs.js +31 -56
- package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
- package/dist/commonGitlabConfig.cjs.js +1 -4
- package/dist/commonGitlabConfig.cjs.js.map +1 -1
- package/dist/index.d.ts +94 -85
- package/package.json +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 063b2d3: Fixed dependency to frontend package from tests
|
|
8
|
+
- a296637: Migrate to new action format
|
|
9
|
+
- 3d6493a: Support merge request labels in publish:gitlab:merge-request
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
- @backstage/plugin-scaffolder-node@0.9.0
|
|
12
|
+
- @backstage/backend-plugin-api@1.4.0
|
|
13
|
+
- @backstage/config@1.3.2
|
|
14
|
+
- @backstage/errors@1.2.7
|
|
15
|
+
- @backstage/integration@1.17.0
|
|
16
|
+
|
|
17
|
+
## 0.9.2-next.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- a296637: Migrate to new action format
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @backstage/plugin-scaffolder-node@0.9.0-next.2
|
|
24
|
+
- @backstage/backend-plugin-api@1.4.0-next.1
|
|
25
|
+
- @backstage/config@1.3.2
|
|
26
|
+
- @backstage/errors@1.2.7
|
|
27
|
+
- @backstage/integration@1.17.0
|
|
28
|
+
|
|
3
29
|
## 0.9.2-next.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -13,243 +13,114 @@ function createPublishGitlabAction(options) {
|
|
|
13
13
|
examples: gitlab_examples.examples,
|
|
14
14
|
schema: {
|
|
15
15
|
input: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
description: "
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
merge_method: {
|
|
109
|
-
title: "Merge Method to use",
|
|
110
|
-
description: "Merge Methods (merge, rebase_merge, ff)",
|
|
111
|
-
type: "string",
|
|
112
|
-
enum: ["merge", "rebase_merge", "ff"]
|
|
113
|
-
},
|
|
114
|
-
squash_option: {
|
|
115
|
-
title: "Squash option",
|
|
116
|
-
description: "Set squash option for the project (never, always, default_on, default_off)",
|
|
117
|
-
type: "string",
|
|
118
|
-
enum: ["default_off", "default_on", "never", "always"]
|
|
119
|
-
},
|
|
120
|
-
topics: {
|
|
121
|
-
title: "Topic labels",
|
|
122
|
-
description: "Topic labels to apply on the repository",
|
|
123
|
-
type: "array",
|
|
124
|
-
items: {
|
|
125
|
-
type: "string"
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
visibility: {
|
|
129
|
-
title: "Project visibility",
|
|
130
|
-
description: "The visibility of the project. Can be private, internal, or public. The default value is private.",
|
|
131
|
-
type: "string",
|
|
132
|
-
enum: ["private", "public", "internal"]
|
|
133
|
-
},
|
|
134
|
-
only_allow_merge_if_all_discussions_are_resolved: {
|
|
135
|
-
title: "All threads must be resolved",
|
|
136
|
-
description: "Set whether merge requests can only be merged when all the discussions are resolved.",
|
|
137
|
-
type: "boolean"
|
|
138
|
-
},
|
|
139
|
-
only_allow_merge_if_pipeline_succeeds: {
|
|
140
|
-
title: "Pipelines must succeed",
|
|
141
|
-
description: "Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.",
|
|
142
|
-
type: "boolean"
|
|
143
|
-
},
|
|
144
|
-
allow_merge_on_skipped_pipeline: {
|
|
145
|
-
title: "Skipped pipelines are considered successful",
|
|
146
|
-
description: "Set whether or not merge requests can be merged with skipped jobs.",
|
|
147
|
-
type: "boolean"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
branches: {
|
|
152
|
-
title: "Project branches settings",
|
|
153
|
-
type: "array",
|
|
154
|
-
items: {
|
|
155
|
-
type: "object",
|
|
156
|
-
required: ["name"],
|
|
157
|
-
properties: {
|
|
158
|
-
name: {
|
|
159
|
-
title: "Branch name",
|
|
160
|
-
type: "string"
|
|
161
|
-
},
|
|
162
|
-
protect: {
|
|
163
|
-
title: "Should branch be protected",
|
|
164
|
-
description: `Will mark branch as protected. The default value is 'false'`,
|
|
165
|
-
type: "boolean"
|
|
166
|
-
},
|
|
167
|
-
create: {
|
|
168
|
-
title: "Should branch be created",
|
|
169
|
-
description: `If branch does not exist, it will be created from provided ref. The default value is 'false'`,
|
|
170
|
-
type: "boolean"
|
|
171
|
-
},
|
|
172
|
-
ref: {
|
|
173
|
-
title: "Branch reference",
|
|
174
|
-
description: `Branch reference to create branch from. The default value is 'master'`,
|
|
175
|
-
type: "string"
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
projectVariables: {
|
|
181
|
-
title: "Project variables",
|
|
182
|
-
description: "Project variables settings based on Gitlab Project Environments API - https://docs.gitlab.com/ee/api/project_level_variables.html#create-a-variable",
|
|
183
|
-
type: "array",
|
|
184
|
-
items: {
|
|
185
|
-
type: "object",
|
|
186
|
-
required: ["key", "value"],
|
|
187
|
-
properties: {
|
|
188
|
-
key: {
|
|
189
|
-
title: "Variable key",
|
|
190
|
-
description: "The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed",
|
|
191
|
-
type: "string"
|
|
192
|
-
},
|
|
193
|
-
value: {
|
|
194
|
-
title: "Variable value",
|
|
195
|
-
description: "The value of a variable",
|
|
196
|
-
type: "string"
|
|
197
|
-
},
|
|
198
|
-
description: {
|
|
199
|
-
title: "Variable description",
|
|
200
|
-
description: `The description of the variable. The default value is 'null'`,
|
|
201
|
-
type: "string"
|
|
202
|
-
},
|
|
203
|
-
variable_type: {
|
|
204
|
-
title: "Variable type",
|
|
205
|
-
description: `The type of a variable. The default value is 'env_var'`,
|
|
206
|
-
type: "string",
|
|
207
|
-
enum: ["env_var", "file"]
|
|
208
|
-
},
|
|
209
|
-
protected: {
|
|
210
|
-
title: "Variable protection",
|
|
211
|
-
description: `Whether the variable is protected. The default value is 'false'`,
|
|
212
|
-
type: "boolean"
|
|
213
|
-
},
|
|
214
|
-
raw: {
|
|
215
|
-
title: "Variable raw",
|
|
216
|
-
description: `Whether the variable is in raw format. The default value is 'false'`,
|
|
217
|
-
type: "boolean"
|
|
218
|
-
},
|
|
219
|
-
environment_scope: {
|
|
220
|
-
title: "Variable environment scope",
|
|
221
|
-
description: `The environment_scope of the variable. The default value is '*'`,
|
|
222
|
-
type: "string"
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
16
|
+
repoUrl: (z) => z.string({
|
|
17
|
+
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`
|
|
18
|
+
}),
|
|
19
|
+
repoVisibility: (z) => z.enum(["private", "public", "internal"], {
|
|
20
|
+
description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`
|
|
21
|
+
}).optional(),
|
|
22
|
+
defaultBranch: (z) => z.string({
|
|
23
|
+
description: `Sets the default branch on the repository. The default value is 'master'`
|
|
24
|
+
}).optional(),
|
|
25
|
+
gitCommitMessage: (z) => z.string({
|
|
26
|
+
description: `Sets the commit message on the repository. The default value is 'initial commit'`
|
|
27
|
+
}).optional(),
|
|
28
|
+
gitAuthorName: (z) => z.string({
|
|
29
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
30
|
+
}).optional(),
|
|
31
|
+
gitAuthorEmail: (z) => z.string({
|
|
32
|
+
description: `Sets the default author email for the commit.`
|
|
33
|
+
}).optional(),
|
|
34
|
+
signCommit: (z) => z.boolean({
|
|
35
|
+
description: "Sign commit with configured PGP private key"
|
|
36
|
+
}).optional(),
|
|
37
|
+
sourcePath: (z) => z.union([z.string(), z.boolean()], {
|
|
38
|
+
description: "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."
|
|
39
|
+
}).optional(),
|
|
40
|
+
skipExisting: (z) => z.boolean({
|
|
41
|
+
description: "Do not publish the repository if it already exists. The default value is false."
|
|
42
|
+
}).optional(),
|
|
43
|
+
token: (z) => z.string({
|
|
44
|
+
description: "The token to use for authorization to GitLab"
|
|
45
|
+
}).optional(),
|
|
46
|
+
setUserAsOwner: (z) => z.boolean({
|
|
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
|
+
}).optional(),
|
|
49
|
+
topics: (z) => z.array(z.string(), {
|
|
50
|
+
description: "Topic labels to apply on the repository. (deprecated, use settings.topics instead)"
|
|
51
|
+
}).optional(),
|
|
52
|
+
settings: (z) => z.object({
|
|
53
|
+
path: z.string({
|
|
54
|
+
description: "Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes)."
|
|
55
|
+
}).optional(),
|
|
56
|
+
auto_devops_enabled: z.boolean({
|
|
57
|
+
description: "Enable Auto DevOps for this project"
|
|
58
|
+
}).optional(),
|
|
59
|
+
ci_config_path: z.string({
|
|
60
|
+
description: "Custom CI config path for this project"
|
|
61
|
+
}).optional(),
|
|
62
|
+
description: z.string({
|
|
63
|
+
description: "Short project description"
|
|
64
|
+
}).optional(),
|
|
65
|
+
merge_method: z.enum(["merge", "rebase_merge", "ff"], {
|
|
66
|
+
description: "Merge Methods (merge, rebase_merge, ff)"
|
|
67
|
+
}).optional(),
|
|
68
|
+
squash_option: z.enum(["default_off", "default_on", "never", "always"], {
|
|
69
|
+
description: "Set squash option for the project (never, always, default_on, default_off)"
|
|
70
|
+
}).optional(),
|
|
71
|
+
topics: z.array(z.string(), {
|
|
72
|
+
description: "Topic labels to apply on the repository"
|
|
73
|
+
}).optional(),
|
|
74
|
+
visibility: z.enum(["private", "public", "internal"], {
|
|
75
|
+
description: "The visibility of the project. Can be private, internal, or public. The default value is private."
|
|
76
|
+
}).optional(),
|
|
77
|
+
only_allow_merge_if_all_discussions_are_resolved: z.boolean({
|
|
78
|
+
description: "Set whether merge requests can only be merged when all the discussions are resolved."
|
|
79
|
+
}).optional(),
|
|
80
|
+
only_allow_merge_if_pipeline_succeeds: z.boolean({
|
|
81
|
+
description: "Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings."
|
|
82
|
+
}).optional(),
|
|
83
|
+
allow_merge_on_skipped_pipeline: z.boolean({
|
|
84
|
+
description: "Set whether or not merge requests can be merged with skipped jobs."
|
|
85
|
+
}).optional()
|
|
86
|
+
}).optional(),
|
|
87
|
+
branches: (z) => z.array(
|
|
88
|
+
z.object({
|
|
89
|
+
name: z.string(),
|
|
90
|
+
protect: z.boolean().optional(),
|
|
91
|
+
create: z.boolean().optional(),
|
|
92
|
+
ref: z.string().optional()
|
|
93
|
+
})
|
|
94
|
+
).optional(),
|
|
95
|
+
projectVariables: (z) => z.array(
|
|
96
|
+
z.object({
|
|
97
|
+
key: z.string(),
|
|
98
|
+
value: z.string(),
|
|
99
|
+
description: z.string().optional(),
|
|
100
|
+
variable_type: z.enum(["env_var", "file"]).optional(),
|
|
101
|
+
protected: z.boolean().optional(),
|
|
102
|
+
masked: z.boolean().optional(),
|
|
103
|
+
raw: z.boolean().optional(),
|
|
104
|
+
environment_scope: z.string().optional()
|
|
105
|
+
})
|
|
106
|
+
).optional()
|
|
228
107
|
},
|
|
229
108
|
output: {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
title: "The git commit hash of the initial commit",
|
|
246
|
-
type: "string"
|
|
247
|
-
},
|
|
248
|
-
created: {
|
|
249
|
-
title: "Whether the repository was created or not",
|
|
250
|
-
type: "boolean"
|
|
251
|
-
}
|
|
252
|
-
}
|
|
109
|
+
remoteUrl: (z) => z.string({
|
|
110
|
+
description: "A URL to the repository with the provider"
|
|
111
|
+
}),
|
|
112
|
+
repoContentsUrl: (z) => z.string({
|
|
113
|
+
description: "A URL to the root of the repository"
|
|
114
|
+
}),
|
|
115
|
+
projectId: (z) => z.number({
|
|
116
|
+
description: "The ID of the project"
|
|
117
|
+
}),
|
|
118
|
+
commitHash: (z) => z.string({
|
|
119
|
+
description: "The git commit hash of the initial commit"
|
|
120
|
+
}),
|
|
121
|
+
created: (z) => z.boolean({
|
|
122
|
+
description: "Whether the repository was created or not"
|
|
123
|
+
})
|
|
253
124
|
}
|
|
254
125
|
},
|
|
255
126
|
async handler(ctx) {
|
|
@@ -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 repoUrl: string;\n defaultBranch?: string;\n /** @deprecated in favour of settings.visibility field */\n repoVisibility?: 'private' | 'internal' | 'public';\n sourcePath?: string | boolean;\n skipExisting?: boolean;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n signCommit?: boolean;\n setUserAsOwner?: boolean;\n /** @deprecated in favour of settings.topics field */\n topics?: string[];\n settings?: {\n path?: string;\n auto_devops_enabled?: boolean;\n ci_config_path?: string;\n description?: string;\n merge_method?: 'merge' | 'rebase_merge' | 'ff';\n squash_option?: 'default_off' | 'default_on' | 'never' | 'always';\n topics?: string[];\n visibility?: 'private' | 'internal' | 'public';\n only_allow_merge_if_all_discussions_are_resolved?: boolean;\n only_allow_merge_if_pipeline_succeeds?: boolean;\n allow_merge_on_skipped_pipeline?: boolean;\n };\n branches?: Array<{\n name: string;\n protect?: boolean;\n create?: boolean;\n ref?: string;\n }>;\n projectVariables?: Array<{\n key: string;\n value: string;\n description?: string;\n variable_type?: string;\n protected?: boolean;\n masked?: boolean;\n raw?: boolean;\n environment_scope?: string;\n }>;\n }>({\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 type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: '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: {\n title: 'Repository Visibility',\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n type: 'string',\n enum: ['private', 'public', 'internal'],\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n signCommit: {\n title: 'Sign commit',\n type: 'boolean',\n description: 'Sign commit with configured PGP private key',\n },\n sourcePath: {\n title: 'Source Path',\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 type: ['string', 'boolean'],\n },\n skipExisting: {\n title: 'Skip if repository exists',\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n type: ['boolean'],\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n setUserAsOwner: {\n title: 'Set User As Owner',\n type: '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 topics: {\n title: 'Topic labels',\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n settings: {\n title: 'Project settings',\n description:\n 'Additional project settings, based on https://docs.gitlab.com/ee/api/projects.html#create-project attributes',\n type: 'object',\n properties: {\n path: {\n title: 'Project path',\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n type: 'string',\n },\n auto_devops_enabled: {\n title: 'Auto DevOps enabled',\n description: 'Enable Auto DevOps for this project',\n type: 'boolean',\n },\n ci_config_path: {\n title: 'CI config path',\n description: 'Custom CI config path for this project',\n type: 'string',\n },\n description: {\n title: 'Project description',\n description: 'Short project description',\n type: 'string',\n },\n merge_method: {\n title: 'Merge Method to use',\n description: 'Merge Methods (merge, rebase_merge, ff)',\n type: 'string',\n enum: ['merge', 'rebase_merge', 'ff'],\n },\n squash_option: {\n title: 'Squash option',\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n type: 'string',\n enum: ['default_off', 'default_on', 'never', 'always'],\n },\n topics: {\n title: 'Topic labels',\n description: 'Topic labels to apply on the repository',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n visibility: {\n title: 'Project visibility',\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n type: 'string',\n enum: ['private', 'public', 'internal'],\n },\n only_allow_merge_if_all_discussions_are_resolved: {\n title: 'All threads must be resolved',\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n type: 'boolean',\n },\n only_allow_merge_if_pipeline_succeeds: {\n title: 'Pipelines must succeed',\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 type: 'boolean',\n },\n allow_merge_on_skipped_pipeline: {\n title: 'Skipped pipelines are considered successful',\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n type: 'boolean',\n },\n },\n },\n branches: {\n title: 'Project branches settings',\n type: 'array',\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: {\n title: 'Branch name',\n type: 'string',\n },\n protect: {\n title: 'Should branch be protected',\n description: `Will mark branch as protected. The default value is 'false'`,\n type: 'boolean',\n },\n create: {\n title: 'Should branch be created',\n description: `If branch does not exist, it will be created from provided ref. The default value is 'false'`,\n type: 'boolean',\n },\n ref: {\n title: 'Branch reference',\n description: `Branch reference to create branch from. The default value is 'master'`,\n type: 'string',\n },\n },\n },\n },\n projectVariables: {\n title: 'Project variables',\n description:\n 'Project variables settings based on Gitlab Project Environments API - https://docs.gitlab.com/ee/api/project_level_variables.html#create-a-variable',\n type: 'array',\n items: {\n type: 'object',\n required: ['key', 'value'],\n properties: {\n key: {\n title: 'Variable key',\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n type: 'string',\n },\n value: {\n title: 'Variable value',\n description: 'The value of a variable',\n type: 'string',\n },\n description: {\n title: 'Variable description',\n description: `The description of the variable. The default value is 'null'`,\n type: 'string',\n },\n variable_type: {\n title: 'Variable type',\n description: `The type of a variable. The default value is 'env_var'`,\n type: 'string',\n enum: ['env_var', 'file'],\n },\n protected: {\n title: 'Variable protection',\n description: `Whether the variable is protected. The default value is 'false'`,\n type: 'boolean',\n },\n raw: {\n title: 'Variable raw',\n description: `Whether the variable is in raw format. The default value is 'false'`,\n type: 'boolean',\n },\n environment_scope: {\n title: 'Variable environment scope',\n description: `The environment_scope of the variable. The default value is '*'`,\n type: 'string',\n },\n },\n },\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n projectId: {\n title: 'The ID of the project',\n type: 'number',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n created: {\n title: 'Whether the repository was created or not',\n type: 'boolean',\n },\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, userId, 50);\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 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 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,OAG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AAA,CAAA;AACrE,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAI,GAAA,CAAA,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA;AAC7B;AACF,GACD,CAAA;AACH;AAEA,SAAS,iBAAiB,KAAoB,EAAA;AAC5C,EAAO,OAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAM,EAAA,OAAA,EAAS,KAAM,CAAA,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 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 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, userId, 50);\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 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 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,OAGvC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,MAAA,EAAW,GAAA,OAAA;AAEj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stage/plugin-scaffolder-node');
|
|
4
|
-
var zod = require('zod');
|
|
5
|
-
var commonGitlabConfig = require('../commonGitlabConfig.cjs.js');
|
|
6
4
|
var util = require('../util.cjs.js');
|
|
7
5
|
var gitlabGroupEnsureExists_examples = require('./gitlabGroupEnsureExists.examples.cjs.js');
|
|
8
6
|
|
|
@@ -14,24 +12,30 @@ const createGitlabGroupEnsureExistsAction = (options) => {
|
|
|
14
12
|
supportsDryRun: true,
|
|
15
13
|
examples: gitlabGroupEnsureExists_examples.examples,
|
|
16
14
|
schema: {
|
|
17
|
-
input:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
input: {
|
|
16
|
+
repoUrl: (z) => z.string({
|
|
17
|
+
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`
|
|
18
|
+
}),
|
|
19
|
+
token: (z) => z.string({
|
|
20
|
+
description: "The token to use for authorization to GitLab"
|
|
21
|
+
}).optional(),
|
|
22
|
+
path: (z) => z.array(
|
|
23
|
+
z.string().or(
|
|
24
|
+
z.object({
|
|
25
|
+
name: z.string(),
|
|
26
|
+
slug: z.string()
|
|
27
|
+
})
|
|
28
|
+
),
|
|
29
|
+
{
|
|
30
|
+
description: "A path of group names or objects (name and slug) that is ensured to exist"
|
|
31
|
+
}
|
|
32
|
+
).min(1)
|
|
33
|
+
},
|
|
34
|
+
output: {
|
|
35
|
+
groupId: (z) => z.number({
|
|
36
|
+
description: "The id of the innermost sub-group"
|
|
37
|
+
}).optional()
|
|
38
|
+
}
|
|
35
39
|
},
|
|
36
40
|
async handler(ctx) {
|
|
37
41
|
if (ctx.isDryRun) {
|