Skip to content
PHP Ecosystem
Explore

NpmManager

API reference › Foxy › Asset › NpmManager

Integrates npm with Foxy’s install, update, workspace, and audit workflows.

PropertyTypeDescriptionDefined by
$config protected constructorFoxy\Config\ConfigFoxy configuration.AbstractManifestAssetManager
$executor protected constructorComposer\Util\ProcessExecutorProcess executor used to invoke the manager.AbstractAssetManager
$fs protected constructorComposer\Util\FilesystemFilesystem used to resolve and update manifest paths.AbstractManifestAssetManager
$io protected constructorComposer\IO\IOInterfaceComposer output used for progress messages.AbstractManifestAssetManager
$updatable protectedboolWhether an existing frontend installation may be updated. Default: true.AbstractManifestAssetManager
$versionConverter protected constructorFoxy\Converter\VersionConverterInterface|nullConverter for manager version output. Default: null.AbstractAssetManager
MethodDescriptionDefined by
__construct()Creates a manager that executes frontend commands for the configured asset manifest.AbstractAssetManager
addDependencies()Merges Composer asset dependencies into the frontend package manifest.AbstractManifestAssetManager
audit()Runs the manager audit command against the current lock file.AbstractAssetManager
getAuditParser()Returns the parser for npm audit JSON output.NpmManager
getLockPackageName()Returns npm’s lock-file name.NpmManager
getName()Returns the manager name used in Foxy configuration.NpmManager
getPackageJsonPath()Returns the frontend package manifest path.AbstractManifestAssetManager
getPackageName()Returns the frontend package manifest filename.AbstractManifestAssetManager
getVersionConstraint()Returns the npm versions supported by this integration.NpmManager
hasLockFile()Returns whether the manager lock file exists.AbstractManifestAssetManager
isAvailable()Returns whether the manager executable reports a detectable version.AbstractAssetManager
isInstalled()Returns whether both the dependency directory and package manifest exist.AbstractManifestAssetManager
isUpdatable()Returns whether an existing frontend installation may be updated.AbstractManifestAssetManager
run()Installs or updates frontend dependencies according to the manager state and configuration.AbstractAssetManager
setUpdatable()Enables or disables updates of an existing frontend installation.AbstractManifestAssetManager
validate()Validates the installed manager version against Foxy’s supported and configured constraints.AbstractAssetManager
actionWhenComposerDependenciesAreAlreadyInstalled() protectedRemoves already-installed Composer assets so npm installs their updated manifest paths.NpmManager
actionWhenComposerDependenciesAreMerged() protectedRuns after the Composer asset dependencies are merged and before the asset package is written.AbstractManifestAssetManager
buildCommand() protectedReturns the manager command run by the configured or default binary, followed by the manager-options and manager-{action}-options values.AbstractAssetManager
buildUnconfiguredCommand() protectedReturns the manager command run by the configured or default binary, without the install and update options.AbstractAssetManager
getAuditCommand() protectedReturns an npm audit command that covers the root package and every locked workspace.NpmManager
getAuditEnvironment() protectedGet environment overrides required for a complete audit.AbstractAssetManager
getDefaultBinary() protectedReturns the executable used when manager-bin is not configured; defaults to the manager name.AbstractAssetManager
getInstallCommand() protectedReturns the command that installs the asset dependencies, followed by the manager-options and manager-install-options values.AbstractAssetManager
getLockFilePath() protectedReturns the manager lock-file path under the root package directory.AbstractManifestAssetManager
getManagerConfig() protectedReturns the configuration scoped to this manager, so manager-* map entries resolve to its own value.AbstractManifestAssetManager
getManagerWorkingDirectory() protectedReturns the configured manager working directory, or null to use the process default.AbstractManifestAssetManager
getNodeModulesPath() protectedReturns the node_modules path under the root package directory.AbstractManifestAssetManager
getRootPackageDir() protectedReturns the resolved root package directory.AbstractManifestAssetManager
getRootPackagePath() protectedResolves a path under the root package directory.AbstractManifestAssetManager
getUpdateCommand() protectedReturns the command that updates the asset dependencies, followed by the manager-options and manager-update-options values.AbstractAssetManager
getVersion() protectedReturns the normalized manager version, or null when it cannot be detected.AbstractAssetManager
getVersionCommand() protectedReturns the command that prints the manager version, without the install and update options.AbstractAssetManager
normalizeVersionOutput() protectedNormalizes the trimmed output of the version command before it is converted.AbstractAssetManager
validateAuditConfiguration() protectedValidate manager configuration that can change the audit scope.AbstractAssetManager
withManagerTimeout() protected finalRuns the callback with the process timeout set to the manager-timeout option and restores the previous timeout afterward, even when the callback throws.AbstractAssetManager
ConstantValueDescriptionDefined by
NODE_MODULES_PATH'./node_modules'AbstractManifestAssetManager
public function getAuditParser(): Foxy\Audit\AuditParserInterface

Returns the parser for npm audit JSON output.

public function getLockPackageName(): string

Returns npm’s lock-file name.

Returns

string

public function getName(): string

Returns the manager name used in Foxy configuration.

Returns

string

public function getVersionConstraint(): string

Returns the npm versions supported by this integration.

Returns

string

actionWhenComposerDependenciesAreAlreadyInstalled()

Section titled “actionWhenComposerDependenciesAreAlreadyInstalled() ”
protected function actionWhenComposerDependenciesAreAlreadyInstalled(array $names): void

Removes already-installed Composer assets so npm installs their updated manifest paths.

Parameters

ParameterTypeDescription
$namesarray
protected function getAuditCommand(bool $noDev): string

Returns an npm audit command that covers the root package and every locked workspace.

Parameters

ParameterTypeDescription
$noDevbool

Returns

string