@firestartr/cli 1.50.1-snapshot-17 → 1.50.1-snapshot-19

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/build/index.js CHANGED
@@ -295737,6 +295737,186 @@ function dist_bundle_paginateRest(octokit) {
295737
295737
  dist_bundle_paginateRest.VERSION = _octokit_plugin_paginate_rest_dist_bundle_VERSION;
295738
295738
 
295739
295739
 
295740
+ ;// CONCATENATED MODULE: ../github/node_modules/@octokit/plugin-paginate-graphql/dist-bundle/index.js
295741
+ // pkg/dist-src/errors.js
295742
+ var generateMessage = (path, cursorValue) => `The cursor at "${path.join(
295743
+ ","
295744
+ )}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`;
295745
+ var MissingCursorChange = class extends Error {
295746
+ constructor(pageInfo, cursorValue) {
295747
+ super(generateMessage(pageInfo.pathInQuery, cursorValue));
295748
+ this.pageInfo = pageInfo;
295749
+ this.cursorValue = cursorValue;
295750
+ if (Error.captureStackTrace) {
295751
+ Error.captureStackTrace(this, this.constructor);
295752
+ }
295753
+ }
295754
+ name = "MissingCursorChangeError";
295755
+ };
295756
+ var MissingPageInfo = class extends Error {
295757
+ constructor(response) {
295758
+ super(
295759
+ `No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
295760
+ response,
295761
+ null,
295762
+ 2
295763
+ )}`
295764
+ );
295765
+ this.response = response;
295766
+ if (Error.captureStackTrace) {
295767
+ Error.captureStackTrace(this, this.constructor);
295768
+ }
295769
+ }
295770
+ name = "MissingPageInfo";
295771
+ };
295772
+
295773
+ // pkg/dist-src/object-helpers.js
295774
+ var isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
295775
+ function findPaginatedResourcePath(responseData) {
295776
+ const paginatedResourcePath = deepFindPathToProperty(
295777
+ responseData,
295778
+ "pageInfo"
295779
+ );
295780
+ if (paginatedResourcePath.length === 0) {
295781
+ throw new MissingPageInfo(responseData);
295782
+ }
295783
+ return paginatedResourcePath;
295784
+ }
295785
+ var deepFindPathToProperty = (object, searchProp, path = []) => {
295786
+ for (const key of Object.keys(object)) {
295787
+ const currentPath = [...path, key];
295788
+ const currentValue = object[key];
295789
+ if (isObject(currentValue)) {
295790
+ if (currentValue.hasOwnProperty(searchProp)) {
295791
+ return currentPath;
295792
+ }
295793
+ const result = deepFindPathToProperty(
295794
+ currentValue,
295795
+ searchProp,
295796
+ currentPath
295797
+ );
295798
+ if (result.length > 0) {
295799
+ return result;
295800
+ }
295801
+ }
295802
+ }
295803
+ return [];
295804
+ };
295805
+ var dist_bundle_get = (object, path) => {
295806
+ return path.reduce((current, nextProperty) => current[nextProperty], object);
295807
+ };
295808
+ var set = (object, path, mutator) => {
295809
+ const lastProperty = path[path.length - 1];
295810
+ const parentPath = [...path].slice(0, -1);
295811
+ const parent = dist_bundle_get(object, parentPath);
295812
+ if (typeof mutator === "function") {
295813
+ parent[lastProperty] = mutator(parent[lastProperty]);
295814
+ } else {
295815
+ parent[lastProperty] = mutator;
295816
+ }
295817
+ };
295818
+
295819
+ // pkg/dist-src/extract-page-info.js
295820
+ var extractPageInfos = (responseData) => {
295821
+ const pageInfoPath = findPaginatedResourcePath(responseData);
295822
+ return {
295823
+ pathInQuery: pageInfoPath,
295824
+ pageInfo: dist_bundle_get(responseData, [...pageInfoPath, "pageInfo"])
295825
+ };
295826
+ };
295827
+
295828
+ // pkg/dist-src/page-info.js
295829
+ var isForwardSearch = (givenPageInfo) => {
295830
+ return givenPageInfo.hasOwnProperty("hasNextPage");
295831
+ };
295832
+ var getCursorFrom = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.endCursor : pageInfo.startCursor;
295833
+ var hasAnotherPage = (pageInfo) => isForwardSearch(pageInfo) ? pageInfo.hasNextPage : pageInfo.hasPreviousPage;
295834
+
295835
+ // pkg/dist-src/iterator.js
295836
+ var createIterator = (octokit) => {
295837
+ return (query, initialParameters = {}) => {
295838
+ let nextPageExists = true;
295839
+ let parameters = { ...initialParameters };
295840
+ return {
295841
+ [Symbol.asyncIterator]: () => ({
295842
+ async next() {
295843
+ if (!nextPageExists) return { done: true, value: {} };
295844
+ const response = await octokit.graphql(
295845
+ query,
295846
+ parameters
295847
+ );
295848
+ const pageInfoContext = extractPageInfos(response);
295849
+ const nextCursorValue = getCursorFrom(pageInfoContext.pageInfo);
295850
+ nextPageExists = hasAnotherPage(pageInfoContext.pageInfo);
295851
+ if (nextPageExists && nextCursorValue === parameters.cursor) {
295852
+ throw new MissingCursorChange(pageInfoContext, nextCursorValue);
295853
+ }
295854
+ parameters = {
295855
+ ...parameters,
295856
+ cursor: nextCursorValue
295857
+ };
295858
+ return { done: false, value: response };
295859
+ }
295860
+ })
295861
+ };
295862
+ };
295863
+ };
295864
+
295865
+ // pkg/dist-src/merge-responses.js
295866
+ var mergeResponses = (response1, response2) => {
295867
+ if (Object.keys(response1).length === 0) {
295868
+ return Object.assign(response1, response2);
295869
+ }
295870
+ const path = findPaginatedResourcePath(response1);
295871
+ const nodesPath = [...path, "nodes"];
295872
+ const newNodes = dist_bundle_get(response2, nodesPath);
295873
+ if (newNodes) {
295874
+ set(response1, nodesPath, (values) => {
295875
+ return [...values, ...newNodes];
295876
+ });
295877
+ }
295878
+ const edgesPath = [...path, "edges"];
295879
+ const newEdges = dist_bundle_get(response2, edgesPath);
295880
+ if (newEdges) {
295881
+ set(response1, edgesPath, (values) => {
295882
+ return [...values, ...newEdges];
295883
+ });
295884
+ }
295885
+ const pageInfoPath = [...path, "pageInfo"];
295886
+ set(response1, pageInfoPath, dist_bundle_get(response2, pageInfoPath));
295887
+ return response1;
295888
+ };
295889
+
295890
+ // pkg/dist-src/paginate.js
295891
+ var createPaginate = (octokit) => {
295892
+ const iterator = createIterator(octokit);
295893
+ return async (query, initialParameters = {}) => {
295894
+ let mergedResponse = {};
295895
+ for await (const response of iterator(
295896
+ query,
295897
+ initialParameters
295898
+ )) {
295899
+ mergedResponse = mergeResponses(mergedResponse, response);
295900
+ }
295901
+ return mergedResponse;
295902
+ };
295903
+ };
295904
+
295905
+ // pkg/dist-src/version.js
295906
+ var plugin_paginate_graphql_dist_bundle_VERSION = "0.0.0-development";
295907
+
295908
+ // pkg/dist-src/index.js
295909
+ function paginateGraphQL(octokit) {
295910
+ return {
295911
+ graphql: Object.assign(octokit.graphql, {
295912
+ paginate: Object.assign(createPaginate(octokit), {
295913
+ iterator: createIterator(octokit)
295914
+ })
295915
+ })
295916
+ };
295917
+ }
295918
+
295919
+
295740
295920
  ;// CONCATENATED MODULE: ../../node_modules/@octokit/oauth-methods/dist-bundle/index.js
295741
295921
  // pkg/dist-src/version.js
295742
295922
  var oauth_methods_dist_bundle_VERSION = "0.0.0-development";
@@ -297624,7 +297804,7 @@ async function dist_node_get(cache, options) {
297624
297804
  repositorySelection
297625
297805
  };
297626
297806
  }
