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
8 changes: 4 additions & 4 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Native\Electron\Traits\InstallsAppIcon;
use Native\Electron\Traits\LocatesPhpBinary;
use Native\Electron\Traits\OsAndArch;
use Native\Electron\Traits\PatchesPackagesJson;
use Native\Electron\Traits\PrunesVendorDirectory;
use Native\Electron\Traits\SetsAppName;
use Symfony\Component\Process\Process as SymfonyProcess;

use function Laravel\Prompts\intro;
Expand All @@ -28,8 +28,8 @@ class BuildCommand extends Command
use InstallsAppIcon;
use LocatesPhpBinary;
use OsAndArch;
use PatchesPackagesJson;
use PrunesVendorDirectory;
use SetsAppName;

protected $signature = 'native:build
{os? : The operating system to build for (all, linux, mac, win)}
Expand Down Expand Up @@ -78,7 +78,7 @@ public function handle(): void

private function buildBundle(): void
{
$this->setAppName();
$this->setAppNameAndVersion();

$this->updateElectronDependencies();

Expand All @@ -101,7 +101,7 @@ private function buildUnsecure(): void
{
$this->preProcess();

$this->setAppName();
$this->setAppNameAndVersion();

$this->updateElectronDependencies();

Expand Down
6 changes: 3 additions & 3 deletions src/Commands/BundleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Native\Electron\Traits\HasPreAndPostProcessing;
use Native\Electron\Traits\InstallsAppIcon;
use Native\Electron\Traits\LocatesPhpBinary;
use Native\Electron\Traits\PatchesPackagesJson;
use Native\Electron\Traits\PrunesVendorDirectory;
use Native\Electron\Traits\SetsAppName;
use Symfony\Component\Finder\Finder;
use ZipArchive;

Expand All @@ -30,8 +30,8 @@ class BundleCommand extends Command
use HasPreAndPostProcessing;
use InstallsAppIcon;
use LocatesPhpBinary;
use PatchesPackagesJson;
use PrunesVendorDirectory;
use SetsAppName;

protected $signature = 'native:bundle {--fetch} {--clear} {--without-cleanup}';

Expand Down Expand Up @@ -87,7 +87,7 @@ public function handle(): int

$this->preProcess();

$this->setAppName();
$this->setAppNameAndVersion();
intro('Copying App to build directory...');

// We update composer.json later,
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/DevelopCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Native\Electron\Traits\Developer;
use Native\Electron\Traits\Installer;
use Native\Electron\Traits\InstallsAppIcon;
use Native\Electron\Traits\SetsAppName;
use Native\Electron\Traits\PatchesPackagesJson;

use function Laravel\Prompts\intro;
use function Laravel\Prompts\note;
Expand All @@ -18,7 +18,7 @@ class DevelopCommand extends Command
use Developer;
use Installer;
use InstallsAppIcon;
use SetsAppName;
use PatchesPackagesJson;

protected $signature = 'native:serve {--no-queue} {--D|no-dependencies} {--installer=npm}';

Expand All @@ -42,7 +42,7 @@ public function handle(): void
$this->patchPlist();
}

$this->setAppName(developmentMode: true);
$this->setAppNameAndVersion(developmentMode: true);

$this->installIcon();

Expand Down
6 changes: 3 additions & 3 deletions src/Commands/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Native\Electron\Commands;

use Illuminate\Console\Command;
use Native\Electron\Traits\SetsAppName;
use Native\Electron\Traits\PatchesPackagesJson;
use Symfony\Component\Filesystem\Filesystem;

use function Laravel\Prompts\intro;

class ResetCommand extends Command
{
use SetsAppName;
use PatchesPackagesJson;

protected $signature = 'native:reset {--with-app-data : Clear the app data as well}';

Expand Down Expand Up @@ -49,7 +49,7 @@ public function handle(): int
if ($this->option('with-app-data')) {

foreach ([true, false] as $developmentMode) {
$appName = $this->setAppName($developmentMode);
$appName = $this->setAppNameAndVersion($developmentMode);

// Eh, just in case, I don't want to delete all user data by accident.
if (! empty($appName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Native\Electron\Traits;

trait SetsAppName
trait PatchesPackagesJson
{
protected function setAppName($developmentMode = false): string
protected function setAppNameAndVersion($developmentMode = false): string
{
$packageJsonPath = __DIR__.'/../../resources/js/package.json';
$packageJson = json_decode(file_get_contents($packageJsonPath), true);
Expand All @@ -21,6 +21,7 @@ protected function setAppName($developmentMode = false): string
}

$packageJson['name'] = $name;
$packageJson['version'] = config('nativephp.version');

file_put_contents($packageJsonPath, json_encode($packageJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

Expand Down