mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
feat: detect framework adapter from config files pre-build
- Add adapter field to detection endpoint response - Read framework config files from GitHub to detect SSR/static adapter - Uses utopia-php/detector 0.2.5 getConfigFiles()/getAdapter() hooks - Falls back to framework config default when detection is inconclusive - Short-circuit package.json fetch using already-fetched packages content
This commit is contained in:
1 parent
7e1010dc0d
commit
134d94d0eb
2 files changed
+43
-14
No files matched your search
Generated
+6
-6
@@ -3742,16 +3742,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/detector.git",
|
||||
"reference": "a564381108518ce6d18b6ab441f1448bd8355afd"
|
||||
"reference": "20f7e2ea8084176fae88a473f82f410281978a3b"
|
||||
},
|
||||
"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/20f7e2ea8084176fae88a473f82f410281978a3b",
|
||||
"reference": "20f7e2ea8084176fae88a473f82f410281978a3b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3781,9 +3781,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.5"
|
||||
},
|
||||
"time": "2026-02-17T11:26:34+00:00"
|
||||
"time": "2026-06-17T08:16:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/di",
|
||||
|
||||
+37
-8
@@ -191,23 +191,51 @@ class Create extends Action
|
||||
$output->setAttribute('installCommand', $framework->getInstallCommand());
|
||||
$output->setAttribute('buildCommand', $framework->getBuildCommand());
|
||||
$output->setAttribute('outputDirectory', $framework->getOutputDirectory());
|
||||
$framework = $framework->getName();
|
||||
$frameworkName = $framework->getName();
|
||||
|
||||
$configContent = '';
|
||||
foreach ($framework->getConfigFiles() as $configFile) {
|
||||
if ($configFile === 'package.json') {
|
||||
$configContent = $packages;
|
||||
break;
|
||||
}
|
||||
if (!\in_array($configFile, $files, true)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$configPath = \rtrim($providerRootDirectory, '/') . '/' . $configFile;
|
||||
$configResponse = $github->getRepositoryContent($owner, $repositoryName, $configPath);
|
||||
$configContent = $configResponse['content'] ?? '';
|
||||
if (!empty($configContent)) {
|
||||
break;
|
||||
}
|
||||
} catch (FileNotFound $e) {
|
||||
// Try next config file
|
||||
}
|
||||
}
|
||||
|
||||
$detectedAdapter = !empty($configContent) ? $framework->getAdapter($configContent) : '';
|
||||
} else {
|
||||
$framework = 'other';
|
||||
$frameworkName = 'other';
|
||||
$detectedAdapter = '';
|
||||
$output->setAttribute('installCommand', '');
|
||||
$output->setAttribute('buildCommand', '');
|
||||
$output->setAttribute('outputDirectory', '');
|
||||
}
|
||||
|
||||
$frameworks = Config::getParam('frameworks');
|
||||
if (!\in_array($framework, \array_keys($frameworks), true)) {
|
||||
$framework = 'other';
|
||||
if (!\in_array($frameworkName, \array_keys($frameworks), true)) {
|
||||
$frameworkName = 'other';
|
||||
}
|
||||
$output->setAttribute('framework', $framework);
|
||||
$output->setAttribute('framework', $frameworkName);
|
||||
|
||||
$frameworkConfig = $frameworks[$framework] ?? [];
|
||||
$defaultAdapter = \array_key_first($frameworkConfig['adapters'] ?? []) ?? '';
|
||||
$output->setAttribute('adapter', $defaultAdapter);
|
||||
$frameworkConfig = $frameworks[$frameworkName] ?? [];
|
||||
if (!empty($frameworkConfig['adapters'])) {
|
||||
$adapter = (!empty($detectedAdapter) && isset($frameworkConfig['adapters'][$detectedAdapter]))
|
||||
? $detectedAdapter
|
||||
: \array_key_first($frameworkConfig['adapters']);
|
||||
$output->setAttribute('adapter', $adapter);
|
||||
}
|
||||
} else {
|
||||
$output = new Document([
|
||||
'runtime' => '',
|
||||
@@ -318,4 +346,5 @@ class Create extends Action
|
||||
|
||||
$response->dynamic($output, $type === 'framework' ? Response::MODEL_DETECTION_FRAMEWORK : Response::MODEL_DETECTION_RUNTIME);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user