fix: seeder uses temp file to avoid heredoc conflict with piped bash

This commit is contained in:
2026-06-11 20:50:44 -05:00
parent ae93a7804f
commit 03c5b819b9

View File

@@ -225,23 +225,28 @@ success "Migrations complete."
# ── Seed Default Roles ──────────────────────────────────────────────────────── # ── Seed Default Roles ────────────────────────────────────────────────────────
step "Seeding default roles..." step "Seeding default roles..."
# Use direct PHP require so we bypass composer autoload limitations
cd "$PANEL_DIR" cd "$PANEL_DIR"
$PHP_BIN - <<'SEED_EOF' 2>&1 || warn "Seeder failed or already run — skipping." # Write seeder bootstrap to a temp file (heredoc doesn't work when script is piped)
SEED_SCRIPT="$(mktemp /tmp/addon_seed_XXXXXX.php)"
cat > "$SEED_SCRIPT" <<'PHPEOF'
<?php <?php
define('LARAVEL_START', microtime(true)); define('LARAVEL_START', microtime(true));
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php'; $app = require_once __DIR__ . '/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap(); $kernel->bootstrap();
// Include and run the seeder directly
require_once __DIR__ . '/database/seeders/DefaultRolesSeeder.php'; require_once __DIR__ . '/database/seeders/DefaultRolesSeeder.php';
$seeder = new Database\Seeders\DefaultRolesSeeder(); $seeder = new Database\Seeders\DefaultRolesSeeder();
$seeder->setContainer($app)->setCommand(new class { public function info($m) { echo " $m\n"; } }); $seeder->setContainer($app)->setCommand(new class {
public function info(string $m): void { echo " [seed] $m\n"; }
});
$seeder->run(); $seeder->run();
echo "Roles seeded successfully.\n"; echo "Roles seeded successfully.\n";
SEED_EOF PHPEOF
# Replace __DIR__ placeholder with the actual panel dir
sed -i "s|__DIR__|'${PANEL_DIR}'|g" "$SEED_SCRIPT"
$PHP_BIN "$SEED_SCRIPT" 2>&1 || warn "Seeder failed or already run — skipping."
rm -f "$SEED_SCRIPT"
success "Seeding complete." success "Seeding complete."
# ── Publish Config ──────────────────────────────────────────────────────────── # ── Publish Config ────────────────────────────────────────────────────────────