@backstage/cli 0.26.5-next.1 → 0.26.6-next.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +38 -6
  2. package/dist/cjs/{Lockfile-C7rtIlD6.cjs.js → Lockfile-BGMdDb8M.cjs.js} +54 -21
  3. package/dist/cjs/{build-D66oGHOO.cjs.js → build-oOoA6doT.cjs.js} +14 -17
  4. package/dist/cjs/{buildBackend-we2Ba62t.cjs.js → buildBackend-DCTPybGH.cjs.js} +8 -10
  5. package/dist/cjs/{buildWorkspace-C6qBqMwe.cjs.js → buildWorkspace-BZ9SFxD1.cjs.js} +5 -5
  6. package/dist/cjs/{bump-5cKD_8oo.cjs.js → bump-DrU2bDOA.cjs.js} +16 -21
  7. package/dist/cjs/{clean-CPw0dNE0.cjs.js → clean-CTXeO6EC.cjs.js} +3 -4
  8. package/dist/cjs/{clean-BsjbtMUW.cjs.js → clean-Xt20-SOd.cjs.js} +2 -2
  9. package/dist/cjs/{codeowners-DvK_j4Tq.cjs.js → codeowners-CmW2AVMp.cjs.js} +2 -2
  10. package/dist/cjs/{config-BuuxVw_w.cjs.js → config-Dr_8wy8K.cjs.js} +3 -4
  11. package/dist/cjs/{createDistWorkspace-DwUb2OGs.cjs.js → createDistWorkspace-DgvlH81m.cjs.js} +15 -25
  12. package/dist/cjs/{createPlugin-DOLMfwjD.cjs.js → createPlugin-DJh1uHOM.cjs.js} +7 -8
  13. package/dist/cjs/{diff-B-i5TSqo.cjs.js → diff-BFT2J47H.cjs.js} +2 -2
  14. package/dist/cjs/{docs-Bpn7hI2X.cjs.js → docs-DPxUZ_5M.cjs.js} +3 -3
  15. package/dist/cjs/{fix-5g9C20X3.cjs.js → fix-Ds21Csn8.cjs.js} +3 -4
  16. package/dist/cjs/{index-fxIvYG3M.cjs.js → index-C9SBzA6q.cjs.js} +38 -44
  17. package/dist/cjs/{index-B_1_hXOx.cjs.js → index-C9SFHBJ7.cjs.js} +160 -343
  18. package/dist/cjs/{index-DncCYByV.cjs.js → index-CIfGsnyl.cjs.js} +30 -63
  19. package/dist/cjs/{index-D_pjpDix.cjs.js → index-D262VPnW.cjs.js} +61 -68
  20. package/dist/cjs/{index-Cjmdbgff.cjs.js → index-zmkgRMEr.cjs.js} +9 -9
  21. package/dist/cjs/{info-BHiDvCg2.cjs.js → info-BJvAN-EV.cjs.js} +5 -6
  22. package/dist/cjs/{install-CK_D5n3K.cjs.js → install-iHbt_0aM.cjs.js} +8 -11
  23. package/dist/cjs/{lint-CNZy4apS.cjs.js → lint-BQoZALVi.cjs.js} +2 -2
  24. package/dist/cjs/{lint-LAlja4Wa.cjs.js → lint-DhdvUtZ-.cjs.js} +4 -4
  25. package/dist/cjs/{lint-B8OIZt3F.cjs.js → lint-ccLOCCQ7.cjs.js} +2 -2
  26. package/dist/cjs/{list-deprecations-DJvZCDiX.cjs.js → list-deprecations-DKQAIdF-.cjs.js} +2 -2
  27. package/dist/cjs/{new-CcqlZCp_.cjs.js → new-pqVZtq0L.cjs.js} +11 -19
  28. package/dist/cjs/{pack-BL0qUp0J.cjs.js → pack-Cb0EFwcV.cjs.js} +3 -3
  29. package/dist/cjs/{packageDetection-zhqJ-m-A.cjs.js → packageDetection-Cfl0g9oD.cjs.js} +15 -21
  30. package/dist/cjs/{packageExports-GUmRFcjL.cjs.js → packageExports-qb2FnJFt.cjs.js} +3 -3
  31. package/dist/cjs/{packageLintConfigs-s5Xf7QSi.cjs.js → packageLintConfigs-CZbCJdAI.cjs.js} +4 -5
  32. package/dist/cjs/{packageRole-D5JpCRDM.cjs.js → packageRole-C_eAxVdS.cjs.js} +2 -2
  33. package/dist/cjs/{packageScripts-CPnlPBBs.cjs.js → packageScripts-DX6dilK6.cjs.js} +10 -11
  34. package/dist/cjs/{packages-CHIGCvQ0.cjs.js → packages-C0iBE8_o.cjs.js} +6 -10
  35. package/dist/cjs/{print-CmGRME-Z.cjs.js → print-DKlinc6o.cjs.js} +3 -3
  36. package/dist/cjs/{productionPack-DotlEIE2.cjs.js → productionPack-BfVQNApa.cjs.js} +4 -6
  37. package/dist/cjs/{reactRouterDeps-BBKc6o07.cjs.js → reactRouterDeps-CR-hjviw.cjs.js} +2 -3
  38. package/dist/cjs/{role-DzCJuRau.cjs.js → role-ji3J4lHr.cjs.js} +3 -4
  39. package/dist/cjs/{run-C1b3EDE9.cjs.js → run-C1016vC-.cjs.js} +3 -4
  40. package/dist/cjs/{schema-C2_ScGGA.cjs.js → schema--27U4Pnd.cjs.js} +3 -3
  41. package/dist/cjs/{tasks-mGXy8WjR.cjs.js → tasks-Dy-6nV0-.cjs.js} +3 -3
  42. package/dist/cjs/{test-DIO_yILs.cjs.js → test-0Q9Uv4gn.cjs.js} +3 -3
  43. package/dist/cjs/{test-ByXbKy71.cjs.js → test-BlJ7hC1z.cjs.js} +3 -3
  44. package/dist/cjs/{validate-Dpae61Um.cjs.js → validate-DrFKUEDH.cjs.js} +3 -3
  45. package/dist/index.cjs.js +1 -1
  46. package/package.json +14 -14
