utils

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNpmUploadFromPackageJSON

func BuildNpmUploadFromPackageJSON(pkgJSON []byte, readme string, file io.ReadCloser) (*npm.PackageUpload, string, string, error)

func ExtractPackageJSONAndReadmeFromTarball added in v1.3.10

func ExtractPackageJSONAndReadmeFromTarball(file io.ReadCloser) ([]byte, string, error)

ExtractPackageJSONAndReadmeFromTarball extracts the root-level package.json and README file from an npm tarball. The readme is optional — if not found, an empty string is returned.

func ResolveFilePath added in v1.3.5

func ResolveFilePath(pattern string, extensions ...string) ([]string, error)

ResolveFilePath resolves a file path pattern (supports glob wildcards and regex). If the pattern contains wildcards/regex, it returns all matching files. If no wildcards, it returns the path as-is after validating it exists. Optional extensions filter can be provided to only include files with specific extensions.

Types

type MinimalPackageJSON

type MinimalPackageJSON struct {
	Name                 string      `json:"name"`
	Version              string      `json:"version"`
	Description          interface{} `json:"description"`
	Homepage             interface{} `json:"homepage"`
	Keywords             []string    `json:"keywords"`
	Repository           interface{} `json:"repository"`
	Author               interface{} `json:"author"`
	License              interface{} `json:"license"`
	Dependencies         interface{} `json:"dependencies"`
	DevDependencies      interface{} `json:"devDependencies"`
	PeerDependencies     interface{} `json:"peerDependencies"`
	PeerDependenciesMeta interface{} `json:"peerDependenciesMeta"`
	OptionalDependencies interface{} `json:"optionalDependencies"`
	AcceptDependencies   interface{} `json:"acceptDependencies"`
	BundleDependencies   interface{} `json:"bundleDependencies"`
	Bin                  interface{} `json:"bin"`
	Contributors         interface{} `json:"contributors"`
	Bugs                 interface{} `json:"bugs"`
	Engines              interface{} `json:"engines"`
	Deprecated           interface{} `json:"deprecated"`
	Directories          interface{} `json:"directories"`
	Funding              interface{} `json:"funding"`
	CPU                  interface{} `json:"cpu"`
	OS                   interface{} `json:"os"`
	Main                 interface{} `json:"main"`
	Module               interface{} `json:"module"`
	Types                interface{} `json:"types"`
	Typings              interface{} `json:"typings"`
	Exports              interface{} `json:"exports"`
	Imports              interface{} `json:"imports"`
	Files                interface{} `json:"files"`
	Workspaces           interface{} `json:"workspaces"`
	Scripts              interface{} `json:"scripts"`
	Config               interface{} `json:"config"`
	PublishConfig        interface{} `json:"publishConfig"`
	SideEffects          interface{} `json:"sideEffects"`
	HasShrinkwrap        interface{} `json:"_hasShrinkwrap"`
	HasInstallScript     interface{} `json:"hasInstallScript"`
	NodeVersion          interface{} `json:"_nodeVersion"`
	NpmUser              interface{} `json:"_npmUser"`
	NpmVersion           interface{} `json:"_npmVersion"`
}

MinimalPackageJSON represents the subset of fields from package.json we care about. Fields use interface{} to match PackageMetadataVersion and avoid parse failures when package.json contains unexpected types (e.g. description as array, dependency values as objects for workspace/override references).

Jump to

Keyboard shortcuts

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