Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Aug 13, 2024
1 parent 0dca70f commit 4db1acc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
29 changes: 28 additions & 1 deletion src/commands/import/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const baseFile = require("../../shared/baseFile.json");
const templateAnatomy = require("../../shared/templateAnatomy.json");
const lambdaHandlerParser = require("../../shared/lambdaHandlerParser");
const fs = require("fs");
const path = require("path");
const _ = require("lodash");
const runtimes = require("../../shared/runtimes.json");
const templateType = "SAM"; // to allow for more template frameworks
Expand All @@ -28,7 +29,33 @@ async function run(cmd) {

const patterns = await githubUtil.getPatterns(cmd.sourceFilter);

const files = fs.readdirSync(path.join(__dirname, "/simple-resources"));

patterns.unshift(new Separator("Community patterns"));
for (const file of files.filter((p) => p.endsWith(".yaml"))) {
patterns.unshift({
name: file.replace(".yaml", ""),
value: {
basic: true,
name: file.replace(".yaml", "")
}
})
}
patterns.unshift(new Separator("Simple resources"));

console.log(JSON.stringify(patterns, null, 2));

const pattern = await inputUtil.autocomplete("Select pattern", patterns);

if (pattern.basic) {
const snippet = fs.readFileSync(
path.join(__dirname, `/simple-resources/${pattern.name}.yaml`)
);
const snippetJson = { Resources: parser.parse("import", snippet) };
mergeWithExistingResource(ownTemplate, [], snippetJson);
return;
}

let templateString;
for (const fileName of pattern.setting.fileNames) {
try {
Expand Down Expand Up @@ -159,7 +186,7 @@ async function handleStepFunctionsActions(template, block, name, pattern, aslFor
template[block.section][name].Properties.DefinitionUri = definitionUri;
}
}
}
}
}

async function importASL(
Expand Down
5 changes: 3 additions & 2 deletions src/commands/local/lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (!fs.existsSync(".lambda-debug") || !certData) {
const createKeysAndCertificate = async () => {

const homeDir = os.homedir();
const certPath = path.join(homeDir, '.lambda-debug', `certificate-${accountId}.json`);
const certPath = path.join(homeDir, '.lambda-debug', `certificate-${accountId}-${targetConfig.region}.json`);
let response;
if (fs.existsSync(certPath)) {
response = JSON.parse(fs.readFileSync(certPath));
Expand All @@ -87,7 +87,7 @@ if (!fs.existsSync(".lambda-debug") || !certData) {
certData = await createKeysAndCertificate();

const getIotEndpoint = async () => {
const cachePath = path.join(os.homedir(), ".lambda-debug", `endpoint-${accountId}.txt`);
const cachePath = path.join(os.homedir(), ".lambda-debug", `endpoint-${accountId}-${targetConfig.region}.txt`);
if (fs.existsSync(cachePath)) {
return fs.readFileSync(cachePath).toString(); q
}
Expand Down Expand Up @@ -134,6 +134,7 @@ if (!fs.existsSync(".lambda-debug") || !certData) {
}
};
const attachPolicy = async () => {
console.log("Attaching policy", certData);
const attachPolicyCommand = new AttachPolicyCommand({
policyName: policyName,
target: certData.certificateArn
Expand Down
1 change: 0 additions & 1 deletion src/commands/powertools/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const program = require("commander");
const powertools = require("./powertools");
const runtimeFinder = require('../../shared/runtime-env-finder');
program
.command("powertools")
.alias("pt")
Expand Down

0 comments on commit 4db1acc

Please sign in to comment.