Commit afa94b7
committed
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).1 parent e66b285 commit afa94b7
28 files changed
Lines changed: 321 additions & 712 deletions
File tree
- snippets
- cmd/snippets
- docs
- internal/adapters/ldapplication
- sdks
- android-client-sdk
- cpp-client-sdk
- cpp-server-sdk
- dotnet-client-sdk
- dotnet-server-sdk
- erlang-server-sdk
- flutter-client-sdk
- go-server-sdk
- haskell-server-sdk
- ios-client-sdk
- java-server-sdk
- js-client-sdk
- lua-server-sdk
- node-client-sdk
- node-server-sdk
- php-server-sdk
- python-server-sdk
- react-client-sdk
- react-native-client-sdk
- roku-client-sdk
- ruby-server-sdk
- rust-server-sdk
- vue-client-sdk
| 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: 96 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 | + | |
105 | 121 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 122 | + | |
| 123 | + | |
112 | 124 | | |
113 | | - | |
114 | | - | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
117 | 141 | | |
118 | 142 | | |
119 | 143 | | |
| |||
0 commit comments