Skip to content

Commit 2e64bbd

Browse files
author
Fabiana Severin
committed
Changing npm publishing
1 parent 201b966 commit 2e64bbd

File tree

7 files changed

+72
-217
lines changed

7 files changed

+72
-217
lines changed

.github/workflows/build-and-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ jobs:
9898
- name: Setup NPM authentication
9999
run: |
100100
NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id aws-lambda-runtimes/github/nodejs/npm-token --query SecretString --output text)
101-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
101+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
102+
chmod 0600 .npmrc
102103
103104
- name: Determine version and package name
104105
id: version
@@ -117,10 +118,11 @@ jobs:
117118
118119
- name: Publish to npm
119120
run: |
121+
PACKAGE_FILE=$(ls aws-lambda-ric-*.tgz)
120122
if [[ "${{ steps.version.outputs.is_rc }}" == "true" ]]; then
121-
npm publish aws-lambda-ric-*.tgz --tag rc
123+
npm publish $PACKAGE_FILE --tag rc --access=public
122124
else
123-
npm publish aws-lambda-ric-*.tgz
125+
npm publish $PACKAGE_FILE --access=public
124126
fi
125127
126128
- name: Create GitHub Release

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"format": "npm run format:src && npm run format:test",
2121
"format:src": "prettier --check \"src/*.*js\" --write",
2222
"format:test": "prettier --check \"test/**/*.*js\" --write",
23-
"check-headers": "node ./scripts/check-headers.js",
24-
"add-headers": "node ./scripts/add-headers.js",
23+
"check-headers": "./scripts/check-headers.sh",
24+
"add-headers": "./scripts/add-headers.sh",
2525
"lint": "eslint --ext \".js\" src test && npm run check-headers",
2626

2727
"fix": "eslint --fix --ext \".js\" src test",
@@ -68,7 +68,7 @@
6868
"eslint": "8.42.0",
6969
"eslint-config-prettier": "8.8.0",
7070
"eslint-plugin-prettier": "4.2.1",
71-
"glob": "^10.3.10",
71+
7272
"husky": "^8.0.3",
7373
"lambda-runtime": "file:./src/",
7474
"mocha": "^10.8.2",

scripts/add-headers.js

Lines changed: 0 additions & 113 deletions
This file was deleted.

scripts/add-headers.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -e
6+
7+
# Find files missing copyright headers
8+
files=$(git ls-files 'bin/**' 'scripts/**' 'src/**' 'test/**' | \
9+
grep -E '\.(js|ts|mjs|mts|jsx|tsx|c|cpp|h)$' | \
10+
xargs grep -L 'Copyright.*Amazon\.com' || true)
11+
12+
if [ -z "$files" ]; then
13+
echo "✓ All files already have copyright headers"
14+
exit 0
15+
fi
16+
17+
echo "Found $(echo "$files" | wc -l) files missing headers"
18+
19+
# Add headers
20+
for file in $files; do
21+
if [[ "$file" == *.sh ]]; then
22+
header="#!/bin/bash
23+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
24+
# SPDX-License-Identifier: Apache-2.0
25+
26+
"
27+
else
28+
header="/*
29+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
30+
SPDX-License-Identifier: Apache-2.0
31+
*/
32+
33+
"
34+
fi
35+
36+
echo "$header$(cat "$file")" > "$file"
37+
echo "✓ Added header to $file"
38+
done
39+
40+
echo
41+
echo "✓ All copyright headers added successfully"
42+
echo "Run 'git diff' to review changes before committing"

scripts/check-headers.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

scripts/check-headers.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -e
6+
7+
# Find files missing copyright headers
8+
files=$(git ls-files 'bin/**' 'scripts/**' 'src/**' 'test/**' | \
9+
grep -E '\.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$' | \
10+
xargs grep -L 'Copyright.*Amazon\.com' || true)
11+
12+
if [ -n "$files" ]; then
13+
echo "❌ Copyright header check failed."
14+
echo "Files missing required \"Copyright\" and \"Amazon.com\" keywords:"
15+
echo "$files" | sed 's/^/ - /'
16+
echo
17+
echo "Run 'npm run add-headers' to fix these issues."
18+
exit 1
19+
fi
20+
21+
echo "✅ All files have proper copyright headers."

test/unit/check-headers.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { execSync } = require('child_process');
1212
describe('check-headers script', function() {
1313
it('should detect files with proper headers', function() {
1414
// This test file itself has the proper header
15-
const result = execSync('node ./scripts/check-headers.js', {
15+
const result = execSync('./scripts/check-headers.sh', {
1616
env: { ...process.env, NODE_ENV: 'test' },
1717
stdio: 'pipe'
1818
}).toString();

0 commit comments

Comments
 (0)