@voxgig/sdkgen 4.45.0 → 4.47.0
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/bin/voxgig-sdkgen +1 -1
- package/dist/action/check.js +73 -4
- package/dist/action/check.js.map +1 -1
- package/dist/action/copies.js +1 -0
- package/dist/action/copies.js.map +1 -1
- package/dist/action/doctor.d.ts +26 -2
- package/dist/action/doctor.js +208 -11
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/package.d.ts +1 -1
- package/dist/action/package.js +15 -16
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +16 -4
- package/dist/action/remove.js.map +1 -1
- package/dist/action/resolve.d.ts +1 -0
- package/dist/action/resolve.js +10 -4
- package/dist/action/resolve.js.map +1 -1
- package/dist/action/target.d.ts +2 -1
- package/dist/action/target.js +50 -11
- package/dist/action/target.js.map +1 -1
- package/dist/admin/status.d.ts +7 -1
- package/dist/admin/status.js +34 -5
- package/dist/admin/status.js.map +1 -1
- package/dist/cmp/AgentGuide.js +46 -23
- package/dist/cmp/AgentGuide.js.map +1 -1
- package/dist/cmp/AgentGuideContent.d.ts +9 -7
- package/dist/cmp/AgentGuideContent.js +73 -43
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/AgentGuideFeature.js +19 -9
- package/dist/cmp/AgentGuideFeature.js.map +1 -1
- package/dist/cmp/AgentGuideTop.js +95 -49
- package/dist/cmp/AgentGuideTop.js.map +1 -1
- package/dist/cmp/Changelog.js +45 -4
- package/dist/cmp/Changelog.js.map +1 -1
- package/dist/cmp/Deploy.js +73 -35
- package/dist/cmp/Deploy.js.map +1 -1
- package/dist/cmp/Entity.js +1 -1
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/ExternalTarget.js +10 -5
- package/dist/cmp/ExternalTarget.js.map +1 -1
- package/dist/cmp/Feature.js +12 -5
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureDocs.d.ts +6 -4
- package/dist/cmp/FeatureDocs.js +14 -39
- package/dist/cmp/FeatureDocs.js.map +1 -1
- package/dist/cmp/FeatureHook.d.ts +7 -1
- package/dist/cmp/FeatureHook.js +34 -1
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/Main.js +1 -1
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/PublishWorkflow.js +89 -55
- package/dist/cmp/PublishWorkflow.js.map +1 -1
- package/dist/cmp/ReadmeErrors.js +521 -18
- package/dist/cmp/ReadmeErrors.js.map +1 -1
- package/dist/cmp/ReadmeExplanation.js +280 -44
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +16 -7
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js +4 -3
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +2 -2
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeRefFeatures.js +34 -24
- package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
- package/dist/cmp/ReadmeStation.js +12 -9
- package/dist/cmp/ReadmeStation.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +479 -382
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/cmp/ReadmeUnions.js +8 -2
- package/dist/cmp/ReadmeUnions.js.map +1 -1
- package/dist/cmp/Registered.js +1 -1
- package/dist/cmp/Registered.js.map +1 -1
- package/dist/cmp/Security.js +26 -5
- package/dist/cmp/Security.js.map +1 -1
- package/dist/cmp/Test.js +1 -1
- package/dist/cmp/Test.js.map +1 -1
- package/dist/helpers/alongside.d.ts +2 -3
- package/dist/helpers/alongside.js +16 -15
- package/dist/helpers/alongside.js.map +1 -1
- package/dist/helpers/applicability.d.ts +3 -1
- package/dist/helpers/applicability.js +40 -1
- package/dist/helpers/applicability.js.map +1 -1
- package/dist/helpers/component.js +9 -1
- package/dist/helpers/component.js.map +1 -1
- package/dist/helpers/copymerge.d.ts +3 -0
- package/dist/helpers/copymerge.js +43 -10
- package/dist/helpers/copymerge.js.map +1 -1
- package/dist/helpers/definitionPlan.js +0 -1
- package/dist/helpers/definitionPlan.js.map +1 -1
- package/dist/helpers/doccheck.d.ts +11 -0
- package/dist/helpers/doccheck.js +146 -0
- package/dist/helpers/doccheck.js.map +1 -0
- package/dist/helpers/doctext.d.ts +11 -0
- package/dist/helpers/doctext.js +85 -0
- package/dist/helpers/doctext.js.map +1 -0
- package/dist/helpers/exampleCall.d.ts +16 -0
- package/dist/helpers/exampleCall.js +334 -0
- package/dist/helpers/exampleCall.js.map +1 -0
- package/dist/helpers/exportnames.d.ts +4 -0
- package/dist/helpers/exportnames.js +35 -0
- package/dist/helpers/exportnames.js.map +1 -0
- package/dist/helpers/facts.d.ts +2 -1
- package/dist/helpers/facts.js +210 -5
- package/dist/helpers/facts.js.map +1 -1
- package/dist/helpers/flowGuard.d.ts +1 -1
- package/dist/helpers/flowGuard.js +20 -7
- package/dist/helpers/flowGuard.js.map +1 -1
- package/dist/helpers/generated.d.ts +1 -0
- package/dist/helpers/generated.js +1 -1
- package/dist/helpers/generated.js.map +1 -1
- package/dist/helpers/graphqlPoint.d.ts +2 -1
- package/dist/helpers/graphqlPoint.js +17 -0
- package/dist/helpers/graphqlPoint.js.map +1 -1
- package/dist/helpers/guardModel.d.ts +2 -0
- package/dist/helpers/guardModel.js +41 -0
- package/dist/helpers/guardModel.js.map +1 -0
- package/dist/helpers/manifest.d.ts +2 -1
- package/dist/helpers/manifest.js +16 -0
- package/dist/helpers/manifest.js.map +1 -1
- package/dist/helpers/mcpTools.d.ts +2 -1
- package/dist/helpers/mcpTools.js +8 -1
- package/dist/helpers/mcpTools.js.map +1 -1
- package/dist/helpers/modelcheck.d.ts +2 -1
- package/dist/helpers/modelcheck.js +13 -0
- package/dist/helpers/modelcheck.js.map +1 -1
- package/dist/helpers/opExample.d.ts +9 -2
- package/dist/helpers/opExample.js +22 -2
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +29 -17
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/packageMeta.d.ts +6 -4
- package/dist/helpers/packageMeta.js +88 -53
- package/dist/helpers/packageMeta.js.map +1 -1
- package/dist/helpers/placement.d.ts +15 -0
- package/dist/helpers/placement.js +76 -0
- package/dist/helpers/placement.js.map +1 -0
- package/dist/helpers/semver.d.ts +3 -1
- package/dist/helpers/semver.js +28 -0
- package/dist/helpers/semver.js.map +1 -1
- package/dist/helpers/serverVars.js +3 -2
- package/dist/helpers/serverVars.js.map +1 -1
- package/dist/helpers/shipped.d.ts +2 -1
- package/dist/helpers/shipped.js +12 -0
- package/dist/helpers/shipped.js.map +1 -1
- package/dist/helpers/sourcestring.d.ts +3 -0
- package/dist/helpers/sourcestring.js +43 -0
- package/dist/helpers/sourcestring.js.map +1 -0
- package/dist/helpers/stdrep.d.ts +1 -1
- package/dist/helpers/stdrep.js +5 -1
- package/dist/helpers/stdrep.js.map +1 -1
- package/dist/helpers/surface.d.ts +7 -0
- package/dist/helpers/surface.js +69 -0
- package/dist/helpers/surface.js.map +1 -0
- package/dist/helpers/targetguard.d.ts +13 -0
- package/dist/helpers/targetguard.js +65 -0
- package/dist/helpers/targetguard.js.map +1 -0
- package/dist/helpers/text.d.ts +3 -1
- package/dist/helpers/text.js +16 -0
- package/dist/helpers/text.js.map +1 -1
- package/dist/helpers/textguard.d.ts +31 -0
- package/dist/helpers/textguard.js +157 -0
- package/dist/helpers/textguard.js.map +1 -0
- package/dist/helpers/title.d.ts +4 -0
- package/dist/helpers/title.js +52 -0
- package/dist/helpers/title.js.map +1 -0
- package/dist/sdkgen.d.ts +4 -6
- package/dist/sdkgen.js +72 -63
- package/dist/sdkgen.js.map +1 -1
- package/dist/testkit.d.ts +7 -2
- package/dist/testkit.js +27 -20
- package/dist/testkit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +2 -1
- package/dist/utility.js.map +1 -1
- package/model/fact.aontu +150 -0
- package/model/sdkgen.aontu +15 -3
- package/package.json +3 -1
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
- package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +1 -1
- package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
- package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
- package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
- package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
- package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
- package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
- package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +2 -1
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
- package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/check.ts +99 -4
- package/src/action/copies.ts +2 -0
- package/src/action/doctor.ts +304 -15
- package/src/action/package.ts +11 -13
- package/src/action/remove.ts +20 -5
- package/src/action/resolve.ts +11 -4
- package/src/action/target.ts +66 -15
- package/src/admin/status.ts +25 -5
- package/src/cmp/AgentGuide.ts +52 -25
- package/src/cmp/AgentGuideContent.ts +75 -43
- package/src/cmp/AgentGuideFeature.ts +21 -10
- package/src/cmp/AgentGuideTop.ts +119 -49
- package/src/cmp/Changelog.ts +56 -5
- package/src/cmp/Deploy.ts +81 -40
- package/src/cmp/Entity.ts +1 -1
- package/src/cmp/ExternalTarget.ts +12 -6
- package/src/cmp/Feature.ts +13 -6
- package/src/cmp/FeatureDocs.ts +21 -40
- package/src/cmp/FeatureHook.ts +38 -1
- package/src/cmp/Main.ts +1 -1
- package/src/cmp/PublishWorkflow.ts +94 -60
- package/src/cmp/ReadmeErrors.ts +555 -25
- package/src/cmp/ReadmeExplanation.ts +316 -52
- package/src/cmp/ReadmeFeatures.ts +18 -8
- package/src/cmp/ReadmeIntro.ts +4 -3
- package/src/cmp/ReadmeModel.ts +2 -2
- package/src/cmp/ReadmeRefFeatures.ts +39 -27
- package/src/cmp/ReadmeStation.ts +13 -16
- package/src/cmp/ReadmeTop.ts +538 -397
- package/src/cmp/ReadmeUnions.ts +10 -2
- package/src/cmp/Registered.ts +1 -1
- package/src/cmp/Security.ts +35 -7
- package/src/cmp/Test.ts +1 -1
- package/src/helpers/alongside.ts +16 -19
- package/src/helpers/applicability.ts +44 -1
- package/src/helpers/component.ts +11 -1
- package/src/helpers/copymerge.ts +58 -10
- package/src/helpers/definitionPlan.ts +0 -1
- package/src/helpers/doccheck.ts +174 -0
- package/src/helpers/doctext.ts +115 -0
- package/src/helpers/exampleCall.ts +415 -0
- package/src/helpers/exportnames.ts +47 -0
- package/src/helpers/facts.ts +259 -5
- package/src/helpers/flowGuard.ts +22 -7
- package/src/helpers/generated.ts +3 -1
- package/src/helpers/graphqlPoint.ts +20 -1
- package/src/helpers/guardModel.ts +50 -0
- package/src/helpers/manifest.ts +19 -0
- package/src/helpers/mcpTools.ts +11 -1
- package/src/helpers/modelcheck.ts +16 -0
- package/src/helpers/opExample.ts +34 -2
- package/src/helpers/opShape.ts +29 -16
- package/src/helpers/packageMeta.ts +89 -52
- package/src/helpers/placement.ts +114 -0
- package/src/helpers/semver.ts +35 -0
- package/src/helpers/serverVars.ts +4 -2
- package/src/helpers/shipped.ts +13 -0
- package/src/helpers/sourcestring.ts +47 -0
- package/src/helpers/stdrep.ts +6 -1
- package/src/helpers/surface.ts +82 -0
- package/src/helpers/targetguard.ts +91 -0
- package/src/helpers/text.ts +22 -0
- package/src/helpers/textguard.ts +208 -0
- package/src/helpers/title.ts +59 -0
- package/src/sdkgen.ts +82 -78
- package/src/testkit.ts +42 -20
- package/src/utility.ts +2 -1
package/src/sdkgen.ts
CHANGED
|
@@ -24,6 +24,9 @@ import { SdkGenError, requirePath, isAuthActive, resolveAuthPrefix, resolveAuthI
|
|
|
24
24
|
import { Main } from './cmp/Main'
|
|
25
25
|
import { featureApplies, targetFeatures, featureTags, unknownTags, TAGS } from './helpers/applicability'
|
|
26
26
|
import { ExternalTarget } from './cmp/ExternalTarget'
|
|
27
|
+
import { readOverride, runOutput } from './helpers/placement'
|
|
28
|
+
import { refuseBrokenTargets } from './helpers/targetguard'
|
|
29
|
+
import type { ExternalOverride } from './helpers/placement'
|
|
27
30
|
|
|
28
31
|
import { KIT, resolvedSpec } from '@voxgig/apidef'
|
|
29
32
|
import { Deploy } from './cmp/Deploy'
|
|
@@ -65,7 +68,10 @@ import { getMatchEntries } from './helpers/getMatchEntries'
|
|
|
65
68
|
import { collectDeps } from './helpers/collectDeps'
|
|
66
69
|
import { guardModelNames } from './helpers/modelNames'
|
|
67
70
|
import { guardFlowSteps } from './helpers/flowGuard'
|
|
68
|
-
import {
|
|
71
|
+
import { guardModel } from './helpers/guardModel'
|
|
72
|
+
import { sourceString } from './helpers/sourcestring'
|
|
73
|
+
import { applyFacts, fact, refuseRootPlan } from './helpers/facts'
|
|
74
|
+
import { docFindings } from './helpers/doccheck'
|
|
69
75
|
import { claimedFiles, pruneGenerated } from './helpers/generated'
|
|
70
76
|
import { cmp as labelledCmp } from './helpers/component'
|
|
71
77
|
import type { DepEntry } from './helpers/collectDeps'
|
|
@@ -229,13 +235,6 @@ type SdkGenOptions = {
|
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
|
|
232
|
-
type ExternalOverride = {
|
|
233
|
-
path?: string
|
|
234
|
-
sdkrel?: string
|
|
235
|
-
enclosing?: boolean
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
238
|
const { Jostraca } = JostracaModule
|
|
240
239
|
|
|
241
240
|
|
|
@@ -321,20 +320,20 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
321
320
|
log.info({ point: 'generate-start', start, note: opts.dryrun ? '** DRY RUN **' : '' })
|
|
322
321
|
log.debug({ point: 'generate-spec', spec })
|
|
323
322
|
|
|
324
|
-
// BEFORE ANYTHING READS A NAME
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
guardModelNames(model, log)
|
|
330
|
-
warnUngeneratedOps(model, log, targetOrigins(model))
|
|
331
|
-
|
|
332
|
-
// A flow step whose call the runtime would refuse is switched off, so no
|
|
333
|
-
// generated test makes it; see helpers/flowGuard.
|
|
334
|
-
guardFlowSteps(model, log)
|
|
323
|
+
// BEFORE ANYTHING READS A NAME: the consumer's own Root.ts re-derives the
|
|
324
|
+
// names per target, so only a correction made to the model itself
|
|
325
|
+
// survives. A flow step whose call the runtime would refuse is switched
|
|
326
|
+
// off too. See helpers/modelNames and helpers/flowGuard.
|
|
327
|
+
guardModel(model, log)
|
|
335
328
|
|
|
336
329
|
applyFacts(model)
|
|
337
330
|
|
|
331
|
+
// A target that would generate an SDK broken at build or run time is a
|
|
332
|
+
// named error, so no document is gated on its state; see helpers/targetguard.
|
|
333
|
+
refuseBrokenTargets(model)
|
|
334
|
+
|
|
335
|
+
warnUngeneratedOps(model, log, targetOrigins(model))
|
|
336
|
+
|
|
338
337
|
let Root = spec.root
|
|
339
338
|
|
|
340
339
|
if (null == Root && null != config?.root) {
|
|
@@ -370,7 +369,8 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
370
369
|
// generator, so an outdated copy would otherwise be used without a word.
|
|
371
370
|
await warnCopies(root, model)
|
|
372
371
|
|
|
373
|
-
const externalOverride = resolveExternalOverride(
|
|
372
|
+
const externalOverride = resolveExternalOverride(
|
|
373
|
+
opts, log, Object.keys(model?.main?.[KIT]?.target || {}))
|
|
374
374
|
// Snapshot the decision before preflight. In particular, do not check a
|
|
375
375
|
// missing optional destination once for safety and AGAIN before writing:
|
|
376
376
|
// if it appeared between those checks, the pass could write into content
|
|
@@ -380,15 +380,25 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
380
380
|
.map((ext) => ({ ...ext, skip: externalSkipReason(ext, fs) }))
|
|
381
381
|
|
|
382
382
|
checkExternalFolders(external, root, fs)
|
|
383
|
+
refuseRootPlan(model, external.map((ext) => ext.name))
|
|
384
|
+
|
|
385
|
+
// A run override moves a target for this run only, so the committed files
|
|
386
|
+
// keep describing the declared layout: the Root keeps the target, and the
|
|
387
|
+
// components that write the target's own files skip it.
|
|
388
|
+
const declaredOut = external.filter((ext) =>
|
|
389
|
+
'' !== String(model.main[KIT][ext.kind]?.[ext.name]?.output?.path ?? ''))
|
|
390
|
+
const relocated = external.filter((ext) => !declaredOut.includes(ext)).map((ext) => ext.name)
|
|
391
|
+
warnStale(fs, log, root, external.filter((ext) => relocated.includes(ext.name)))
|
|
383
392
|
|
|
384
393
|
const tree: { root?: any } = {}
|
|
385
|
-
const jres = await jostraca.generate(jopts, keepingTree(
|
|
386
|
-
() => Root({ model: 0 ===
|
|
394
|
+
const jres = await jostraca.generate({ ...jopts, meta: { ...jopts.meta, relocated } }, keepingTree(
|
|
395
|
+
() => Root({ model: 0 === declaredOut.length ? model : withoutExternal(model, declaredOut) }), tree))
|
|
387
396
|
|
|
388
397
|
showChanges(jopts.log, 'generate-result', jres, Path.dirname(process.cwd()))
|
|
398
|
+
checkDocs(tree.root, folder)
|
|
389
399
|
pruneGenerated({
|
|
390
400
|
fs, log, project: root, out: root, jres, claims: claimedFiles(tree.root, folder),
|
|
391
|
-
dryrun: !!opts.dryrun,
|
|
401
|
+
dryrun: !!opts.dryrun, keep: relocated.map((name: string) => name + '/'),
|
|
392
402
|
})
|
|
393
403
|
|
|
394
404
|
// Docgen owns editions, destinations, templates, text QA and deployment.
|
|
@@ -404,7 +414,7 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
404
414
|
const gone = false === ext.target.output?.create && !fs.existsSync(ext.folder)
|
|
405
415
|
|
|
406
416
|
if (null != ext.skip || gone) {
|
|
407
|
-
log.info({
|
|
417
|
+
log[ext.active ? 'warn' : 'info']({
|
|
408
418
|
point: 'generate-external-skip', target: ext.name, folder: ext.folder,
|
|
409
419
|
note: ext.skip ?? (ext.name + ' output folder disappeared after ' +
|
|
410
420
|
'preflight and output.create=false, not generated')
|
|
@@ -433,6 +443,7 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
433
443
|
}), etree))
|
|
434
444
|
|
|
435
445
|
showChanges(jopts.log, 'generate-result', eres, Path.dirname(process.cwd()))
|
|
446
|
+
checkDocs(etree.root, ext.folder)
|
|
436
447
|
pruneGenerated({
|
|
437
448
|
fs, log, project: root, out: ext.folder, jres: eres,
|
|
438
449
|
claims: claimedFiles(etree.root, ext.folder),
|
|
@@ -446,6 +457,15 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
446
457
|
}
|
|
447
458
|
|
|
448
459
|
|
|
460
|
+
// A warning, never a failure: the text that breaks a link or a table may be
|
|
461
|
+
// the spec's, which the project cannot edit.
|
|
462
|
+
function checkDocs(tree: any, out: string) {
|
|
463
|
+
for (const f of docFindings(tree, out, (path: string) => fs.existsSync(path), !!opts.dryrun)) {
|
|
464
|
+
log.warn({ point: f.point, file: f.file, line: f.line, note: f.note })
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
|
|
449
469
|
// A warning, never a failure: a difference may be a deliberate edit, and a
|
|
450
470
|
// check that cannot run must not stop a build.
|
|
451
471
|
async function warnCopies(root: string, model: any) {
|
|
@@ -557,6 +577,10 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
557
577
|
|
|
558
578
|
model.const = projectConst(model)
|
|
559
579
|
|
|
580
|
+
// The model a generate prepares, without the notices, which belong to it.
|
|
581
|
+
guardModel(model)
|
|
582
|
+
applyFacts(model)
|
|
583
|
+
|
|
560
584
|
return {
|
|
561
585
|
model,
|
|
562
586
|
url: path,
|
|
@@ -694,52 +718,22 @@ type ExternalPlan = ExternalSpec & {
|
|
|
694
718
|
|
|
695
719
|
|
|
696
720
|
function resolveExternalOverride(
|
|
697
|
-
opts: SdkGenOptions, log: any,
|
|
721
|
+
opts: SdkGenOptions, log: any, targets: string[],
|
|
698
722
|
): Record<string, ExternalOverride> {
|
|
699
|
-
const
|
|
700
|
-
const raw = process.env.SDKGEN_EXTERNAL
|
|
701
|
-
|
|
702
|
-
if (null == raw || '' === raw.trim()) {
|
|
703
|
-
return declared
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
let parsed: any
|
|
707
|
-
|
|
708
|
-
try {
|
|
709
|
-
parsed = JSON.parse(raw)
|
|
710
|
-
}
|
|
711
|
-
catch (err: any) {
|
|
712
|
-
throw new SdkGenError(
|
|
713
|
-
'SDKGEN_EXTERNAL is not valid JSON: ' + (err?.message || err) +
|
|
714
|
-
'\n Expected an object keyed by item name, for example:' +
|
|
715
|
-
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
716
|
-
'\n Got: ' + raw.slice(0, 200))
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if (null == parsed || 'object' !== typeof parsed || Array.isArray(parsed)) {
|
|
720
|
-
throw new SdkGenError(
|
|
721
|
-
'SDKGEN_EXTERNAL must be a JSON OBJECT keyed by item name, for example:' +
|
|
722
|
-
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
723
|
-
'\n Got: ' + raw.slice(0, 200))
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
const merged: Record<string, ExternalOverride> = { ...declared }
|
|
727
|
-
|
|
728
|
-
for (const name of Object.keys(parsed)) {
|
|
729
|
-
merged[name] = { ...(declared[name] || {}), ...(parsed[name] || {}) }
|
|
730
|
-
}
|
|
723
|
+
const { override, named } = readOverride(opts.external, process.env.SDKGEN_EXTERNAL, targets)
|
|
731
724
|
|
|
732
725
|
// LOUDLY. Generation writing somewhere other than the model says is
|
|
733
726
|
// exactly the thing whose only previous trace was one INFO line naming a
|
|
734
727
|
// resolved folder, and that cost a silent green run that emitted nothing.
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
728
|
+
if (0 < named.length) {
|
|
729
|
+
log.info({
|
|
730
|
+
point: 'external-override',
|
|
731
|
+
items: named.join(','),
|
|
732
|
+
note: 'SDKGEN_EXTERNAL overrides the output of: ' + named.join(', '),
|
|
733
|
+
})
|
|
734
|
+
}
|
|
741
735
|
|
|
742
|
-
return
|
|
736
|
+
return override
|
|
743
737
|
}
|
|
744
738
|
|
|
745
739
|
|
|
@@ -757,20 +751,9 @@ function externalItems(
|
|
|
757
751
|
// Overrides are keyed by installed target name.
|
|
758
752
|
const ov = override[name] || {}
|
|
759
753
|
|
|
760
|
-
// A
|
|
761
|
-
//
|
|
762
|
-
|
|
763
|
-
// identity — withoutExternal keys by kind:name.
|
|
764
|
-
const output = { ...(items[name]?.output || {}) }
|
|
765
|
-
|
|
766
|
-
if (null != ov.path && '' !== ov.path) {
|
|
767
|
-
output.path = ov.path
|
|
768
|
-
// The override relocates this run's output, root placement included.
|
|
769
|
-
delete output.root
|
|
770
|
-
}
|
|
771
|
-
if (null != ov.sdkrel && '' !== ov.sdkrel) {
|
|
772
|
-
output.sdkrel = ov.sdkrel
|
|
773
|
-
}
|
|
754
|
+
// A copy, so the override never writes back into the model: the
|
|
755
|
+
// in-tree pass still reads it, and `target add` round-trips it to disk.
|
|
756
|
+
const output = runOutput(items[name]?.output, ov)
|
|
774
757
|
|
|
775
758
|
return { kind, name, target: { ...items[name], output }, ov }
|
|
776
759
|
})
|
|
@@ -794,6 +777,21 @@ function externalItems(
|
|
|
794
777
|
}
|
|
795
778
|
|
|
796
779
|
|
|
780
|
+
// A target this run writes elsewhere leaves its earlier in-tree output as it was.
|
|
781
|
+
function warnStale(fs: any, log: any, root: string, moved: ExternalSpec[]): void {
|
|
782
|
+
for (const ext of moved) {
|
|
783
|
+
const folder = Path.join(root, ext.name)
|
|
784
|
+
if (fs.existsSync(folder)) {
|
|
785
|
+
log.warn({
|
|
786
|
+
point: 'generate-external-stale', target: ext.name, folder,
|
|
787
|
+
note: ext.name + '/ holds an earlier in-tree generation, and this run writes ' +
|
|
788
|
+
ext.name + ' to ' + ext.folder + ': the in-tree copy is left as it was, and is stale'
|
|
789
|
+
})
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
|
|
797
795
|
function externalSkipReason(ext: ExternalSpec, fs: any): string | null {
|
|
798
796
|
if (!ext.active) {
|
|
799
797
|
return ext.name + ' inactive, not generated'
|
|
@@ -960,6 +958,10 @@ function withoutExternal(
|
|
|
960
958
|
kit[kind] = kept
|
|
961
959
|
}
|
|
962
960
|
|
|
961
|
+
if (Array.isArray(kit.fact?.active)) {
|
|
962
|
+
kit.fact = { ...kit.fact, active: kit.fact.active.filter((name: string) => !drop.has('target:' + name)) }
|
|
963
|
+
}
|
|
964
|
+
|
|
963
965
|
return {
|
|
964
966
|
...model,
|
|
965
967
|
main: { ...model.main, [KIT]: kit },
|
|
@@ -1193,6 +1195,8 @@ export {
|
|
|
1193
1195
|
entityCollection,
|
|
1194
1196
|
guardModelNames,
|
|
1195
1197
|
guardFlowSteps,
|
|
1198
|
+
guardModel,
|
|
1199
|
+
sourceString,
|
|
1196
1200
|
applyFacts,
|
|
1197
1201
|
fact,
|
|
1198
1202
|
projectConst,
|
package/src/testkit.ts
CHANGED
|
@@ -14,6 +14,11 @@ import { ACTION_MAP } from './action/dispatch'
|
|
|
14
14
|
|
|
15
15
|
import { KIT } from './types'
|
|
16
16
|
|
|
17
|
+
import type { ExternalOverride } from './helpers/placement'
|
|
18
|
+
|
|
19
|
+
import { textGuard } from './helpers/textguard'
|
|
20
|
+
import type { TextFinding, TextGuardOptions } from './helpers/textguard'
|
|
21
|
+
|
|
17
22
|
|
|
18
23
|
// This package's own root — `<...>/node_modules/@voxgig/sdkgen` for a
|
|
19
24
|
// consumer, or the checkout when sdkgen tests itself. Computed from this
|
|
@@ -394,9 +399,17 @@ type GenerateOptions = {
|
|
|
394
399
|
|
|
395
400
|
root?: any
|
|
396
401
|
|
|
402
|
+
// The root documents (README, AGENTS.md, LICENSE and the rest), written as
|
|
403
|
+
// the standard Root writes them when the model's top phase is on. Off by
|
|
404
|
+
// default, so a package's suite sees only its targets' files.
|
|
405
|
+
top?: boolean
|
|
406
|
+
|
|
397
407
|
allowPlaceholder?: (path: string, token: string) => boolean
|
|
398
408
|
|
|
399
409
|
outside?: string[]
|
|
410
|
+
|
|
411
|
+
// Generate's `external` option: SDKGEN_EXTERNAL for this call alone.
|
|
412
|
+
external?: Record<string, ExternalOverride>
|
|
400
413
|
}
|
|
401
414
|
|
|
402
415
|
|
|
@@ -439,6 +452,7 @@ async function generateInto(
|
|
|
439
452
|
folder: consumer.root,
|
|
440
453
|
root: '',
|
|
441
454
|
pino: consumer.log,
|
|
455
|
+
external: opts.external,
|
|
442
456
|
})
|
|
443
457
|
|
|
444
458
|
const prevcwd = process.cwd()
|
|
@@ -448,7 +462,7 @@ async function generateInto(
|
|
|
448
462
|
try {
|
|
449
463
|
res = await sdkgen.generate({
|
|
450
464
|
model: opts.model,
|
|
451
|
-
root: opts.root ?? defaultRoot(),
|
|
465
|
+
root: opts.root ?? defaultRoot({ top: opts.top }),
|
|
452
466
|
})
|
|
453
467
|
}
|
|
454
468
|
finally {
|
|
@@ -562,10 +576,11 @@ function layeredFs(mem: any): any {
|
|
|
562
576
|
}
|
|
563
577
|
|
|
564
578
|
|
|
565
|
-
function defaultRoot(): any {
|
|
579
|
+
function defaultRoot(opts: { top?: boolean } = {}): any {
|
|
566
580
|
const { cmp, each, names, Project, Folder } = require('jostraca')
|
|
567
581
|
const {
|
|
568
|
-
Main, Entity, Feature, Test, Readme, AgentGuide,
|
|
582
|
+
Main, Entity, Feature, Test, Readme, AgentGuide, fact,
|
|
583
|
+
ReadmeTop, AgentGuideTop, License, Security, Changelog, Deploy, PublishWorkflow,
|
|
569
584
|
} = require('./sdkgen')
|
|
570
585
|
|
|
571
586
|
return cmp(function Root(props: any) {
|
|
@@ -580,27 +595,31 @@ function defaultRoot(): any {
|
|
|
580
595
|
ctx$.stdrep = ctx$.stdrep || {}
|
|
581
596
|
names(ctx$.stdrep, model.Name, 'Project' + 'Name')
|
|
582
597
|
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
const
|
|
598
|
+
const kit = model.main[KIT]
|
|
599
|
+
const target = kit.target || {}
|
|
600
|
+
const feature = kit.feature || {}
|
|
601
|
+
const entity = kit.entity || {}
|
|
586
602
|
|
|
587
603
|
const active = each(target).filter((t: any) => t && false !== t.active)
|
|
588
604
|
|
|
589
|
-
const atRoot = active.filter((t: any) => true === t.output?.root)
|
|
590
|
-
if (1 < atRoot.length) {
|
|
591
|
-
throw new SdkGenError('Only one target can be generated at the ' +
|
|
592
|
-
'project root: ' + atRoot.map((t: any) => t.name).join(', '))
|
|
593
|
-
}
|
|
594
|
-
|
|
595
605
|
Project({}, () => {
|
|
606
|
+
if (true === opts.top && fact(kit, 'top')) {
|
|
607
|
+
ReadmeTop({})
|
|
608
|
+
AgentGuideTop({})
|
|
609
|
+
License({})
|
|
610
|
+
Security({})
|
|
611
|
+
Changelog({})
|
|
612
|
+
Deploy({})
|
|
613
|
+
PublishWorkflow({})
|
|
614
|
+
}
|
|
615
|
+
|
|
596
616
|
active.map((t: any) => {
|
|
597
617
|
names(t, t.name)
|
|
598
618
|
|
|
599
|
-
const phase = t
|
|
600
|
-
const on = (n: string) => false !== (phase[n] && phase[n].active)
|
|
619
|
+
const phase = fact(t, 'phase')
|
|
601
620
|
|
|
602
621
|
const phases = () => {
|
|
603
|
-
if (
|
|
622
|
+
if (phase.entity) {
|
|
604
623
|
each(entity)
|
|
605
624
|
.filter((e: any) => e && false !== e.active)
|
|
606
625
|
.map((e: any) => {
|
|
@@ -609,7 +628,7 @@ function defaultRoot(): any {
|
|
|
609
628
|
})
|
|
610
629
|
}
|
|
611
630
|
|
|
612
|
-
if (
|
|
631
|
+
if (phase.feature) {
|
|
613
632
|
each(feature)
|
|
614
633
|
.filter((f: any) => f && f.active)
|
|
615
634
|
.map((f: any) => {
|
|
@@ -620,12 +639,12 @@ function defaultRoot(): any {
|
|
|
620
639
|
|
|
621
640
|
Main({ target: t })
|
|
622
641
|
|
|
623
|
-
if (
|
|
624
|
-
if (
|
|
625
|
-
if (
|
|
642
|
+
if (phase.readme) Readme({ target: t })
|
|
643
|
+
if (phase.agentguide) AgentGuide({ target: t })
|
|
644
|
+
if (phase.test) Test({ target: t })
|
|
626
645
|
}
|
|
627
646
|
|
|
628
|
-
if (
|
|
647
|
+
if ('root' === fact(t, 'place')) {
|
|
629
648
|
phases()
|
|
630
649
|
}
|
|
631
650
|
else {
|
|
@@ -650,6 +669,8 @@ export type {
|
|
|
650
669
|
StageOptions,
|
|
651
670
|
GenerateOptions,
|
|
652
671
|
GenerateResult,
|
|
672
|
+
TextFinding,
|
|
673
|
+
TextGuardOptions,
|
|
653
674
|
}
|
|
654
675
|
|
|
655
676
|
export {
|
|
@@ -659,4 +680,5 @@ export {
|
|
|
659
680
|
stageConsumer,
|
|
660
681
|
generateInto,
|
|
661
682
|
manifestParity,
|
|
683
|
+
textGuard,
|
|
662
684
|
}
|
package/src/utility.ts
CHANGED
|
@@ -335,7 +335,8 @@ function configDefinition(model: any, targetname?: string): { def: any, json: st
|
|
|
335
335
|
|
|
336
336
|
const authActive = isAuthActive(model)
|
|
337
337
|
const authPrefix = resolveAuthPrefix(model)
|
|
338
|
-
|
|
338
|
+
// PrepareAuth composes Basic only in the header; elsewhere nothing reads the flag.
|
|
339
|
+
const authBasic = isHttpBasicAuth(model) && 'header' === resolveAuthIn(model)
|
|
339
340
|
|
|
340
341
|
let baseUrl = ''
|
|
341
342
|
try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
|