@zuke/npm

← API reference

`@zuke/npm` — typed `NpmTasks` wrappers for the `npm` CLI, for use in Zuke

Symbols

# NpmAccess type
type NpmAccess = public | restricted

An access level accepted by npm's --access flag.

# NpmCiSettings class
class NpmCiSettings extends NpmSettings

Settings for npm ci.

MemberSignatureDoc
omit omit(type: NpmOmitType): this Skip a dependency group (--omit=dev etc.); repeatable.
# NpmExecSettings class
class NpmExecSettings extends NpmSettings

Settings for npm exec.

MemberSignatureDoc
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 --).
# NpmInstallSettings class
class NpmInstallSettings extends NpmSettings

Settings for npm install.

MemberSignatureDoc
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).
# NpmOmitType type
type NpmOmitType = dev | optional | peer

A dependency group accepted by npm's --omit flag.

# NpmPublishSettings class
class NpmPublishSettings extends NpmSettings

Settings for npm publish.

MemberSignatureDoc
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=).
# NpmRunSettings class
class NpmRunSettings extends NpmSettings

Settings for npm run.

MemberSignatureDoc
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 --).
# NpmSettings class
class NpmSettings extends ToolSettings

Base for all npm subcommand settings: binary is npm from PATH.

# NpmTasks const
const NpmTasks: NpmTasksApi

Typed task functions for the npm CLI.

# NpmTasksApi interface
interface NpmTasksApi

The shape of NpmTasks.

MemberSignatureDoc
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.
# NpmVersionSettings class
class NpmVersionSettings extends NpmSettings

Settings for npm version.

MemberSignatureDoc
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).