@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/cmp/FeatureDocs.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { featureApplies } from '../helpers/applicability'
|
|
2
|
+
import { fact } from '../helpers/facts'
|
|
2
3
|
|
|
3
4
|
import { each } from 'jostraca'
|
|
4
5
|
|
|
@@ -10,9 +11,13 @@ type FeatureDoc = {
|
|
|
10
11
|
name: string
|
|
11
12
|
Name: string
|
|
12
13
|
title: string
|
|
14
|
+
titleCell: string
|
|
13
15
|
transport: string
|
|
14
16
|
wraps: boolean
|
|
15
|
-
|
|
17
|
+
on: boolean
|
|
18
|
+
// Active hooks, which a wrapping feature such as cost may also declare.
|
|
19
|
+
hooks: string[]
|
|
20
|
+
options: Array<{ name: string, code: string }>
|
|
16
21
|
|
|
17
22
|
extras: Array<{ name: string, type: string }>
|
|
18
23
|
}
|
|
@@ -23,40 +28,6 @@ function isWrapping(feat: any): boolean {
|
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
|
|
26
|
-
// A struct.validate sentinel as a reader's word for it: '`$FUNCTION`' ->
|
|
27
|
-
// 'function'. A union renders its members, so netsim's latency reads
|
|
28
|
-
// 'number | map'. Anything unrecognised renders verbatim rather than being
|
|
29
|
-
// dropped — a doc table that silently omits an option is the failure this
|
|
30
|
-
// whole path exists to fix.
|
|
31
|
-
function sentinelName(v: any): string {
|
|
32
|
-
if (Array.isArray(v)) {
|
|
33
|
-
const members = v.slice(1).map((m: any) => sentinelName(m))
|
|
34
|
-
.filter((m: string) => 'one' !== m)
|
|
35
|
-
return 0 === members.length ? 'any' : members.join(' | ')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if ('string' !== typeof v) {
|
|
39
|
-
return 'any'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const bare = v.replace(/[`$]/g, '').trim().toLowerCase()
|
|
43
|
-
return '' === bare ? 'any' : bare
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function renderValue(v: any): string {
|
|
48
|
-
if (null == v) { return '' }
|
|
49
|
-
if (Array.isArray(v)) { return '[' + v.map((x) => renderValue(x)).join(', ') + ']' }
|
|
50
|
-
if ('object' === typeof v) {
|
|
51
|
-
const keys = Object.keys(v)
|
|
52
|
-
return 0 === keys.length ? '{}' :
|
|
53
|
-
'{' + keys.map((k) => k + ': ' + renderValue(v[k])).join(', ') + '}'
|
|
54
|
-
}
|
|
55
|
-
if ('string' === typeof v) { return `'${v}'` }
|
|
56
|
-
return String(v)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
31
|
function featureDocs(model: any, target?: any): FeatureDoc[] {
|
|
61
32
|
const feature = getModelPath(model, `main.${KIT}.feature`)
|
|
62
33
|
|
|
@@ -67,20 +38,23 @@ function featureDocs(model: any, target?: any): FeatureDoc[] {
|
|
|
67
38
|
const opts = (f.config && f.config.options) || {}
|
|
68
39
|
const options = Object.keys(opts).sort().map((k) => ({
|
|
69
40
|
name: k,
|
|
70
|
-
|
|
41
|
+
code: fact(f, 'option')[k].value.codecell,
|
|
71
42
|
}))
|
|
72
43
|
|
|
73
44
|
const extra = (f.config && f.config.optspec) || {}
|
|
74
45
|
const extras = Object.keys(extra)
|
|
75
46
|
.filter((k) => null == opts[k])
|
|
76
47
|
.sort()
|
|
77
|
-
.map((k) => ({ name: k, type:
|
|
48
|
+
.map((k) => ({ name: k, type: fact(f, 'option')[k].type.cell }))
|
|
78
49
|
return {
|
|
79
50
|
name: f.name,
|
|
80
51
|
Name: f.Name || f.name,
|
|
81
|
-
title: f
|
|
52
|
+
title: fact(f, 'title').inline,
|
|
53
|
+
titleCell: fact(f, 'title').cell,
|
|
82
54
|
transport: f.transport || 'none',
|
|
83
55
|
wraps: isWrapping(f),
|
|
56
|
+
on: true === fact(f, 'on'),
|
|
57
|
+
hooks: Object.keys(f.hook || {}).filter((h: string) => true === f.hook[h]?.active).sort(),
|
|
84
58
|
options,
|
|
85
59
|
extras,
|
|
86
60
|
}
|
|
@@ -91,6 +65,14 @@ function featureDocs(model: any, target?: any): FeatureDoc[] {
|
|
|
91
65
|
|
|
92
66
|
|
|
93
67
|
|
|
68
|
+
// `a`, `a` and `b`, `a`, `b` and `c`.
|
|
69
|
+
function codeList(names: string[]): string {
|
|
70
|
+
const code = names.map((n: string) => '`' + n + '`')
|
|
71
|
+
return code.length < 2 ? code.join('') :
|
|
72
|
+
code.slice(0, -1).join(', ') + ' and ' + code[code.length - 1]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
94
76
|
const FIXED_ORDER_TARGETS = ['lean']
|
|
95
77
|
|
|
96
78
|
function honoursActivationOrder(target: any): boolean {
|
|
@@ -100,8 +82,7 @@ function honoursActivationOrder(target: any): boolean {
|
|
|
100
82
|
|
|
101
83
|
export {
|
|
102
84
|
featureDocs,
|
|
103
|
-
|
|
104
|
-
sentinelName,
|
|
85
|
+
codeList,
|
|
105
86
|
honoursActivationOrder,
|
|
106
87
|
}
|
|
107
88
|
|
package/src/cmp/FeatureHook.ts
CHANGED
|
@@ -22,6 +22,43 @@ const FeatureHook = cmp(function FeatureHook(props: any, children: any) {
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
// The stages every entity operation runs, in order; each fires its hook first.
|
|
26
|
+
const PIPELINE_STAGES: { name: string, hook: string, purpose: string }[] = [
|
|
27
|
+
{
|
|
28
|
+
name: 'Point', hook: 'PrePoint',
|
|
29
|
+
purpose: 'Resolves which API endpoint to call based on the operation name and entity configuration.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Spec', hook: 'PreSpec',
|
|
33
|
+
purpose: 'Builds the HTTP spec — URL, method, headers, body — from the resolved point and the caller\'s parameters.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Request', hook: 'PreRequest',
|
|
37
|
+
purpose: 'Sends the HTTP request. Features can intercept here to replace the transport.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Response', hook: 'PreResponse',
|
|
41
|
+
purpose: 'Parses the raw HTTP response.',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Result', hook: 'PreResult',
|
|
45
|
+
purpose: 'Extracts the business data from the parsed response.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Done', hook: 'PreDone',
|
|
49
|
+
purpose: 'Final stage before returning to the caller. Entity state (match, data) is updated here.',
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
const COUNT_WORDS = ['no', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
|
|
54
|
+
|
|
55
|
+
function pipelineLength(): string {
|
|
56
|
+
return COUNT_WORDS[PIPELINE_STAGES.length] ?? String(PIPELINE_STAGES.length)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
25
60
|
export {
|
|
26
|
-
FeatureHook
|
|
61
|
+
FeatureHook,
|
|
62
|
+
PIPELINE_STAGES,
|
|
63
|
+
pipelineLength,
|
|
27
64
|
}
|
package/src/cmp/Main.ts
CHANGED
|
@@ -18,7 +18,7 @@ const Main = cmp(function Main(props: any) {
|
|
|
18
18
|
|
|
19
19
|
// Generator-owned placeholders (PROJECTENV) that the project's frozen
|
|
20
20
|
// Root.ts cannot know about.
|
|
21
|
-
const stdrep = ensureStdrep(ctx
|
|
21
|
+
const stdrep = ensureStdrep(ctx$, target)
|
|
22
22
|
|
|
23
23
|
// Per target, as `plain` names the target's own release; each Main_<lang>
|
|
24
24
|
// copies its templates with this map before the next target sets it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright (c) 2024-2026 Voxgig Ltd, MIT License */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Content, File, Folder } from 'jostraca'
|
|
4
4
|
import { cmp } from '../helpers/component'
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
getModelPath
|
|
9
9
|
} from '../types'
|
|
10
10
|
|
|
11
|
-
import { hasPackageName, packageName, packageVersion, repoInfo } from '../helpers/packageMeta'
|
|
11
|
+
import { hasPackageName, packageName, packageVersion, registryState, releaseBranch, repoInfo } from '../helpers/packageMeta'
|
|
12
12
|
|
|
13
13
|
import { npmTrustScript } from '../admin/npm-trust'
|
|
14
|
+
import { fact } from '../helpers/facts'
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
const PublishWorkflow = cmp(function PublishWorkflow(props: any) {
|
|
@@ -23,15 +24,10 @@ const PublishWorkflow = cmp(function PublishWorkflow(props: any) {
|
|
|
23
24
|
// npm's OIDC exchange — and a PyPI or RubyGems target needs a different
|
|
24
25
|
// workflow rather than this one with a word changed. Emitting nothing for
|
|
25
26
|
// them is the honest answer until those exist.
|
|
26
|
-
const npmTargets: any[] = []
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
if ('npm' === (t.publish?.registry?.name || '') && hasPackageName(model, t.name)) {
|
|
32
|
-
npmTargets.push(t)
|
|
33
|
-
}
|
|
34
|
-
})
|
|
27
|
+
const npmTargets: any[] = fact(model.main[KIT], 'active')
|
|
28
|
+
.map((name: string) => targetMap[name])
|
|
29
|
+
.filter((t: any) => 'npm' === (t.publish?.registry?.name || '') && hasPackageName(model, t.name) &&
|
|
30
|
+
'inactive' !== registryState(model, t.name))
|
|
35
31
|
|
|
36
32
|
if (0 === npmTargets.length) {
|
|
37
33
|
return
|
|
@@ -76,25 +72,14 @@ function workflowFile(target: any): string {
|
|
|
76
72
|
}
|
|
77
73
|
|
|
78
74
|
|
|
79
|
-
function isPrimaryNpm(model: any, target: any, npmTargets: any[]): boolean {
|
|
80
|
-
if (1 === npmTargets.length) {
|
|
81
|
-
return true
|
|
82
|
-
}
|
|
83
|
-
return packageName(model, target.name) === packageName(model, 'npm')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function releaseTag(model: any, target: any, npmTargets: any[]): string {
|
|
88
|
-
return isPrimaryNpm(model, target, npmTargets) ?
|
|
89
|
-
'v$VERSION' : `${target.name}/v$VERSION`
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
75
|
function publishWorkflow(
|
|
94
76
|
model: any, target: any, npmTargets: any[], repository: string | null,
|
|
95
77
|
): string {
|
|
96
78
|
const name = target.name
|
|
97
|
-
const
|
|
79
|
+
const dir = fact(target, 'dir')
|
|
80
|
+
const tag = fact(target, 'tag') + '$VERSION'
|
|
81
|
+
const tagged = '' !== fact(target, 'tag')
|
|
82
|
+
const branch = releaseBranch(model)
|
|
98
83
|
const pkg = packageName(model, name)
|
|
99
84
|
const setup = null == repository ? '' : `
|
|
100
85
|
# .sdk/admin/setup-npm-trust.sh registers exactly this, and with --check
|
|
@@ -103,7 +88,7 @@ function publishWorkflow(
|
|
|
103
88
|
|
|
104
89
|
return `# Generated by @voxgig/sdkgen. Do not edit.
|
|
105
90
|
#
|
|
106
|
-
# Publishes ${pkg} (the \`${
|
|
91
|
+
# Publishes ${pkg} (the \`${dir}/\` target) to npm, via GitHub OIDC Trusted
|
|
107
92
|
# Publishing — no NPM_TOKEN. npm exchanges a short-lived OIDC token minted
|
|
108
93
|
# for THIS job in THIS repository for a publish credential, and attaches SLSA
|
|
109
94
|
# provenance automatically.
|
|
@@ -118,12 +103,15 @@ function publishWorkflow(
|
|
|
118
103
|
# THE FILENAME IS PART OF THAT CONFIGURATION. Renaming this file breaks
|
|
119
104
|
# publishing until the npm side is updated to match.
|
|
120
105
|
#
|
|
121
|
-
|
|
106
|
+
${'active' === registryState(model, name) ? `# BY DISPATCH, deliberately. The deploy Makefile publishes with a
|
|
122
107
|
# vault-injected token; a tag-triggered workflow racing it would publish one
|
|
123
|
-
# version by two mechanisms.
|
|
108
|
+
# version by two mechanisms.` : tagged ? `# BY DISPATCH, deliberately. While the registry is pending, the deploy
|
|
109
|
+
# Makefile only cuts the git tag, and a tag-triggered workflow would turn
|
|
110
|
+
# every tag it cuts into a publish.` : `# BY DISPATCH, deliberately. While the registry is pending, the deploy
|
|
111
|
+
# Makefile publishes nothing.`} Releasing is an act someone performs and
|
|
124
112
|
# watches.
|
|
125
113
|
#
|
|
126
|
-
# THREE JOBS, BECAUSE THEY NEED DIFFERENT PRIVILEGES. A dependency lifecycle
|
|
114
|
+
# ${tagged ? 'THREE' : 'TWO'} JOBS, BECAUSE THEY NEED DIFFERENT PRIVILEGES. A dependency lifecycle
|
|
127
115
|
# script can ask the runner for any OIDC token its job is permitted to mint,
|
|
128
116
|
# so a job that both installs dependencies and holds \`id-token: write\` can be
|
|
129
117
|
# made to publish before its own gates finish. The same reasoning keeps
|
|
@@ -132,7 +120,7 @@ function publishWorkflow(
|
|
|
132
120
|
#
|
|
133
121
|
# verify contents: read, nothing else. Installs, builds and tests.
|
|
134
122
|
# publish id-token: write. Installs no dependencies and runs no project
|
|
135
|
-
# code; it packs what is already in the tree
|
|
123
|
+
# code; it packs what is already in the tree.${tagged ? `
|
|
136
124
|
# tag contents: write. Runs git and nothing else.
|
|
137
125
|
#
|
|
138
126
|
# THE TAG IS CUT HERE BECAUSE IT CANNOT BE CUT ANYWHERE ELSE. npm binds the
|
|
@@ -141,7 +129,11 @@ function publishWorkflow(
|
|
|
141
129
|
# workflow run, so "tag, and let a tag-triggered publisher fire" does not
|
|
142
130
|
# work. A release that publishes but leaves no ref cannot be answered later:
|
|
143
131
|
# nothing in git says which tree the tarball came from, and nothing
|
|
144
|
-
# downstream can pin this SDK by tag
|
|
132
|
+
# downstream can pin this SDK by tag.` : `
|
|
133
|
+
#
|
|
134
|
+
# NO TAG IS CUT. The model switches this target's release tag off
|
|
135
|
+
# (publish.tag.active is false), so nothing in git names the tree a
|
|
136
|
+
# version was published from.`}
|
|
145
137
|
|
|
146
138
|
name: publish-${name}
|
|
147
139
|
|
|
@@ -149,7 +141,7 @@ on:
|
|
|
149
141
|
workflow_dispatch:
|
|
150
142
|
inputs:
|
|
151
143
|
expect_sha:
|
|
152
|
-
description: 'Optional: refuse unless
|
|
144
|
+
description: 'Optional: refuse unless ${branch} is still at this commit'
|
|
153
145
|
type: string
|
|
154
146
|
default: ''
|
|
155
147
|
|
|
@@ -173,40 +165,40 @@ jobs:
|
|
|
173
165
|
with:
|
|
174
166
|
node-version: 24.x
|
|
175
167
|
|
|
176
|
-
# RELEASES COME FROM
|
|
168
|
+
# RELEASES COME FROM ${branch}, INCLUDING FROM THE BUTTON. workflow_dispatch
|
|
177
169
|
# accepts any ref, so without this the Actions UI can release a branch.
|
|
178
|
-
- name: This ref is
|
|
170
|
+
- name: This ref is ${branch}, and is where the caller thinks it is
|
|
179
171
|
env:
|
|
180
172
|
EXPECT: \${{ inputs.expect_sha }}
|
|
181
173
|
run: |
|
|
182
174
|
set -euo pipefail
|
|
183
|
-
if [ "\${GITHUB_REF_NAME}" != "
|
|
184
|
-
echo "::error::releases come from
|
|
175
|
+
if [ "\${GITHUB_REF_NAME}" != "${branch}" ]; then
|
|
176
|
+
echo "::error::releases come from ${branch}, not \${GITHUB_REF_NAME}"
|
|
185
177
|
exit 1
|
|
186
178
|
fi
|
|
187
179
|
if [ -n "\$EXPECT" ] && [ "\$EXPECT" != "\$GITHUB_SHA" ]; then
|
|
188
|
-
echo "::error
|
|
180
|
+
echo "::error::${branch} is at \$GITHUB_SHA, not \$EXPECT"
|
|
189
181
|
exit 1
|
|
190
182
|
fi
|
|
191
183
|
|
|
192
184
|
- name: Resolve the version
|
|
193
185
|
id: version
|
|
194
|
-
working-directory: ${
|
|
186
|
+
working-directory: ${dir}
|
|
195
187
|
run: |
|
|
196
188
|
set -euo pipefail
|
|
197
189
|
VERSION="\$(node -p "require('./package.json').version")"
|
|
198
|
-
test -n "\$VERSION" || { echo "::error::no version in ${
|
|
190
|
+
test -n "\$VERSION" || { echo "::error::no version in ${dir}/package.json"; exit 1; }
|
|
199
191
|
echo "version=\$VERSION" >> "\$GITHUB_OUTPUT"
|
|
200
192
|
echo "${pkg} \$VERSION"
|
|
201
193
|
|
|
202
194
|
- run: npm install
|
|
203
|
-
working-directory: ${
|
|
195
|
+
working-directory: ${dir}
|
|
204
196
|
|
|
205
197
|
- run: npm run build
|
|
206
|
-
working-directory: ${
|
|
198
|
+
working-directory: ${dir}
|
|
207
199
|
|
|
208
200
|
- run: npm test
|
|
209
|
-
working-directory: ${
|
|
201
|
+
working-directory: ${dir}
|
|
210
202
|
|
|
211
203
|
publish:
|
|
212
204
|
name: npm publish
|
|
@@ -251,9 +243,15 @@ jobs:
|
|
|
251
243
|
|
|
252
244
|
- name: Publish to npm
|
|
253
245
|
if: steps.registry.outputs.published == 'false'
|
|
254
|
-
working-directory: ${
|
|
246
|
+
working-directory: ${dir}
|
|
255
247
|
run: npm publish --access public
|
|
248
|
+
` + (tagged ? tagJob(tag) : '')
|
|
249
|
+
}
|
|
256
250
|
|
|
251
|
+
|
|
252
|
+
// The job that cuts the release tag, once the package is published.
|
|
253
|
+
function tagJob(tag: string): string {
|
|
254
|
+
return `
|
|
257
255
|
# Runs git and nothing else. No install, no project code — so the
|
|
258
256
|
# repository-write credential is never in scope while third-party code runs.
|
|
259
257
|
#
|
|
@@ -307,6 +305,7 @@ jobs:
|
|
|
307
305
|
|
|
308
306
|
|
|
309
307
|
function publishingDoc(model: any, targets: any[], repository: string | null): string {
|
|
308
|
+
const branch = releaseBranch(model)
|
|
310
309
|
const pkg = packageName(model, targets[0].name)
|
|
311
310
|
const first = workflowFile(targets[0])
|
|
312
311
|
|
|
@@ -332,9 +331,11 @@ An npm with no \`npm trust\` command is bypassed for \`npx npm@latest\`.
|
|
|
332
331
|
// primary npm target owns the bare `v<version>` and every other one is
|
|
333
332
|
// prefixed, so with more than one npm target the answer differs per row.
|
|
334
333
|
const tagRows = '| target | tag |\n|---|---|\n' + targets.map((t: any) =>
|
|
335
|
-
`| \`${t.name}/\` |
|
|
336
|
-
|
|
337
|
-
'
|
|
334
|
+
`| \`${t.name}/\` | ` +
|
|
335
|
+
('' === fact(t, 'tag') ? 'none' : '`' + fact(t, 'tag') + '<version>`') +
|
|
336
|
+
' |').join('\n')
|
|
337
|
+
const untagged = targets.filter((t: any) => '' === fact(t, 'tag')).length
|
|
338
|
+
const tagged = untagged < targets.length
|
|
338
339
|
|
|
339
340
|
return `# Publishing
|
|
340
341
|
|
|
@@ -361,26 +362,27 @@ publish credential, and attaches SLSA provenance as it goes.
|
|
|
361
362
|
|
|
362
363
|
main: kit: target: ${targets[0].name}: publish: version: '<x.y.z>'
|
|
363
364
|
|
|
364
|
-
2. Commit and push to
|
|
365
|
+
2. Commit and push to \`${branch}\`, and let CI go green.
|
|
365
366
|
3. Run the workflow from the Actions tab, or:
|
|
366
367
|
|
|
367
|
-
gh workflow run ${first} --ref
|
|
368
|
+
gh workflow run ${first} --ref ${branch} -f expect_sha=$(git rev-parse HEAD)
|
|
368
369
|
|
|
369
|
-
\`expect_sha\` is optional and worth using: it refuses if \`
|
|
370
|
+
\`expect_sha\` is optional and worth using: it refuses if \`${branch}\` moved between
|
|
370
371
|
the commit you checked and the run resolving.
|
|
371
372
|
|
|
372
|
-
|
|
373
|
-
publishes, with a vault-injected token. A tag-triggered workflow racing it
|
|
374
|
-
would publish one version by two mechanisms.
|
|
373
|
+
${dispatchReason(model, targets)}
|
|
375
374
|
|
|
376
|
-
|
|
375
|
+
${tagged ? `## The release is tagged for you
|
|
377
376
|
|
|
378
377
|
The workflow cuts the git tag itself, after a successful publish, so a
|
|
379
378
|
released version always has a ref naming the tree it came from. Nothing to
|
|
380
379
|
do by hand.
|
|
381
380
|
|
|
382
381
|
${tagRows}
|
|
383
|
-
|
|
382
|
+
${0 < untagged ? `
|
|
383
|
+
A target whose tag reads none cuts no tag: its model sets
|
|
384
|
+
\`publish.tag.active: false\`, so its workflow has no tag job.
|
|
385
|
+
` : ''}
|
|
384
386
|
Re-dispatching a version that is already on the registry skips the publish
|
|
385
387
|
and still cuts a missing tag, so a partial release is finished by running it
|
|
386
388
|
again rather than repaired by hand. If the tag already exists on a DIFFERENT
|
|
@@ -391,7 +393,13 @@ which is wrong.
|
|
|
391
393
|
The tag job is the only one that may write to the repository, and it runs
|
|
392
394
|
git and nothing else. \`contents: write\` never shares a job with project
|
|
393
395
|
code, for the same reason \`id-token: write\` does not — \`checkout\` persists
|
|
394
|
-
its token into the git config for the whole job
|
|
396
|
+
its token into the git config for the whole job.` : `## No release tag
|
|
397
|
+
|
|
398
|
+
The model switches the release tag off (\`publish.tag.active: false\`), so
|
|
399
|
+
the workflow publishes without cutting a git tag, and nothing in git names
|
|
400
|
+
the tree a version came from.
|
|
401
|
+
|
|
402
|
+
${tagRows}`}
|
|
395
403
|
|
|
396
404
|
## One-time set-up
|
|
397
405
|
|
|
@@ -414,11 +422,11 @@ ${setupCheck}
|
|
|
414
422
|
trusted-publisher settings once a version exists, so the FIRST release of a
|
|
415
423
|
package goes out by hand from an authenticated machine:
|
|
416
424
|
|
|
417
|
-
cd
|
|
425
|
+
${'.' === fact(targets[0], 'dir') ? '' : 'cd ' + fact(targets[0], 'dir') + ' && '}npm publish --access public
|
|
418
426
|
|
|
419
427
|
After that, register the publisher and every later release is a dispatch.
|
|
420
428
|
|
|
421
|
-
## Why the workflow has three jobs
|
|
429
|
+
## Why the workflow has ${tagged ? 'three' : 'two'} jobs
|
|
422
430
|
|
|
423
431
|
A dependency lifecycle script can ask the runner for any OIDC token the job
|
|
424
432
|
it runs in is permitted to mint. A job that both installs dependencies and
|
|
@@ -426,18 +434,44 @@ holds \`id-token: write\` can therefore be made to publish as this package
|
|
|
426
434
|
before its own gates finish.
|
|
427
435
|
|
|
428
436
|
So \`verify\` installs, builds and tests under \`contents: read\` and holds no
|
|
429
|
-
credential
|
|
437
|
+
credential${tagged ? `; \`publish\` holds \`id-token: write\` while installing nothing and
|
|
430
438
|
running no project code; and \`tag\` holds \`contents: write\` while running
|
|
431
439
|
git and nothing else.
|
|
432
440
|
|
|
433
441
|
The tag cannot be moved out into its own workflow: npm binds the trusted
|
|
434
442
|
publisher to ONE workflow filename, so anything that must accompany a publish
|
|
435
443
|
has to live inside this file. Nor can it be left to a tag-triggered
|
|
436
|
-
publisher — a ref pushed with \`GITHUB_TOKEN\` starts no further workflow run
|
|
444
|
+
publisher — a ref pushed with \`GITHUB_TOKEN\` starts no further workflow run.` : `, and \`publish\` holds \`id-token: write\` while installing nothing and
|
|
445
|
+
running no project code.`}
|
|
437
446
|
`
|
|
438
447
|
}
|
|
439
448
|
|
|
440
449
|
|
|
450
|
+
// The root Makefile publishes an active registry and only tags a pending one,
|
|
451
|
+
// so the reason a tag trigger is wrong differs between them.
|
|
452
|
+
function dispatchReason(model: any, targets: any[]): string {
|
|
453
|
+
const states = targets.map((t: any) => registryState(model, t.name))
|
|
454
|
+
const active = states.includes('active')
|
|
455
|
+
const pending = states.some((s: string) => 'active' !== s)
|
|
456
|
+
if (active && !pending) {
|
|
457
|
+
return 'It is a DISPATCH rather than a tag push because the root `Makefile` also\n' +
|
|
458
|
+
'publishes, with a vault-injected token. A tag-triggered workflow racing it\n' +
|
|
459
|
+
'would publish one version by two mechanisms.'
|
|
460
|
+
}
|
|
461
|
+
if (!active) {
|
|
462
|
+
return 'It is a DISPATCH rather than a tag push. While the registry is pending, the\n' +
|
|
463
|
+
'root `Makefile` only cuts the git tag, and a tag-triggered workflow would\n' +
|
|
464
|
+
'turn every tag it cuts into a publish.'
|
|
465
|
+
}
|
|
466
|
+
return 'It is a DISPATCH rather than a tag push. Where a registry is active, the\n' +
|
|
467
|
+
'root `Makefile` also publishes, with a vault-injected token, and a\n' +
|
|
468
|
+
'tag-triggered workflow racing it would publish one version by two\n' +
|
|
469
|
+
'mechanisms. Where one is pending, the root `Makefile` only cuts the git\n' +
|
|
470
|
+
'tag, and a tag-triggered workflow would turn every tag it cuts into a\n' +
|
|
471
|
+
'publish.'
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
441
475
|
export {
|
|
442
476
|
PublishWorkflow
|
|
443
477
|
}
|