@firestartr/cli 1.43.2-snapshot-5 → 1.43.2-snapshot-7

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
@@ -165787,7 +165787,7 @@ const Comparator = __nccwpck_require__(14435)
165787
165787
  const Range = __nccwpck_require__(34189)
165788
165788
  const satisfies = __nccwpck_require__(74432)
165789
165789
  const toComparators = __nccwpck_require__(90453)
165790
- const maxSatisfying = __nccwpck_require__(49939)
165790
+ const maxSatisfying = __nccwpck_require__(46253)
165791
165791
  const minSatisfying = __nccwpck_require__(59276)
165792
165792
  const minVersion = __nccwpck_require__(97241)
165793
165793
  const validRange = __nccwpck_require__(65493)
@@ -166213,7 +166213,7 @@ module.exports = ltr
166213
166213
 
166214
166214
  /***/ }),
166215
166215
 
166216
- /***/ 49939:
166216
+ /***/ 46253:
166217
166217
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
166218
166218
 
166219
166219
  const SemVer = __nccwpck_require__(87048)
@@ -281289,6 +281289,12 @@ class FirestartrAllClaim {
281289
281289
  type: 'string',
281290
281290
  enum: ['private', 'public', 'internal'],
281291
281291
  },
281292
+ features: {
281293
+ type: 'array',
281294
+ items: {
281295
+ $ref: 'firestartr.dev://github/GithubComponentFeatureClaim',
281296
+ },
281297
+ },
281292
281298
  },
281293
281299
  required: ['visibility', 'org'],
281294
281300
  },
@@ -281349,14 +281355,58 @@ class FirestartrAllClaim {
281349
281355
  },
281350
281356
  });
281351
281357
 
281358
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/feature.schema.ts
281359
+ /* harmony default export */ const feature_schema = ({
281360
+ $schema: 'http://json-schema.org/draft-07/schema#',
281361
+ $id: 'GithubComponentFeatureClaim',
281362
+ definitions: {
281363
+ GithubComponentFeatureClaim: {
281364
+ $id: 'firestartr.dev://github/GithubComponentFeatureClaim',
281365
+ description: 'A feature for a GithubComponentClaim',
281366
+ properties: {
281367
+ name: {
281368
+ type: 'string',
281369
+ description: 'The name of the feature',
281370
+ },
281371
+ version: {
281372
+ type: 'string',
281373
+ description: 'The semver of the feature',
281374
+ },
281375
+ ref: {
281376
+ type: 'string',
281377
+ description: 'A github reference (commit, tag, branch)',
281378
+ pattern: '^[a-zA-Z0-9-._]+/[a-zA-Z0-9-._]+$',
281379
+ },
281380
+ args: {
281381
+ type: 'object',
281382
+ properties: {},
281383
+ additionalProperties: true,
281384
+ },
281385
+ repo: {
281386
+ type: 'string',
281387
+ description: 'A repo where the feature exists, format: owner/repository',
281388
+ },
281389
+ },
281390
+ required: ['name'],
281391
+ oneOf: [
281392
+ { required: ['ref'], not: { required: ['version'] } },
281393
+ { required: ['version'], not: { required: ['ref'] } },
281394
+ ],
281395
+ additionalProperties: false,
281396
+ },
281397
+ },
281398
+ });
281399
+
281352
281400
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/index.ts
281353
281401
 
281354
281402
 
281355
281403
 
281356
281404
 
281405
+
281357
281406
  const GithubSchemas = [
281358
281407
  github_group_schema,
281359
281408
  github_user_schema,
281409
+ feature_schema,
281360
281410
  github_component_schema,
281361
281411
  github_orgwebhook_schema,
281362
281412
  ];
