@backstage/plugin-scaffolder-backend-module-gitlab 0.11.10-next.0 → 0.11.10
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 +3 -3
- package/dist/actions/gitlab.cjs.js +13 -0
- package/dist/actions/gitlab.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupAccessAction.cjs.js +7 -2
- package/dist/actions/gitlabGroupAccessAction.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupEnsureExists.cjs.js +7 -2
- package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueCreate.cjs.js +7 -2
- package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueEdit.cjs.js +7 -2
- package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -1
- package/dist/actions/gitlabMergeRequest.cjs.js +3 -2
- package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -1
- package/dist/actions/gitlabPipelineTrigger.cjs.js +7 -2
- package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js +6 -8
- package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js +7 -2
- package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectVariableCreate.cjs.js +7 -2
- package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabRepoPush.cjs.js +5 -12
- package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
- package/dist/actions/helpers.cjs.js +11 -1
- package/dist/actions/helpers.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/module.cjs.js +35 -10
- package/dist/module.cjs.js.map +1 -1
- package/dist/util.cjs.js +12 -2
- package/dist/util.cjs.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ declare function createPublishGitlabAction(options: {
|
|
|
72
72
|
*/
|
|
73
73
|
declare const createGitlabGroupEnsureExistsAction: (options: {
|
|
74
74
|
integrations: ScmIntegrationRegistry;
|
|
75
|
+
requireScmUserCredentials?: boolean;
|
|
75
76
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
76
77
|
repoUrl: string;
|
|
77
78
|
path: (string | {
|
|
@@ -91,6 +92,7 @@ declare const createGitlabGroupEnsureExistsAction: (options: {
|
|
|
91
92
|
*/
|
|
92
93
|
declare const createGitlabGroupAccessAction: (options: {
|
|
93
94
|
integrations: ScmIntegrationRegistry;
|
|
95
|
+
requireScmUserCredentials?: boolean;
|
|
94
96
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
95
97
|
repoUrl: string;
|
|
96
98
|
path: string | number;
|
|
@@ -114,6 +116,7 @@ declare const createGitlabGroupAccessAction: (options: {
|
|
|
114
116
|
*/
|
|
115
117
|
declare const createGitlabIssueAction: (options: {
|
|
116
118
|
integrations: ScmIntegrationRegistry;
|
|
119
|
+
requireScmUserCredentials?: boolean;
|
|
117
120
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
118
121
|
repoUrl: string;
|
|
119
122
|
projectId: number;
|
|
@@ -145,6 +148,7 @@ declare const createGitlabIssueAction: (options: {
|
|
|
145
148
|
*/
|
|
146
149
|
declare const editGitlabIssueAction: (options: {
|
|
147
150
|
integrations: ScmIntegrationRegistry;
|
|
151
|
+
requireScmUserCredentials?: boolean;
|
|
148
152
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
149
153
|
repoUrl: string;
|
|
150
154
|
projectId: number;
|
|
@@ -182,6 +186,7 @@ declare const editGitlabIssueAction: (options: {
|
|
|
182
186
|
*/
|
|
183
187
|
declare const createPublishGitlabMergeRequestAction: (options: {
|
|
184
188
|
integrations: ScmIntegrationRegistry;
|
|
189
|
+
requireScmUserCredentials?: boolean;
|
|
185
190
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
186
191
|
repoUrl: string;
|
|
187
192
|
title: string;
|
|
@@ -213,6 +218,7 @@ declare const createPublishGitlabMergeRequestAction: (options: {
|
|
|
213
218
|
*/
|
|
214
219
|
declare const createTriggerGitlabPipelineAction: (options: {
|
|
215
220
|
integrations: ScmIntegrationRegistry;
|
|
221
|
+
requireScmUserCredentials?: boolean;
|
|
216
222
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
217
223
|
repoUrl: string;
|
|
218
224
|
projectId: number;
|
|
@@ -232,6 +238,7 @@ declare const createTriggerGitlabPipelineAction: (options: {
|
|
|
232
238
|
*/
|
|
233
239
|
declare const createGitlabProjectAccessTokenAction: (options: {
|
|
234
240
|
integrations: ScmIntegrationRegistry;
|
|
241
|
+
requireScmUserCredentials?: boolean;
|
|
235
242
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
236
243
|
projectId: string | number;
|
|
237
244
|
repoUrl: string;
|
|
@@ -252,6 +259,7 @@ declare const createGitlabProjectAccessTokenAction: (options: {
|
|
|
252
259
|
*/
|
|
253
260
|
declare const createGitlabProjectDeployTokenAction: (options: {
|
|
254
261
|
integrations: ScmIntegrationRegistry;
|
|
262
|
+
requireScmUserCredentials?: boolean;
|
|
255
263
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
256
264
|
repoUrl: string;
|
|
257
265
|
projectId: string | number;
|
|
@@ -272,6 +280,7 @@ declare const createGitlabProjectDeployTokenAction: (options: {
|
|
|
272
280
|
*/
|
|
273
281
|
declare const createGitlabProjectVariableAction: (options: {
|
|
274
282
|
integrations: ScmIntegrationRegistry;
|
|
283
|
+
requireScmUserCredentials?: boolean;
|
|
275
284
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
276
285
|
repoUrl: string;
|
|
277
286
|
projectId: string | number;
|
|
@@ -295,6 +304,7 @@ declare const createGitlabProjectVariableAction: (options: {
|
|
|
295
304
|
*/
|
|
296
305
|
declare const createGitlabRepoPushAction: (options: {
|
|
297
306
|
integrations: ScmIntegrationRegistry;
|
|
307
|
+
requireScmUserCredentials?: boolean;
|
|
298
308
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
299
309
|
repoUrl: string;
|
|
300
310
|
branchName: string;
|
|
@@ -307,7 +317,7 @@ declare const createGitlabRepoPushAction: (options: {
|
|
|
307
317
|
}, {
|
|
308
318
|
projectid: string;
|
|
309
319
|
projectPath: string;
|
|
310
|
-
commitHash
|
|
320
|
+
commitHash: string;
|
|
311
321
|
}, "v2">;
|
|
312
322
|
|
|
313
323
|
/**
|
package/dist/module.cjs.js
CHANGED
|
@@ -32,20 +32,45 @@ const gitlabModule = backendPluginApi.createBackendModule({
|
|
|
32
32
|
},
|
|
33
33
|
async init({ scaffolder, autocomplete: autocomplete$1, config }) {
|
|
34
34
|
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
35
|
+
const requireScmUserCredentials = config.getOptionalBoolean("scaffolder.requireScmUserCredentials") ?? false;
|
|
35
36
|
scaffolder.addActions(
|
|
36
|
-
gitlabGroupEnsureExists.createGitlabGroupEnsureExistsAction({
|
|
37
|
-
|
|
37
|
+
gitlabGroupEnsureExists.createGitlabGroupEnsureExistsAction({
|
|
38
|
+
integrations,
|
|
39
|
+
requireScmUserCredentials
|
|
40
|
+
}),
|
|
41
|
+
gitlabGroupAccessAction.createGitlabGroupAccessAction({
|
|
42
|
+
integrations,
|
|
43
|
+
requireScmUserCredentials
|
|
44
|
+
}),
|
|
38
45
|
gitlabProjectMigrate.createGitlabProjectMigrateAction({ integrations }),
|
|
39
|
-
gitlabIssueCreate.createGitlabIssueAction({ integrations }),
|
|
40
|
-
gitlabProjectAccessTokenCreate.createGitlabProjectAccessTokenAction({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
gitlabIssueCreate.createGitlabIssueAction({ integrations, requireScmUserCredentials }),
|
|
47
|
+
gitlabProjectAccessTokenCreate.createGitlabProjectAccessTokenAction({
|
|
48
|
+
integrations,
|
|
49
|
+
requireScmUserCredentials
|
|
50
|
+
}),
|
|
51
|
+
gitlabProjectDeployTokenCreate.createGitlabProjectDeployTokenAction({
|
|
52
|
+
integrations,
|
|
53
|
+
requireScmUserCredentials
|
|
54
|
+
}),
|
|
55
|
+
gitlabProjectVariableCreate.createGitlabProjectVariableAction({
|
|
56
|
+
integrations,
|
|
57
|
+
requireScmUserCredentials
|
|
58
|
+
}),
|
|
59
|
+
gitlabRepoPush.createGitlabRepoPushAction({
|
|
60
|
+
integrations,
|
|
61
|
+
requireScmUserCredentials
|
|
62
|
+
}),
|
|
44
63
|
gitlabUserInfo.createGitlabUserInfoAction({ integrations }),
|
|
45
|
-
gitlabIssueEdit.editGitlabIssueAction({ integrations }),
|
|
64
|
+
gitlabIssueEdit.editGitlabIssueAction({ integrations, requireScmUserCredentials }),
|
|
46
65
|
gitlab.createPublishGitlabAction({ config, integrations }),
|
|
47
|
-
gitlabMergeRequest.createPublishGitlabMergeRequestAction({
|
|
48
|
-
|
|
66
|
+
gitlabMergeRequest.createPublishGitlabMergeRequestAction({
|
|
67
|
+
integrations,
|
|
68
|
+
requireScmUserCredentials
|
|
69
|
+
}),
|
|
70
|
+
gitlabPipelineTrigger.createTriggerGitlabPipelineAction({
|
|
71
|
+
integrations,
|
|
72
|
+
requireScmUserCredentials
|
|
73
|
+
})
|
|
49
74
|
);
|
|
50
75
|
autocomplete$1.addAutocompleteProvider({
|
|
51
76
|
id: "gitlab",
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabGroupAccessAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createGitlabUserInfoAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabGroupAccessAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createGitlabUserInfoAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n const requireScmUserCredentials =\n config.getOptionalBoolean('scaffolder.requireScmUserCredentials') ??\n false;\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabGroupAccessAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabProjectMigrateAction({ integrations }),\n createGitlabIssueAction({ integrations, requireScmUserCredentials }),\n createGitlabProjectAccessTokenAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabProjectDeployTokenAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabProjectVariableAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabRepoPushAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGitlabUserInfoAction({ integrations }),\n editGitlabIssueAction({ integrations, requireScmUserCredentials }),\n createPublishGitlabAction({ config, integrations }),\n createPublishGitlabMergeRequestAction({\n integrations,\n requireScmUserCredentials,\n }),\n createTriggerGitlabPipelineAction({\n integrations,\n requireScmUserCredentials,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'gitlab',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabGroupAccessAction","createGitlabProjectMigrateAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","createGitlabUserInfoAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction","createHandleAutocompleteRequest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAM,eAAeA,oCAAA,CAAoB;AAAA,EAC9C,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,oDAAA;AAAA,QACZ,YAAA,EAAcC,0CAAA;AAAA,QACd,QAAQC,6BAAA,CAAa;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,gBAAYC,cAAA,EAAc,QAAO,EAAG;AAC/C,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AACtD,QAAA,MAAM,yBAAA,GACJ,MAAA,CAAO,kBAAA,CAAmB,sCAAsC,CAAA,IAChE,KAAA;AAEF,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,2DAAA,CAAoC;AAAA,YAClC,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,qDAAA,CAA8B;AAAA,YAC5B,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,qDAAA,CAAiC,EAAE,YAAA,EAAc,CAAA;AAAA,UACjDC,yCAAA,CAAwB,EAAE,YAAA,EAAc,yBAAA,EAA2B,CAAA;AAAA,UACnEC,mEAAA,CAAqC;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,mEAAA,CAAqC;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,6DAAA,CAAkC;AAAA,YAChC,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,yCAAA,CAA2B;AAAA,YACzB,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,yCAAA,CAA2B,EAAE,YAAA,EAAc,CAAA;AAAA,UAC3CC,qCAAA,CAAsB,EAAE,YAAA,EAAc,yBAAA,EAA2B,CAAA;AAAA,UACjEC,gCAAA,CAA0B,EAAE,MAAA,EAAQ,YAAA,EAAc,CAAA;AAAA,UAClDC,wDAAA,CAAsC;AAAA,YACpC,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,uDAAA,CAAkC;AAAA,YAChC,YAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAEA,QAAAd,cAAA,CAAa,uBAAA,CAAwB;AAAA,UACnC,EAAA,EAAI,QAAA;AAAA,UACJ,OAAA,EAASe,4CAAA,CAAgC,EAAE,YAAA,EAAc;AAAA,SAC1D,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/dist/util.cjs.js
CHANGED
|
@@ -20,7 +20,7 @@ const parseRepoHost = (repoUrl) => {
|
|
|
20
20
|
}
|
|
21
21
|
return parsed.host;
|
|
22
22
|
};
|
|
23
|
-
const getToken = (config, integrations) => {
|
|
23
|
+
const getToken = (config, integrations, requireScmUserCredentials = false) => {
|
|
24
24
|
const host = parseRepoHost(config.repoUrl);
|
|
25
25
|
const integrationConfig = integrations.gitlab.byHost(host);
|
|
26
26
|
if (!integrationConfig) {
|
|
@@ -28,6 +28,11 @@ const getToken = (config, integrations) => {
|
|
|
28
28
|
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
|
+
if (requireScmUserCredentials && !config.token) {
|
|
32
|
+
throw new errors.InputError(
|
|
33
|
+
`No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
31
36
|
const token = config.token || integrationConfig.config.token;
|
|
32
37
|
return { token, integrationConfig };
|
|
33
38
|
};
|
|
@@ -52,13 +57,18 @@ const parseRepoUrl = (repoUrl, integrations) => {
|
|
|
52
57
|
return { host, owner, repo };
|
|
53
58
|
};
|
|
54
59
|
function getClient(props) {
|
|
55
|
-
const { host, token, integrations } = props;
|
|
60
|
+
const { host, token, integrations, requireScmUserCredentials } = props;
|
|
56
61
|
const integrationConfig = integrations.gitlab.byHost(host);
|
|
57
62
|
if (!integrationConfig) {
|
|
58
63
|
throw new errors.InputError(
|
|
59
64
|
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
60
65
|
);
|
|
61
66
|
}
|
|
67
|
+
if (requireScmUserCredentials && !token) {
|
|
68
|
+
throw new errors.InputError(
|
|
69
|
+
`No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
62
72
|
const { config } = integrationConfig;
|
|
63
73
|
if (!config.token && !token) {
|
|
64
74
|
throw new errors.InputError(`No token available for host ${host}`);
|
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/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,EA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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 requireScmUserCredentials = false,\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 if (requireScmUserCredentials && !config.token) {\n throw new InputError(\n `No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`,\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 requireScmUserCredentials?: boolean;\n}): InstanceType<typeof Gitlab> {\n const { host, token, integrations, requireScmUserCredentials } = 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 if (requireScmUserCredentials && !token) {\n throw new InputError(\n `No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`,\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,EACA,4BAA4B,KAAA,KACgC;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,IAAI,yBAAA,IAA6B,CAAC,MAAA,CAAO,KAAA,EAAO;AAC9C,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,yCAAyC,IAAI,CAAA,qDAAA;AAAA,KAC/C;AAAA,EACF;AAEA,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,IAAS,iBAAA,CAA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
|
+
"version": "0.11.10",
|
|
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.10.0",
|
|
57
|
-
"@backstage/config": "1.3.8",
|
|
58
|
-
"@backstage/errors": "1.3.1",
|
|
59
|
-
"@backstage/integration": "2.1.
|
|
60
|
-
"@backstage/plugin-scaffolder-node": "0.13.
|
|
56
|
+
"@backstage/backend-plugin-api": "^1.10.0",
|
|
57
|
+
"@backstage/config": "^1.3.8",
|
|
58
|
+
"@backstage/errors": "^1.3.1",
|
|
59
|
+
"@backstage/integration": "^2.1.1",
|
|
60
|
+
"@backstage/plugin-scaffolder-node": "^0.13.6",
|
|
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.6",
|
|
70
|
-
"@backstage/cli": "0.36.
|
|
71
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.3.
|
|
69
|
+
"@backstage/backend-test-utils": "^1.11.6",
|
|
70
|
+
"@backstage/cli": "^0.36.5",
|
|
71
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.14"
|
|
72
72
|
}
|
|
73
73
|
}
|