@voxgig/sdkgen 4.16.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.
Files changed (104) hide show
  1. package/README.md +8 -0
  2. package/bin/voxgig-sdkgen +2 -2
  3. package/dist/action/action.js +2 -2
  4. package/dist/action/action.js.map +1 -1
  5. package/dist/action/check.js +9 -8
  6. package/dist/action/check.js.map +1 -1
  7. package/dist/action/dispatch.js +4 -4
  8. package/dist/action/dispatch.js.map +1 -1
  9. package/dist/action/doctor.js +16 -15
  10. package/dist/action/doctor.js.map +1 -1
  11. package/dist/action/edition.d.ts +4 -0
  12. package/dist/action/{docs.js → edition.js} +57 -54
  13. package/dist/action/edition.js.map +1 -0
  14. package/dist/action/kind.d.ts +1 -2
  15. package/dist/action/kind.js +22 -38
  16. package/dist/action/kind.js.map +1 -1
  17. package/dist/action/package.js +17 -16
  18. package/dist/action/package.js.map +1 -1
  19. package/dist/action/resolve.d.ts +3 -1
  20. package/dist/action/resolve.js +29 -11
  21. package/dist/action/resolve.js.map +1 -1
  22. package/dist/admin/status.d.ts +43 -0
  23. package/dist/admin/status.js +161 -0
  24. package/dist/admin/status.js.map +1 -0
  25. package/dist/cmp/Test.js +11 -0
  26. package/dist/cmp/Test.js.map +1 -1
  27. package/dist/helpers/kindCollection.d.ts +1 -0
  28. package/dist/helpers/kindCollection.js +14 -0
  29. package/dist/helpers/kindCollection.js.map +1 -0
  30. package/dist/helpers/modelcheck.d.ts +1 -1
  31. package/dist/helpers/modelcheck.js +13 -3
  32. package/dist/helpers/modelcheck.js.map +1 -1
  33. package/dist/helpers/shipped.js +2 -3
  34. package/dist/helpers/shipped.js.map +1 -1
  35. package/dist/helpers/testPolicy.d.ts +1 -1
  36. package/dist/helpers/testPolicy.js +6 -37
  37. package/dist/helpers/testPolicy.js.map +1 -1
  38. package/dist/sdkgen.d.ts +1 -1
  39. package/dist/sdkgen.js +22 -89
  40. package/dist/sdkgen.js.map +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/dist/utility.js +9 -1
  43. package/dist/utility.js.map +1 -1
  44. package/model/sdkgen.aon +5 -52
  45. package/package.json +1 -1
  46. package/project/.sdk/src/cmp/go/Config_go.ts +4 -4
  47. package/project/.sdk/src/cmp/go/utility_go.ts +10 -2
  48. package/project/.sdk/src/cmp/js/Package_js.ts +5 -1
  49. package/project/.sdk/src/cmp/js/TestDirect_js.ts +11 -7
  50. package/project/.sdk/src/cmp/js/TestEntity_js.ts +16 -2
  51. package/project/.sdk/src/cmp/js/TestLive_js.ts +32 -0
  52. package/project/.sdk/src/cmp/js/Test_js.ts +2 -0
  53. package/project/.sdk/src/cmp/js/fragment/Direct.test.fragment.js +1 -1
  54. package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +4 -2
  55. package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +30 -9
  56. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +8 -3
  57. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +5 -4
  58. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
  59. package/project/.sdk/src/cmp/ts/Package_ts.ts +5 -1
  60. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +5 -0
  61. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +15 -11
  62. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +13 -16
  63. package/project/.sdk/src/cmp/ts/TestLive_ts.ts +32 -0
  64. package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
  65. package/project/.sdk/src/cmp/ts/fragment/Direct.test.fragment.ts +1 -0
  66. package/project/.sdk/src/cmp/ts/fragment/Entity.test.fragment.ts +2 -0
  67. package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +9 -2
  68. package/project/.sdk/tm/js/test/live-contract.js +183 -0
  69. package/project/.sdk/tm/js/test/live-entity.js +169 -0
  70. package/project/.sdk/tm/js/test/live-runner.js +129 -0
  71. package/project/.sdk/tm/js/test/live-scenarios.js +142 -0
  72. package/project/.sdk/tm/js/test/utility.js +84 -0
  73. package/project/.sdk/tm/ts/test/live-contract.ts +104 -0
  74. package/project/.sdk/tm/ts/test/live-entity.ts +142 -0
  75. package/project/.sdk/tm/ts/test/live-runner.ts +166 -0
  76. package/project/.sdk/tm/ts/test/live-scenarios.ts +112 -0
  77. package/project/.sdk/tm/ts/test/utility.ts +1 -2
  78. package/project/sdkgen-package.json +1 -1
  79. package/src/action/action.ts +2 -2
  80. package/src/action/check.ts +3 -2
  81. package/src/action/dispatch.ts +4 -4
  82. package/src/action/doctor.ts +10 -9
  83. package/src/action/{docs.ts → edition.ts} +56 -53
  84. package/src/action/kind.ts +12 -33
  85. package/src/action/package.ts +4 -3
  86. package/src/action/resolve.ts +26 -2
  87. package/src/admin/status.ts +124 -0
  88. package/src/cmp/Test.ts +13 -1
  89. package/src/helpers/kindCollection.ts +11 -0
  90. package/src/helpers/modelcheck.ts +10 -3
  91. package/src/helpers/shipped.ts +2 -3
  92. package/src/helpers/testPolicy.ts +7 -45
  93. package/src/sdkgen.ts +15 -94
  94. package/src/utility.ts +8 -2
  95. package/dist/action/docs.d.ts +0 -4
  96. package/dist/action/docs.js.map +0 -1
  97. package/dist/cmp/Docs.d.ts +0 -4
  98. package/dist/cmp/Docs.js +0 -98
  99. package/dist/cmp/Docs.js.map +0 -1
  100. package/dist/cmp/ExternalDocs.d.ts +0 -2
  101. package/dist/cmp/ExternalDocs.js +0 -43
  102. package/dist/cmp/ExternalDocs.js.map +0 -1
  103. package/src/cmp/Docs.ts +0 -125
  104. package/src/cmp/ExternalDocs.ts +0 -54
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
@@ -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;AACj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AAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAEzB,MAAM,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,WAAG,CAAC,EAAE,IAAI,IAAI,EAAE,CAAA;IAE5C,IAAA,eAAI,EAAC,KAAK,EAAE,CAAC,IAAS,EAAE,EAAE;QACxB,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,OAAM;QACR,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAA;QAE9B,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAChC,OAAM;QACR,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAEnC,IAAA,gBAAK,EAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAEjB,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"}
@@ -1,2 +0,0 @@
1
- declare const ExternalDocs: import("jostraca").Component;
2
- export { ExternalDocs };
@@ -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"}
package/src/cmp/Docs.ts DELETED
@@ -1,125 +0,0 @@
1
- // GENERATING A DOCS ITEM. See docs/design/sdkgen-packages.md §20.3.
2
- //
3
- // A docs item is dispatched by the same convention a target is —
4
- // `cmp/docs/<n>/Main_<n>` — so an item's package supplies the emitter and
5
- // sdkgen supplies only the call.
6
- //
7
- // WHY THIS IS NOT RENDERED BY THE CONSUMER'S Root.ts
8
- //
9
- // A project's `Root.ts` is written once, by create-sdkgen, and is never
10
- // touched again (doctor has an `unwired` category precisely because of it).
11
- // So a kind introduced later can reach generation in one of two ways: every
12
- // existing project edits its Root, or sdkgen runs the kind's own pass. The
13
- // second is what happens here — `docs add` in a project scaffolded years ago
14
- // generates with no scaffold change at all, which is the whole point of
15
- // putting the destinations in packages.
16
- //
17
- // The cost is honest and small: a second `generate()` call over the same
18
- // root, so the changes report arrives in two parts.
19
-
20
- import { cmp, each, names, Folder } from 'jostraca'
21
-
22
- import { requirePath } from '../utility'
23
-
24
- import { ensureStdrep } from '../helpers/stdrep'
25
-
26
- import { KIT } from '../types'
27
-
28
-
29
- // The model preamble every pass performs before rendering: the case-variant
30
- // name constants (`Name`, `NAME`, …) and the ProjectName replacement map that
31
- // template substitution reads.
32
- //
33
- // Done HERE rather than relied upon, because a docs pass does NOT go through
34
- // the consumer's Root — nothing else has set `ctx$.model`, and when there are
35
- // out-of-tree items the Root was handed a FILTERED COPY, so the preamble it
36
- // performed did not touch this object at all.
37
- function prepareModel(model: any, ctx$: any) {
38
- ctx$.model = model
39
-
40
- model.const = model.const || { name: model.name }
41
- names(model.const, model.name)
42
- if (null == model.const.year) {
43
- model.const.year = new Date().getFullYear()
44
- }
45
- names(model, model.name)
46
-
47
- ctx$.stdrep = ctx$.stdrep || {}
48
- names(ctx$.stdrep, model.Name, 'Project' + 'Name')
49
- }
50
-
51
-
52
- // One item: its emitter, called with the item and the shared replace map.
53
- //
54
- // No Folder here — WHERE it lands is the caller's business, because that is
55
- // exactly what differs between the two passes: in-tree the item owns
56
- // `<sdk-repo>/<name>/`, out-of-tree the destination IS the item's root.
57
- const DocsItem = cmp(function DocsItem(props: any) {
58
- const { item, ctx$ } = props
59
- const log = ctx$.log
60
- const model = props.model ?? ctx$.model
61
-
62
- const stdrep = ensureStdrep(ctx$)
63
-
64
- // The MODEL KEY is the fallback, and it is not paranoia: `name` comes from
65
- // the base schema's `name: key()`, so an item whose project has not
66
- // included that schema — or whose own definition omits it — reached
67
- // `require('cmp/docs/undefined/Main_undefined')`, a message naming nothing
68
- // the author wrote. Seen in the first real install of a docs package.
69
- const name = item.name ?? item.key$
70
-
71
- if (null == name || '' === name) {
72
- throw new Error(
73
- 'Docs item has no name and no model key, so its component cannot be ' +
74
- 'located: ' + JSON.stringify(Object.keys(item ?? {})))
75
- }
76
-
77
- const Main_docs = requirePath(ctx$, `cmp/docs/${name}/Main_${name}`)
78
-
79
- Main_docs['Main']({ model, docs: item, stdrep })
80
-
81
- log.info({
82
- point: 'generate-docs', docs: name, note: 'docs:' + name
83
- })
84
- })
85
-
86
-
87
- // Every IN-TREE docs item, each in its own folder.
88
- //
89
- // Items with `output: path` are excluded: they get their own pass rooted at
90
- // that path, and rendering them here as well would ALSO write them into
91
- // `<sdk-repo>/<name>/` — the same reason `withoutExternal` exists for
92
- // targets.
93
- const Docs = cmp(function Docs(props: any) {
94
- const { ctx$ } = props
95
- const model = props.model ?? ctx$.model
96
-
97
- prepareModel(model, ctx$)
98
-
99
- const items = model?.main?.[KIT]?.docs ?? {}
100
-
101
- each(items, (item: any) => {
102
- if (false === item.active) {
103
- return
104
- }
105
-
106
- const path = item.output?.path
107
-
108
- if (null != path && '' !== path) {
109
- return
110
- }
111
-
112
- const name = item.name ?? item.key$
113
-
114
- names(item, name)
115
-
116
- Folder({ name }, () => DocsItem({ item }))
117
- })
118
- })
119
-
120
-
121
- export {
122
- Docs,
123
- DocsItem,
124
- prepareModel,
125
- }
@@ -1,54 +0,0 @@
1
- // The Root for a DOCS item that generates outside the SDK repo
2
- // (`main: kit: docs: <n>: output: path`).
3
- //
4
- // Out of tree is the NORMAL case for a docs item, not the exception it is for
5
- // a target: a documentation site usually has its own repo, and in-tree it
6
- // would collide with the SDK repo's own README and CI workflows.
7
- //
8
- // The two facts that make this a separate `generate()` pass rather than a
9
- // folder are the ones `ExternalTarget` documents at length: jostraca's
10
- // `FileHandler.validName` refuses a `..` segment in a folder name (the guard
11
- // that keeps generation inside the tree it was pointed at, not an oversight
12
- // to route around), and the output root is `jopts.folder` PER CALL — so
13
- // writing somewhere else means another call.
14
- //
15
- // No Folder wraps the item: the destination IS the site, so its files go at
16
- // the root of the output path.
17
-
18
- import { cmp, names, Project } from 'jostraca'
19
-
20
- import { KIT } from '../types'
21
-
22
- import { DocsItem, prepareModel } from './Docs'
23
-
24
-
25
- const ExternalDocs = cmp(function ExternalDocs(props: any) {
26
- const { model, item, cmpfolder, sdkrelpath } = props
27
- const ctx$ = props.ctx$
28
-
29
- // Components live in the PROJECT, not in the repo being written to. This
30
- // pass has retargeted jostraca's output folder, which is what requirePath
31
- // otherwise resolves against — see utility.resolvePath. Losing this line
32
- // makes the pass look for components under the DESTINATION.
33
- ctx$.cmpfolder = cmpfolder
34
-
35
- // The path from the destination back to the SDK project, for a site that
36
- // sits beside the SDK in a known layout and needs to name it.
37
- ctx$.sdkrelpath = sdkrelpath
38
-
39
- // The same preamble the in-tree pass performs — one definition, both
40
- // callers, because a project whose ONLY docs item is out of tree must
41
- // generate exactly as one with both.
42
- prepareModel(model, ctx$)
43
-
44
- Project({}, () => {
45
- names(item, item.name ?? item.key$)
46
-
47
- DocsItem({ item })
48
- })
49
- })
50
-
51
-
52
- export {
53
- ExternalDocs
54
- }