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
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ This serves two purposes:
- **Breaking:** You must now use `npm run build` to compile your assets, instead of `npm run prod`
- Bundled assets are now compiled directly into the `_media` folder, and will not be copied to the `_site/media` folder by the NPM command in https://github.com/hydephp/develop/pull/2011
- The realtime compiler now only serves assets from the media source directory (`_media`), and no longer checks the site output directory (`_site/media`) in https://github.com/hydephp/develop/pull/2012
- **Breaking:** Replaced `--run-dev` and `--run-prod` build command flags with a single `--run-vite` flag that uses Vite to build assets in https://github.com/hydephp/develop/pull/2013
- Moved the Vite build step to run before the site build to prevent duplicate media asset transfers in https://github.com/hydephp/develop/pull/2013

### Deprecated

Expand Down
5 changes: 2 additions & 3 deletions docs/getting-started/console-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Here is a quick reference of all the available commands. You can also run `php h
<a name="build" style="display: inline-block; position: absolute; margin-top: -5rem;"></a>

```bash
php hyde build [--run-dev] [--run-prod] [--run-prettier] [--pretty-urls] [--no-api]
php hyde build [--run-vite] [--run-prettier] [--pretty-urls] [--no-api]
```

Build the static site
Expand All @@ -75,8 +75,7 @@ Build the static site

| | |
|------------------|--------------------------------------------|
| `--run-dev` | Run the NPM dev script after build |
| `--run-prod` | Run the NPM prod script after build |
| `--run-vite` | Build frontend assets using Vite |
| `--run-prettier` | Format the output using NPM Prettier |
| `--pretty-urls` | Should links in output use pretty URLs? |
| `--no-api` | Disable API calls, for example, Torchlight |
Expand Down
42 changes: 31 additions & 11 deletions packages/framework/src/Console/Commands/BuildSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class BuildSiteCommand extends Command
{
/** @var string */
protected $signature = 'build
{--run-dev : Run the NPM dev script after build}
{--run-prod : Run the NPM prod script after build}
{--run-vite : Build frontend assets using Vite}
{--run-prettier : Format the output using NPM Prettier}
{--pretty-urls : Should links in output use pretty URLs?}
{--no-api : Disable API calls, for example, Torchlight}';
{--no-api : Disable API calls, for example, Torchlight}
{--run-dev : [Removed] Use --run-vite instead}
{--run-prod : [Removed] Use --run-vite instead}';

/** @var string */
protected $description = 'Build the static site';
Expand All @@ -40,6 +41,12 @@ class BuildSiteCommand extends Command

public function handle(): int
{
// CodeCoverageIgnoreStart
if ($this->option('run-dev') || $this->option('run-prod')) {
return $this->deprecatedRunMixCommandFailure();
}
// CodeCoverageIgnoreEnd

$timeStart = microtime(true);

$this->title('Building your static site!');
Expand Down Expand Up @@ -85,6 +92,10 @@ protected function runPreBuildActions(): void
Config::set(['hyde.pretty_urls' => true]);
}

if ($this->option('run-vite')) {
$this->runNodeCommand('npm run build', 'Building frontend assets for production!');
}

$this->taskService->runPreBuildTasks();
}

Expand All @@ -99,14 +110,6 @@ public function runPostBuildActions(): void
'prettify code'
);
}

if ($this->option('run-dev')) {
$this->runNodeCommand('npm run dev', 'Building frontend assets for development!');
}

if ($this->option('run-prod')) {
$this->runNodeCommand('npm run build', 'Building frontend assets for production!');
}
}

protected function printFinishMessage(float $timeStart): void
Expand Down Expand Up @@ -158,4 +161,21 @@ protected function getExitCode(): int

return Command::SUCCESS;
}

/**
* This method is called when the removed --run-dev or --run-prod options are used.
*
* @deprecated Use --run-vite instead
* @since v2.0 - This will be removed after 2-3 minor releases depending on the timeframe between them. (~v2.3)
*
* @codeCoverageIgnore
*/
protected function deprecatedRunMixCommandFailure(): int
{
$this->error('The --run-dev and --run-prod options have been removed in HydePHP v2.0.');
$this->info('Please use --run-vite instead to build assets for production with Vite.');
$this->line('See https://github.com/hydephp/develop/pull/2013 for more information.');

return Command::FAILURE;
}
}
8 changes: 3 additions & 5 deletions packages/framework/tests/Feature/StaticSiteServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ public function testNodeActionOutputs()
{
Process::fake();

$this->artisan('build --run-prettier --run-dev --run-prod')
->expectsOutput('Prettifying code! This may take a second.')
->expectsOutput('Building frontend assets for development! This may take a second.')
$this->artisan('build --run-prettier --run-vite')
->expectsOutput('Building frontend assets for production! This may take a second.')
->expectsOutput('Prettifying code! This may take a second.')
->assertExitCode(0);

Process::assertRan(fn ($process) => $process->command === 'npx prettier '.Hyde::pathToRelative(Hyde::sitePath()).'/**/*.html --write --bracket-same-line');
Process::assertRan(fn ($process) => $process->command === 'npm run dev');
Process::assertRan(fn ($process) => $process->command === 'npm run build');
Process::assertRan(fn ($process) => $process->command === 'npx prettier '.Hyde::pathToRelative(Hyde::sitePath()).'/**/*.html --write --bracket-same-line');
}

public function testPrettyUrlsOptionOutput()
Expand Down