@bifravst/aws-cdk-lambda-helpers 3.4.42 → 3.5.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.
@@ -10,6 +10,7 @@ export const packLayer = async ({ id, dependencies, baseDir, distDir, installCom
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');
13
+ const npmrcFile = path.join(base, '.npmrc');
13
14
  const packageLockJsonFile = path.join(base, 'package-lock.json');
14
15
  const { dependencies: deps, devDependencies: devDeps } = JSON.parse(await readFile(packageJsonFile, 'utf-8'));
15
16
  const layerDir = path.join(dist, id);
@@ -41,6 +42,15 @@ export const packLayer = async ({ id, dependencies, baseDir, distDir, installCom
41
42
  dependencies: depsToBeInstalled
42
43
  }), 'utf-8');
43
44
  checkSumFiles.push(packageJSON);
45
+ let hasNpmRcFile = true;
46
+ try {
47
+ // .npmrc may not exist
48
+ await stat(npmrcFile);
49
+ await copyFile(npmrcFile, path.join(nodejsDir, '.npmrc'));
50
+ checkSumFiles.push(npmrcFile);
51
+ } catch {
52
+ hasNpmRcFile = false;
53
+ }
44
54
  let hasLockFile = true;
45
55
  try {
46
56
  // package-lock.json may not exist
@@ -82,6 +92,9 @@ export const packLayer = async ({ id, dependencies, baseDir, distDir, installCom
82
92
  filesToAdd.forEach((f)=>{
83
93
  zipfile.addFile(path.join(layerDir, f), f);
84
94
  });
95
+ if (hasNpmRcFile) {
96
+ zipfile.addFile(path.join(nodejsDir, '.npmrc'), 'nodejs/.npmrc');
97
+ }
85
98
  const zipFileName = await new Promise((resolve)=>{
86
99
  const zipFileName = path.join(dist, `${id}.zip`);
87
100
  zipfile.outputStream.pipe(createWriteStream(zipFileName)).on('close', ()=>{
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path, { dirname } from 'node:path';
5
+ import { describe, it } from 'node:test';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { packLayer } from './packLayer.js';
8
+ import { getFileFromZip } from './test/getFileFromZip.js';
9
+ const tmpDir = os.tmpdir();
10
+ await describe('packLayer()', async ()=>{
11
+ await it('should include a .npmrc file if present', async ()=>{
12
+ const distDir = path.join(await fs.mkdtemp(`${tmpDir}${path.sep}`), 'jsr');
13
+ const layer = await packLayer({
14
+ baseDir: path.join(dirname(fileURLToPath(import.meta.url)), 'test-data', 'jsr'),
15
+ distDir,
16
+ id: 'jsr-layer',
17
+ dependencies: [
18
+ '@nrfcloud/wait-for-it'
19
+ ]
20
+ });
21
+ const npmrc = await getFileFromZip(layer.layerZipFilePath, 'nodejs/.npmrc');
22
+ assert.equal(npmrc.includes(`@jsr:registry=https://npm.jsr.io`), true, 'The .npmrc file should contain the JSR registry');
23
+ });
24
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/aws-cdk-lambda-helpers",
3
- "version": "3.4.42",
3
+ "version": "3.5.0",
4
4
  "description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
5
5
  "exports": {
6
6
  ".": {
@@ -54,7 +54,7 @@
54
54
  "license": "BSD-3-Clause",
55
55
  "devDependencies": {
56
56
  "@aws-sdk/client-cloudformation": "3.864.0",
57
- "@aws-sdk/client-dynamodb": "3.864.0",
57
+ "@aws-sdk/client-dynamodb": "3.868.0",
58
58
  "@bifravst/cloudformation-helpers": "9.1.1",
59
59
  "@bifravst/eslint-config-typescript": "6.4.3",
60
60
  "@bifravst/from-env": "3.0.2",
@@ -65,7 +65,7 @@
65
65
  "@types/node": "24.2.1",
66
66
  "@types/unzip-stream": "0.3.4",
67
67
  "@types/yazl": "3.3.0",
68
- "cdk": "2.1024.0",
68
+ "cdk": "2.1025.0",
69
69
  "commitlint": "19.8.1",
70
70
  "husky": "9.1.7",
71
71
  "id128": "1.6.6",