@firestartr/cli 2.6.0-snapshot-2 → 2.6.0-snapshot-3

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 (2) hide show
  1. package/build/index.js +74 -60
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -294790,8 +294790,6 @@ function processHandler(processToHandle, ctl, onTimedOut) {
294790
294790
  return (this.output ?? '').trim();
294791
294791
  }
294792
294792
  writeToTerraformProject(mainTfPath) {
294793
- // DEBUG LOG
294794
- // eslint-disable-next-line no-console
294795
294793
  const dir = mainTfPath.split('/').slice(0, -1).join('/');
294796
294794
  if (!external_fs_.existsSync(dir)) {
294797
294795
  external_fs_.mkdirSync(dir, { recursive: true });
@@ -294800,7 +294798,6 @@ function processHandler(processToHandle, ctl, onTimedOut) {
294800
294798
  throw new Error('Writer output is not set. Did you forget to call render()?');
294801
294799
  }
294802
294800
  external_fs_.writeFileSync(mainTfPath, this.output, { encoding: 'utf8' });
294803
- // eslint-disable-next-line no-console
294804
294801
  }
294805
294802
  });
294806
294803
 
@@ -295583,21 +295580,25 @@ var external_stream_ = __nccwpck_require__(12781);
295583
295580
 
295584
295581
  class project_tf_TFProjectManager {
295585
295582
  async tearUpProject() {
295583
+ const resolvedProjectPath = this.projectPath
295584
+ ? external_path_.resolve(this.projectPath)
295585
+ : '';
295586
295586
  // Remove the entire workspace directory
295587
- if (this.projectPath && this.projectPath.startsWith('/tmp/gh-debug/')) {
295587
+ if (resolvedProjectPath &&
295588
+ resolvedProjectPath.startsWith('/tmp/gh-debug/')) {
295588
295589
  // Never delete debug workspaces, per spec.
295589
295590
  terraform_provisioner_src_logger.info(`[terraform-provisioner]: SKIP teardown for debug workspace at ${this.projectPath}`);
295590
295591
  return;
295591
295592
  }
295592
- if (this.projectPath &&
295593
- this.projectPath.startsWith('/tmp/') &&
295594
- external_path_.resolve(this.projectPath) !== '/tmp') {
295593
+ if (resolvedProjectPath &&
295594
+ resolvedProjectPath.startsWith('/tmp/') &&
295595
+ resolvedProjectPath !== '/tmp') {
295595
295596
  try {
295596
- external_fs_.rmSync(this.projectPath, {
295597
+ external_fs_.rmSync(resolvedProjectPath, {
295597
295598
  recursive: true,
295598
295599
  force: true,
295599
295600
  });
295600
- terraform_provisioner_src_logger.info(`[terraform-provisioner]: Workspace at ${this.projectPath} torn up successfully`);
295601
+ terraform_provisioner_src_logger.info(`[terraform-provisioner]: Workspace at ${resolvedProjectPath} torn up successfully`);
295601
295602
  }
295602
295603
  catch (e) {
295603
295604
  throw new Error(`[terraform-provisioner]: Failed to tear up local project at ${this.projectPath}: ${e}`);
@@ -295642,8 +295643,10 @@ class project_tf_TFProjectManager {
295642
295643
  this.stream.on('end', fnEnd);
295643
295644
  }
295644
295645
  async build() {
295645
- // Workspace reuse block: verify if we should preserve existing workspace
295646
295646
  if (this.ctx?.reuseExistingProject) {
295647
+ if (!external_fs_.existsSync(this.projectPath)) {
295648
+ throw new Error(`[terraform-provisioner]: Workspace reuse requested but projectPath does not exist: ${this.projectPath}. Cannot continue.`);
295649
+ }
295647
295650
  const expectedFiles = await computeInlineWorkspaceFiles(this.ctx);
295648
295651
  const missing = validateWorkspaceStructure(this.projectPath, expectedFiles);
295649
295652
  if (missing.length === 0) {
@@ -295676,8 +295679,8 @@ class project_tf_TFProjectManager {
295676
295679
  const writerImports = new WriterImports(this.customArgs);
295677
295680
  await writerImports.render();
295678
295681
  await writerImports.writeToTerraformProject(external_path_.join(this.projectPath, 'imports.tf'));
295679
- // Always re-init backend after imports.tf is rebuilt (import mode)
295680
- this.tfOutput += await init(this.projectPath, this.secrets, this.stream, this.ctl);
295682
+ // Note: for freshly built workspaces, __init() will run before the import command executes.
295683
+ // Only reuse mode needs an extra init immediately after regenerating imports.tf.
295681
295684
  }
295682
295685
  }
295683
295686
  async __init() {
@@ -296273,21 +296276,25 @@ var lib_ajv_default = /*#__PURE__*/__nccwpck_require__.n(lib_ajv);
296273
296276
 
296274
296277
  class TFProjectManagerRemote {
296275
296278
  async tearUpProject() {
296279
+ const resolvedProjectPath = this.projectPath
296280
+ ? external_path_.resolve(this.projectPath)
296281
+ : '';
296276
296282
  // Remove the entire workspace directory
296277
- if (this.projectPath && this.projectPath.startsWith('/tmp/gh-debug/')) {
296283
+ if (resolvedProjectPath &&
296284
+ resolvedProjectPath.startsWith('/tmp/gh-debug/')) {
296278
296285
  // Never delete debug workspaces, per spec.
296279
296286
  terraform_provisioner_src_logger.info(`[terraform-provisioner]: SKIP teardown for debug workspace at ${this.projectPath}`);
296280
296287
  return;
296281
296288
  }
296282
- if (this.projectPath &&
296283
- this.projectPath.startsWith('/tmp/') &&
296284
- external_path_.resolve(this.projectPath) !== '/tmp') {
296289
+ if (resolvedProjectPath &&
296290
+ resolvedProjectPath.startsWith('/tmp/') &&
296291
+ resolvedProjectPath !== '/tmp') {
296285
296292
  try {
296286
- external_fs_.rmSync(this.projectPath, {
296293
+ external_fs_.rmSync(resolvedProjectPath, {
296287
296294
  recursive: true,
296288
296295
  force: true,
296289
296296
  });
296290
- terraform_provisioner_src_logger.info(`[terraform-provisioner]: Workspace at ${this.projectPath} torn up successfully`);
296297
+ terraform_provisioner_src_logger.info(`[terraform-provisioner]: Workspace at ${resolvedProjectPath} torn up successfully`);
296291
296298
  }
296292
296299
  catch (e) {
296293
296300
  throw new Error(`[terraform-provisioner]: Failed to tear up local project at ${this.projectPath}: ${e}`);
@@ -296337,6 +296344,9 @@ class TFProjectManagerRemote {
296337
296344
  async build() {
296338
296345
  // Workspace reuse block for remote
296339
296346
  if (this.ctx?.reuseExistingProject) {
296347
+ if (!external_fs_.existsSync(this.projectPath)) {
296348
+ throw new Error(`[terraform-provisioner]: Workspace reuse requested but projectPath does not exist: ${this.projectPath}. Cannot continue.`);
296349
+ }
296340
296350
  const expectedFiles = await computeRemoteWorkspaceFiles(this.ctx);
296341
296351
  const missing = validateWorkspaceStructure(this.projectPath, expectedFiles);
296342
296352
  if (missing.length === 0) {
@@ -296372,8 +296382,8 @@ class TFProjectManagerRemote {
296372
296382
  const writerImports = new WriterImports(this.customArgs);
296373
296383
  await writerImports.render();
296374
296384
  await writerImports.writeToTerraformProject(external_path_.join(this.projectPath, 'imports.tf'));
296375
- // Always re-init backend after imports.tf is rebuilt (import mode)
296376
- this.tfOutput += await init(this.projectPath, this.secrets, this.stream, this.ctl);
296385
+ // Note: for freshly built workspaces, __init() will run before the import command executes.
296386
+ // Only reuse mode needs an extra init immediately after regenerating imports.tf.
296377
296387
  }
296378
296388
  }
296379
296389
  async __init() {
@@ -299977,11 +299987,51 @@ function providers_replaceInlineSecrets(inline, secrets) {
299977
299987
  return result;
299978
299988
  }
299979
299989
 
299990
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/debug.ts
299991
+
299992
+
299993
+
299994
+
299995
+
299996
+ const DEBUG_DIR = external_path_default().join(external_os_default().tmpdir(), 'gh-debug');
299997
+ // Returns the project path to use for debug artifacts (always SessionProjectPath for consistency)
299998
+ function getDebugProjectPath(entity) {
299999
+ // Use the sessionProjectPath, which now always includes the 4-character sessionId
300000
+ return (entity.sessionProjectPath ||
300001
+ external_path_default().join(DEBUG_DIR, entity.k8sId.replace(/\//, '-') + '-id_missing'));
300002
+ }
300003
+ async function initDebug(entity, deps) {
300004
+ // Clean only this session's project debug directory, NOT all debug workspaces
300005
+ // Only create the specific debug project path for this session; never remove in debug mode
300006
+ await (0,promises_.mkdir)(getDebugProjectPath(entity), { recursive: true });
300007
+ const debugArtifactsDir = external_path_default().join(getDebugProjectPath(entity), 'gh_provisioner_debug');
300008
+ await (0,promises_.mkdir)(debugArtifactsDir, { recursive: true });
300009
+ // Write artifact files into the required debug project subdirectory
300010
+ await (0,promises_.writeFile)(external_path_default().join(debugArtifactsDir, 'cr.yaml'), catalog_common/* default.io.toYaml */.Z.io.toYaml(entity.cr.rawCr));
300011
+ await (0,promises_.writeFile)(external_path_default().join(debugArtifactsDir, 'deps.yaml'), catalog_common/* default.io.toYaml */.Z.io.toYaml(deps));
300012
+ gh_provisioner_src_logger.enableFileLogging(external_path_default().join(debugArtifactsDir, 'debug.log'));
300013
+ }
300014
+ // Deprecated: Use getDebugProjectPath in all debug logic
300015
+ function getTFProjectPath(entity) {
300016
+ return getDebugProjectPath(entity);
300017
+ }
300018
+ async function debugTerraformOutput(entity, output) {
300019
+ const pathToOutput = external_path_default().join(getDebugProjectPath(entity), 'terraform-output.txt');
300020
+ await (0,promises_.writeFile)(pathToOutput, output);
300021
+ gh_provisioner_src_logger.debug(`[gh-provisioner] debug: Terraform error written to ${pathToOutput}`);
300022
+ }
300023
+ async function endDebug(entity) {
300024
+ await (0,promises_.writeFile)(external_path_default().join(getDebugProjectPath(entity), 'config.json'), JSON.stringify(entity.document, null, 4));
300025
+ gh_provisioner_src_logger.disableFileLogging();
300026
+ }
300027
+
299980
300028
  ;// CONCATENATED MODULE: ../gh_provisioner/src/tp_bridge.ts
299981
300029
  // Bridge to terraform provisioner
299982
300030
 
299983
300031
 
299984
300032
 
300033
+
300034
+
299985
300035
  const tp_bridge_TF_PROJECTS_PATH = '/tmp/gh-workspaces';
299986
300036
  async function runOnTerraform(entity, command, customArgs, opts = {}) {
299987
300037
  if (!entity || typeof entity !== 'object')
@@ -300030,7 +300080,9 @@ function tp_bridge_buildContext(entity, reuseExistingProjectOverride = false, im
300030
300080
  const result = providers_adaptProviders(entity);
300031
300081
  const projectPath = entity.sessionProjectPath
300032
300082
  ? entity.sessionProjectPath // Always use session projectPath if present
300033
- : `/tmp/gh-workspaces/${entity.cr.kind.toLowerCase()}-${entity.cr.name}-${entity.sessionId ?? 'unknown'}`;
300083
+ : entity.inDebugMode
300084
+ ? getTFProjectPath(entity)
300085
+ : external_path_default().join(tp_bridge_TF_PROJECTS_PATH, `${entity.cr.kind.toLowerCase()}-${entity.cr.name}-${entity.sessionId ?? 'unknown'}`);
300034
300086
  const backend = providers_adaptBackend(entity);
300035
300087
  return {
300036
300088
  type: 'Remote',
@@ -300560,44 +300612,6 @@ async function loadCr(crPath) {
300560
300612
  return entityCr;
300561
300613
  }
300562
300614
 
300563
- ;// CONCATENATED MODULE: ../gh_provisioner/src/debug.ts
300564
-
300565
-
300566
-
300567
-
300568
-
300569
- const DEBUG_DIR = external_path_default().join(external_os_default().tmpdir(), 'gh-debug');
300570
- // Returns the project path to use for debug artifacts (always SessionProjectPath for consistency)
300571
- function getDebugProjectPath(entity) {
300572
- // Use the sessionProjectPath, which now always includes the 4-character sessionId
300573
- return (entity.sessionProjectPath ||
300574
- external_path_default().join(DEBUG_DIR, entity.k8sId.replace(/\//, '-') + '-id_missing'));
300575
- }
300576
- async function initDebug(entity, deps) {
300577
- // Clean only this session's project debug directory, NOT all debug workspaces
300578
- // Only create the specific debug project path for this session; never remove in debug mode
300579
- await (0,promises_.mkdir)(getDebugProjectPath(entity), { recursive: true });
300580
- const debugArtifactsDir = external_path_default().join(getDebugProjectPath(entity), 'gh_provisioner_debug');
300581
- await (0,promises_.mkdir)(debugArtifactsDir, { recursive: true });
300582
- // Write artifact files into the required debug project subdirectory
300583
- await (0,promises_.writeFile)(external_path_default().join(debugArtifactsDir, 'cr.yaml'), catalog_common/* default.io.toYaml */.Z.io.toYaml(entity.cr.rawCr));
300584
- await (0,promises_.writeFile)(external_path_default().join(debugArtifactsDir, 'deps.yaml'), catalog_common/* default.io.toYaml */.Z.io.toYaml(deps));
300585
- gh_provisioner_src_logger.enableFileLogging(external_path_default().join(debugArtifactsDir, 'debug.log'));
300586
- }
300587
- // Deprecated: Use getDebugProjectPath in all debug logic
300588
- function getTFProjectPath(entity) {
300589
- return getDebugProjectPath(entity);
300590
- }
300591
- async function debugTerraformOutput(entity, output) {
300592
- const pathToOutput = external_path_default().join(getDebugProjectPath(entity), 'terraform-output.txt');
300593
- await (0,promises_.writeFile)(pathToOutput, output);
300594
- gh_provisioner_src_logger.debug(`[gh-provisioner] debug: Terraform error written to ${pathToOutput}`);
300595
- }
300596
- async function endDebug(entity) {
300597
- await (0,promises_.writeFile)(external_path_default().join(getDebugProjectPath(entity), 'config.json'), JSON.stringify(entity.document, null, 4));
300598
- gh_provisioner_src_logger.disableFileLogging();
300599
- }
300600
-
300601
300615
  ;// CONCATENATED MODULE: ../gh_provisioner/index.ts
300602
300616
 
300603
300617
 
@@ -302511,7 +302525,7 @@ const crs_analyzerSubcommand = {
302511
302525
  };
302512
302526
 
302513
302527
  ;// CONCATENATED MODULE: ./package.json
302514
- const package_namespaceObject = JSON.parse('{"i8":"2.6.0-snapshot-2"}');
302528
+ const package_namespaceObject = JSON.parse('{"i8":"2.6.0-snapshot-3"}');
302515
302529
  ;// CONCATENATED MODULE: ../../package.json
302516
302530
  const package_namespaceObject_1 = {"i8":"2.5.0"};
302517
302531
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.6.0-snapshot-2",
3
+ "version": "2.6.0-snapshot-3",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",