Skip to content

Commit e5c8f28

Browse files
committed
rename Bundler to Builder
1 parent e838e15 commit e5c8f28

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

src/Desktop/Drivers/Electron/Commands/BuildCommand.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Native\Desktop\Drivers\Electron\Traits\InstallsAppIcon;
1111
use Native\Desktop\Drivers\Electron\Traits\OsAndArch;
1212
use Native\Desktop\Drivers\Electron\Traits\PatchesPackagesJson;
13-
use Native\Support\Bundler;
13+
use Native\Support\Builder;
1414
use Symfony\Component\Console\Attribute\AsCommand;
1515
use Symfony\Component\Process\Process as SymfonyProcess;
1616

@@ -38,7 +38,7 @@ class BuildCommand extends Command
3838
private string $buildOS;
3939

4040
public function __construct(
41-
protected Bundler $bundler
41+
protected Builder $builder
4242
) {
4343
parent::__construct();
4444
}
@@ -58,81 +58,81 @@ public function handle(): void
5858
$this->buildCommand = 'publish';
5959
}
6060

61-
if ($this->bundler->hasBundled()) {
61+
if ($this->builder->hasBundled()) {
6262
$this->buildBundle();
6363
} else {
64-
$this->bundler->warnUnsecureBuild();
64+
$this->builder->warnUnsecureBuild();
6565
$this->buildUnsecure();
6666
}
6767
}
6868

6969
private function buildBundle(): void
7070
{
71-
$this->bundler->preProcess();
71+
$this->builder->preProcess();
7272

7373
$this->setAppNameAndVersion();
7474

7575
$this->updateElectronDependencies();
7676

7777
$this->newLine();
7878
intro('Copying Bundle to build directory...');
79-
$this->bundler->copyBundleToBuildDirectory();
79+
$this->builder->copyBundleToBuildDirectory();
8080

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

8585
$this->newLine();
8686
intro('Copying app icons...');
8787
$this->installIcon();
8888

8989
$this->buildOrPublish();
9090

91-
$this->bundler->postProcess();
91+
$this->builder->postProcess();
9292
}
9393

9494
private function buildUnsecure(): void
9595
{
96-
$this->bundler->preProcess();
96+
$this->builder->preProcess();
9797

9898
$this->setAppNameAndVersion();
9999

100100
$this->updateElectronDependencies();
101101

102102
$this->newLine();
103103
intro('Copying App to build directory...');
104-
$this->bundler->copyToBuildDirectory();
104+
$this->builder->copyToBuildDirectory();
105105

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

110110
$this->newLine();
111111
intro('Cleaning .env file...');
112-
$this->bundler->cleanEnvFile();
112+
$this->builder->cleanEnvFile();
113113

114114
$this->newLine();
115115
intro('Copying app icons...');
116116
$this->installIcon();
117117

118118
$this->newLine();
119119
intro('Pruning vendor directory');
120-
$this->bundler->pruneVendorDirectory();
120+
$this->builder->pruneVendorDirectory();
121121

122122
$this->buildOrPublish();
123123

124-
$this->bundler->postProcess();
124+
$this->builder->postProcess();
125125
}
126126

