@backstage/plugin-scaffolder-backend-module-gitlab 0.2.11-next.2 → 0.2.11
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 +25 -0
- package/dist/index.cjs.js +693 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +73 -1
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitlab
|
|
2
2
|
|
|
3
|
+
## 0.2.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 219d7f0: Extract some more actions to this library
|
|
8
|
+
- 0cbb03b: Fixing regular expression ReDoS with zod packages. Upgrading to latest. ref: https://security.snyk.io/vuln/SNYK-JS-ZOD-5925617
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/backend-common@0.20.0
|
|
11
|
+
- @backstage/plugin-scaffolder-node@0.2.9
|
|
12
|
+
- @backstage/integration@1.8.0
|
|
13
|
+
- @backstage/config@1.1.1
|
|
14
|
+
- @backstage/errors@1.2.3
|
|
15
|
+
|
|
16
|
+
## 0.2.11-next.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 219d7f0: Extract some more actions to this library
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/plugin-scaffolder-node@0.2.9-next.3
|
|
23
|
+
- @backstage/backend-common@0.20.0-next.3
|
|
24
|
+
- @backstage/config@1.1.1
|
|
25
|
+
- @backstage/errors@1.2.3
|
|
26
|
+
- @backstage/integration@1.8.0-next.1
|
|
27
|
+
|
|
3
28
|
## 0.2.11-next.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -7,10 +7,13 @@ var node = require('@gitbeaker/node');
|
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var errors = require('@backstage/errors');
|
|
9
9
|
var yaml = require('yaml');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
var backendCommon = require('@backstage/backend-common');
|
|
10
12
|
|
|
11
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
14
|
|
|
13
15
|
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
16
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
14
17
|
|
|
15
18
|
const commonGitlabConfig = zod.z.object({
|
|
16
19
|
repoUrl: zod.z.string({ description: "Repository Location" }),
|
|
@@ -149,7 +152,7 @@ const createGitlabProjectDeployTokenAction = (options) => {
|
|
|
149
152
|
});
|
|
150
153
|
};
|
|
151
154
|
|
|
152
|
-
const examples = [
|
|
155
|
+
const examples$1 = [
|
|
153
156
|
{
|
|
154
157
|
description: "Create a GitLab project access token with minimal options.",
|
|
155
158
|
example: yaml__default["default"].stringify({
|
|
@@ -238,7 +241,7 @@ const createGitlabProjectAccessTokenAction = (options) => {
|
|
|
238
241
|
const { integrations } = options;
|
|
239
242
|
return pluginScaffolderNode.createTemplateAction({
|
|
240
243
|
id: "gitlab:projectAccessToken:create",
|
|
241
|
-
examples,
|
|
244
|
+
examples: examples$1,
|
|
242
245
|
schema: {
|
|
243
246
|
input: commonGitlabConfig.merge(
|
|
244
247
|
zod.z.object({
|
|
@@ -333,8 +336,696 @@ const createGitlabProjectVariableAction = (options) => {
|
|
|
333
336
|
});
|
|
334
337
|
};
|
|
335
338
|
|
|
339
|
+
const examples = [
|
|
340
|
+
{
|
|
341
|
+
description: "Initializes a git repository of the content in the workspace, and publishes it to GitLab.",
|
|
342
|
+
example: yaml__default["default"].stringify({
|
|
343
|
+
steps: [
|
|
344
|
+
{
|
|
345
|
+
id: "publish",
|
|
346
|
+
action: "publish:gitlab",
|
|
347
|
+
name: "Publish to GitLab",
|
|
348
|
+
input: {
|
|
349
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name"
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
})
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
description: "Add a description.",
|
|
357
|
+
example: yaml__default["default"].stringify({
|
|
358
|
+
steps: [
|
|
359
|
+
{
|
|
360
|
+
id: "publish",
|
|
361
|
+
action: "publish:gitlab",
|
|
362
|
+
name: "Publish to GitLab",
|
|
363
|
+
input: {
|
|
364
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
365
|
+
description: "Initialize a git repository"
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
]
|
|
369
|
+
})
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
description: "Sets the commit message on the repository. The default value is `initial commit`.",
|
|
373
|
+
example: yaml__default["default"].stringify({
|
|
374
|
+
steps: [
|
|
375
|
+
{
|
|
376
|
+
id: "publish",
|
|
377
|
+
action: "publish:gitlab",
|
|
378
|
+
name: "Publish to GitLab",
|
|
379
|
+
input: {
|
|
380
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
381
|
+
description: "Initialize a git repository",
|
|
382
|
+
gitCommitMessage: "Started a project."
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
})
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
description: "Initializes a git repository with additional settings.",
|
|
390
|
+
example: yaml__default["default"].stringify({
|
|
391
|
+
steps: [
|
|
392
|
+
{
|
|
393
|
+
id: "publish",
|
|
394
|
+
action: "publish:gitlab",
|
|
395
|
+
name: "Publish to GitLab",
|
|
396
|
+
input: {
|
|
397
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
398
|
+
settings: {
|
|
399
|
+
ci_config_path: ".gitlab-ci.yml",
|
|
400
|
+
visibility: "public"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
})
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
description: "Initializes a git repository with branches settings",
|
|
409
|
+
example: yaml__default["default"].stringify({
|
|
410
|
+
steps: [
|
|
411
|
+
{
|
|
412
|
+
id: "publish",
|
|
413
|
+
action: "publish:gitlab",
|
|
414
|
+
name: "Publish to GitLab",
|
|
415
|
+
input: {
|
|
416
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
417
|
+
branches: [
|
|
418
|
+
{
|
|
419
|
+
name: "dev",
|
|
420
|
+
create: true,
|
|
421
|
+
protected: true,
|
|
422
|
+
ref: "master"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "master",
|
|
426
|
+
protected: true
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
})
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
description: "Initializes a git repository with environment variables",
|
|
436
|
+
example: yaml__default["default"].stringify({
|
|
437
|
+
steps: [
|
|
438
|
+
{
|
|
439
|
+
id: "publish",
|
|
440
|
+
action: "publish:gitlab",
|
|
441
|
+
name: "Publish to GitLab",
|
|
442
|
+
input: {
|
|
443
|
+
repoUrl: "gitlab.com?repo=project_name&owner=group_name",
|
|
444
|
+
projectVariables: [
|
|
445
|
+
{
|
|
446
|
+
key: "key1",
|
|
447
|
+
value: "value1",
|
|
448
|
+
protected: true,
|
|
449
|
+
masked: false
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
key: "key2",
|
|
453
|
+
value: "value2",
|
|
454
|
+
protected: true,
|
|
455
|
+
masked: false
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
|
|
465
|
+
function createPublishGitlabAction(options) {
|
|
466
|
+
const { integrations, config } = options;
|
|
467
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
468
|
+
id: "publish:gitlab",
|
|
469
|
+
description: "Initializes a git repository of the content in the workspace, and publishes it to GitLab.",
|
|
470
|
+
examples,
|
|
471
|
+
schema: {
|
|
472
|
+
input: {
|
|
473
|
+
type: "object",
|
|
474
|
+
required: ["repoUrl"],
|
|
475
|
+
properties: {
|
|
476
|
+
repoUrl: {
|
|
477
|
+
title: "Repository Location",
|
|
478
|
+
type: "string",
|
|
479
|
+
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`
|
|
480
|
+
},
|
|
481
|
+
repoVisibility: {
|
|
482
|
+
title: "Repository Visibility",
|
|
483
|
+
description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,
|
|
484
|
+
type: "string",
|
|
485
|
+
enum: ["private", "public", "internal"]
|
|
486
|
+
},
|
|
487
|
+
defaultBranch: {
|
|
488
|
+
title: "Default Branch",
|
|
489
|
+
type: "string",
|
|
490
|
+
description: `Sets the default branch on the repository. The default value is 'master'`
|
|
491
|
+
},
|
|
492
|
+
gitCommitMessage: {
|
|
493
|
+
title: "Git Commit Message",
|
|
494
|
+
type: "string",
|
|
495
|
+
description: `Sets the commit message on the repository. The default value is 'initial commit'`
|
|
496
|
+
},
|
|
497
|
+
gitAuthorName: {
|
|
498
|
+
title: "Default Author Name",
|
|
499
|
+
type: "string",
|
|
500
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
501
|
+
},
|
|
502
|
+
gitAuthorEmail: {
|
|
503
|
+
title: "Default Author Email",
|
|
504
|
+
type: "string",
|
|
505
|
+
description: `Sets the default author email for the commit.`
|
|
506
|
+
},
|
|
507
|
+
sourcePath: {
|
|
508
|
+
title: "Source Path",
|
|
509
|
+
description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
|
|
510
|
+
type: "string"
|
|
511
|
+
},
|
|
512
|
+
token: {
|
|
513
|
+
title: "Authentication Token",
|
|
514
|
+
type: "string",
|
|
515
|
+
description: "The token to use for authorization to GitLab"
|
|
516
|
+
},
|
|
517
|
+
setUserAsOwner: {
|
|
518
|
+
title: "Set User As Owner",
|
|
519
|
+
type: "boolean",
|
|
520
|
+
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"
|
|
521
|
+
},
|
|
522
|
+
topics: {
|
|
523
|
+
title: "Topic labels",
|
|
524
|
+
description: "Topic labels to apply on the repository. (deprecated, use settings.topics instead)",
|
|
525
|
+
type: "array",
|
|
526
|
+
items: {
|
|
527
|
+
type: "string"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
settings: {
|
|
531
|
+
title: "Project settings",
|
|
532
|
+
description: "Additional project settings, based on https://docs.gitlab.com/ee/api/projects.html#create-project attributes",
|
|
533
|
+
type: "object",
|
|
534
|
+
properties: {
|
|
535
|
+
path: {
|
|
536
|
+
title: "Project path",
|
|
537
|
+
description: "Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).",
|
|
538
|
+
type: "string"
|
|
539
|
+
},
|
|
540
|
+
auto_devops_enabled: {
|
|
541
|
+
title: "Auto DevOps enabled",
|
|
542
|
+
description: "Enable Auto DevOps for this project",
|
|
543
|
+
type: "boolean"
|
|
544
|
+
},
|
|
545
|
+
ci_config_path: {
|
|
546
|
+
title: "CI config path",
|
|
547
|
+
description: "Custom CI config path for this project",
|
|
548
|
+
type: "string"
|
|
549
|
+
},
|
|
550
|
+
description: {
|
|
551
|
+
title: "Project description",
|
|
552
|
+
description: "Short project description",
|
|
553
|
+
type: "string"
|
|
554
|
+
},
|
|
555
|
+
topics: {
|
|
556
|
+
title: "Topic labels",
|
|
557
|
+
description: "Topic labels to apply on the repository",
|
|
558
|
+
type: "array",
|
|
559
|
+
items: {
|
|
560
|
+
type: "string"
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
visibility: {
|
|
564
|
+
title: "Project visibility",
|
|
565
|
+
description: "The visibility of the project. Can be private, internal, or public. The default value is private.",
|
|
566
|
+
type: "string",
|
|
567
|
+
enum: ["private", "public", "internal"]
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
branches: {
|
|
572
|
+
title: "Project branches settings",
|
|
573
|
+
type: "array",
|
|
574
|
+
items: {
|
|
575
|
+
type: "object",
|
|
576
|
+
required: ["name"],
|
|
577
|
+
properties: {
|
|
578
|
+
name: {
|
|
579
|
+
title: "Branch name",
|
|
580
|
+
type: "string"
|
|
581
|
+
},
|
|
582
|
+
protect: {
|
|
583
|
+
title: "Should branch be protected",
|
|
584
|
+
description: `Will mark branch as protected. The default value is 'false'`,
|
|
585
|
+
type: "boolean"
|
|
586
|
+
},
|
|
587
|
+
create: {
|
|
588
|
+
title: "Should branch be created",
|
|
589
|
+
description: `If branch does not exist, it will be created from provided ref. The default value is 'false'`,
|
|
590
|
+
type: "boolean"
|
|
591
|
+
},
|
|
592
|
+
ref: {
|
|
593
|
+
title: "Branch reference",
|
|
594
|
+
description: `Branch reference to create branch from. The default value is 'master'`,
|
|
595
|
+
type: "string"
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
projectVariables: {
|
|
601
|
+
title: "Project variables",
|
|
602
|
+
description: "Project variables settings based on Gitlab Project Environments API - https://docs.gitlab.com/ee/api/project_level_variables.html#create-a-variable",
|
|
603
|
+
type: "array",
|
|
604
|
+
items: {
|
|
605
|
+
type: "object",
|
|
606
|
+
required: ["key", "value"],
|
|
607
|
+
properties: {
|
|
608
|
+
key: {
|
|
609
|
+
title: "Variable key",
|
|
610
|
+
description: "The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed",
|
|
611
|
+
type: "string"
|
|
612
|
+
},
|
|
613
|
+
value: {
|
|
614
|
+
title: "Variable value",
|
|
615
|
+
description: "The value of a variable",
|
|
616
|
+
type: "string"
|
|
617
|
+
},
|
|
618
|
+
description: {
|
|
619
|
+
title: "Variable description",
|
|
620
|
+
description: `The description of the variable. The default value is 'null'`,
|
|
621
|
+
type: "string"
|
|
622
|
+
},
|
|
623
|
+
variable_type: {
|
|
624
|
+
title: "Variable type",
|
|
625
|
+
description: `The type of a variable. The default value is 'env_var'`,
|
|
626
|
+
type: "string",
|
|
627
|
+
enum: ["env_var", "file"]
|
|
628
|
+
},
|
|
629
|
+
protected: {
|
|
630
|
+
title: "Variable protection",
|
|
631
|
+
description: `Whether the variable is protected. The default value is 'false'`,
|
|
632
|
+
type: "boolean"
|
|
633
|
+
},
|
|
634
|
+
raw: {
|
|
635
|
+
title: "Variable raw",
|
|
636
|
+
description: `Whether the variable is in raw format. The default value is 'false'`,
|
|
637
|
+
type: "boolean"
|
|
638
|
+
},
|
|
639
|
+
environment_scope: {
|
|
640
|
+
title: "Variable environment scope",
|
|
641
|
+
description: `The environment_scope of the variable. The default value is '*'`,
|
|
642
|
+
type: "string"
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
output: {
|
|
650
|
+
type: "object",
|
|
651
|
+
properties: {
|
|
652
|
+
remoteUrl: {
|
|
653
|
+
title: "A URL to the repository with the provider",
|
|
654
|
+
type: "string"
|
|
655
|
+
},
|
|
656
|
+
repoContentsUrl: {
|
|
657
|
+
title: "A URL to the root of the repository",
|
|
658
|
+
type: "string"
|
|
659
|
+
},
|
|
660
|
+
projectId: {
|
|
661
|
+
title: "The ID of the project",
|
|
662
|
+
type: "string"
|
|
663
|
+
},
|
|
664
|
+
commitHash: {
|
|
665
|
+
title: "The git commit hash of the initial commit",
|
|
666
|
+
type: "string"
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
async handler(ctx) {
|
|
672
|
+
var _a, _b, _c, _d, _e;
|
|
673
|
+
const {
|
|
674
|
+
repoUrl,
|
|
675
|
+
repoVisibility = "private",
|
|
676
|
+
defaultBranch = "master",
|
|
677
|
+
gitCommitMessage = "initial commit",
|
|
678
|
+
gitAuthorName,
|
|
679
|
+
gitAuthorEmail,
|
|
680
|
+
setUserAsOwner = false,
|
|
681
|
+
topics = [],
|
|
682
|
+
settings = {},
|
|
683
|
+
branches = [],
|
|
684
|
+
projectVariables = []
|
|
685
|
+
} = ctx.input;
|
|
686
|
+
const { owner, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
687
|
+
if (!owner) {
|
|
688
|
+
throw new errors.InputError(
|
|
689
|
+
`No owner provided for host: ${host}, and repo ${repo}`
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
const integrationConfig = integrations.gitlab.byHost(host);
|
|
693
|
+
if (!integrationConfig) {
|
|
694
|
+
throw new errors.InputError(
|
|
695
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
if (!integrationConfig.config.token && !ctx.input.token) {
|
|
699
|
+
throw new errors.InputError(`No token available for host ${host}`);
|
|
700
|
+
}
|
|
701
|
+
const token = ctx.input.token || integrationConfig.config.token;
|
|
702
|
+
const tokenType = ctx.input.token ? "oauthToken" : "token";
|
|
703
|
+
const client = new node.Gitlab({
|
|
704
|
+
host: integrationConfig.config.baseUrl,
|
|
705
|
+
[tokenType]: token
|
|
706
|
+
});
|
|
707
|
+
let targetNamespaceId;
|
|
708
|
+
try {
|
|
709
|
+
const namespaceResponse = await client.Namespaces.show(owner);
|
|
710
|
+
targetNamespaceId = namespaceResponse.id;
|
|
711
|
+
} catch (e) {
|
|
712
|
+
if (e.response && e.response.statusCode === 404) {
|
|
713
|
+
throw new errors.InputError(
|
|
714
|
+
`The namespace ${owner} is not found or the user doesn't have permissions to access it`
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
throw e;
|
|
718
|
+
}
|
|
719
|
+
const { id: userId } = await client.Users.current();
|
|
720
|
+
if (!targetNamespaceId) {
|
|
721
|
+
targetNamespaceId = userId;
|
|
722
|
+
}
|
|
723
|
+
const { id: projectId, http_url_to_repo } = await client.Projects.create({
|
|
724
|
+
namespace_id: targetNamespaceId,
|
|
725
|
+
name: repo,
|
|
726
|
+
visibility: repoVisibility,
|
|
727
|
+
...topics.length ? { topics } : {},
|
|
728
|
+
...Object.keys(settings).length ? { ...settings } : {}
|
|
729
|
+
});
|
|
730
|
+
if (setUserAsOwner && integrationConfig.config.token) {
|
|
731
|
+
const adminClient = new node.Gitlab({
|
|
732
|
+
host: integrationConfig.config.baseUrl,
|
|
733
|
+
token: integrationConfig.config.token
|
|
734
|
+
});
|
|
735
|
+
await adminClient.ProjectMembers.add(projectId, userId, 50);
|
|
736
|
+
}
|
|
737
|
+
const remoteUrl = http_url_to_repo.replace(/\.git$/, "");
|
|
738
|
+
const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;
|
|
739
|
+
const gitAuthorInfo = {
|
|
740
|
+
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
741
|
+
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
742
|
+
};
|
|
743
|
+
const commitResult = await pluginScaffolderNode.initRepoAndPush({
|
|
744
|
+
dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
|
|
745
|
+
remoteUrl: http_url_to_repo,
|
|
746
|
+
defaultBranch,
|
|
747
|
+
auth: {
|
|
748
|
+
username: "oauth2",
|
|
749
|
+
password: token
|
|
750
|
+
},
|
|
751
|
+
logger: ctx.logger,
|
|
752
|
+
commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
|
|
753
|
+
gitAuthorInfo
|
|
754
|
+
});
|
|
755
|
+
if (branches) {
|
|
756
|
+
for (const branch of branches) {
|
|
757
|
+
const {
|
|
758
|
+
name,
|
|
759
|
+
protect = false,
|
|
760
|
+
create = false,
|
|
761
|
+
ref = "master"
|
|
762
|
+
} = branch;
|
|
763
|
+
if (create) {
|
|
764
|
+
try {
|
|
765
|
+
await client.Branches.create(projectId, name, ref);
|
|
766
|
+
} catch (e) {
|
|
767
|
+
throw new errors.InputError(
|
|
768
|
+
`Branch creation failed for ${name}. ${printGitlabError(e)}`
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
ctx.logger.info(
|
|
772
|
+
`Branch ${name} created for ${projectId} with ref ${ref}`
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
if (protect) {
|
|
776
|
+
try {
|
|
777
|
+
await client.ProtectedBranches.protect(projectId, name);
|
|
778
|
+
} catch (e) {
|
|
779
|
+
throw new errors.InputError(
|
|
780
|
+
`Branch protection failed for ${name}. ${printGitlabError(e)}`
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
ctx.logger.info(`Branch ${name} protected for ${projectId}`);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (projectVariables) {
|
|
788
|
+
for (const variable of projectVariables) {
|
|
789
|
+
const variableWithDefaults = Object.assign(variable, {
|
|
790
|
+
variable_type: (_a = variable.variable_type) != null ? _a : "env_var",
|
|
791
|
+
protected: (_b = variable.protected) != null ? _b : false,
|
|
792
|
+
masked: (_c = variable.masked) != null ? _c : false,
|
|
793
|
+
raw: (_d = variable.raw) != null ? _d : false,
|
|
794
|
+
environment_scope: (_e = variable.environment_scope) != null ? _e : "*"
|
|
795
|
+
});
|
|
796
|
+
try {
|
|
797
|
+
await client.ProjectVariables.create(
|
|
798
|
+
projectId,
|
|
799
|
+
variableWithDefaults
|
|
800
|
+
);
|
|
801
|
+
} catch (e) {
|
|
802
|
+
throw new errors.InputError(
|
|
803
|
+
`Environment variable creation failed for ${variableWithDefaults.key}. ${printGitlabError(e)}`
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
ctx.output("commitHash", commitResult == null ? void 0 : commitResult.commitHash);
|
|
809
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
810
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
811
|
+
ctx.output("projectId", projectId);
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
function printGitlabError(error) {
|
|
816
|
+
return JSON.stringify({ code: error.code, message: error.description });
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const createPublishGitlabMergeRequestAction = (options) => {
|
|
820
|
+
const { integrations } = options;
|
|
821
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
822
|
+
id: "publish:gitlab:merge-request",
|
|
823
|
+
schema: {
|
|
824
|
+
input: {
|
|
825
|
+
required: ["repoUrl", "branchName"],
|
|
826
|
+
type: "object",
|
|
827
|
+
properties: {
|
|
828
|
+
repoUrl: {
|
|
829
|
+
type: "string",
|
|
830
|
+
title: "Repository Location",
|
|
831
|
+
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`
|
|
832
|
+
},
|
|
833
|
+
/** @deprecated projectID is passed as query parameters in the repoUrl */
|
|
834
|
+
projectid: {
|
|
835
|
+
type: "string",
|
|
836
|
+
title: "projectid",
|
|
837
|
+
description: "Project ID/Name(slug) of the Gitlab Project"
|
|
838
|
+
},
|
|
839
|
+
title: {
|
|
840
|
+
type: "string",
|
|
841
|
+
title: "Merge Request Name",
|
|
842
|
+
description: "The name for the merge request"
|
|
843
|
+
},
|
|
844
|
+
description: {
|
|
845
|
+
type: "string",
|
|
846
|
+
title: "Merge Request Description",
|
|
847
|
+
description: "The description of the merge request"
|
|
848
|
+
},
|
|
849
|
+
branchName: {
|
|
850
|
+
type: "string",
|
|
851
|
+
title: "Source Branch Name",
|
|
852
|
+
description: "The source branch name of the merge request"
|
|
853
|
+
},
|
|
854
|
+
targetBranchName: {
|
|
855
|
+
type: "string",
|
|
856
|
+
title: "Target Branch Name",
|
|
857
|
+
description: "The target branch name of the merge request"
|
|
858
|
+
},
|
|
859
|
+
sourcePath: {
|
|
860
|
+
type: "string",
|
|
861
|
+
title: "Working Subdirectory",
|
|
862
|
+
description: "Subdirectory of working directory to copy changes from"
|
|
863
|
+
},
|
|
864
|
+
targetPath: {
|
|
865
|
+
type: "string",
|
|
866
|
+
title: "Repository Subdirectory",
|
|
867
|
+
description: "Subdirectory of repository to apply changes to"
|
|
868
|
+
},
|
|
869
|
+
token: {
|
|
870
|
+
title: "Authentication Token",
|
|
871
|
+
type: "string",
|
|
872
|
+
description: "The token to use for authorization to GitLab"
|
|
873
|
+
},
|
|
874
|
+
commitAction: {
|
|
875
|
+
title: "Commit action",
|
|
876
|
+
type: "string",
|
|
877
|
+
enum: ["create", "update", "delete"],
|
|
878
|
+
description: "The action to be used for git commit. Defaults to create."
|
|
879
|
+
},
|
|
880
|
+
removeSourceBranch: {
|
|
881
|
+
title: "Delete source branch",
|
|
882
|
+
type: "boolean",
|
|
883
|
+
description: "Option to delete source branch once the MR has been merged. Default: false"
|
|
884
|
+
},
|
|
885
|
+
assignee: {
|
|
886
|
+
title: "Merge Request Assignee",
|
|
887
|
+
type: "string",
|
|
888
|
+
description: "User this merge request will be assigned to"
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
output: {
|
|
893
|
+
type: "object",
|
|
894
|
+
properties: {
|
|
895
|
+
targetBranchName: {
|
|
896
|
+
title: "Target branch name of the merge request",
|
|
897
|
+
type: "string"
|
|
898
|
+
},
|
|
899
|
+
projectid: {
|
|
900
|
+
title: "Gitlab Project id/Name(slug)",
|
|
901
|
+
type: "string"
|
|
902
|
+
},
|
|
903
|
+
projectPath: {
|
|
904
|
+
title: "Gitlab Project path",
|
|
905
|
+
type: "string"
|
|
906
|
+
},
|
|
907
|
+
mergeRequestUrl: {
|
|
908
|
+
title: "MergeRequest(MR) URL",
|
|
909
|
+
type: "string",
|
|
910
|
+
description: "Link to the merge request in GitLab"
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
async handler(ctx) {
|
|
916
|
+
const {
|
|
917
|
+
assignee,
|
|
918
|
+
branchName,
|
|
919
|
+
targetBranchName,
|
|
920
|
+
description,
|
|
921
|
+
repoUrl,
|
|
922
|
+
removeSourceBranch,
|
|
923
|
+
targetPath,
|
|
924
|
+
sourcePath,
|
|
925
|
+
title,
|
|
926
|
+
token: providedToken
|
|
927
|
+
} = ctx.input;
|
|
928
|
+
const { host, owner, repo, project } = pluginScaffolderNode.parseRepoUrl(
|
|
929
|
+
repoUrl,
|
|
930
|
+
integrations
|
|
931
|
+
);
|
|
932
|
+
const repoID = project ? project : `${owner}/${repo}`;
|
|
933
|
+
const integrationConfig = integrations.gitlab.byHost(host);
|
|
934
|
+
if (!integrationConfig) {
|
|
935
|
+
throw new errors.InputError(
|
|
936
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
if (!integrationConfig.config.token && !providedToken) {
|
|
940
|
+
throw new errors.InputError(`No token available for host ${host}`);
|
|
941
|
+
}
|
|
942
|
+
const token = providedToken != null ? providedToken : integrationConfig.config.token;
|
|
943
|
+
const tokenType = providedToken ? "oauthToken" : "token";
|
|
944
|
+
const api = new node.Gitlab({
|
|
945
|
+
host: integrationConfig.config.baseUrl,
|
|
946
|
+
[tokenType]: token
|
|
947
|
+
});
|
|
948
|
+
let assigneeId = void 0;
|
|
949
|
+
if (assignee !== void 0) {
|
|
950
|
+
try {
|
|
951
|
+
const assigneeUser = await api.Users.username(assignee);
|
|
952
|
+
assigneeId = assigneeUser[0].id;
|
|
953
|
+
} catch (e) {
|
|
954
|
+
ctx.logger.warn(
|
|
955
|
+
`Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
let fileRoot;
|
|
960
|
+
if (sourcePath) {
|
|
961
|
+
fileRoot = backendCommon.resolveSafeChildPath(ctx.workspacePath, sourcePath);
|
|
962
|
+
} else if (targetPath) {
|
|
963
|
+
fileRoot = backendCommon.resolveSafeChildPath(ctx.workspacePath, targetPath);
|
|
964
|
+
} else {
|
|
965
|
+
fileRoot = ctx.workspacePath;
|
|
966
|
+
}
|
|
967
|
+
const fileContents = await pluginScaffolderNode.serializeDirectoryContents(fileRoot, {
|
|
968
|
+
gitignore: true
|
|
969
|
+
});
|
|
970
|
+
const actions = fileContents.map((file) => {
|
|
971
|
+
var _a;
|
|
972
|
+
return {
|
|
973
|
+
action: (_a = ctx.input.commitAction) != null ? _a : "create",
|
|
974
|
+
filePath: targetPath ? path__default["default"].posix.join(targetPath, file.path) : file.path,
|
|
975
|
+
encoding: "base64",
|
|
976
|
+
content: file.content.toString("base64"),
|
|
977
|
+
execute_filemode: file.executable
|
|
978
|
+
};
|
|
979
|
+
});
|
|
980
|
+
let targetBranch = targetBranchName;
|
|
981
|
+
if (!targetBranch) {
|
|
982
|
+
const projects = await api.Projects.show(repoID);
|
|
983
|
+
const { default_branch: defaultBranch } = projects;
|
|
984
|
+
targetBranch = defaultBranch;
|
|
985
|
+
}
|
|
986
|
+
try {
|
|
987
|
+
await api.Branches.create(repoID, branchName, String(targetBranch));
|
|
988
|
+
} catch (e) {
|
|
989
|
+
throw new errors.InputError(
|
|
990
|
+
`The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
try {
|
|
994
|
+
await api.Commits.create(repoID, branchName, ctx.input.title, actions);
|
|
995
|
+
} catch (e) {
|
|
996
|
+
throw new errors.InputError(
|
|
997
|
+
`Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
try {
|
|
1001
|
+
const mergeRequestUrl = await api.MergeRequests.create(
|
|
1002
|
+
repoID,
|
|
1003
|
+
branchName,
|
|
1004
|
+
String(targetBranch),
|
|
1005
|
+
title,
|
|
1006
|
+
{
|
|
1007
|
+
description,
|
|
1008
|
+
removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,
|
|
1009
|
+
assigneeId
|
|
1010
|
+
}
|
|
1011
|
+
).then((mergeRequest) => {
|
|
1012
|
+
return mergeRequest.web_url;
|
|
1013
|
+
});
|
|
1014
|
+
ctx.output("projectid", repoID);
|
|
1015
|
+
ctx.output("targetBranchName", targetBranch);
|
|
1016
|
+
ctx.output("projectPath", repoID);
|
|
1017
|
+
ctx.output("mergeRequestUrl", mergeRequestUrl);
|
|
1018
|
+
} catch (e) {
|
|
1019
|
+
throw new errors.InputError(`Merge request creation failed${e}`);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
|
|
336
1025
|
exports.createGitlabGroupEnsureExistsAction = createGitlabGroupEnsureExistsAction;
|
|
337
1026
|
exports.createGitlabProjectAccessTokenAction = createGitlabProjectAccessTokenAction;
|
|
338
1027
|
exports.createGitlabProjectDeployTokenAction = createGitlabProjectDeployTokenAction;
|
|
339
1028
|
exports.createGitlabProjectVariableAction = createGitlabProjectVariableAction;
|
|
1029
|
+
exports.createPublishGitlabAction = createPublishGitlabAction;
|
|
1030
|
+
exports.createPublishGitlabMergeRequestAction = createPublishGitlabMergeRequestAction;
|
|
340
1031
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/commonGitlabConfig.ts","../src/util.ts","../src/actions/createGitlabGroupEnsureExistsAction.ts","../src/actions/createGitlabProjectDeployTokenAction.ts","../src/actions/createGitlabProjectAccessTokenAction.examples.ts","../src/actions/createGitlabProjectAccessTokenAction.ts","../src/actions/createGitlabProjectVariableAction.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 { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n","/*\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 {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\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 const tokenType = config.token ? 'oauthToken' : 'token';\n\n if (tokenType === 'oauthToken') {\n throw new InputError(`OAuth Token is currently not supported`);\n }\n\n return { token: token, integrationConfig: integrationConfig };\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { GroupSchema } from '@gitbeaker/core/dist/types/resources/Groups';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\n\n/**\n * Creates an `gitlab:group:ensureExists` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupEnsureExistsAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:ensureExists',\n description: 'Ensures a Gitlab group exists',\n supportsDryRun: true,\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n path: z\n .array(z.string(), {\n description: 'A path of group names that is ensured to exist',\n })\n .min(1),\n }),\n ),\n output: z.object({\n groupId: z\n .number({ description: 'The id of the innermost sub-group' })\n .optional(),\n }),\n },\n async handler(ctx) {\n if (ctx.isDryRun) {\n ctx.output('groupId', 42);\n return;\n }\n\n const { path } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n let currentPath: string | null = null;\n let parent: GroupSchema | null = null;\n for (const pathElement of path) {\n const fullPath: string = currentPath\n ? `${currentPath}/${pathElement}`\n : pathElement;\n const result = (await api.Groups.search(\n fullPath,\n )) as unknown as Array<GroupSchema>; // recast since the return type for search is wrong in the gitbeaker typings\n const subGroup = result.find(\n searchPathElem => searchPathElem.full_path === fullPath,\n );\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n parent = await api.Groups.create(\n pathElement,\n pathElement,\n parent\n ? {\n parent_id: parent.id,\n }\n : {},\n );\n } else {\n parent = subGroup;\n }\n currentPath = fullPath;\n }\n if (parent !== null) {\n ctx.output('groupId', parent?.id);\n }\n },\n });\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { DeployTokenScope } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { InputError } from '@backstage/errors';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectDeployToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectDeployToken:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }),\n username: z\n .string({ description: 'Deploy Token Username' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n deploy_token: z.string({ description: 'Deploy Token' }),\n user: z.string({ description: 'User' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n","/*\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: 'Create a GitLab project access token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token using specific GitLab integrations.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n },\n },\n ],\n }),\n },\n];\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\nimport { examples } from './createGitlabProjectAccessTokenAction.examples';\n\n/**\n * Creates a `gitlab:projectAccessToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectAccessToken:create',\n examples,\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }).optional(),\n accessLevel: z\n .number({ description: 'Access Level of the Token' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n access_token: z.string({ description: 'Access Token' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, accessLevel, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const response = await fetch(\n `${integrationConfig.config.baseUrl}/api/v4/projects/${projectId}/access_tokens`,\n {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'PRIVATE-TOKEN': token,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n name: name,\n scopes: scopes,\n access_level: accessLevel,\n }),\n },\n );\n\n const result = await response.json();\n\n ctx.output('access_token', result.token);\n },\n });\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { getToken } from '../util';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z\n .string({\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 })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z.string({ description: 'The value of a variable' }),\n variableType: z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z\n .boolean({ description: 'Whether the variable is protected' })\n .default(false)\n .optional(),\n masked: z\n .boolean({ description: 'Whether the variable is masked' })\n .default(false)\n .optional(),\n raw: z\n .boolean({ description: 'Whether the variable is expandable' })\n .default(false)\n .optional(),\n environmentScope: z\n .string({ description: 'The environment_scope of the variable' })\n .default('*')\n .optional(),\n }),\n ),\n },\n async handler(ctx) {\n const {\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n await api.ProjectVariables.create(projectId, {\n key: key,\n value: value,\n variable_type: variableType,\n protected: variableProtected,\n masked: masked,\n raw: raw,\n environment_scope: environmentScope,\n });\n },\n });\n};\n"],"names":["z","InputError","createTemplateAction","Gitlab","yaml"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,kBAAA,GAAqBA,MAAE,MAAO,CAAA;AAAA,EAClC,SAASA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,MACJ,MAAO,CAAA,EAAE,aAAa,8CAA+C,EAAC,EACtE,QAAS,EAAA;AACd,CAAC,CAAA;;ACCY,MAAA,aAAA,GAAgB,CAAC,OAA4B,KAAA;AACxD,EAAI,IAAA,MAAA,CAAA;AACJ,EAAI,IAAA;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAW,QAAA,EAAA,OAAO,CAAE,CAAA,CAA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src/actions/createGitlabGroupEnsureExistsAction.ts","../src/actions/createGitlabProjectDeployTokenAction.ts","../src/actions/createGitlabProjectAccessTokenAction.examples.ts","../src/actions/createGitlabProjectAccessTokenAction.ts","../src/actions/createGitlabProjectVariableAction.ts","../src/actions/gitlab.examples.ts","../src/actions/gitlab.ts","../src/actions/gitlabMergeRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n","/*\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 {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\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 const tokenType = config.token ? 'oauthToken' : 'token';\n\n if (tokenType === 'oauthToken') {\n throw new InputError(`OAuth Token is currently not supported`);\n }\n\n return { token: token, integrationConfig: integrationConfig };\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { GroupSchema } from '@gitbeaker/core/dist/types/resources/Groups';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\n\n/**\n * Creates an `gitlab:group:ensureExists` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupEnsureExistsAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:ensureExists',\n description: 'Ensures a Gitlab group exists',\n supportsDryRun: true,\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n path: z\n .array(z.string(), {\n description: 'A path of group names that is ensured to exist',\n })\n .min(1),\n }),\n ),\n output: z.object({\n groupId: z\n .number({ description: 'The id of the innermost sub-group' })\n .optional(),\n }),\n },\n async handler(ctx) {\n if (ctx.isDryRun) {\n ctx.output('groupId', 42);\n return;\n }\n\n const { path } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n let currentPath: string | null = null;\n let parent: GroupSchema | null = null;\n for (const pathElement of path) {\n const fullPath: string = currentPath\n ? `${currentPath}/${pathElement}`\n : pathElement;\n const result = (await api.Groups.search(\n fullPath,\n )) as unknown as Array<GroupSchema>; // recast since the return type for search is wrong in the gitbeaker typings\n const subGroup = result.find(\n searchPathElem => searchPathElem.full_path === fullPath,\n );\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n parent = await api.Groups.create(\n pathElement,\n pathElement,\n parent\n ? {\n parent_id: parent.id,\n }\n : {},\n );\n } else {\n parent = subGroup;\n }\n currentPath = fullPath;\n }\n if (parent !== null) {\n ctx.output('groupId', parent?.id);\n }\n },\n });\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { DeployTokenScope } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { InputError } from '@backstage/errors';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectDeployToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectDeployToken:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }),\n username: z\n .string({ description: 'Deploy Token Username' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n deploy_token: z.string({ description: 'Deploy Token' }),\n user: z.string({ description: 'User' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n","/*\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: 'Create a GitLab project access token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token using specific GitLab integrations.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n },\n },\n ],\n }),\n },\n];\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\nimport { examples } from './createGitlabProjectAccessTokenAction.examples';\n\n/**\n * Creates a `gitlab:projectAccessToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectAccessToken:create',\n examples,\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }).optional(),\n accessLevel: z\n .number({ description: 'Access Level of the Token' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n access_token: z.string({ description: 'Access Token' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, accessLevel, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const response = await fetch(\n `${integrationConfig.config.baseUrl}/api/v4/projects/${projectId}/access_tokens`,\n {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'PRIVATE-TOKEN': token,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n name: name,\n scopes: scopes,\n access_level: accessLevel,\n }),\n },\n );\n\n const result = await response.json();\n\n ctx.output('access_token', result.token);\n },\n });\n};\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { getToken } from '../util';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z\n .string({\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 })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z.string({ description: 'The value of a variable' }),\n variableType: z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z\n .boolean({ description: 'Whether the variable is protected' })\n .default(false)\n .optional(),\n masked: z\n .boolean({ description: 'Whether the variable is masked' })\n .default(false)\n .optional(),\n raw: z\n .boolean({ description: 'Whether the variable is expandable' })\n .default(false)\n .optional(),\n environmentScope: z\n .string({ description: 'The environment_scope of the variable' })\n .default('*')\n .optional(),\n }),\n ),\n },\n async handler(ctx) {\n const {\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n await api.ProjectVariables.create(projectId, {\n key: key,\n value: value,\n variable_type: variableType,\n protected: variableProtected,\n masked: masked,\n raw: raw,\n environment_scope: environmentScope,\n });\n },\n });\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n },\n },\n ],\n }),\n },\n {\n description: 'Add a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Sets the commit message on the repository. The default value is `initial commit`.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n description: 'Initialize a git repository',\n gitCommitMessage: 'Started a project.',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a git repository with additional settings.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n settings: {\n ci_config_path: '.gitlab-ci.yml',\n visibility: 'public',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a git repository with branches settings',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n branches: [\n {\n name: 'dev',\n create: true,\n protected: true,\n ref: 'master',\n },\n {\n name: 'master',\n protected: true,\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a git repository with environment variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitlab',\n name: 'Publish to GitLab',\n input: {\n repoUrl: 'gitlab.com?repo=project_name&owner=group_name',\n projectVariables: [\n {\n key: 'key1',\n value: 'value1',\n protected: true,\n masked: false,\n },\n {\n key: 'key2',\n value: 'value2',\n protected: true,\n masked: false,\n },\n ],\n },\n },\n ],\n }),\n },\n];\n","/*\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport {\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\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;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\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 topics?: string[];\n visibility?: 'private' | 'internal' | 'public';\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 sourcePath: {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\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 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 },\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: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\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 } = 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\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n };\n\n targetNamespaceId = namespaceResponse.id;\n } catch (e) {\n if (e.response && e.response.statusCode === 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.current()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n }\n\n const { id: projectId, http_url_to_repo } = await client.Projects.create({\n namespace_id: 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 commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\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 });\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(e)}`,\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(e)}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: variable.variable_type ?? 'env_var',\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,\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\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport { Types } from '@gitbeaker/core';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-common';\n\n/**\n * Create a new action that creates a gitlab merge request.\n *\n * @public\n */\nexport const createPublishGitlabMergeRequestAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n title: string;\n description: string;\n branchName: string;\n targetBranchName?: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update';\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid?: string;\n removeSourceBranch?: boolean;\n assignee?: string;\n }>({\n id: 'publish:gitlab:merge-request',\n schema: {\n input: {\n required: ['repoUrl', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n },\n /** @deprecated projectID is passed as query parameters in the repoUrl */\n projectid: {\n type: 'string',\n title: 'projectid',\n description: 'Project ID/Name(slug) of the Gitlab Project',\n },\n title: {\n type: 'string',\n title: 'Merge Request Name',\n description: 'The name for the merge request',\n },\n description: {\n type: 'string',\n title: 'Merge Request Description',\n description: 'The description of the merge request',\n },\n branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The source branch name of the merge request',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete'],\n description:\n 'The action to be used for git commit. Defaults to create.',\n },\n removeSourceBranch: {\n title: 'Delete source branch',\n type: 'boolean',\n description:\n 'Option to delete source branch once the MR has been merged. Default: false',\n },\n assignee: {\n title: 'Merge Request Assignee',\n type: 'string',\n description: 'User this merge request will be assigned to',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n mergeRequestUrl: {\n title: 'MergeRequest(MR) URL',\n type: 'string',\n description: 'Link to the merge request in GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n assignee,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo, project } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n const repoID = project ? project : `${owner}/${repo}`;\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 && !providedToken) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = providedToken ?? integrationConfig.config.token!;\n const tokenType = providedToken ? 'oauthToken' : 'token';\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let assigneeId = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.username(assignee);\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,\n );\n }\n }\n\n let fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else if (targetPath) {\n // for backward compatibility\n fileRoot = resolveSafeChildPath(ctx.workspacePath, targetPath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const actions: Types.CommitAction[] = fileContents.map(file => ({\n action: ctx.input.commitAction ?? 'create',\n filePath: targetPath\n ? path.posix.join(targetPath, file.path)\n : file.path,\n encoding: 'base64',\n content: file.content.toString('base64'),\n execute_filemode: file.executable,\n }));\n\n let targetBranch = targetBranchName;\n if (!targetBranch) {\n const projects = await api.Projects.show(repoID);\n\n const { default_branch: defaultBranch } = projects;\n targetBranch = defaultBranch!;\n }\n\n try {\n await api.Branches.create(repoID, branchName, String(targetBranch));\n } catch (e) {\n throw new InputError(\n `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${e}`,\n );\n }\n\n try {\n await api.Commits.create(repoID, branchName, ctx.input.title, actions);\n } catch (e) {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${e}`,\n );\n }\n\n try {\n const mergeRequestUrl = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,\n assigneeId,\n },\n ).then((mergeRequest: { web_url: string }) => {\n return mergeRequest.web_url;\n });\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mergeRequestUrl);\n } catch (e) {\n throw new InputError(`Merge request creation failed${e}`);\n }\n },\n });\n};\n"],"names":["z","InputError","createTemplateAction","Gitlab","examples","yaml","parseRepoUrl","initRepoAndPush","getRepoSourceDirectory","resolveSafeChildPath","serializeDirectoryContents","path"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAA,GAAqBA,MAAE,MAAO,CAAA;AAAA,EAClC,SAASA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,MACJ,MAAO,CAAA,EAAE,aAAa,8CAA+C,EAAC,EACtE,QAAS,EAAA;AACd,CAAC,CAAA;;ACCY,MAAA,aAAA,GAAgB,CAAC,OAA4B,KAAA;AACxD,EAAI,IAAA,MAAA,CAAA;AACJ,EAAI,IAAA;AACF,IAAA,MAA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,MAAA,CAAO,eAAe,MAAM,CAAA,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,eACtC,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,OAC1D;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
2
|
import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
3
3
|
import * as _backstage_types from '@backstage/types';
|
|
4
|
+
import { Config } from '@backstage/config';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Creates an `gitlab:group:ensureExists` Scaffolder action.
|
|
@@ -77,4 +78,75 @@ declare const createGitlabProjectVariableAction: (options: {
|
|
|
77
78
|
environmentScope?: string | undefined;
|
|
78
79
|
}, _backstage_types.JsonObject>;
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new action that initializes a git repository of the content in the workspace
|
|
83
|
+
* and publishes it to GitLab.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
declare function createPublishGitlabAction(options: {
|
|
88
|
+
integrations: ScmIntegrationRegistry;
|
|
89
|
+
config: Config;
|
|
90
|
+
}): _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
91
|
+
repoUrl: string;
|
|
92
|
+
defaultBranch?: string | undefined;
|
|
93
|
+
/** @deprecated in favour of settings.visibility field */
|
|
94
|
+
repoVisibility?: "internal" | "private" | "public" | undefined;
|
|
95
|
+
sourcePath?: string | undefined;
|
|
96
|
+
token?: string | undefined;
|
|
97
|
+
gitCommitMessage?: string | undefined;
|
|
98
|
+
gitAuthorName?: string | undefined;
|
|
99
|
+
gitAuthorEmail?: string | undefined;
|
|
100
|
+
setUserAsOwner?: boolean | undefined;
|
|
101
|
+
/** @deprecated in favour of settings.topics field */
|
|
102
|
+
topics?: string[] | undefined;
|
|
103
|
+
settings?: {
|
|
104
|
+
path?: string | undefined;
|
|
105
|
+
auto_devops_enabled?: boolean | undefined;
|
|
106
|
+
ci_config_path?: string | undefined;
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
topics?: string[] | undefined;
|
|
109
|
+
visibility?: "internal" | "private" | "public" | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
branches?: {
|
|
112
|
+
name: string;
|
|
113
|
+
protect?: boolean | undefined;
|
|
114
|
+
create?: boolean | undefined;
|
|
115
|
+
ref?: string | undefined;
|
|
116
|
+
}[] | undefined;
|
|
117
|
+
projectVariables?: {
|
|
118
|
+
key: string;
|
|
119
|
+
value: string;
|
|
120
|
+
description?: string | undefined;
|
|
121
|
+
variable_type?: string | undefined;
|
|
122
|
+
protected?: boolean | undefined;
|
|
123
|
+
masked?: boolean | undefined;
|
|
124
|
+
raw?: boolean | undefined;
|
|
125
|
+
environment_scope?: string | undefined;
|
|
126
|
+
}[] | undefined;
|
|
127
|
+
}, _backstage_types.JsonObject>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Create a new action that creates a gitlab merge request.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
declare const createPublishGitlabMergeRequestAction: (options: {
|
|
135
|
+
integrations: ScmIntegrationRegistry;
|
|
136
|
+
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
137
|
+
repoUrl: string;
|
|
138
|
+
title: string;
|
|
139
|
+
description: string;
|
|
140
|
+
branchName: string;
|
|
141
|
+
targetBranchName?: string | undefined;
|
|
142
|
+
sourcePath?: string | undefined;
|
|
143
|
+
targetPath?: string | undefined;
|
|
144
|
+
token?: string | undefined;
|
|
145
|
+
commitAction?: "update" | "delete" | "create" | undefined;
|
|
146
|
+
/** @deprecated projectID passed as query parameters in the repoUrl */
|
|
147
|
+
projectid?: string | undefined;
|
|
148
|
+
removeSourceBranch?: boolean | undefined;
|
|
149
|
+
assignee?: string | undefined;
|
|
150
|
+
}, _backstage_types.JsonObject>;
|
|
151
|
+
|
|
152
|
+
export { createGitlabGroupEnsureExistsAction, createGitlabProjectAccessTokenAction, createGitlabProjectDeployTokenAction, createGitlabProjectVariableAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitlab",
|
|
3
|
-
"version": "0.2.11
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,18 +31,20 @@
|
|
|
31
31
|
"postpack": "backstage-cli package postpack"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@backstage/backend-common": "^0.20.0",
|
|
34
35
|
"@backstage/config": "^1.1.1",
|
|
35
36
|
"@backstage/errors": "^1.2.3",
|
|
36
|
-
"@backstage/integration": "^1.8.0
|
|
37
|
-
"@backstage/plugin-scaffolder-node": "^0.2.9
|
|
37
|
+
"@backstage/integration": "^1.8.0",
|
|
38
|
+
"@backstage/plugin-scaffolder-node": "^0.2.9",
|
|
39
|
+
"@gitbeaker/core": "^35.8.0",
|
|
38
40
|
"@gitbeaker/node": "^35.8.0",
|
|
39
41
|
"yaml": "^2.0.0",
|
|
40
|
-
"zod": "^3.
|
|
42
|
+
"zod": "^3.22.4"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@backstage/backend-
|
|
44
|
-
"@backstage/cli": "^0.25.0
|
|
45
|
-
"@backstage/core-app-api": "^1.11.2
|
|
45
|
+
"@backstage/backend-test-utils": "^0.2.9",
|
|
46
|
+
"@backstage/cli": "^0.25.0",
|
|
47
|
+
"@backstage/core-app-api": "^1.11.2"
|
|
46
48
|
},
|
|
47
49
|
"files": [
|
|
48
50
|
"dist"
|