zuke.tools.npm
@zuke/npm 1.3.1: @zuke/npm — typed NpmTasks wrappers for the npm CLI, for use in Zuke build targets (including builds that drive Node projects).
zuke on PyPI ↗ 35 symbols
Symbols
class NpmAccessSettings(NpmSettings) Settings for npm access.
-
list_packages(owner: str | None=None, pkg: str | None=None) -> SelfList the packages a user, scope, or team can reach (
access list packages). -
list_collaborators(pkg: str | None=None, user: str | None=None) -> SelfList a package's collaborators (
access list collaborators). -
get_status(pkg: str | None=None) -> SelfRead whether a package is public or private (
access get status), the default. -
set_status(level: Literal['public', 'private'], pkg: str | None=None) -> SelfSet a package public or private (
access set status=<level>). -
set_mfa(mode: Literal['none', 'publish', 'automation'], pkg: str | None=None) -> SelfRequire two-factor auth for publishing (
access set mfa=<mode>). -
grant(permission: Literal['read-only', 'read-write'], team: str, pkg: str | None=None) -> SelfGive a team access (
access grant <permission> <scope:team>). -
revoke(team: str, pkg: str | None=None) -> SelfTake a team's access away (
access revoke <scope:team>). -
otp(code: str) -> SelfProvide a one-time password. Carried in
npm_config_otprather than on the command line — see NpmSettings.applyOtp for why.
class NpmAuditSettings(NpmWorkspaceSettings) Settings for npm audit.
-
fix() -> SelfInstall compatible updates for what it finds (
npm audit fix). -
signatures() -> SelfVerify the registry signatures of what is installed (
npm audit signatures). -
audit_level(level: Literal['info', 'low', 'moderate', 'high', 'critical', 'none']) -> SelfThe severity at which the command fails (
--audit-level=<info|low|moderate|high|critical|none>). -
omit(*types: Literal['dev', 'optional', 'peer']) -> SelfSkip a dependency group (
--omit=<group>); repeatable. -
include(*types: Literal['prod', 'dev', 'optional', 'peer']) -> SelfKeep a dependency group npm would otherwise omit (
--include=<group>); repeatable. -
package_lock_only() -> SelfAudit the lockfile without touching
node_modules(--package-lock-only). -
dry_run() -> SelfReport what a fix would change without changing it (
--dry-run).
class NpmCacheSettings(NpmSettings) Settings for npm cache. Pick the operation with add, clean, ls, or verify.
-
add(*specs: str) -> SelfAdd a package to the cache (
cache add <spec>). -
clean(key: str | None=None) -> SelfEmpty the cache (
cache clean). npm refuses this without--force, so pair it with force — see the error this reports otherwise. -
ls(*specs: str) -> SelfList what the cache holds (
cache ls). -
verify() -> SelfCheck and compact the cache (
cache verify), the default. -
cache(path: str) -> SelfUse a specific cache directory (
--cache=<path>). -
force() -> SelfConfirm a clean npm would otherwise refuse (
--force).
class NpmCiSettings(NpmDependencySettings) Settings for npm ci.
-
no_audit() -> SelfSkip the audit npm runs after installing (
--no-audit). -
no_fund() -> SelfSkip the funding message (
--no-fund).
class NpmConfigSettings(NpmSettings) Settings for npm config. Pick the operation with get, set, deleteKeys, list, or fix.
-
get(*keys: str) -> SelfRead config keys (
config get <key>...). -
set(*assignments: str) -> SelfWrite config keys (
config set <key>=<value>...). -
delete_keys(*keys: str) -> SelfRemove config keys (
config delete <key>...). -
list() -> SelfList the effective configuration (
config list). -
fix() -> SelfRepair invalid config entries (
config fix). -
location(where: Literal['global', 'user', 'project']) -> SelfWhich file to read or write (
--location=<global|user|project>). -
long() -> SelfInclude defaults in a listing (
--long).
class NpmDedupeSettings(NpmDependencySettings) Settings for npm dedupe.
-
dry_run() -> SelfReport what would move without changing the tree (
--dry-run).
class NpmDependencySettings(NpmWorkspaceSettings) Shared base for the install-shaped commands: the --omit/--include dependency-group selectors npm accepts on all of them, plus the package specs most of them take.
-
packages(*specs: str) -> SelfPackage specs the command operates on (positional); repeatable.
-
omit(*types: Literal['dev', 'optional', 'peer']) -> SelfSkip a dependency group (
--omit=<group>); repeatable. -
include(*types: Literal['prod', 'dev', 'optional', 'peer']) -> SelfKeep a dependency group npm would otherwise omit (
--include=<group>); repeatable. -
ignore_scripts() -> SelfDo not run lifecycle scripts (
--ignore-scripts). -
foreground_scripts() -> SelfShow lifecycle-script output as it runs (
--foreground-scripts).
class NpmDeprecateSettings(NpmSettings) Settings for npm deprecate.
-
spec(value: str) -> SelfThe package spec to deprecate, e.g.
app@<2(required). -
message(text: str) -> SelfThe warning installers will see (required). An empty message is how npm *un*-deprecates a version, so it must be given deliberately rather than by omission.
-
otp(code: str) -> SelfProvide a one-time password. Carried in
npm_config_otprather than on the command line — see NpmSettings.applyOtp for why.
class NpmDistTagSettings(NpmWorkspaceSettings) Settings for npm dist-tag. Pick the subcommand with add, rm, or ls.
-
add(spec: str, tag: str | None=None) -> SelfPoint a tag at a published version (
dist-tag add <pkg@version> [<tag>]). The spec must carry the version; a tag cannot point at a range. With no tag npm useslatest, as it does on the command line. -
rm(spec: str, tag: str) -> SelfRemove a tag (
dist-tag rm <pkg> <tag>). -
ls(spec: str | None=None) -> SelfList a package's tags (
dist-tag ls [<pkg>]), the default.
class NpmExecSettings(NpmWorkspaceSettings) Settings for npm exec.
-
command(name: str) -> SelfThe command to execute (required).
-
package(spec: str) -> SelfThe package providing the command (
--package=). -
yes() -> SelfSkip the install prompt (
--yes). -
no() -> SelfRefuse to install anything (
--no), so the command runs only if it is already present — what a hermetic CI step wants instead of a silent fetch. -
exec_args(*args: str | float) -> SelfArguments forwarded to the command (after
--).
class NpmInitSettings(NpmWorkspaceSettings) Settings for npm init.
-
initializer(spec: str) -> SelfThe initializer package to run, e.g.
vitefornpm init vite(positional). With none, npm writes apackage.jsonitself. -
yes() -> SelfAccept the defaults instead of prompting (
--yes). -
scope(name: str) -> SelfScope the created package (
--scope=<@scope>). -
init_args(*args: str | float) -> SelfArguments forwarded to the initializer (after
--).
class NpmInstallSettings(NpmDependencySettings) Settings for npm install.
-
save_dev() -> SelfSave to devDependencies (
--save-dev). -
save_optional() -> SelfSave to optionalDependencies (
--save-optional). -
save_peer() -> SelfSave to peerDependencies (
--save-peer). -
save_exact() -> SelfPin exact versions (
--save-exact). -
no_save() -> SelfInstall without recording the dependency (
--no-save). -
install_strategy(strategy: Literal['hoisted', 'nested', 'shallow', 'linked']) -> SelfHow npm lays out the tree (
--install-strategy=<strategy>). -
no_audit() -> SelfSkip the audit npm runs after installing (
--no-audit). -
no_fund() -> SelfSkip the funding message (
--no-fund).
class NpmLinkSettings(NpmDependencySettings) Settings for npm link.
-
save_dev() -> SelfRecord the linked package in devDependencies (
--save-dev).
class NpmLsSettings(NpmWorkspaceSettings) Settings for npm ls.
-
spec(value: str) -> SelfLimit the listing to one package spec (positional).
-
depth(levels: float) -> SelfHow deep to walk the tree (
--depth=<n>);0lists direct dependencies. -
all() -> SelfShow every dependency, not just the top level (
--all). -
long() -> SelfInclude extended information (
--long). -
parseable() -> SelfEmit one line per package, tab-separated (
--parseable). -
omit(*types: Literal['dev', 'optional', 'peer']) -> SelfSkip a dependency group (
--omit=<group>); repeatable.
class NpmOutdatedSettings(NpmWorkspaceSettings) Settings for npm outdated.
-
packages(*specs: str) -> SelfLimit the report to these package specs (positional); repeatable.
-
all() -> SelfReport transitive dependencies too (
--all). -
long() -> SelfInclude the package type and homepage (
--long).
class NpmOwnerSettings(NpmWorkspaceSettings) Settings for npm owner.
-
add(user: str, pkg: str) -> SelfAdd a maintainer (
owner add <user> <pkg>). -
rm(user: str, pkg: str) -> SelfRemove a maintainer (
owner rm <user> <pkg>). -
ls(pkg: str) -> SelfList a package's maintainers (
owner ls <pkg>). -
otp(code: str) -> SelfProvide a one-time password. Carried in
npm_config_otprather than on the command line — see NpmSettings.applyOtp for why.
class NpmPackSettings(NpmWorkspaceSettings) Settings for npm pack.
-
packages(*specs: str) -> SelfPackage specs to pack (positional); defaults to the current project.
-
pack_destination(dir: str) -> SelfWhere to write the tarball (
--pack-destination=<dir>). -
dry_run() -> SelfReport what would be packed without writing a tarball (
--dry-run).
class NpmPingSettings(NpmSettings) Settings for npm ping.
class NpmPkgSettings(NpmWorkspaceSettings) Settings for npm pkg. Pick the operation with get, set, deleteKeys, or fix.
-
get(*keys: str) -> SelfRead one or more
package.jsonfields (pkg get <key>...). -
set(*assignments: str) -> SelfWrite fields (
pkg set <key>=<value>...). Each argument is npm's ownkey=valueform, which is also how it addresses arrays and nested keys. -
delete_keys(*keys: str) -> SelfRemove fields (
pkg delete <key>...). -
fix() -> SelfRepair what npm can correct automatically (
pkg fix). -
force() -> SelfSkip npm's confirmation for a destructive edit (
--force).
class NpmPruneSettings(NpmDependencySettings) Settings for npm prune.
-
dry_run() -> SelfReport what would be removed without removing it (
--dry-run).
class NpmPublishSettings(NpmWorkspaceSettings) Settings for npm publish.
-
tag(name: str) -> SelfPublish under a dist-tag (
--tag=). -
access(level: Literal['public', 'restricted']) -> SelfSet the package access level (
--access=). -
dry_run() -> SelfReport what would be published without uploading (
--dry-run). -
otp(code: str) -> SelfProvide a one-time password. Carried in
npm_config_otprather than on the command line — see NpmSettings.applyOtp for why. -
provenance() -> SelfPublish with a provenance attestation (
--provenance), which npm can generate from a trusted CI run — the supply-chain signal a consumer can verify against the workflow that built the tarball.
class NpmRebuildSettings(NpmDependencySettings) Settings for npm rebuild.
-
no_bin_links() -> SelfDo not create the
.binsymlinks (--no-bin-links).
class NpmRunSettings(NpmWorkspaceSettings) Settings for npm run.
-
script(name: str) -> SelfThe package.json script to run (required).
-
if_present() -> SelfDo not fail when the script is missing (
--if-present). -
script_args(*args: str | float) -> SelfArguments forwarded to the script (after
--).
class NpmSbomSettings(NpmWorkspaceSettings) Settings for npm sbom.
-
sbom_format(format: Literal['cyclonedx', 'spdx']) -> SelfWhich document to emit (
--sbom-format=<cyclonedx|spdx>), required by npm. -
sbom_type(type_: Literal['library', 'application', 'framework']) -> SelfWhat the project is (
--sbom-type=<library|application|framework>). -
omit(*types: Literal['dev', 'optional', 'peer']) -> SelfSkip a dependency group (
--omit=<group>); repeatable. -
package_lock_only() -> SelfBuild the document from the lockfile alone (
--package-lock-only).
class NpmSettings(ToolSettings) Shared base for every npm subcommand: the binary, and the flags npm treats as configuration rather than as a command's own — it accepts these on any command, which is why they live here instead of being repeated.
-
registry(url: str) -> SelfUse a specific registry (
--registry=<url>). -
json() -> SelfEmit JSON (
--json). The value-returning tasks set this themselves; a caller reaches for it to parse output the wrapper does not yet model. -
log_level(level: Literal['silent', 'error', 'warn', 'notice', 'http', 'info', 'verbose', 'silly']) -> SelfHow much npm prints (
--loglevel=<level>). -
global_() -> SelfOperate on the global install rather than the project (
--global). -
prefix(path: str) -> SelfRun as if npm were started in this directory (
--prefix=<path>). -
userconfig(path: str) -> SelfRead this user config file rather than
~/.npmrc(--userconfig=<path>).
class NpmTasks Typed task functions for the npm CLI.
-
static async install(ctx: ServiceContext, configure: Callable[[NpmInstallSettings], NpmInstallSettings] | None=None) -> ExecResultInstall dependencies:
npm install. -
static async ci(ctx: ServiceContext, configure: Callable[[NpmCiSettings], NpmCiSettings] | None=None) -> ExecResultClean install from the lockfile:
npm ci. -
static async uninstall(ctx: ServiceContext, configure: Callable[[NpmUninstallSettings], NpmUninstallSettings] | None=None) -> ExecResultRemove dependencies:
npm uninstall. -
static async update(ctx: ServiceContext, configure: Callable[[NpmUpdateSettings], NpmUpdateSettings] | None=None) -> ExecResultUpdate dependencies within their ranges:
npm update. -
static async dedupe(ctx: ServiceContext, configure: Callable[[NpmDedupeSettings], NpmDedupeSettings] | None=None) -> ExecResultFlatten duplicated packages:
npm dedupe. -
static async prune(ctx: ServiceContext, configure: Callable[[NpmPruneSettings], NpmPruneSettings] | None=None) -> ExecResultRemove packages nothing depends on:
npm prune. -
static async rebuild(ctx: ServiceContext, configure: Callable[[NpmRebuildSettings], NpmRebuildSettings] | None=None) -> ExecResultRebuild native packages:
npm rebuild. -
static async link(ctx: ServiceContext, configure: Callable[[NpmLinkSettings], NpmLinkSettings] | None=None) -> ExecResultSymlink a package for local development:
npm link. -
static async run(ctx: ServiceContext, configure: Callable[[NpmRunSettings], NpmRunSettings] | None=None) -> ExecResultRun a package.json script:
npm run. -
static async test(ctx: ServiceContext, configure: Callable[[NpmTestSettings], NpmTestSettings] | None=None) -> ExecResultRun the project's test script:
npm test. -
static async exec(ctx: ServiceContext, configure: Callable[[NpmExecSettings], NpmExecSettings] | None=None) -> ExecResultExecute a package binary:
npm exec. -
static async publish(ctx: ServiceContext, configure: Callable[[NpmPublishSettings], NpmPublishSettings] | None=None) -> ExecResultPublish the package:
npm publish. -
static async pack(ctx: ServiceContext, configure: Callable[[NpmPackSettings], NpmPackSettings] | None=None) -> ExecResultBuild a tarball without publishing it:
npm pack. -
static async version(ctx: ServiceContext, configure: Callable[[NpmVersionSettings], NpmVersionSettings] | None=None) -> ExecResultBump the package version:
npm version. -
static async unpublish(ctx: ServiceContext, configure: Callable[[NpmUnpublishSettings], NpmUnpublishSettings] | None=None) -> ExecResultRemove a published version:
npm unpublish. -
static async deprecate(ctx: ServiceContext, configure: Callable[[NpmDeprecateSettings], NpmDeprecateSettings] | None=None) -> ExecResultWarn installers off a version:
npm deprecate. -
static async dist_tag(ctx: ServiceContext, configure: Callable[[NpmDistTagSettings], NpmDistTagSettings] | None=None) -> ExecResultManage dist-tags:
npm dist-tag add|rm|ls. -
static async view(ctx: ServiceContext, configure: Callable[[NpmViewSettings], NpmViewSettings] | None=None) -> ExecResultRead registry metadata:
npm view. -
static async ping(ctx: ServiceContext, configure: Callable[[NpmPingSettings], NpmPingSettings] | None=None) -> ExecResultCheck the registry is reachable:
npm ping. -
static async whoami(ctx: ServiceContext, configure: Callable[[NpmWhoamiSettings], NpmWhoamiSettings] | None=None) -> ExecResultPrint the authenticated user:
npm whoami. -
static async whoami_name(ctx: ServiceContext, configure: Callable[[NpmWhoamiSettings], NpmWhoamiSettings] | None=None) -> objectThe authenticated user's name, or
undefinedwhen this machine is not logged in — an answer a release target can act on, rather than the non-zero exit npm reports. -
static async access(ctx: ServiceContext, configure: Callable[[NpmAccessSettings], NpmAccessSettings] | None=None) -> ExecResultManage package access:
npm access. -
static async owner(ctx: ServiceContext, configure: Callable[[NpmOwnerSettings], NpmOwnerSettings] | None=None) -> ExecResultManage package maintainers:
npm owner add|rm|ls. -
static async token(ctx: ServiceContext, configure: Callable[[NpmTokenSettings], NpmTokenSettings] | None=None) -> ExecResultManage registry tokens:
npm token list|create|revoke. -
static async ls(ctx: ServiceContext, configure: Callable[[NpmLsSettings], NpmLsSettings] | None=None) -> ExecResultList the installed tree:
npm ls. -
static async outdated(ctx: ServiceContext, configure: Callable[[NpmOutdatedSettings], NpmOutdatedSettings] | None=None) -> ExecResultReport dependencies behind their latest:
npm outdated. -
static async outdated_entries(ctx: ServiceContext, configure: Callable[[NpmOutdatedSettings], NpmOutdatedSettings] | None=None) -> objectThe outdated dependencies as parsed NpmOutdatedEntry values. npm exits non-zero *because* something is outdated, so this reads that as the answer rather than as a failure; an empty array means everything is current.
-
static async audit(ctx: ServiceContext, configure: Callable[[NpmAuditSettings], NpmAuditSettings] | None=None) -> ExecResultAudit dependencies for vulnerabilities:
npm audit. -
static async audit_summary(ctx: ServiceContext, configure: Callable[[NpmAuditSettings], NpmAuditSettings] | None=None) -> objectThe audit's vulnerability counts by severity, so a target decides for itself what is worth failing on. npm's non-zero exit is the finding, not an error.
-
static async sbom(ctx: ServiceContext, configure: Callable[[NpmSbomSettings], NpmSbomSettings] | None=None) -> ExecResultEmit a software bill of materials:
npm sbom. -
static async init(ctx: ServiceContext, configure: Callable[[NpmInitSettings], NpmInitSettings] | None=None) -> ExecResultCreate a package or run an initializer:
npm init. -
static async pkg(ctx: ServiceContext, configure: Callable[[NpmPkgSettings], NpmPkgSettings] | None=None) -> ExecResultRead or write package.json fields:
npm pkg get|set|delete|fix. -
static async pkg_get(ctx: ServiceContext, key: str, configure: Callable[[NpmPkgSettings], NpmPkgSettings] | None=None) -> objectOne
package.jsonfield as a string, orundefinedwhen it is unset or is not a scalar — how a build reads its own version without parsing the manifest or guessing where it lives. -
static async config(ctx: ServiceContext, configure: Callable[[NpmConfigSettings], NpmConfigSettings] | None=None) -> ExecResultRead or write npm configuration:
npm config get|set|delete|list|fix. -
static async cache(ctx: ServiceContext, configure: Callable[[NpmCacheSettings], NpmCacheSettings] | None=None) -> ExecResultMaintain the package cache:
npm cache add|clean|ls|verify.
class NpmTestSettings(NpmWorkspaceSettings) Settings for npm test.
-
test_args(*args: str | float) -> SelfArguments forwarded to the test script (after
--).
class NpmTokenSettings(NpmSettings) Settings for npm token. Pick the subcommand with list, create, or revoke.
-
list() -> SelfList this account's tokens (
token list), the default. -
create() -> SelfCreate a token (
token create). -
revoke(id_or_token: str) -> SelfRevoke a token by id or value (
token revoke <id|token>). npm takes this positionally, with no environment route, so the value reaches the child's argv either way. It is registered with the run's redactor so every *rendering* of the command masks it; the process table is not something the wrapper can do anything about here. Masked whichever it is, because the two are indistinguishable from here — npm accepts the id or the token itself, and nothing in the string says which. Masking an id costs a[redacted]in this run's output; not masking a token puts a live credential in it. -
read_only() -> SelfCreate a token that cannot publish (
--read-only). -
cidr(*ranges: str) -> SelfRestrict a created token to these ranges (
--cidr=<range>); repeatable. -
otp(code: str) -> SelfProvide a one-time password. Carried in
npm_config_otprather than on the command line — see NpmSettings.applyOtp for why.
class NpmUninstallSettings(NpmDependencySettings) Settings for npm uninstall.
-
no_save() -> SelfRemove the package without updating
package.json(--no-save).
class NpmUnpublishSettings(NpmWorkspaceSettings) Settings for npm unpublish.
-
spec(value: str) -> SelfThe package spec to remove, e.g.
app@1.2.3(positional). -
force() -> SelfConfirm an unpublish npm would otherwise refuse (
--force) — removing a whole package, or a version outside the 72-hour window. -
dry_run() -> SelfReport what would be removed without removing it (
--dry-run).
class NpmUpdateSettings(NpmDependencySettings) Settings for npm update.
-
save() -> SelfWrite the updated ranges back to
package.json(--save).
class NpmVersionSettings(NpmWorkspaceSettings) Settings for npm version.
-
bump(value: str) -> SelfThe bump:
patch|minor|majoror an explicit semver (required). -
message(text: str) -> SelfCommit message;
%sexpands to the new version (--message). -
no_git_tag_version() -> SelfDo not create a git commit and tag (
--no-git-tag-version). -
preid(id: str) -> SelfThe prerelease identifier for a
pre*bump (--preid=<id>), e.g.rc. -
allow_same_version() -> SelfAccept a bump to the version already set (
--allow-same-version).
class NpmViewSettings(NpmWorkspaceSettings) Settings for npm view.
-
spec(value: str) -> SelfThe package spec to read, e.g.
react@18(positional). -
field(*names: str) -> SelfA field of the registry metadata to print, e.g.
versionordist-tags.latest(positional); repeatable. With none, npm prints the whole record.
class NpmWhoamiSettings(NpmSettings) Settings for npm whoami.
class NpmWorkspaceSettings(NpmSettings) Base for the npm commands that accept workspace selection. --workspace names one (repeatable) and --workspaces means all of them; npm takes one or the other, and this refuses the combination rather than passing on a command whose meaning is ambiguous.
-
workspace(*names: str) -> SelfRun in this workspace (
--workspace=<name>); repeatable. -
workspaces() -> SelfRun in every workspace (
--workspaces). Mutually exclusive with workspace — setting both is a build error. -
include_workspace_root() -> SelfInclude the root project alongside the workspaces (
--include-workspace-root).