@voxgig/sdkgen 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/target.js +100 -0
- package/dist/action/target.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/c/Config_c.ts +1 -1
- package/project/.sdk/src/cmp/c/utility_c.ts +57 -6
- package/project/.sdk/src/cmp/clojure/Config_clojure.ts +1 -1
- package/project/.sdk/src/cmp/clojure/utility_clojure.ts +57 -6
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +1 -1
- package/project/.sdk/src/cmp/cpp/utility_cpp.ts +57 -6
- package/project/.sdk/src/cmp/csharp/Config_csharp.ts +1 -1
- package/project/.sdk/src/cmp/csharp/utility_csharp.ts +57 -6
- package/project/.sdk/src/cmp/dart/Config_dart.ts +1 -1
- package/project/.sdk/src/cmp/dart/utility_dart.ts +57 -6
- package/project/.sdk/src/cmp/elixir/Config_elixir.ts +1 -1
- package/project/.sdk/src/cmp/elixir/utility_elixir.ts +57 -6
- package/project/.sdk/src/cmp/go/Config_go.ts +1 -1
- package/project/.sdk/src/cmp/go/utility_go.ts +57 -6
- package/project/.sdk/src/cmp/haskell/Config_haskell.ts +1 -1
- package/project/.sdk/src/cmp/haskell/utility_haskell.ts +57 -6
- package/project/.sdk/src/cmp/java/Config_java.ts +1 -1
- package/project/.sdk/src/cmp/java/utility_java.ts +57 -6
- package/project/.sdk/src/cmp/js/Config_js.ts +1 -1
- package/project/.sdk/src/cmp/js/utility_js.ts +57 -6
- package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +1 -1
- package/project/.sdk/src/cmp/kotlin/utility_kotlin.ts +57 -6
- package/project/.sdk/src/cmp/lean/Config_lean.ts +1 -1
- package/project/.sdk/src/cmp/lean/utility_lean.ts +57 -6
- package/project/.sdk/src/cmp/lua/Config_lua.ts +1 -1
- package/project/.sdk/src/cmp/lua/utility_lua.ts +57 -6
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +1 -1
- package/project/.sdk/src/cmp/ocaml/utility_ocaml.ts +57 -6
- package/project/.sdk/src/cmp/perl/Config_perl.ts +1 -1
- package/project/.sdk/src/cmp/perl/utility_perl.ts +57 -6
- package/project/.sdk/src/cmp/php/Config_php.ts +1 -1
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +22 -0
- package/project/.sdk/src/cmp/php/utility_php.ts +57 -6
- package/project/.sdk/src/cmp/py/Config_py.ts +1 -1
- package/project/.sdk/src/cmp/py/utility_py.ts +57 -6
- package/project/.sdk/src/cmp/rb/Config_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/utility_rb.ts +57 -6
- package/project/.sdk/src/cmp/rust/Config_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/utility_rust.ts +57 -6
- package/project/.sdk/src/cmp/scala/Config_scala.ts +1 -1
- package/project/.sdk/src/cmp/scala/utility_scala.ts +57 -6
- package/project/.sdk/src/cmp/swift/Config_swift.ts +1 -1
- package/project/.sdk/src/cmp/swift/utility_swift.ts +57 -6
- package/project/.sdk/src/cmp/ts/Config_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/utility_ts.ts +57 -6
- package/project/.sdk/src/cmp/zig/Config_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/utility_zig.ts +57 -6
- package/project/.sdk/tm/c/core/point.c +2 -1
- package/project/.sdk/tm/csharp/core/Point.cs +3 -1
- package/project/.sdk/tm/dart/lib/Point.dart +2 -1
- package/project/.sdk/tm/java/core/Point.java +3 -1
- package/project/.sdk/tm/js/src/Point.js +3 -1
- package/project/.sdk/tm/kotlin/core/Point.kt +3 -1
- package/project/.sdk/tm/scala/core/Point.scala +2 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Point.swift +3 -1
- package/project/.sdk/tm/ts/src/Point.ts +3 -1
- package/project/.sdk/tm/zig/core/point.zig +2 -1
- package/src/action/target.ts +115 -0
|
@@ -30,7 +30,9 @@ class Point {
|
|
|
30
30
|
this.parts = getprop(altmap, 'parts', [])
|
|
31
31
|
this.params = getprop(altmap, 'params', [])
|
|
32
32
|
this.select = getprop(altmap, 'select')
|
|
33
|
-
|
|
33
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default
|
|
34
|
+
// (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
35
|
+
this.active = getprop(altmap, 'active', true)
|
|
34
36
|
this.relations = getprop(altmap, 'relations', [])
|
|
35
37
|
this.alias = getprop(altmap, 'alias', {})
|
|
36
38
|
this.transform = getprop(altmap, 'transform', { req: undefined, res: undefined })
|
|
@@ -12,7 +12,8 @@ pub const Point = struct {
|
|
|
12
12
|
parts: Value,
|
|
13
13
|
params: Value,
|
|
14
14
|
select: Value,
|
|
15
|
-
active:
|
|
15
|
+
// Absent in config means ACTIVE: emission drops `active: true` as a default (sdkgen L0), so only an explicit `active: false` turns a point off.
|
|
16
|
+
active: bool = true,
|
|
16
17
|
relations: Value,
|
|
17
18
|
alias: Value,
|
|
18
19
|
transform: Value,
|
package/src/action/target.ts
CHANGED
|
@@ -207,6 +207,22 @@ const TargetRoot = cmp(function TargetRoot(props: any) {
|
|
|
207
207
|
// language puts feature source somewhere different.
|
|
208
208
|
const trim = trimFeatures(ctx$, tfolder, torigname, tname, features)
|
|
209
209
|
|
|
210
|
+
// Copy only ADDS and overwrites — it never removes, and it never even
|
|
211
|
+
// looks at a file the trim excludes. So a template that this SDK should
|
|
212
|
+
// NOT have lived on at whatever revision it was first copied at, and
|
|
213
|
+
// kept being generated from.
|
|
214
|
+
//
|
|
215
|
+
// That is how 30 cedar repos ended up with tm/go/test/feature_test.go
|
|
216
|
+
// still declaring the nine fh* harness helpers after upstream moved them
|
|
217
|
+
// into feature_harness_test.go: feature_test.go is feature-source, so it
|
|
218
|
+
// is trimmed for an SDK without those features, so Copy skipped it, so
|
|
219
|
+
// the pre-move revision survived every `target add go` those repos ever
|
|
220
|
+
// ran. Generation then emitted it alongside the new harness and the go
|
|
221
|
+
// package failed to compile — "fhHasFeature redeclared in this block".
|
|
222
|
+
//
|
|
223
|
+
// The invariant this restores: tm/<target> == source tree MINUS trim.
|
|
224
|
+
pruneStaleTemplates(ctx$, tfolder + '/tm/' + torigname, 'tm/' + tname, trim)
|
|
225
|
+
|
|
210
226
|
Folder({ name: 'tm/' + tname }, () => {
|
|
211
227
|
Copy({
|
|
212
228
|
from: tfolder + '/tm/' + torigname,
|
|
@@ -234,6 +250,105 @@ const TargetRoot = cmp(function TargetRoot(props: any) {
|
|
|
234
250
|
// read. Trimming a target whose templates are not ready for it produces a
|
|
235
251
|
// project that does not build, so an unreadable declaration must fail safe
|
|
236
252
|
// rather than fail tidy.
|
|
253
|
+
// Bring the consumer's `tm/<target>` back to the invariant that Copy alone
|
|
254
|
+
// cannot maintain: it must contain EXACTLY the source tree minus the files
|
|
255
|
+
// this SDK's feature set trims away.
|
|
256
|
+
//
|
|
257
|
+
// Copy adds and overwrites. It does not remove, and it does not touch an
|
|
258
|
+
// excluded file at all — so both of these persist silently forever:
|
|
259
|
+
//
|
|
260
|
+
// - a template the toolchain has RETIRED (absent from the source tree);
|
|
261
|
+
// - a template this SDK should not have (present in source, but trimmed),
|
|
262
|
+
// frozen at whatever revision it was first copied at.
|
|
263
|
+
//
|
|
264
|
+
// The second is the one that bit: tm/go/test/feature_test.go is feature
|
|
265
|
+
// source, so it is trimmed for an SDK without those features, so it was never
|
|
266
|
+
// refreshed after upstream moved the fh* harness helpers out of it.
|
|
267
|
+
//
|
|
268
|
+
// tm/ is toolchain-owned — the scaffold rewrites it on every add-target, and
|
|
269
|
+
// model/guide/guide.aontu is the one file a user owns (merged separately by
|
|
270
|
+
// create-sdkgen) — so removing what the toolchain says should not be there is
|
|
271
|
+
// consistent with how the rest of that tree is already treated.
|
|
272
|
+
function pruneStaleTemplates(
|
|
273
|
+
ctx$: any,
|
|
274
|
+
fromDir: string,
|
|
275
|
+
toRel: string,
|
|
276
|
+
trim: RegExp[],
|
|
277
|
+
) {
|
|
278
|
+
const { log } = ctx$
|
|
279
|
+
const fs = ctx$.fs()
|
|
280
|
+
const folder = ctx$.folder ?? '.'
|
|
281
|
+
const destDir = Path.join(folder, toRel)
|
|
282
|
+
|
|
283
|
+
const listRel = (root: string): string[] => {
|
|
284
|
+
const out: string[] = []
|
|
285
|
+
const walk = (dir: string, rel: string) => {
|
|
286
|
+
let entries: any[]
|
|
287
|
+
try {
|
|
288
|
+
entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
289
|
+
}
|
|
290
|
+
catch (e: any) {
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
for (const ent of entries) {
|
|
294
|
+
const child = Path.join(dir, ent.name)
|
|
295
|
+
const childRel = '' === rel ? ent.name : rel + '/' + ent.name
|
|
296
|
+
if (ent.isDirectory()) {
|
|
297
|
+
walk(child, childRel)
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
out.push(childRel)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
walk(root, '')
|
|
305
|
+
return out
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const sourceFiles = listRel(fromDir)
|
|
309
|
+
|
|
310
|
+
// An unreadable source tree must not be read as "everything is stale" — that
|
|
311
|
+
// would empty the destination.
|
|
312
|
+
if (0 === sourceFiles.length) {
|
|
313
|
+
return
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// What SHOULD be present: source, minus anything the trim excludes. The trim
|
|
317
|
+
// patterns are matched against the source-relative path, the same way Copy
|
|
318
|
+
// applies them.
|
|
319
|
+
const trimmed = (rel: string) => trim.some((re) => re.test(rel))
|
|
320
|
+
const want = new Set(sourceFiles.filter((rel) => !trimmed(rel)))
|
|
321
|
+
|
|
322
|
+
const stale = listRel(destDir).filter((rel) => !want.has(rel))
|
|
323
|
+
if (0 === stale.length) {
|
|
324
|
+
return
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const removed: string[] = []
|
|
328
|
+
for (const rel of stale) {
|
|
329
|
+
try {
|
|
330
|
+
fs.unlinkSync(Path.join(destDir, rel))
|
|
331
|
+
removed.push(rel)
|
|
332
|
+
}
|
|
333
|
+
catch (e: any) {
|
|
334
|
+
log.warn({
|
|
335
|
+
point: 'target-template-prune', target: toRel, file: rel,
|
|
336
|
+
note: 'could not remove stale template ' + rel + ': ' + e.message
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (0 < removed.length) {
|
|
342
|
+
log.info({
|
|
343
|
+
point: 'target-template-prune', target: toRel, count: removed.length,
|
|
344
|
+
files: removed,
|
|
345
|
+
note: toRel + ': removed ' + removed.length +
|
|
346
|
+
' stale template(s) the toolchain no longer provides for this SDK'
|
|
347
|
+
})
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
237
352
|
function trimFeatures(
|
|
238
353
|
ctx$: any,
|
|
239
354
|
tfolder: string,
|