Repository navigation
feat(detector): resolve the TanStack Start output directory from the vite config - #13914
ChiragAgg5k wants to merge 2 commits into
Conversation
…vite config Co-authored-by: harsh mahajan <[email protected]>
…here holds parsed dependency names
|
| public function getOutputDirectory(): string | ||
| { | ||
| return './.output'; | ||
| $static = $this->getAdapter($this->config) === 'static'; |
There was a problem hiding this comment.
Static output paths remain unreachable
When Appwrite detects a prerendered TanStack Start repository, it passes package.json and file names to the detector but never passes the Vite config content. This call therefore runs with an empty config and always selects ssr, reporting ./dist or ./.output instead of the static assets directory ./dist/client or ./.output/public. The missing config also prevents the plugin-registration check from determining whether Nitro is enabled.
Knowledge Base Used: Runtime detector library
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detection/Framework/TanStackStart.php
Line: 50
Comment:
**Static output paths remain unreachable**
When Appwrite detects a prerendered TanStack Start repository, it passes `package.json` and file names to the detector but never passes the Vite config content. This call therefore runs with an empty config and always selects `ssr`, reporting `./dist` or `./.output` instead of the static assets directory `./dist/client` or `./.output/public`. The missing config also prevents the plugin-registration check from determining whether Nitro is enabled.
**Knowledge Base Used:** [Runtime detector library](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/runtime-detector-library.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| foreach ($this->options as $detector) { | ||
| if ($detector->getName() === $bestFramework) { | ||
| $detector->setPackager($this->packager); | ||
| $detector->setPackages(\implode("\n", $manifests)); |
There was a problem hiding this comment.
Multiple manifests select Nitro output
If a caller supplies more than one supported INPUT_PACKAGES manifest, joining them with a newline produces a string that cannot be decoded as one JSON document. usesNitro() then treats the decode failure as evidence of Nitro, so a TanStack project without Nitro reports ./.output rather than ./dist.
Knowledge Base Used: Runtime detector library
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detector/Framework.php
Line: 132
Comment:
**Multiple manifests select Nitro output**
If a caller supplies more than one supported `INPUT_PACKAGES` manifest, joining them with a newline produces a string that cannot be decoded as one JSON document. `usesNitro()` then treats the decode failure as evidence of Nitro, so a TanStack project without Nitro reports `./.output` rather than `./dist`.
**Knowledge Base Used:** [Runtime detector library](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/runtime-detector-library.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| \preg_match('/\bprerender[\x27\x22]?\s*:\s*(\{(?:[^{}]|(?1))*\})/s', $stripped, $prerender); | ||
|
|
||
| // Listing routes, filtering them, or switching it off all leave part of the site to a server. | ||
| if (\preg_match('/\b(?:routes|filter)[\x27\x22]?\s*:|\benabled[\x27\x22]?\s*:\s*false\b/', $prerender[1] ?? '')) { |
There was a problem hiding this comment.
New regex checks violate guidance
The new prerender check uses a recursive preg_match, and the Nitro check also adds preg_replace and preg_match. The repository guide directs contributors not to add regex checks: use string operations or an existing validator, or explain in the PR why neither works. That requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/src/Detection/Framework/TanStackStart.php
Line: 107-110
Comment:
**New regex checks violate guidance**
The new prerender check uses a recursive `preg_match`, and the Nitro check also adds `preg_replace` and `preg_match`. The repository guide directs contributors not to add regex checks: use string operations or an existing validator, or explain in the PR why neither works. That requirement must be satisfied before merging.
**Context Used:** CLAUDE.md ([source](https://github.com/appwrite/appwrite/blob/main/CLAUDE.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| $this->assertSame('./.output/public', (new TanStackStart())->setPackages($nitro)->setConfig($nitroPrerender)->getOutputDirectory()); | ||
| $this->assertSame('./dist/client', (new TanStackStart())->setPackages($plain)->setConfig($prerender)->getOutputDirectory()); |
There was a problem hiding this comment.
Tests bypass config delivery
These tests create a framework result and inject Vite config directly, so they pass for static output paths even though the real detection flow never supplies that config. The additional syntax-specific config cases also couple the tests to the parser. The repository instruction requires tests of observable behavior rather than mirrored configuration details; cover the detection-to-output behavior before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/tests/DetectorTest.php
Line: 825-826
Comment:
**Tests bypass config delivery**
These tests create a framework result and inject Vite config directly, so they pass for static output paths even though the real detection flow never supplies that config. The additional syntax-specific config cases also couple the tests to the parser. The repository instruction requires tests of observable behavior rather than mirrored configuration details; cover the detection-to-output behavior before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
@HarshMN2345 your utopia-php/detector#19 is ported here, now that |
|
Closing this port. @HarshMN2345, re-open it if you still want the change in |
TanStackStart::getOutputDirectory()now resolves./.outputor./distdepending on whether a nitro plugin is both declared inpackage.jsonand registered in the vite config, and picks the static assets subdirectory (public/client) from the adapter.getAdapter()now treats a narrowed prerender (routes,filter) orenabled: falseasssr, and matches theprerenderblock with balanced braces.Ported from utopia-php/detector#19 after detector moved to packages/detector (#13891).
One adaptation: in
packages/detector,Detector\Framework::detect()already parses each manifest into a list of dependency names, so the detection is handed the raw manifests ($manifests) instead of$packages.bin/monorepo check detector(Pint, PHPStan, Rector)bin/monorepo test detectorbin/monorepo validategit diff --check🤖 Generated with Claude Code