Skip to content
PHP Ecosystem
Explore

AbstractAssetManager

API reference › Foxy › Asset › AbstractAssetManager

abstract classFoxy\Asset\AbstractAssetManager
ExtendsAbstractManifestAssetManager
ImplementsAssetManagerInterface
Sourcesrc/Asset/AbstractAssetManager.php
5 subclasses

Runs an external frontend package manager and validates its executable version.

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() abstractReturns the parser of this manager’s audit report.AssetManagerInterface
getLockPackageName() abstractGet the filename of the lock file.AssetManagerInterface
getName() abstractGet the name of asset manager.AssetManagerInterface
getPackageJsonPath()Returns the frontend package manifest path.AbstractManifestAssetManager
getPackageName()Returns the frontend package manifest filename.AbstractManifestAssetManager
getVersionConstraint() abstractGet the supported version constraint of the asset manager.AssetManagerInterface
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() protectedHandles dependencies already present in the frontend installation.AbstractManifestAssetManager
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() protected abstractGet the command to audit the asset dependencies.AbstractAssetManager
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 __construct(Composer\IO\IOInterface $io, Foxy\Config\Config $config, Composer\Util\ProcessExecutor $executor, Composer\Util\Filesystem $fs, Foxy\Converter\VersionConverterInterface|null $versionConverter = null)

Creates a manager that executes frontend commands for the configured asset manifest.

Parameters

ParameterTypeDescription
$ioComposer\IO\IOInterfaceComposer output used for progress messages.
$configFoxy\Config\ConfigFoxy configuration.
$executorComposer\Util\ProcessExecutorProcess executor used to invoke the manager.
$fsComposer\Util\FilesystemFilesystem used by manifest handling.
$versionConverterFoxy\Converter\VersionConverterInterface|nullConverter for manager version output.
public function audit(bool $noDev): Foxy\Audit\AuditProcessResult

Runs the manager audit command against the current lock file.

Parameters

ParameterTypeDescription
$noDevbool

Returns

Foxy\Audit\AuditProcessResult

public function isAvailable(): bool

Returns whether the manager executable reports a detectable version.

Returns

bool

public function run(): int

Installs or updates frontend dependencies according to the manager state and configuration.

Returns

int

public function validate(): void

Validates the installed manager version against Foxy’s supported and configured constraints.

protected function buildCommand(string $action, array|string $command): string

Returns the manager command run by the configured or default binary, followed by the manager-options and manager-{action}-options values.

Parameters

ParameterTypeDescription
$actionstringThe action whose manager-{action}-options value is appended.
$commandarray|stringThe command arguments, joined with spaces.

Returns

string

protected function buildUnconfiguredCommand(array|string $command): string

Returns the manager command run by the configured or default binary, without the install and update options.

Parameters

ParameterTypeDescription
$commandarray|stringThe command arguments, joined with spaces.

Returns

string

abstract protected function getAuditCommand(bool $noDev): string

Get the command to audit the asset dependencies.

Parameters

ParameterTypeDescription
$noDevbool

Returns

string

protected function getAuditEnvironment(): array<string, string>

Get environment overrides required for a complete audit.

Returns

array<string, string>

protected function getDefaultBinary(): string

Returns the executable used when manager-bin is not configured; defaults to the manager name.

Returns

string

protected function getInstallCommand(): string

Returns the command that installs the asset dependencies, followed by the manager-options and manager-install-options values.

Returns

string

protected function getUpdateCommand(): string

Returns the command that updates the asset dependencies, followed by the manager-options and manager-update-options values.

Returns

string

protected function getVersion(): string|null

Returns the normalized manager version, or null when it cannot be detected.

Returns

string|null

protected function getVersionCommand(): string

Returns the command that prints the manager version, without the install and update options.

Returns

string

protected function normalizeVersionOutput(string $output): string

Normalizes the trimmed output of the version command before it is converted.

Parameters

ParameterTypeDescription
$outputstring

Returns

string

protected function validateAuditConfiguration(bool $noDev): void

Validate manager configuration that can change the audit scope.

Parameters

ParameterTypeDescription
$noDevbool
final protected function withManagerTimeout(callable(): Foxy\Asset\T $callback): Foxy\Asset\T

Runs the callback with the process timeout set to the manager-timeout option and restores the previous timeout afterward, even when the callback throws.

Parameters

ParameterTypeDescription
$callbackcallable(): Foxy\Asset\TThe operation to run under the manager timeout.

Returns

Foxy\Asset\T: The callback result.