@voxgig/sdkgen 4.28.0 → 4.30.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 (43) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/admin/npm-trust.d.ts +39 -0
  3. package/dist/admin/npm-trust.js +308 -0
  4. package/dist/admin/npm-trust.js.map +1 -0
  5. package/dist/cmp/PublishWorkflow.js +47 -26
  6. package/dist/cmp/PublishWorkflow.js.map +1 -1
  7. package/dist/helpers/packageMeta.d.ts +2 -1
  8. package/dist/helpers/packageMeta.js +7 -3
  9. package/dist/helpers/packageMeta.js.map +1 -1
  10. package/dist/sdkgen.d.ts +3 -2
  11. package/dist/sdkgen.js +15 -4
  12. package/dist/sdkgen.js.map +1 -1
  13. package/dist/testkit.js +16 -6
  14. package/dist/testkit.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/dist/types.d.ts +1 -0
  17. package/model/sdkgen.aontu +9 -0
  18. package/package.json +3 -2
  19. package/project/.sdk/model/target/rb.aontu +1 -2
  20. package/project/.sdk/src/cmp/c/utility_c.ts +3 -1
  21. package/project/.sdk/src/cmp/cpp/ReadmeInstall_cpp.ts +3 -3
  22. package/project/.sdk/src/cmp/elixir/ReadmeInstall_elixir.ts +2 -2
  23. package/project/.sdk/src/cmp/java/Package_java.ts +2 -1
  24. package/project/.sdk/src/cmp/java/ReadmeInstall_java.ts +2 -2
  25. package/project/.sdk/src/cmp/js/Package_js.ts +2 -2
  26. package/project/.sdk/src/cmp/kotlin/Package_kotlin.ts +2 -1
  27. package/project/.sdk/src/cmp/kotlin/ReadmeInstall_kotlin.ts +2 -2
  28. package/project/.sdk/src/cmp/lua/Package_lua.ts +3 -5
  29. package/project/.sdk/src/cmp/ocaml/utility_ocaml.ts +3 -1
  30. package/project/.sdk/src/cmp/php/Package_php.ts +0 -2
  31. package/project/.sdk/src/cmp/py/Package_py.ts +0 -2
  32. package/project/.sdk/src/cmp/py-data/Main_py-data.ts +1 -3
  33. package/project/.sdk/src/cmp/rb/Package_rb.ts +15 -23
  34. package/project/.sdk/src/cmp/rust/utility_rust.ts +3 -1
  35. package/project/.sdk/src/cmp/scala/ReadmeInstall_scala.ts +2 -2
  36. package/project/.sdk/src/cmp/ts/Package_ts.ts +1 -1
  37. package/project/sdkgen-package.json +1 -1
  38. package/src/admin/npm-trust.ts +408 -0
  39. package/src/cmp/PublishWorkflow.ts +56 -26
  40. package/src/helpers/packageMeta.ts +9 -3
  41. package/src/sdkgen.ts +14 -0
  42. package/src/testkit.ts +50 -35
  43. package/src/types.ts +1 -0
@@ -4,6 +4,8 @@ import {
4
4
  walk,
5
5
  } from '@voxgig/struct'
6
6
 
7
+ import { sdkName } from '@voxgig/sdkgen'
8
+
7
9
 
8
10
  // C reserved keywords illegal as identifiers.
9
11
  const C_RESERVED = new Set<string>([
@@ -31,7 +33,7 @@ function cIdent(model: any): string {
31
33
  // Package-ish name (used in comments only), e.g. voxgig-solar-sdk.
32
34
  function cName(model: any): string {
33
35
  const org = (model.origin || 'voxgig-sdk').replace(/-sdk$/, '')
34
- return `${org}-${model.name}-sdk`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
36
+ return `${org}-${sdkName(model.name)}`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
35
37
  }
36
38
 
37
39
 
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, repoInfo } from '@voxgig/sdkgen'
2
+ import { cmp, Content, repoInfo, sdkName } from '@voxgig/sdkgen'
3
3
 
4
4
 
5
5
  const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
@@ -20,7 +20,7 @@ Releases are cut as the git tag \`${target.name}/vX.Y.Z\` (see
20
20
 
21
21
  \`\`\`bash
22
22
  # Add the SDK as a submodule (or copy the cpp/ directory into your tree).
23
- git submodule add <repo-url> third_party/${model.const.Name.toLowerCase()}-sdk
23
+ git submodule add <repo-url> third_party/${sdkName(model.const.Name.toLowerCase())}
24
24
  \`\`\`
25
25
 
26
26
  Then include the umbrella header and compile with C++17:
@@ -30,7 +30,7 @@ Then include the umbrella header and compile with C++17:
30
30
  \`\`\`
31
31
 
32
32
  \`\`\`bash
33
- g++ -std=c++17 -Ithird_party/${model.const.Name.toLowerCase()}-sdk/cpp your_app.cpp -o your_app
33
+ g++ -std=c++17 -Ithird_party/${sdkName(model.const.Name.toLowerCase())}/cpp your_app.cpp -o your_app
34
34
  \`\`\`
35
35
 
36
36
  `)
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, isPublished, repoInfo, packageVersion } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isPublished, repoInfo, packageVersion, sdkName } from '@voxgig/sdkgen'
3
3
 
