Commit 82a9c4f
authored
feat(snippets): entrypoint-based render + sdk.yaml reduced to id (#405)
* feat(snippets): entrypoint-based render + sdk.yaml reduced to id
Two related schema changes that simplify the contract between this
repo and its consumers:
1. Drop the `ld-application.get-started-file(s)` field entirely.
The renderer no longer asks each sdk.yaml which file to rewrite.
Instead the consumer (gonfalon, ld-docs-private) declares its own
list of entrypoint directories, and the renderer walks them
recursively for files containing the SDK_SNIPPET:RENDER sentinel.
- `Render(sdksFS, entrypoints []string)` and the matching `Verify`
replace the old `(sdksFS, appDir)` signatures.
- The walk skips `node_modules`, `.git`, `.next`, `dist`, `build`,
`.cache`, `coverage`, `out`, `.turbo`. Files are filtered by
extension (.tsx/.jsx/.ts/.js/.mdx) and by a fast bytes.Contains
pre-check for the marker sentinel before invoking the regex
scanner.
- Symlinks are skipped, so a malicious symlink farm in a vendored
directory can't pull the renderer outside the entrypoint.
- Overlapping entrypoints dedupe.
- Empty entrypoint list, missing entrypoint, or entrypoint that
points at a file all fail loudly.
2. Reduce sdk.yaml to a single field: `id:`. The id matches the
SDK's identifier in launchdarkly/sdk-meta's API packages, where the
authoritative metadata lives (display name, type, languages,
regions, hello-world repo, docs URL). Every previously-modeled
field on the descriptor was unread by this codebase; downstream
consumers that need that metadata read sdk-meta directly.
- The `descriptor` struct + `loadDescriptor` function are deleted.
Nothing in the engine reads sdk.yaml today.
- Each of the 23 sdk.yaml files reduces to a header comment plus
`id: <sdk>`.
CLI:
Old: snippets render --target=ld-application --out=<consumer>
New: snippets render --target=ld-application --entrypoint=<dir> ...
--entrypoint is a custom flag.Value that accumulates across repeats
(mirrors the standard Go-stdlib stringSliceFlag idiom).
End-to-end against gonfalon's static/ld/components/getStarted:
- Reset every marker hash to 0 (122 markers in 24 files).
- `snippets render --entrypoint=...getStarted` rewrites all 24
files via the embedded sdks/ tree.
- Diff against pre-reset stash: byte-identical.
- `snippets verify --entrypoint=...getStarted`: ok.
Companion changes follow:
- launchdarkly/gh-actions PR #82 needs to add an `entrypoints` input
that the consumer-side workflow declares.
- This PR stacks on #404 (the embedding +
release pipeline PR).
* feat(snippets): drop ld-application.slot
Per the schema audit, slot was a write-only field — declared on the
LDApplicationHints struct, decoded from frontmatter, never read by any
production code. The marker comment carries the snippet id directly,
so the per-page lookup slot was meant to power doesn't happen.
- Remove the LDApplicationHints struct and the LDApplication field on
Frontmatter.
- Strip the `ld-application:\n slot: <name>\n` block from all 122
snippet files (KnownFields(true) would otherwise fail to parse them
after the struct change).
- Render output unaffected: end-to-end against gonfalon shows
`no changes` + `ok` from verify.
* fix(snippets): always descend into the entrypoint root
skipDirNames prunes well-known noise (node_modules, dist, build, …) under
each entrypoint, but filepath.WalkDir invokes the callback for the root
itself first. If a consumer pointed `--entrypoint=./build` at a project
that emits TSX there, the root's basename matched the skip-list and the
walk silently produced zero files. Guard the skip check so it only fires
beneath the root, and add a regression test.1 parent a7bf6af commit 82a9c4f
154 files changed
Lines changed: 350 additions & 971 deletions
File tree
- snippets
- cmd/snippets
- docs
- internal
- adapters/ldapplication
- model
- sdks
- android-client-sdk
- snippets/getting-started
- cpp-client-sdk
- snippets/getting-started
- cpp-server-sdk
- snippets/getting-started
- dotnet-client-sdk
- snippets/getting-started
- dotnet-server-sdk
- snippets/getting-started
- erlang-server-sdk
- snippets/getting-started
- flutter-client-sdk
- snippets/getting-started
- go-server-sdk
- snippets/getting-started
- haskell-server-sdk
- snippets/getting-started
- ios-client-sdk
- snippets/getting-started
- java-server-sdk
- snippets/getting-started
- js-client-sdk
- snippets/getting-started
- lua-server-sdk
- snippets/getting-started
- node-client-sdk
- snippets/getting-started
- node-server-sdk
- snippets/getting-started
- php-server-sdk
- snippets/getting-started
- python-server-sdk
- snippets/getting-started
- react-client-sdk
- snippets/getting-started
- react-native-client-sdk
- snippets/getting-started
- roku-client-sdk
- snippets/getting-started
- ruby-server-sdk
- snippets/getting-started
- rust-server-sdk
- snippets/getting-started
- vue-client-sdk
- snippets/getting-started
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| |||
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
76 | | - | |
| 88 | + | |
| 89 | + | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
80 | | - | |
81 | | - | |
| 93 | + | |
| 94 | + | |
82 | 95 | | |
83 | 96 | | |
84 | | - | |
| 97 | + | |
85 | 98 | | |
86 | 99 | | |
87 | 100 | | |
| |||
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
101 | | - | |
| 114 | + | |
| 115 | + | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
105 | | - | |
106 | | - | |
| 119 | + | |
| 120 | + | |
107 | 121 | | |
108 | 122 | | |
109 | | - | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
| |||
This file was deleted.
Lines changed: 104 additions & 72 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
28 | 24 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
33 | 32 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | | - | |
| 62 | + | |
54 | 63 | | |
55 | 64 | | |
56 | | - | |
| 65 | + | |
57 | 66 | | |
58 | | - | |
| 67 | + | |
59 | 68 | | |
60 | 69 | | |
61 | | - | |
62 | | - | |
63 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
64 | 78 | | |
65 | 79 | | |
66 | | - | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
| 93 | + | |
85 | 94 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | | - | |
91 | | - | |
| 100 | + | |
92 | 101 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 102 | + | |
97 | 103 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
105 | 129 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 130 | + | |
| 131 | + | |
112 | 132 | | |
113 | | - | |
114 | | - | |
| 133 | + | |
| 134 | + | |
115 | 135 | | |
116 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
117 | 149 | | |
118 | 150 | | |
119 | 151 | | |
| |||
0 commit comments