@firestartr/cli 2.7.0 → 2.7.1

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
@@ -323668,6 +323668,57 @@ function sanitizeApiEntityName(name) {
323668
323668
  .replace(/[^a-z0-9-]/g, '-')
323669
323669
  .replace(/^-+|-+$/g, '');
323670
323670
  }
323671
+ async function generateClaimsMap(claimsPath, outputPath, sha) {
323672
+ const map = {
323673
+ headers: {
323674
+ sha: sha ?? '',
323675
+ },
323676
+ claims: {},
323677
+ };
323678
+ await crawlClaimsDir(claimsPath, claimsPath, map.claims);
323679
+ await external_fs_default().promises.writeFile(outputPath, JSON.stringify(map, null, 2), 'utf-8');
323680
+ }
323681
+ async function crawlClaimsDir(dir, basePath, claims) {
323682
+ let entries;
323683
+ try {
323684
+ entries = await (0,promises_.readdir)(dir, { withFileTypes: true });
323685
+ }
323686
+ catch (err) {
323687
+ throw new Error(`Reading directory ${dir}: ${err}`);
323688
+ }
323689
+ for (const entry of entries) {
323690
+ const fullPath = external_path_default().join(dir, entry.name);
323691
+ if (entry.isDirectory()) {
323692
+ await crawlClaimsDir(fullPath, basePath, claims);
323693
+ }
323694
+ else if (entry.isFile() && entry.name.match(/\.yaml$|\.yml$/)) {
323695
+ try {
323696
+ const data = await external_fs_default().promises.readFile(fullPath, 'utf-8');
323697
+ const claim = catalog_common/* default.io.fromYaml */.Z.io.fromYaml(data);
323698
+ if (typeof claim !== 'object' ||
323699
+ claim === null ||
323700
+ typeof claim.kind !== 'string' ||
323701
+ !claim.kind ||
323702
+ typeof claim.name !== 'string' ||
323703
+ !claim.name) {
323704
+ logger.warn(`Skipping file ${fullPath}: missing or invalid kind or name`);
323705
+ continue;
323706
+ }
323707
+ const ref = `${claim.kind}-${claim.name}`;
323708
+ if (claims[ref]) {
323709
+ throw new Error(`Duplicate claim reference: ${ref}`);
323710
+ }
323711
+ const relativePath = external_path_default().relative(basePath, fullPath)
323712
+ .split((external_path_default()).sep)
323713
+ .join((external_path_default()).posix.sep);
323714
+ claims[ref] = { filePath: relativePath };
323715
+ }
323716
+ catch (err) {
323717
+ throw new Error(`Error processing claim file ${fullPath}: ${err}`);
323718
+ }
323719
+ }
323720
+ }
323721
+ }
323671
323722
 
323672
323723
  ;// CONCATENATED MODULE: ../cdk8s_renderer/imports/firestartr.dev.ts
323673
323724
  // generated by cdk8s
