mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #12756 from appwrite/fix-ssr-detection-at-scale
Fix: SSR detection
This commit is contained in:
3 files changed
+22
-13
No files matched your search
Generated
+6
-6
@@ -3736,16 +3736,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/detector.git",
|
||||
"reference": "a564381108518ce6d18b6ab441f1448bd8355afd"
|
||||
"reference": "2b2744be7ea028307dc9352eeec109cd1f9ab2d3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/detector/zipball/a564381108518ce6d18b6ab441f1448bd8355afd",
|
||||
"reference": "a564381108518ce6d18b6ab441f1448bd8355afd",
|
||||
"url": "https://api.github.com/repos/utopia-php/detector/zipball/2b2744be7ea028307dc9352eeec109cd1f9ab2d3",
|
||||
"reference": "2b2744be7ea028307dc9352eeec109cd1f9ab2d3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3775,9 +3775,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/detector/issues",
|
||||
"source": "https://github.com/utopia-php/detector/tree/0.2.4"
|
||||
"source": "https://github.com/utopia-php/detector/tree/0.2.6"
|
||||
},
|
||||
"time": "2026-02-17T11:26:34+00:00"
|
||||
"time": "2026-07-01T14:00:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/di",
|
||||
|
||||
@@ -749,7 +749,7 @@ class Builds extends Action
|
||||
} else {
|
||||
$outputDirectory = $deployment->getAttribute('buildOutput') ?? $resource->getAttribute('outputDirectory');
|
||||
if ($resource->getCollection() === 'sites') {
|
||||
$command = $this->prepareSiteBuildCommand($command, $outputDirectory ?? '');
|
||||
$command = $this->prepareSiteBuildCommand($command, $outputDirectory ?? '', $resource->getAttribute('framework', ''));
|
||||
}
|
||||
|
||||
$command = 'tar -zxf /tmp/code.tar.gz -C /mnt/code && helpers/build.sh ' . \trim(\escapeshellarg($command));
|
||||
@@ -1399,7 +1399,7 @@ class Builds extends Action
|
||||
return \substr(\hash('sha256', \json_encode($hashContext, JSON_THROW_ON_ERROR)), 0, 48);
|
||||
}
|
||||
|
||||
protected function prepareSiteBuildCommand(string $command, string $outputDirectory): string
|
||||
protected function prepareSiteBuildCommand(string $command, string $outputDirectory, string $framework): string
|
||||
{
|
||||
$listFilesCommand = 'echo "{APPWRITE_DETECTION_SEPARATOR_START}" && cd /usr/local/build';
|
||||
|
||||
@@ -1407,7 +1407,14 @@ class Builds extends Action
|
||||
$listFilesCommand .= ' && cd ' . \escapeshellarg($outputDirectory);
|
||||
}
|
||||
|
||||
$listFilesCommand .= ' && find . -name \'node_modules\' -prune -o -type f -print && echo "{APPWRITE_DETECTION_SEPARATOR_END}"';
|
||||
foreach (SSR::FRAMEWORK_FILES[$framework] ?? [] as $file) {
|
||||
$listFilesCommand .= ' && ( [ -e ' . \escapeshellarg($file) . ' ] && echo ' . \escapeshellarg($file) . ' || true )';
|
||||
}
|
||||
|
||||
// Static fallback detection only needs to distinguish 0, 1, or 2+ HTML files, so cap the output
|
||||
$listFilesCommand .= ' && find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2';
|
||||
|
||||
$listFilesCommand .= ' && echo "{APPWRITE_DETECTION_SEPARATOR_END}"';
|
||||
|
||||
if (empty($command)) {
|
||||
return $listFilesCommand;
|
||||
|
||||
@@ -45,20 +45,22 @@ final class BuildsTest extends TestCase
|
||||
|
||||
public function testSiteBuildCommandAppendsDetectionFileListing(): void
|
||||
{
|
||||
$command = $this->callBuilds('prepareSiteBuildCommand', 'npm run build', './dist folder');
|
||||
$command = $this->callBuilds('prepareSiteBuildCommand', 'npm run build', './dist folder', 'astro');
|
||||
|
||||
$this->assertStringStartsWith('npm run build && echo "{APPWRITE_DETECTION_SEPARATOR_START}"', $command);
|
||||
$this->assertStringContainsString('cd /usr/local/build && cd \'./dist folder\'', (string) $command);
|
||||
$this->assertStringContainsString('find . -name \'node_modules\' -prune -o -type f -print', (string) $command);
|
||||
$this->assertStringContainsString('( [ -e \'server/entry.mjs\' ] && echo \'server/entry.mjs\' || true )', (string) $command);
|
||||
$this->assertStringContainsString('find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2', (string) $command);
|
||||
$this->assertStringEndsWith('echo "{APPWRITE_DETECTION_SEPARATOR_END}"', $command);
|
||||
}
|
||||
|
||||
public function testSiteBuildCommandCanBeOnlyDetectionFileListing(): void
|
||||
{
|
||||
$command = $this->callBuilds('prepareSiteBuildCommand', '', '');
|
||||
$command = $this->callBuilds('prepareSiteBuildCommand', '', '', 'sveltekit');
|
||||
|
||||
$this->assertStringStartsWith('echo "{APPWRITE_DETECTION_SEPARATOR_START}"', $command);
|
||||
$this->assertStringContainsString('cd /usr/local/build && find .', (string) $command);
|
||||
$this->assertStringContainsString('cd /usr/local/build && ( [ -e \'handler.js\' ] && echo \'handler.js\' || true )', (string) $command);
|
||||
$this->assertStringContainsString('find . -name \'node_modules\' -prune -o -type f -name \'*.html\' -print | head -n 2', (string) $command);
|
||||
}
|
||||
|
||||
public function testSplitSiteDetectionLogsRemovesDetectionBlock(): void
|
||||
|
||||
Reference in new issue
Block a user