Read and write package.json files.
Summary
Functions
Add a dependency to package.json, creating the file if needed.
Expand workspace patterns to actual directories with package.json files.
Check if a dependency range refers to a local file path.
Check if a dependency range refers to a git repository.
Read dependencies from package.json.
Read all dependency groups from package.json.
Read bundleDependencies (or bundledDependencies) from package.json.
Read overrides from package.json.
Read resolutions (Yarn-style) from package.json.
Read scripts from package.json.
Read workspace patterns from package.json.
Remove a dependency from package.json.
Resolve a file dependency path.
Check if a dependency range refers to a URL tarball.
Functions
Add a dependency to package.json, creating the file if needed.
Options
:dev- whentrue, adds todevDependenciesinstead ofdependencies
Expand workspace patterns to actual directories with package.json files.
Supports glob patterns like packages/* and apps/**.
Check if a dependency range refers to a local file path.
Supports file:../path and file:./path references.
Check if a dependency range refers to a git repository.
Supports git+https://, git+ssh://, github:user/repo, and git:// URLs.
Read dependencies from package.json.
@spec read_all(String.t()) :: {:ok, %{dependencies: map(), dev_dependencies: map(), optional_dependencies: map()}} | {:error, term()}
Read all dependency groups from package.json.
Read bundleDependencies (or bundledDependencies) from package.json.
Returns a list of package names that should be bundled in the tarball.
Read overrides from package.json.
@spec read_resolutions(String.t()) :: {:ok, %{required(String.t()) => String.t()}} | {:error, term()}
Read resolutions (Yarn-style) from package.json.
Read scripts from package.json.
Read workspace patterns from package.json.
Remove a dependency from package.json.
Resolve a file dependency path.
Returns the absolute path for a file: reference.
Check if a dependency range refers to a URL tarball.
Supports http:// and https:// URLs ending in .tgz or .tar.gz.