Skip to main content

XpmPackage class

Provides access to package metadata and xpm-specific validation.

Signature

export declare class XpmPackage

Remarks

This class loads and validates package.json content, determines package capabilities, and provides helper methods used across xpm workflows.

The package abstraction provides a layer over package.json processing with progressive validation:

  1. Basic file I/O: Read and write package.json with error handling.
  2. npm validation: Check for valid npm package structure (name, version).
  3. xpm validation: Verify xpack section presence and structure.
  4. Binary package validation: Validate binary-specific metadata (executables, binaries, platforms).
  5. Capability detection: Determine package features (scripts, actions, build configurations).
  6. Version checking: Validate minimum xpm version requirements.
  7. Specifier parsing: Extract scope, name, and version from package identifiers.

This hierarchy allows validation to be performed incrementally as needed, avoiding unnecessary checks for packages that don't meet earlier criteria.

Constructors

Constructor

Modifiers

Description

(constructor)({ log, packageFolderPath, })

Constructs a package helper bound to a specific folder.

Properties

Property

Modifiers

Type

Description

_log

protected

Logger

The logger instance for output and diagnostics.

jsonPackage?

JsonXpmPackage

(Optional) The parsed package.json content, when available.

packageFolderPath

string

The absolute path to the package folder.

Methods

Method

Modifiers

Description

checkMinimumXpmRequired({ xpmRootFolderPath, })

Validates the minimum required xpm version against the installed CLI.

getMinimumXpmRequired()

Retrieves the minimum required xpm version specified by the package.

hasNpmScripts()

Determines whether the package defines any npm scripts.

hasXpmActions()

Determines whether the package defines any xpm actions.

isBinaryNodeModule()

Determines whether the package is a Node module with a binary entry.

isBinaryXpmPackage()

Determines whether the package is a binary xpm package.

isNodeModule()

Determines whether the package is a Node module without xpm metadata.

isNpmPackage()

Determines whether the package.json content represents a valid npm package.

isXpmPackage()

Determines whether the package is an xpm package.

parsePackageSpecifier({ npmPackageSpecifier, })

Parses an npm package specifier into its components.

readPackageDotJson({ withThrow, })

Reads and parses package.json from the package folder.

rewritePackageDotJson(jsonPackage)

Writes the provided package.json content to disk.


Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.