@voxgig/create-sdkgen 0.15.0 → 0.16.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/dist/project/standard/CreateRoot.js +0 -1
- package/dist/project/standard/CreateRoot.js.map +1 -1
- package/package.json +13 -7
- package/project/standard/.github/workflows/ci.yml +135 -0
- package/project/standard/.sdk/model/sdk.fragment.jsonic +2 -2
- package/project/standard/.sdk/src/BuildSDK.ts +28 -4
- package/project/standard/.sdk/src/Root.ts +38 -11
- package/project/standard/.sdk/src/Top.ts +6 -0
- package/project/standard/.sdk/src/tsconfig.json +7 -0
- package/src/project/standard/CreateRoot.ts +0 -2
- package/src/tsconfig.json +6 -0
- package/bin/create-sdkgen~ +0 -261
- package/project/standard/.env.local +0 -1
|
@@ -77,7 +77,6 @@ const CreateRoot = (0, jostraca_1.cmp)(function CreateRoot(props) {
|
|
|
77
77
|
(0, jostraca_1.Copy)({ from: origdef, to: projdef });
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
console.log('DEF NOT FOUND: ', origdef);
|
|
81
80
|
(0, jostraca_1.File)({ name: projdef }, () => {
|
|
82
81
|
(0, jostraca_1.Content)('# OpenAPI Definition');
|
|
83
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateRoot.js","sourceRoot":"","sources":["../../../src/project/standard/CreateRoot.ts"],"names":[],"mappings":";;;;;;AAEA,0DAA4B;AAC5B,gCAAgC;AAEhC,uCAUiB;AAGjB,yCAAqC;AAGrC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;CAiBrB,CAAA;AAGD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;CAkBrB,CAAA;AAGD,0BAA0B;AAC1B,MAAM,UAAU,GAAG,IAAA,cAAG,EAAC,SAAS,UAAU,CAAC,KAAU;IACnD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE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,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE;gBAC7B,IAAA,mBAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAA;YACpB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IAEJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAIA,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/create-sdkgen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"main": "dist/create-sdkgen.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/create-sdkgen.d.ts",
|
|
@@ -28,9 +28,15 @@
|
|
|
28
28
|
"test-model-watch": "voxgig-model -w project/.sdk/test/test.jsonic",
|
|
29
29
|
"clean": "rm -rf dist dist-test node_modules yarn.lock package-lock.json",
|
|
30
30
|
"reset": "npm run clean && npm i && npm run build && npm test",
|
|
31
|
+
"repo-bump": "npm version patch --no-git-tag-version && node -e \"console.log('bumped to v' + require('./package.json').version + ' (package.json only - commit via repo-tag / repo-release)')\"",
|
|
31
32
|
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
|
|
33
|
+
"repo-tag-dry": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo \"[dry-run] TAG: v$REPO_VERSION\" && if git rev-parse -q --verify refs/tags/v$REPO_VERSION >/dev/null; then echo \"[dry-run] WARNING: tag v$REPO_VERSION already exists - bump the version first\"; else echo \"[dry-run] would commit -a, push, tag v$REPO_VERSION and push --tags; nothing done\"; fi && git status --short",
|
|
32
34
|
"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
|
|
33
|
-
"repo-publish-
|
|
35
|
+
"repo-publish-dry": "npm run clean && npm i && npm run repo-publish-quick-dry",
|
|
36
|
+
"repo-publish-quick": "npm run build && npm run test && npm publish --registry https://registry.npmjs.org --access=public",
|
|
37
|
+
"repo-publish-quick-dry": "npm run build && npm run test && ( npm publish --dry-run --registry https://registry.npmjs.org --access=public || echo \"[dry-run] npm publish refused (see npm error above) - usually the version is already published; bump package.json before a real release\" )",
|
|
38
|
+
"repo-release": "npm run repo-publish && npm run repo-tag",
|
|
39
|
+
"repo-release-dry": "npm run repo-publish-quick-dry && npm run repo-tag-dry"
|
|
34
40
|
},
|
|
35
41
|
"license": "MIT",
|
|
36
42
|
"files": [
|
|
@@ -41,15 +47,15 @@
|
|
|
41
47
|
"LICENSE"
|
|
42
48
|
],
|
|
43
49
|
"devDependencies": {
|
|
44
|
-
"@types/node": "
|
|
45
|
-
"memfs": "4.
|
|
50
|
+
"@types/node": "26.1.0",
|
|
51
|
+
"memfs": "4.62.0",
|
|
46
52
|
"typescript": "6.0.3"
|
|
47
53
|
},
|
|
48
54
|
"dependencies": {
|
|
49
|
-
"@voxgig/util": "0.
|
|
50
|
-
"aontu": "0.
|
|
55
|
+
"@voxgig/util": "0.5.1",
|
|
56
|
+
"aontu": "0.48.1",
|
|
51
57
|
"chokidar": "5.0.0",
|
|
52
|
-
"jostraca": "0.
|
|
58
|
+
"jostraca": "0.31.0",
|
|
53
59
|
"shape": "10.1.0"
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
# Unit tests only — strictly offline. No live API calls.
|
|
4
|
+
# Each per-language job runs the mocked unit-test suite for that target.
|
|
5
|
+
# Each step after checkout is gated by hashFiles() so a job auto-skips
|
|
6
|
+
# all its work when the target directory is absent.
|
|
7
|
+
#
|
|
8
|
+
# Live API verification is NOT run here. It happens in the central
|
|
9
|
+
# rebuild pipeline under controlled conditions, with per-API auth and
|
|
10
|
+
# rate-limit handling.
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
branches: [main]
|
|
15
|
+
pull_request:
|
|
16
|
+
branches: [main]
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
go:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- if: hashFiles('go/go.mod') != ''
|
|
27
|
+
uses: actions/setup-go@v5
|
|
28
|
+
with:
|
|
29
|
+
go-version: '1.24'
|
|
30
|
+
- if: hashFiles('go/go.mod') != ''
|
|
31
|
+
run: make -C go test
|
|
32
|
+
|
|
33
|
+
go-cli:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
# aql/eng/go is served via proxy.golang.org but its source repo
|
|
36
|
+
# (aql-lang/aql) is currently private, so sum.golang.org can't
|
|
37
|
+
# checksum-verify it. GOSUMDB=off lets `go mod tidy` use the
|
|
38
|
+
# committed go.sum without re-checking the public sum DB. Once
|
|
39
|
+
# aql-lang/aql goes public this env can be removed.
|
|
40
|
+
env:
|
|
41
|
+
GOSUMDB: 'off'
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
- if: hashFiles('go-cli/go.mod') != ''
|
|
45
|
+
uses: actions/setup-go@v5
|
|
46
|
+
with:
|
|
47
|
+
go-version: '1.24'
|
|
48
|
+
- if: hashFiles('go-cli/go.mod') != ''
|
|
49
|
+
run: |
|
|
50
|
+
cd go-cli
|
|
51
|
+
go mod tidy
|
|
52
|
+
go vet ./...
|
|
53
|
+
go build ./...
|
|
54
|
+
go test ./...
|
|
55
|
+
|
|
56
|
+
go-mcp:
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v4
|
|
60
|
+
- if: hashFiles('go-mcp/go.mod') != ''
|
|
61
|
+
uses: actions/setup-go@v5
|
|
62
|
+
with:
|
|
63
|
+
go-version: '1.24'
|
|
64
|
+
- if: hashFiles('go-mcp/go.mod') != ''
|
|
65
|
+
run: |
|
|
66
|
+
cd go-mcp
|
|
67
|
+
go mod tidy
|
|
68
|
+
go vet ./...
|
|
69
|
+
go build ./...
|
|
70
|
+
go test ./...
|
|
71
|
+
|
|
72
|
+
ts:
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v4
|
|
76
|
+
- if: hashFiles('ts/package.json') != ''
|
|
77
|
+
uses: actions/setup-node@v4
|
|
78
|
+
with:
|
|
79
|
+
node-version: '24'
|
|
80
|
+
- if: hashFiles('ts/package.json') != ''
|
|
81
|
+
run: cd ts && npm install --no-audit --no-fund
|
|
82
|
+
- if: hashFiles('ts/package.json') != ''
|
|
83
|
+
run: cd ts && npm test
|
|
84
|
+
|
|
85
|
+
py:
|
|
86
|
+
runs-on: ubuntu-latest
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/checkout@v4
|
|
89
|
+
- if: hashFiles('py/Makefile') != ''
|
|
90
|
+
uses: actions/setup-python@v5
|
|
91
|
+
with:
|
|
92
|
+
python-version: '3.13'
|
|
93
|
+
- if: hashFiles('py/Makefile') != ''
|
|
94
|
+
run: pip install pytest
|
|
95
|
+
- if: hashFiles('py/Makefile') != ''
|
|
96
|
+
run: make -C py test
|
|
97
|
+
|
|
98
|
+
rb:
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
- if: hashFiles('rb/Makefile') != ''
|
|
103
|
+
uses: ruby/setup-ruby@v1
|
|
104
|
+
with:
|
|
105
|
+
ruby-version: '3.3'
|
|
106
|
+
- if: hashFiles('rb/Makefile') != ''
|
|
107
|
+
run: make -C rb test
|
|
108
|
+
|
|
109
|
+
php:
|
|
110
|
+
runs-on: ubuntu-latest
|
|
111
|
+
steps:
|
|
112
|
+
- uses: actions/checkout@v4
|
|
113
|
+
- if: hashFiles('php/composer.json') != ''
|
|
114
|
+
uses: shivammathur/setup-php@v2
|
|
115
|
+
with:
|
|
116
|
+
php-version: '8.3'
|
|
117
|
+
- if: hashFiles('php/composer.json') != ''
|
|
118
|
+
run: cd php && composer install --no-interaction --no-progress
|
|
119
|
+
- if: hashFiles('php/composer.json') != ''
|
|
120
|
+
run: make -C php test
|
|
121
|
+
|
|
122
|
+
lua:
|
|
123
|
+
runs-on: ubuntu-latest
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- if: hashFiles('lua/Makefile') != ''
|
|
127
|
+
uses: leafo/gh-actions-lua@v10
|
|
128
|
+
with:
|
|
129
|
+
luaVersion: '5.4'
|
|
130
|
+
- if: hashFiles('lua/Makefile') != ''
|
|
131
|
+
uses: leafo/gh-actions-luarocks@v4
|
|
132
|
+
- if: hashFiles('lua/Makefile') != ''
|
|
133
|
+
run: luarocks install busted
|
|
134
|
+
- if: hashFiles('lua/Makefile') != ''
|
|
135
|
+
run: make -C lua test
|
|
@@ -77,6 +77,14 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
77
77
|
const pathParams = collectEntityPathParams(entity)
|
|
78
78
|
|
|
79
79
|
const hasEntId = null != (entity as any).id
|
|
80
|
+
// Some entities don't declare a top-level `id` field but still need an
|
|
81
|
+
// `id` value in their fixture: any entity that has a non-list op (remove,
|
|
82
|
+
// update, load) will hit `data["id"]` in the generated test code. The
|
|
83
|
+
// test mock is lenient about extra/missing path params, so synthesising
|
|
84
|
+
// an `id` here keeps tests green for entities like
|
|
85
|
+
// `/{namespace}/{key}` (no `id` in URL) or `/{resource}/{id}`
|
|
86
|
+
// alongside the simple `{id}`-only case.
|
|
87
|
+
const needsFixtureId = hasEntId || entityHasMutatingOp(entity)
|
|
80
88
|
|
|
81
89
|
let i = 1
|
|
82
90
|
|
|
@@ -91,10 +99,11 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
91
99
|
ent[paramName] = paramValue
|
|
92
100
|
}
|
|
93
101
|
}
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
// bare so test generators don't synthesise bogus
|
|
97
|
-
|
|
102
|
+
// Inject a fixture id when the spec models one for this entity (either
|
|
103
|
+
// as a top-level field or as a path param). Read-only feeds with no id
|
|
104
|
+
// at all leave fixtures bare so test generators don't synthesise bogus
|
|
105
|
+
// id assertions.
|
|
106
|
+
if (needsFixtureId) {
|
|
98
107
|
ent.id = id
|
|
99
108
|
}
|
|
100
109
|
})
|
|
@@ -108,6 +117,21 @@ function makeEntityTestData(_model: Model, entity: ModelEntity) {
|
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
|
|
120
|
+
// Detect whether the entity has any op other than `list` (which doesn't
|
|
121
|
+
// take a per-item id). Used to decide whether the fixture needs a
|
|
122
|
+
// synthesised `id` — the test code for load/update/remove ops references
|
|
123
|
+
// `data["id"]` unconditionally in Python (and similarly in other strict
|
|
124
|
+
// languages), so the fixture must provide one even when the URL path
|
|
125
|
+
// params are named differently (e.g. `/{namespace}/{key}`).
|
|
126
|
+
function entityHasMutatingOp(entity: any): boolean {
|
|
127
|
+
const ops = entity?.op || {}
|
|
128
|
+
for (const opname of Object.keys(ops)) {
|
|
129
|
+
if (opname !== 'list') return true
|
|
130
|
+
}
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
111
135
|
// Walk every op point on the entity, collect the names of path params, and
|
|
112
136
|
// pair each with its canonical idmap value. The canonical value mirrors the
|
|
113
137
|
// flow generator's path-param defaulting in apidef:
|
|
@@ -83,21 +83,48 @@ const Root = cmp(function Root(props: any) {
|
|
|
83
83
|
|
|
84
84
|
Folder({ name: target.name }, () => {
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
86
|
+
// Per-generation-phase activation. A target's jsonic carries
|
|
87
|
+
// a `phase` map mirroring the feature pattern:
|
|
88
|
+
//
|
|
89
|
+
// phase: {
|
|
90
|
+
// entity: { active: false }
|
|
91
|
+
// feature: { active: false }
|
|
92
|
+
// readme: { active: false }
|
|
93
|
+
// test: { active: false }
|
|
94
|
+
// }
|
|
95
|
+
//
|
|
96
|
+
// Defaults are inclusive — when a phase entry is absent (or
|
|
97
|
+
// active is not explicitly false), the phase runs. Existing
|
|
98
|
+
// standard targets don't declare `phase` and keep current
|
|
99
|
+
// behaviour. A CLI-style target switches all four off and
|
|
100
|
+
// only emits Main.
|
|
101
|
+
const phase = target.phase || {}
|
|
102
|
+
const phaseActive = (name: string): boolean =>
|
|
103
|
+
false !== (phase[name] && phase[name].active)
|
|
104
|
+
|
|
105
|
+
if (phaseActive('entity')) {
|
|
106
|
+
each(entity, (entity: any) => {
|
|
107
|
+
names(entity, entity.name)
|
|
108
|
+
Entity({ target, entity })
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (phaseActive('feature')) {
|
|
113
|
+
each(feature).filter((feature: any) => feature.active).map((feature: any) => {
|
|
114
|
+
names(feature, feature.name)
|
|
115
|
+
Feature({ target, feature })
|
|
116
|
+
})
|
|
117
|
+
}
|
|
95
118
|
|
|
96
119
|
Main({ target })
|
|
97
120
|
|
|
98
|
-
|
|
121
|
+
if (phaseActive('readme')) {
|
|
122
|
+
Readme({ target })
|
|
123
|
+
}
|
|
99
124
|
|
|
100
|
-
|
|
125
|
+
if (phaseActive('test')) {
|
|
126
|
+
Test({ target })
|
|
127
|
+
}
|
|
101
128
|
})
|
|
102
129
|
})
|
|
103
130
|
|
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
cmp,
|
|
5
|
+
Deploy,
|
|
5
6
|
ReadmeTop,
|
|
6
7
|
} from '@voxgig/sdkgen'
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
const Top = cmp(function Top(props: any) {
|
|
10
11
|
ReadmeTop({})
|
|
12
|
+
|
|
13
|
+
// Root deployment Makefile: per-target `make deploy-<t>` (publish with
|
|
14
|
+
// credentials injected by the aql key vault) plus an all-targets
|
|
15
|
+
// `make deploy-dry` rehearsal.
|
|
16
|
+
Deploy({})
|
|
11
17
|
})
|
|
12
18
|
|
|
13
19
|
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"strict": true,
|
|
11
11
|
"target": "es2021",
|
|
12
12
|
"types": ["node"],
|
|
13
|
+
|
|
14
|
+
// A generated project must not fail on a *dependency's* own .d.ts: e.g.
|
|
15
|
+
// thread-stream (via @voxgig/apidef -> pino) references
|
|
16
|
+
// worker_threads.TransferListItem, dropped in @types/node >=26. Only src
|
|
17
|
+
// is our code, so skip lib checking of node_modules type declarations.
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
|
|
13
20
|
"declaration": true,
|
|
14
21
|
"declarationDir": "../dist"
|
|
15
22
|
},
|
package/src/tsconfig.json
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"sourceMap": true,
|
|
10
10
|
"strict": true,
|
|
11
11
|
"target": "es2021",
|
|
12
|
+
|
|
13
|
+
// @types/node >=26 dropped worker_threads.TransferListItem, which a
|
|
14
|
+
// dependency's own .d.ts (thread-stream via pino) still references. Only
|
|
15
|
+
// src is our code, so skip lib checking of node_modules type declarations.
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
|
|
12
18
|
"declaration": true,
|
|
13
19
|
"declarationDir": "../dist"
|
|
14
20
|
}
|
package/bin/create-sdkgen~
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const Path = require('node:path')
|
|
4
|
-
const { statSync } = require('node:fs')
|
|
5
|
-
const { parseArgs } = require('node:util')
|
|
6
|
-
|
|
7
|
-
const { Gubu, Fault, One } = require('gubu')
|
|
8
|
-
|
|
9
|
-
const Pkg = require('../package.json')
|
|
10
|
-
|
|
11
|
-
const { CreateSdkGen } = require('../dist/create-sdkgen.js')
|
|
12
|
-
|
|
13
|
-
const rootpath = require.resolve('../dist/standard/Root')
|
|
14
|
-
|
|
15
|
-
let KONSOLE = global['con'+'sole']
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
run()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
async function run() {
|
|
22
|
-
try {
|
|
23
|
-
let options = resolveOptions()
|
|
24
|
-
|
|
25
|
-
if(options.debug) {
|
|
26
|
-
DEBUG = true
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if(options.version) {
|
|
30
|
-
version()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if(options.help) {
|
|
34
|
-
help()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if(options.version || options.help) {
|
|
38
|
-
exit()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
options = validateOptions(options)
|
|
42
|
-
|
|
43
|
-
generate(options)
|
|
44
|
-
}
|
|
45
|
-
catch(err) {
|
|
46
|
-
handleError(err)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function exit(err) {
|
|
52
|
-
let code = 0
|
|
53
|
-
if(err) {
|
|
54
|
-
code = 1
|
|
55
|
-
}
|
|
56
|
-
process.exit(code)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function generate(options) {
|
|
61
|
-
const createSdkGen = CreateSdkGen({
|
|
62
|
-
debug: options.debug
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const spec = {
|
|
67
|
-
root: 'Root',
|
|
68
|
-
|
|
69
|
-
name: options.name,
|
|
70
|
-
def: options.def,
|
|
71
|
-
dryrun: options.dryrun,
|
|
72
|
-
project: options.project,
|
|
73
|
-
install: options.install,
|
|
74
|
-
target: options.target,
|
|
75
|
-
feature: options.feature,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
createSdkGen.generate(spec)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function resolveOptions() {
|
|
84
|
-
|
|
85
|
-
let args
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
args = parseArgs({
|
|
89
|
-
allowPositionals: true,
|
|
90
|
-
allowNegative: true,
|
|
91
|
-
options: {
|
|
92
|
-
def: {
|
|
93
|
-
type: 'string',
|
|
94
|
-
short: 'd',
|
|
95
|
-
default: ''
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
project: {
|
|
99
|
-
type: 'string',
|
|
100
|
-
short: 'p',
|
|
101
|
-
default: 'standard'
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
dryrun: {
|
|
105
|
-
type: 'boolean',
|
|
106
|
-
short: 'y',
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
install: {
|
|
110
|
-
type: 'boolean',
|
|
111
|
-
short: 'y',
|
|
112
|
-
default: true,
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
target: {
|
|
116
|
-
type: 'string',
|
|
117
|
-
short: 't',
|
|
118
|
-
multiple: true
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
feature: {
|
|
122
|
-
type: 'string',
|
|
123
|
-
short: 'f',
|
|
124
|
-
multiple: true
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
debug: {
|
|
128
|
-
type: 'string',
|
|
129
|
-
short: 'g',
|
|
130
|
-
default: 'info'
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
help: {
|
|
134
|
-
type: 'boolean',
|
|
135
|
-
short: 'h',
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
version: {
|
|
139
|
-
type: 'boolean',
|
|
140
|
-
short: 'v',
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
catch(err) {
|
|
147
|
-
if('ERR_PARSE_ARGS_UNKNOWN_OPTION' === err.code) {
|
|
148
|
-
handleError(err.message.replace(/\. .+$/,'.'))
|
|
149
|
-
}
|
|
150
|
-
throw err
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Set fake name if -v or -h used.
|
|
154
|
-
let name = args.positionals[0]
|
|
155
|
-
name = null == name ? '' : name
|
|
156
|
-
name = '' === name && (args.values.help || args.values.version) ? '__none__' : name
|
|
157
|
-
|
|
158
|
-
targets = args.values.target || []
|
|
159
|
-
if( 1 < args.positionals.length ) {
|
|
160
|
-
targets.push(args.positionals.slice(1))
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
features = args.values.feature || []
|
|
164
|
-
|
|
165
|
-
const options = {
|
|
166
|
-
name,
|
|
167
|
-
def: args.values.def,
|
|
168
|
-
project: args.values.project,
|
|
169
|
-
dryrun: !!args.values.dryrun,
|
|
170
|
-
install: !!args.values.install,
|
|
171
|
-
target: targets,
|
|
172
|
-
feature: features,
|
|
173
|
-
debug: args.values.debug,
|
|
174
|
-
help: !!args.values.help,
|
|
175
|
-
version: !!args.values.version,
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// console.log('ARGS', args, options)
|
|
179
|
-
|
|
180
|
-
return options
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
function validateOptions(rawOptions) {
|
|
185
|
-
const optShape = Gubu({
|
|
186
|
-
name: Fault('The first argument must be the project name.', String),
|
|
187
|
-
def: '',
|
|
188
|
-
project: String,
|
|
189
|
-
dryrun: Boolean,
|
|
190
|
-
install: Boolean,
|
|
191
|
-
target: [String],
|
|
192
|
-
feature: [String],
|
|
193
|
-
debug: String,
|
|
194
|
-
help: Boolean,
|
|
195
|
-
version: Boolean,
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
const err = []
|
|
199
|
-
const options = optShape(rawOptions,{err})
|
|
200
|
-
|
|
201
|
-
if(err[0]) {
|
|
202
|
-
handleError(err[0].text)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return options
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
function handleError(err) {
|
|
210
|
-
KONSOLE.log('Voxgig Create SDK Error: '+err)
|
|
211
|
-
exit(err)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
function version() {
|
|
216
|
-
KONSOLE.log(Pkg.version)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
function help() {
|
|
221
|
-
let s = `
|
|
222
|
-
Create a Voxgig SDK Generator project.
|
|
223
|
-
|
|
224
|
-
Usage: npm create @voxgig/sdkgen@latest <name> <args>
|
|
225
|
-
|
|
226
|
-
<name> is the name of the SDK project. This is also used to
|
|
227
|
-
create a project folder. If run against an existing folder
|
|
228
|
-
generated files will be overwritten.
|
|
229
|
-
|
|
230
|
-
<args> are the command arguments:
|
|
231
|
-
|
|
232
|
-
--def Path to the OpenAPI definition file (optional).
|
|
233
|
-
-d
|
|
234
|
-
|
|
235
|
-
--project Project template (folder or package reference). Default: standard.
|
|
236
|
-
-p
|
|
237
|
-
|
|
238
|
-
--dryrun Perform a dry run, where no files are modified.
|
|
239
|
-
-y
|
|
240
|
-
|
|
241
|
-
--debug Set log level (default: info): trace, error, debug, info, warn, fatal.
|
|
242
|
-
-g
|
|
243
|
-
|
|
244
|
-
--help Print this help message.
|
|
245
|
-
-h
|
|
246
|
-
|
|
247
|
-
--version Print version number.
|
|
248
|
-
-v
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
Examples:
|
|
252
|
-
|
|
253
|
-
# Basic usage
|
|
254
|
-
> npm create @voxgig/sdkgen@latest foo
|
|
255
|
-
# Creates the SDK Project in the folder ./foo
|
|
256
|
-
|
|
257
|
-
See also: https://voxgig.com/sdkgen
|
|
258
|
-
`
|
|
259
|
-
|
|
260
|
-
KONSOLE.log(s)
|
|
261
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
PROJECTNAME_APIKEY=<apikey>
|