Skip to content

Commit e0624eb

Browse files
authored
fix: App::version() not returning the correct version (#208)
* fix: App::version() not returning the correct version * Fix styling
1 parent 6a10202 commit e0624eb

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

src/Commands/BuildCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use Native\Electron\Traits\InstallsAppIcon;
1414
use Native\Electron\Traits\LocatesPhpBinary;
1515
use Native\Electron\Traits\OsAndArch;
16+
use Native\Electron\Traits\PatchesPackagesJson;
1617
use Native\Electron\Traits\PrunesVendorDirectory;
17-
use Native\Electron\Traits\SetsAppName;
1818
use Symfony\Component\Process\Process as SymfonyProcess;
1919

2020
use function Laravel\Prompts\intro;
@@ -28,8 +28,8 @@ class BuildCommand extends Command
2828
use InstallsAppIcon;
2929
use LocatesPhpBinary;
3030
use OsAndArch;
31+
use PatchesPackagesJson;
3132
use PrunesVendorDirectory;
32-
use SetsAppName;
3333

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

7979
private function buildBundle(): void
8080
{
81-
$this->setAppName();
81+
$this->setAppNameAndVersion();
8282

8383
$this->updateElectronDependencies();
8484

@@ -101,7 +101,7 @@ private function buildUnsecure(): void
101101
{
102102
$this->preProcess();
103103

104-
$this->setAppName();
104+
$this->setAppNameAndVersion();
105105

106106
$this->updateElectronDependencies();
107107

src/Commands/BundleCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Native\Electron\Traits\HasPreAndPostProcessing;
1616
use Native\Electron\Traits\InstallsAppIcon;
1717
use Native\Electron\Traits\LocatesPhpBinary;
18+
use Native\Electron\Traits\PatchesPackagesJson;
1819
use Native\Electron\Traits\PrunesVendorDirectory;
19-
use Native\Electron\Traits\SetsAppName;
2020
use Symfony\Component\Finder\Finder;
2121
use ZipArchive;
2222

@@ -30,8 +30,8 @@ class BundleCommand extends Command
3030
use HasPreAndPostProcessing;
3131
use InstallsAppIcon;
3232
use LocatesPhpBinary;
33+
use PatchesPackagesJson;
3334
use PrunesVendorDirectory;
34-
use SetsAppName;
3535

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

@@ -87,7 +87,7 @@ public function handle(): int
8787

8888
$this->preProcess();
8989

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

9393
// We update composer.json later,

src/Commands/DevelopCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Native\Electron\Traits\Developer;
88
use Native\Electron\Traits\Installer;
99
use Native\Electron\Traits\InstallsAppIcon;
10-
use Native\Electron\Traits\SetsAppName;
10+
use Native\Electron\Traits\PatchesPackagesJson;
1111

1212
use function Laravel\Prompts\intro;
1313
use function Laravel\Prompts\note;
@@ -18,7 +18,7 @@ class DevelopCommand extends Command
1818
use Developer;
1919
use Installer;
2020
use InstallsAppIcon;
21-
use SetsAppName;
21+
use PatchesPackagesJson;
2222

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

@@ -42,7 +42,7 @@ public function handle(): void
4242
$this->patchPlist();
4343
}
4444

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

4747
$this->installIcon();
4848

src/Commands/ResetCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace Native\Electron\Commands;
44

55
use Illuminate\Console\Command;
6-
use Native\Electron\Traits\SetsAppName;
6+
use Native\Electron\Traits\PatchesPackagesJson;
77
use Symfony\Component\Filesystem\Filesystem;
88

99
use function Laravel\Prompts\intro;
1010

1111
class ResetCommand extends Command
1212
{
13-
use SetsAppName;
13+
use PatchesPackagesJson;
1414

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

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

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

5454
// Eh, just in case, I don't want to delete all user data by accident.
5555
if (! empty($appName)) {

src/Traits/SetsAppName.php renamed to src/Traits/PatchesPackagesJson.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Native\Electron\Traits;
44

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

2323
$packageJson['name'] = $name;
24+
$packageJson['version'] = config('nativephp.version');
2425

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

0 commit comments

Comments
 (0)