@@ -284110,57 +284160,85 @@ function renderFeature(featureName, version, featureOwner, renderPath = '/tmp',
284110
284160
  // EXTERNAL MODULE: ../../node_modules/adm-zip/adm-zip.js
284111
284161
  var adm_zip = __nccwpck_require__(7993);
284112
284162
  var adm_zip_default = /*#__PURE__*/__nccwpck_require__.n(adm_zip);
284163
+ // EXTERNAL MODULE: external "node:stream"
284164
+ var external_node_stream_ = __nccwpck_require__(84492);
284165
+ ;// CONCATENATED MODULE: ../features_preparer/src/zip.ts
284166
+
284167
+
284168
+ async function downloadZipBall(url, filePath) {
284169
+ try {
284170
+ const zipResponse = await fetch(url);
284171
+ if (!zipResponse.ok) {
284172
+ throw new Error(`Failed to download ZIP: ${zipResponse.statusText}`);
284173
+ }
284174
+ const webStream = zipResponse.body;
284175
+ const stream = external_node_stream_.Readable.fromWeb(webStream);
284176
+ await (0,promises_namespaceObject.writeFile)(filePath, stream);
284177
+ }
284178
+ catch (err) {
284179
+ throw new Error(`Downloading feature's zip: ${err.message}`);
284180
+ }
284181
+ }
284182
+
284113
284183
  ;// CONCATENATED MODULE: ../features_preparer/src/installer.ts
284114
284184
 
284115
284185
 
284116
284186
 
284117
284187
 
284118
284188
 
284119
- //const IS_COMMIT_REF = new RegExp(/\b[0-9a-f]{40}/g);
284120
- const IS_SEMVER_REF = new RegExp(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?(?:\+([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?$/);
284189
+
284190
+ async function getFeatureConfigFromRef(featureName, featureRef, featureOwner, // -> cr
284191
+ featureArgs = {}, repo = 'features', owner = 'prefapp') {
284192
+ // reference is the featureRef directly
284193
+ const reference = `${featureRef}`;
284194
+ return processFeature(featureName, reference, featureOwner, featureArgs, repo, owner);
284195
+ }
284121
284196
  async function getFeatureConfig(featureName, version, featureOwner, // -> cr
284122
284197
  featureArgs = {}, repo = 'features', owner = 'prefapp') {
284123
- await downloadFeatureZip(repo, featureName, version, owner);
284124
- const ref = buildRef(featureName, version);
284198
+ const reference = `${featureName}-v${version}`;
284199
+ return processFeature(featureName, reference, featureOwner, featureArgs, repo, owner);
284200
+ }
284201
+ async function processFeature(featureName, reference, featureOwner, // -> cr
284202
+ featureArgs = {}, repo = 'features', owner = 'prefapp') {
284203
+ await downloadFeatureZip(repo, featureName, reference, owner);
284125
284204
  featureArgs['traceability'] = {
284126
- version,
284205
+ version: reference,
284127
284206
  owner,
284128
284207
  repo,
284129
284208
  name: featureName,
284130
- ref,
284131
- url: `https://github.com/${owner}/${repo}/tree/${ref}/packages/${featureName}`,
284209
+ ref: reference,
284210
+ url: `https://github.com/${owner}/${repo}/tree/${reference}/packages/${featureName}`,
284132
284211
  };
284133
- return renderFeature(featureName, version, featureOwner, '/tmp', featureArgs);
284212
+ return renderFeature(featureName, reference, featureOwner, '/tmp', featureArgs);
284134
284213
  }
284135
284214
  async function prepareFeature(featureName, version, repo = 'features', owner = 'prefapp') {
284136
284215
  await downloadFeatureZip(repo, featureName, version, owner);
284137
284216
  }
284138
- async function downloadFeatureZip(repo, featureName, version, owner = 'prefapp') {
284217
+ async function downloadFeatureZip(repo, featureName, reference, owner = 'prefapp') {
284139
284218
  try {
284140
- const ref = buildRef(featureName, version);
284141
284219
  const octokit = await github_0.getOctokitForOrg(owner);
284142
- const zipballExtractPath = catalog_common.features.tarballs.getFeaturesExtractPath(featureName, version, { createIfNotExists: true });
284220
+ const zipballExtractPath = catalog_common.features.tarballs.getFeaturesExtractPath(featureName, reference, { createIfNotExists: true });
284143
284221
  console.log(`Zipball extract path: ${zipballExtractPath}`);
284144
284222
  if (external_fs_.existsSync(zipballExtractPath)) {
284145
284223
  console.log(`Zipball extract path ${zipballExtractPath} already exists, removing it.`);
284146
284224
  external_fs_.rmSync(zipballExtractPath, { recursive: true });
284147
284225
  }
284148
- const response = await octokit.request('GET /repos/{owner}/{repo}/zipball/{ref}', {
284226
+ const response = await octokit.request('GET /repos/{owner}/{repo}/zipball/{reference}', {
284149
284227
  request: {
284150
284228
  parseSuccessResponseBody: false,
284151
284229
  },
284152
284230
  owner,
284153
284231
  repo,
284154
- ref,
284232
+ reference,
284155
284233
  });
284156
284234
  const randomZipTmpPath = `/tmp/${catalog_common.generic.randomString(20)}.zip`;
284157
- console.log(`Downloading feature ${featureName} version ${version} to ${randomZipTmpPath}`);
284235
+ console.log(`Downloading feature ${featureName} version ${reference} to ${randomZipTmpPath}`);
284158
284236
  if (external_fs_.existsSync(randomZipTmpPath)) {
284159
284237
  console.log(`Temporary zip file ${randomZipTmpPath} already exists, removing it.`);
284160
284238
  external_fs_.unlinkSync(randomZipTmpPath);
284161
284239
  }
284162
284240
  const randomExtractPath = `/tmp/${catalog_common.generic.randomString(20)}`;
284163
- console.log(`Extracting feature ${featureName} version ${version} to ${randomExtractPath}`);
284241
+ console.log(`Extracting feature ${featureName} version ${reference} to ${randomExtractPath}`);
284164
284242
  external_fs_.rmSync(randomExtractPath, { recursive: true, force: true });
284165
284243
  await downloadZipBall(response.url, randomZipTmpPath);
284166
284244
  const zip = new (adm_zip_default())(randomZipTmpPath);
@@ -284176,31 +284254,11 @@ async function downloadFeatureZip(repo, featureName, version, owner = 'prefapp')
284176
284254
  }
284177
284255
  catch (error) {
284178
284256
  console.error(error);
284179
- throw new Error(`Error for feature with tag ${featureName}-v${version}: ${error}. GitHub response: ${error}`);
284180
- }
284181
- }
284182
- async function downloadZipBall(url, filePath) {
284183
- try {
284184
- const zipResponse = await fetch(url);
284185
- if (!zipResponse.ok) {
284186
- throw new Error(`Failed to download ZIP: ${zipResponse.statusText}`);
284187
- }
284188
- const zipBuffer = await zipResponse.text();
284189
- external_fs_.writeFileSync(filePath, zipBuffer);
284190
- const stats = external_fs_.statfsSync(filePath);
284191
- console.dir(stats);
284192
- }
284193
- catch (err) {
284194
- throw new Error(`Downloading feature's zip: ${err.message}`);
284257
+ throw new Error(`Error for feature with tag ${reference}: ${error}. GitHub response: ${error}`);
284195
284258
  }
284196
284259
  }
284197
284260
  function buildRef(featureName, version) {
284198
- if (IS_SEMVER_REF.test(version)) {
284199
- return `${featureName}-v${version}`;
284200
- }
284201
- else {
284202
- return `${version}`;
284203
- }
284261
+ return `${featureName}-v${version}`;
284204
284262
  }
284205
284263
 
284206
284264
  ;// CONCATENATED MODULE: ../features_preparer/src/index.ts
@@ -284208,6 +284266,7 @@ function buildRef(featureName, version) {
284208
284266
 
284209
284267
  /* harmony default export */ const features_preparer_src = ({
284210
284268
  renderFeature: renderFeature,
284269
+ getFeatureConfigFromRef: getFeatureConfigFromRef,
284211
284270
  getFeatureConfig: getFeatureConfig,
284212
284271
  prepareFeature: prepareFeature,
284213
284272
  });
@@ -284263,13 +284322,17 @@ async function utils_renderFeature(featureName, featureVersion, featureOutputObj
284263
284322
 
284264
284323
 
284265
284324
  class FeaturesOverrider extends OverriderPatches {
284266
- constructor(featureName, featureVersion, featureConfig, featureArgs) {
284325
+ constructor(featureName, featureVersion, featureConfig, featureArgs, featureRef, featureRepo) {
284267
284326
  super();
284268
284327
  this.applicableProviders = ['github'];
284269
284328
  this.featureConfig = false;
284329
+ this.featureRepo = '';
284330
+ this.featureRef = '';
284270
284331
  this.featureName = featureName;
284271
284332
  this.featureVersion = featureVersion;
284272
284333
  this.featureArgs = featureArgs || {};
284334
+ this.featureRef = featureRef || '';
284335
+ this.featureRepo = featureRepo || '';
284273
284336
  if (featureConfig) {
284274
284337
  this.featureConfig = featureConfig;
284275
284338
  }
@@ -284277,7 +284340,18 @@ class FeaturesOverrider extends OverriderPatches {
284277
284340
  getFeatureConfig(cr) {
284278
284341
  if (this.featureConfig)
284279
284342
  return this.featureConfig;
284280
- return features_preparer.getFeatureConfig(this.featureName, this.featureVersion, this.featureArgs, cr, 'features', 'prefapp');
284343
+ let repo = 'features';
284344
+ let owner = 'prefapp';
284345
+ let version = this.featureVersion;
284346
+ let renderer = 'getFeatureConfig';
284347
+ if (this.featureRepo) {
284348
+ [owner, repo] = this.featureRepo.split(/\//);
284349
+ }
284350
+ if (this.featureRef) {
284351
+ version = this.featureRef;
284352
+ renderer = 'getFeatureConfigFromRef';
284353
+ }
284354
+ return features_preparer[renderer](this.featureName, version, this.featureArgs, cr, repo, owner, this.featureRef);
284281
284355
  }
284282
284356
  async __validate() {
284283
284357
  return true;
@@ -284339,7 +284413,7 @@ async function generateFeaturesPatches(claim) {
284339
284413
  return patches;
284340
284414
  }
284341
284415
  async function createRenderFeaturePatch(claim, feature) {
284342
- const featureOverrider = new FeaturesOverrider(feature.name, feature.version, false, feature.args);
284416
+ const featureOverrider = new FeaturesOverrider(feature.name, feature.version, false, feature.args, feature.ref, feature.repo);
284343
284417
  return featureOverrider.patches(claim, null);
284344
284418
  }
284345
284419
 
@@ -343,6 +343,47 @@ declare const schemas: {
343
343
  })[];
344
344
  };
345
345
  };
346
+ } | {
347
+ $schema: string;
348
+ $id: string;
349
+ definitions: {
350
+ GithubComponentFeatureClaim: {
351
+ $id: string;
352
+ description: string;
353
+ properties: {
354
+ name: {
355
+ type: string;
356
+ description: string;
357
+ };
358
+ version: {
359
+ type: string;
360
+ description: string;
361
+ };
362
+ ref: {
363
+ type: string;
364
+ description: string;
365
+ pattern: string;
366
+ };
367
+ args: {
368
+ type: string;
369
+ properties: {};
370
+ additionalProperties: boolean;
371
+ };
372
+ repo: {
373
+ type: string;
374
+ description: string;
375
+ };
376
+ };
377
+ required: string[];
378
+ oneOf: {
379
+ required: string[];
380
+ not: {
381
+ required: string[];
382
+ };
383
+ }[];
384
+ additionalProperties: boolean;
385
+ };
386
+ };
346
387
  } | {
347
388
  $schema: string;
348
389
  $id: string;
@@ -367,6 +408,12 @@ declare const schemas: {
367
408
  type: string;
368
409
  enum: string[];
369
410
  };
411
+ features: {
412
+ type: string;
413
+ items: {
414
+ $ref: string;
415
+ };
416
+ };
370
417
  };
371
418
  required: string[];
372
419
  $ref?: undefined;
@@ -22,6 +22,12 @@ declare const _default: {
22
22
  type: string;
23
23
  enum: string[];
24
24
  };
25
+ features: {
26
+ type: string;
27
+ items: {
28
+ $ref: string;
29
+ };
30
+ };
25
31
  };
26
32
  required: string[];
27
33
  $ref?: undefined;
@@ -0,0 +1,43 @@
1
+ declare const _default: {
2
+ $schema: string;
3
+ $id: string;
4
+ definitions: {
5
+ GithubComponentFeatureClaim: {
6
+ $id: string;
7
+ description: string;
8
+ properties: {
9
+ name: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ version: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ ref: {
18
+ type: string;
19
+ description: string;
20
+ pattern: string;
21
+ };
22
+ args: {
23
+ type: string;
24
+ properties: {};
25
+ additionalProperties: boolean;
26
+ };
27
+ repo: {
28
+ type: string;
29
+ description: string;
30
+ };
31
+ };
32
+ required: string[];
33
+ oneOf: {
34
+ required: string[];
35
+ not: {
36
+ required: string[];
37
+ };
38
+ }[];
39
+ additionalProperties: boolean;
40
+ };
41
+ };
42
+ };
43
+ export default _default;
@@ -59,6 +59,47 @@ export declare const GithubSchemas: ({
59
59
  })[];
60
60
  };
61
61
  };
62
+ } | {
63
+ $schema: string;
64
+ $id: string;
65
+ definitions: {
66
+ GithubComponentFeatureClaim: {
67
+ $id: string;
68
+ description: string;
69
+ properties: {
70
+ name: {
71
+ type: string;
72
+ description: string;
73
+ };
74
+ version: {
75
+ type: string;
76
+ description: string;
77
+ };
78
+ ref: {
79
+ type: string;
80
+ description: string;
81
+ pattern: string;
82
+ };
83
+ args: {
84
+ type: string;
85
+ properties: {};
86
+ additionalProperties: boolean;
87
+ };
88
+ repo: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ };
93
+ required: string[];
94
+ oneOf: {
95
+ required: string[];
96
+ not: {
97
+ required: string[];
98
+ };
99
+ }[];
100
+ additionalProperties: boolean;
101
+ };
102
+ };
62
103
  } | {
63
104
  $schema: string;
64
105
  $id: string;
@@ -83,6 +124,12 @@ export declare const GithubSchemas: ({
83
124
  type: string;
84
125
  enum: string[];
85
126
  };
127
+ features: {
128
+ type: string;
129
+ items: {
130
+ $ref: string;
131
+ };
132
+ };
86
133
  };
87
134
  required: string[];
88
135
  $ref?: undefined;
@@ -13,7 +13,9 @@ export interface IGithubRepositoryFeatureClaim extends IClaim {
13
13
  context: any;
14
14
  feature: {
15
15
  name: string;
16
- version: string;
16
+ version?: string;
17
+ ref?: string;
18
+ repo?: string;
17
19
  };
18
20
  repositoryTarget: FirestartrGithubRepositoryFeatureSpecRepositoryTarget;
19
21
  files: Array<IGithubRepositoryFeatureFileClaim>;
@@ -5,7 +5,9 @@ export declare class FeaturesOverrider extends OverriderPatches {
5
5
  private featureVersion;
6
6
  private featureConfig;
7
7
  private featureArgs;
8
- constructor(featureName: string, featureVersion: string, featureConfig?: any, featureArgs?: any);
8
+ private featureRepo;
9
+ private featureRef;
10
+ constructor(featureName: string, featureVersion: string, featureConfig?: any, featureArgs?: any, featureRef?: string, featureRepo?: string);
9
11
  getFeatureConfig(cr: any): any;
10
12
  __validate(): Promise<boolean>;
11
13
  __patches(claim: any, _previousCR: any): Promise<({
@@ -1,7 +1,8 @@
1
- import { getFeatureConfig, prepareFeature } from './installer';
1
+ import { getFeatureConfigFromRef, getFeatureConfig, prepareFeature } from './installer';
2
2
  import { renderFeature } from './renderer';
3
3
  declare const _default: {
4
4
  renderFeature: typeof renderFeature;
5
+ getFeatureConfigFromRef: typeof getFeatureConfigFromRef;
5
6
  getFeatureConfig: typeof getFeatureConfig;
6
7
  prepareFeature: typeof prepareFeature;
7
8
  };
@@ -1,4 +1,6 @@
1
+ export declare function getFeatureConfigFromRef(featureName: string, featureRef: string, featureOwner: any, // -> cr
2
+ featureArgs?: any, repo?: string, owner?: string): Promise<any>;
1
3
  export declare function getFeatureConfig(featureName: string, version: string, featureOwner: any, // -> cr
2
4
  featureArgs?: any, repo?: string, owner?: string): Promise<any>;
3
5
  export declare function prepareFeature(featureName: string, version: string, repo?: string, owner?: string): Promise<void>;
4
- export declare function downloadFeatureZip(repo: string, featureName: string, version: string, owner?: string): Promise<string>;
6
+ export declare function downloadFeatureZip(repo: string, featureName: string, reference: string, owner?: string): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare function downloadZipBall(url: string, filePath: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.43.2-snapshot-5",
3
+ "version": "1.43.2-snapshot-7",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",