AbstractAssetManager
API reference › Foxy › Asset › AbstractAssetManager
5 subclasses
Runs an external frontend package manager and validates its executable version.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$config protected constructor | Foxy\ | Foxy configuration. | AbstractManifestAssetManager |
$executor protected constructor | Composer\ | Process executor used to invoke the manager. | AbstractAssetManager |
$fs protected constructor | Composer\ | Filesystem used to resolve and update manifest paths. | AbstractManifestAssetManager |
$io protected constructor | Composer\ | Composer output used for progress messages. | AbstractManifestAssetManager |
$updatable protected | bool | Whether an existing frontend installation may be updated. Default: true. | AbstractManifestAssetManager |
$versionConverter protected constructor | Foxy\| | Converter for manager version output. Default: null. | AbstractAssetManager |
Methods
Section titled “Methods”| Method | Description | Defined 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() abstract | Returns the parser of this manager’s audit report. | AssetManagerInterface |
getLockPackageName() abstract | Get the filename of the lock file. | AssetManagerInterface |
getName() abstract | Get the name of asset manager. | AssetManagerInterface |
getPackageJsonPath() | Returns the frontend package manifest path. | AbstractManifestAssetManager |
getPackageName() | Returns the frontend package manifest filename. | AbstractManifestAssetManager |
getVersionConstraint() abstract | Get 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() protected | Handles dependencies already present in the frontend installation. | AbstractManifestAssetManager |
actionWhenComposerDependenciesAreMerged() protected | Runs after the Composer asset dependencies are merged and before the asset package is written. | AbstractManifestAssetManager |
buildCommand() protected | Returns the manager command run by the configured or default binary, followed by the manager-options and manager-{action}-options values. | AbstractAssetManager |
buildUnconfiguredCommand() protected | Returns the manager command run by the configured or default binary, without the install and update options. | AbstractAssetManager |
getAuditCommand() protected abstract | Get the command to audit the asset dependencies. | AbstractAssetManager |
getAuditEnvironment() protected | Get environment overrides required for a complete audit. | AbstractAssetManager |
getDefaultBinary() protected | Returns the executable used when manager-bin is not configured; defaults to the manager name. | AbstractAssetManager |
getInstallCommand() protected | Returns the command that installs the asset dependencies, followed by the manager-options and manager-install-options values. | AbstractAssetManager |
getLockFilePath() protected | Returns the manager lock-file path under the root package directory. | AbstractManifestAssetManager |
getManagerConfig() protected | Returns the configuration scoped to this manager, so manager-* map entries resolve to its own value. | AbstractManifestAssetManager |
getManagerWorkingDirectory() protected | Returns the configured manager working directory, or null to use the process default. | AbstractManifestAssetManager |
getNodeModulesPath() protected | Returns the node_modules path under the root package directory. | AbstractManifestAssetManager |
getRootPackageDir() protected | Returns the resolved root package directory. | AbstractManifestAssetManager |
getRootPackagePath() protected | Resolves a path under the root package directory. | AbstractManifestAssetManager |
getUpdateCommand() protected | Returns the command that updates the asset dependencies, followed by the manager-options and manager-update-options values. | AbstractAssetManager |
getVersion() protected | Returns the normalized manager version, or null when it cannot be detected. | AbstractAssetManager |
getVersionCommand() protected | Returns the command that prints the manager version, without the install and update options. | AbstractAssetManager |
normalizeVersionOutput() protected | Normalizes the trimmed output of the version command before it is converted. | AbstractAssetManager |
validateAuditConfiguration() protected | Validate manager configuration that can change the audit scope. | AbstractAssetManager |
withManagerTimeout() protected final | Runs the callback with the process timeout set to the manager-timeout option and restores the previous timeout afterward, even when the callback throws. | AbstractAssetManager |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
NODE_MODULES_PATH | './node_modules' | AbstractManifestAssetManager |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$io | Composer\ | Composer output used for progress messages. |
$config | Foxy\ | Foxy configuration. |
$executor | Composer\ | Process executor used to invoke the manager. |
$fs | Composer\ | Filesystem used by manifest handling. |
$versionConverter | Foxy\| | Converter for manager version output. |
audit()
Section titled “audit() ”public function audit(bool $noDev): Foxy\Audit\AuditProcessResultRuns the manager audit command against the current lock file.
isAvailable()
Section titled “isAvailable() ”public function isAvailable(): boolReturns whether the manager executable reports a detectable version.
Returns
bool
run()
Section titled “run() ”public function run(): intInstalls or updates frontend dependencies according to the manager state and configuration.
Returns
int
validate()
Section titled “validate() ”public function validate(): voidValidates the installed manager version against Foxy’s supported and configured constraints.
buildCommand()
Section titled “buildCommand() ”protected function buildCommand(string $action, array|string $command): stringReturns the manager command run by the configured or default binary, followed by the manager-options and
manager-{action}-options values.
Parameters
| Parameter | Type | Description |
|---|---|---|
$action | string | The action whose manager-{action}-options value is appended. |
$command | array| | The command arguments, joined with spaces. |
Returns
string
buildUnconfiguredCommand()
Section titled “buildUnconfiguredCommand() ”protected function buildUnconfiguredCommand(array|string $command): stringReturns the manager command run by the configured or default binary, without the install and update options.
Parameters
| Parameter | Type | Description |
|---|---|---|
$command | array| | The command arguments, joined with spaces. |
Returns
string
getAuditCommand()
Section titled “getAuditCommand() ”abstract protected function getAuditCommand(bool $noDev): stringGet the command to audit the asset dependencies.
Parameters
| Parameter | Type | Description |
|---|---|---|
$noDev | bool |
Returns
string
getAuditEnvironment()
Section titled “getAuditEnvironment() ”protected function getAuditEnvironment(): array<string, string>Get environment overrides required for a complete audit.
Returns
array<string, string>
getDefaultBinary()
Section titled “getDefaultBinary() ”protected function getDefaultBinary(): stringReturns the executable used when manager-bin is not configured; defaults to the manager name.
Returns
string
getInstallCommand()
Section titled “getInstallCommand() ”protected function getInstallCommand(): stringReturns the command that installs the asset dependencies, followed by the manager-options and
manager-install-options values.
Returns
string
getUpdateCommand()
Section titled “getUpdateCommand() ”protected function getUpdateCommand(): stringReturns the command that updates the asset dependencies, followed by the manager-options and
manager-update-options values.
Returns
string
getVersion()
Section titled “getVersion() ”protected function getVersion(): string|nullReturns the normalized manager version, or null when it cannot be detected.
Returns
string|null
getVersionCommand()
Section titled “getVersionCommand() ”protected function getVersionCommand(): stringReturns the command that prints the manager version, without the install and update options.
Returns
string
normalizeVersionOutput()
Section titled “normalizeVersionOutput() ”protected function normalizeVersionOutput(string $output): stringNormalizes the trimmed output of the version command before it is converted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$output | string |
Returns
string
validateAuditConfiguration()
Section titled “validateAuditConfiguration() ”protected function validateAuditConfiguration(bool $noDev): voidValidate manager configuration that can change the audit scope.
Parameters
| Parameter | Type | Description |
|---|---|---|
$noDev | bool |
withManagerTimeout()
Section titled “withManagerTimeout() ”final protected function withManagerTimeout(callable(): Foxy\Asset\T $callback): Foxy\Asset\TRuns the callback with the process timeout set to the manager-timeout option and restores the previous timeout
afterward, even when the callback throws.
Parameters
| Parameter | Type | Description |
|---|---|---|
$callback | callable(): Foxy\ | The operation to run under the manager timeout. |
Returns
Foxy\Asset\T: The callback result.