chore(setup): add SDK init/injection library and templates - #751
chore(setup): add SDK init/injection library and templates#751ffantl-ld wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c56c506. Configure here.
| // --- init --- | ||
| const ldClient = new LDClient(); | ||
| const context = { kind: 'user', key: 'example-user-key', name: 'Example User' }; | ||
| await ldClient.configure({ mobileKey: '{{.MobileKey}}' }, context); |
There was a problem hiding this comment.
React Native template API mismatch
High Severity
The React Native init snippet imports @launchdarkly/react-native-client-sdk (v10) but uses the v9 LDClient default export and configure() API. That package exposes ReactNativeLDClient instead, so the guidance snippet does not run against the imported SDK.
Reviewed by Cursor Bugbot for commit c56c506. Configure here.
| "python-server-sdk": "sdk/server-side/python", | ||
| "react-client-sdk": "sdk/client-side/react", | ||
| "react-native": "sdk/client-side/react-native", | ||
| "react-native-client-sdk": "sdk/client-side/react-native", |
There was a problem hiding this comment.
Incorrect React Native docs URL
Medium Severity
sdkDocsPaths maps react-native and react-native-client-sdk to sdk/client-side/react-native, but the live docs live at sdk/client-side/react/react-native. GetDocsURL therefore returns a dead link for those IDs.
Reviewed by Cursor Bugbot for commit c56c506. Configure here.
|
|
||
| content := string(existing) | ||
| if importSection != "" { | ||
| content = importSection + "\n" + content |
There was a problem hiding this comment.
Import prepend breaks shebang
High Severity
For append-safe SDKs, InjectIntoFile always prepends the import section at byte 0 of an existing file. That displaces a leading shebang and Python encoding cookies, so common entry points like manage.py stop being directly executable.
Reviewed by Cursor Bugbot for commit c56c506. Configure here.
| @@ -0,0 +1,12 @@ | |||
| import * as LDClient from 'launchdarkly-js-client-sdk'; | |||
There was a problem hiding this comment.
JS client package name mismatch
Medium Severity
The JS client init template imports launchdarkly-js-client-sdk, but the stacked installer layer installs @launchdarkly/js-client-sdk for the same SDK ID. After a successful install, the rendered snippet’s import does not resolve to the installed package.
Reviewed by Cursor Bugbot for commit c56c506. Configure here.


Describe the solution you've provided
Third layer of the guided
setupcommand: SDK initialization. Renders per-SDK code snippets from embedded templates and injects them into the project (Initializer,RenderTemplate,InjectIntoFile), plus docs-URL helpers. Ships thesdk_init_templates/for the supported SDKs.Independent library layer.
Related issues
Part of the
setup-ldfeature. Stacked PR — base isffantl/setup-ld/2-installer.Requirements
Note
Medium Risk
Append-safe paths write to user-specified files (create or modify), so callers must pass correct paths; guidance-only paths avoid corrupting compiled/framework projects.
Overview
Adds an SDK initialization layer for guided
setup: embedded per-SDK templates render init code fromInitConfig(SDK key, client-side ID, mobile key, flag key), andInjectIntoFileeither writes into the project or returns copy-paste guidance.In-place injection is limited to append-safe interpreted entrypoints (Node, Python, Ruby): imports are prepended and init code appended, with
// --- init ---/# --- init ---stripped from output. Go, Java, C#, Swift, Android, React, and React Native never modify files—InitResultreturnsSuccess: falsewith a Snippet and DocsURL so callers do not treat broken appended code as done. SDKs without templates only get documentation links via a broadsdkDocsPathsmap andGetDocsURL.Ships 11
sdk_init_templates/*.tmplfiles plus unit tests covering rendering, injection, guidance-only paths, and docs fallbacks.Reviewed by Cursor Bugbot for commit c56c506. Bugbot is set up for automated code reviews on this repo. Configure here.