npm

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: Apache-2.0, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package npm provides the manifest parsing and writing for the npm package.json format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReadWriter

func GetReadWriter() (manifest.ReadWriter, error)

GetReadWriter returns a ReadWriter for package.json manifest files. registry is unused.

func MakeRequirementKey

func MakeRequirementKey(requirement resolve.RequirementVersion) manifest.RequirementKey

MakeRequirementKey constructs an npm RequirementKey from the given RequirementVersion.

func SplitNPMAlias

func SplitNPMAlias(v string) (name, version string)

SplitNPMAlias extracts the real package name and version from an alias-specified version.

e.g. "npm:pkg@^1.2.3" -> name: "pkg", version: "^1.2.3"

If the version is not an alias specifier, the name will be empty and the version unchanged.

Types

type PackageJSON

type PackageJSON struct {
	Name                 string            `json:"name"`
	Version              string            `json:"version"`
	Workspaces           []string          `json:"workspaces"`
	Dependencies         map[string]string `json:"dependencies"`
	DevDependencies      map[string]string `json:"devDependencies"`
	OptionalDependencies map[string]string `json:"optionalDependencies"`
	PeerDependencies     map[string]string `json:"peerDependencies"`
	PeerDependenciesMeta map[string]struct {
		Optional bool `json:"optional,omitempty"`
	} `json:"peerDependenciesMeta,omitempty"`
}

PackageJSON is the structure for the contents of a package.json file.

type RequirementKey

type RequirementKey struct {
	resolve.PackageKey

	KnownAs string
}

RequirementKey is a comparable type that uniquely identifies a package dependency in a manifest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL