-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unbroken previous change for removing publish command
- Loading branch information
Nicolas Utzinger
committed
Jun 1, 2024
1 parent
a066072
commit 8c671a2
Showing
4 changed files
with
80 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Native\Electron\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Native\Electron\Concerns\LocatesPhpBinary; | ||
use Native\Electron\Traits\OsAndArch; | ||
|
||
use function Laravel\Prompts\confirm; | ||
use function Laravel\Prompts\select; | ||
|
||
class PublishCommand extends Command | ||
{ | ||
use LocatesPhpBinary; | ||
use OsAndArch; | ||
|
||
protected $signature = 'native:publish | ||
{os? : The operating system to build for (linux, mac, win)} | ||
{arch? : The Processor Architecture to build for (-x64, -x86, -arm64)}'; | ||
|
||
public function handle(): void | ||
{ | ||
$this->info('Building and publishing NativePHP app…'); | ||
|
||
if (! $os = $this->argument('os')) { | ||
// Dependos on available publish commands | ||
$os = select( | ||
label: 'Please select the operating system to build for', | ||
options: ['win', 'linux', 'mac'], | ||
default: $this->getDefaultOs(), | ||
); | ||
} | ||
|
||
// Depends on the currenty available php executables | ||
if (! $arch = $this->argument('arch')) { | ||
$arch = select( | ||
label: 'Please select Processor Architecture', | ||
options: ($a = $this->getArchForOs($os)), | ||
default: $a[0] | ||
); | ||
if ($arch == 'all') { | ||
$arch = ''; | ||
} | ||
} | ||
|
||
Artisan::call("native:build", ['os'=>$os, 'arch' => $arch, 'pub' => true ], $this->output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
namespace Native\Electron\Traits; | ||
|
||
trait OsAndArch { | ||
protected function getDefaultOs(): string | ||
{ | ||
return match (PHP_OS_FAMILY) { | ||
'Windows' => 'win', | ||
'Darwin' => 'mac', | ||
'Linux' => 'linux', | ||
default => 'all', | ||
}; | ||
} | ||
|
||
protected function getArchForOs(string $os): array { | ||
return match ($os) { | ||
'win' => ['-x64'], | ||
'mac' => ['-x86', '-arm', 'all'], | ||
'linux' => ['-x64'] | ||
}; | ||
} | ||
} |