@@ -2,14 +2,14 @@
2
2
 
3
3
  var chalk = require('chalk');
4
4
  var inquirer = require('inquirer');
5
- var tasks = require('./tasks-mGXy8WjR.cjs.js');
5
+ var tasks = require('./tasks-Dy-6nV0-.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-BuuxVw_w.cjs.js');
12
+ var config = require('./config-Dr_8wy8K.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-D_pjpDix.cjs.js');
27
+ require('./index-D262VPnW.cjs.js');
28
28
  require('commander');
29
29
  require('semver');
30
30
  require('@manypkg/get-packages');
@@ -341,7 +341,6 @@ const getConfig = ({
341
341
  }
342
342
  });
343
343
  const github = async (providerAnswers) => {
344
- var _a, _b, _c;
345
344
  const answers = await inquirer__default.default.prompt([
346
345
  {
347
346
  type: "confirm",
@@ -361,12 +360,12 @@ const github = async (providerAnswers) => {
361
360
  name: "apiBaseUrl",
362
361
  message: "What is your GitHub Enterprise API path?",
363
362
  default: "/api/v3",
364
- when: ({ hasEnterprise }) => hasEnterprise || (providerAnswers == null ? void 0 : providerAnswers.hasEnterprise)
363
+ when: ({ hasEnterprise }) => hasEnterprise || providerAnswers?.hasEnterprise
365
364
  // TODO(tudi2d): Fetch API using OAuth Token if Auth was set up
366
365
  }
367
366
  ]);
368
367
  const host = new URL(
369
- (_b = (_a = providerAnswers == null ? void 0 : providerAnswers.enterpriseInstanceUrl) != null ? _a : answers == null ? void 0 : answers.enterpriseInstanceUrl) != null ? _b : "http://github.com"
368
+ providerAnswers?.enterpriseInstanceUrl ?? answers?.enterpriseInstanceUrl ?? "http://github.com"
370
369
  );
371
370
  tasks.Task.log(`
372
371
  To create new repositories in GitHub using Software Templates you first need to create a personal access token: ${chalk__default.default.blue(
@@ -401,7 +400,7 @@ const github = async (providerAnswers) => {
401
400
  }
402
401
  ]);
403
402
  const config = getConfig({
404
- hasEnterprise: (_c = providerAnswers == null ? void 0 : providerAnswers.hasEnterprise) != null ? _c : answers.hasEnterprise,
403
+ hasEnterprise: providerAnswers?.hasEnterprise ?? answers.hasEnterprise,
405
404
  apiBaseUrl: host.origin + answers.apiBaseUrl,
406
405
  host: host.hostname,
407
406
  token
@@ -420,8 +419,8 @@ async function integrations(providerInfo) {
420
419
  {
421
420
  type: "confirm",
422
421
  name: "shouldUsePreviousProvider",
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(
422
+ message: `Do you want to keep using ${providerInfo?.provider} as your provider when setting up Software Templates?`,
423
+ when: () => providerInfo?.provider && Object.values(Integrations).includes(
425
424
  providerInfo.provider
426
425
  )
427
426
  },
@@ -439,7 +438,7 @@ async function integrations(providerInfo) {
439
438
  }
440
439
  switch (answers.integration) {
441
440
  case "GitHub" /* GITHUB */: {
442
- const providerAnswers = (providerInfo == null ? void 0 : providerInfo.provider) === "GitHub" ? providerInfo.answers : void 0;
441
+ const providerAnswers = providerInfo?.provider === "GitHub" ? providerInfo.answers : void 0;
443
442
  await github(providerAnswers);
444
443
  break;
445
444
  }
@@ -449,62 +448,29 @@ async function integrations(providerInfo) {
449
448
  tasks.Task.log();
450
449
  }
451
450
 
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;
466
451
  class DefaultAnalysisOutputs {
467
- constructor() {
468
- __privateAdd$7(this, _outputs, /* @__PURE__ */ new Map());
469
- }
452
+ #outputs = /* @__PURE__ */ new Map();
470
453
  produce(output) {
471
- __privateGet$6(this, _outputs).set(output.entity.metadata.name, output);
454
+ this.#outputs.set(output.entity.metadata.name, output);
472
455
  }
473
456
  list() {
474
- return Array.from(__privateGet$6(this, _outputs)).map(([_, output]) => output);
457
+ return Array.from(this.#outputs).map(([_, output]) => output);
475
458
  }
476
459
  }
477
- _outputs = new WeakMap();
478
460
 
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;
493
461
  class Discovery {
494
- constructor() {
495
- __privateAdd$6(this, _providers, []);
496
- __privateAdd$6(this, _analyzers, []);
497
- }
462
+ #providers = [];
463
+ #analyzers = [];
498
464
  addProvider(provider) {
499
- __privateGet$5(this, _providers).push(provider);
465
+ this.#providers.push(provider);
500
466
  }
501
467
  addAnalyzer(analyzer) {
502
- __privateGet$5(this, _analyzers).push(analyzer);
468
+ this.#analyzers.push(analyzer);
503
469
  }
504
470
  async run(url) {
505
471
  tasks.Task.log(`Running discovery for ${chalk__default.default.cyan(url)}`);
506
472
  const result = [];
507
- for (const provider of __privateGet$5(this, _providers)) {
473
+ for (const provider of this.#providers) {
508
474
  const repositories = await provider.discover(url);
509
475
  if (repositories && repositories.length) {
510
476
  tasks.Task.log(
@@ -515,7 +481,7 @@ class Discovery {
515
481
  for (const repository of repositories) {
516
482
  await tasks.Task.forItem("Analyzing", repository.name, async () => {
517
483
  const output = new DefaultAnalysisOutputs();
518
- for (const analyzer of __privateGet$5(this, _analyzers)) {
484
+ for (const analyzer of this.#analyzers) {
519
485
  await analyzer.analyzeRepository({ repository, output });
520
486
  }
521
487
  output.list().filter((entry) => entry.type === "entity").forEach(({ entity }) => result.push(entity));
@@ -529,8 +495,6 @@ class Discovery {
529
495
  };
530
496
  }
531
497
  }
532
- _providers = new WeakMap();
533
- _analyzers = new WeakMap();
534
498
 
535
499
  class BasicRepositoryAnalyzer {
536
500
  name() {
@@ -563,7 +527,6 @@ class PackageJsonAnalyzer {
563
527
  return PackageJsonAnalyzer.name;
564
528
  }
565
529
  async analyzeRepository(options) {
566
- var _a, _b;
567
530
  const packageJson = await options.repository.file("package.json");
568
531
  if (!packageJson) {
569
532
  return;
@@ -572,7 +535,7 @@ class PackageJsonAnalyzer {
572
535
  if (!content) {
573
536
  return;
574
537
  }
575
- const name = (_a = sanitizeName(content == null ? void 0 : content.name)) != null ? _a : options.repository.name;
538
+ const name = sanitizeName(content?.name) ?? options.repository.name;
576
539
  const entity = {
577
540
  apiVersion: "backstage.io/v1alpha1",
578
541
  kind: "Component",
@@ -597,7 +560,7 @@ class PackageJsonAnalyzer {
597
560
  type: "website"
598
561
  };
599
562
  decorate.entity.metadata.tags = [
600
- ...(_b = decorate.entity.metadata.tags) != null ? _b : [],
563
+ ...decorate.entity.metadata.tags ?? [],
601
564
  "javascript"
602
565
  ];
603
566
  decorate.entity.metadata.annotations = {
@@ -632,103 +595,51 @@ async function readPackageJson(file) {
632
595
  }
633
596
  }
634
597
 
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;
654
598
  class GithubFile {
599
+ #path;
600
+ #content;
655
601
  constructor(path, content) {
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);
602
+ this.#path = path;
603
+ this.#content = content;
660
604
  }
661
605
  get path() {
662
- return __privateGet$4(this, _path$1);
606
+ return this.#path;
663
607
  }
664
608
  async text() {
665
- return __privateGet$4(this, _content$1);
609
+ return this.#content;
666
610
  }
667
611
  }
668
- _path$1 = new WeakMap();
669
- _content$1 = new WeakMap();
670
612
 
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;
694
613
  class GithubRepository {
614
+ #client;
615
+ #repo;
616
+ #org;
695
617
  constructor(client, repo, org) {
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);
618
+ this.#client = client;
619
+ this.#repo = repo;
620
+ this.#org = org;
703
621
  }
704
622
  get url() {
705
- return __privateGet$3(this, _repo).url;
623
+ return this.#repo.url;
706
624
  }
707
625
  get name() {
708
- return __privateGet$3(this, _repo).name;
626
+ return this.#repo.name;
709
627
  }
710
628
  get owner() {
711
- return __privateGet$3(this, _org);
629
+ return this.#org;
712
630
  }
713
631
  get description() {
714
- var _a;
715
- return (_a = __privateGet$3(this, _repo).description) != null ? _a : void 0;
632
+ return this.#repo.description ?? void 0;
716
633
  }
717
634
  async file(filename) {
718
- var _a;
719
- const content = await __privateMethod$3(this, _getFileContent$1, getFileContent_fn$1).call(this, filename);
635
+ const content = await this.#getFileContent(filename);
720
636
  if (!content || content.isBinary || !content.text) {
721
637
  return void 0;
722
638
  }
723
- return new GithubFile(filename, (_a = content.text) != null ? _a : "");
639
+ return new GithubFile(filename, content.text ?? "");
724
640
  }
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!) {
641
+ async #getFileContent(filename) {
642
+ const query = `query RepoFiles($owner: String!, $name: String!, $expr: String!) {
732
643
  repository(owner: $owner, name: $name) {
733
644
  object(expression: $expr) {
734
645
  ...on Blob {
@@ -738,58 +649,37 @@ getFileContent_fn$1 = async function(filename) {
738
649
  }
739
650
  }
740
651
  }`;
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
- };
748
-
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);
652
+ const response = await this.#client(
653
+ query,
654
+ {
655
+ name: this.#repo.name,
656
+ owner: this.#org,
657
+ expr: `HEAD:${filename}`
658
+ }
659
+ );
660
+ return response.repository.object;
782
661
  }
662
+ }
663
+
664
+ class GithubDiscoveryProvider {
665
+ #envToken;
666
+ #scmIntegrations;
667
+ #credentialsProvider;
783
668
  static fromConfig(config) {
784
669
  const envToken = process.env.GITHUB_TOKEN || void 0;
785
670
  const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
786
671
  const credentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(scmIntegrations);
787
- return new _GithubDiscoveryProvider(
672
+ return new GithubDiscoveryProvider(
788
673
  envToken,
789
674
  scmIntegrations,
790
675
  credentialsProvider
791
676
  );
792
677
  }
678
+ constructor(envToken, integrations, credentialsProvider) {
679
+ this.#envToken = envToken;
680
+ this.#scmIntegrations = integrations;
681
+ this.#credentialsProvider = credentialsProvider;
682
+ }
793
683
  name() {
794
684
  return "GitHub";
795
685
  }
@@ -797,7 +687,7 @@ const _GithubDiscoveryProvider = class _GithubDiscoveryProvider {
797
687
  if (!url.startsWith("https://github.com/")) {
798
688
  return false;
799
689
  }
800
- const scmIntegration = __privateGet$2(this, _scmIntegrations$1).github.byUrl(url);
690
+ const scmIntegration = this.#scmIntegrations.github.byUrl(url);
801
691
  if (!scmIntegration) {
802
692
  throw new Error(`No GitHub integration found for ${url}`);
803
693
  }
@@ -806,36 +696,32 @@ const _GithubDiscoveryProvider = class _GithubDiscoveryProvider {
806
696
  const org = organization || name;
807
697
  const client = graphql.graphql.defaults({
808
698
  baseUrl: scmIntegration.config.apiBaseUrl,
809
- headers: await __privateMethod$2(this, _getRequestHeaders$1, getRequestHeaders_fn$1).call(this, url)
699
+ headers: await this.#getRequestHeaders(url)
810
700
  });
811
- const { repositories } = await __privateMethod$2(this, _getOrganizationRepositories, getOrganizationRepositories_fn).call(this, client, org);
701
+ const { repositories } = await this.#getOrganizationRepositories(
702
+ client,
703
+ org
704
+ );
812
705
  return repositories.filter((repo) => repo.url.startsWith(url)).map((repo) => new GithubRepository(client, repo, org));
813
706
  }
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}` };
827
- }
828
- if (__privateGet$2(this, _envToken$1)) {
829
- return { authorization: `token ${__privateGet$2(this, _envToken$1)}` };
707
+ async #getRequestHeaders(url) {
708
+ const credentials = await this.#credentialsProvider.getCredentials({
709
+ url
710
+ });
711
+ if (credentials.headers) {
712
+ return credentials.headers;
713
+ } else if (credentials.token) {
714
+ return { authorization: `token ${credentials.token}` };
715
+ }
716
+ if (this.#envToken) {
717
+ return { authorization: `token ${this.#envToken}` };
718
+ }
719
+ throw new Error(
720
+ "No token available for GitHub, please configure your integrations or set a GITHUB_TOKEN env variable"
721
+ );
830
722
  }
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) {
723
+ async #getOrganizationRepositories(client, org) {
724
+ const query = `query repositories($org: String!, $cursor: String) {
839
725
  repositoryOwner(login: $org) {
840
726
  login
841
727
  repositories(first: 50, after: $cursor) {
@@ -853,89 +739,52 @@ getOrganizationRepositories_fn = async function(client, org) {
853
739
  }
854
740
  }
855
741
  }`;
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);
742
+ const result = [];
743
+ let cursor = void 0;
744
+ let hasNextPage = true;
745
+ while (hasNextPage) {
746
+ const response = await client(query, {
747
+ org,
748
+ cursor
749
+ });
750
+ const { repositories: connection } = response.repositoryOwner ?? {};
751
+ if (!connection) {
752
+ throw new Error(`Found no repositories for ${org}`);
753
+ }
754
+ for (const repository of connection.nodes ?? []) {
755
+ if (repository && !repository.isArchived && !repository.isFork) {
756
+ result.push(repository);
757
+ }
871
758
  }
759
+ cursor = connection.pageInfo.endCursor;
760
+ hasNextPage = connection.pageInfo.hasNextPage;
872
761
  }
