Skip to content

fix: CLI CDK context parameter #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@
"type": "node",
"cwd": "${workspaceRoot}/test/cdk-basic"
},
{
"name": "LLDebugger - CDK basic - monorepo",
"program": "${workspaceRoot}/node_modules/tsx/dist/cli.mjs",
"args": [
"../src/lldebugger.ts",
"-c environment=test",
"--subfolder=cdk-basic"
],
// "args": ["../src/lldebugger.ts", "-w"],
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"console": "integratedTerminal",
"type": "node",
"cwd": "${workspaceRoot}/test"
},
{
"name": "LLDebugger - CDK ESM",
"program": "${workspaceRoot}/node_modules/tsx/dist/cli.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/cdkFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ export class CdkFramework implements IFramework {
(acc: Record<string, string>, arg: string) => {
const [key, value] = arg.split('=');
if (key && value) {
acc[key] = value;
acc[key.trim()] = value.trim();
}
return acc;
},
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/cdkFrameworkWorker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parentPort.on('message', async (data) => {
// this is global variable to store the data from the CDK code once it is executed
global.lambdas = [];

Logger.verbose(`[Worker ${workerData.workerId}] Received message`, data);
Logger.verbose(`[Worker] Received message`, data);

// execute code to get the data into global.lambdas
await import(data.compileOutput);
Expand Down
4 changes: 2 additions & 2 deletions test/cdk-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('cdk-basic', async () => {

beforeAll(async () => {
if (process.env.CI === 'true' || process.env.RUN_TEST_FROM_CLI === 'true') {
lldProcess = await startDebugger(folder, ['-c=environment=test']);
lldProcess = await startDebugger(folder, ['-c environment=test']);
}
});

Expand Down Expand Up @@ -139,7 +139,7 @@ describe('cdk-basic', async () => {

test('remove infra', async () => {
if (process.env.CI === 'true' || process.env.RUN_TEST_FROM_CLI === 'true') {
await removeInfra(lldProcess, folder);
await removeInfra(lldProcess, folder, ['-c environment=test']);
const lambdaName = await getFunctionName(
folder,
'FunctionNameTestTsCommonJs',
Expand Down
6 changes: 5 additions & 1 deletion test/cdk-basic/bin/cdk-basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { CdkbasicStack2 } from '../lib/subfolder/cdk-basic-stack2';

const app = new cdk.App();

const environment = 'test';
const environment = app.node.tryGetContext('environment');

if (!environment) {
throw new Error('Environment is not set in the context');
}

new CdkbasicStack(app, 'CdkbasicStack', {
stackName: `${environment}-lld-cdk-basic`,
Expand Down
4 changes: 2 additions & 2 deletions test/cdk-esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('cdk-esm', async () => {

beforeAll(async () => {
if (process.env.CI === 'true' || process.env.RUN_TEST_FROM_CLI === 'true') {
lldProcess = await startDebugger(folder, ['-c=environment=test']);
lldProcess = await startDebugger(folder, ['-c environment=test']);
}
});

Expand Down Expand Up @@ -139,7 +139,7 @@ describe('cdk-esm', async () => {

test('remove infra', async () => {
if (process.env.CI === 'true' || process.env.RUN_TEST_FROM_CLI === 'true') {
await removeInfra(lldProcess, folder);
await removeInfra(lldProcess, folder, ['-c environment=test']);
const lambdaName = await getFunctionName(
folder,
'FunctionNameTestTsCommonJs',
Expand Down
6 changes: 5 additions & 1 deletion test/cdk-esm/bin/cdk-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { CdkEsmStack2 } from '../lib/subfolder/cdk-esm-stack2';

const app = new cdk.App();

const environment = 'test';
const environment = app.node.tryGetContext('environment');

if (!environment) {
throw new Error('Environment is not set in the context');
}

new CdkEsmStack(app, 'CdkEsmStack', {
stackName: `${environment}-lld-cdk-esm`,
Expand Down
2 changes: 1 addition & 1 deletion test/terraform-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('terraform-basic', async () => {

beforeAll(async () => {
if (process.env.CI === 'true' || process.env.RUN_TEST_FROM_CLI === 'true') {
lldProcess = await startDebugger(folder, ['-c=environment=test']);
lldProcess = await startDebugger(folder);
}
});

Expand Down
Loading