@backstage/cli 0.26.6-next.0 → 0.26.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -14
- package/dist/cjs/{Lockfile-BGMdDb8M.cjs.js → Lockfile-C7rtIlD6.cjs.js} +21 -54
- package/dist/cjs/{build-oOoA6doT.cjs.js → build-BSDLApkE.cjs.js} +17 -14
- package/dist/cjs/{buildBackend-DCTPybGH.cjs.js → buildBackend-FV4cZ7YT.cjs.js} +10 -8
- package/dist/cjs/{buildWorkspace-BZ9SFxD1.cjs.js → buildWorkspace-DV7BpoZT.cjs.js} +5 -5
- package/dist/cjs/{bump-DrU2bDOA.cjs.js → bump-CjL9wSlI.cjs.js} +21 -16
- package/dist/cjs/{clean-CTXeO6EC.cjs.js → clean-Cw1FeJO5.cjs.js} +4 -3
- package/dist/cjs/{clean-Xt20-SOd.cjs.js → clean-SL6sMYtJ.cjs.js} +2 -2
- package/dist/cjs/{codeowners-CmW2AVMp.cjs.js → codeowners-B9Ys_6Yd.cjs.js} +2 -2
- package/dist/cjs/{config-Dr_8wy8K.cjs.js → config-XS8tRRzZ.cjs.js} +4 -3
- package/dist/cjs/{createDistWorkspace-DgvlH81m.cjs.js → createDistWorkspace-B1pyeDwS.cjs.js} +21 -15
- package/dist/cjs/{createPlugin-DJh1uHOM.cjs.js → createPlugin-Bf67GaKA.cjs.js} +8 -7
- package/dist/cjs/{diff-BFT2J47H.cjs.js → diff-jArODNjZ.cjs.js} +2 -2
- package/dist/cjs/{docs-DPxUZ_5M.cjs.js → docs-VFbH2gLP.cjs.js} +3 -3
- package/dist/cjs/{fix-Ds21Csn8.cjs.js → fix-F8xWYiWH.cjs.js} +4 -3
- package/dist/cjs/{index-C9SFHBJ7.cjs.js → index-BWsdQbfr.cjs.js} +343 -160
- package/dist/cjs/{index-D262VPnW.cjs.js → index-CS6xQRSZ.cjs.js} +67 -60
- package/dist/cjs/{index-zmkgRMEr.cjs.js → index-DtxQfUmH.cjs.js} +9 -9
- package/dist/cjs/{index-CIfGsnyl.cjs.js → index-Wt0qQuCU.cjs.js} +68 -33
- package/dist/cjs/{index-C9SBzA6q.cjs.js → index-ko14Ea3F.cjs.js} +44 -38
- package/dist/cjs/{info-BJvAN-EV.cjs.js → info-31wuUeHo.cjs.js} +6 -5
- package/dist/cjs/{install-iHbt_0aM.cjs.js → install-Bf0Cm4CP.cjs.js} +11 -8
- package/dist/cjs/{lint-BQoZALVi.cjs.js → lint-BHZJ9s87.cjs.js} +2 -2
- package/dist/cjs/{lint-DhdvUtZ-.cjs.js → lint-CeLPKohb.cjs.js} +4 -4
- package/dist/cjs/{lint-ccLOCCQ7.cjs.js → lint-NokSgx6Q.cjs.js} +2 -2
- package/dist/cjs/{list-deprecations-DKQAIdF-.cjs.js → list-deprecations-PCaNouxb.cjs.js} +2 -2
- package/dist/cjs/{new-pqVZtq0L.cjs.js → new-wsaO3CgE.cjs.js} +19 -11
- package/dist/cjs/{pack-Cb0EFwcV.cjs.js → pack-D65aI1Y5.cjs.js} +3 -3
- package/dist/cjs/{packageDetection-Cfl0g9oD.cjs.js → packageDetection-DT09yDE6.cjs.js} +21 -15
- package/dist/cjs/{packageExports-qb2FnJFt.cjs.js → packageExports-BQpjmF7V.cjs.js} +3 -3
- package/dist/cjs/{packageLintConfigs-CZbCJdAI.cjs.js → packageLintConfigs-CtbeLXlD.cjs.js} +5 -4
- package/dist/cjs/{packageRole-C_eAxVdS.cjs.js → packageRole-B-GQB2ZF.cjs.js} +2 -2
- package/dist/cjs/{packageScripts-DX6dilK6.cjs.js → packageScripts-CPnlPBBs.cjs.js} +11 -10
- package/dist/cjs/{packages-C0iBE8_o.cjs.js → packages-BS13eILq.cjs.js} +10 -6
- package/dist/cjs/{print-DKlinc6o.cjs.js → print-B6UB54DH.cjs.js} +3 -3
- package/dist/cjs/{productionPack-BfVQNApa.cjs.js → productionPack-DotlEIE2.cjs.js} +6 -4
- package/dist/cjs/{reactRouterDeps-CR-hjviw.cjs.js → reactRouterDeps-BBKc6o07.cjs.js} +3 -2
- package/dist/cjs/{role-ji3J4lHr.cjs.js → role-DTQZhzFJ.cjs.js} +4 -3
- package/dist/cjs/{run-C1016vC-.cjs.js → run-B3QtsbD6.cjs.js} +4 -3
- package/dist/cjs/{schema--27U4Pnd.cjs.js → schema-M5iIZ_Eq.cjs.js} +3 -3
- package/dist/cjs/{tasks-Dy-6nV0-.cjs.js → tasks-mGXy8WjR.cjs.js} +3 -3
- package/dist/cjs/{test-0Q9Uv4gn.cjs.js → test-BuGhBxNC.cjs.js} +3 -3
- package/dist/cjs/{test-BlJ7hC1z.cjs.js → test-Dt0SmBb4.cjs.js} +3 -3
- package/dist/cjs/{validate-DrFKUEDH.cjs.js → validate-2WOv51mB.cjs.js} +3 -3
- package/dist/index.cjs.js +1 -1
- package/package.json +10 -10
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var inquirer = require('inquirer');
|
|
5
|
-
var tasks = require('./tasks-
|
|
5
|
+
var tasks = require('./tasks-mGXy8WjR.cjs.js');
|
|
6
6
|
var oauthApp = require('@octokit/oauth-app');
|
|
7
7
|
var fs = require('fs-extra');
|
|
8
8
|
var yaml = require('yaml');
|
|
9
9
|
var cliCommon = require('@backstage/cli-common');
|
|
10
10
|
var path = require('path');
|
|
11
11
|
var differ = require('diff');
|
|
12
|
-
var config = require('./config-
|
|
12
|
+
var config = require('./config-XS8tRRzZ.cjs.js');
|
|
13
13
|
var catalogModel = require('@backstage/catalog-model');
|
|
14
14
|
var z = require('zod');
|
|
15
15
|
var integration = require('@backstage/integration');
|
|
@@ -24,7 +24,7 @@ require('child_process');
|
|
|
24
24
|
require('@backstage/errors');
|
|
25
25
|
require('@backstage/config-loader');
|
|
26
26
|
require('@backstage/config');
|
|
27
|
-
require('./index-
|
|
27
|
+
require('./index-CS6xQRSZ.cjs.js');
|
|
28
28
|
require('commander');
|
|
29
29
|
require('semver');
|
|
30
30
|
require('@manypkg/get-packages');
|
|
@@ -341,6 +341,7 @@ const getConfig = ({
|
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
343
|
const github = async (providerAnswers) => {
|
|
344
|
+
var _a, _b, _c;
|
|
344
345
|
const answers = await inquirer__default.default.prompt([
|
|
345
346
|
{
|
|
346
347
|
type: "confirm",
|
|
@@ -360,12 +361,12 @@ const github = async (providerAnswers) => {
|
|
|
360
361
|
name: "apiBaseUrl",
|
|
361
362
|
message: "What is your GitHub Enterprise API path?",
|
|
362
363
|
default: "/api/v3",
|
|
363
|
-
when: ({ hasEnterprise }) => hasEnterprise || providerAnswers
|
|
364
|
+
when: ({ hasEnterprise }) => hasEnterprise || (providerAnswers == null ? void 0 : providerAnswers.hasEnterprise)
|
|
364
365
|
// TODO(tudi2d): Fetch API using OAuth Token if Auth was set up
|
|
365
366
|
}
|
|
366
367
|
]);
|
|
367
368
|
const host = new URL(
|
|
368
|
-
providerAnswers
|
|
369
|
+
(_b = (_a = providerAnswers == null ? void 0 : providerAnswers.enterpriseInstanceUrl) != null ? _a : answers == null ? void 0 : answers.enterpriseInstanceUrl) != null ? _b : "http://github.com"
|
|
369
370
|
);
|
|
370
371
|
tasks.Task.log(`
|
|
371
372
|
To create new repositories in GitHub using Software Templates you first need to create a personal access token: ${chalk__default.default.blue(
|
|
@@ -400,7 +401,7 @@ const github = async (providerAnswers) => {
|
|
|
400
401
|
}
|
|
401
402
|
]);
|
|
402
403
|
const config = getConfig({
|
|
403
|
-
hasEnterprise: providerAnswers
|
|
404
|
+
hasEnterprise: (_c = providerAnswers == null ? void 0 : providerAnswers.hasEnterprise) != null ? _c : answers.hasEnterprise,
|
|
404
405
|
apiBaseUrl: host.origin + answers.apiBaseUrl,
|
|
405
406
|
host: host.hostname,
|
|
406
407
|
token
|
|
@@ -419,8 +420,8 @@ async function integrations(providerInfo) {
|
|
|
419
420
|
{
|
|
420
421
|
type: "confirm",
|
|
421
422
|
name: "shouldUsePreviousProvider",
|
|
422
|
-
message: `Do you want to keep using ${providerInfo
|
|
423
|
-
when: () => providerInfo
|
|
423
|
+
message: `Do you want to keep using ${providerInfo == null ? void 0 : providerInfo.provider} as your provider when setting up Software Templates?`,
|
|
424
|
+
when: () => (providerInfo == null ? void 0 : providerInfo.provider) && Object.values(Integrations).includes(
|
|
424
425
|
providerInfo.provider
|
|
425
426
|
)
|
|
426
427
|
},
|
|
@@ -438,7 +439,7 @@ async function integrations(providerInfo) {
|
|
|
438
439
|
}
|
|
439
440
|
switch (answers.integration) {
|
|
440
441
|
case "GitHub" /* GITHUB */: {
|
|
441
|
-
const providerAnswers = providerInfo
|
|
442
|
+
const providerAnswers = (providerInfo == null ? void 0 : providerInfo.provider) === "GitHub" ? providerInfo.answers : void 0;
|
|
442
443
|
await github(providerAnswers);
|
|
443
444
|
break;
|
|
444
445
|
}
|
|
@@ -448,29 +449,62 @@ async function integrations(providerInfo) {
|
|
|
448
449
|
tasks.Task.log();
|
|
449
450
|
}
|
|
450
451
|
|
|
452
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
453
|
+
if (!member.has(obj))
|
|
454
|
+
throw TypeError("Cannot " + msg);
|
|
455
|
+
};
|
|
456
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
457
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
458
|
+
return member.get(obj);
|
|
459
|
+
};
|
|
460
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
461
|
+
if (member.has(obj))
|
|
462
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
463
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
464
|
+
};
|
|
465
|
+
var _outputs;
|
|
451
466
|
class DefaultAnalysisOutputs {
|
|
452
|
-
|
|
467
|
+
constructor() {
|
|
468
|
+
__privateAdd$7(this, _outputs, /* @__PURE__ */ new Map());
|
|
469
|
+
}
|
|
453
470
|
produce(output) {
|
|
454
|
-
this
|
|
471
|
+
__privateGet$6(this, _outputs).set(output.entity.metadata.name, output);
|
|
455
472
|
}
|
|
456
473
|
list() {
|
|
457
|
-
return Array.from(this
|
|
474
|
+
return Array.from(__privateGet$6(this, _outputs)).map(([_, output]) => output);
|
|
458
475
|
}
|
|
459
476
|
}
|
|
477
|
+
_outputs = new WeakMap();
|
|
460
478
|
|
|
479
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
480
|
+
if (!member.has(obj))
|
|
481
|
+
throw TypeError("Cannot " + msg);
|
|
482
|
+
};
|
|
483
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
484
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
485
|
+
return member.get(obj);
|
|
486
|
+
};
|
|
487
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
488
|
+
if (member.has(obj))
|
|
489
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
490
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
491
|
+
};
|
|
492
|
+
var _providers, _analyzers;
|
|
461
493
|
class Discovery {
|
|
462
|
-
|
|
463
|
-
|
|
494
|
+
constructor() {
|
|
495
|
+
__privateAdd$6(this, _providers, []);
|
|
496
|
+
__privateAdd$6(this, _analyzers, []);
|
|
497
|
+
}
|
|
464
498
|
addProvider(provider) {
|
|
465
|
-
this
|
|
499
|
+
__privateGet$5(this, _providers).push(provider);
|
|
466
500
|
}
|
|
467
501
|
addAnalyzer(analyzer) {
|
|
468
|
-
this
|
|
502
|
+
__privateGet$5(this, _analyzers).push(analyzer);
|
|
469
503
|
}
|
|
470
504
|
async run(url) {
|
|
471
505
|
tasks.Task.log(`Running discovery for ${chalk__default.default.cyan(url)}`);
|
|
472
506
|
const result = [];
|
|
473
|
-
for (const provider of this
|
|
507
|
+
for (const provider of __privateGet$5(this, _providers)) {
|
|
474
508
|
const repositories = await provider.discover(url);
|
|
475
509
|
if (repositories && repositories.length) {
|
|
476
510
|
tasks.Task.log(
|
|
@@ -481,7 +515,7 @@ class Discovery {
|
|
|
481
515
|
for (const repository of repositories) {
|
|
482
516
|
await tasks.Task.forItem("Analyzing", repository.name, async () => {
|
|
483
517
|
const output = new DefaultAnalysisOutputs();
|
|
484
|
-
for (const analyzer of this
|
|
518
|
+
for (const analyzer of __privateGet$5(this, _analyzers)) {
|
|
485
519
|
await analyzer.analyzeRepository({ repository, output });
|
|
486
520
|
}
|
|
487
521
|
output.list().filter((entry) => entry.type === "entity").forEach(({ entity }) => result.push(entity));
|
|
@@ -495,6 +529,8 @@ class Discovery {
|
|
|
495
529
|
};
|
|
496
530
|
}
|
|
497
531
|
}
|
|
532
|
+
_providers = new WeakMap();
|
|
533
|
+
_analyzers = new WeakMap();
|
|
498
534
|
|
|
499
535
|
class BasicRepositoryAnalyzer {
|
|
500
536
|
name() {
|
|
@@ -527,6 +563,7 @@ class PackageJsonAnalyzer {
|
|
|
527
563
|
return PackageJsonAnalyzer.name;
|
|
528
564
|
}
|
|
529
565
|
async analyzeRepository(options) {
|
|
566
|
+
var _a, _b;
|
|
530
567
|
const packageJson = await options.repository.file("package.json");
|
|
531
568
|
if (!packageJson) {
|
|
532
569
|
return;
|
|
@@ -535,7 +572,7 @@ class PackageJsonAnalyzer {
|
|
|
535
572
|
if (!content) {
|
|
536
573
|
return;
|
|
537
574
|
}
|
|
538
|
-
const name = sanitizeName(content
|
|
575
|
+
const name = (_a = sanitizeName(content == null ? void 0 : content.name)) != null ? _a : options.repository.name;
|
|
539
576
|
const entity = {
|
|
540
577
|
apiVersion: "backstage.io/v1alpha1",
|
|
541
578
|
kind: "Component",
|
|
@@ -560,7 +597,7 @@ class PackageJsonAnalyzer {
|
|
|
560
597
|
type: "website"
|
|
561
598
|
};
|
|
562
599
|
decorate.entity.metadata.tags = [
|
|
563
|
-
...decorate.entity.metadata.tags
|
|
600
|
+
...(_b = decorate.entity.metadata.tags) != null ? _b : [],
|
|
564
601
|
"javascript"
|
|
565
602
|
];
|
|
566
603
|
decorate.entity.metadata.annotations = {
|
|
@@ -595,51 +632,103 @@ async function readPackageJson(file) {
|
|
|
595
632
|
}
|
|
596
633
|
}
|
|
597
634
|
|
|
635
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
636
|
+
if (!member.has(obj))
|
|
637
|
+
throw TypeError("Cannot " + msg);
|
|
638
|
+
};
|
|
639
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
640
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
641
|
+
return member.get(obj);
|
|
642
|
+
};
|
|
643
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
644
|
+
if (member.has(obj))
|
|
645
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
646
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
647
|
+
};
|
|
648
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
649
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
650
|
+
member.set(obj, value);
|
|
651
|
+
return value;
|
|
652
|
+
};
|
|
653
|
+
var _path$1, _content$1;
|
|
598
654
|
class GithubFile {
|
|
599
|
-
#path;
|
|
600
|
-
#content;
|
|
601
655
|
constructor(path, content) {
|
|
602
|
-
this
|
|
603
|
-
this
|
|
656
|
+
__privateAdd$5(this, _path$1, void 0);
|
|
657
|
+
__privateAdd$5(this, _content$1, void 0);
|
|
658
|
+
__privateSet$4(this, _path$1, path);
|
|
659
|
+
__privateSet$4(this, _content$1, content);
|
|
604
660
|
}
|
|
605
661
|
get path() {
|
|
606
|
-
return this
|
|
662
|
+
return __privateGet$4(this, _path$1);
|
|
607
663
|
}
|
|
608
664
|
async text() {
|
|
609
|
-
return this
|
|
665
|
+
return __privateGet$4(this, _content$1);
|
|
610
666
|
}
|
|
611
667
|
}
|
|
668
|
+
_path$1 = new WeakMap();
|
|
669
|
+
_content$1 = new WeakMap();
|
|
612
670
|
|
|
671
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
672
|
+
if (!member.has(obj))
|
|
673
|
+
throw TypeError("Cannot " + msg);
|
|
674
|
+
};
|
|
675
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
676
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
677
|
+
return member.get(obj);
|
|
678
|
+
};
|
|
679
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
680
|
+
if (member.has(obj))
|
|
681
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
682
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
683
|
+
};
|
|
684
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
685
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
686
|
+
member.set(obj, value);
|
|
687
|
+
return value;
|
|
688
|
+
};
|
|
689
|
+
var __privateMethod$3 = (obj, member, method) => {
|
|
690
|
+
__accessCheck$4(obj, member, "access private method");
|
|
691
|
+
return method;
|
|
692
|
+
};
|
|
693
|
+
var _client, _repo, _org, _getFileContent$1, getFileContent_fn$1;
|
|
613
694
|
class GithubRepository {
|
|
614
|
-
#client;
|
|
615
|
-
#repo;
|
|
616
|
-
#org;
|
|
617
695
|
constructor(client, repo, org) {
|
|
618
|
-
this
|
|
619
|
-
this
|
|
620
|
-
this
|
|
696
|
+
__privateAdd$4(this, _getFileContent$1);
|
|
697
|
+
__privateAdd$4(this, _client, void 0);
|
|
698
|
+
__privateAdd$4(this, _repo, void 0);
|
|
699
|
+
__privateAdd$4(this, _org, void 0);
|
|
700
|
+
__privateSet$3(this, _client, client);
|
|
701
|
+
__privateSet$3(this, _repo, repo);
|
|
702
|
+
__privateSet$3(this, _org, org);
|
|
621
703
|
}
|
|
622
704
|
get url() {
|
|
623
|
-
return this
|
|
705
|
+
return __privateGet$3(this, _repo).url;
|
|
624
706
|
}
|
|
625
707
|
get name() {
|
|
626
|
-
return this
|
|
708
|
+
return __privateGet$3(this, _repo).name;
|
|
627
709
|
}
|
|
628
710
|
get owner() {
|
|
629
|
-
return this
|
|
711
|
+
return __privateGet$3(this, _org);
|
|
630
712
|
}
|
|
631
713
|
get description() {
|
|
632
|
-
|
|
714
|
+
var _a;
|
|
715
|
+
return (_a = __privateGet$3(this, _repo).description) != null ? _a : void 0;
|
|
633
716
|
}
|
|
634
717
|
async file(filename) {
|
|
635
|
-
|
|
718
|
+
var _a;
|
|
719
|
+
const content = await __privateMethod$3(this, _getFileContent$1, getFileContent_fn$1).call(this, filename);
|
|
636
720
|
if (!content || content.isBinary || !content.text) {
|
|
637
721
|
return void 0;
|
|
638
722
|
}
|
|
639
|
-
return new GithubFile(filename, content.text
|
|
723
|
+
return new GithubFile(filename, (_a = content.text) != null ? _a : "");
|
|
640
724
|
}
|
|
641
|
-
|
|
642
|
-
|
|
725
|
+
}
|
|
726
|
+
_client = new WeakMap();
|
|
727
|
+
_repo = new WeakMap();
|
|
728
|
+
_org = new WeakMap();
|
|
729
|
+
_getFileContent$1 = new WeakSet();
|
|
730
|
+
getFileContent_fn$1 = async function(filename) {
|
|
731
|
+
const query = `query RepoFiles($owner: String!, $name: String!, $expr: String!) {
|
|
643
732
|
repository(owner: $owner, name: $name) {
|
|
644
733
|
object(expression: $expr) {
|
|
645
734
|
...on Blob {
|
|
@@ -649,37 +738,58 @@ class GithubRepository {
|
|
|
649
738
|
}
|
|
650
739
|
}
|
|
651
740
|
}`;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
);
|
|
660
|
-
return response.repository.object;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
741
|
+
const response = await __privateGet$3(this, _client).call(this, query, {
|
|
742
|
+
name: __privateGet$3(this, _repo).name,
|
|
743
|
+
owner: __privateGet$3(this, _org),
|
|
744
|
+
expr: `HEAD:${filename}`
|
|
745
|
+
});
|
|
746
|
+
return response.repository.object;
|
|
747
|
+
};
|
|
663
748
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
749
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
750
|
+
if (!member.has(obj))
|
|
751
|
+
throw TypeError("Cannot " + msg);
|
|
752
|
+
};
|
|
753
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
754
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
755
|
+
return member.get(obj);
|
|
756
|
+
};
|
|
757
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
758
|
+
if (member.has(obj))
|
|
759
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
760
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
761
|
+
};
|
|
762
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
763
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
764
|
+
member.set(obj, value);
|
|
765
|
+
return value;
|
|
766
|
+
};
|
|
767
|
+
var __privateMethod$2 = (obj, member, method) => {
|
|
768
|
+
__accessCheck$3(obj, member, "access private method");
|
|
769
|
+
return method;
|
|
770
|
+
};
|
|
771
|
+
var _envToken$1, _scmIntegrations$1, _credentialsProvider$1, _getRequestHeaders$1, getRequestHeaders_fn$1, _getOrganizationRepositories, getOrganizationRepositories_fn;
|
|
772
|
+
const _GithubDiscoveryProvider = class _GithubDiscoveryProvider {
|
|
773
|
+
constructor(envToken, integrations, credentialsProvider) {
|
|
774
|
+
__privateAdd$3(this, _getRequestHeaders$1);
|
|
775
|
+
__privateAdd$3(this, _getOrganizationRepositories);
|
|
776
|
+
__privateAdd$3(this, _envToken$1, void 0);
|
|
777
|
+
__privateAdd$3(this, _scmIntegrations$1, void 0);
|
|
778
|
+
__privateAdd$3(this, _credentialsProvider$1, void 0);
|
|
779
|
+
__privateSet$2(this, _envToken$1, envToken);
|
|
780
|
+
__privateSet$2(this, _scmIntegrations$1, integrations);
|
|
781
|
+
__privateSet$2(this, _credentialsProvider$1, credentialsProvider);
|
|
782
|
+
}
|
|
668
783
|
static fromConfig(config) {
|
|
669
784
|
const envToken = process.env.GITHUB_TOKEN || void 0;
|
|
670
785
|
const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
671
786
|
const credentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(scmIntegrations);
|
|
672
|
-
return new
|
|
787
|
+
return new _GithubDiscoveryProvider(
|
|
673
788
|
envToken,
|
|
674
789
|
scmIntegrations,
|
|
675
790
|
credentialsProvider
|
|
676
791
|
);
|
|
677
792
|
}
|
|
678
|
-
constructor(envToken, integrations, credentialsProvider) {
|
|
679
|
-
this.#envToken = envToken;
|
|
680
|
-
this.#scmIntegrations = integrations;
|
|
681
|
-
this.#credentialsProvider = credentialsProvider;
|
|
682
|
-
}
|
|
683
793
|
name() {
|
|
684
794
|
return "GitHub";
|
|
685
795
|
}
|
|
@@ -687,7 +797,7 @@ class GithubDiscoveryProvider {
|
|
|
687
797
|
if (!url.startsWith("https://github.com/")) {
|
|
688
798
|
return false;
|
|
689
799
|
}
|
|
690
|
-
const scmIntegration = this
|
|
800
|
+
const scmIntegration = __privateGet$2(this, _scmIntegrations$1).github.byUrl(url);
|
|
691
801
|
if (!scmIntegration) {
|
|
692
802
|
throw new Error(`No GitHub integration found for ${url}`);
|
|
693
803
|
}
|
|
@@ -696,32 +806,36 @@ class GithubDiscoveryProvider {
|
|
|
696
806
|
const org = organization || name;
|
|
697
807
|
const client = graphql.graphql.defaults({
|
|
698
808
|
baseUrl: scmIntegration.config.apiBaseUrl,
|
|
699
|
-
headers: await this
|
|
809
|
+
headers: await __privateMethod$2(this, _getRequestHeaders$1, getRequestHeaders_fn$1).call(this, url)
|
|
700
810
|
});
|
|
701
|
-
const { repositories } = await this
|
|
702
|
-
client,
|
|
703
|
-
org
|
|
704
|
-
);
|
|
811
|
+
const { repositories } = await __privateMethod$2(this, _getOrganizationRepositories, getOrganizationRepositories_fn).call(this, client, org);
|
|
705
812
|
return repositories.filter((repo) => repo.url.startsWith(url)).map((repo) => new GithubRepository(client, repo, org));
|
|
706
813
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
"No token available for GitHub, please configure your integrations or set a GITHUB_TOKEN env variable"
|
|
721
|
-
);
|
|
814
|
+
};
|
|
815
|
+
_envToken$1 = new WeakMap();
|
|
816
|
+
_scmIntegrations$1 = new WeakMap();
|
|
817
|
+
_credentialsProvider$1 = new WeakMap();
|
|
818
|
+
_getRequestHeaders$1 = new WeakSet();
|
|
819
|
+
getRequestHeaders_fn$1 = async function(url) {
|
|
820
|
+
const credentials = await __privateGet$2(this, _credentialsProvider$1).getCredentials({
|
|
821
|
+
url
|
|
822
|
+
});
|
|
823
|
+
if (credentials.headers) {
|
|
824
|
+
return credentials.headers;
|
|
825
|
+
} else if (credentials.token) {
|
|
826
|
+
return { authorization: `token ${credentials.token}` };
|
|
722
827
|
}
|
|
723
|
-
|
|
724
|
-
|
|
828
|
+
if (__privateGet$2(this, _envToken$1)) {
|
|
829
|
+
return { authorization: `token ${__privateGet$2(this, _envToken$1)}` };
|
|
830
|
+
}
|
|
831
|
+
throw new Error(
|
|
832
|
+
"No token available for GitHub, please configure your integrations or set a GITHUB_TOKEN env variable"
|
|
833
|
+
);
|
|
834
|
+
};
|
|
835
|
+
_getOrganizationRepositories = new WeakSet();
|
|
836
|
+
getOrganizationRepositories_fn = async function(client, org) {
|
|
837
|
+
var _a, _b;
|
|
838
|
+
const query = `query repositories($org: String!, $cursor: String) {
|
|
725
839
|
repositoryOwner(login: $org) {
|
|
726
840
|
login
|
|
727
841
|
repositories(first: 50, after: $cursor) {
|
|
@@ -739,52 +853,89 @@ class GithubDiscoveryProvider {
|
|
|
739
853
|
}
|
|
740
854
|
}
|
|
741
855
|
}`;
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
856
|
+
const result = [];
|
|
857
|
+
let cursor = void 0;
|
|
858
|
+
let hasNextPage = true;
|
|
859
|
+
while (hasNextPage) {
|
|
860
|
+
const response = await client(query, {
|
|
861
|
+
org,
|
|
862
|
+
cursor
|
|
863
|
+
});
|
|
864
|
+
const { repositories: connection } = (_a = response.repositoryOwner) != null ? _a : {};
|
|
865
|
+
if (!connection) {
|
|
866
|
+
throw new Error(`Found no repositories for ${org}`);
|
|
867
|
+
}
|
|
868
|
+
for (const repository of (_b = connection.nodes) != null ? _b : []) {
|
|
869
|
+
if (repository && !repository.isArchived && !repository.isFork) {
|
|
870
|
+
result.push(repository);
|
|
758
871
|
}
|
|
759
|
-
cursor = connection.pageInfo.endCursor;
|
|
760
|
-
hasNextPage = connection.pageInfo.hasNextPage;
|
|
761
872
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
};
|
|
873
|
+
cursor = connection.pageInfo.endCursor;
|
|
874
|
+
hasNextPage = connection.pageInfo.hasNextPage;
|
|
765
875
|
}
|
|
766
|
-
|
|
876
|
+
return {
|
|
877
|
+
repositories: result
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
let GithubDiscoveryProvider = _GithubDiscoveryProvider;
|
|
767
881
|
|
|
882
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
883
|
+
if (!member.has(obj))
|
|
884
|
+
throw TypeError("Cannot " + msg);
|
|
885
|
+
};
|
|
886
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
887
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
888
|
+
return member.get(obj);
|
|
889
|
+
};
|
|
890
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
891
|
+
if (member.has(obj))
|
|
892
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
893
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
894
|
+
};
|
|
895
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
896
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
897
|
+
member.set(obj, value);
|
|
898
|
+
return value;
|
|
899
|
+
};
|
|
900
|
+
var _path, _content;
|
|
768
901
|
class GitlabFile {
|
|
769
|
-
#path;
|
|
770
|
-
#content;
|
|
771
902
|
constructor(path, content) {
|
|
772
|
-
this
|
|
773
|
-
this
|
|
903
|
+
__privateAdd$2(this, _path, void 0);
|
|
904
|
+
__privateAdd$2(this, _content, void 0);
|
|
905
|
+
__privateSet$1(this, _path, path);
|
|
906
|
+
__privateSet$1(this, _content, content);
|
|
774
907
|
}
|
|
775
908
|
get path() {
|
|
776
|
-
return this
|
|
909
|
+
return __privateGet$1(this, _path);
|
|
777
910
|
}
|
|
778
911
|
async text() {
|
|
779
|
-
return this
|
|
912
|
+
return __privateGet$1(this, _content);
|
|
780
913
|
}
|
|
781
914
|
}
|
|
915
|
+
_path = new WeakMap();
|
|
916
|
+
_content = new WeakMap();
|
|
782
917
|
|
|
918
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
919
|
+
if (!member.has(obj))
|
|
920
|
+
throw TypeError("Cannot " + msg);
|
|
921
|
+
};
|
|
922
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
923
|
+
if (member.has(obj))
|
|
924
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
925
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
926
|
+
};
|
|
927
|
+
var __privateMethod$1 = (obj, member, method) => {
|
|
928
|
+
__accessCheck$1(obj, member, "access private method");
|
|
929
|
+
return method;
|
|
930
|
+
};
|
|
931
|
+
var _getFileContent, getFileContent_fn, _getMainBranch, getMainBranch_fn;
|
|
783
932
|
class GitlabProject {
|
|
784
933
|
constructor(project, apiBaseUrl, headers) {
|
|
785
934
|
this.project = project;
|
|
786
935
|
this.apiBaseUrl = apiBaseUrl;
|
|
787
936
|
this.headers = headers;
|
|
937
|
+
__privateAdd$1(this, _getFileContent);
|
|
938
|
+
__privateAdd$1(this, _getMainBranch);
|
|
788
939
|
}
|
|
789
940
|
get url() {
|
|
790
941
|
return this.project.web_url;
|
|
@@ -799,58 +950,85 @@ class GitlabProject {
|
|
|
799
950
|
return this.project.description;
|
|
800
951
|
}
|
|
801
952
|
async file(filename) {
|
|
802
|
-
const mainBranch = await this
|
|
803
|
-
const content = await this
|
|
953
|
+
const mainBranch = await __privateMethod$1(this, _getMainBranch, getMainBranch_fn).call(this);
|
|
954
|
+
const content = await __privateMethod$1(this, _getFileContent, getFileContent_fn).call(this, filename, mainBranch);
|
|
804
955
|
return new GitlabFile(filename, content);
|
|
805
956
|
}
|
|
806
|
-
async #getFileContent(path, mainBranch) {
|
|
807
|
-
const response = await fetch__default.default(
|
|
808
|
-
`${this.apiBaseUrl}/projects/${this.project.id}/repository/files/${path}?ref=${mainBranch}`,
|
|
809
|
-
{ headers: this.headers }
|
|
810
|
-
);
|
|
811
|
-
const { content } = await response.json();
|
|
812
|
-
return Buffer.from(content, "base64").toString("ascii");
|
|
813
|
-
}
|
|
814
|
-
async #getMainBranch() {
|
|
815
|
-
const response = await fetch__default.default(
|
|
816
|
-
`${this.apiBaseUrl}/projects/${this.project.id}/repository/branches`,
|
|
817
|
-
{ headers: this.headers }
|
|
818
|
-
);
|
|
819
|
-
const branches = await response.json();
|
|
820
|
-
return branches.find((branch) => branch.default)?.name ?? "main";
|
|
821
|
-
}
|
|
822
957
|
}
|
|
958
|
+
_getFileContent = new WeakSet();
|
|
959
|
+
getFileContent_fn = async function(path, mainBranch) {
|
|
960
|
+
const response = await fetch__default.default(
|
|
961
|
+
`${this.apiBaseUrl}/projects/${this.project.id}/repository/files/${path}?ref=${mainBranch}`,
|
|
962
|
+
{ headers: this.headers }
|
|
963
|
+
);
|
|
964
|
+
const { content } = await response.json();
|
|
965
|
+
return Buffer.from(content, "base64").toString("ascii");
|
|
966
|
+
};
|
|
967
|
+
_getMainBranch = new WeakSet();
|
|
968
|
+
getMainBranch_fn = async function() {
|
|
969
|
+
var _a, _b;
|
|
970
|
+
const response = await fetch__default.default(
|
|
971
|
+
`${this.apiBaseUrl}/projects/${this.project.id}/repository/branches`,
|
|
972
|
+
{ headers: this.headers }
|
|
973
|
+
);
|
|
974
|
+
const branches = await response.json();
|
|
975
|
+
return (_b = (_a = branches.find((branch) => branch.default)) == null ? void 0 : _a.name) != null ? _b : "main";
|
|
976
|
+
};
|
|
823
977
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
978
|
+
var __accessCheck = (obj, member, msg) => {
|
|
979
|
+
if (!member.has(obj))
|
|
980
|
+
throw TypeError("Cannot " + msg);
|
|
981
|
+
};
|
|
982
|
+
var __privateGet = (obj, member, getter) => {
|
|
983
|
+
__accessCheck(obj, member, "read from private field");
|
|
984
|
+
return member.get(obj);
|
|
985
|
+
};
|
|
986
|
+
var __privateAdd = (obj, member, value) => {
|
|
987
|
+
if (member.has(obj))
|
|
988
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
989
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
990
|
+
};
|
|
991
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
992
|
+
__accessCheck(obj, member, "write to private field");
|
|
993
|
+
member.set(obj, value);
|
|
994
|
+
return value;
|
|
995
|
+
};
|
|
996
|
+
var __privateMethod = (obj, member, method) => {
|
|
997
|
+
__accessCheck(obj, member, "access private method");
|
|
998
|
+
return method;
|
|
999
|
+
};
|
|
1000
|
+
var _envToken, _scmIntegrations, _credentialsProvider, _getRequestHeaders, getRequestHeaders_fn;
|
|
1001
|
+
const _GitlabDiscoveryProvider = class _GitlabDiscoveryProvider {
|
|
1002
|
+
constructor(envToken, integrations, credentialsProvider) {
|
|
1003
|
+
__privateAdd(this, _getRequestHeaders);
|
|
1004
|
+
__privateAdd(this, _envToken, void 0);
|
|
1005
|
+
__privateAdd(this, _scmIntegrations, void 0);
|
|
1006
|
+
__privateAdd(this, _credentialsProvider, void 0);
|
|
1007
|
+
__privateSet(this, _envToken, envToken);
|
|
1008
|
+
__privateSet(this, _scmIntegrations, integrations);
|
|
1009
|
+
__privateSet(this, _credentialsProvider, credentialsProvider);
|
|
1010
|
+
}
|
|
828
1011
|
static fromConfig(config) {
|
|
829
1012
|
const envToken = process.env.GITLAB_TOKEN || void 0;
|
|
830
1013
|
const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
831
1014
|
const credentialsProvider = integration.DefaultGitlabCredentialsProvider.fromIntegrations(scmIntegrations);
|
|
832
|
-
return new
|
|
1015
|
+
return new _GitlabDiscoveryProvider(
|
|
833
1016
|
envToken,
|
|
834
1017
|
scmIntegrations,
|
|
835
1018
|
credentialsProvider
|
|
836
1019
|
);
|
|
837
1020
|
}
|
|
838
|
-
constructor(envToken, integrations, credentialsProvider) {
|
|
839
|
-
this.#envToken = envToken;
|
|
840
|
-
this.#scmIntegrations = integrations;
|
|
841
|
-
this.#credentialsProvider = credentialsProvider;
|
|
842
|
-
}
|
|
843
1021
|
name() {
|
|
844
1022
|
return "GitLab";
|
|
845
1023
|
}
|
|
846
1024
|
async discover(url) {
|
|
847
1025
|
const { origin, pathname } = new URL(url);
|
|
848
1026
|
const [, user] = pathname.split("/");
|
|
849
|
-
const scmIntegration = this
|
|
1027
|
+
const scmIntegration = __privateGet(this, _scmIntegrations).gitlab.byUrl(origin);
|
|
850
1028
|
if (!scmIntegration) {
|
|
851
1029
|
throw new Error(`No GitLab integration found for ${origin}`);
|
|
852
1030
|
}
|
|
853
|
-
const headers = await this
|
|
1031
|
+
const headers = await __privateMethod(this, _getRequestHeaders, getRequestHeaders_fn).call(this, origin);
|
|
854
1032
|
const response = await fetch__default.default(
|
|
855
1033
|
`${scmIntegration.config.apiBaseUrl}/users/${user}/projects`,
|
|
856
1034
|
{ headers }
|
|
@@ -863,23 +1041,28 @@ class GitlabDiscoveryProvider {
|
|
|
863
1041
|
(project) => new GitlabProject(project, scmIntegration.config.apiBaseUrl, headers)
|
|
864
1042
|
);
|
|
865
1043
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
"No token available for GitLab, please set a GITLAB_TOKEN env variable"
|
|
880
|
-
);
|
|
1044
|
+
};
|
|
1045
|
+
_envToken = new WeakMap();
|
|
1046
|
+
_scmIntegrations = new WeakMap();
|
|
1047
|
+
_credentialsProvider = new WeakMap();
|
|
1048
|
+
_getRequestHeaders = new WeakSet();
|
|
1049
|
+
getRequestHeaders_fn = async function(url) {
|
|
1050
|
+
const credentials = await __privateGet(this, _credentialsProvider).getCredentials({
|
|
1051
|
+
url
|
|
1052
|
+
});
|
|
1053
|
+
if (credentials.headers) {
|
|
1054
|
+
return credentials.headers;
|
|
1055
|
+
} else if (credentials.token) {
|
|
1056
|
+
return { authorization: `Bearer ${credentials.token}` };
|
|
881
1057
|
}
|
|
882
|
-
|
|
1058
|
+
if (__privateGet(this, _envToken)) {
|
|
1059
|
+
return { authorization: `Bearer ${__privateGet(this, _envToken)}` };
|
|
1060
|
+
}
|
|
1061
|
+
throw new Error(
|
|
1062
|
+
"No token available for GitLab, please set a GITLAB_TOKEN env variable"
|
|
1063
|
+
);
|
|
1064
|
+
};
|
|
1065
|
+
let GitlabDiscoveryProvider = _GitlabDiscoveryProvider;
|
|
883
1066
|
|
|
884
1067
|
async function discover(providerInfo) {
|
|
885
1068
|
tasks.Task.log(`
|
|
@@ -905,7 +1088,7 @@ async function discover(providerInfo) {
|
|
|
905
1088
|
name: "provider",
|
|
906
1089
|
message: "Please select which SCM provider you want to use:",
|
|
907
1090
|
choices: ["GitHub", "GitLab"],
|
|
908
|
-
default: providerInfo
|
|
1091
|
+
default: providerInfo == null ? void 0 : providerInfo.provider,
|
|
909
1092
|
when: ({ shouldContinue }) => shouldContinue
|
|
910
1093
|
},
|
|
911
1094
|
{
|
|
@@ -1024,4 +1207,4 @@ async function command() {
|
|
|
1024
1207
|
}
|
|
1025
1208
|
|
|
1026
1209
|
exports.command = command;
|
|
1027
|
-
//# sourceMappingURL=index-
|
|
1210
|
+
//# sourceMappingURL=index-BWsdQbfr.cjs.js.map
|