873
- cursor = connection.pageInfo.endCursor;
874
- hasNextPage = connection.pageInfo.hasNextPage;
762
+ return {
763
+ repositories: result
764
+ };
875
765
  }
876
- return {
877
- repositories: result
878
- };
879
- };
880
- let GithubDiscoveryProvider = _GithubDiscoveryProvider;
766
+ }
881
767
 
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;
901
768
  class GitlabFile {
769
+ #path;
770
+ #content;
902
771
  constructor(path, content) {
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);
772
+ this.#path = path;
773
+ this.#content = content;
907
774
  }
908
775
  get path() {
909
- return __privateGet$1(this, _path);
776
+ return this.#path;
910
777
  }
911
778
  async text() {
912
- return __privateGet$1(this, _content);
779
+ return this.#content;
913
780
  }
914
781
  }
915
- _path = new WeakMap();
916
- _content = new WeakMap();
917
782
 
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;
932
783
  class GitlabProject {
933
784
  constructor(project, apiBaseUrl, headers) {
934
785
  this.project = project;
935
786
  this.apiBaseUrl = apiBaseUrl;
936
787
  this.headers = headers;
937
- __privateAdd$1(this, _getFileContent);
938
- __privateAdd$1(this, _getMainBranch);
939
788
  }
940
789
  get url() {
941
790
  return this.project.web_url;
@@ -950,85 +799,58 @@ class GitlabProject {
950
799
  return this.project.description;
951
800
  }
952
801
  async file(filename) {
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);
802
+ const mainBranch = await this.#getMainBranch();
803
+ const content = await this.#getFileContent(filename, mainBranch);
955
804
  return new GitlabFile(filename, content);
956
805
  }
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
+ }
957
822
  }
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
- };
977
823
 
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
- }
824
+ class GitlabDiscoveryProvider {
825
+ #envToken;
826
+ #scmIntegrations;
827
+ #credentialsProvider;
1011
828
  static fromConfig(config) {
1012
829
  const envToken = process.env.GITLAB_TOKEN || void 0;
1013
830
  const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
1014
831
  const credentialsProvider = integration.DefaultGitlabCredentialsProvider.fromIntegrations(scmIntegrations);
1015
- return new _GitlabDiscoveryProvider(
832
+ return new GitlabDiscoveryProvider(
1016
833
  envToken,
1017
834
  scmIntegrations,
1018
835
  credentialsProvider
1019
836
  );
1020
837
  }
838
+ constructor(envToken, integrations, credentialsProvider) {
839
+ this.#envToken = envToken;
840
+ this.#scmIntegrations = integrations;
841
+ this.#credentialsProvider = credentialsProvider;
842
+ }
1021
843
  name() {
1022
844
  return "GitLab";
1023
845
  }
1024
846
  async discover(url) {
1025
847
  const { origin, pathname } = new URL(url);
1026
848
  const [, user] = pathname.split("/");
1027
- const scmIntegration = __privateGet(this, _scmIntegrations).gitlab.byUrl(origin);
849
+ const scmIntegration = this.#scmIntegrations.gitlab.byUrl(origin);
1028
850
  if (!scmIntegration) {
1029
851
  throw new Error(`No GitLab integration found for ${origin}`);
1030
852
  }
1031
- const headers = await __privateMethod(this, _getRequestHeaders, getRequestHeaders_fn).call(this, origin);
853
+ const headers = await this.#getRequestHeaders(origin);
1032
854
  const response = await fetch__default.default(
1033
855
  `${scmIntegration.config.apiBaseUrl}/users/${user}/projects`,
1034
856
  { headers }
@@ -1041,28 +863,23 @@ const _GitlabDiscoveryProvider = class _GitlabDiscoveryProvider {
1041
863
  (project) => new GitlabProject(project, scmIntegration.config.apiBaseUrl, headers)
1042
864
  );
1043
865
  }
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}` };
1057
- }
1058
- if (__privateGet(this, _envToken)) {
1059
- return { authorization: `Bearer ${__privateGet(this, _envToken)}` };
866
+ async #getRequestHeaders(url) {
867
+ const credentials = await this.#credentialsProvider.getCredentials({
868
+ url
869
+ });
870
+ if (credentials.headers) {
871
+ return credentials.headers;
872
+ } else if (credentials.token) {
873
+ return { authorization: `Bearer ${credentials.token}` };
874
+ }
875
+ if (this.#envToken) {
876
+ return { authorization: `Bearer ${this.#envToken}` };
877
+ }
878
+ throw new Error(
879
+ "No token available for GitLab, please set a GITLAB_TOKEN env variable"
880
+ );
1060
881
  }
1061
- throw new Error(
1062
- "No token available for GitLab, please set a GITLAB_TOKEN env variable"
1063
- );
1064
- };
1065
- let GitlabDiscoveryProvider = _GitlabDiscoveryProvider;
882
+ }
1066
883
 
1067
884
  async function discover(providerInfo) {
1068
885
  tasks.Task.log(`
@@ -1088,7 +905,7 @@ async function discover(providerInfo) {
1088
905
  name: "provider",
1089
906
  message: "Please select which SCM provider you want to use:",
1090
907
  choices: ["GitHub", "GitLab"],
1091
- default: providerInfo == null ? void 0 : providerInfo.provider,
908
+ default: providerInfo?.provider,
1092
909
  when: ({ shouldContinue }) => shouldContinue
1093
910
  },
1094
911
  {
@@ -1207,4 +1024,4 @@ async function command() {
1207
1024
  }
1208
1025
 
1209
1026
  exports.command = command;
1210
- //# sourceMappingURL=index-B_1_hXOx.cjs.js.map
1027
+ //# sourceMappingURL=index-C9SFHBJ7.cjs.js.map