shouldDeferInstallerHooks()) { return self::SUCCESS; } if (! file_exists(base_path('chisel.php'))) { return self::SUCCESS; } /** @var Script $script */ $script = require base_path('chisel.php'); $providedAnswers = $this->option('answers') === null ? [] : json_decode((string) $this->option('answers'), true, 512, JSON_THROW_ON_ERROR); $answers = $script ->collectAnswers() ->onQuestion(fn (Question $question) => multiselect( label: $question->label, options: $question->options, default: $question->default ?? [], required: $question->required, hint: $question->hint, )) ->interactive($this->input->isInteractive()) ->withAnswers($providedAnswers); $skipNode = $this->shouldSkipNode(); if (! $skipNode) { $this->installNodeDependencies(); } $script->chisel($answers); if (! $skipNode) { $this->buildAssets(); } return self::SUCCESS; } protected function shouldDeferInstallerHooks(): bool { if ($this->option('answers') !== null) { return false; } return $this->installerFlag('LARAVEL_INSTALLER_DEFER_HOOKS'); } protected function shouldSkipNode(): bool { return $this->installerFlag('LARAVEL_INSTALLER_NO_NODE'); } protected function installerFlag(string $name): bool { return filter_var( $_ENV[$name] ?? $_SERVER[$name] ?? getenv($name), FILTER_VALIDATE_BOOL, ); } protected function installNodeDependencies(): void { $npm = Chisel::in(base_path())->npm(); $packageManager = $npm->packageManager(); spin( fn () => $npm->install(), "Installing dependencies with {$packageManager->value}...", ); } protected function buildAssets(): void { $npm = Chisel::in(base_path())->npm(); spin( fn () => $npm->run('build'), 'Building assets...', ); } }