Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Jul 16, 2023
1 parent 91fdd92 commit fc08258
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/commands/local/cdk-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/commands/local/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit fc08258

Please sign in to comment.