Skip to content

Commit

Permalink
Added more messages to improve ux
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxwilko committed Jan 3, 2025
1 parent f4b67bb commit 19a09cd
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions modules/system/classes/extensions/source/ExtensionSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,27 @@ public function getPath(): ?string
*/
public function createFiles(): ?static
{
$manager = $this->getExtensionManager();

switch ($this->source) {
case static::SOURCE_COMPOSER:
$manager->renderComponent(
Info::class,
'Requiring composer package: <fg=yellow>' . $this->composerPackage . '</>'
);

try {
Composer::require($this->composerPackage);
} catch (CommandException $e) {
throw new ApplicationException('Unable to require composer package', previous: $e);
$manager->renderComponent(
Error::class,
'Unable to require composer package, details: <fg=yellow>' . $e->getMessage() . '</>'
);
return null;
}

$manager->renderComponent(Info::class, 'Composer require complete.');

$info = Composer::show('installed', $this->composerPackage);
$this->path = $this->relativePath($info['path']);
$this->source = static::SOURCE_LOCAL;
Expand All @@ -123,11 +136,6 @@ public function createFiles(): ?static
throw new ApplicationException("The market place only supports themes and plugins '{$this->type}'");
}

$manager = match ($this->type) {
static::TYPE_THEME => ThemeManager::instance(),
static::TYPE_PLUGIN => PluginManager::instance(),
};

$manager->renderComponent(Info::class, 'Downloading ' . $this->type . ' details...');

try {
Expand Down Expand Up @@ -162,6 +170,11 @@ public function createFiles(): ?static
case static::SOURCE_LOCAL:
$extensionPath = $this->guessPathFromCode($this->code);
if ($this->path !== $extensionPath) {
$manager->renderComponent(
Info::class,
'Moving ' . $this->type . ' to path <fg=yellow>' . $extensionPath . '</>...'
);

File::moveDirectory($this->path, $extensionPath);
$this->path = $extensionPath;
}
Expand Down Expand Up @@ -264,8 +277,7 @@ protected function guessCodeFromPath(string $path): ?string
? Str::after($path, basename(plugins_path()))
: $this->guessCodeFromPlugin($path),
'/')),
static::TYPE_THEME => Str::after($path, themes_path()),
static::TYPE_MODULE => Str::after($path, base_path('modules/')),
static::TYPE_THEME, static::TYPE_MODULE => basename($path),
default => null,
};
}
Expand Down

0 comments on commit 19a09cd

Please sign in to comment.