4
4
 
5
5
  const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
@@ -51,7 +51,7 @@ Or from a local source checkout:
51
51
  \`\`\`elixir
52
52
  def deps do
53
53
  [
54
- {:${app}, path: "../${model.const.name.toLowerCase()}-sdk/${target.name}"}
54
+ {:${app}, path: "../${sdkName(model.const.name.toLowerCase())}/${target.name}"}
55
55
  ]
56
56
  end
57
57
  \`\`\`
@@ -5,6 +5,7 @@ import {
5
5
  cmp,
6
6
  collectDeps,
7
7
  packageVersion,
8
+ sdkName,
8
9
  } from '@voxgig/sdkgen'
9
10
 
10
11
 
@@ -28,7 +29,7 @@ const Package = cmp(async function Package(props: any) {
28
29
  const model: Model = ctx$.model
29
30
 
30
31
  const groupId = mavenGroupId(model)
31
- const artifactId = `${model.name}-sdk`
32
+ const artifactId = sdkName(model.name)
32
33
 
33
34
  // Dep name convention: "groupId:artifactId" with an explicit version.
34
35
  const deps: { groupId: string, artifactId: string, version: string, kind: string }[] = []
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, isPublished, repoInfo, packageVersion } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isPublished, repoInfo, packageVersion, sdkName } from '@voxgig/sdkgen'
3
3
 
4
4
  import { mavenGroupId } from './utility_java'
5
5
 
@@ -9,7 +9,7 @@ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
9
9
  const { model } = ctx$
10
10
 
11
11
  const groupId = mavenGroupId(model)
12
- const artifactId = `${model.name}-sdk`
12
+ const artifactId = sdkName(model.name)
13
13
 
14
14
  if (isPublished(model, target.name)) {
15
15
  Content(`Add the dependency to your \`pom.xml\`:
@@ -74,8 +74,8 @@ const Package = cmp(async function Package(props: any) {
74
74
 
75
75
  // What actually ships. Without `files`, `npm publish` packs the test
76
76
  // suite and the build scaffolding too. The js target runs from `src`
77
- // directly (no build step), so that is the whole package.
78
- files: ['src'],
77
+ // directly (no build step), so that and the README are the whole package.
78
+ files: ['src', 'README.md'],
79
79
  scripts: {
80
80
  ...(hasLiveScenarios(model) ? {
81
81
  'test:live': `${envName(model)}_TEST_LIVE=TRUE node --test test/live.test.js`,
@@ -5,6 +5,7 @@ import {
5
5
  cmp,
6
6
  collectDeps,
7
7
  packageVersion,
8
+ sdkName,
8
9
  } from '@voxgig/sdkgen'
9
10
 
10
11
 
@@ -27,7 +28,7 @@ const Package = cmp(async function Package(props: any) {
27
28
  const model: Model = ctx$.model
28
29
 
29
30
  const group = gradleGroup(model)
30
- const artifactId = `${model.name}-sdk`
31
+ const artifactId = sdkName(model.name)
31
32
 
32
33
  // Dep name convention: "group:artifact" with an explicit version.
33
34
  const deps: { group: string, artifact: string, version: string, kind: string }[] = []
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, isPublished, repoInfo, packageVersion } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isPublished, repoInfo, packageVersion, sdkName } from '@voxgig/sdkgen'
3
3
 
4
4
  import { gradleGroup } from './utility_kotlin'
5
5
 
@@ -9,7 +9,7 @@ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
9
9
  const { model } = ctx$
10
10
 
11
11
  const group = gradleGroup(model)
12
- const artifactId = `${model.name}-sdk`
12
+ const artifactId = sdkName(model.name)
13
13
 
14
14
  if (isPublished(model, target.name)) {
15
15
  Content(`Add the dependency to your \`build.gradle.kts\`:
@@ -66,10 +66,8 @@ const Package = cmp(async function Package(props: any) {
66
66
  // Rock name is namespaced to model.origin (e.g. "voxgig-sdk"). LuaRocks has
67
67
  // no real namespaces, so the parts are hyphen-joined. The Lua module name
68
68
  // (`${model.name}_sdk`) used by `require` is unchanged.
69
- const ns = model.origin || 'voxgig-sdk'
70
- const pkgBase = ns.endsWith('-sdk') ? model.name : `${model.name}-sdk`
71
69
  const rockName = packageName(model, target.name)
72
- const { repoUrl, issuesUrl } = repoInfo(model)
70
+ const { repo, repoUrl, issuesUrl } = repoInfo(model)
73
71
  const labels = keywords(model).map((k) => `"${k}"`).join(', ')
74
72
 
75
73
  // Single source for the version so the rockspec version and the source.tag
@@ -82,9 +80,9 @@ version = "${rockVersion}-1"
82
80
  source = {
83
81
  -- git+https (GitHub dropped git:// in 2022); pin the install to the release
84
82
  -- tag pushed by \`make publish\`, and point at the lua/ subdir of the monorepo.
85
- url = "git+https://github.com/${ns}/${model.name}-sdk.git",
83
+ url = "git+${repoUrl}.git",
86
84
  tag = "lua/v${rockVersion}",
87
- dir = "${model.name}-sdk/lua"
85
+ dir = "${repo}/lua"
88
86
  }
89
87
  description = {
90
88
  summary = "${pkgDescription(model, target.name)}",
@@ -4,6 +4,8 @@ import {
4
4
  walk,
5
5
  } from '@voxgig/struct'
6
6
 
7
+ import { sdkName } from '@voxgig/sdkgen'
8
+
7
9
 
8
10
  // OCaml keywords that are illegal as a lowercase identifier. sdkgen's shared
9
11
  // safeVarName has no ocaml entry, so the guard lives here.
@@ -36,7 +38,7 @@ function entityModule(name: string): string {
36
38
  // module naming: org prefix from model.origin).
37
39
  function packageName(model: any): string {
38
40
  const org = (model.origin || 'voxgig-sdk').replace(/-sdk$/, '')
39
- return `${org}-${model.name}-sdk`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
41
+ return `${org}-${sdkName(model.name)}`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
40
42
  }
41
43
 
42
44
 
@@ -31,8 +31,6 @@ const Package = cmp(async function Package(props: any) {
31
31
  // Package namespace mirrors the npm scope (model.origin, e.g. "voxgig-sdk").
32
32
  // If origin already ends in "-sdk" the slug stands alone; otherwise append
33
33
  // "-sdk" (matches the TS Package generator).
34
- const ns = model.origin || 'voxgig-sdk'
35
- const pkgBase = ns.endsWith('-sdk') ? model.name : `${model.name}-sdk`
36
34
  const { repoUrl, issuesUrl } = repoInfo(model)
37
35
  const kw = keywords(model).map((k) => `"${k}"`).join(', ')
38
36
 
@@ -22,8 +22,6 @@ const Package = cmp(async function Package(props: any) {
22
22
 
23
23
  const model: Model = ctx$.model
24
24
 
25
- const ns = model.origin || 'voxgig-sdk'
26
- const pkgBase = ns.endsWith('-sdk') ? model.name : `${model.name}-sdk`
27
25
  const distName = packageName(model, target.name)
28
26
  const { repoUrl, issuesUrl } = repoInfo(model)
29
27
  const kw = keywords(model).map((k) => `"${k}"`).join(', ')
@@ -99,9 +99,7 @@ const Package = cmp(function Package(props: any) {
99
99
  const { target, model, lower, dataModule } = props
100
100
  const ctx$ = props.ctx$
101
101
 
102
- const ns = model.origin || 'voxgig-sdk'
103
- const pkgBase = ns.endsWith('-sdk') ? model.name : `${model.name}-sdk`
104
- const distName = `${ns}-${pkgBase}-data`
102
+ const distName = packageName(model, target.name)
105
103
  // The `py` SDK this package WRAPS — a different target, so it keeps its
106
104
  // own name and does not follow this target's alias.
107
105
  const sdkDist = packageName(model, 'py')
@@ -28,32 +28,12 @@ const Package = cmp(async function Package(props: any) {
28
28
  // constant here did.
29
29
  const author = authorInfo(model, target.name)
30
30
 
31
- const ns = model.origin || 'voxgig-sdk'
32
- const pkgBase = ns.endsWith('-sdk') ? model.name : `${model.name}-sdk`
33
31
  const gemName = packageName(model, target.name)
34
32
  const { repoUrl, issuesUrl, changelogUrl } = repoInfo(model)
35
33
 
36
- const versionOf = (d: { version: string; source: 'feature' | 'target' }) =>
37
- d.source === 'target' ? (d.version || '0.0') : d.version
38
-
39
- File({ name: 'Gemfile' }, () => {
40
- Content(`source "https://rubygems.org"
41
-
42
- gemspec
43
-
44
- `)
45
-
46
- for (const d of collectDeps(model, target.name, target.deps, ctx$.log)) {
47
- Content(`gem "${d.name}", "~> ${versionOf(d)}"
48
- `)
49
- }
50
- })
51
-
52
34
  File({ name: model.const.Name + '_sdk.gemspec' }, () => {
53
- // RubyGems rejects a gemspec that declares the same runtime dependency
54
- // twice (Gem::InvalidSpecificationException at `gem build`), so the
55
- // unconstrained json fallback is only emitted when the model's own
56
- // dependency list doesn't already declare json.
35
+ // `gem build` rejects a duplicate runtime dependency, so the json
36
+ // fallback is emitted only when the model does not declare json.
57
37
  const deps = collectDeps(model, target.name, target.deps, ctx$.log)
58
38
  const hasJson = deps.some((d: any) => 'json' === d.name)
59
39
 
@@ -91,7 +71,8 @@ ${hasJson ? '' : `
91
71
  `}`)
