Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b23978d
fix: --modules installs private modules by short name
roble Nov 15, 2026
d50a81e
fix: a failed install step shows its error
roble Nov 16, 2026
fad28d4
feat: a clean install with auth says how to become the admin
roble Nov 16, 2026
1d270df
fix: a failed install gives one way on, and names the step
roble Nov 16, 2026
e35e63b
fix: drop Composer's status lines from a failed step's reason
roble Nov 16, 2026
4db083c
feat: every module names its own demo account
roble Nov 16, 2026
f94e8d4
Revert "feat: every module names its own demo account"
roble Nov 16, 2026
dcc0534
feat: the finish message names the demo's featured accounts
roble Nov 16, 2026
368348a
fix: switching stacks keeps a template workspace whole
roble Nov 18, 2026
4187f6e
Merge branch 'renanroble-stack-template' into dev
roble Nov 18, 2026
e816d42
refactor: the stack command leaves template files to core
roble Nov 18, 2026
4021a76
Merge branch 'renanroble-stack-template-hint' into dev
roble Nov 18, 2026
f5ad452
fix: a Herd install no longer requires mkcert
roble Nov 19, 2026
61a1342
fix: .env values are written as given, whatever they hold
roble Nov 19, 2026
3e7f777
Merge branch 'renanroble-night-2026-11-18' into dev
roble Nov 19, 2026
fc81a19
fix: APP_URL follows the installer's own host, failed steps say why, …
roble Nov 19, 2026
2412a7b
Merge branch 'renanroble-bugfixes-2026-11-19' into dev
roble Nov 19, 2026
b706aeb
ci: lint with the project's own Pint
roble Nov 20, 2026
79bdcc8
Merge branch 'renanroble-ci-own-pint' into dev
roble Nov 20, 2026
b1ca531
fix: Docker with SSL checks for mkcert before the project is created
roble Nov 20, 2026
646c244
fix: a workspace named by --path is told to go there first
roble Nov 20, 2026
6a6439b
fix: a Docker install prints its artisan commands for the container
roble Nov 20, 2026
97b2f19
Merge branch 'renanroble-coderabbit-2026-11-20' into dev
roble Nov 20, 2026
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
14 changes: 11 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ jobs:
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
- name: "laravel-pint"
uses: aglipanci/laravel-pint-action@latest
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
configPath: './pint.json'
php-version: '8.4'
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-progress

# The project's own Pint (composer.json), so CI formats as a local run does.
- name: Pint
run: vendor/bin/pint --config pint.json

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"require-dev": {
"phpunit/phpunit": "^13.4.3",
"mockery/mockery": "^1.6.15"
"mockery/mockery": "^1.6.15",
"laravel/pint": "^1.32.1"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "laravel"
}
120 changes: 73 additions & 47 deletions src/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Console\View\TaskResult;
use Illuminate\Contracts\Process\ProcessResult;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Str;
use Laravel\Prompts\Elements\Element;
Expand Down Expand Up @@ -111,10 +112,22 @@
*/
public function runArtisan(array $args, int $timeout = 120): bool
{
return Process::path($this->targetPath())
return $this->remember(Process::path($this->targetPath())
->timeout($timeout)
->run([PHP_BINARY, $this->path('artisan'), ...$args])
->successful();
->run([PHP_BINARY, $this->path('artisan'), ...$args]));
}

/** The last lines a failed step wrote, so its warning can say why. */
protected ?string $lastFailure = null;

/** The install task that failed, named in the failure box when the driver didn't name a step. */
protected ?string $failedTask = null;

private function remember(ProcessResult $result): bool
{
$this->lastFailure = $result->successful() ? null : trim($result->output()."\n".$result->errorOutput());

return $result->successful();
}

public function getSelectedStack(): ?string
Expand Down Expand Up @@ -286,10 +299,9 @@
/** @param string[] $command */
public function runProcess(array $command, int $timeout = 300): bool
{
return Process::path($this->targetPath())
return $this->remember(Process::path($this->targetPath())
->timeout($timeout)
->run($command)
->successful();
->run($command));
}

