NPM.Manifest (NPM v0.6.0)

Copy Markdown View Source

Generate a complete package manifest from package.json.

Aggregates data from the package.json file into a structured manifest used by publishing, auditing, and analysis tools.

Summary

Functions

Get all dependency names across all types.

Count total dependency count across all types.

Build a manifest from a package.json file.

Build a manifest from a JSON string.

Check if the manifest has any scripts defined.

Types

t()

@type t() :: %{
  name: String.t() | nil,
  version: String.t() | nil,
  license: String.t() | nil,
  module_type: :esm | :cjs,
  dependencies: %{required(String.t()) => String.t()},
  dev_dependencies: %{required(String.t()) => String.t()},
  optional_dependencies: %{required(String.t()) => String.t()},
  scripts: %{required(String.t()) => String.t()},
  engines: %{required(String.t()) => String.t()},
  exports: map() | nil,
  files: [String.t()] | nil
}

Functions

all_dep_names(manifest)

@spec all_dep_names(t()) :: [String.t()]

Get all dependency names across all types.

dep_count(manifest)

@spec dep_count(t()) :: non_neg_integer()

Count total dependency count across all types.

from_file(path \\ "package.json")

@spec from_file(String.t()) :: {:ok, t()} | {:error, term()}

Build a manifest from a package.json file.

from_json(json)

@spec from_json(String.t()) :: t()

Build a manifest from a JSON string.

has_scripts?(manifest)

@spec has_scripts?(t()) :: boolean()

Check if the manifest has any scripts defined.