From fc082580c74ce1877d817260ab5b86540d59b739 Mon Sep 17 00:00:00 2001 From: ljacobsson Date: Sun, 16 Jul 2023 15:48:36 +0200 Subject: [PATCH] fixes --- src/commands/local/cdk-wrapper.js | 11 +++++------ src/commands/local/local.js | 6 +++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/commands/local/cdk-wrapper.js b/src/commands/local/cdk-wrapper.js index 23c03f1..a8050d9 100644 --- a/src/commands/local/cdk-wrapper.js +++ b/src/commands/local/cdk-wrapper.js @@ -3,17 +3,16 @@ const cdk = require('aws-cdk-lib'); const fs = require('fs'); const { yamlDump } = require('yaml-cfn'); let stackFile = fs.readFileSync(`${process.cwd()}/${process.argv[2]}`, 'utf8'); -stackFile = stackFile.replace(/\.ts"/g, '.js"'); +stackFile = stackFile.replace(/\.ts"/g, '.js"').replace(/\.ts'/g, ".js'"); fs.writeFileSync(`${process.cwd()}/${process.argv[2]}`, stackFile); const TargetStack = require(`${process.cwd()}/${process.argv[2]}`); -const stackName = Object.keys(TargetStack)[0]; -process.env.SAMP_STACKNAME = stackName; -const templatePath = `${process.cwd()}/cdk.out/${stackName}.template.json`; +const className = Object.keys(TargetStack)[0]; + +const templatePath = `${process.cwd()}/cdk.out/${process.env.SAMP_STACKNAME}.template.json`; const synthedTemplate = JSON.parse(fs.readFileSync(templatePath, 'utf8')); -console.log("TargetStack: ", stackName); const app = new cdk.App(); -const stack = new TargetStack[stackName](null, stackName, {}); +const stack = new TargetStack[className](null, process.env.SAMP_STACKNAME, {}); const resources = stack.node._children; diff --git a/src/commands/local/local.js b/src/commands/local/local.js index e4ea3c9..7df1819 100644 --- a/src/commands/local/local.js +++ b/src/commands/local/local.js @@ -124,9 +124,13 @@ async function setupDebug() { let stack = null; if (fs.existsSync(`cdk.json`)) { const constructs = findConstructs(); + constructs.push("Enter manually"); const construct = await inputUtil.autocomplete("Which stack construct do you want to debug?", constructs); + if (construct === "Enter manually") { + construct = await inputUtil.autocomplete("Which stack construct do you want to debug?"); + } const cdkTree = JSON.parse(fs.readFileSync("cdk.out/tree.json", "utf8")); - const stacks = Object.keys(cdkTree.tree.children); + const stacks = Object.keys(cdkTree.tree.children).filter(c => c !== "Tree"); stacks.push("Enter manually"); stack = await inputUtil.autocomplete("What's the name of the deployed stack?", stacks); if (stack === "Enter manually") {