297627
- async function set(cache, options, data) {
297807
+ async function dist_node_set(cache, options, data) {
297628
297808
  const key = optionsToCacheKey(options);
297629
297809
  const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(
297630
297810
  (name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`
@@ -297799,7 +297979,7 @@ async function getInstallationAuthenticationImpl(state, options, request) {
297799
297979
  if (singleFileName) {
297800
297980
  Object.assign(payload, { singleFileName });
297801
297981
  }
297802
- await set(state.cache, options, cacheOptions);
297982
+ await dist_node_set(state.cache, options, cacheOptions);
297803
297983
  const cacheData = {
297804
297984
  installationId: options.installationId,
297805
297985
  token,
@@ -298063,6 +298243,7 @@ async function checkIfInstalledForOrg(org = 'default') {
298063
298243
 
298064
298244
 
298065
298245
 
298246
+
298066
298247
  const generateGithubAppToken = async (config) => {
298067
298248
  try {
298068
298249
  const { appId, privateKey, installationOrgId } = config;
@@ -298108,7 +298289,7 @@ async function getOctokitForOrg(org, paginated = false, genGithubAppToken = gene
298108
298289
  });
298109
298290
  const options = { auth: auth };
298110
298291
  if (paginated) {
298111
- options.plugins = [dist_bundle_paginateRest];
298292
+ options.plugins = [dist_bundle_paginateRest, paginateGraphQL];
298112
298293
  }
298113
298294
  return new dist_src_Octokit(options);
298114
298295
  }
@@ -298175,6 +298356,54 @@ async function getOrgInfo(org) {
298175
298356
  const orgInfo = await octokit.orgs.get({ org });
298176
298357
  return orgInfo.data;
298177
298358
  }
298359
+ async function getOrgTeamsDirectAccess(org) {
298360
+ github_src_logger.info(`Getting teams for org ${org}`);
298361
+ const octokit = await getOctokitForOrg(org);
298362
+ const response = await octokit.graphql(`{
298363
+ organization(login: "${org}") {
298364
+ teams(first: 30) {
298365
+ nodes {
298366
+ id
298367
+ name
298368
+ repositories {
298369
+ edges {
298370
+ permission
298371
+ node {
298372
+ name
298373
+ }
298374
+ }
298375
+ }
298376
+ }
298377
+ }
298378
+ }
298379
+ }`);
298380
+ return transformGraphQLResponse(response);
298381
+ }
298382
+ ;
298383
+ function transformGraphQLResponse(response) {
298384
+ const teams = response?.data?.organization?.teams?.nodes;
298385
+ if (!teams)
298386
+ return {};
298387
+ let result = {
298388
+ repositories: {},
298389
+ teams: {},
298390
+ };
298391
+ teams.forEach((team) => {
298392
+ const teamName = team.name;
298393
+ const teamId = team.id;
298394
+ result.teams[teamName] = { id: teamId };
298395
+ const repositories = team.repositories.edges;
298396
+ repositories.forEach((repoEdge) => {
298397
+ const repoName = repoEdge.node.name;
298398
+ const permission = repoEdge.permission;
298399
+ if (!result.repositories[repoName]) {
298400
+ result.repositories[repoName] = {};
298401
+ }
298402
+ result.repositories[repoName][teamName] = permission;
298403
+ });
298404
+ });
298405
+ return result;
298406
+ }
298178
298407
  async function getOrgPlanName(org) {
298179
298408
  github_src_logger.info(`Getting plan for org ${org}`);
298180
298409
  const orgInfo = await getOrgInfo(org);
@@ -298193,6 +298422,7 @@ async function doPaginatedRequest(options) {
298193
298422
  validateMember,
298194
298423
  getUserRoleInOrg,
298195
298424
  getOrgInfo,
298425
+ getOrgTeamsDirectAccess,
298196
298426
  getOrgPlanName,
298197
298427
  });
298198
298428
 
@@ -309917,9 +310147,10 @@ const TYPE_MAP = {
309917
310147
  Organization: 'org',
309918
310148
  };
309919
310149
  class RepoGithubDecanter extends GithubDecanter {
309920
- constructor() {
309921
- super(...arguments);
310150
+ constructor(data, org, githubTeams = {}) {
310151
+ super(data, org);
309922
310152
  this.claimKind = 'ComponentClaim';
310153
+ this.githubTeams = githubTeams;
309923
310154
  }
309924
310155
  __decantStart() {
309925
310156
  this.claim = {
@@ -309980,6 +310211,8 @@ class RepoGithubDecanter extends GithubDecanter {
309980
310211
  }
309981
310212
  }
309982
310213
  __decantRelations() {
310214
+ importer_src_logger.debug("Decanting repo's relations...");
310215
+ importer_src_logger.debug("Decanting maintainers...");
309983
310216
  const directMaintainers = this.data.teamsAndMembers.directMembers
309984
310217
  .filter((member) => member.role === 'maintain')
309985
310218
  .map((member) => {
@@ -310005,6 +310238,7 @@ class RepoGithubDecanter extends GithubDecanter {
310005
310238
  path: '/maintainedBy',
310006
310239
  });
310007
310240
  }
310241
+ importer_src_logger.debug("Decanting admins...");
310008
310242
  const directAdmins = this.data.teamsAndMembers.directMembers
310009
310243
  .filter((member) => member.role === 'admin')
310010
310244
  .map((member) => {
@@ -310040,6 +310274,7 @@ class RepoGithubDecanter extends GithubDecanter {
310040
310274
  path: '/providers/github/overrides',
310041
310275
  });
310042
310276
  }
310277
+ importer_src_logger.debug("Decanting writers...");
310043
310278
  const directWriters = this.data.teamsAndMembers.directMembers
310044
310279
  .filter((member) => member.role === 'push')
310045
310280
  .map((member) => {
@@ -310064,6 +310299,7 @@ class RepoGithubDecanter extends GithubDecanter {
310064
310299
  path: '/providers/github/overrides',
310065
310300
  });
310066
310301
  }
310302
+ importer_src_logger.debug("Decanting readers...");
310067
310303
  const directReaders = this.data.teamsAndMembers.directMembers
310068
310304
  .filter((member) => member.role === 'pull')
310069
310305
  .map((member) => {
@@ -310097,8 +310333,11 @@ class RepoGithubDecanter extends GithubDecanter {
310097
310333
  const outsideMembers = (await github_0.repo.getCollaborators(this.data.repoDetails.owner.login, this.data.repoDetails.name, 'outside')).map((member) => {
310098
310334
  return { name: member.login, role: member.role_name };
310099
310335
  });
310100
- const teams = (await github_0.repo.getTeams(this.data.repoDetails.owner.login, this.data.repoDetails.name)).map((team) => {
310101
- return { name: team.name, role: team.permission, id: team.id };
310336
+ const teams = Object.keys(this.githubTeams).map((teamName) => {
310337
+ return {
310338
+ name: teamName,
310339
+ role: this.githubTeams[teamName].permission.toLowerCase(),
310340
+ };
310102
310341
  });
310103
310342
  this.data['teamsAndMembers']['teams'] = teams;
310104
310343
  this.data['teamsAndMembers']['directMembers'] = directMembers;
@@ -310247,6 +310486,7 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
310247
310486
  if (this.IS_SKIP_SET(filters, RepoCollectionGithubDecanter.collectionKind)) {
310248
310487
  return [];
310249
310488
  }
310489
+ const { teams, repositories: directAccessRepos } = await this.github.org.getOrgTeamsDirectAccess(this.org);
310250
310490
  let repoList = await this.github.org.getRepositoryList(this.org);
310251
310491
  repoList = repoList.filter((el) => !el.archived);
310252
310492
  const repoMap = {};
@@ -310257,7 +310497,7 @@ class RepoCollectionGithubDecanter extends GithubDecanter {
310257
310497
  const filteredRepos = await this.filter(RepoCollectionGithubDecanter.collectionKind, filters, repoList.map((repo) => repo.name));
310258
310498
  for (const repoName of filteredRepos) {
310259
310499
  const repoInfo = await this.github.repo.getRepoInfo(this.org, repoName);
310260
- repos.push(new RepoGithubDecanter({ repoDetails: repoInfo }, this.org));
310500
+ repos.push(new RepoGithubDecanter({ repoDetails: repoInfo }, this.org, directAccessRepos?.[repoName]));
310261
310501
  }
310262
310502
  this.data['collection'] = repos;
310263
310503
  return repos;
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  validateMember: typeof import("./src/organization").validateMember;
10
10
  getUserRoleInOrg: typeof import("./src/organization").getUserRoleInOrg;
11
11
  getOrgInfo: typeof import("./src/organization").getOrgInfo;
12
+ getOrgTeamsDirectAccess: typeof import("./src/organization").getOrgTeamsDirectAccess;
12
13
  getOrgPlanName: typeof import("./src/organization").getOrgPlanName;
13
14
  };
14
15
  repo: {
@@ -4,6 +4,8 @@ export declare function getUserList(org: string, perPageEntries?: number): Promi
4
4
  export declare function validateMember(username: string, org: string): Promise<any>;
5
5
  export declare function getUserRoleInOrg(username: string, org: string): Promise<"admin" | "member" | "billing_manager">;
6
6
  export declare function getOrgInfo(org: string): Promise<any>;
7
+ export declare function getOrgTeamsDirectAccess(org: string): Promise<any>;
8
+ export declare function transformGraphQLResponse(response: any): any;
7
9
  export declare function getOrgPlanName(org: string): Promise<any>;
8
10
  declare const _default: {
9
11
  getRepositoryList: typeof getRepositoryList;
@@ -12,6 +14,7 @@ declare const _default: {
12
14
  validateMember: typeof validateMember;
13
15
  getUserRoleInOrg: typeof getUserRoleInOrg;
14
16
  getOrgInfo: typeof getOrgInfo;
17
+ getOrgTeamsDirectAccess: typeof getOrgTeamsDirectAccess;
15
18
  getOrgPlanName: typeof getOrgPlanName;
16
19
  };
17
20
  export default _default;
@@ -1,6 +1,8 @@
1
1
  import { BranchStrategiesInitializer, GithubRepositoryOverrider, InitializerDefault } from 'cdk8s_renderer';
2
2
  import { GithubDecanter } from './base';
3
3
  export default class RepoGithubDecanter extends GithubDecanter {
4
+ githubTeams: any;
5
+ constructor(data: any, org: string, githubTeams?: any);
4
6
  claimKind: string;
5
7
  __decantStart(): void;
6
8
  __decantProviders(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.50.1-snapshot-17",
3
+ "version": "1.50.1-snapshot-19",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",