/** A contributor checkout runs the UI from saucebase/core instead of owning a copy. */
Expand Down Expand Up @@ -331,12 +343,7 @@

$this->generateApplicationKey();

$installed = false;
$this->task('Installing Saucebase', function () use (&$installed) {
return $installed = $this->installCore();
});

if (! $installed) {
if (! $this->installSaucebase()) {
return self::FAILURE;
}

Expand Down Expand Up @@ -490,7 +497,8 @@
protected function applyIdentityToEnv(string $env, string $name, string $slug, string $host, bool $native = false): string
{
$replaceable = [
'APP_NAME' => [['Laravel', 'Saucebase'], str_contains($name, ' ') ? "\"{$name}\"" : $name],
// Quoted when dotenv would misread it bare; inside the quotes, \ and " are escaped.
'APP_NAME' => [['Laravel', 'Saucebase'], preg_match('/[\s"\\\\$#]/', $name) ? '"'.addcslashes($name, '"\\').'"' : $name],

Check warning on line 501 in src/Console/Commands/InstallCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 133 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH6tY8e6Zu4sJ8julS1&open=AaH6tY8e6Zu4sJ8julS1&pullRequest=38
'APP_SLUG' => [['saucebase'], $slug],
];

Expand All @@ -502,16 +510,23 @@
}
}

// Read before APP_HOST is overwritten: a URL on the host chosen last time is ours.
$previousHost = self::readEnvLine($env, 'APP_HOST');

// Always authoritative: the certificate and nginx config are generated from the
// resolved domain, so APP_HOST must agree with them. A user's own value is not
// lost — it is what captureDomain() offers as the prompt default.
$env = self::setEnvLine($env, 'APP_HOST', $host);

// Native serves on whatever laravel/installer already wrote for localhost
// (http://localhost:8000, which is what `composer dev` binds); only a custom
// host needs correcting here.
if ($native && $host !== 'localhost') {
$env = self::setEnvLine($env, 'APP_URL', 'http://'.$host);
// Only a URL the installer wrote follows the host, keeping its scheme and port: native's
// localhost one is laravel/installer's http://localhost:8000, what `composer dev` binds.
// Docker's localhost URL is applyDockerEnvDefaults()'s, which also sets scheme and port.
$url = self::readEnvLine($env, 'APP_URL');
$urlHost = $url === null ? null : parse_url($url, PHP_URL_HOST);
$ours = array_filter([$native ? 'localhost' : null, $previousHost]);

if (is_string($urlHost) && $urlHost !== $host && in_array($urlHost, $ours, true)) {
$env = self::setEnvLine($env, 'APP_URL', (string) preg_replace('#^(https?://)[^/:]+#', '${1}'.$host, $url));
}

return $env;
Expand All @@ -530,8 +545,9 @@
{
$pattern = '/^'.preg_quote($key, '/').'=.*$/m';

// A callback, so the value is written as given: preg_replace would read $0 or \1 in it as backreferences.
return preg_match($pattern, $env)
? preg_replace($pattern, "{$key}={$value}", $env)
? preg_replace_callback($pattern, fn () => "{$key}={$value}", $env)
: rtrim($env, "\n")."\n{$key}={$value}\n";
}

Expand Down Expand Up @@ -567,18 +583,19 @@
});
}

/** Composer and core's own install; a failure says why, like every install step. */
protected function installSaucebase(): bool
{
return $this->runInstallTask('Installing Saucebase', [], fn () => $this->installCore());
}

protected function setupDatabase(): bool
{
$fresh = $this->option('fresh');
$label = $fresh ? 'Running migrate:fresh --seed' : 'Running migrations';
$command = $fresh ? 'migrate:fresh' : 'migrate';
$ok = false;

$this->task($label, function () use ($command, &$ok) {
return $ok = $this->runArtisan([$command, '--seed', '--force'], 300);
});

return $ok;
return $this->runInstallTask($label, [$command, '--seed', '--force'], fn (array $args) => $this->runArtisan($args, 300));

Check warning on line 598 in src/Console/Commands/InstallCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 129 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH6tY8e6Zu4sJ8julS2&open=AaH6tY8e6Zu4sJ8julS2&pullRequest=38
}