127127
protected function getEnvironmentVariables(): array
128128
{
129129
return array_merge(
130130
[
131-
'APP_PATH' => $this->bundler->sourcePath(),
131+
'APP_PATH' => $this->builder->sourcePath(),
132132
'APP_URL' => config('app.url'),
133133
'NATIVEPHP_BUILDING' => true,
134134
'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION,
135-
'NATIVEPHP_PHP_BINARY_PATH' => $this->bundler->phpBinaryPath(),
135+
'NATIVEPHP_PHP_BINARY_PATH' => $this->builder->phpBinaryPath(),
136136
'NATIVEPHP_APP_NAME' => config('app.name'),
137137
'NATIVEPHP_APP_ID' => config('nativephp.app_id'),
138138
'NATIVEPHP_APP_VERSION' => config('nativephp.version'),

src/Desktop/Drivers/Electron/Commands/BundleCommand.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Native\Desktop\Drivers\Electron\Traits\HandlesZephpyr;
1313
use Native\Desktop\Drivers\Electron\Traits\InstallsAppIcon;
1414
use Native\Desktop\Drivers\Electron\Traits\PatchesPackagesJson;
15-
use Native\Support\Bundler;
15+
use Native\Support\Builder;
1616
use Symfony\Component\Console\Attribute\AsCommand;
1717
use Symfony\Component\Finder\Finder;
1818
use ZipArchive;
@@ -37,13 +37,13 @@ class BundleCommand extends Command
3737

3838
private string $zipName;
3939

40-
private Bundler $bundler;
40+
private Builder $builder;
4141

4242
public function __construct()
4343
{
4444
parent::__construct();
4545

46-
$this->bundler = Bundler::make(
46+
$this->builder = Builder::make(
4747
buildPath: base_path('build/app/')
4848
);
4949
}
@@ -96,19 +96,19 @@ public function handle(): int
9696
intro('Copying App to build directory...');
9797

9898
// We update composer.json later,
99-
$this->bundler->copyToBuildDirectory();
99+
$this->builder->copyToBuildDirectory();
100100

101101
$this->newLine();
102102
intro('Cleaning .env file...');
103-
$this->bundler->cleanEnvFile();
103+
$this->builder->cleanEnvFile();
104104

105105
$this->newLine();
106106
intro('Copying app icons...');
107107
$this->installIcon();
108108

109109
$this->newLine();
110110
intro('Pruning vendor directory');
111-
$this->bundler->pruneVendorDirectory();
111+
$this->builder->pruneVendorDirectory();
112112

113113
// Check composer.json for symlinked or private packages
114114
if (! $this->checkComposerJson()) {
@@ -161,7 +161,7 @@ private function zipApplication(): bool
161161

162162
private function checkComposerJson(): bool
163163
{
164-
$composerJson = json_decode(file_get_contents($this->bundler->buildPath('composer.json')), true);
164+
$composerJson = json_decode(file_get_contents($this->builder->buildPath('composer.json')), true);
165165

166166
// // Fail if there is symlinked packages
167167
// foreach ($composerJson['repositories'] ?? [] as $repository) {
@@ -194,10 +194,10 @@ private function checkComposerJson(): bool
194194

195195
if (count($filteredRepo) !== count($composerJson['repositories'])) {
196196
$composerJson['repositories'] = $filteredRepo;
197-
file_put_contents($this->bundler->buildPath('composer.json'),
197+
file_put_contents($this->builder->buildPath('composer.json'),
198198
json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
199199

200-
// Process::path($this->bundler->buildPath())
200+
// Process::path($this->builder->buildPath())
201201
// ->run('composer install --no-dev', function (string $type, string $output) {
202202
// echo $output;
203203
// });
@@ -228,7 +228,7 @@ private function addFilesToZip(ZipArchive $zip): void
228228
$finder = (new Finder)->files()
229229
->followLinks()
230230
// ->ignoreVCSIgnored(true) // TODO: Make our own list of ignored files
231-
->in($this->bundler->buildPath())
231+
->in($this->builder->buildPath())
232232
->exclude([
233233
// We add those a few lines below and they are ignored by most .gitignore anyway
234234
'vendor',
@@ -246,22 +246,22 @@ private function addFilesToZip(ZipArchive $zip): void
246246
$this->finderToZip($finder, $zip);
247247

248248
// Why do I have to force this? please someone explain.
249-
if (file_exists($this->bundler->buildPath('public/build'))) {
249+
if (file_exists($this->builder->buildPath('public/build'))) {
250250
$this->finderToZip(
251251
(new Finder)->files()
252252
->followLinks()
253-
->in($this->bundler->buildPath('public/build')), $zip, 'public/build');
253+
->in($this->builder->buildPath('public/build')), $zip, 'public/build');
254254
}
255255

256256
// Add .env file manually because Finder ignores VCS and dot files
257-
$zip->addFile($this->bundler->buildPath('.env'), '.env');
257+
$zip->addFile($this->builder->buildPath('.env'), '.env');
258258

259259
// Add auth.json file to support private packages
260260
// WARNING: Only for testing purposes, don't uncomment this
261-
// $zip->addFile($this->bundler->buildPath('auth.json'), 'auth.json');
261+
// $zip->addFile($this->builder->buildPath('auth.json'), 'auth.json');
262262

263263
// Custom binaries
264-
$binaryPath = Str::replaceStart($this->bundler->buildPath('vendor'), '', config('nativephp.binary_path'));
264+
$binaryPath = Str::replaceStart($this->builder->buildPath('vendor'), '', config('nativephp.binary_path'));
265265

266266
// Add composer dependencies without unnecessary files
267267
$vendor = (new Finder)->files()
@@ -271,14 +271,14 @@ private function addFilesToZip(ZipArchive $zip): void
271271
'*/*/vendor', // Exclude sub-vendor directories
272272
$binaryPath,
273273
]))
274-
->in($this->bundler->buildPath('vendor'));
274+
->in($this->builder->buildPath('vendor'));
275275

276276
$this->finderToZip($vendor, $zip, 'vendor');
277277

278278
// Add javascript dependencies
279-
if (file_exists($this->bundler->buildPath('node_modules'))) {
279+
if (file_exists($this->builder->buildPath('node_modules'))) {
280280
$nodeModules = (new Finder)->files()
281-
->in($this->bundler->buildPath('node_modules'));
281+
->in($this->builder->buildPath('node_modules'));
282282

283283
$this->finderToZip($nodeModules, $zip, 'node_modules');
284284
}

src/Desktop/Drivers/Electron/Commands/DevelopCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Native\Desktop\Drivers\Electron\Traits\Installer;
99
use Native\Desktop\Drivers\Electron\Traits\InstallsAppIcon;
1010
use Native\Desktop\Drivers\Electron\Traits\PatchesPackagesJson;
11-
use Native\Support\Bundler;
11+
use Native\Support\Builder;
1212
use Symfony\Component\Console\Attribute\AsCommand;
1313

1414
use function Laravel\Prompts\intro;
@@ -28,7 +28,7 @@ class DevelopCommand extends Command
2828
protected $signature = 'native:serve {--no-queue} {--D|no-dependencies} {--installer=npm}';
2929

3030
public function __construct(
31-
protected Bundler $bundler
31+
protected Builder $builder
3232
) {
3333
parent::__construct();
3434
}
@@ -57,7 +57,7 @@ public function handle(): void
5757

5858
$this->installIcon();
5959

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

6262
$this->runDeveloper(
6363
installer: $this->option('installer'),

src/Desktop/Drivers/Electron/ElectronServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Native\Desktop\Drivers\Electron\Commands\PublishCommand;
1111
use Native\Desktop\Drivers\Electron\Commands\ResetCommand;
1212
use Native\Desktop\Drivers\Electron\Updater\UpdaterManager;
13-
use Native\Support\Bundler;
13+
use Native\Support\Builder;
1414
use Spatie\LaravelPackageTools\Package;
1515
use Spatie\LaravelPackageTools\PackageServiceProvider;
1616

@@ -38,8 +38,8 @@ public function packageRegistered(): void
3838
return new UpdaterManager($app);
3939
});
4040

41-
$this->app->bind(Bundler::class, function () {
42-
return Bundler::make(
41+
$this->app->bind(Builder::class, function () {
42+
return Builder::make(
4343
buildPath: self::ELECTRON_PATH.'/resources/app'
4444
);
4545
});

src/Desktop/Drivers/Electron/Traits/ExecuteCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Support\Facades\Process;
66
use Native\Desktop\Drivers\Electron\ElectronServiceProvider;
7-
use Native\Support\Bundler;
7+
use Native\Support\Builder;
88

99
use function Laravel\Prompts\note;
1010

@@ -17,17 +17,17 @@ protected function executeCommand(
1717
bool $withoutInteraction = false
1818
): void {
1919

20-
$bundler = resolve(Bundler::class);
20+
$builder = resolve(Builder::class);
2121

2222
$envs = [
2323
'install' => [
2424
'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION,
25-
'NATIVEPHP_PHP_BINARY_PATH' => $bundler->phpBinaryPath(),
25+
'NATIVEPHP_PHP_BINARY_PATH' => $builder->phpBinaryPath(),
2626
],
2727
'serve' => [
2828
'APP_PATH' => base_path(),
2929
'NATIVEPHP_PHP_BINARY_VERSION' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION,
30-
'NATIVEPHP_PHP_BINARY_PATH' => $bundler->phpBinaryPath(),
30+
'NATIVEPHP_PHP_BINARY_PATH' => $builder->phpBinaryPath(),
3131
'NATIVE_PHP_SKIP_QUEUE' => $skip_queue,
3232
'NATIVEPHP_BUILDING' => false,
3333
],

src/Support/Bundler.php renamed to src/Support/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Native\Support\Traits\PrunesVendorDirectory;
1212
use Symfony\Component\Filesystem\Path;
1313

14-
class Bundler
14+
class Builder
1515
{
1616
use CleansEnvFile;
1717
use CopiesBundleToBuildDirectory;

tests/Build/CopiesCertificateAuthorityTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
use Native\Desktop\Drivers\Electron\ElectronServiceProvider;
4-
use Native\Support\Bundler;
4+
use Native\Support\Builder;
55
use Symfony\Component\Filesystem\Filesystem;
66
use Symfony\Component\Filesystem\Path;
77

@@ -12,7 +12,7 @@
1212

1313
expect($certificatePath)->not->toBeFile();
1414

15-
resolve(Bundler::class)->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources');
15+
resolve(Builder::class)->copyCertificateAuthority(path: ElectronServiceProvider::ELECTRON_PATH.'/resources');
1616

1717
expect($certificatePath)->toBeFile();
1818

0 commit comments

Comments
 (0)