Skip to content

Commit 06e93e2

Browse files
committed
wip - split the asar contents dir from the electron project
1 parent ae1e412 commit 06e93e2

File tree

12 files changed

+25
-23
lines changed

12 files changed

+25
-23
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
.idea
22
.phpunit.cache
3-
build
43
composer.lock
54
coverage
65
docs
76
phpunit.xml
87
testbench.yaml
98
vendor
109
node_modules
10+
/build
1111
.DS_Store
12-
!tests/Build
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/Drivers/Electron/Commands/BuildCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function buildBundle(): void
8080

8181
$this->newLine();
8282
intro('Copying latest CA Certificate...');
83-
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources');
83+
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::electronPath().'/resources');
8484

8585
$this->newLine();
8686
intro('Copying app icons...');
@@ -105,7 +105,7 @@ private function buildUnsecure(): void
105105

106106
$this->newLine();
107107
intro('Copying latest CA Certificate...');
108-
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources');
108+
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::buildPath());
109109

110110
$this->newLine();
111111
intro('Cleaning .env file...');
@@ -162,7 +162,7 @@ private function updateElectronDependencies(): void
162162
{
163163
$this->newLine();
164164
intro('Updating Electron dependencies...');
165-
Process::path(ElectronServiceProvider::ELECTRON_PATH)
165+
Process::path(ElectronServiceProvider::electronPath())
166166
->env($this->getEnvironmentVariables())
167167
->forever()
168168
->run('npm ci', function (string $type, string $output) {
@@ -174,7 +174,7 @@ private function buildOrPublish(): void
174174
{
175175
$this->newLine();
176176
intro((($this->buildCommand == 'publish') ? 'Publishing' : 'Building')." for {$this->buildOS}");
177-
Process::path(ElectronServiceProvider::ELECTRON_PATH)
177+
Process::path(ElectronServiceProvider::electronPath())
178178
->env($this->getEnvironmentVariables())
179179
->forever()
180180
->tty(SymfonyProcess::isTtySupported() && ! $this->option('no-interaction'))

src/Drivers/Electron/Commands/DevelopCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function handle(): void
5757

5858
$this->installIcon();
5959

60-
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources');
60+
$this->builder->copyCertificateAuthority(path: ElectronServiceProvider::buildPath());
6161

6262
$this->runDeveloper(
6363
installer: $this->option('installer'),
@@ -72,7 +72,7 @@ public function handle(): void
7272
*/
7373
protected function patchPlist(): void
7474
{
75-
$pList = file_get_contents(ElectronServiceProvider::ELECTRON_PATH.'/node_modules/electron/dist/Electron.app/Contents/Info.plist');
75+
$pList = file_get_contents(ElectronServiceProvider::electronPath('node_modules/electron/dist/Electron.app/Contents/Info.plist'));
7676

7777
// Change the CFBundleName to the correct app name
7878
$pattern = '/(<key>CFBundleName<\/key>\s+<string>)(.*?)(<\/string>)/m';
@@ -81,6 +81,6 @@ protected function patchPlist(): void
8181
$pattern = '/(<key>CFBundleDisplayName<\/key>\s+<string>)(.*?)(<\/string>)/m';
8282
$pList = preg_replace($pattern, '$1'.config('app.name').'$3', $pList);
8383

84-
file_put_contents(ElectronServiceProvider::ELECTRON_PATH.'/node_modules/electron/dist/Electron.app/Contents/Info.plist', $pList);
84+
file_put_contents(ElectronServiceProvider::electronPath('node_modules/electron/dist/Electron.app/Contents/Info.plist'), $pList);
8585
}
8686
}

src/Drivers/Electron/Commands/ResetCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function handle(): int
2727
$filesystem = new Filesystem;
2828

2929
// Removing and recreating the native serve resource path
30-
$nativeServeResourcePath = realpath(ElectronServiceProvider::ELECTRON_PATH.'/resources/app/');
30+
$nativeServeResourcePath = realpath(ElectronServiceProvider::buildPath('app'));
3131
if ($filesystem->exists($nativeServeResourcePath)) {
3232
$this->line('Clearing: '.$nativeServeResourcePath);
3333
$filesystem->remove($nativeServeResourcePath);

src/Drivers/Electron/Traits/ExecuteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function executeCommand(
3535

3636
note('Fetching latest dependencies…');
3737

38-
Process::path(ElectronServiceProvider::ELECTRON_PATH)
38+
Process::path(ElectronServiceProvider::electronPath())
3939
->env($envs[$type])
4040
->forever()
4141
->tty(! $withoutInteraction && PHP_OS_FAMILY != 'Windows')

src/Drivers/Electron/Traits/InstallsAppIcon.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ trait InstallsAppIcon
88
{
99
public function installIcon()
1010
{
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');
11+
// Copy to Electron project
12+
@copy(public_path('icon.png'), ElectronServiceProvider::electronPath('build/icon.png'));
13+
@copy(public_path('icon.ico'), ElectronServiceProvider::electronPath('build/icon.ico'));
14+
@copy(public_path('icon.icns'), ElectronServiceProvider::electronPath('build/icon.icns'));
15+
16+
// Copy to asar archive
17+
@copy(public_path('icon.png'), ElectronServiceProvider::buildPath('icon.png'));
18+
@copy(public_path('icon.ico'), ElectronServiceProvider::buildPath('icon.ico'));
19+
@copy(public_path('icon.icns'), ElectronServiceProvider::buildPath('icon.icns'));
20+
21+
@copy(public_path('IconTemplate.png'), ElectronServiceProvider::buildPath('IconTemplate.png'));
22+
@copy(public_path('IconTemplate@2x.png'), ElectronServiceProvider::buildPath('IconTemplate@2x.png'));
1923
}
2024
}

0 commit comments

Comments
 (0)