Verifies the source files of a NodeJS package - by running its verify
script within the scripts
section of package.json
.
It is worth noting this action can support any technology - as long as you comply with the requirements described below.
The action can be placed right after checking out the source code:
steps:
- uses: actions/checkout@v4
- uses: giancosta86/aurora-github/actions/verify-npm-package@v4
IMPORTANT: please, remember to declare your verification process in the verify
script within package.json
! For example:
"scripts": {
"test": "vitest",
"build": "tsc",
"verify": "pnpm test && pnpm build"
}
-
Optionally run check-artifact-version, to ensure that the artifact version in
package.json
matches the version detected from the name of the current Git branch. -
Ensure that the package is based on ESM - via the
"type": "module"
attribute inpackage.json
; this default behaviour can be disabled. -
Find critical TODOs in the source code - which crash the workflow by default.
-
Install the required NodeJS version, pnpm and the dependencies, via setup-nodejs-context
-
Run
pnpm verify
- so that the related script inpackage.json
can decide what to do. -
By default, run check-subpath-exports to verify that the
exports
field inpackage.json
actually references existing files.
-
The package manager for the project must be pnpm - version
9
or later compatible. -
The entire verification process for the package must be triggered by the
verify
script inpackage.json
(see the example). -
The root directory of the project must contain a
.nvmrc
file - declaring the required Node.js version - whose format must be compatible with theactions/setup-node
action (for example:vX.Y.Z
). -
The requirements for check-artifact-version, if
check-artifact-version
is enabled.
Name | Type | Description | Default value |
---|---|---|---|
registry-url |
string | The URL of the npm registry | Official npm registry |
frozen-lockfile |
boolean | Fails if pnpm-lock.yaml is missing or outdated |
true |
crash-on-critical-todos |
boolean | Crash the workflow if critical TODOs are found | true |
source-file-regex |
string | PCRE pattern describing the source files | \.(c|m)?(j|t)sx?$ |
check-artifact-version |
boolean | Ensure the version in package.json matches the branch name |
true |
enforce-esm |
boolean | Verify that the type field is module - to create an ESM package |
true |
check-subpath-exports |
boolean | Run check-subpath-exports after the verify package script |
true |
project-directory |
string | The directory containing package.json |
. |
shell |
string | The shell used to run commands | bash |