@@ -328837,6 +328888,7 @@ async function addLastStateAndLastClaimAnnotations(filePath, lastStatePRLink, la
328837
328888
 
328838
328889
 
328839
328890
 
328891
+
328840
328892
 
328841
328893
 
328842
328894
  /* harmony default export */ const cdk8s_renderer = ({
@@ -341876,6 +341928,7 @@ function gh_checkrun_helperCreateCheckRunName(cmd, item) {
341876
341928
 
341877
341929
 
341878
341930
 
341931
+
341879
341932
  const process_operation_TF_CACHES_PATH = '/tmp/tfcaches';
341880
341933
  function process_operation_processOperation(item, op, handler) {
341881
341934
  operator_src_logger.info(`Processing operation ${op} on ${item.kind}/${item.metadata?.name}`);
@@ -342039,19 +342092,13 @@ async function* gh_process_operation_markedToDeletion(item, op, handler) {
342039
342092
  }
342040
342093
  catch (e) {
342041
342094
  error = true;
342042
- let errorMsg;
342043
- if (typeof e === 'object' && 'output' in e) {
342044
- errorMsg = e.output;
342045
- }
342046
- else {
342047
- errorMsg = e;
342048
- }
342095
+ const { output: errorMsg, exitCode: errCode } = extractErrorDetails(e);
342049
342096
  // if there is a current checkRun working
342050
342097
  // we close it with an error
342051
342098
  if (checkRunCtl)
342052
342099
  checkRunCtl.fnOnError(errorMsg);
342053
342100
  await tryPublishDestroy(item, errorMsg, false);
342054
- await handler.writeTerraformOutputInTfResult(item, errorMsg, 1);
342101
+ await handler.writeTerraformOutputInTfResult(item, errorMsg, errCode ?? 1);
342055
342102
  void handler.error();
342056
342103
  }
342057
342104
  finally {
@@ -342202,15 +342249,9 @@ async function* process_operation_doApply(item, op, handler) {
342202
342249
  }
342203
342250
  catch (e) {
342204
342251
  error = true;
342205
- let errorMsg;
342206
- if (typeof e === 'object' && 'output' in e) {
342207
- errorMsg = e.output;
342208
- }
342209
- else {
342210
- errorMsg = e;
342211
- }
342252
+ const { output: errorMsg, exitCode: errCode } = extractErrorDetails(e);
342212
342253
  // being one the exitCode
342213
- await tryPublishApply(item, errorMsg, false, 1);
342254
+ await tryPublishApply(item, errorMsg, false, errCode ?? 1);
342214
342255
  // if there is a current checkRun working
342215
342256
  // we close it with an error
342216
342257
  if (checkRunCtl)
@@ -342220,7 +342261,7 @@ async function* process_operation_doApply(item, op, handler) {
342220
342261
  operator_src_logger.error(`Error applying item ${item.metadata.name}: ${errorMsg}`);
342221
342262
  handler.error();
342222
342263
  if (errorMsg) {
342223
- await handler.writeTerraformOutputInTfResult(item, errorMsg, 1);
342264
+ await handler.writeTerraformOutputInTfResult(item, errorMsg, errCode ?? 1);
342224
342265
  }
342225
342266
  }
342226
342267
  finally {
@@ -342660,6 +342701,7 @@ const cdk8s_rendererSubcommands = {
342660
342701
  { name: 'render', alias: 'r', type: Boolean },
342661
342702
  { name: 'compare', type: Boolean },
342662
342703
  { name: 'render-plan', type: Boolean },
342704
+ { name: 'generate-claims-map', type: Boolean },
342663
342705
  /**
342664
342706
  * Specific parameters for render functionality
342665
342707
  */
@@ -342716,6 +342758,10 @@ const cdk8s_rendererSubcommands = {
342716
342758
  { name: 'lastStatePrLink', type: String },
342717
342759
  { name: 'lastClaimPrLink', type: String },
342718
342760
  { name: 'crLocation', type: String },
342761
+ /**
342762
+ * Specific parameters for claims-map generation
342763
+ */
342764
+ { name: 'claims-map-output', alias: 'm', type: String },
342719
342765
  ],
342720
342766
  run: async (options) => {
342721
342767
  if (options['render']) {
@@ -342728,6 +342774,14 @@ const cdk8s_rendererSubcommands = {
342728
342774
  else if (options['lastStatePrLink'] && options['lastClaimPrLink']) {
342729
342775
  await cdk8s_renderer.addLastStateAndLastClaimAnnotations(options['crLocation'], options['lastStatePrLink'], options['lastClaimPrLink']);
342730
342776
  }
342777
+ else if (options['generate-claims-map']) {
342778
+ const claimsPath = options['claims'];
342779
+ const outputPath = options['claims-map-output'];
342780
+ if (!claimsPath || !outputPath) {
342781
+ throw new Error('--claims and --claims-map-output are required with --generate-claims-map');
342782
+ }
342783
+ await generateClaimsMap(claimsPath, outputPath, options['sha']);
342784
+ }
342731
342785
  },
342732
342786
  };
342733
342787
 
@@ -521369,9 +521423,9 @@ const crsStatusSubcommand = {
521369
521423
  };
521370
521424
 
521371
521425
  ;// CONCATENATED MODULE: ./package.json
521372
- const package_namespaceObject = {"i8":"2.7.0"};
521426
+ const package_namespaceObject = {"i8":"2.7.1"};
521373
521427
  ;// CONCATENATED MODULE: ../../package.json
521374
- const package_namespaceObject_1 = {"i8":"2.7.0"};
521428
+ const package_namespaceObject_1 = {"i8":"2.7.1"};
521375
521429
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
521376
521430
 
521377
521431
 
@@ -13,6 +13,7 @@ import { runComparer } from './src/comparer';
13
13
  import { AllowedProviders, setDefaultBranch, setPath, setRepositoryUrl } from './src/config';
14
14
  import { render } from './src/renderer/renderer';
15
15
  export { AllowedProviders, configureProvider, setDefaultBranch, setRepositoryUrl, } from './src/config';
16
+ export { generateClaimsMap } from './src/utils/claimUtils';
16
17
  import { isCatalogEntity } from './src/validations/references';
17
18
  import { normalizeModuleContent } from './src/normalizers';
18
19
  import { loadCRs } from './src/loader/loader';
@@ -5,3 +5,13 @@ export declare function resolveClaimEntries(claimRefsList: string[]): AsyncGener
5
5
  export declare function resolveClaimFileRef(claimFile: string): Promise<string>;
6
6
  export declare function getClaimsEntryAbsolutePath(claimsDir: string, entryPath: string): string;
7
7
  export declare function sanitizeApiEntityName(name: string): string;
8
+ export interface ClaimsMapEntry {
9
+ filePath: string;
10
+ }
11
+ export interface ClaimsMap {
12
+ headers: {
13
+ sha: string;
14
+ };
15
+ claims: Record<string, ClaimsMapEntry>;
16
+ }
17
+ export declare function generateClaimsMap(claimsPath: string, outputPath: string, sha?: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",