@voxgig/sdkgen-infrapack 0.0.4 → 0.0.6
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.
|
@@ -42,6 +42,46 @@ main: kit: target: 'seneca-provider': {
|
|
|
42
42
|
test: { active: false }
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
# HOW THIS PROVIDER DEPENDS ON THE SDK IT WRAPS.
|
|
46
|
+
#
|
|
47
|
+
# Default: the PUBLISHED package, pinned to the version the `ts` target
|
|
48
|
+
# publishes, so the two can never disagree. That is right whenever the SDK
|
|
49
|
+
# is on a registry.
|
|
50
|
+
#
|
|
51
|
+
# It is not always on one. An SDK generated for a private API, or one not
|
|
52
|
+
# published yet, leaves the provider with a dependency that cannot resolve
|
|
53
|
+
# — `npm install` fails with a 404 and the provider cannot be built, tested
|
|
54
|
+
# or released at all. `kind: 'git'` points the dependency at a GIT TAG
|
|
55
|
+
# instead, which needs no registry.
|
|
56
|
+
#
|
|
57
|
+
# A PROJECT DECISION, not an API fact, so it belongs in the project overlay
|
|
58
|
+
# (`model/project.aon`) — `target add` overwrites THIS file:
|
|
59
|
+
#
|
|
60
|
+
# main: kit: target: 'seneca-provider': sdk: dep: {
|
|
61
|
+
# kind: 'git'
|
|
62
|
+
# ref: 'v0.1.0'
|
|
63
|
+
# }
|
|
64
|
+
#
|
|
65
|
+
# `repo` defaults to the SDK's own repository, so normally only the ref is
|
|
66
|
+
# stated.
|
|
67
|
+
#
|
|
68
|
+
# `path` is the SUBDIRECTORY the SDK package sits in, because npm resolves
|
|
69
|
+
# a git dependency against the repository root and sdkgen generates the
|
|
70
|
+
# TypeScript SDK into `ts/`. It therefore defaults to `ts` — the layout
|
|
71
|
+
# this toolchain produces — and npm spells it `#<ref>::path:<path>`. Set it
|
|
72
|
+
# to `.` for an SDK whose package.json IS the repository root.
|
|
73
|
+
#
|
|
74
|
+
# `spec` states the whole dependency value outright and wins over
|
|
75
|
+
# everything, for anything the shorthand cannot express — a release-tarball
|
|
76
|
+
# URL, say.
|
|
77
|
+
sdk: dep: {
|
|
78
|
+
kind: *'npm' | 'git'
|
|
79
|
+
ref: *'' | string
|
|
80
|
+
repo: *'' | string
|
|
81
|
+
path: *'ts' | string
|
|
82
|
+
spec: *'' | string
|
|
83
|
+
}
|
|
84
|
+
|
|
45
85
|
# `kind` is a COMMA-SEPARATED LIST of manifest sections, not a single one.
|
|
46
86
|
# collectDeps deduplicates by package name and this map is keyed by name, so
|
|
47
87
|
# a package belonging in two sections cannot be declared twice — it says so
|
|
@@ -1621,8 +1621,14 @@ const Workflow = cmp(function Workflow(props: any) {
|
|
|
1621
1621
|
File({ name: 'build.yml' }, () => {
|
|
1622
1622
|
Content(`# Generated by @voxgig/sdkgen. Do not edit.
|
|
1623
1623
|
#
|
|
1624
|
-
|
|
1625
|
-
|
|
1624
|
+
${provider.sdkGit ?
|
|
1625
|
+
`# The ${provider.api} SDK is depended on by GIT TAG rather than taken from a\n` +
|
|
1626
|
+
'# registry, so `npm install` resolves the tag named in package.json and\n' +
|
|
1627
|
+
'# needs git on PATH — every GitHub runner has it. Nothing else is needed\n' +
|
|
1628
|
+
'# to build and run the offline tests on any platform.' :
|
|
1629
|
+
`# The ${provider.api} SDK is a normal published dependency, so \`npm install\`\n` +
|
|
1630
|
+
'# is all that is needed to build and run the offline tests on every\n' +
|
|
1631
|
+
'# platform.'}
|
|
1626
1632
|
${!provider.liveApp ? '' : `#
|
|
1627
1633
|
# The live tests additionally need the companion server, which is only
|
|
1628
1634
|
# distributed in the SDK's source repository (it is not published). That repo
|
|
@@ -1651,10 +1657,18 @@ jobs:
|
|
|
1651
1657
|
runs-on: \${{ matrix.os }}
|
|
1652
1658
|
|
|
1653
1659
|
steps:
|
|
1654
|
-
|
|
1660
|
+
# EVERY ACTION IS PINNED TO A SHA, with the version in a comment.
|
|
1661
|
+
#
|
|
1662
|
+
# Not a preference: an organisation can require it (the repository
|
|
1663
|
+
# setting is sha_pinning_required), and a workflow naming a TAG then
|
|
1664
|
+
# fails to START — no jobs, no logs, just a startup_failure on every
|
|
1665
|
+
# push. The senecajs org has that policy on, so this workflow never ran
|
|
1666
|
+
# once in the repository it was generated for, and weeks of red marks
|
|
1667
|
+
# said nothing about the code.
|
|
1668
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
1655
1669
|
|
|
1656
1670
|
- name: Use Node.js \${{ matrix.node-version }}
|
|
1657
|
-
uses: actions/setup-node@v7
|
|
1671
|
+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
|
|
1658
1672
|
with:
|
|
1659
1673
|
node-version: \${{ matrix.node-version }}
|
|
1660
1674
|
|
|
@@ -1757,9 +1771,9 @@ jobs:
|
|
|
1757
1771
|
contents: read
|
|
1758
1772
|
|
|
1759
1773
|
steps:
|
|
1760
|
-
- uses: actions/checkout@
|
|
1774
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
1761
1775
|
|
|
1762
|
-
- uses: actions/setup-node@
|
|
1776
|
+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
|
|
1763
1777
|
with:
|
|
1764
1778
|
node-version: 24.x
|
|
1765
1779
|
registry-url: 'https://registry.npmjs.org'
|
|
@@ -711,6 +711,11 @@ const Main = cmp(function Main(props: any) {
|
|
|
711
711
|
const provider = {
|
|
712
712
|
Name, lower, ENV, sdkClass, pluginName, fileBase,
|
|
713
713
|
sdkPkg, sdkVersion, entities,
|
|
714
|
+
// Whether the SDK dependency is a git tag rather than a registry
|
|
715
|
+
// package. The generated CI note says which, because "npm install is all
|
|
716
|
+
// you need" stops being true the moment git is in the path.
|
|
717
|
+
sdkGit: sdkDependency(model, target, { sdkVersion, sdkRepoUrl: repoInfo(model).repoUrl })
|
|
718
|
+
.startsWith('github:'),
|
|
714
719
|
repoUrl: repo.url,
|
|
715
720
|
// The SDK's own repo, for pointing at the companion test server which is
|
|
716
721
|
// only distributed in source.
|
|
@@ -772,6 +777,74 @@ const Main = cmp(function Main(props: any) {
|
|
|
772
777
|
})
|
|
773
778
|
|
|
774
779
|
|
|
780
|
+
// HOW THE PROVIDER DEPENDS ON THE SDK IT WRAPS, as one dependency value.
|
|
781
|
+
//
|
|
782
|
+
// Default: the PUBLISHED package pinned to the version the `ts` target
|
|
783
|
+
// publishes, so the two can never disagree. Right whenever the SDK is on a
|
|
784
|
+
// registry — and wrong when it is not. An SDK for a private API, or one not
|
|
785
|
+
// published yet, leaves the provider unable to `npm install` at all: the
|
|
786
|
+
// dependency 404s, so the package cannot be built, tested or released. That
|
|
787
|
+
// is not hypothetical; it is why @seneca/github-provider could not be
|
|
788
|
+
// regenerated and released for weeks.
|
|
789
|
+
//
|
|
790
|
+
// `kind: 'git'` points at a GIT TAG instead, which needs no registry.
|
|
791
|
+
//
|
|
792
|
+
// NPM RESOLVES A GIT DEPENDENCY AGAINST THE REPOSITORY ROOT, and sdkgen
|
|
793
|
+
// generates the TypeScript SDK into `ts/` — so the bare
|
|
794
|
+
// `github:owner/repo#ref` every example shows would install a directory with
|
|
795
|
+
// no package.json in it. npm spells the subdirectory `#<ref>::path:<sub>`
|
|
796
|
+
// (npm-package-arg resolves that to gitSubdir), and `path` therefore
|
|
797
|
+
// defaults to `ts` rather than to nothing: the default has to match the
|
|
798
|
+
// layout this toolchain actually produces, or the shorthand is a trap. `.`
|
|
799
|
+
// means the package IS the repository root.
|
|
800
|
+
//
|
|
801
|
+
// `spec` still wins over all of it, for anything the shorthand cannot say.
|
|
802
|
+
function sdkDependency(model: any, target: any, provider: any): string {
|
|
803
|
+
const dep = model?.main?.[KIT]?.target?.[target.name]?.sdk?.dep || {}
|
|
804
|
+
|
|
805
|
+
const spec = String(dep.spec || '').trim()
|
|
806
|
+
if ('' !== spec) {
|
|
807
|
+
return spec
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if ('git' !== String(dep.kind || 'npm')) {
|
|
811
|
+
return `^${provider.sdkVersion}`
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// `owner/repo`, from the SDK's own repository unless the project says
|
|
815
|
+
// otherwise. Accepts a full URL and reduces it, so a project can paste
|
|
816
|
+
// what its remote prints.
|
|
817
|
+
const repo = String(dep.repo || provider.sdkRepoUrl || '')
|
|
818
|
+
.replace(/^git\+/, '')
|
|
819
|
+
.replace(/^(https?:\/\/)?(www\.)?github\.com[/:]/, '')
|
|
820
|
+
.replace(/\.git$/, '')
|
|
821
|
+
.replace(/\/+$/, '')
|
|
822
|
+
|
|
823
|
+
if ('' === repo) {
|
|
824
|
+
throw new SdkGenError(
|
|
825
|
+
'seneca-provider: sdk.dep.kind is "git" but no repository is known. ' +
|
|
826
|
+
'Set `main.' + KIT + '.target.' + target.name +
|
|
827
|
+
'.sdk.dep.repo` to `owner/repo`, or state the whole dependency with ' +
|
|
828
|
+
'`sdk.dep.spec`.')
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
const ref = String(dep.ref || '').trim()
|
|
832
|
+
if ('' === ref) {
|
|
833
|
+
throw new SdkGenError(
|
|
834
|
+
'seneca-provider: sdk.dep.kind is "git" but no `ref` is set. A git ' +
|
|
835
|
+
'dependency with no ref follows the default branch, so an install ' +
|
|
836
|
+
'today and an install tomorrow can differ — name the TAG to depend ' +
|
|
837
|
+
'on, e.g. `sdk.dep.ref: "v' + provider.sdkVersion + '"`.')
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// `.` (and empty) mean the repository root, which needs no path segment.
|
|
841
|
+
const sub = String(dep.path ?? 'ts').trim().replace(/^\/+|\/+$/g, '')
|
|
842
|
+
|
|
843
|
+
return `github:${repo}#${ref}` +
|
|
844
|
+
('' === sub || '.' === sub ? '' : `::path:${sub}`)
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
|
|
775
848
|
// --- package.json -----------------------------------------------------------
|
|
776
849
|
|
|
777
850
|
const PackageJson = cmp(function PackageJson(props: any) {
|
|
@@ -872,8 +945,10 @@ const PackageJson = cmp(function PackageJson(props: any) {
|
|
|
872
945
|
files: ['dist', 'doc', 'src/**/*.ts', 'LICENSE'],
|
|
873
946
|
engines: { node: '>=24' },
|
|
874
947
|
dependencies: {
|
|
875
|
-
// The SDK this plugin wraps
|
|
876
|
-
|
|
948
|
+
// The SDK this plugin wraps. Published-and-pinned by default; a git
|
|
949
|
+
// tag when the project says so, because an unpublished SDK otherwise
|
|
950
|
+
// leaves this package unable to install at all. See sdkDependency.
|
|
951
|
+
[provider.sdkPkg]: sdkDependency(model, target, provider),
|
|
877
952
|
...dep('prod'),
|
|
878
953
|
},
|
|
879
954
|
peerDependencies: dep('peer'),
|
package/package.json
CHANGED