/** False when a selected module could not be wired into the application. */
Expand All @@ -595,12 +612,16 @@
return true;
}

// Fast path: skip Packagist discovery when all requested names are fully qualified
// Named modules need no discovery: a short name is one of Saucebase's, as in
// core's template-install. Private modules aren't on Packagist; Composer says
// so if a name doesn't exist.
if ($opt) {
$names = array_values(array_filter(array_map(fn ($n) => strtolower(trim($n)), explode(',', $opt))));
if ($names && ! array_filter($names, fn ($n) => ! str_contains($n, '/'))) {
return $this->doInstallModules($names);
}
return $this->doInstallModules(collect(explode(',', $opt))
->map(fn (string $name) => strtolower(trim($name)))
->filter()
->map(fn (string $name) => str_contains($name, '/') ? $name : 'saucebase/'.$name)
->values()
->all());
}

if (! $opt && empty($this->selectedModules) && ! $this->option('all-modules')) {
Expand Down Expand Up @@ -717,7 +738,16 @@
});

if (! $ok) {
$this->components->warn("{$label} failed. Run it again to see why: ".implode(' ', array_diff($command, ['--no-interaction'])));
// ANSI codes and blank lines out; the end of the output is where the reason is.
$why = collect(explode("\n", (string) preg_replace('/\e\[[0-9;]*m/', '', (string) $this->lastFailure)))
->map(fn (string $line) => trim($line))->filter()
// Composer's progress, per-package and usage lines bury the reason.
->reject(fn (string $line) => (bool) preg_match('/^(\d+(\/\d+)? \[|- (Installing|Downloading|Locking|Excluded)|require \[|Loading composer|Updating dependencies|Lock file operations|Writing lock file|Installing dependencies|Package operations|Generating .*autoload)/', $line))

Check warning on line 745 in src/Console/Commands/InstallCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 292 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH6tY8e6Zu4sJ8julS3&open=AaH6tY8e6Zu4sJ8julS3&pullRequest=38
->take(-12)->implode("\n");
// The reason only: the failure box's resume command reruns this step and every
// one after it (the build, HTTPS); re-running this one alone would skip them.
$this->failedTask = $label;
$this->components->warn("{$label} failed".($why !== '' ? ":\n{$why}" : '.'));
}

return $ok;
Expand All @@ -742,22 +772,6 @@
return $available;
}

// 2. Modules passed via --modules option
if ($modules = $this->option('modules')) {
$requested = collect(explode(',', $modules))
->map(fn ($m) => strtolower(trim($m)))
->filter()
->values();

return collect($available)
->filter(function (string $package) use ($requested) {
return $requested->contains(strtolower($package))
|| $requested->contains(strtolower(Str::after($package, '/')));
})
->values()
->all();
}

return $this->selectedModules;
}