92
72
 
93
73
  for (const d of deps) {
94
- Content(` spec.add_dependency "${d.name}", "~> ${versionOf(d)}"
74
+ const req = gemRequirement(d.version)
75
+ Content(` spec.add_dependency "${d.name}"${null == req ? '' : `, "${req}"`}
95
76
  `)
96
77
  }
97
78
 
@@ -104,6 +85,17 @@ end
104
85
  })
105
86
 
106
87
 
88
+ // `~> 0` admits only 0.x releases, so an absent, `*` or all-zero version is
89
+ // no constraint at all.
90
+ function gemRequirement(version?: string): string | null {
91
+ const v = String(version ?? '').trim()
92
+ if ('' === v || '*' === v || /^0(\.0)*$/.test(v)) {
93
+ return null
94
+ }
95
+ return /^(>=|<=|~>|!=|=|>|<)/.test(v) ? v : '~> ' + v
96
+ }
97
+
98
+
107
99
  export {
108
100
  Package
109
101
  }
@@ -4,6 +4,8 @@ import {
4
4
  walk,
5
5
  } from '@voxgig/struct'
6
6
 
7
+ import { sdkName } from '@voxgig/sdkgen'
8
+
7
9
 
8
10
  // Rust keywords (strict + reserved) that are illegal as an identifier.
9
11
  // sdkgen's shared safeVarName has no rust entry, so the guard lives here.
@@ -44,7 +46,7 @@ function rustVarName(name: string): string {
44
46
 
45
47
  function crateName(model: any): string {
46
48
  const org = (model.origin || 'voxgig-sdk').replace(/-sdk$/, '')
47
- return `${org}-${model.name}-sdk`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
49
+ return `${org}-${sdkName(model.name)}`.toLowerCase().replace(/[^a-z0-9-]/g, '-')
48
50
  }
49
51
 
50
52
 
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Content, isPublished, repoInfo, packageVersion } from '@voxgig/sdkgen'
2
+ import { cmp, Content, isPublished, repoInfo, packageVersion, sdkName } from '@voxgig/sdkgen'
3
3
 
4
4
  import { mavenGroupId } from './utility_scala'
5
5
 
@@ -9,7 +9,7 @@ const ReadmeInstall = cmp(function ReadmeInstall(props: any) {
9
9
  const { model } = ctx$
10
10
 
11
11
  const groupId = mavenGroupId(model)
12
- const artifactId = `${model.name}-sdk`
12
+ const artifactId = sdkName(model.name)
13
13
 
14
14
  if (isPublished(model, target.name)) {
15
15
  Content(`Add the dependency with scala-cli:
@@ -73,7 +73,7 @@ const Package = cmp(async function Package(props: any) {
73
73
  type: 'commonjs',
74
74
  types: `dist/${SdkName}SDK.d.ts`,
75
75
 
76
- files: ['dist', 'src'],
76
+ files: ['dist', 'src', 'README.md'],
77
77
  scripts: {
78
78
  ...(hasLiveScenarios(model) ? {
79
79
  'test:live': `npm run build && ${envName(model)}_TEST_LIVE=TRUE node --test dist-test/live.test.js`,
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.28.0",
6
+ "version": "4.30.0",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",