@voxgig/sdkgen 4.15.0 → 4.17.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/README.md +8 -0
- package/bin/voxgig-sdkgen +2 -2
- package/dist/action/action.js +2 -2
- package/dist/action/action.js.map +1 -1
- package/dist/action/check.js +9 -8
- package/dist/action/check.js.map +1 -1
- package/dist/action/dispatch.js +4 -4
- package/dist/action/dispatch.js.map +1 -1
- package/dist/action/doctor.js +16 -15
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/edition.d.ts +4 -0
- package/dist/action/{docs.js → edition.js} +57 -54
- package/dist/action/edition.js.map +1 -0
- package/dist/action/kind.d.ts +1 -2
- package/dist/action/kind.js +22 -38
- package/dist/action/kind.js.map +1 -1
- package/dist/action/package.js +17 -16
- package/dist/action/package.js.map +1 -1
- package/dist/action/resolve.d.ts +3 -1
- package/dist/action/resolve.js +29 -11
- package/dist/action/resolve.js.map +1 -1
- package/dist/admin/status.d.ts +43 -0
- package/dist/admin/status.js +161 -0
- package/dist/admin/status.js.map +1 -0
- package/dist/cmp/Test.js +11 -0
- package/dist/cmp/Test.js.map +1 -1
- package/dist/helpers/kindCollection.d.ts +1 -0
- package/dist/helpers/kindCollection.js +14 -0
- package/dist/helpers/kindCollection.js.map +1 -0
- package/dist/helpers/modelcheck.d.ts +1 -1
- package/dist/helpers/modelcheck.js +13 -3
- package/dist/helpers/modelcheck.js.map +1 -1
- package/dist/helpers/shipped.js +2 -3
- package/dist/helpers/shipped.js.map +1 -1
- package/dist/helpers/testPolicy.d.ts +1 -1
- package/dist/helpers/testPolicy.js +6 -37
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -1
- package/dist/sdkgen.js +146 -89
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +9 -1
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aon +5 -52
- package/package.json +1 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +4 -4
- package/project/.sdk/src/cmp/go/utility_go.ts +10 -2
- package/project/.sdk/src/cmp/js/Package_js.ts +5 -1
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +11 -7
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +16 -2
- package/project/.sdk/src/cmp/js/TestLive_js.ts +32 -0
- package/project/.sdk/src/cmp/js/Test_js.ts +2 -0
- package/project/.sdk/src/cmp/js/fragment/Direct.test.fragment.js +1 -1
- package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +4 -2
- package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +30 -9
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +8 -3
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +5 -4
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
- package/project/.sdk/src/cmp/ts/Package_ts.ts +5 -1
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +5 -0
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +15 -11
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +13 -16
- package/project/.sdk/src/cmp/ts/TestLive_ts.ts +32 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
- package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +1 -0
- package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +2 -0
- package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +9 -2
- package/project/.sdk/tm/js/test/live-contract.js +183 -0
- package/project/.sdk/tm/js/test/live-entity.js +169 -0
- package/project/.sdk/tm/js/test/live-runner.js +129 -0
- package/project/.sdk/tm/js/test/live-scenarios.js +142 -0
- package/project/.sdk/tm/js/test/utility.js +84 -0
- package/project/.sdk/tm/ts/test/live-contract.ts +104 -0
- package/project/.sdk/tm/ts/test/live-entity.ts +142 -0
- package/project/.sdk/tm/ts/test/live-runner.ts +166 -0
- package/project/.sdk/tm/ts/test/live-scenarios.ts +112 -0
- package/project/.sdk/tm/ts/test/utility.ts +1 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/action.ts +2 -2
- package/src/action/check.ts +3 -2
- package/src/action/dispatch.ts +4 -4
- package/src/action/doctor.ts +10 -9
- package/src/action/{docs.ts → edition.ts} +56 -53
- package/src/action/kind.ts +12 -33
- package/src/action/package.ts +4 -3
- package/src/action/resolve.ts +26 -2
- package/src/admin/status.ts +124 -0
- package/src/cmp/Test.ts +13 -1
- package/src/helpers/kindCollection.ts +11 -0
- package/src/helpers/modelcheck.ts +10 -3
- package/src/helpers/shipped.ts +2 -3
- package/src/helpers/testPolicy.ts +7 -45
- package/src/sdkgen.ts +189 -93
- package/src/utility.ts +8 -2
- package/dist/action/docs.d.ts +0 -4
- package/dist/action/docs.js.map +0 -1
- package/dist/cmp/Docs.d.ts +0 -4
- package/dist/cmp/Docs.js +0 -98
- package/dist/cmp/Docs.js.map +0 -1
- package/dist/cmp/ExternalDocs.d.ts +0 -2
- package/dist/cmp/ExternalDocs.js +0 -43
- package/dist/cmp/ExternalDocs.js.map +0 -1
- package/src/cmp/Docs.ts +0 -125
- package/src/cmp/ExternalDocs.ts +0 -54
package/src/sdkgen.ts
CHANGED
|
@@ -24,8 +24,6 @@ import { SdkGenError, requirePath, isAuthActive, resolveAuthPrefix, isHttpBasicA
|
|
|
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 { Docs, DocsItem } from './cmp/Docs'
|
|
28
|
-
import { ExternalDocs } from './cmp/ExternalDocs'
|
|
29
27
|
|
|
30
28
|
import { KIT } from '@voxgig/apidef'
|
|
31
29
|
import { Deploy } from './cmp/Deploy'
|
|
@@ -150,7 +148,7 @@ import {
|
|
|
150
148
|
|
|
151
149
|
import { cmd_package_check } from './action/check'
|
|
152
150
|
|
|
153
|
-
import {
|
|
151
|
+
import { edition_add } from './action/edition'
|
|
154
152
|
|
|
155
153
|
// The verbs, built from the kind registry — see action/dispatch.
|
|
156
154
|
import { ACTION_MAP, actionNames, needsModel } from './action/dispatch'
|
|
@@ -181,6 +179,32 @@ type SdkGenOptions = {
|
|
|
181
179
|
}
|
|
182
180
|
|
|
183
181
|
dryrun?: boolean
|
|
182
|
+
|
|
183
|
+
// WHERE AN OUT-OF-TREE ITEM GOES, DECIDED AT GENERATE TIME RATHER THAN IN
|
|
184
|
+
// THE MODEL. Keyed by item name:
|
|
185
|
+
//
|
|
186
|
+
// external: { 'seneca-provider': { path: '../..', sdkrel: '.sdksrc/acme-sdk', enclosing: true } }
|
|
187
|
+
//
|
|
188
|
+
// `output: path` in the model is a fact about ONE developer's checkout
|
|
189
|
+
// layout, and it is committed. The same model generated from a different
|
|
190
|
+
// layout is the same model — a different INVOCATION of it, not a second
|
|
191
|
+
// truth to encode — so the second layout belongs here and not in a second
|
|
192
|
+
// committed value that the two layouts then fight over.
|
|
193
|
+
//
|
|
194
|
+
// The case that forced it: a provider repo that carries a tagged checkout
|
|
195
|
+
// of its SDK in a subfolder and regenerates itself from it. The SDK's own
|
|
196
|
+
// committed model cannot describe that, because the SDK does not know it
|
|
197
|
+
// has been cloned into someone else's repo.
|
|
198
|
+
external?: Record<string, ExternalOverride>
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
// See SdkGenOptions.external. `enclosing` is separate from `path` on
|
|
203
|
+
// purpose — see checkExternalFolders.
|
|
204
|
+
type ExternalOverride = {
|
|
205
|
+
path?: string
|
|
206
|
+
sdkrel?: string
|
|
207
|
+
enclosing?: boolean
|
|
184
208
|
}
|
|
185
209
|
|
|
186
210
|
|
|
@@ -317,12 +341,14 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
317
341
|
// so resolve it ONCE: every destination is compared against it, and a
|
|
318
342
|
// comparison between a relative and an absolute path is meaningless.
|
|
319
343
|
const root = Path.resolve(folder)
|
|
344
|
+
|
|
345
|
+
const externalOverride = resolveExternalOverride(opts, log)
|
|
320
346
|
// Snapshot the decision before preflight. In particular, do not check a
|
|
321
347
|
// missing optional destination once for safety and AGAIN before writing:
|
|
322
348
|
// if it appeared between those checks, the pass could write into content
|
|
323
349
|
// that was never ownership-validated.
|
|
324
350
|
const external: ExternalPlan[] =
|
|
325
|
-
externalItems(model, root, ['target',
|
|
351
|
+
externalItems(model, root, ['target'], externalOverride)
|
|
326
352
|
.map((ext) => ({ ...ext, skip: externalSkipReason(ext, fs) }))
|
|
327
353
|
|
|
328
354
|
// Before ANY file is written, in-tree included: a destination that turns
|
|
@@ -335,74 +361,13 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
335
361
|
|
|
336
362
|
showChanges(jopts.log, 'generate-result', jres, Path.dirname(process.cwd()))
|
|
337
363
|
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// before `docs add` did anything. A second pass costs one more changes
|
|
344
|
-
// report and makes the kind work in projects that predate it, which is
|
|
345
|
-
// the whole point of putting the destinations in packages.
|
|
346
|
-
//
|
|
347
|
-
// Items with `output: path` are excluded here and generated by the loop
|
|
348
|
-
// below, exactly as out-of-tree targets are.
|
|
349
|
-
const intreedocs = Object.keys(model?.main?.[KIT]?.docs ?? {})
|
|
350
|
-
.filter((name: string) => {
|
|
351
|
-
const item = model.main[KIT].docs[name]
|
|
352
|
-
const path = item?.output?.path
|
|
353
|
-
return false !== item?.active && (null == path || '' === path)
|
|
364
|
+
// Docgen owns editions, destinations, templates, text QA and deployment.
|
|
365
|
+
if (model?.main?.[KIT]?.doc?.active !== false && Object.values(model?.main?.[KIT]?.doc?.edition ?? {})
|
|
366
|
+
.some((item: any) => item.active !== false)) {
|
|
367
|
+
const docgenPath = require.resolve('@voxgig/docgen', {
|
|
368
|
+
paths: [Path.join(root, '.sdk')],
|
|
354
369
|
})
|
|
355
|
-
|
|
356
|
-
// AN IN-TREE DOCS ITEM AND A TARGET CANNOT SHARE A NAME.
|
|
357
|
-
//
|
|
358
|
-
// `docs` and `target` are separate namespaces — deliberately, so an item
|
|
359
|
-
// of each may be called `api` — and their `.sdk` trees are nested apart
|
|
360
|
-
// (`src/cmp/docs/<n>` vs `src/cmp/<n>`), so installing both is fine.
|
|
361
|
-
//
|
|
362
|
-
// Their GENERATED destinations are not separate. Both render into
|
|
363
|
-
// `<sdk-repo>/<name>/`, the docs pass runs second, and jostraca is
|
|
364
|
-
// last-write-wins — so a docs item named `go` would quietly overwrite the
|
|
365
|
-
// Go SDK's README, and whatever else the two have in common, leaving a
|
|
366
|
-
// corrupt SDK and a green run.
|
|
367
|
-
//
|
|
368
|
-
// Refused rather than reordered, and refused BEFORE the docs pass writes
|
|
369
|
-
// anything: this is the in-tree half of the rule `checkExternalFolders`
|
|
370
|
-
// enforces for out-of-tree destinations, and the fix is the same either
|
|
371
|
-
// way — give one of them `output: path`, or rename it.
|
|
372
|
-
const targets: any = model?.main?.[KIT]?.target ?? {}
|
|
373
|
-
|
|
374
|
-
for (const name of intreedocs) {
|
|
375
|
-
const target = targets[name]
|
|
376
|
-
|
|
377
|
-
if (null == target || false === target.active) {
|
|
378
|
-
continue
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const tpath = target.output?.path
|
|
382
|
-
|
|
383
|
-
if (null != tpath && '' !== tpath) {
|
|
384
|
-
continue
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
throw new SdkGenError(
|
|
388
|
-
'Docs item "' + name + '" and target "' + name + '" would both ' +
|
|
389
|
-
'generate into <sdk-project>/' + name + '/.\n' +
|
|
390
|
-
' They are separate kinds, so sharing a name is legal — but they ' +
|
|
391
|
-
'share one output folder, and the docs pass runs second, so it ' +
|
|
392
|
-
'would overwrite the SDK.\n' +
|
|
393
|
-
' Give one of them `output: path`, or rename it.')
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (0 < intreedocs.length) {
|
|
397
|
-
log.info({
|
|
398
|
-
point: 'generate-docs-start', docs: intreedocs,
|
|
399
|
-
note: intreedocs.join(', ')
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
const dres = await jostraca.generate(jopts, () => Docs({ model }))
|
|
403
|
-
|
|
404
|
-
showChanges(jopts.log, 'generate-docs-result', dres,
|
|
405
|
-
Path.dirname(process.cwd()))
|
|
370
|
+
await require(docgenPath).generate({ ...jopts, folder: root, model })
|
|
406
371
|
}
|
|
407
372
|
|
|
408
373
|
for (const ext of external) {
|
|
@@ -434,12 +399,7 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
434
399
|
|
|
435
400
|
const sdkrelpath = externalSdkRel(ext, root, log)
|
|
436
401
|
|
|
437
|
-
const eres =
|
|
438
|
-
await jostraca.generate(
|
|
439
|
-
{ ...jopts, folder: ext.folder },
|
|
440
|
-
() => ExternalDocs({
|
|
441
|
-
model, item: ext.target, cmpfolder: folder, sdkrelpath,
|
|
442
|
-
})) :
|
|
402
|
+
const eres =
|
|
443
403
|
await jostraca.generate(
|
|
444
404
|
{ ...jopts, folder: ext.folder },
|
|
445
405
|
() => ExternalTarget({
|
|
@@ -600,10 +560,10 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
600
560
|
|
|
601
561
|
// The third kind. sdkgen ships no docs items, so every ref here is a path
|
|
602
562
|
// into a package — see action/docs.
|
|
603
|
-
const
|
|
563
|
+
const edition = {
|
|
604
564
|
add: async (items: string[]): Promise<ActionResult> => {
|
|
605
565
|
const ctx = resolveActionContext()
|
|
606
|
-
return
|
|
566
|
+
return edition_add(items, ctx)
|
|
607
567
|
}
|
|
608
568
|
}
|
|
609
569
|
|
|
@@ -652,7 +612,7 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
652
612
|
generate,
|
|
653
613
|
action,
|
|
654
614
|
check,
|
|
655
|
-
|
|
615
|
+
edition,
|
|
656
616
|
target,
|
|
657
617
|
feature,
|
|
658
618
|
|
|
@@ -700,6 +660,11 @@ type ExternalSpec = {
|
|
|
700
660
|
target: any
|
|
701
661
|
folder: string
|
|
702
662
|
active: boolean
|
|
663
|
+
|
|
664
|
+
// The caller asked, at generate time, to write into a folder that CONTAINS
|
|
665
|
+
// the SDK project. Never read from the model — see SdkGenOptions.external
|
|
666
|
+
// and checkExternalFolders.
|
|
667
|
+
enclosing: boolean
|
|
703
668
|
}
|
|
704
669
|
|
|
705
670
|
|
|
@@ -721,31 +686,117 @@ type ExternalPlan = ExternalSpec & {
|
|
|
721
686
|
// An INACTIVE target is still listed: it must be taken out of the in-tree
|
|
722
687
|
// model (see withoutExternal) so that switching it off does not silently
|
|
723
688
|
// relocate it into `<sdk-repo>/<target>/`. The generate loop skips it.
|
|
724
|
-
//
|
|
689
|
+
// The generate-time override of where out-of-tree items are written.
|
|
690
|
+
//
|
|
691
|
+
// Two ways in, merged, the environment winning:
|
|
725
692
|
//
|
|
726
|
-
//
|
|
727
|
-
//
|
|
728
|
-
// project, unclaimed, and either empty or previously generated into — are
|
|
729
|
-
// properties of WRITING SOMEWHERE ELSE, not of being a target.
|
|
693
|
+
// opts.external the caller holds the config — a build script it owns.
|
|
694
|
+
// SDKGEN_EXTERNAL JSON, for driving a checkout the caller does NOT own.
|
|
730
695
|
//
|
|
731
|
-
// The
|
|
732
|
-
//
|
|
733
|
-
//
|
|
696
|
+
// The environment matters more than it looks. The case this exists for is a
|
|
697
|
+
// repository that carries a tagged checkout of its SDK and regenerates
|
|
698
|
+
// itself from it: the script doing that owns neither the SDK's model nor its
|
|
699
|
+
// `.sdk/build/sdkgen.js`, so any route that requires editing a file inside
|
|
700
|
+
// the checkout means patching someone else's repo on every clone — and the
|
|
701
|
+
// point of the exercise was that the clone is disposable.
|
|
702
|
+
//
|
|
703
|
+
// ONE JSON VARIABLE, not one variable per item per field. Item names carry
|
|
704
|
+
// hyphens (`seneca-provider`), so a
|
|
705
|
+
// `SDKGEN_EXTERNAL_SENECA_PROVIDER_PATH` scheme needs a name mangling with
|
|
706
|
+
// no inverse: `a-b` and `a_b` collide, and nothing can tell which was meant.
|
|
707
|
+
function resolveExternalOverride(
|
|
708
|
+
opts: SdkGenOptions, log: any,
|
|
709
|
+
): Record<string, ExternalOverride> {
|
|
710
|
+
const declared = opts.external || {}
|
|
711
|
+
const raw = process.env.SDKGEN_EXTERNAL
|
|
712
|
+
|
|
713
|
+
if (null == raw || '' === raw.trim()) {
|
|
714
|
+
return declared
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
let parsed: any
|
|
718
|
+
|
|
719
|
+
try {
|
|
720
|
+
parsed = JSON.parse(raw)
|
|
721
|
+
}
|
|
722
|
+
catch (err: any) {
|
|
723
|
+
throw new SdkGenError(
|
|
724
|
+
'SDKGEN_EXTERNAL is not valid JSON: ' + (err?.message || err) +
|
|
725
|
+
'\n Expected an object keyed by item name, for example:' +
|
|
726
|
+
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
727
|
+
'\n Got: ' + raw.slice(0, 200))
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (null == parsed || 'object' !== typeof parsed || Array.isArray(parsed)) {
|
|
731
|
+
throw new SdkGenError(
|
|
732
|
+
'SDKGEN_EXTERNAL must be a JSON OBJECT keyed by item name, for example:' +
|
|
733
|
+
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
734
|
+
'\n Got: ' + raw.slice(0, 200))
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const merged: Record<string, ExternalOverride> = { ...declared }
|
|
738
|
+
|
|
739
|
+
for (const name of Object.keys(parsed)) {
|
|
740
|
+
merged[name] = { ...(declared[name] || {}), ...(parsed[name] || {}) }
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// LOUDLY. Generation writing somewhere other than the model says is
|
|
744
|
+
// exactly the thing whose only previous trace was one INFO line naming a
|
|
745
|
+
// resolved folder, and that cost a silent green run that emitted nothing.
|
|
746
|
+
const named = Object.keys(parsed).sort()
|
|
747
|
+
log.info({
|
|
748
|
+
point: 'external-override',
|
|
749
|
+
items: named.join(','),
|
|
750
|
+
note: 'SDKGEN_EXTERNAL overrides the output of: ' + named.join(', '),
|
|
751
|
+
})
|
|
752
|
+
|
|
753
|
+
return merged
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
// SDK targets can generate into separately owned repositories. Documentation
|
|
758
|
+
// editions are confined to this SDK repository and are handled by docgen.
|
|
734
759
|
function externalItems(
|
|
735
760
|
model: any, folder: string, kinds: string[],
|
|
761
|
+
override: Record<string, ExternalOverride>,
|
|
736
762
|
): ExternalSpec[] {
|
|
737
763
|
return kinds.flatMap((kind: string) => {
|
|
738
764
|
const items = model?.main?.[KIT]?.[kind] || {}
|
|
739
765
|
|
|
740
766
|
return Object.keys(items).sort()
|
|
741
|
-
.map((name: string) =>
|
|
767
|
+
.map((name: string) => {
|
|
768
|
+
// Overrides are keyed by installed target name.
|
|
769
|
+
const ov = override[name] || {}
|
|
770
|
+
|
|
771
|
+
// A SHALLOW CLONE, so the override never writes back into the model.
|
|
772
|
+
// The in-tree pass still reads it, and `target add` still round-trips
|
|
773
|
+
// it to disk; an override is for THIS RUN. Nothing compares these by
|
|
774
|
+
// identity — withoutExternal keys by kind:name.
|
|
775
|
+
const output = { ...(items[name]?.output || {}) }
|
|
776
|
+
|
|
777
|
+
if (null != ov.path && '' !== ov.path) {
|
|
778
|
+
output.path = ov.path
|
|
779
|
+
}
|
|
780
|
+
if (null != ov.sdkrel && '' !== ov.sdkrel) {
|
|
781
|
+
output.sdkrel = ov.sdkrel
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
return { kind, name, target: { ...items[name], output }, ov }
|
|
785
|
+
})
|
|
786
|
+
// AFTER the override, so it can send an item out of tree that the
|
|
787
|
+
// model generates in tree. The machinery needs nothing else for that:
|
|
788
|
+
// withoutExternal takes it out of the in-tree pass by kind:name, and
|
|
789
|
+
// every destination guard below runs on it either way.
|
|
742
790
|
.filter((t: any) => {
|
|
743
|
-
const path = t.target
|
|
791
|
+
const path = t.target.output.path
|
|
744
792
|
return null != path && '' !== path
|
|
745
793
|
})
|
|
746
794
|
.map((t: any) => ({
|
|
747
|
-
|
|
795
|
+
kind: t.kind,
|
|
796
|
+
name: t.name,
|
|
797
|
+
target: t.target,
|
|
748
798
|
folder: Path.resolve(folder, String(t.target.output.path)),
|
|
799
|
+
enclosing: true === t.ov.enclosing,
|
|
749
800
|
active: false !== t.target.active,
|
|
750
801
|
}))
|
|
751
802
|
})
|
|
@@ -848,11 +899,31 @@ function checkExternalFolders(external: ExternalPlan[], root: string, fs: any) {
|
|
|
848
899
|
ext.name + '/.')
|
|
849
900
|
}
|
|
850
901
|
|
|
851
|
-
|
|
902
|
+
// A DESTINATION THAT CONTAINS THE PROJECT is what `..` produces, and it
|
|
903
|
+
// is refused — UNLESS the caller said at generate time that it meant it.
|
|
904
|
+
//
|
|
905
|
+
// The legitimate case is a repository that carries a tagged checkout of
|
|
906
|
+
// its SDK in a subfolder and regenerates itself from it: the SDK then
|
|
907
|
+
// sits INSIDE its own output folder, and `output: path` resolves to an
|
|
908
|
+
// ancestor. Generation writes the files its components declare and
|
|
909
|
+
// prunes nothing, so the checkout survives its own run.
|
|
910
|
+
//
|
|
911
|
+
// `enclosing` is a separate flag from `path` on purpose, and only the
|
|
912
|
+
// override can set it — never the model. Overriding a path is one
|
|
913
|
+
// decision; writing over the directory holding the project is a second,
|
|
914
|
+
// much worse thing to get wrong, and it fails silently: a typo'd `..`
|
|
915
|
+
// fabricates a package tree over an unrelated repo, overwriting its
|
|
916
|
+
// package.json, README, LICENSE and CI in place. Saying it twice is the
|
|
917
|
+
// cost of keeping the typo caught for everyone who did not ask.
|
|
918
|
+
if (folderContains(ext.folder, root) && !ext.enclosing) {
|
|
852
919
|
throw new SdkGenError(
|
|
853
920
|
'External output path contains the SDK project.\n ' + where +
|
|
854
921
|
'\n Generation would write this package over the directory holding ' +
|
|
855
|
-
'the SDK project itself.'
|
|
922
|
+
'the SDK project itself.' +
|
|
923
|
+
'\n If that is deliberate — the SDK is checked out INSIDE its own ' +
|
|
924
|
+
'output folder, and regenerates it — say so at generate time with ' +
|
|
925
|
+
'`enclosing: true` in the ' + ext.name + ' entry of SDKGEN_EXTERNAL ' +
|
|
926
|
+
'or the `external` build option. It cannot be set in the model.')
|
|
856
927
|
}
|
|
857
928
|
|
|
858
929
|
// ACROSS KINDS, not within one: `docs` and `target` are separate
|
|
@@ -876,6 +947,20 @@ function checkExternalFolders(external: ExternalPlan[], root: string, fs: any) {
|
|
|
876
947
|
|
|
877
948
|
if (true === ext.target.output.adopt) continue
|
|
878
949
|
|
|
950
|
+
// AN ENCLOSING DESTINATION ALWAYS HOLDS CONTENT: the SDK project itself
|
|
951
|
+
// is inside it, along with whatever else the repository carries. The
|
|
952
|
+
// emptiness check can therefore only ever say "yes, it has content", so
|
|
953
|
+
// it carries no information here — and requiring `output: adopt` on top
|
|
954
|
+
// of the opt-in would put the layout back in the SDK's COMMITTED model,
|
|
955
|
+
// which is the coupling the generate-time override exists to break. An
|
|
956
|
+
// SDK cloned into a repository it regenerates cannot have anticipated
|
|
957
|
+
// being cloned there.
|
|
958
|
+
//
|
|
959
|
+
// The containment check above is what guards this case, and it is
|
|
960
|
+
// stricter: it refuses unless the caller named this item and said
|
|
961
|
+
// `enclosing` for it.
|
|
962
|
+
if (ext.enclosing) continue
|
|
963
|
+
|
|
879
964
|
const entries: string[] = fs.readdirSync(ext.folder)
|
|
880
965
|
.map((entry: any) => String(entry))
|
|
881
966
|
|
|
@@ -936,6 +1021,17 @@ function externalSdkRel(ext: ExternalSpec, root: string, log: any): string {
|
|
|
936
1021
|
// earlier one is a directory ABOVE it, which nothing in the model declares.
|
|
937
1022
|
const named = derived.split('/').filter((seg) => '..' !== seg)
|
|
938
1023
|
|
|
1024
|
+
// NOT WHEN THE OUTPUT ENCLOSES THE PROJECT. There the walk back descends
|
|
1025
|
+
// rather than ascends — `.sdksrc/acme-sdk` names the subfolder holding the
|
|
1026
|
+
// checkout and then the checkout, both INSIDE the output folder and both
|
|
1027
|
+
// chosen by whoever asked for this layout. Nothing is above anything, so
|
|
1028
|
+
// the warning's complaint (directories the model does not declare) is
|
|
1029
|
+
// false, and its advice (declare `output: sdkrel`) would put one layout's
|
|
1030
|
+
// path into the other's committed model.
|
|
1031
|
+
if (ext.enclosing) {
|
|
1032
|
+
return derived
|
|
1033
|
+
}
|
|
1034
|
+
|
|
939
1035
|
if (1 < named.length) {
|
|
940
1036
|
log.warn({
|
|
941
1037
|
point: 'external-sdkrel-derived', target: ext.name, sdkrel: derived,
|
package/src/utility.ts
CHANGED
|
@@ -381,8 +381,14 @@ function withPointParts(op: any): any {
|
|
|
381
381
|
each(op, (o: any, opname: string) => {
|
|
382
382
|
out[opname] = null == o || null == o.points ? o : {
|
|
383
383
|
...o,
|
|
384
|
-
points: each(o.points).map((pt: any) =>
|
|
385
|
-
null == pt
|
|
384
|
+
points: each(o.points).map((pt: any) => {
|
|
385
|
+
if (null == pt) return pt
|
|
386
|
+
// Contracts feed test generation directly from the model. Keeping
|
|
387
|
+
// them in every runtime entity also retains entire request/response
|
|
388
|
+
// schemas in clones and debug output, exhausting large SDKs' memory.
|
|
389
|
+
const { contract, ...runtimePoint } = pt
|
|
390
|
+
return { ...runtimePoint, parts: pointParts(pt) }
|
|
391
|
+
}),
|
|
386
392
|
}
|
|
387
393
|
})
|
|
388
394
|
|
package/dist/action/docs.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ActionContext, ActionResult } from '../types';
|
|
2
|
-
declare function action_docs(args: string[], actx: ActionContext): Promise<ActionResult>;
|
|
3
|
-
declare function docs_add(docs: string[], actx: ActionContext): Promise<ActionResult>;
|
|
4
|
-
export { action_docs, docs_add, };
|
package/dist/action/docs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","s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;gBACrD,mBAAmB;SACtB,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IAED,sEAAsE;IACtE,yEAAyE;IACzE,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,2CAA2C;IAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,QAAQ,IAAI,MAAM,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/D,IAAA,qBAAY,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAC9D,OAAO,EAAE,CAAC,CAAA;QACZ,OAAM;IACR,CAAC;IAED,IAAA,iBAAM,EAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;QAC/B,IAAA,eAAI,EAAC;YACH,IAAI;YACJ,8DAA8D;YAC9D,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC/B,EAAE,OAAO,EAAE,IAAA,6BAAoB,EAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/cmp/Docs.d.ts
DELETED
package/dist/cmp/Docs.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// GENERATING A DOCS ITEM. See docs/design/sdkgen-packages.md §20.3.
|
|
3
|
-
//
|
|
4
|
-
// A docs item is dispatched by the same convention a target is —
|
|
5
|
-
// `cmp/docs/<n>/Main_<n>` — so an item's package supplies the emitter and
|
|
6
|
-
// sdkgen supplies only the call.
|
|
7
|
-
//
|
|
8
|
-
// WHY THIS IS NOT RENDERED BY THE CONSUMER'S Root.ts
|
|
9
|
-
//
|
|
10
|
-
// A project's `Root.ts` is written once, by create-sdkgen, and is never
|
|
11
|
-
// touched again (doctor has an `unwired` category precisely because of it).
|
|
12
|
-
// So a kind introduced later can reach generation in one of two ways: every
|
|
13
|
-
// existing project edits its Root, or sdkgen runs the kind's own pass. The
|
|
14
|
-
// second is what happens here — `docs add` in a project scaffolded years ago
|
|
15
|
-
// generates with no scaffold change at all, which is the whole point of
|
|
16
|
-
// putting the destinations in packages.
|
|
17
|
-
//
|
|
18
|
-
// The cost is honest and small: a second `generate()` call over the same
|
|
19
|
-
// root, so the changes report arrives in two parts.
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.DocsItem = exports.Docs = void 0;
|
|
22
|
-
exports.prepareModel = prepareModel;
|
|
23
|
-
const jostraca_1 = require("jostraca");
|
|
24
|
-
const utility_1 = require("../utility");
|
|
25
|
-
const stdrep_1 = require("../helpers/stdrep");
|
|
26
|
-
const types_1 = require("../types");
|
|
27
|
-
// The model preamble every pass performs before rendering: the case-variant
|
|
28
|
-
// name constants (`Name`, `NAME`, …) and the ProjectName replacement map that
|
|
29
|
-
// template substitution reads.
|
|
30
|
-
//
|
|
31
|
-
// Done HERE rather than relied upon, because a docs pass does NOT go through
|
|
32
|
-
// the consumer's Root — nothing else has set `ctx$.model`, and when there are
|
|
33
|
-
// out-of-tree items the Root was handed a FILTERED COPY, so the preamble it
|
|
34
|
-
// performed did not touch this object at all.
|
|
35
|
-
function prepareModel(model, ctx$) {
|
|
36
|
-
ctx$.model = model;
|
|
37
|
-
model.const = model.const || { name: model.name };
|
|
38
|
-
(0, jostraca_1.names)(model.const, model.name);
|
|
39
|
-
if (null == model.const.year) {
|
|
40
|
-
model.const.year = new Date().getFullYear();
|
|
41
|
-
}
|
|
42
|
-
(0, jostraca_1.names)(model, model.name);
|
|
43
|
-
ctx$.stdrep = ctx$.stdrep || {};
|
|
44
|
-
(0, jostraca_1.names)(ctx$.stdrep, model.Name, 'Project' + 'Name');
|
|
45
|
-
}
|
|
46
|
-
// One item: its emitter, called with the item and the shared replace map.
|
|
47
|
-
//
|
|
48
|
-
// No Folder here — WHERE it lands is the caller's business, because that is
|
|
49
|
-
// exactly what differs between the two passes: in-tree the item owns
|
|
50
|
-
// `<sdk-repo>/<name>/`, out-of-tree the destination IS the item's root.
|
|
51
|
-
const DocsItem = (0, jostraca_1.cmp)(function DocsItem(props) {
|
|
52
|
-
const { item, ctx$ } = props;
|
|
53
|
-
const log = ctx$.log;
|
|
54
|
-
const model = props.model ?? ctx$.model;
|
|
55
|
-
const stdrep = (0, stdrep_1.ensureStdrep)(ctx$);
|
|
56
|
-
// The MODEL KEY is the fallback, and it is not paranoia: `name` comes from
|
|
57
|
-
// the base schema's `name: key()`, so an item whose project has not
|
|
58
|
-
// included that schema — or whose own definition omits it — reached
|
|
59
|
-
// `require('cmp/docs/undefined/Main_undefined')`, a message naming nothing
|
|
60
|
-
// the author wrote. Seen in the first real install of a docs package.
|
|
61
|
-
const name = item.name ?? item.key$;
|
|
62
|
-
if (null == name || '' === name) {
|
|
63
|
-
throw new Error('Docs item has no name and no model key, so its component cannot be ' +
|
|
64
|
-
'located: ' + JSON.stringify(Object.keys(item ?? {})));
|
|
65
|
-
}
|
|
66
|
-
const Main_docs = (0, utility_1.requirePath)(ctx$, `cmp/docs/${name}/Main_${name}`);
|
|
67
|
-
Main_docs['Main']({ model, docs: item, stdrep });
|
|
68
|
-
log.info({
|
|
69
|
-
point: 'generate-docs', docs: name, note: 'docs:' + name
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
exports.DocsItem = DocsItem;
|
|
73
|
-
// Every IN-TREE docs item, each in its own folder.
|
|
74
|
-
//
|
|
75
|
-
// Items with `output: path` are excluded: they get their own pass rooted at
|
|
76
|
-
// that path, and rendering them here as well would ALSO write them into
|
|
77
|
-
// `<sdk-repo>/<name>/` — the same reason `withoutExternal` exists for
|
|
78
|
-
// targets.
|
|
79
|
-
const Docs = (0, jostraca_1.cmp)(function Docs(props) {
|
|
80
|
-
const { ctx$ } = props;
|
|
81
|
-
const model = props.model ?? ctx$.model;
|
|
82
|
-
prepareModel(model, ctx$);
|
|
83
|
-
const items = model?.main?.[types_1.KIT]?.docs ?? {};
|
|
84
|
-
(0, jostraca_1.each)(items, (item) => {
|
|
85
|
-
if (false === item.active) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const path = item.output?.path;
|
|
89
|
-
if (null != path && '' !== path) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const name = item.name ?? item.key$;
|
|
93
|
-
(0, jostraca_1.names)(item, name);
|
|
94
|
-
(0, jostraca_1.Folder)({ name }, () => DocsItem({ item }));
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
exports.Docs = Docs;
|
|
98
|
-
//# sourceMappingURL=Docs.js.map
|
package/dist/cmp/Docs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Docs.js","sourceRoot":"","sources":["../../src/cmp/Docs.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,EAAE;AACF,iEAAiE;AACjE,0EAA0E;AAC1E,iCAAiC;AACjC,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,wEAAwE;AACxE,wCAAwC;AACxC,EAAE;AACF,yEAAyE;AACzE,oDAAoD;;;QA0GlD,YAAY;AAxGd,uCAAmD;AAEnD,wCAAwC;AAExC,8CAAgD;AAEhD,oCAA8B;AAG9B,4EAA4E;AAC5E,8EAA8E;AAC9E,+BAA+B;AAC/B,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,8CAA8C;AAC9C,SAAS,YAAY,CAAC,KAAU,EAAE,IAAS;IACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IAElB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CA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,IAAA,iBAAM,EAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;QAIA,IAAI"}
|
package/dist/cmp/ExternalDocs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// The Root for a DOCS item that generates outside the SDK repo
|
|
3
|
-
// (`main: kit: docs: <n>: output: path`).
|
|
4
|
-
//
|
|
5
|
-
// Out of tree is the NORMAL case for a docs item, not the exception it is for
|
|
6
|
-
// a target: a documentation site usually has its own repo, and in-tree it
|
|
7
|
-
// would collide with the SDK repo's own README and CI workflows.
|
|
8
|
-
//
|
|
9
|
-
// The two facts that make this a separate `generate()` pass rather than a
|
|
10
|
-
// folder are the ones `ExternalTarget` documents at length: jostraca's
|
|
11
|
-
// `FileHandler.validName` refuses a `..` segment in a folder name (the guard
|
|
12
|
-
// that keeps generation inside the tree it was pointed at, not an oversight
|
|
13
|
-
// to route around), and the output root is `jopts.folder` PER CALL — so
|
|
14
|
-
// writing somewhere else means another call.
|
|
15
|
-
//
|
|
16
|
-
// No Folder wraps the item: the destination IS the site, so its files go at
|
|
17
|
-
// the root of the output path.
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.ExternalDocs = void 0;
|
|
20
|
-
const jostraca_1 = require("jostraca");
|
|
21
|
-
const Docs_1 = require("./Docs");
|
|
22
|
-
const ExternalDocs = (0, jostraca_1.cmp)(function ExternalDocs(props) {
|
|
23
|
-
const { model, item, cmpfolder, sdkrelpath } = props;
|
|
24
|
-
const ctx$ = props.ctx$;
|
|
25
|
-
// Components live in the PROJECT, not in the repo being written to. This
|
|
26
|
-
// pass has retargeted jostraca's output folder, which is what requirePath
|
|
27
|
-
// otherwise resolves against — see utility.resolvePath. Losing this line
|
|
28
|
-
// makes the pass look for components under the DESTINATION.
|
|
29
|
-
ctx$.cmpfolder = cmpfolder;
|
|
30
|
-
// The path from the destination back to the SDK project, for a site that
|
|
31
|
-
// sits beside the SDK in a known layout and needs to name it.
|
|
32
|
-
ctx$.sdkrelpath = sdkrelpath;
|
|
33
|
-
// The same preamble the in-tree pass performs — one definition, both
|
|
34
|
-
// callers, because a project whose ONLY docs item is out of tree must
|
|
35
|
-
// generate exactly as one with both.
|
|
36
|
-
(0, Docs_1.prepareModel)(model, ctx$);
|
|
37
|
-
(0, jostraca_1.Project)({}, () => {
|
|
38
|
-
(0, jostraca_1.names)(item, item.name ?? item.key$);
|
|
39
|
-
(0, Docs_1.DocsItem)({ item });
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
exports.ExternalDocs = ExternalDocs;
|
|
43
|
-
//# sourceMappingURL=ExternalDocs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalDocs.js","sourceRoot":"","sources":["../../src/cmp/ExternalDocs.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,0CAA0C;AAC1C,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,6CAA6C;AAC7C,EAAE;AACF,4EAA4E;AAC5E,+BAA+B;;;AAE/B,uCAA8C;AAI9C,iCAA+C;AAG/C,MAAM,YAAY,GAAG,IAAA,cAAG,EAAC,SAAS,YAAY,CAAC,KAAU;IACvD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IAEvB,yEAAyE;IACzE,0EAA0E;IAC1E,yEAAyE;IACzE,4DAA4D;IAC5D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAE1B,yEAAyE;IACzE,8DAA8D;IAC9D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAE5B,qEAAqE;IACrE,sEAAsE;IACtE,qCAAqC;IACrC,IAAA,mBAAY,EAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAEzB,IAAA,kBAAO,EAAC,EAAE,EAAE,GAAG,EAAE;QACf,IAAA,gBAAK,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;QAEnC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;QAIA,YAAY"}
|