Skip to content

Commit e84a570

Browse files
committed
publish electron project
1 parent 5f53d86 commit e84a570

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/Drivers/Electron/Commands/InstallCommand.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace Native\Desktop\Drivers\Electron\Commands;
44

55
use Illuminate\Console\Command;
6+
use Native\Desktop\Drivers\Electron\Traits\CreatesElectronProject;
67
use Native\Desktop\Drivers\Electron\Traits\Installer;
78
use Native\Desktop\Support\Composer;
89
use Symfony\Component\Console\Attribute\AsCommand;
910

1011
use function Laravel\Prompts\confirm;
12+
use function Laravel\Prompts\info;
1113
use function Laravel\Prompts\intro;
1214
use function Laravel\Prompts\outro;
1315

@@ -17,6 +19,7 @@
1719
)]
1820
class InstallCommand extends Command
1921
{
22+
use CreatesElectronProject;
2023
use Installer;
2124

2225
protected $signature = 'native:install
@@ -25,25 +28,34 @@ class InstallCommand extends Command
2528

2629
public function handle(): void
2730
{
28-
intro('Publishing NativePHP Service Provider...');
29-
3031
$withoutInteraction = $this->option('no-interaction');
3132

33+
// Publish provider & config
34+
intro('Publishing NativePHP Service Provider...');
3235
$this->call('vendor:publish', ['--tag' => 'nativephp-provider']);
3336
$this->call('vendor:publish', ['--tag' => 'nativephp-config']);
3437

38+
// Install Composer scripts
39+
intro('Installing composer scripts');
3540
Composer::installScripts();
3641

37-
$installer = $this->getInstaller($this->option('installer'));
42+
// Create Electron project
43+
// NOTE: Consider making this optional
44+
intro('Creating Electron project');
45+
$installPath = base_path('nativephp/electron');
46+
$this->createElectronProject($installPath);
47+
info('Created Electron project in `./nativephp/electron`');
3848

49+
// Install NPM Dependencies
50+
$installer = $this->getInstaller($this->option('installer'));
3951
$this->installNPMDependencies(
4052
force: $this->option('force'),
4153
installer: $installer,
4254
withoutInteraction: $withoutInteraction
4355
);
4456

57+
// Promt to serve the app
4558
$shouldPromptForServe = ! $withoutInteraction && ! $this->option('force');
46-
4759
if ($shouldPromptForServe && confirm('Would you like to start the NativePHP development server', false)) {
4860
$this->call('native:serve', [
4961
'--installer' => $installer,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Native\Desktop\Drivers\Electron\Traits;
4+
5+
use Illuminate\Support\Facades\File;
6+
use Native\Desktop\Support\Composer;
7+
use Symfony\Component\Filesystem\Filesystem;
8+
9+
trait CreatesElectronProject
10+
{
11+
public function createElectronProject($installPath)
12+
{
13+
$sourcePath = Composer::desktopPackagePath('resources/electron');
14+
15+
File::ensureDirectoryExists($installPath, 0755, true);
16+
17+
(new Filesystem)->mirror(
18+
$sourcePath,
19+
$installPath,
20+
options: [
21+
'override' => true,
22+
'delete' => true,
23+
]
24+
);
25+
}
26+
}

0 commit comments

Comments
 (0)