Skip to content

Commit

Permalink
Implement signature option for asset-build
Browse files Browse the repository at this point in the history
- Specify `--assets` to build assets
- If --asset-build is unspecified, we'll try to run `npm run build`.
- A specific build command can be specified like so `--asset-build=my-build-command`
  • Loading branch information
PeteBishwhip committed Feb 15, 2025
1 parent 5305c19 commit e9caa32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Laravel",
"name": "NativePHP",
"version": "1.0.0",
"description": "A NativePHP Electron application",
"main": "./out/main/index.js",
Expand Down Expand Up @@ -105,4 +105,4 @@
"#plugin": "./electron-plugin/dist/index.js"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
8 changes: 6 additions & 2 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class BuildCommand extends Command
protected $signature = 'native:build
{os? : The operating system to build for (all, linux, mac, win)}
{arch? : The Processor Architecture to build for (x64, x86, arm64)}
{--publish : to publish the app}';
{--publish : to publish the app}
{--assets : to build the project assets}
{--asset-build=build : The NPM script to run to build your project assets}';

protected $availableOs = ['win', 'linux', 'mac', 'all'];

Expand All @@ -41,7 +43,9 @@ public function handle(): void
echo $output;
});

$this->checkAndBuildProjectAssets(null);
if ($this->option('assets')) {
$this->checkAndBuildProjectAssets($this->option('asset-build'));
}

$os = $this->selectOs($this->argument('os'));

Expand Down
9 changes: 7 additions & 2 deletions src/Traits/ManagesAssetBuilding.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ public function checkAndBuildProjectAssets(?string $buildCommand): ?ProcessResul
}

if (! isset($scripts[$buildCommand])) {
$this->error('Invalid script selected... Continuing...');
// We might get here if the script wasn't defined and the default was used.
// We can try to prompt the user again.
$buildCommand = $this->promptForAssetBuildCommand($scripts);

return null;
if (! isset($scripts[$buildCommand])) {
$this->error('Invalid script selected. Exiting…');
return null;
}
}

$this->info('Building project assets…');
Expand Down

0 comments on commit e9caa32

Please sign in to comment.