Skip to content

Commit 666f68b

Browse files
committed
fix: bundling
1 parent 613d955 commit 666f68b

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

resources/js/electron-plugin/src/server/php.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
252252

253253
phpServer.stdout.on('data', (data) => {
254254
// [Tue Jan 14 19:51:00 2025] 127.0.0.1:52779 [POST] URI: /_native/api/events
255-
console.log('D:', data.toString());
255+
256+
if (parseInt(process.env.SHELL_VERBOSITY) > 0) {
257+
console.log(data.toString());
258+
}
256259
})
257260

258261

src/Commands/BundleCommand.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ private function addFilesToZip(ZipArchive $zip): void
221221
intro('Creating zip archive…');
222222

223223
$finder = (new Finder)->files()
224-
->followLinks()
225-
// ->ignoreVCSIgnored(true) // TODO: Make our own list of ignored files
224+
// ->followLinks()
225+
->ignoreVCSIgnored(true) // TODO: Make our own list of ignored files
226226
->in($this->buildPath())
227227
->exclude([
228228
// We add those a few lines below
@@ -239,6 +239,12 @@ private function addFilesToZip(ZipArchive $zip): void
239239

240240
$this->finderToZip($finder, $zip);
241241

242+
// Why do I have to force this? please someone explain.
243+
$this->finderToZip(
244+
(new Finder)->files()
245+
->followLinks()
246+
->in($this->buildPath('public/build')), $zip, 'public/build');
247+
242248
// Add .env file manually because Finder ignores VCS and dot files
243249
$zip->addFile($this->buildPath('.env'), '.env');
244250

@@ -306,9 +312,18 @@ private function fetchLatestBundle(): bool
306312
if ($response->status() === 404) {
307313
$this->error('Project or bundle not found.');
308314
} elseif ($response->status() === 500) {
309-
$this->error('Build failed. Please try again later.');
315+
$url = $response->json('url');
316+
317+
if ($url) {
318+
$this->error('Build failed. Inspect the build here: '.$url);
319+
} else {
320+
$this->error('Build failed. Please try again later.');
321+
}
310322
} elseif ($response->status() === 503) {
311-
$this->warn('Bundle not ready. Please try again in '.now()->addSeconds(intval($response->header('Retry-After')))->diffForHumans(syntax: CarbonInterface::DIFF_ABSOLUTE).'.');
323+
$retryAfter = intval($response->header('Retry-After'));
324+
$diff = now()->addSeconds($retryAfter);
325+
$diffMessage = $retryAfter <= 60 ? 'a minute' : $diff->diffForHumans(syntax: CarbonInterface::DIFF_ABSOLUTE);
326+
$this->warn('Bundle not ready. Please try again in '.$diffMessage.'.');
312327
} else {
313328
$this->handleApiErrors($response);
314329
}
@@ -371,12 +386,12 @@ protected function cleanUp(): void
371386

372387
protected function buildPath(string $path = ''): string
373388
{
374-
return base_path('temp/build/'.$path);
389+
return base_path('build/app/'.$path);
375390
}
376391

377392
protected function zipPath(string $path = ''): string
378393
{
379-
return base_path('temp/zip/'.$path);
394+
return base_path('build/zip/'.$path);
380395
}
381396

382397
protected function sourcePath(string $path = ''): string

src/Traits/CopiesToBuildDirectory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ abstract protected function sourcePath(string $path = ''): string;
5151

5252
// Also deleted in PrunesVendorDirectory after fresh composer install
5353
'vendor/bin',
54+
55+
// Exlude build & temp directory
56+
'build',
57+
'temp',
5458
];
5559

5660
public function copyToBuildDirectory()

0 commit comments

Comments
 (0)