@firestartr/cli 2.5.0-snapshot-1 → 2.5.0-snapshot-2

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/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  # requirements
10
10
 
11
11
  - terraform 1.6.2
12
- - cdktf-cli@0.19.0
13
12
  - lerna@7.4.1
14
13
 
15
14
  To install it, run the next commands:
@@ -21,7 +20,6 @@ mv terraform /usr/local/bin/; \
21
20
  chmod a+x /usr/local/bin/terraform; \
22
21
  rm -f terraform_1.6.2_linux_amd64.zip; \
23
22
  terraform --version; \
24
- npm install -g cdktf-cli@0.19.0; \
25
23
  npm install -g lerna@7.4.1;
26
24
  ```
27
25
 
package/build/index.js CHANGED
@@ -268553,12 +268553,7 @@ var envVars;
268553
268553
  envVars["s3Bucket"] = "S3_BUCKET";
268554
268554
  envVars["s3Lock"] = "S3_LOCK";
268555
268555
  envVars["s3Region"] = "S3_REGION";
268556
- // ---- CDKTF/LOCAL VARIABLES -----------------------------------------------
268557
- envVars["cdktfConfigFiles"] = "CDKTF_CONFIG_FILES";
268558
268556
  envVars["exclusionsYamlPath"] = "EXCLUSIONS_PATH";
268559
- envVars["cdktfEntityPath"] = "FIRESTARTR_CDKTF_ENTITY_PATH";
268560
- envVars["cdktfDepsPath"] = "FIRESTARTR_CDKTF_DEPS_PATH";
268561
- envVars["cdktfIsImport"] = "FIRESTARTR_CDKTF_IS_IMPORT";
268562
268557
  // ---- GITHUB APP VARIABLES -----------------------------------------------
268563
268558
  envVars["githubAppId"] = "GITHUB_APP_ID";
268564
268559
  envVars["githubAppInstallationId"] = "GITHUB_APP_INSTALLATION_ID";
@@ -268980,6 +268975,128 @@ class SimpleTokenizer {
268980
268975
  SimpleTokenizer,
268981
268976
  });
268982
268977
 
268978
+ ;// CONCATENATED MODULE: ../catalog_common/src/codeowners/index.ts
268979
+ // Common CODEOWNERS machinery (pure TypeScript/data; NO IO, NO classes)
268980
+ // Strictly follows GitHub CODEOWNERS syntax.
268981
+ // Spec: see specs/common/001-common-codeowners-machinery/spec.md
268982
+
268983
+ const OWNER_RE = /^@[\w.-]+(\/[\w.-]+)?$/;
268984
+ function codeowners_parse(raw) {
268985
+ if (typeof raw !== 'string' || raw === '')
268986
+ return [];
268987
+ return raw.split(/\r?\n/).map((line) => {
268988
+ const trimmed = line.trim();
268989
+ if (trimmed === '') {
268990
+ return { type: 'blank', raw: line };
268991
+ }
268992
+ if (/^#/.test(trimmed)) {
268993
+ return { type: 'comment', raw: line };
268994
+ }
268995
+ // Rule line: parse pattern & owners structurally, no ref resolution
268996
+ const tokens = trimmed.split(/\s+/);
268997
+ const pattern = tokens[0];
268998
+ const owners = tokens.slice(1);
268999
+ return { type: 'rule', pattern, owners, raw: line };
269000
+ });
269001
+ }
269002
+ function format(entries) {
269003
+ let end = entries.length;
269004
+ while (end > 0 && entries[end - 1].type === 'blank') {
269005
+ end -= 1;
269006
+ }
269007
+ const lines = entries.slice(0, end).map((entry) => {
269008
+ switch (entry.type) {
269009
+ case 'blank':
269010
+ return '';
269011
+ case 'comment':
269012
+ return entry.raw.trimEnd();
269013
+ case 'rule': {
269014
+ const owners = entry.owners ?? [];
269015
+ return owners.length > 0
269016
+ ? `${entry.pattern} ${owners.join(' ')}`
269017
+ : `${entry.pattern}`;
269018
+ }
269019
+ }
269020
+ });
269021
+ return lines.join('\n') + '\n';
269022
+ }
269023
+ function codeowners_validate(raw) {
269024
+ const errors = [];
269025
+ const lines = raw.split(/\r?\n/);
269026
+ for (let i = 0; i < lines.length; i++) {
269027
+ const line = lines[i];
269028
+ if (/^\s*$/.test(line))
269029
+ continue;
269030
+ if (/^\s*#/.test(line))
269031
+ continue;
269032
+ const tokens = line.trim().split(/\s+/);
269033
+ const pattern = tokens[0];
269034
+ const owners = tokens.slice(1);
269035
+ if (!pattern) {
269036
+ errors.push(`Line ${i + 1}: empty pattern`);
269037
+ continue;
269038
+ }
269039
+ if (owners.length === 0) {
269040
+ errors.push(`Line ${i + 1}: rule must have at least one owner`);
269041
+ continue;
269042
+ }
269043
+ for (const owner of owners) {
269044
+ if (!OWNER_RE.test(owner)) {
269045
+ errors.push(`Line ${i + 1}: invalid owner '${owner}' (must be @username or @org/team-slug)`);
269046
+ }
269047
+ }
269048
+ if (line.includes('#')) {
269049
+ errors.push(`Line ${i + 1}: inline comments are not allowed`);
269050
+ }
269051
+ }
269052
+ return { valid: errors.length === 0, errors };
269053
+ }
269054
+ function updateRule(entries, pattern, owners) {
269055
+ const idx = entries.findIndex((e) => e.type === 'rule' && e.pattern === pattern);
269056
+ const newEntry = {
269057
+ type: 'rule',
269058
+ pattern,
269059
+ owners,
269060
+ raw: `${pattern} ${owners.join(' ')}`,
269061
+ };
269062
+ if (idx >= 0) {
269063
+ const result = [...entries];
269064
+ result[idx] = newEntry;
269065
+ return result;
269066
+ }
269067
+ return [...entries, newEntry];
269068
+ }
269069
+ function remove(entries, pattern) {
269070
+ return entries.filter((e) => !(e.type === 'rule' && e.pattern === pattern));
269071
+ }
269072
+ function getOwners(entries) {
269073
+ const owners = new Set();
269074
+ for (const entry of entries) {
269075
+ if (entry.type === 'rule' && entry.owners) {
269076
+ for (const owner of entry.owners) {
269077
+ owners.add(owner);
269078
+ }
269079
+ }
269080
+ }
269081
+ return [...owners];
269082
+ }
269083
+ function resolveRefs(raw, replacements) {
269084
+ const tokenizer = new SimpleTokenizer(/\{\{\s*([\w./-]+)\s*\}\}/);
269085
+ return tokenizer.replace(raw, (token) => {
269086
+ const key = token.groups?.[0] ?? '';
269087
+ return key in replacements ? replacements[key] : token.value;
269088
+ });
269089
+ }
269090
+ /* harmony default export */ const codeowners = ({
269091
+ parse: codeowners_parse,
269092
+ format,
269093
+ validate: codeowners_validate,
269094
+ updateRule,
269095
+ remove,
269096
+ getOwners,
269097
+ resolveRefs,
269098
+ });
269099
+
268983
269100
  // EXTERNAL MODULE: ../../node_modules/cron-parser/dist/index.js
268984
269101
  var cron_parser_dist = __nccwpck_require__(98370);
268985
269102
  ;// CONCATENATED MODULE: ../catalog_common/src/cron.ts
@@ -269023,6 +269140,7 @@ function getCronNextInterval(cronLine, tz) {
269023
269140
 
269024
269141
 
269025
269142
 
269143
+
269026
269144
  /* harmony default export */ const catalog_common = ({
269027
269145
  io: io,
269028
269146
  generic: generic,
@@ -269033,6 +269151,7 @@ function getCronNextInterval(cronLine, tz) {
269033
269151
  policies: policies,
269034
269152
  logger: logger_logger,
269035
269153
  tokenizer: tokenizer,
269154
+ codeowners: codeowners,
269036
269155
  cron: {
269037
269156
  validateCron: validateCron,
269038
269157
  isValidCron: isValidCron,
@@ -290043,7 +290162,7 @@ class RepoGithubDecanter extends GithubDecanter {
290043
290162
  if (this.data.isEmpty) {
290044
290163
  const repoFullName = `${this.org}/${this.data.repoDetails.name}`;
290045
290164
  throw new Error(`The repo ${repoFullName} is empty - no commits, therefore CAN NOT be imported. ` +
290046
- 'Create it with firestartr or fill it with some README.md or another initial file or code');
290165
+ 'Create it with Firestartr or fill it with some README.md or another initial file or code');
290047
290166
  }
290048
290167
  }
290049
290168
  constructor(data, org, githubTeams = {}) {
@@ -293242,7 +293361,7 @@ async function* markedToDeletion(item, op, handler) {
293242
293361
  reason: op,
293243
293362
  type: 'PROVISIONED',
293244
293363
  status: 'False',
293245
- message: 'Synth CDKTF',
293364
+ message: 'Synth',
293246
293365
  };
293247
293366
  yield {
293248
293367
  item,
@@ -296792,7 +296911,7 @@ async function* process_operation_markedToDeletion(item, op, handler) {
296792
296911
  reason: op,
296793
296912
  type: 'PROVISIONED',
296794
296913
  status: 'False',
296795
- message: 'Synth CDKTF',
296914
+ message: 'Synth',
296796
296915
  };
296797
296916
  yield {
296798
296917
  item,
@@ -296914,7 +297033,7 @@ async function* doApply(item, op, handler) {
296914
297033
  reason: op,
296915
297034
  type: 'PROVISIONED',
296916
297035
  status: 'False',
296917
- message: 'Synth CDKTF',
297036
+ message: 'Synth',
296918
297037
  };
296919
297038
  let output = '';
296920
297039
  const type = 'PROVISIONING';
@@ -298683,16 +298802,67 @@ function provisionDefaultBranch(fsGithubRepository) {
298683
298802
  ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghrepo/helpers/codeowners.ts
298684
298803
 
298685
298804
 
298805
+ // Helper: Escape RegExp special characters in owner strings
298806
+ function codeowners_escapeRegExp(string) {
298807
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
298808
+ }
298686
298809
  async function provisionCodeowners(fsGithubRepository) {
298687
298810
  const cr = fsGithubRepository.cr;
298811
+ let codeownersText = cr.spec.repo.codeowners;
298812
+ const org = cr.spec.org;
298813
+ if (typeof codeownersText !== 'string') {
298814
+ gh_provisioner_src_logger.debug('[provisionCodeowners] No CODEOWNERS content configured; skipping provisioning.');
298815
+ return;
298816
+ }
298817
+ // 1. Gather all group refs present in cr.spec.permissions (if any)
298818
+ const allRefs = [];
298819
+ if (cr.spec.permissions && Array.isArray(cr.spec.permissions)) {
298820
+ for (const perm of cr.spec.permissions) {
298821
+ if (perm.ref && perm.ref.kind === 'FirestartrGithubGroup') {
298822
+ allRefs.push(perm.ref);
298823
+ }
298824
+ }
298825
+ }
298826
+ // (Extend here if group refs appear in other fields in future specs)
298827
+ // 2. For each group dependency: get external name & slug
298828
+ const replacements = [];
298829
+ for (const ref of allRefs) {
298830
+ let dep;
298831
+ try {
298832
+ dep = base_Entity.refResolver(ref);
298833
+ }
298834
+ catch (e) {
298835
+ gh_provisioner_src_logger.error(`[provisionCodeowners] Failed to resolve group ref ${ref.name}: ${String(e)}`);
298836
+ continue;
298837
+ }
298838
+ const extName = dep?.cr?.metadata?.annotations?.['firestartr.dev/external-name'];
298839
+ const slug = dep?.getOutput && dep.getOutput('slug');
298840
+ if (!extName) {
298841
+ gh_provisioner_src_logger.error(`[provisionCodeowners] Missing external-name annotation for group ref ${ref.name}`);
298842
+ continue;
298843
+ }
298844
+ if (!slug) {
298845
+ gh_provisioner_src_logger.error(`[provisionCodeowners] Missing slug output for group '${extName}' (${ref.name}) - will preserve as-is.`);
298846
+ continue;
298847
+ }
298848
+ const from = `@${org}/${extName}`;
298849
+ const to = `@${org}/${slug}`;
298850
+ replacements.push({ from, to });
298851
+ }
298852
+ // 3. Replace all exact occurrences of each external name owner with slug owner
298853
+ for (const { from, to } of replacements) {
298854
+ // Needs literal match, even if source owner has spaces/punctuation
298855
+ codeownersText = codeownersText.replace(new RegExp(codeowners_escapeRegExp(from), 'g'), to);
298856
+ }
298857
+ // Do not reformat, parse, or canonicalize further (per spec: preserve layout except for replacements)
298688
298858
  const config = {
298689
298859
  branch: cr.spec.repo.defaultBranch,
298690
298860
  commitMessage: 'ci: provision CODEOWNERS file',
298691
- content: cr.spec.repo.codeowners,
298861
+ content: codeownersText,
298692
298862
  file: '.github/CODEOWNERS',
298693
298863
  overwriteOnCreate: true,
298694
298864
  };
298695
- gh_provisioner_src_logger.debug(`Content of the codeowners: ${cr.spec.repo.codeowners}`);
298865
+ gh_provisioner_src_logger.debug(`[provisionCodeowners] Final CODEOWNERS content: ${codeownersText}`);
298696
298866
  fsGithubRepository.patchData({
298697
298867
  path: '/config/files/-',
298698
298868
  op: PatchOperations.add,
@@ -301739,7 +301909,7 @@ const crs_analyzerSubcommand = {
301739
301909
  };
301740
301910
 
301741
301911
  ;// CONCATENATED MODULE: ./package.json
301742
- const package_namespaceObject = JSON.parse('{"i8":"2.5.0-snapshot-1"}');
301912
+ const package_namespaceObject = JSON.parse('{"i8":"2.5.0-snapshot-2"}');
301743
301913
  ;// CONCATENATED MODULE: ../../package.json
301744
301914
  const package_namespaceObject_1 = {"i8":"2.4.0"};
301745
301915
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -104,6 +104,15 @@ declare const _default: {
104
104
  tokenizer: {
105
105
  SimpleTokenizer: typeof import("./src/tokenizer").SimpleTokenizer;
106
106
  };
107
+ codeowners: {
108
+ parse: typeof import("./src/codeowners").parse;
109
+ format: typeof import("./src/codeowners").format;
110
+ validate: typeof import("./src/codeowners").validate;
111
+ updateRule: typeof import("./src/codeowners").updateRule;
112
+ remove: typeof import("./src/codeowners").remove;
113
+ getOwners: typeof import("./src/codeowners").getOwners;
114
+ resolveRefs: typeof import("./src/codeowners").resolveRefs;
115
+ };
107
116
  cron: {
108
117
  validateCron: typeof validateCron;
109
118
  isValidCron: typeof isValidCron;
@@ -0,0 +1,26 @@
1
+ export interface CodeownersEntry {
2
+ type: 'rule' | 'comment' | 'blank';
3
+ pattern?: string;
4
+ owners?: string[];
5
+ raw: string;
6
+ }
7
+ export declare function parse(raw: string): CodeownersEntry[];
8
+ export declare function format(entries: CodeownersEntry[]): string;
9
+ export declare function validate(raw: string): {
10
+ valid: boolean;
11
+ errors: string[];
12
+ };
13
+ export declare function updateRule(entries: CodeownersEntry[], pattern: string, owners: string[]): CodeownersEntry[];
14
+ export declare function remove(entries: CodeownersEntry[], pattern: string): CodeownersEntry[];
15
+ export declare function getOwners(entries: CodeownersEntry[]): string[];
16
+ export declare function resolveRefs(raw: string, replacements: Record<string, string>): string;
17
+ declare const _default: {
18
+ parse: typeof parse;
19
+ format: typeof format;
20
+ validate: typeof validate;
21
+ updateRule: typeof updateRule;
22
+ remove: typeof remove;
23
+ getOwners: typeof getOwners;
24
+ resolveRefs: typeof resolveRefs;
25
+ };
26
+ export default _default;
@@ -25,11 +25,7 @@ export declare enum envVars {
25
25
  s3Bucket = "S3_BUCKET",
26
26
  s3Lock = "S3_LOCK",
27
27
  s3Region = "S3_REGION",
28
- cdktfConfigFiles = "CDKTF_CONFIG_FILES",
29
28
  exclusionsYamlPath = "EXCLUSIONS_PATH",
30
- cdktfEntityPath = "FIRESTARTR_CDKTF_ENTITY_PATH",
31
- cdktfDepsPath = "FIRESTARTR_CDKTF_DEPS_PATH",
32
- cdktfIsImport = "FIRESTARTR_CDKTF_IS_IMPORT",
33
29
  githubAppId = "GITHUB_APP_ID",
34
30
  githubAppInstallationId = "GITHUB_APP_INSTALLATION_ID",
35
31
  githubAppInstallationIdPrefapp = "GITHUB_APP_INSTALLATION_ID_PREFAPP",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.5.0-snapshot-1",
3
+ "version": "2.5.0-snapshot-2",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",