Skip to content

Commit 4dd131b

Browse files
committed
fix paths
1 parent 74ce05c commit 4dd131b

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

src/Electron/Commands/BuildCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Support\Facades\Process;
77
use Illuminate\Support\Str;
8+
use Native\Electron\ElectronServiceProvider;
89
use Native\Electron\Facades\Updater;
910
use Native\Electron\Traits\CleansEnvFile;
1011
use Native\Electron\Traits\CopiesBundleToBuildDirectory;
@@ -49,7 +50,7 @@ class BuildCommand extends Command
4950

5051
protected function buildPath(string $path = ''): string
5152
{
52-
return __DIR__.'/../../resources/js/resources/app/'.$path;
53+
return ElectronServiceProvider::ELECTRON_PATH.'/resources/app/'.$path;
5354
}
5455

5556
protected function sourcePath(string $path = ''): string
@@ -171,7 +172,7 @@ private function updateElectronDependencies(): void
171172
{
172173
$this->newLine();
173174
intro('Updating Electron dependencies...');
174-
Process::path(__DIR__.'/../../resources/js/')
175+
Process::path(ElectronServiceProvider::ELECTRON_PATH)
175176
->env($this->getEnvironmentVariables())
176177
->forever()
177178
->run('npm ci', function (string $type, string $output) {
@@ -183,7 +184,7 @@ private function buildOrPublish(): void
183184
{
184185
$this->newLine();
185186
intro((($this->buildCommand == 'publish') ? 'Publishing' : 'Building')." for {$this->buildOS}");
186-
Process::path(__DIR__.'/../../resources/js/')
187+
Process::path(ElectronServiceProvider::ELECTRON_PATH)
187188
->env($this->getEnvironmentVariables())
188189
->forever()
189190
->tty(SymfonyProcess::isTtySupported() && ! $this->option('no-interaction'))

src/Electron/Commands/DevelopCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Native\Electron\Commands;
44

55
use Illuminate\Console\Command;
6+
use Native\Electron\ElectronServiceProvider;
67
use Native\Electron\Traits\CopiesCertificateAuthority;
78
use Native\Electron\Traits\Developer;
89
use Native\Electron\Traits\Installer;
@@ -66,7 +67,7 @@ public function handle(): void
6667
*/
6768
protected function patchPlist(): void
6869
{
69-
$pList = file_get_contents(__DIR__.'/../../resources/js/node_modules/electron/dist/Electron.app/Contents/Info.plist');
70+
$pList = file_get_contents(ElectronServiceProvider::ELECTRON_PATH.'/node_modules/electron/dist/Electron.app/Contents/Info.plist');
7071

7172
// Change the CFBundleName to the correct app name
7273
$pattern = '/(<key>CFBundleName<\/key>\s+<string>)(.*?)(<\/string>)/m';
@@ -75,6 +76,6 @@ protected function patchPlist(): void
7576
$pattern = '/(<key>CFBundleDisplayName<\/key>\s+<string>)(.*?)(<\/string>)/m';
7677
$pList = preg_replace($pattern, '$1'.config('app.name').'$3', $pList);
7778

78-
file_put_contents(__DIR__.'/../../resources/js/node_modules/electron/dist/Electron.app/Contents/Info.plist', $pList);
79+
file_put_contents(ElectronServiceProvider::ELECTRON_PATH.'/node_modules/electron/dist/Electron.app/Contents/Info.plist', $pList);
7980
}
8081
}

src/Electron/Commands/ResetCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Native\Electron\Commands;
44

55
use Illuminate\Console\Command;
6+
use Native\Electron\ElectronServiceProvider;
67
use Native\Electron\Traits\PatchesPackagesJson;
78
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Filesystem\Filesystem;
@@ -26,7 +27,7 @@ public function handle(): int
2627
$filesystem = new Filesystem;
2728

2829
// Removing and recreating the native serve resource path
29-
$nativeServeResourcePath = realpath(__DIR__.'/../../resources/js/resources/app/');
30+
$nativeServeResourcePath = realpath(ElectronServiceProvider::ELECTRON_PATH.'/resources/app/');
3031
if ($filesystem->exists($nativeServeResourcePath)) {
3132
$this->line('Clearing: '.$nativeServeResourcePath);
3233
$filesystem->remove($nativeServeResourcePath);

src/Electron/ElectronServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
class ElectronServiceProvider extends PackageServiceProvider
1717
{
18+
const ELECTRON_PATH = __DIR__.'/../../resources/js';
19+
1820
public function configurePackage(Package $package): void
1921
{
2022
$package

src/Electron/Traits/CopiesCertificateAuthority.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Native\Electron\Traits;
44

5+
use Native\Electron\ElectronServiceProvider;
56
use Symfony\Component\Filesystem\Path;
67

78
use function Laravel\Prompts\error;
@@ -28,7 +29,7 @@ protected function copyCertificateAuthorityCertificate(): void
2829

2930
$copied = copy(
3031
$certFilePath,
31-
Path::join(base_path('vendor/nativephp/electron/resources/js/resources'), $certificateFileName)
32+
Path::join(ElectronServiceProvider::ELECTRON_PATH, 'resources', $certificateFileName)
3233
);
3334

3435
if (! $copied) {

src/Electron/Traits/InstallsAppIcon.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
namespace Native\Electron\Traits;
44

5+
use Native\Electron\ElectronServiceProvider;
6+
57
trait InstallsAppIcon
68
{
79
public function installIcon()
810
{
9-
@copy(public_path('icon.png'), __DIR__.'/../../resources/js/build/icon.png');
10-
@copy(public_path('icon.png'), __DIR__.'/../../resources/js/resources/icon.png');
11-
@copy(public_path('icon.ico'), __DIR__.'/../../resources/js/build/icon.ico');
12-
@copy(public_path('icon.ico'), __DIR__.'/../../resources/js/resources/icon.ico');
13-
@copy(public_path('icon.icns'), __DIR__.'/../../resources/js/build/icon.icns');
14-
@copy(public_path('icon.icns'), __DIR__.'/../../resources/js/resources/icon.icns');
15-
@copy(public_path('IconTemplate.png'), __DIR__.'/../../resources/js/resources/IconTemplate.png');
16-
@copy(public_path('IconTemplate@2x.png'), __DIR__.'/../../resources/js/resources/IconTemplate@2x.png');
11+
@copy(public_path('icon.png'), ElectronServiceProvider::ELECTRON_PATH.'/build/icon.png');
12+
@copy(public_path('icon.png'), ElectronServiceProvider::ELECTRON_PATH.'/resources/icon.png');
13+
@copy(public_path('icon.ico'), ElectronServiceProvider::ELECTRON_PATH.'/build/icon.ico');
14+
@copy(public_path('icon.ico'), ElectronServiceProvider::ELECTRON_PATH.'/resources/icon.ico');
15+
@copy(public_path('icon.icns'), ElectronServiceProvider::ELECTRON_PATH.'/build/icon.icns');
16+
@copy(public_path('icon.icns'), ElectronServiceProvider::ELECTRON_PATH.'/resources/icon.icns');
17+
@copy(public_path('IconTemplate.png'), ElectronServiceProvider::ELECTRON_PATH.'/resources/IconTemplate.png');
18+
@copy(public_path('IconTemplate@2x.png'), ElectronServiceProvider::ELECTRON_PATH.'/resources/IconTemplate@2x.png');
1719
}
1820
}

src/Electron/Traits/PatchesPackagesJson.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace Native\Electron\Traits;
44

5+
use Native\Electron\ElectronServiceProvider;
6+
57
trait PatchesPackagesJson
68
{
79
protected function setAppNameAndVersion($developmentMode = false): string
810
{
9-
$packageJsonPath = __DIR__.'/../../resources/js/package.json';
11+
$packageJsonPath = ElectronServiceProvider::ELECTRON_PATH.'/package.json';
1012
$packageJson = json_decode(file_get_contents($packageJsonPath), true);
1113

1214
$name = str(config('app.name'))->slug();

0 commit comments

Comments
 (0)