fix: resolve TS SDK review comments#1407
Conversation
…gnore - Convert lockfile templates from copy to Twig-rendered scope so PLACEHOLDER values are replaced with real package metadata (name, version, license) during generation - Add JSDoc documentation to getHeaders() in node, web, react-native, and cli client templates - Fix .gitignore dist/ negation pattern in web and react-native to only track package.json stubs, not generated build outputs - Update update-lockfiles.sh to restore Twig expressions after lockfile generation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughLockfile generation moved from static copies to Twig templates with POSIX-portable helpers to restore Twig placeholders in npm/bun outputs. SDK file manifests updated to use Changes
Sequence Diagram(s)sequenceDiagram
participant Generator
participant BuildScript as "scripts/update-lockfiles.sh"
participant PackageTool as "npm / bun"
participant Files as "Filesystem / Templates"
Generator->>BuildScript: invoke update_npm/update_bun (lang, extra_flags, twig_name)
BuildScript->>PackageTool: run package tool to generate lockfile
PackageTool-->>BuildScript: emits lockfile (static values)
BuildScript->>Files: copy lockfile to *.lock.twig
BuildScript->>BuildScript: run restore_twig_* to replace first PLACEHOLDERs with Twig exprs
BuildScript->>Files: write final *.lock.twig
BuildScript-->>Generator: return status (fail if PLACEHOLDER remains)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR addresses a set of SDK review comments across the TypeScript-based SDK targets (node, web, react-native, cli) by fixing PLACEHOLDER lock file values, adding
One minor cleanup opportunity: when Confidence Score: 5/5Safe to merge — all previously flagged P1 issues are resolved and the one remaining finding is a minor P2 cleanup in a developer tooling script. The two P1 concerns from prior review threads (PLACEHOLDER lockfile values and GNU sed incompatibility on macOS) are both properly addressed. The gitignore fix uses the correct dist/* glob and a valid three-stage negation chain. The only new finding is a stale .tmp file that can be left behind if replace_first fails to locate a pattern — this is P2 and does not affect the correctness of the generated SDKs. scripts/update-lockfiles.sh — minor .tmp cleanup issue in the replace_first function. Important Files Changed
Reviews (4): Last reviewed commit: "fix: exclude lock files from max-line-le..." | Re-trigger Greptile |
- Use dist/* (glob) instead of dist/ (directory) in .gitignore so negation patterns for package.json stubs still work - Replace GNU sed 0,/addr/ with portable awk-based replace_first() in update-lockfiles.sh for macOS compatibility
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/update-lockfiles.sh`:
- Around line 40-45: The replace_first helper is allowing silent no-ops which
can corrupt lockfiles; update the awk invocation inside replace_first to exit
with code 2 when it doesn't find/replace the pattern, then ensure callers of
replace_first (the lines replacing "PLACEHOLDER" for name, version, license)
check that exit code and abort on non-zero; additionally add a final validation
step (e.g., grep or awk scan) after all replacements to detect any remaining
"PLACEHOLDER" tokens and fail the script if any are found so lockfiles are never
left partially replaced.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a4016a2b-ce13-4fa7-9ce1-ab49c0f111ed
📒 Files selected for processing (15)
scripts/update-lockfiles.shsrc/SDK/Language/CLI.phpsrc/SDK/Language/Node.phpsrc/SDK/Language/ReactNative.phpsrc/SDK/Language/Web.phptemplates/cli/bun.lock.twigtemplates/cli/lib/client.tstemplates/node/package-lock.json.twigtemplates/node/src/client.ts.twigtemplates/react-native/.gitignoretemplates/react-native/package-lock.json.twigtemplates/react-native/src/client.ts.twigtemplates/web/.gitignoretemplates/web/package-lock.json.twigtemplates/web/src/client.ts.twig
- Add EXIT block to awk so replace_first exits with code 2 when the pattern is not found, preventing silent no-ops - Add post-replacement grep validation in restore_twig_npm and restore_twig_bun to catch any remaining PLACEHOLDER values
Summary
Addresses review comments from the following SDK PRs:
Changes
copyscope to Twig-rendereddefaultscope. Thename,version, andlicensefields now use proper Twig expressions ({{ language.params.npmPackage }},{{ sdk.version }},{{ sdk.license }}) instead of being stuck as"PLACEHOLDER". Updatedscripts/update-lockfiles.shto restore Twig expressions after generating lockfiles.getHeaders()(P2): Added JSDoc documentation togetHeaders()in all four TS client templates (node, web, react-native, cli)..gitignoredist/ pattern (React Native + Web): Fixed the negation pattern so onlydist/cjs/package.jsonanddist/esm/package.jsonare tracked — generated build outputs in those directories are now properly ignored.Test plan
getHeaders()has JSDoc in all generated client files.gitignorecorrectly ignoresdist/build outputs while keepingpackage.jsonstubscomposer lint-twig— 0 errors)Summary by CodeRabbit
New Features
Chores