@zuke/npm
`@zuke/npm` — typed `NpmTasks` wrappers for the `npm` CLI, for use in Zuke
@zuke/npm on JSR ↗ 11 symbols
Symbols
type NpmAccess = public | restricted An access level accepted by npm's --access flag.
class NpmCiSettings extends NpmSettings Settings for npm ci.
| Member | Signature | Doc |
|---|---|---|
omit | omit(type: NpmOmitType): this | Skip a dependency group (--omit=dev etc.); repeatable. |
class NpmExecSettings extends NpmSettings Settings for npm exec.
| Member | Signature | Doc |
|---|---|---|
command | command(name: string): this | The command to execute (required). |
package | package(spec: string): this | The package providing the command (--package=). |
yes | yes(): this | Skip the install prompt (--yes). |
execArgs | execArgs(...args: Array<string | number>): this | Arguments forwarded to the command (after --). |
class NpmInstallSettings extends NpmSettings Settings for npm install.
| Member | Signature | Doc |
|---|---|---|
packages | packages(...specs: string[]): this | Package specs to install; omit to install from package.json. |
saveDev | saveDev(): this | Save to devDependencies (--save-dev). |
saveExact | saveExact(): this | Pin exact versions (--save-exact). |
type NpmOmitType = dev | optional | peer A dependency group accepted by npm's --omit flag.
class NpmPublishSettings extends NpmSettings Settings for npm publish.
| Member | Signature | Doc |
|---|---|---|
tag | tag(name: string): this | Publish under a dist-tag (--tag=). |
access | access(level: NpmAccess): this | Set the package access level (--access=). |
dryRun | dryRun(): this | Report what would be published without uploading (--dry-run). |
otp | otp(code: string): this | Provide a one-time password (--otp=). |
class NpmRunSettings extends NpmSettings Settings for npm run.
| Member | Signature | Doc |
|---|---|---|
script | script(name: string): this | The package.json script to run (required). |
workspace | workspace(name: string): this | Run in a specific workspace (--workspace=). |
workspaces | workspaces(): this | Run the script in every workspace (--workspaces). Pair with ifPresent to skip workspaces that lack the script. Mutually exclusive with workspace — setting both is a build error. |
ifPresent | ifPresent(): this | Do not fail when the script is missing (--if-present). |
scriptArgs | scriptArgs(...args: Array<string | number>): this | Arguments forwarded to the script (after --). |
class NpmSettings extends ToolSettings Base for all npm subcommand settings: binary is npm from PATH.
const NpmTasks: NpmTasksApi Typed task functions for the npm CLI.
interface NpmTasksApi The shape of NpmTasks.
| Member | Signature | Doc |
|---|---|---|
install | install(configure?: Configure<NpmInstallSettings>): Promise<CommandOutput> | Install dependencies: npm install. |
ci | ci(configure?: Configure<NpmCiSettings>): Promise<CommandOutput> | Clean install from the lockfile: npm ci. |
run | run(configure?: Configure<NpmRunSettings>): Promise<CommandOutput> | Run a package.json script: npm run. |
exec | exec(configure?: Configure<NpmExecSettings>): Promise<CommandOutput> | Execute a package binary: npm exec. |
publish | publish(configure?: Configure<NpmPublishSettings>): Promise<CommandOutput> | Publish the package: npm publish. |
version | version(configure?: Configure<NpmVersionSettings>): Promise<CommandOutput> | Bump the package version: npm version. |
class NpmVersionSettings extends NpmSettings Settings for npm version.
| Member | Signature | Doc |
|---|---|---|
bump | bump(value: string): this | The bump: patch | minor | major or an explicit semver (required). |
message | message(text: string): this | Commit message; %s expands to the new version (--message). |
noGitTagVersion | noGitTagVersion(): this | Do not create a git commit and tag (--no-git-tag-version). |