-
Notifications
You must be signed in to change notification settings - Fork 0
verify npm package #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e8c3fc7
main function
le-cong 26f4f81
handle npmrc
le-cong 8cd39cc
move npmrc handling to the first step
le-cong 9a1e1bb
pass npm auth token
le-cong dcc4834
remove npmrc
le-cong e26e8d2
remove unused import
le-cong f8e16d1
add back NPM_TOKEN
le-cong 2c7d9dd
use NPM_TOKEN_PUBLISH instead
le-cong 6e8e799
put back npmrc
le-cong f28a268
NODE_AUTH_TOKEN
le-cong 71fb7ea
xxx
le-cong 2f66088
1
le-cong 5036f83
2
le-cong b32c182
add npmrc to package folder
le-cong 53247cf
fix coverage, refactor
le-cong 35707eb
npmrc
le-cong 4904446
cleanup
le-cong 968c27c
update dependencies
le-cong 9f7b39e
use npm import approach
le-cong 63dc2ae
bump MINOR version, fix flaky tests, refactor tests
le-cong 736a28c
swap expected/actual values in the assertion so that the displayed er…
le-cong f083b5a
address carl's comments
le-cong dfacc90
update dependencies
le-cong 9b1a9dd
refactoring
le-cong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: ['20.x', '21.x'] | ||
| node-version: ['20.x', '22.x'] | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -30,13 +30,15 @@ jobs: | |
| run: npm run ci:lint | ||
| - name: Run Tests | ||
| run: npm run ci:test | ||
| env: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed to pass tests which access npm |
||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH }} | ||
|
|
||
| branchBuild: | ||
| name: Branch Build | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: ['20.x', '21.x'] | ||
| node-version: ['20.x', '22.x'] | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -57,3 +59,5 @@ jobs: | |
| run: npm run ci:lint | ||
| - name: Run Tests | ||
| run: npm run ci:test | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // check-imports/check-imports.ts | ||
|
|
||
| import { strict as assert } from 'node:assert'; | ||
|
|
||
| import debug from 'debug'; | ||
|
|
||
| import { extractPackageName, getPackageLock, satisfiesNameAndRange } from './package-lock-file-util'; | ||
| import notAllowed from './packages-not-allowed'; | ||
|
|
||
| const log = debug('github-actions:check-imports'); | ||
|
|
||
| export default async function main(): Promise<void> { | ||
| log('Action starting'); | ||
|
|
||
| const { packages } = await getPackageLock(process.cwd()); | ||
|
|
||
| log('Reviewing package-lock'); | ||
| for (const key in packages) { | ||
| if (Object.hasOwn(packages, key)) { | ||
| const descriptor = packages[key]; | ||
| assert.ok(descriptor !== undefined, 'Package version is missing'); | ||
| const packageVersion = descriptor.version; | ||
| const packageName = extractPackageName(key); | ||
|
|
||
| for (const [name, range, reason] of notAllowed) { | ||
| if (satisfiesNameAndRange(packageName, packageVersion, [name, range])) { | ||
| throw new Error( | ||
| `Package ${packageName}@${packageVersion} is not allowed to be imported because it is included in ${JSON.stringify( | ||
| [name, range], | ||
| )}. Package ${name}@${range} is not allowed for the following reason: ${reason}`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| log('Action end'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,5 @@ | ||
| // check-imports/index.ts | ||
|
|
||
| import { strict as assert } from 'node:assert'; | ||
| import main from './check-imports'; | ||
|
|
||
| import debug from 'debug'; | ||
|
|
||
| import { extractPackageName, getPackageLock, satisfiesNameAndRange } from './package-lock-file-util'; | ||
| import notAllowed from './packages-not-allowed'; | ||
|
|
||
| const log = debug('check-imports'); | ||
| export async function main(): Promise<void> { | ||
| log('Action starting'); | ||
|
|
||
| const { packages } = await getPackageLock(process.cwd()); | ||
|
|
||
| log('Reviewing package-lock'); | ||
| for (const key in packages) { | ||
| if (Object.hasOwn(packages, key)) { | ||
| const descriptor = packages[key]; | ||
| assert.ok(descriptor !== undefined, 'Package version is missing'); | ||
| const packageVersion = descriptor.version; | ||
| const packageName = extractPackageName(key); | ||
|
|
||
| for (const [name, range, reason] of notAllowed) { | ||
| if (satisfiesNameAndRange(packageName, packageVersion, [name, range])) { | ||
| throw new Error( | ||
| `Package ${packageName}@${packageVersion} is not allowed to be imported because it is included in ${JSON.stringify( | ||
| [name, range], | ||
| )}. Package ${name}@${range} is not allowed for the following reason: ${reason}`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| main() | ||
| .then(() => { | ||
| process.stdin.destroy(); | ||
| // eslint-disable-next-line unicorn/no-process-exit | ||
| process.exit(0); | ||
| }) | ||
| // eslint-disable-next-line unicorn/prefer-top-level-await | ||
| .catch((error) => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('Action Error - exit 1 - error:', error); | ||
| // eslint-disable-next-line unicorn/no-process-exit | ||
| process.exit(1); | ||
| }); | ||
| await main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be updated to use 20.x/22.x now