Documentation
¶
Overview ¶
Package npmgo installs npm dependencies from a package-lock.json into a node_modules directory. It is pure Go with no external dependencies: parse the lock file, download tarballs from the registry (or a local content-addressed cache), verify their SHA-512 integrity, and extract them to disk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Install ¶
Install reads the lock file referenced by opts, then resolves every (non-skipped) package: packages already installed at the correct version are skipped, otherwise the tarball is taken from the cache or downloaded, verified, cached, and extracted into opts.TargetDir.
Optional-dependency failures are logged and tolerated; any other package failure aborts the install and is returned.
Types ¶
type Options ¶
type Options struct {
LockfilePath string // default: "package-lock.json"
TargetDir string // default: "node_modules"
CacheDir string // default: "<user cache>/npmgo"; cache is keyed by integrity hash
Registry string // default: "https://registry.npmjs.org"
Token string // optional Bearer token for private registries
Concurrency int // default: 8
Production bool // skip devDependencies when true
Timeout time.Duration
// Logf, when set, receives human-readable progress lines, including
// per-package cache/download/skip status. It may be called
// concurrently and must be safe for concurrent use.
Logf func(format string, args ...any)
}
Options configures an Install.
type Package ¶
type Package struct {
Path string // install path, e.g. "node_modules/react"
Version string // resolved version
Resolved string // tarball URL
Integrity string // subresource integrity, e.g. "sha512-..."
Dependencies map[string]string // declared dependencies (informational)
Dev bool // development-only dependency
Optional bool // optional dependency (failure is non-fatal)
}
Package is a single resolved dependency that must be downloaded and extracted. Path is the install location relative to the project root, e.g. "node_modules/react" or "node_modules/a/node_modules/b".
func ParseLockfile ¶
ParseLockfile parses package-lock.json bytes into the set of packages that must be downloaded. It supports lockfileVersion 1, 2 and 3.
The v2/v3 "packages" map is preferred when present; otherwise the legacy v1 "dependencies" tree is walked. The root entry, and any file:/link: local references, are skipped.
func ParseLockfileFile ¶
ParseLockfileFile reads and parses a package-lock.json from disk.
type RegistryConfig ¶
type RegistryConfig struct {
URL string // base registry URL (used for relative-path fallbacks)
Token string // optional Bearer token for private registries
}
RegistryConfig describes how to reach a package registry. Token, when set, is sent as a Bearer credential for private-registry access.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
npmgo
command
Command npmgo is a minimal, pure-Go npm package installer driven by package-lock.json.
|
Command npmgo is a minimal, pure-Go npm package installer driven by package-lock.json. |
|
esbuildplugin
module
|