Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions src/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,39 +314,23 @@ protected function setupModules(): void

$this->newLine();

// Phase 1: require all selected packages
$anyFailed = false;
foreach ($selected as $package) {
$ok = false;
$this->components->task("Requiring {$package}", function () use ($package, &$ok) {
$process = new Process(['composer', 'require', $package, '--no-interaction']);
$process->setTimeout(300);
$process->run();

return $ok = $process->isSuccessful();
});
// Phase 1: require all selected packages in one Composer run
$ok = false;
$this->components->task('Installing modules', function () use ($selected, &$ok) {
$process = new Process(array_merge(['composer', 'require', '--no-interaction'], $selected));
$process->setTimeout(300);
$process->run();

if (! $ok) {
$anyFailed = true;
}
}
return $ok = $process->isSuccessful();
});

if ($anyFailed) {
$this->components->warn('One or more packages failed to install — skipping module sync and migrations.');
if (! $ok) {
$this->components->warn('Module installation failed — skipping patches, sync, and migrations.');

return;
}

// Phase 2: regenerate autoload once for all new modules
$this->components->task('Dumping autoload', function () {
$process = new Process(['composer', 'dump-autoload', '--no-interaction']);
$process->setTimeout(120);
$process->run();

return $process->isSuccessful();
});

// Phase 2.5: apply any patches the modules ship for the host app
// Phase 2: apply any patches the modules ship for the host app
$this->applyModulePatches($selected);

// Phase 3: sync module configs, then migrate + seed each module individually
Expand All @@ -370,7 +354,7 @@ protected function setupModules(): void
});

$this->components->task("Seeding {$name}", function () use ($name) {
$process = new Process([PHP_BINARY, base_path('artisan'), 'modules:seed', "--module={$name}"]);
$process = new Process([PHP_BINARY, base_path('artisan'), 'db:seed', "--module={$name}", '--force']);
$process->setTimeout(60);
$process->run();

Expand Down
19 changes: 8 additions & 11 deletions src/Environments/DockerEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,25 @@ protected function installModules(InstallCommand $command): void

$command->info('Installing modules...');

$anyFailed = false;
foreach ($modules as $package) {
$ok = $this->execInContainer($command, ['composer', 'require', $package, '--no-interaction'], timeout: 300);
$ok = $this->execInContainer(
$command,
['composer', 'require', ...$modules, '--no-interaction'],
timeout: 300,
);

if (! $ok) {
$command->warn("Failed to require {$package} — skipping.");
$anyFailed = true;
}
}
if (! $ok) {
$command->warn('Failed to install one or more modules — skipping patches, sync, and migrations.');

if ($anyFailed) {
return;
}

$this->execInContainer($command, ['composer', 'dump-autoload', '--no-interaction']);
$command->applyModulePatches($modules);
$this->execInContainer($command, ['php', 'artisan', 'modules:sync']);

foreach ($modules as $package) {
$name = Str::after($package, '/');
$this->execInContainer($command, ['php', 'artisan', 'modules:migrate', "--module={$name}", '--force'], timeout: 120);
$this->execInContainer($command, ['php', 'artisan', 'modules:seed', "--module={$name}"]);
$this->execInContainer($command, ['php', 'artisan', 'db:seed', "--module={$name}", '--force']);
}
}

Expand Down