diff --git a/.gitignore b/.gitignore index 3dd7896c..69fdb2d1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ testbench.yaml vendor node_modules .DS_Store +!tests/Build diff --git a/composer.json b/composer.json index 7aa2ff77..19095a8d 100644 --- a/composer.json +++ b/composer.json @@ -61,8 +61,7 @@ }, "autoload": { "psr-4": { - "Native\\Desktop\\": "src/Desktop", - "Native\\Electron\\": "src/Electron" + "Native\\Desktop\\": "src" } }, "autoload-dev": { @@ -92,8 +91,7 @@ "extra": { "laravel": { "providers": [ - "Native\\Desktop\\NativeServiceProvider", - "Native\\Electron\\ElectronServiceProvider" + "Native\\Desktop\\NativeServiceProvider" ], "aliases": { "ChildProcess": "Native\\Desktop\\Facades\\ChildProcess", diff --git a/phpstan.neon b/phpstan.neon index 737434dc..9b0b672a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -18,4 +18,4 @@ parameters: excludePaths: - - ./src/Desktop/NativeServiceProvider.php + - ./src/NativeServiceProvider.php diff --git a/resources/electron/build/icon.png b/resources/electron/build/icon.png new file mode 100644 index 00000000..9c89cdbb Binary files /dev/null and b/resources/electron/build/icon.png differ diff --git a/src/Desktop/Alert.php b/src/Alert.php similarity index 100% rename from src/Desktop/Alert.php rename to src/Alert.php diff --git a/src/Desktop/App.php b/src/App.php similarity index 100% rename from src/Desktop/App.php rename to src/App.php diff --git a/src/Desktop/AutoUpdater.php b/src/AutoUpdater.php similarity index 100% rename from src/Desktop/AutoUpdater.php rename to src/AutoUpdater.php diff --git a/src/Builder/Builder.php b/src/Builder/Builder.php new file mode 100644 index 00000000..76db30da --- /dev/null +++ b/src/Builder/Builder.php @@ -0,0 +1,50 @@ +sourcePath = $sourcePath + ? $sourcePath + : base_path(); + } + + public static function make( + string $buildPath, + ?string $sourcePath = null + ) { + return new self($buildPath, $sourcePath); + } + + public function buildPath(string $path = ''): string + { + return Path::join($this->buildPath, $path); + } + + public function sourcePath(string $path = ''): string + { + return Path::join($this->sourcePath, $path); + } +} diff --git a/src/Electron/Traits/CleansEnvFile.php b/src/Builder/Concerns/CleansEnvFile.php similarity index 87% rename from src/Electron/Traits/CleansEnvFile.php rename to src/Builder/Concerns/CleansEnvFile.php index 9eb493d6..45d2e0cd 100644 --- a/src/Electron/Traits/CleansEnvFile.php +++ b/src/Builder/Concerns/CleansEnvFile.php @@ -3,15 +3,13 @@ /** * This trait is responsible for cleaning any sensitive information from the .env file * and also injects some defaults that need to be set as soon as possible. - * - * TODO: When more drivers/adapters are added, this should be relocated */ -namespace Native\Electron\Traits; +namespace Native\Desktop\Builder\Concerns; trait CleansEnvFile { - abstract protected function buildPath(string $path = ''): string; + abstract public function buildPath(string $path = ''): string; public array $overrideKeys = [ 'LOG_CHANNEL', diff --git a/src/Electron/Traits/CopiesBundleToBuildDirectory.php b/src/Builder/Concerns/CopiesBundleToBuildDirectory.php similarity index 79% rename from src/Electron/Traits/CopiesBundleToBuildDirectory.php rename to src/Builder/Concerns/CopiesBundleToBuildDirectory.php index 5d0f0989..9a819a1e 100644 --- a/src/Electron/Traits/CopiesBundleToBuildDirectory.php +++ b/src/Builder/Concerns/CopiesBundleToBuildDirectory.php @@ -1,6 +1,6 @@ exists($this->sourcePath(self::$bundlePath)); } @@ -21,9 +21,9 @@ public function copyBundleToBuildDirectory(): bool { $filesystem = new Filesystem; - $this->line('Copying secure app bundle to build directory...'); - $this->line('From: '.realpath(dirname($this->sourcePath(self::$bundlePath)))); - $this->line('To: '.realpath(dirname($this->buildPath(self::$bundlePath)))); + echo 'Copying secure app bundle to build directory...'.PHP_EOL; + echo 'From: '.realpath(dirname($this->sourcePath(self::$bundlePath))).PHP_EOL; + echo 'To: '.realpath(dirname($this->buildPath(self::$bundlePath))).PHP_EOL; // Clean and create build directory $filesystem->remove($this->buildPath()); @@ -36,7 +36,7 @@ public function copyBundleToBuildDirectory(): bool foreach ($filesToCopy as $file) { $filesystem->copy($this->sourcePath($file), $this->buildPath($file), true); } - // $this->keepRequiredDirectories(); + $this->keepRequiredDirectories(); return true; } diff --git a/src/Builder/Concerns/CopiesCertificateAuthority.php b/src/Builder/Concerns/CopiesCertificateAuthority.php new file mode 100644 index 00000000..7164401d --- /dev/null +++ b/src/Builder/Concerns/CopiesCertificateAuthority.php @@ -0,0 +1,38 @@ +getMessage()); + } + } +} diff --git a/src/Electron/Traits/CopiesToBuildDirectory.php b/src/Builder/Concerns/CopiesToBuildDirectory.php similarity index 93% rename from src/Electron/Traits/CopiesToBuildDirectory.php rename to src/Builder/Concerns/CopiesToBuildDirectory.php index 0faaff17..d0c73523 100644 --- a/src/Electron/Traits/CopiesToBuildDirectory.php +++ b/src/Builder/Concerns/CopiesToBuildDirectory.php @@ -3,11 +3,9 @@ /** * This trait is responsible for copying over the app to the build directory. * It skips any ignored paths/globs during the copy step - * - * TODO: When more drivers/adapters are added, this should be relocated */ -namespace Native\Electron\Traits; +namespace Native\Desktop\Builder\Concerns; use RecursiveCallbackFilterIterator; use RecursiveDirectoryIterator; @@ -19,9 +17,9 @@ trait CopiesToBuildDirectory { - abstract protected function buildPath(string $path = ''): string; + abstract public function buildPath(string $path = ''): string; - abstract protected function sourcePath(string $path = ''): string; + abstract public function sourcePath(string $path = ''): string; public function copyToBuildDirectory(): bool { diff --git a/src/Electron/Traits/HasPreAndPostProcessing.php b/src/Builder/Concerns/HasPreAndPostProcessing.php similarity index 97% rename from src/Electron/Traits/HasPreAndPostProcessing.php rename to src/Builder/Concerns/HasPreAndPostProcessing.php index 61c81f4d..9bee88c5 100644 --- a/src/Electron/Traits/HasPreAndPostProcessing.php +++ b/src/Builder/Concerns/HasPreAndPostProcessing.php @@ -1,6 +1,6 @@ binaryPackageDirectory().'bin/'; + return $this->sourcePath($this->binaryPackageDirectory().'bin/'); } } diff --git a/src/Electron/Traits/PrunesVendorDirectory.php b/src/Builder/Concerns/PrunesVendorDirectory.php similarity index 78% rename from src/Electron/Traits/PrunesVendorDirectory.php rename to src/Builder/Concerns/PrunesVendorDirectory.php index 6f9ad0de..565aa8ea 100644 --- a/src/Electron/Traits/PrunesVendorDirectory.php +++ b/src/Builder/Concerns/PrunesVendorDirectory.php @@ -1,19 +1,15 @@ buildPath()) ->timeout(300) diff --git a/src/Desktop/ChildProcess.php b/src/ChildProcess.php similarity index 100% rename from src/Desktop/ChildProcess.php rename to src/ChildProcess.php diff --git a/src/Desktop/Client/Client.php b/src/Client/Client.php similarity index 100% rename from src/Desktop/Client/Client.php rename to src/Client/Client.php diff --git a/src/Desktop/Clipboard.php b/src/Clipboard.php similarity index 100% rename from src/Desktop/Clipboard.php rename to src/Clipboard.php diff --git a/src/Desktop/Commands/DebugCommand.php b/src/Commands/DebugCommand.php similarity index 100% rename from src/Desktop/Commands/DebugCommand.php rename to src/Commands/DebugCommand.php diff --git a/src/Desktop/Commands/FreshCommand.php b/src/Commands/FreshCommand.php similarity index 100% rename from src/Desktop/Commands/FreshCommand.php rename to src/Commands/FreshCommand.php diff --git a/src/Desktop/Commands/LoadPHPConfigurationCommand.php b/src/Commands/LoadPHPConfigurationCommand.php similarity index 100% rename from src/Desktop/Commands/LoadPHPConfigurationCommand.php rename to src/Commands/LoadPHPConfigurationCommand.php diff --git a/src/Desktop/Commands/LoadStartupConfigurationCommand.php b/src/Commands/LoadStartupConfigurationCommand.php similarity index 100% rename from src/Desktop/Commands/LoadStartupConfigurationCommand.php rename to src/Commands/LoadStartupConfigurationCommand.php diff --git a/src/Desktop/Commands/MigrateCommand.php b/src/Commands/MigrateCommand.php similarity index 100% rename from src/Desktop/Commands/MigrateCommand.php rename to src/Commands/MigrateCommand.php diff --git a/src/Desktop/Commands/SeedDatabaseCommand.php b/src/Commands/SeedDatabaseCommand.php similarity index 100% rename from src/Desktop/Commands/SeedDatabaseCommand.php rename to src/Commands/SeedDatabaseCommand.php diff --git a/src/Desktop/Commands/WipeDatabaseCommand.php b/src/Commands/WipeDatabaseCommand.php similarity index 100% rename from src/Desktop/Commands/WipeDatabaseCommand.php rename to src/Commands/WipeDatabaseCommand.php diff --git a/src/Desktop/Concerns/DetectsWindowId.php b/src/Concerns/DetectsWindowId.php similarity index 100% rename from src/Desktop/Concerns/DetectsWindowId.php rename to src/Concerns/DetectsWindowId.php diff --git a/src/Desktop/Concerns/HasDimensions.php b/src/Concerns/HasDimensions.php similarity index 100% rename from src/Desktop/Concerns/HasDimensions.php rename to src/Concerns/HasDimensions.php diff --git a/src/Desktop/Concerns/HasPositioner.php b/src/Concerns/HasPositioner.php similarity index 100% rename from src/Desktop/Concerns/HasPositioner.php rename to src/Concerns/HasPositioner.php diff --git a/src/Desktop/Concerns/HasUrl.php b/src/Concerns/HasUrl.php similarity index 100% rename from src/Desktop/Concerns/HasUrl.php rename to src/Concerns/HasUrl.php diff --git a/src/Desktop/Concerns/HasVibrancy.php b/src/Concerns/HasVibrancy.php similarity index 100% rename from src/Desktop/Concerns/HasVibrancy.php rename to src/Concerns/HasVibrancy.php diff --git a/src/Desktop/ContextMenu.php b/src/ContextMenu.php similarity index 100% rename from src/Desktop/ContextMenu.php rename to src/ContextMenu.php diff --git a/src/Desktop/Contracts/ChildProcess.php b/src/Contracts/ChildProcess.php similarity index 100% rename from src/Desktop/Contracts/ChildProcess.php rename to src/Contracts/ChildProcess.php diff --git a/src/Desktop/Contracts/GlobalShortcut.php b/src/Contracts/GlobalShortcut.php similarity index 100% rename from src/Desktop/Contracts/GlobalShortcut.php rename to src/Contracts/GlobalShortcut.php diff --git a/src/Desktop/Contracts/MenuItem.php b/src/Contracts/MenuItem.php similarity index 100% rename from src/Desktop/Contracts/MenuItem.php rename to src/Contracts/MenuItem.php diff --git a/src/Desktop/Contracts/PowerMonitor.php b/src/Contracts/PowerMonitor.php similarity index 100% rename from src/Desktop/Contracts/PowerMonitor.php rename to src/Contracts/PowerMonitor.php diff --git a/src/Desktop/Contracts/ProvidesPhpIni.php b/src/Contracts/ProvidesPhpIni.php similarity index 100% rename from src/Desktop/Contracts/ProvidesPhpIni.php rename to src/Contracts/ProvidesPhpIni.php diff --git a/src/Desktop/Contracts/QueueWorker.php b/src/Contracts/QueueWorker.php similarity index 79% rename from src/Desktop/Contracts/QueueWorker.php rename to src/Contracts/QueueWorker.php index 30ddd450..e3f4c398 100644 --- a/src/Desktop/Contracts/QueueWorker.php +++ b/src/Contracts/QueueWorker.php @@ -2,7 +2,7 @@ namespace Native\Desktop\Contracts; -use Native\Desktop\DTOs\QueueConfig; +use Native\Desktop\DataObjects\QueueConfig; interface QueueWorker { diff --git a/src/Desktop/Contracts/WindowManager.php b/src/Contracts/WindowManager.php similarity index 100% rename from src/Desktop/Contracts/WindowManager.php rename to src/Contracts/WindowManager.php diff --git a/src/Desktop/DataObjects/Printer.php b/src/DataObjects/Printer.php similarity index 100% rename from src/Desktop/DataObjects/Printer.php rename to src/DataObjects/Printer.php diff --git a/src/Desktop/DTOs/QueueConfig.php b/src/DataObjects/QueueConfig.php similarity index 96% rename from src/Desktop/DTOs/QueueConfig.php rename to src/DataObjects/QueueConfig.php index ba1187c8..8214775a 100644 --- a/src/Desktop/DTOs/QueueConfig.php +++ b/src/DataObjects/QueueConfig.php @@ -1,6 +1,6 @@ buildCommand = 'publish'; } - if ($this->hasBundled()) { + if ($this->builder->hasBundled()) { $this->buildBundle(); } else { - $this->warnUnsecureBuild(); + $this->builder->warnUnsecureBuild(); $this->buildUnsecure(); } } private function buildBundle(): void { + $this->builder->preProcess(); + $this->setAppNameAndVersion(); $this->updateElectronDependencies(); $this->newLine(); intro('Copying Bundle to build directory...'); - $this->copyBundleToBuildDirectory(); - $this->keepRequiredDirectories(); + $this->builder->copyBundleToBuildDirectory(); $this->newLine(); - $this->copyCertificateAuthorityCertificate(); + intro('Copying latest CA Certificate...'); + $this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources'); $this->newLine(); intro('Copying app icons...'); $this->installIcon(); $this->buildOrPublish(); + + $this->builder->postProcess(); } private function buildUnsecure(): void { - $this->preProcess(); + $this->builder->preProcess(); $this->setAppNameAndVersion(); @@ -112,14 +101,15 @@ private function buildUnsecure(): void $this->newLine(); intro('Copying App to build directory...'); - $this->copyToBuildDirectory(); + $this->builder->copyToBuildDirectory(); $this->newLine(); - $this->copyCertificateAuthorityCertificate(); + intro('Copying latest CA Certificate...'); + $this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources'); $this->newLine(); intro('Cleaning .env file...'); - $this->cleanEnvFile(); + $this->builder->cleanEnvFile(); $this->newLine(); intro('Copying app icons...'); @@ -127,22 +117,22 @@ private function buildUnsecure(): void $this->newLine(); intro('Pruning vendor directory'); - $this->pruneVendorDirectory(); + $this->builder->pruneVendorDirectory(); $this->buildOrPublish(); - $this->postProcess(); + $this->builder->postProcess(); } protected function getEnvironmentVariables(): array { return array_merge( [ - 'APP_PATH' => $this->sourcePath(), + 'APP_PATH' => $this->builder->sourcePath(), 'APP_URL' => config('app.url'), 'NATIVEPHP_BUILDING' => true, 'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION, - 'NATIVEPHP_PHP_BINARY_PATH' => $this->sourcePath($this->phpBinaryPath()), + 'NATIVEPHP_PHP_BINARY_PATH' => $this->builder->phpBinaryPath(), 'NATIVEPHP_APP_NAME' => config('app.name'), 'NATIVEPHP_APP_ID' => config('nativephp.app_id'), 'NATIVEPHP_APP_VERSION' => config('nativephp.version'), diff --git a/src/Electron/Commands/BundleCommand.php b/src/Drivers/Electron/Commands/BundleCommand.php similarity index 87% rename from src/Electron/Commands/BundleCommand.php rename to src/Drivers/Electron/Commands/BundleCommand.php index 898563c2..3304c35a 100644 --- a/src/Electron/Commands/BundleCommand.php +++ b/src/Drivers/Electron/Commands/BundleCommand.php @@ -1,6 +1,6 @@ builder = Builder::make( + buildPath: base_path('build/app/') + ); + } + public function handle(): int { // Remove the bundle @@ -88,17 +90,17 @@ public function handle(): int return static::SUCCESS; } - $this->preProcess(); + $this->builder->preProcess(); $this->setAppNameAndVersion(); intro('Copying App to build directory...'); // We update composer.json later, - $this->copyToBuildDirectory(); + $this->builder->copyToBuildDirectory(); $this->newLine(); intro('Cleaning .env file...'); - $this->cleanEnvFile(); + $this->builder->cleanEnvFile(); $this->newLine(); intro('Copying app icons...'); @@ -106,9 +108,7 @@ public function handle(): int $this->newLine(); intro('Pruning vendor directory'); - $this->pruneVendorDirectory(); - - $this->cleanEnvFile(); + $this->builder->pruneVendorDirectory(); // Check composer.json for symlinked or private packages if (! $this->checkComposerJson()) { @@ -161,7 +161,7 @@ private function zipApplication(): bool private function checkComposerJson(): bool { - $composerJson = json_decode(file_get_contents($this->buildPath('composer.json')), true); + $composerJson = json_decode(file_get_contents($this->builder->buildPath('composer.json')), true); // // Fail if there is symlinked packages // foreach ($composerJson['repositories'] ?? [] as $repository) { @@ -194,10 +194,10 @@ private function checkComposerJson(): bool if (count($filteredRepo) !== count($composerJson['repositories'])) { $composerJson['repositories'] = $filteredRepo; - file_put_contents($this->buildPath('composer.json'), + file_put_contents($this->builder->buildPath('composer.json'), json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); - // Process::path($this->buildPath()) + // Process::path($this->builder->buildPath()) // ->run('composer install --no-dev', function (string $type, string $output) { // echo $output; // }); @@ -228,7 +228,7 @@ private function addFilesToZip(ZipArchive $zip): void $finder = (new Finder)->files() ->followLinks() // ->ignoreVCSIgnored(true) // TODO: Make our own list of ignored files - ->in($this->buildPath()) + ->in($this->builder->buildPath()) ->exclude([ // We add those a few lines below and they are ignored by most .gitignore anyway 'vendor', @@ -246,39 +246,39 @@ private function addFilesToZip(ZipArchive $zip): void $this->finderToZip($finder, $zip); // Why do I have to force this? please someone explain. - if (file_exists($this->buildPath('public/build'))) { + if (file_exists($this->builder->buildPath('public/build'))) { $this->finderToZip( (new Finder)->files() ->followLinks() - ->in($this->buildPath('public/build')), $zip, 'public/build'); + ->in($this->builder->buildPath('public/build')), $zip, 'public/build'); } // Add .env file manually because Finder ignores VCS and dot files - $zip->addFile($this->buildPath('.env'), '.env'); + $zip->addFile($this->builder->buildPath('.env'), '.env'); // Add auth.json file to support private packages // WARNING: Only for testing purposes, don't uncomment this - // $zip->addFile($this->buildPath('auth.json'), 'auth.json'); + // $zip->addFile($this->builder->buildPath('auth.json'), 'auth.json'); // Custom binaries - $binaryPath = Str::replaceStart($this->buildPath('vendor'), '', config('nativephp.binary_path')); + $binaryPath = Str::replaceStart($this->builder->buildPath('vendor'), '', config('nativephp.binary_path')); // Add composer dependencies without unnecessary files $vendor = (new Finder)->files() ->exclude(array_filter([ 'nativephp/php-bin', - 'nativephp/electron/resources/electron', + 'nativephp/desktop/resources/electron', '*/*/vendor', // Exclude sub-vendor directories $binaryPath, ])) - ->in($this->buildPath('vendor')); + ->in($this->builder->buildPath('vendor')); $this->finderToZip($vendor, $zip, 'vendor'); // Add javascript dependencies - if (file_exists($this->buildPath('node_modules'))) { + if (file_exists($this->builder->buildPath('node_modules'))) { $nodeModules = (new Finder)->files() - ->in($this->buildPath('node_modules')); + ->in($this->builder->buildPath('node_modules')); $this->finderToZip($nodeModules, $zip, 'node_modules'); } @@ -373,7 +373,7 @@ private function handleApiErrors(Response $result): void protected function cleanUp(): void { - $this->postProcess(); + $this->builder->postProcess(); if ($this->option('without-cleanup')) { return; @@ -395,18 +395,8 @@ protected function cleanUp(): void } } - protected function buildPath(string $path = ''): string - { - return base_path('build/app/'.$path); - } - protected function zipPath(string $path = ''): string { return base_path('build/zip/'.$path); } - - protected function sourcePath(string $path = ''): string - { - return base_path($path); - } } diff --git a/src/Electron/Commands/DevelopCommand.php b/src/Drivers/Electron/Commands/DevelopCommand.php similarity index 78% rename from src/Electron/Commands/DevelopCommand.php rename to src/Drivers/Electron/Commands/DevelopCommand.php index c87c0baf..1798eea4 100644 --- a/src/Electron/Commands/DevelopCommand.php +++ b/src/Drivers/Electron/Commands/DevelopCommand.php @@ -1,14 +1,14 @@ installIcon(); - $this->copyCertificateAuthorityCertificate(); + $this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources'); $this->runDeveloper( installer: $this->option('installer'), diff --git a/src/Electron/Commands/InstallCommand.php b/src/Drivers/Electron/Commands/InstallCommand.php similarity index 56% rename from src/Electron/Commands/InstallCommand.php rename to src/Drivers/Electron/Commands/InstallCommand.php index 29626b31..408e25db 100644 --- a/src/Electron/Commands/InstallCommand.php +++ b/src/Drivers/Electron/Commands/InstallCommand.php @@ -1,16 +1,14 @@ call('vendor:publish', ['--tag' => 'nativephp-provider']); $this->call('vendor:publish', ['--tag' => 'nativephp-config']); - $this->installComposerScript(); + Composer::installScripts(); $installer = $this->getInstaller($this->option('installer')); @@ -56,34 +54,4 @@ public function handle(): void outro('NativePHP scaffolding installed successfully.'); } - - private function installComposerScript() - { - info('Installing `composer native:dev` script alias...'); - - $composer = json_decode(file_get_contents(base_path('composer.json'))); - throw_unless($composer, RuntimeException::class, "composer.json couldn't be parsed"); - - $composerScripts = $composer->scripts ?? (object) []; - - if ($composerScripts->{'native:dev'} ?? false) { - note('native:dev script already installed... skipping.'); - - return; - } - - $composerScripts->{'native:dev'} = [ - 'Composer\\Config::disableProcessTimeout', - 'npx concurrently -k -c "#93c5fd,#c4b5fd" "php artisan native:serve --no-interaction" "npm run dev" --names=app,vite', - ]; - - data_set($composer, 'scripts', $composerScripts); - - file_put_contents( - base_path('composer.json'), - json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL - ); - - note('native:dev script installed!'); - } } diff --git a/src/Electron/Commands/PublishCommand.php b/src/Drivers/Electron/Commands/PublishCommand.php similarity index 87% rename from src/Electron/Commands/PublishCommand.php rename to src/Drivers/Electron/Commands/PublishCommand.php index c2aef693..e14c5502 100644 --- a/src/Electron/Commands/PublishCommand.php +++ b/src/Drivers/Electron/Commands/PublishCommand.php @@ -1,11 +1,10 @@ app->bind('nativephp.updater', function (Application $app) { return new UpdaterManager($app); }); - } - protected function getPackageBaseDir(): string - { - return dirname(parent::getPackageBaseDir()); + $this->app->bind(Builder::class, function () { + return Builder::make( + buildPath: self::ELECTRON_PATH.'/resources/app' + ); + }); } } diff --git a/src/Electron/Facades/Updater.php b/src/Drivers/Electron/Facades/Updater.php similarity index 84% rename from src/Electron/Facades/Updater.php rename to src/Drivers/Electron/Facades/Updater.php index ce1ee0cb..1b859a1e 100644 --- a/src/Electron/Facades/Updater.php +++ b/src/Drivers/Electron/Facades/Updater.php @@ -1,6 +1,6 @@ [ 'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION, - 'NATIVEPHP_PHP_BINARY_PATH' => base_path($this->phpBinaryPath()), + 'NATIVEPHP_PHP_BINARY_PATH' => $builder->phpBinaryPath(), ], 'serve' => [ 'APP_PATH' => base_path(), 'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION, - 'NATIVEPHP_PHP_BINARY_PATH' => base_path($this->phpBinaryPath()), + 'NATIVEPHP_PHP_BINARY_PATH' => $builder->phpBinaryPath(), 'NATIVE_PHP_SKIP_QUEUE' => $skip_queue, 'NATIVEPHP_BUILDING' => false, ], diff --git a/src/Electron/Traits/HandlesZephpyr.php b/src/Drivers/Electron/Traits/HandlesZephpyr.php similarity index 97% rename from src/Electron/Traits/HandlesZephpyr.php rename to src/Drivers/Electron/Traits/HandlesZephpyr.php index 26749968..b9f51b06 100644 --- a/src/Electron/Traits/HandlesZephpyr.php +++ b/src/Drivers/Electron/Traits/HandlesZephpyr.php @@ -1,6 +1,6 @@ getMessage()); - } - } -} diff --git a/src/Desktop/Enums/PowerStatesEnum.php b/src/Enums/PowerStatesEnum.php similarity index 100% rename from src/Desktop/Enums/PowerStatesEnum.php rename to src/Enums/PowerStatesEnum.php diff --git a/src/Desktop/Enums/RolesEnum.php b/src/Enums/RolesEnum.php similarity index 100% rename from src/Desktop/Enums/RolesEnum.php rename to src/Enums/RolesEnum.php diff --git a/src/Desktop/Enums/SystemIdleStatesEnum.php b/src/Enums/SystemIdleStatesEnum.php similarity index 100% rename from src/Desktop/Enums/SystemIdleStatesEnum.php rename to src/Enums/SystemIdleStatesEnum.php diff --git a/src/Desktop/Enums/SystemThemesEnum.php b/src/Enums/SystemThemesEnum.php similarity index 100% rename from src/Desktop/Enums/SystemThemesEnum.php rename to src/Enums/SystemThemesEnum.php diff --git a/src/Desktop/Enums/ThermalStatesEnum.php b/src/Enums/ThermalStatesEnum.php similarity index 100% rename from src/Desktop/Enums/ThermalStatesEnum.php rename to src/Enums/ThermalStatesEnum.php diff --git a/src/Desktop/Events/App/ApplicationBooted.php b/src/Events/App/ApplicationBooted.php similarity index 100% rename from src/Desktop/Events/App/ApplicationBooted.php rename to src/Events/App/ApplicationBooted.php diff --git a/src/Desktop/Events/App/OpenFile.php b/src/Events/App/OpenFile.php similarity index 100% rename from src/Desktop/Events/App/OpenFile.php rename to src/Events/App/OpenFile.php diff --git a/src/Desktop/Events/App/OpenedFromURL.php b/src/Events/App/OpenedFromURL.php similarity index 100% rename from src/Desktop/Events/App/OpenedFromURL.php rename to src/Events/App/OpenedFromURL.php diff --git a/src/Desktop/Events/AutoUpdater/CheckingForUpdate.php b/src/Events/AutoUpdater/CheckingForUpdate.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/CheckingForUpdate.php rename to src/Events/AutoUpdater/CheckingForUpdate.php diff --git a/src/Desktop/Events/AutoUpdater/DownloadProgress.php b/src/Events/AutoUpdater/DownloadProgress.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/DownloadProgress.php rename to src/Events/AutoUpdater/DownloadProgress.php diff --git a/src/Desktop/Events/AutoUpdater/Error.php b/src/Events/AutoUpdater/Error.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/Error.php rename to src/Events/AutoUpdater/Error.php diff --git a/src/Desktop/Events/AutoUpdater/UpdateAvailable.php b/src/Events/AutoUpdater/UpdateAvailable.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/UpdateAvailable.php rename to src/Events/AutoUpdater/UpdateAvailable.php diff --git a/src/Desktop/Events/AutoUpdater/UpdateCancelled.php b/src/Events/AutoUpdater/UpdateCancelled.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/UpdateCancelled.php rename to src/Events/AutoUpdater/UpdateCancelled.php diff --git a/src/Desktop/Events/AutoUpdater/UpdateDownloaded.php b/src/Events/AutoUpdater/UpdateDownloaded.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/UpdateDownloaded.php rename to src/Events/AutoUpdater/UpdateDownloaded.php diff --git a/src/Desktop/Events/AutoUpdater/UpdateNotAvailable.php b/src/Events/AutoUpdater/UpdateNotAvailable.php similarity index 100% rename from src/Desktop/Events/AutoUpdater/UpdateNotAvailable.php rename to src/Events/AutoUpdater/UpdateNotAvailable.php diff --git a/src/Desktop/Events/ChildProcess/ErrorReceived.php b/src/Events/ChildProcess/ErrorReceived.php similarity index 100% rename from src/Desktop/Events/ChildProcess/ErrorReceived.php rename to src/Events/ChildProcess/ErrorReceived.php diff --git a/src/Desktop/Events/ChildProcess/MessageReceived.php b/src/Events/ChildProcess/MessageReceived.php similarity index 100% rename from src/Desktop/Events/ChildProcess/MessageReceived.php rename to src/Events/ChildProcess/MessageReceived.php diff --git a/src/Desktop/Events/ChildProcess/ProcessExited.php b/src/Events/ChildProcess/ProcessExited.php similarity index 100% rename from src/Desktop/Events/ChildProcess/ProcessExited.php rename to src/Events/ChildProcess/ProcessExited.php diff --git a/src/Desktop/Events/ChildProcess/ProcessSpawned.php b/src/Events/ChildProcess/ProcessSpawned.php similarity index 100% rename from src/Desktop/Events/ChildProcess/ProcessSpawned.php rename to src/Events/ChildProcess/ProcessSpawned.php diff --git a/src/Desktop/Events/ChildProcess/StartupError.php b/src/Events/ChildProcess/StartupError.php similarity index 100% rename from src/Desktop/Events/ChildProcess/StartupError.php rename to src/Events/ChildProcess/StartupError.php diff --git a/src/Desktop/Events/EventWatcher.php b/src/Events/EventWatcher.php similarity index 100% rename from src/Desktop/Events/EventWatcher.php rename to src/Events/EventWatcher.php diff --git a/src/Desktop/Events/Menu/MenuItemClicked.php b/src/Events/Menu/MenuItemClicked.php similarity index 100% rename from src/Desktop/Events/Menu/MenuItemClicked.php rename to src/Events/Menu/MenuItemClicked.php diff --git a/src/Desktop/Events/MenuBar/MenuBarClicked.php b/src/Events/MenuBar/MenuBarClicked.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarClicked.php rename to src/Events/MenuBar/MenuBarClicked.php diff --git a/src/Desktop/Events/MenuBar/MenuBarCreated.php b/src/Events/MenuBar/MenuBarCreated.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarCreated.php rename to src/Events/MenuBar/MenuBarCreated.php diff --git a/src/Desktop/Events/MenuBar/MenuBarDoubleClicked.php b/src/Events/MenuBar/MenuBarDoubleClicked.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarDoubleClicked.php rename to src/Events/MenuBar/MenuBarDoubleClicked.php diff --git a/src/Desktop/Events/MenuBar/MenuBarDroppedFiles.php b/src/Events/MenuBar/MenuBarDroppedFiles.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarDroppedFiles.php rename to src/Events/MenuBar/MenuBarDroppedFiles.php diff --git a/src/Desktop/Events/MenuBar/MenuBarHidden.php b/src/Events/MenuBar/MenuBarHidden.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarHidden.php rename to src/Events/MenuBar/MenuBarHidden.php diff --git a/src/Desktop/Events/MenuBar/MenuBarRightClicked.php b/src/Events/MenuBar/MenuBarRightClicked.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarRightClicked.php rename to src/Events/MenuBar/MenuBarRightClicked.php diff --git a/src/Desktop/Events/MenuBar/MenuBarShown.php b/src/Events/MenuBar/MenuBarShown.php similarity index 100% rename from src/Desktop/Events/MenuBar/MenuBarShown.php rename to src/Events/MenuBar/MenuBarShown.php diff --git a/src/Desktop/Events/Notifications/NotificationActionClicked.php b/src/Events/Notifications/NotificationActionClicked.php similarity index 100% rename from src/Desktop/Events/Notifications/NotificationActionClicked.php rename to src/Events/Notifications/NotificationActionClicked.php diff --git a/src/Desktop/Events/Notifications/NotificationClicked.php b/src/Events/Notifications/NotificationClicked.php similarity index 100% rename from src/Desktop/Events/Notifications/NotificationClicked.php rename to src/Events/Notifications/NotificationClicked.php diff --git a/src/Desktop/Events/Notifications/NotificationClosed.php b/src/Events/Notifications/NotificationClosed.php similarity index 100% rename from src/Desktop/Events/Notifications/NotificationClosed.php rename to src/Events/Notifications/NotificationClosed.php diff --git a/src/Desktop/Events/Notifications/NotificationReply.php b/src/Events/Notifications/NotificationReply.php similarity index 100% rename from src/Desktop/Events/Notifications/NotificationReply.php rename to src/Events/Notifications/NotificationReply.php diff --git a/src/Desktop/Events/PowerMonitor/PowerStateChanged.php b/src/Events/PowerMonitor/PowerStateChanged.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/PowerStateChanged.php rename to src/Events/PowerMonitor/PowerStateChanged.php diff --git a/src/Desktop/Events/PowerMonitor/ScreenLocked.php b/src/Events/PowerMonitor/ScreenLocked.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/ScreenLocked.php rename to src/Events/PowerMonitor/ScreenLocked.php diff --git a/src/Desktop/Events/PowerMonitor/ScreenUnlocked.php b/src/Events/PowerMonitor/ScreenUnlocked.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/ScreenUnlocked.php rename to src/Events/PowerMonitor/ScreenUnlocked.php diff --git a/src/Desktop/Events/PowerMonitor/Shutdown.php b/src/Events/PowerMonitor/Shutdown.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/Shutdown.php rename to src/Events/PowerMonitor/Shutdown.php diff --git a/src/Desktop/Events/PowerMonitor/SpeedLimitChanged.php b/src/Events/PowerMonitor/SpeedLimitChanged.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/SpeedLimitChanged.php rename to src/Events/PowerMonitor/SpeedLimitChanged.php diff --git a/src/Desktop/Events/PowerMonitor/ThermalStateChanged.php b/src/Events/PowerMonitor/ThermalStateChanged.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/ThermalStateChanged.php rename to src/Events/PowerMonitor/ThermalStateChanged.php diff --git a/src/Desktop/Events/PowerMonitor/UserDidBecomeActive.php b/src/Events/PowerMonitor/UserDidBecomeActive.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/UserDidBecomeActive.php rename to src/Events/PowerMonitor/UserDidBecomeActive.php diff --git a/src/Desktop/Events/PowerMonitor/UserDidResignActive.php b/src/Events/PowerMonitor/UserDidResignActive.php similarity index 100% rename from src/Desktop/Events/PowerMonitor/UserDidResignActive.php rename to src/Events/PowerMonitor/UserDidResignActive.php diff --git a/src/Desktop/Events/Settings/SettingChanged.php b/src/Events/Settings/SettingChanged.php similarity index 100% rename from src/Desktop/Events/Settings/SettingChanged.php rename to src/Events/Settings/SettingChanged.php diff --git a/src/Desktop/Events/Windows/WindowBlurred.php b/src/Events/Windows/WindowBlurred.php similarity index 100% rename from src/Desktop/Events/Windows/WindowBlurred.php rename to src/Events/Windows/WindowBlurred.php diff --git a/src/Desktop/Events/Windows/WindowClosed.php b/src/Events/Windows/WindowClosed.php similarity index 100% rename from src/Desktop/Events/Windows/WindowClosed.php rename to src/Events/Windows/WindowClosed.php diff --git a/src/Desktop/Events/Windows/WindowFocused.php b/src/Events/Windows/WindowFocused.php similarity index 100% rename from src/Desktop/Events/Windows/WindowFocused.php rename to src/Events/Windows/WindowFocused.php diff --git a/src/Desktop/Events/Windows/WindowHidden.php b/src/Events/Windows/WindowHidden.php similarity index 100% rename from src/Desktop/Events/Windows/WindowHidden.php rename to src/Events/Windows/WindowHidden.php diff --git a/src/Desktop/Events/Windows/WindowMaximized.php b/src/Events/Windows/WindowMaximized.php similarity index 100% rename from src/Desktop/Events/Windows/WindowMaximized.php rename to src/Events/Windows/WindowMaximized.php diff --git a/src/Desktop/Events/Windows/WindowMinimized.php b/src/Events/Windows/WindowMinimized.php similarity index 100% rename from src/Desktop/Events/Windows/WindowMinimized.php rename to src/Events/Windows/WindowMinimized.php diff --git a/src/Desktop/Events/Windows/WindowResized.php b/src/Events/Windows/WindowResized.php similarity index 100% rename from src/Desktop/Events/Windows/WindowResized.php rename to src/Events/Windows/WindowResized.php diff --git a/src/Desktop/Events/Windows/WindowShown.php b/src/Events/Windows/WindowShown.php similarity index 100% rename from src/Desktop/Events/Windows/WindowShown.php rename to src/Events/Windows/WindowShown.php diff --git a/src/Desktop/Exceptions/Handler.php b/src/Exceptions/Handler.php similarity index 100% rename from src/Desktop/Exceptions/Handler.php rename to src/Exceptions/Handler.php diff --git a/src/Desktop/Facades/Alert.php b/src/Facades/Alert.php similarity index 100% rename from src/Desktop/Facades/Alert.php rename to src/Facades/Alert.php diff --git a/src/Desktop/Facades/App.php b/src/Facades/App.php similarity index 100% rename from src/Desktop/Facades/App.php rename to src/Facades/App.php diff --git a/src/Desktop/Facades/AutoUpdater.php b/src/Facades/AutoUpdater.php similarity index 100% rename from src/Desktop/Facades/AutoUpdater.php rename to src/Facades/AutoUpdater.php diff --git a/src/Desktop/Facades/ChildProcess.php b/src/Facades/ChildProcess.php similarity index 100% rename from src/Desktop/Facades/ChildProcess.php rename to src/Facades/ChildProcess.php diff --git a/src/Desktop/Facades/Clipboard.php b/src/Facades/Clipboard.php similarity index 100% rename from src/Desktop/Facades/Clipboard.php rename to src/Facades/Clipboard.php diff --git a/src/Desktop/Facades/ContextMenu.php b/src/Facades/ContextMenu.php similarity index 100% rename from src/Desktop/Facades/ContextMenu.php rename to src/Facades/ContextMenu.php diff --git a/src/Desktop/Facades/Dock.php b/src/Facades/Dock.php similarity index 100% rename from src/Desktop/Facades/Dock.php rename to src/Facades/Dock.php diff --git a/src/Desktop/Facades/GlobalShortcut.php b/src/Facades/GlobalShortcut.php similarity index 100% rename from src/Desktop/Facades/GlobalShortcut.php rename to src/Facades/GlobalShortcut.php diff --git a/src/Desktop/Facades/Menu.php b/src/Facades/Menu.php similarity index 100% rename from src/Desktop/Facades/Menu.php rename to src/Facades/Menu.php diff --git a/src/Desktop/Facades/MenuBar.php b/src/Facades/MenuBar.php similarity index 100% rename from src/Desktop/Facades/MenuBar.php rename to src/Facades/MenuBar.php diff --git a/src/Desktop/Facades/Notification.php b/src/Facades/Notification.php similarity index 100% rename from src/Desktop/Facades/Notification.php rename to src/Facades/Notification.php diff --git a/src/Desktop/Facades/PowerMonitor.php b/src/Facades/PowerMonitor.php similarity index 100% rename from src/Desktop/Facades/PowerMonitor.php rename to src/Facades/PowerMonitor.php diff --git a/src/Desktop/Facades/Process.php b/src/Facades/Process.php similarity index 100% rename from src/Desktop/Facades/Process.php rename to src/Facades/Process.php diff --git a/src/Desktop/Facades/QueueWorker.php b/src/Facades/QueueWorker.php similarity index 94% rename from src/Desktop/Facades/QueueWorker.php rename to src/Facades/QueueWorker.php index 7fb3aeb2..452b2ae1 100644 --- a/src/Desktop/Facades/QueueWorker.php +++ b/src/Facades/QueueWorker.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Facade; use Native\Desktop\Contracts\QueueWorker as QueueWorkerContract; -use Native\Desktop\DTOs\QueueConfig; +use Native\Desktop\DataObjects\QueueConfig; use Native\Desktop\Fakes\QueueWorkerFake; /** diff --git a/src/Desktop/Facades/Screen.php b/src/Facades/Screen.php similarity index 100% rename from src/Desktop/Facades/Screen.php rename to src/Facades/Screen.php diff --git a/src/Desktop/Facades/Settings.php b/src/Facades/Settings.php similarity index 100% rename from src/Desktop/Facades/Settings.php rename to src/Facades/Settings.php diff --git a/src/Desktop/Facades/Shell.php b/src/Facades/Shell.php similarity index 100% rename from src/Desktop/Facades/Shell.php rename to src/Facades/Shell.php diff --git a/src/Desktop/Facades/System.php b/src/Facades/System.php similarity index 100% rename from src/Desktop/Facades/System.php rename to src/Facades/System.php diff --git a/src/Desktop/Facades/Window.php b/src/Facades/Window.php similarity index 100% rename from src/Desktop/Facades/Window.php rename to src/Facades/Window.php diff --git a/src/Desktop/Fakes/ChildProcessFake.php b/src/Fakes/ChildProcessFake.php similarity index 100% rename from src/Desktop/Fakes/ChildProcessFake.php rename to src/Fakes/ChildProcessFake.php diff --git a/src/Desktop/Fakes/GlobalShortcutFake.php b/src/Fakes/GlobalShortcutFake.php similarity index 100% rename from src/Desktop/Fakes/GlobalShortcutFake.php rename to src/Fakes/GlobalShortcutFake.php diff --git a/src/Desktop/Fakes/PowerMonitorFake.php b/src/Fakes/PowerMonitorFake.php similarity index 100% rename from src/Desktop/Fakes/PowerMonitorFake.php rename to src/Fakes/PowerMonitorFake.php diff --git a/src/Desktop/Fakes/QueueWorkerFake.php b/src/Fakes/QueueWorkerFake.php similarity index 96% rename from src/Desktop/Fakes/QueueWorkerFake.php rename to src/Fakes/QueueWorkerFake.php index b6546fa8..f56f3961 100644 --- a/src/Desktop/Fakes/QueueWorkerFake.php +++ b/src/Fakes/QueueWorkerFake.php @@ -4,7 +4,7 @@ use Closure; use Native\Desktop\Contracts\QueueWorker as QueueWorkerContract; -use Native\Desktop\DTOs\QueueConfig; +use Native\Desktop\DataObjects\QueueConfig; use PHPUnit\Framework\Assert as PHPUnit; class QueueWorkerFake implements QueueWorkerContract diff --git a/src/Desktop/Fakes/WindowManagerFake.php b/src/Fakes/WindowManagerFake.php similarity index 100% rename from src/Desktop/Fakes/WindowManagerFake.php rename to src/Fakes/WindowManagerFake.php diff --git a/src/Desktop/GlobalShortcut.php b/src/GlobalShortcut.php similarity index 100% rename from src/Desktop/GlobalShortcut.php rename to src/GlobalShortcut.php diff --git a/src/Desktop/Http/Controllers/CreateSecurityCookieController.php b/src/Http/Controllers/CreateSecurityCookieController.php similarity index 100% rename from src/Desktop/Http/Controllers/CreateSecurityCookieController.php rename to src/Http/Controllers/CreateSecurityCookieController.php diff --git a/src/Desktop/Http/Controllers/DispatchEventFromAppController.php b/src/Http/Controllers/DispatchEventFromAppController.php similarity index 100% rename from src/Desktop/Http/Controllers/DispatchEventFromAppController.php rename to src/Http/Controllers/DispatchEventFromAppController.php diff --git a/src/Desktop/Http/Controllers/NativeAppBootedController.php b/src/Http/Controllers/NativeAppBootedController.php similarity index 100% rename from src/Desktop/Http/Controllers/NativeAppBootedController.php rename to src/Http/Controllers/NativeAppBootedController.php diff --git a/src/Desktop/Http/Middleware/PreventRegularBrowserAccess.php b/src/Http/Middleware/PreventRegularBrowserAccess.php similarity index 100% rename from src/Desktop/Http/Middleware/PreventRegularBrowserAccess.php rename to src/Http/Middleware/PreventRegularBrowserAccess.php diff --git a/src/Desktop/Logging/LogWatcher.php b/src/Logging/LogWatcher.php similarity index 100% rename from src/Desktop/Logging/LogWatcher.php rename to src/Logging/LogWatcher.php diff --git a/src/Desktop/Menu/Items/Checkbox.php b/src/Menu/Items/Checkbox.php similarity index 100% rename from src/Desktop/Menu/Items/Checkbox.php rename to src/Menu/Items/Checkbox.php diff --git a/src/Desktop/Menu/Items/Label.php b/src/Menu/Items/Label.php similarity index 100% rename from src/Desktop/Menu/Items/Label.php rename to src/Menu/Items/Label.php diff --git a/src/Desktop/Menu/Items/Link.php b/src/Menu/Items/Link.php similarity index 100% rename from src/Desktop/Menu/Items/Link.php rename to src/Menu/Items/Link.php diff --git a/src/Desktop/Menu/Items/MenuItem.php b/src/Menu/Items/MenuItem.php similarity index 100% rename from src/Desktop/Menu/Items/MenuItem.php rename to src/Menu/Items/MenuItem.php diff --git a/src/Desktop/Menu/Items/Radio.php b/src/Menu/Items/Radio.php similarity index 100% rename from src/Desktop/Menu/Items/Radio.php rename to src/Menu/Items/Radio.php diff --git a/src/Desktop/Menu/Items/Role.php b/src/Menu/Items/Role.php similarity index 100% rename from src/Desktop/Menu/Items/Role.php rename to src/Menu/Items/Role.php diff --git a/src/Desktop/Menu/Items/Separator.php b/src/Menu/Items/Separator.php similarity index 100% rename from src/Desktop/Menu/Items/Separator.php rename to src/Menu/Items/Separator.php diff --git a/src/Desktop/Menu/Menu.php b/src/Menu/Menu.php similarity index 100% rename from src/Desktop/Menu/Menu.php rename to src/Menu/Menu.php diff --git a/src/Desktop/Menu/MenuBuilder.php b/src/Menu/MenuBuilder.php similarity index 100% rename from src/Desktop/Menu/MenuBuilder.php rename to src/Menu/MenuBuilder.php diff --git a/src/Desktop/MenuBar/MenuBar.php b/src/MenuBar/MenuBar.php similarity index 100% rename from src/Desktop/MenuBar/MenuBar.php rename to src/MenuBar/MenuBar.php diff --git a/src/Desktop/MenuBar/MenuBarManager.php b/src/MenuBar/MenuBarManager.php similarity index 100% rename from src/Desktop/MenuBar/MenuBarManager.php rename to src/MenuBar/MenuBarManager.php diff --git a/src/Desktop/MenuBar/PendingCreateMenuBar.php b/src/MenuBar/PendingCreateMenuBar.php similarity index 100% rename from src/Desktop/MenuBar/PendingCreateMenuBar.php rename to src/MenuBar/PendingCreateMenuBar.php diff --git a/src/Desktop/NativeServiceProvider.php b/src/NativeServiceProvider.php similarity index 98% rename from src/Desktop/NativeServiceProvider.php rename to src/NativeServiceProvider.php index eb01b180..09a2ca4f 100644 --- a/src/Desktop/NativeServiceProvider.php +++ b/src/NativeServiceProvider.php @@ -21,7 +21,8 @@ use Native\Desktop\Contracts\PowerMonitor as PowerMonitorContract; use Native\Desktop\Contracts\QueueWorker as QueueWorkerContract; use Native\Desktop\Contracts\WindowManager as WindowManagerContract; -use Native\Desktop\DTOs\QueueConfig; +use Native\Desktop\DataObjects\QueueConfig; +use Native\Desktop\Drivers\Electron\ElectronServiceProvider; use Native\Desktop\Events\EventWatcher; use Native\Desktop\Exceptions\Handler; use Native\Desktop\GlobalShortcut as GlobalShortcutImplementation; @@ -53,6 +54,8 @@ public function configurePackage(Package $package): void public function packageRegistered() { + $this->app->register(ElectronServiceProvider::class); + $this->mergeConfigFrom($this->package->basePath('../config/nativephp-internal.php'), 'nativephp-internal'); $this->app->singleton(FreshCommand::class, function ($app) { @@ -244,9 +247,4 @@ protected function fireUpQueueWorkers(): void $this->app->make(QueueWorkerContract::class)->up($queueConfig); } } - - protected function getPackageBaseDir(): string - { - return dirname(parent::getPackageBaseDir()); - } } diff --git a/src/Desktop/Notification.php b/src/Notification.php similarity index 100% rename from src/Desktop/Notification.php rename to src/Notification.php diff --git a/src/Desktop/PowerMonitor.php b/src/PowerMonitor.php similarity index 100% rename from src/Desktop/PowerMonitor.php rename to src/PowerMonitor.php diff --git a/src/Desktop/Process.php b/src/Process.php similarity index 100% rename from src/Desktop/Process.php rename to src/Process.php diff --git a/src/Desktop/ProgressBar.php b/src/ProgressBar.php similarity index 100% rename from src/Desktop/ProgressBar.php rename to src/ProgressBar.php diff --git a/src/Desktop/QueueWorker.php b/src/QueueWorker.php similarity index 97% rename from src/Desktop/QueueWorker.php rename to src/QueueWorker.php index b000f511..1aac51bc 100644 --- a/src/Desktop/QueueWorker.php +++ b/src/QueueWorker.php @@ -4,7 +4,7 @@ use Native\Desktop\Contracts\ChildProcess as ChildProcessContract; use Native\Desktop\Contracts\QueueWorker as QueueWorkerContract; -use Native\Desktop\DTOs\QueueConfig; +use Native\Desktop\DataObjects\QueueConfig; class QueueWorker implements QueueWorkerContract { diff --git a/src/Desktop/Screen.php b/src/Screen.php similarity index 100% rename from src/Desktop/Screen.php rename to src/Screen.php diff --git a/src/Desktop/Settings.php b/src/Settings.php similarity index 100% rename from src/Desktop/Settings.php rename to src/Settings.php diff --git a/src/Desktop/Shell.php b/src/Shell.php similarity index 100% rename from src/Desktop/Shell.php rename to src/Shell.php diff --git a/src/Support/Composer.php b/src/Support/Composer.php new file mode 100644 index 00000000..6b3f31b3 --- /dev/null +++ b/src/Support/Composer.php @@ -0,0 +1,91 @@ +scripts ?? (object) []; + + info('Installing `composer native:dev` script alias...'); + + if ($composerScripts->{'native:dev'} ?? false) { + note('native:dev script already installed... skipping.'); + + return; + } + + $composerScripts->{'native:dev'} = [ + 'Composer\\Config::disableProcessTimeout', + 'npx concurrently -k -c "#93c5fd,#c4b5fd" "php artisan native:serve --no-interaction" "npm run dev" --names=app,vite', + ]; + + data_set($composer, 'scripts', $composerScripts); + + file_put_contents( + base_path('composer.json'), + json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL + ); + + note('native:dev script installed!'); + } + + private static function installUpdateScript(object $composer) + { + $postUpdateScripts = data_get($composer, 'scripts.post-update-cmd', []); + + info('Installing `native:install` post-update-cmd script'); + + foreach ($postUpdateScripts as $script) { + if (str_contains($script, 'native:install')) { + note('native:install script already present in post-update-cmd... skipping.'); + + return; + } + } + + $postUpdateScripts[] = '@php artisan native:install --force --quiet'; + + data_set($composer, 'scripts.post-update-cmd', $postUpdateScripts); + + file_put_contents( + base_path('composer.json'), + json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL + ); + + note('post-update-cmd script installed!'); + } +} diff --git a/src/Desktop/Support/Environment.php b/src/Support/Environment.php similarity index 100% rename from src/Desktop/Support/Environment.php rename to src/Support/Environment.php diff --git a/src/Desktop/Support/Timezones.php b/src/Support/Timezones.php similarity index 100% rename from src/Desktop/Support/Timezones.php rename to src/Support/Timezones.php diff --git a/src/Desktop/System.php b/src/System.php similarity index 100% rename from src/Desktop/System.php rename to src/System.php diff --git a/src/Desktop/Windows/PendingOpenWindow.php b/src/Windows/PendingOpenWindow.php similarity index 100% rename from src/Desktop/Windows/PendingOpenWindow.php rename to src/Windows/PendingOpenWindow.php diff --git a/src/Desktop/Windows/Window.php b/src/Windows/Window.php similarity index 100% rename from src/Desktop/Windows/Window.php rename to src/Windows/Window.php diff --git a/src/Desktop/Windows/WindowManager.php b/src/Windows/WindowManager.php similarity index 100% rename from src/Desktop/Windows/WindowManager.php rename to src/Windows/WindowManager.php diff --git a/tests/Build/CleanEnvFileTest.php b/tests/Build/CleanEnvFileTest.php index 77b36ddc..f5228ae4 100644 --- a/tests/Build/CleanEnvFileTest.php +++ b/tests/Build/CleanEnvFileTest.php @@ -1,7 +1,7 @@ joinPaths($this->buildPath, $path); } diff --git a/tests/Build/CopiesCertificateAuthorityTest.php b/tests/Build/CopiesCertificateAuthorityTest.php index 2a34c90e..db5909f0 100644 --- a/tests/Build/CopiesCertificateAuthorityTest.php +++ b/tests/Build/CopiesCertificateAuthorityTest.php @@ -1,30 +1,19 @@ remove($certificatePath); expect($certificatePath)->not->toBeFile(); - $mock->run(); + resolve(Builder::class)->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources'); expect($certificatePath)->toBeFile(); -})->with([ - // Empty class with the CopiesCertificateAuthority trait - new class - { - use CopiesCertificateAuthority; - - public function run() - { - $this->copyCertificateAuthorityCertificate(); - } - }, -]); +}); diff --git a/tests/Build/CopyToBuildDirectoryTest.php b/tests/Build/CopyToBuildDirectoryTest.php index c33e0213..655f2b72 100644 --- a/tests/Build/CopyToBuildDirectoryTest.php +++ b/tests/Build/CopyToBuildDirectoryTest.php @@ -1,6 +1,6 @@ joinPaths($this->sourcePath, $path); } - protected function buildPath(string $path = ''): string + public function buildPath(string $path = ''): string { return app()->joinPaths($this->buildPath, $path); } diff --git a/tests/Build/HasPreAndPostProcessingTest.php b/tests/Build/HasPreAndPostProcessingTest.php index e8ab32c1..49b7f4e2 100644 --- a/tests/Build/HasPreAndPostProcessingTest.php +++ b/tests/Build/HasPreAndPostProcessingTest.php @@ -1,7 +1,7 @@