Expand Down Expand Up @@ -829,6 +843,8 @@
/** @return array<int, string> */
protected function failureCalloutContent(?string $step): array
{
$step ??= $this->failedTask;

return array_values(array_filter([
$step ? "Failed at: {$step}" : null,
'Your application directory is intact — nothing was rolled back.',
Expand All @@ -854,10 +870,20 @@
$command .= ' '.$this->selectedStack;
}

// Herd's choice is only on the command line; Docker's comes back resolved.
if (! isset($resumeOptions['--ssl']) && ($ssl = $this->optionOrNull('ssl'))) {
$resumeOptions['--ssl'] = $ssl;
}

foreach ($resumeOptions as $option => $value) {
$command .= " {$option}={$value}";
}

// Free text: quoted, so a name with spaces or quotes survives the shell.
if ($name = $this->optionOrNull('app-name')) {
$command .= ' --app-name='.escapeshellarg($name);
}

if ($this->domain !== null) {
$command .= ' --domain='.$this->domain;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Console/Commands/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function handle(): int

$ssl = $this->ssl($driver);

if ($ssl === true && ! $driver->hasCommand('mkcert')) {
// Docker's certificates come from mkcert: checked here, before the project exists, so a
// missing one leaves nothing half-made. Herd secures with `herd secure` instead.
if ($ssl === true && $driver->name() === 'docker' && ! $driver->hasCommand('mkcert')) {
$this->error('mkcert is required for SSL. Install it with: brew install mkcert');
$this->info('Official mkcert installation instructions: https://github.com/FiloSottile/mkcert');

Expand Down
31 changes: 29 additions & 2 deletions src/Console/Commands/StackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,22 @@

$this->info("Framework set to {$framework} (dev mode)");

// A template's own files (CSS, page shell, tsconfig) are core's to put back, not this command's.
if (is_string($this->projectJson()['template'] ?? null)) {
$this->line('Template workspace: run `'.$this->inWorkspace('php artisan saucebase:template-capture --restore').'` to put its files back for this stack.');

Check warning on line 131 in src/Console/Commands/StackCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 166 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH60lxYKWHopb5SW3fx&open=AaH60lxYKWHopb5SW3fx&pullRequest=38
}

return self::SUCCESS;
}

/** A command for the workspace to run: from elsewhere (--path), it goes there first. */
private function inWorkspace(string $command): string
{
return realpath($this->basePath) === realpath((string) getcwd())
? $command
: 'cd '.escapeshellarg($this->basePath)." && {$command}";
}

private function runReset(): int
{
$framework = $this->getSelectedFramework();
Expand All @@ -140,14 +153,21 @@
}

if ($this->cssEdited() && ! $this->option('force')) {
$this->error('resources/css has changes that are not in saucebase/core. Run `saucebase stack --sync` '
.'to keep them, or `saucebase stack --reset --force` to discard them.');
// A template's CSS belongs in its stubs, never in core: --sync would push it there.
$this->error(is_string($this->projectJson()['template'] ?? null)
? 'resources/css differs from saucebase/core. Keep template changes with `'.$this->inWorkspace('php artisan saucebase:template-capture').'`, '

Check warning on line 158 in src/Console/Commands/StackCommand.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 158 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH60lxYKWHopb5SW3fy&open=AaH60lxYKWHopb5SW3fy&pullRequest=38
.'then run `'.$this->inWorkspace('saucebase stack --reset --force').'`.'
: 'resources/css has changes that are not in saucebase/core. Run `saucebase stack --sync` '
.'to keep them, or `saucebase stack --reset --force` to discard them.');

return self::FAILURE;
}

$this->info("Resetting framework '{$framework}'...");

// What the workspace set itself (the template it builds, say) outlives the stack.
$kept = array_diff_key($this->projectJson(), array_flip(['framework', 'contributor']));

$this->restoreTrackedFiles($framework);

foreach ($this->generatedFiles($framework) as $file) {
Expand All @@ -168,6 +188,13 @@
$this->files->delete($lockfile);
}

if ($kept !== []) {
$this->files->put(
$this->basePath.'/saucebase.json',
json_encode([...$this->projectJson(), ...$kept], JSON_PRETTY_PRINT).PHP_EOL,
);
}

$this->info('Reset complete. Run: npm install to restore base dependencies.');

return self::SUCCESS;
Expand Down
12 changes: 12 additions & 0 deletions src/Environments/DockerEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,24 @@
$this->execInContainer($command, ['php', 'artisan', 'storage:link']);
}

protected function printedArtisan(): string
{
return 'docker compose exec app php artisan';
}

/** Inside the app container: on the host, `.env` points at hostnames only Docker resolves. */
protected function artisan(InstallCommand $command, array $args): bool
{
return $this->execInContainer($command, ['php', 'artisan', ...$args], quiet: true);
}

protected function artisanOutput(InstallCommand $command, array $args): ?string
{
$result = Process::path($command->targetPath())->timeout(120)->run(['docker', 'compose', 'exec', '-T', 'app', 'php', 'artisan', ...$args]);

Check warning on line 841 in src/Environments/DockerEnvironment.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 147 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_installer&issues=AaH6tY9C6Zu4sJ8julS4&open=AaH6tY9C6Zu4sJ8julS4&pullRequest=38

return $result->successful() ? $result->output() : null;
}

protected function clearCaches(InstallCommand $command): void
{
$command->info('Clearing caches...');
Expand Down
Loading