@bifravst/aws-cdk-lambda-helpers 1.3.0 → 1.3.2

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.
package/dist/src/cdk.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './LambdaSource.js';
2
2
  export * from './LambdaLogGroup.js';
3
+ export * from './IoTActionRole.js';
package/dist/src/cdk.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './LambdaSource.js';
2
2
  export * from './LambdaLogGroup.js';
3
+ export * from './IoTActionRole.js';
@@ -1,2 +1,2 @@
1
1
  import { type PackedLambda } from './packLambda.js';
2
- export declare const packLambdaFromPath: (id: string, sourceFile: string, handlerFunction?: string, baseDir?: string) => Promise<PackedLambda>;
2
+ export declare const packLambdaFromPath: (id: string, sourceFile: string, handlerFunction?: string, baseDir?: string, distDir?: string) => Promise<PackedLambda>;
@@ -1,16 +1,24 @@
1
1
  import { mkdir } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { packLambda } from './packLambda.js';
4
- export const packLambdaFromPath = async (id, sourceFile, handlerFunction = 'handler', baseDir = process.cwd()) => {
4
+ export const packLambdaFromPath = async (id, sourceFile, handlerFunction = 'handler',
5
+ /**
6
+ * @default process.cwd()
7
+ */
8
+ baseDir = process.cwd(),
9
+ /**
10
+ * @default ${baseDir}/dist/lambdas
11
+ */
12
+ distDir = path.join(process.cwd(), 'dist', 'lambdas')) => {
5
13
  try {
6
- await mkdir(path.join(process.cwd(), 'dist', 'lambdas'), {
14
+ await mkdir(distDir, {
7
15
  recursive: true,
8
16
  });
9
17
  }
10
18
  catch {
11
19
  // Directory exists
12
20
  }
13
- const zipFile = path.join(process.cwd(), 'dist', 'lambdas', `${id}.zip`);
21
+ const zipFile = path.join(distDir, `${id}.zip`);
14
22
  const { handler, hash } = await packLambda({
15
23
  sourceFile: path.join(baseDir, sourceFile),
16
24
  zipFile,
@@ -2,7 +2,15 @@ export type PackedLayer = {
2
2
  layerZipFile: string;
3
3
  hash: string;
4
4
  };
5
- export declare const packLayer: ({ id, dependencies, }: {
5
+ export declare const packLayer: ({ id, dependencies, baseDir, distDir, }: {
6
6
  id: string;
7
7
  dependencies: string[];
8
+ /**
9
+ * @default process.cwd()
10
+ */
11
+ baseDir?: string;
12
+ /**
13
+ * @default ${baseDir}/dist/layers
14
+ */
15
+ distDir?: string;
8
16
  }) => Promise<PackedLayer>;
@@ -6,11 +6,13 @@ 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, }) => {
10
- const packageJsonFile = path.join(process.cwd(), 'package.json');
11
- const packageLockJsonFile = path.join(process.cwd(), 'package-lock.json');
9
+ export const packLayer = async ({ id, dependencies, baseDir, distDir, }) => {
10
+ const base = baseDir ?? process.cwd();
11
+ const dist = distDir ?? path.join(base, 'dist', 'layers');
12
+ const packageJsonFile = path.join(base, 'package.json');
13
+ const packageLockJsonFile = path.join(base, 'package-lock.json');
12
14
  const { dependencies: deps, devDependencies: devDeps } = JSON.parse(await readFile(packageJsonFile, 'utf-8'));
13
- const layerDir = path.join(process.cwd(), 'dist', 'layers', id);
15
+ const layerDir = path.join(dist, id);
14
16
  const nodejsDir = path.join(layerDir, 'nodejs');
15
17
  try {
16
18
  await rm(layerDir, { recursive: true });
@@ -62,7 +64,7 @@ export const packLayer = async ({ id, dependencies, }) => {
62
64
  zipfile.addFile(path.join(layerDir, f), f);
63
65
  });
64
66
  const zipFileName = await new Promise((resolve) => {
65
- const zipFileName = path.join(process.cwd(), 'dist', 'layers', `${id}.zip`);
67
+ const zipFileName = path.join(base, 'dist', 'layers', `${id}.zip`);
66
68
  zipfile.outputStream
67
69
  .pipe(createWriteStream(zipFileName))
68
70
  .on('close', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/aws-cdk-lambda-helpers",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
5
5
  "exports": {
6
6
  ".": {