@bifravst/aws-cdk-lambda-helpers 1.5.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,5 +45,7 @@ export class PackedLambdaFn extends Construct {
45
45
  handler: source.handler,
46
46
  code: new LambdaSource(this, source).code,
47
47
  });
48
+ this.fn.node.addMetadata('packedLambda:id', source.id);
49
+ this.fn.node.addMetadata('packedLambda:hash', source.hash);
48
50
  }
49
51
  }
@@ -2,7 +2,7 @@ export type PackedLayer = {
2
2
  layerZipFile: string;
3
3
  hash: string;
4
4
  };
5
- export declare const packLayer: ({ id, dependencies, baseDir, distDir, }: {
5
+ export declare const packLayer: ({ id, dependencies, baseDir, distDir, installCommand, }: {
6
6
  id: string;
7
7
  dependencies: string[];
8
8
  /**
@@ -13,4 +13,11 @@ export declare const packLayer: ({ id, dependencies, baseDir, distDir, }: {
13
13
  * @default ${baseDir}/dist/layers
14
14
  */
15
15
  distDir?: string;
16
+ /**
17
+ * Returns the command to run, the first element is the command (e.g. `npm`) and the rest are its arguments.
18
+ */
19
+ installCommand?: (args: {
20
+ packageFile: string;
21
+ packageLockFile: string;
22
+ }) => [string, ...Array<string>];
16
23
  }) => Promise<PackedLayer>;
@@ -6,7 +6,7 @@ import path from 'path';
6
6
  import { ZipFile } from 'yazl';
7
7
  import { checkSumOfFiles, checkSumOfStrings } from './checksumOfFiles.js';
8
8
  import { fileURLToPath } from 'node:url';
9
- export const packLayer = async ({ id, dependencies, baseDir, distDir, }) => {
9
+ export const packLayer = async ({ id, dependencies, baseDir, distDir, installCommand, }) => {
10
10
  const base = baseDir ?? process.cwd();
11
11
  const dist = distDir ?? path.join(base, 'dist', 'layers');
12
12
  const packageJsonFile = path.join(base, 'package.json');
@@ -52,7 +52,10 @@ export const packLayer = async ({ id, dependencies, baseDir, distDir, }) => {
52
52
  // pass
53
53
  }
54
54
  await new Promise((resolve, reject) => {
55
- const [cmd, ...args] = [
55
+ const [cmd, ...args] = installCommand?.({
56
+ packageFile: packageJSON,
57
+ packageLockFile: packageLockJsonFile,
58
+ }) ?? [
56
59
  'npm',
57
60
  hasLockFile ? 'ci' : 'i',
58
61
  '--ignore-scripts',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/aws-cdk-lambda-helpers",
3
- "version": "1.5.2",
3
+ "version": "1.7.0",
4
4
  "description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
5
5
  "exports": {
6
6
  ".": {