Skip to content

Commit 1dca6b3

Browse files
feat: Optimize and clean adding and removing infrastructure
1 parent 9ea0862 commit 1dca6b3

File tree

9 files changed

+736
-498
lines changed

9 files changed

+736
-498
lines changed

.github/workflows/common-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ permissions:
2323
contents: write
2424

2525
env:
26-
DISABLE_PARALLEL_DEPLOY: false
2726
REAL_NPM: ${{ inputs.mode == 'global' || inputs.mode == 'local' }}
2827
TEST_MONOREPO: ${{ inputs.testMonorepo }}
2928
node_version: 22

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configuration.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { LambdaProps } from './types/lambdaProps.js';
21
import { LldConfig } from './types/lldConfig.js';
32
import { LambdaResource } from './types/resourcesDiscovery.js';
43
import * as crypto from 'crypto';
@@ -12,7 +11,7 @@ import { ResourceDiscovery } from './resourceDiscovery.js';
1211
import { Logger } from './logger.js';
1312

1413
let config: LldConfig;
15-
const lambdas: Record<string, LambdaProps> = {};
14+
const lambdas: Record<string, LambdaResource> = {};
1615
let lambdasList: LambdaResource[] | undefined = undefined;
1716

1817
/**
@@ -103,34 +102,43 @@ async function generateDebuggerId(observableMode: boolean) {
103102
* Add a Lambda to the configuration
104103
* @param props
105104
*/
106-
function addLambda(props: Omit<LambdaProps, 'functionId'>) {
105+
function addLambda(props: LambdaResource) {
107106
lambdas[props.functionName] = {
108-
functionId: props.functionName,
109107
...props,
110108
};
111109
}
112110

113111
/**
114-
* Get a Lambda by functionId
115-
* @param functionId
112+
* Get a Lambda by name
113+
* @param functionName
116114
* @returns
117115
*/
118-
async function getLambda(functionId: string): Promise<LambdaProps> {
119-
const lambda = lambdas[functionId];
116+
async function getLambda(functionName: string): Promise<LambdaResource> {
117+
const lambda = lambdas[functionName];
120118

121119
if (lambda) return lambda;
122120

123-
throw new Error(`Lambda not found: ${functionId}`);
121+
throw new Error(`Lambda not found: ${functionName}`);
124122
}
125123

126124
/**
127125
* Get all Lambdas
128126
* @returns
129127
*/
130-
function getLambdas() {
128+
function getLambdasAll(): LambdaResource[] {
131129
return Object.values(lambdas);
132130
}
133131

132+
/**
133+
* Get filtered Lambdas
134+
* @returns
135+
*/
136+
function getLambdasFiltered() {
137+
const list = Object.values(lambdas);
138+
139+
return list.filter((l) => !l.filteredOut);
140+
}
141+
134142
/**
135143
* Discover Lambdas
136144
*/
@@ -180,7 +188,7 @@ function saveDiscoveredLambdas(lambdasListNew: LambdaResource[]) {
180188

181189
Logger.log('Found the following Lambdas to debug:');
182190
Logger.log(
183-
` - ${getLambdas()
191+
` - ${getLambdasFiltered()
184192
.map((f) => `${f.functionName} code: ${f.codePath}`)
185193
.join('\n - ')}`,
186194
);
@@ -205,6 +213,7 @@ export const Configuration = {
205213
},
206214
discoverLambdas,
207215
getLambda,
208-
getLambdas,
216+
getLambdasAll,
217+
getLambdasFiltered,
209218
setConfig,
210219
};

0 commit comments

Comments
 (0)