@voxgig/create-sdkgen 0.0.5 → 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.
Files changed (104) hide show
  1. package/bin/voxgig-create-sdkgen +196 -0
  2. package/dist/create-sdkgen.d.ts +8 -8
  3. package/dist/create-sdkgen.js +60 -70
  4. package/dist/create-sdkgen.js.map +1 -1
  5. package/dist/standard/ModelSdk.js +7 -67
  6. package/dist/standard/ModelSdk.js.map +1 -1
  7. package/dist/standard/Root.js +54 -19
  8. package/dist/standard/Root.js.map +1 -1
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/package.json +13 -10
  11. package/src/create-sdkgen.ts +50 -85
  12. package/src/standard/ModelSdk.ts +8 -85
  13. package/src/standard/Root.ts +22 -25
  14. package/bin/run-create-sdkgen.js +0 -330
  15. package/bin/run-create-sdkgen.js~ +0 -1
  16. package/src/utility.ts +0 -8
  17. package/tm/standard/.env.local +0 -2
  18. package/tm/standard/build/doc.js +0 -23
  19. package/tm/standard/build/sdk.js +0 -22
  20. package/tm/standard/def/DEFINITION.md +0 -4
  21. package/tm/standard/model/.model-config/model-config.jsonic +0 -15
  22. package/tm/standard/model/go.jsonic +0 -6
  23. package/tm/standard/model/js.jsonic +0 -6
  24. package/tm/standard/model/php.jsonic +0 -6
  25. package/tm/standard/model/py.jsonic +0 -7
  26. package/tm/standard/model/rb.jsonic +0 -6
  27. package/tm/standard/package.json +0 -31
  28. package/tm/standard/src/DocStaticRoot.ts +0 -32
  29. package/tm/standard/src/Root.ts +0 -62
  30. package/tm/standard/src/go/Entity_go.ts +0 -226
  31. package/tm/standard/src/go/MainEntity_go.ts +0 -26
  32. package/tm/standard/src/go/Main_go.ts +0 -168
  33. package/tm/standard/src/go/Quick_go.ts +0 -108
  34. package/tm/standard/src/go/ReadmeInstall_go.ts +0 -19
  35. package/tm/standard/src/go/ReadmeQuick_go.ts +0 -45
  36. package/tm/standard/src/go/TestAcceptEntity_go.ts +0 -219
  37. package/tm/standard/src/go/TestAccept_go.ts +0 -38
  38. package/tm/standard/src/go/TestEntity_go.ts +0 -79
  39. package/tm/standard/src/go/TestMain_go.ts +0 -61
  40. package/tm/standard/src/go/Test_go.ts +0 -20
  41. package/tm/standard/src/js/Entity_js.ts +0 -196
  42. package/tm/standard/src/js/MainEntity_js.ts +0 -22
  43. package/tm/standard/src/js/Main_js.ts +0 -154
  44. package/tm/standard/src/js/Quick_js.ts +0 -81
  45. package/tm/standard/src/js/ReadmeInstall_js.ts +0 -19
  46. package/tm/standard/src/js/ReadmeQuick_js.ts +0 -27
  47. package/tm/standard/src/js/TestAcceptEntity_js.ts +0 -101
  48. package/tm/standard/src/js/TestAccept_js.ts +0 -60
  49. package/tm/standard/src/js/TestEntity_js.ts +0 -24
  50. package/tm/standard/src/js/TestMain_js.ts +0 -123
  51. package/tm/standard/src/js/Test_js.ts +0 -24
  52. package/tm/standard/src/php/Entity_php.ts +0 -97
  53. package/tm/standard/src/php/MainEntity_php.ts +0 -43
  54. package/tm/standard/src/php/Main_php.ts +0 -50
  55. package/tm/standard/src/php/Quick_php.ts +0 -59
  56. package/tm/standard/src/php/TestAcceptEntity_php.ts +0 -81
  57. package/tm/standard/src/php/TestAccept_php.ts +0 -33
  58. package/tm/standard/src/php/TestEntity_php.ts +0 -64
  59. package/tm/standard/src/php/TestMain_php.ts +0 -120
  60. package/tm/standard/src/php/Test_php.ts +0 -21
  61. package/tm/standard/src/py/Entity_py.ts +0 -98
  62. package/tm/standard/src/py/MainEntity_py.ts +0 -19
  63. package/tm/standard/src/py/Main_py.ts +0 -211
  64. package/tm/standard/src/py/Quick_py.ts +0 -133
  65. package/tm/standard/src/py/TestAcceptEntity_py.ts +0 -47
  66. package/tm/standard/src/py/TestAccept_py.ts +0 -77
  67. package/tm/standard/src/py/TestEntity_py.ts +0 -50
  68. package/tm/standard/src/py/TestMain_py.ts +0 -103
  69. package/tm/standard/src/py/Test_py.ts +0 -28
  70. package/tm/standard/src/rb/Client_rb.ts +0 -142
  71. package/tm/standard/src/rb/Entity_rb.ts +0 -153
  72. package/tm/standard/src/rb/Error_rb.ts +0 -56
  73. package/tm/standard/src/rb/MainEntity_rb.ts +0 -16
  74. package/tm/standard/src/rb/Main_rb.ts +0 -55
  75. package/tm/standard/src/rb/Quick_rb.ts +0 -65
  76. package/tm/standard/src/rb/ReadmeInstall_rb.ts +0 -19
  77. package/tm/standard/src/rb/ReadmeQuick_rb.ts +0 -30
  78. package/tm/standard/src/rb/TestAcceptEntity_rb.ts +0 -83
  79. package/tm/standard/src/rb/TestAccept_rb.ts +0 -45
  80. package/tm/standard/src/rb/TestEntity_rb.ts +0 -82
  81. package/tm/standard/src/rb/TestMain_rb.ts +0 -67
  82. package/tm/standard/src/rb/Test_rb.ts +0 -27
  83. package/tm/standard/src/tsconfig.json +0 -15
  84. package/tm/standard/tm/go/.env.example +0 -2
  85. package/tm/standard/tm/go/LICENSE +0 -22
  86. package/tm/standard/tm/go/go.mod +0 -5
  87. package/tm/standard/tm/go/go.sum +0 -2
  88. package/tm/standard/tm/js/LICENSE +0 -22
  89. package/tm/standard/tm/js/package.json +0 -17
  90. package/tm/standard/tm/php/LICENSE +0 -22
  91. package/tm/standard/tm/py/LICENSE +0 -22
  92. package/tm/standard/tm/py/MANIFEST.in +0 -4
  93. package/tm/standard/tm/py/Makefile +0 -14
  94. package/tm/standard/tm/py/pyproject.toml +0 -4
  95. package/tm/standard/tm/py/pytest.ini +0 -3
  96. package/tm/standard/tm/py/requirements.txt +0 -4
  97. package/tm/standard/tm/py/setup.cfg +0 -2
  98. package/tm/standard/tm/py/setup.py +0 -82
  99. package/tm/standard/tm/rb/.rspec +0 -1
  100. package/tm/standard/tm/rb/Gemfile +0 -21
  101. package/tm/standard/tm/rb/LICENSE +0 -22
  102. package/tm/standard/tm/rb/Rakefile +0 -6
  103. package/tm/standard/tm/rb/spec/spec_helper.rb +0 -22
  104. package/tm/standard/tm/rb/tm.gemspec +0 -39
@@ -1,26 +1,28 @@
1
1
  /* Copyright (c) 2024 Richard Rodger, MIT License */
2
2
 
3
3
  import * as Fs from 'node:fs'
4
+ import Path from 'node:path'
4
5
 
5
- import { FSWatcher } from 'chokidar'
6
+ import { prettyPino, Pino } from '@voxgig/util'
6
7
 
7
8
  import * as JostracaModule from 'jostraca'
8
9
 
9
10
 
10
11
 
11
12
  type FullCreateSdkGenOptions = {
12
- folder: string
13
- fs: any
14
- model: any
15
- meta: any
16
- rootpath: string
13
+ fs?: any
14
+ debug?: boolean | string
15
+ pino?: ReturnType<typeof Pino>
16
+
17
17
  }
18
18
 
19
19
  type CreateSdkGenOptions = Partial<FullCreateSdkGenOptions>
20
20
 
21
21
 
22
22
  type GenerateSpec = {
23
- watch: string[]
23
+ name: string // Name of SDK project.
24
+ def: string // Path to OpenAPI definition file, copied into SDK project.
25
+ root: string // Path to Root template component.
24
26
  }
25
27
 
26
28
 
@@ -29,109 +31,72 @@ const { each, names, Jostraca } = JostracaModule
29
31
 
30
32
  function CreateSdkGen(opts: FullCreateSdkGenOptions) {
31
33
  const fs = opts.fs || Fs
32
- const folder = opts.folder || '.'
34
+ const pino = prettyPino('create', opts)
35
+ const log = pino.child({ cmp: 'create' })
36
+
33
37
  const jostraca = Jostraca()
34
- const rootpath = opts.rootpath as string
35
38
 
36
- async function generate(spec: any) {
37
- const now = Date.now()
38
- // console.log('CREATE SDK', now, new Date(now), spec)
39
+ async function generate(spec: GenerateSpec) {
40
+ const start = Date.now()
39
41
 
40
- const { model } = spec
42
+ log.info({ point: 'generate-start', start })
43
+ log.debug({ point: 'generate-spec', spec, note: JSON.stringify(spec, null, 2) })
41
44
 
42
- const ctx$ = { fs, folder, meta: { spec } }
45
+ const rootModule: any = require(spec.root)
46
+ const Root = rootModule.Root
43
47
 
44
- clear()
45
- const { Root } = require(rootpath)
48
+ const name = spec.name
49
+ spec.def = (null == spec.def || '' === spec.def) ? name + '-openapi3.yml' : spec.def
46
50
 
47
- completeModel(model)
51
+ const folder = Path.join(process.cwd(), name + (name.endsWith('-sdk') ? '' : '-sdk'))
48
52
 
49
- try {
50
- await jostraca.generate(ctx$, () => Root({ model }))
51
- }
52
- catch (err: any) {
53
- console.log('CREATE SDKGEN ERROR: ', err)
54
- throw err
53
+ const opts = {
54
+ fs: () => fs,
55
+ folder,
56
+ log: log.child({ cmp: 'jostraca' }),
57
+ meta: { spec },
58
+ existing: {
59
+ // write: false,
60
+ // present: true,
61
+ merge: true
62
+ }
55
63
  }
56
- }
57
-
58
-
59
- async function watch(spec: GenerateSpec) {
60
- const fsw = new FSWatcher()
61
- let last_change_time = 0
62
-
63
- await generate(spec)
64
64
 
65
- fsw.on('change', (args: any[]) => {
66
- // console.log('CHANGE', args)
65
+ const model = {
66
+ name,
67
+ year: new Date().getFullYear(),
68
+ }
67
69
 
68
- const dorun = 1111 < Date.now() - last_change_time
70
+ names(model, model.name)
69
71
 
70
- if (dorun) {
71
- last_change_time = Date.now()
72
- generate(spec)
73
- }
74
- })
72
+ log.debug({ point: 'generate-model', model, note: JSON.stringify(model, null, 2) })
75
73
 
76
- spec.watch
77
- .map((wf: string) => (__dirname + '/' + wf))
78
- // .map((wf: string) => (console.log(wf), wf))
79
- .map((wf: string) => fsw.add(wf))
74
+ const info = await jostraca.generate(opts, () => Root({ model, spec }))
80
75
 
81
- // generate()
82
- }
76
+ logfiles(info, log)
83
77
 
84
-
85
- function clear() {
86
- if (rootpath) {
87
- clearRequire(rootpath)
88
- }
78
+ log.info({ point: 'generate-end' })
89
79
  }
90
80
 
91
-
92
81
  return {
93
82
  generate,
94
- watch,
95
83
  }
96
84
 
97
85
  }
98
86
 
99
87
 
100
- function completeModel(model: any) {
101
- names(model, model.name)
88
+ function logfiles(info: any, log: ReturnType<typeof Pino>) {
89
+ const cwd = process.cwd()
102
90
 
103
- each(model.feature, (feature: any) => {
104
- names(feature, feature.key$)
105
- })
106
- }
107
-
108
-
109
- // Adapted from https://github.com/sindresorhus/import-fresh - Thanks!
110
- function clearRequire(path: string) {
111
- let filePath = require.resolve(path)
112
-
113
- if (require.cache[filePath]) {
114
- const children = require.cache[filePath].children.map(child => child.id)
115
-
116
- // Delete module from cache
117
- delete require.cache[filePath]
118
-
119
- for (const id of children) {
120
- clearRequire(id)
121
- }
122
- }
123
-
124
-
125
- if (require.cache[filePath] && require.cache[filePath].parent) {
126
- let i = require.cache[filePath].parent.children.length
127
-
128
- while (i--) {
129
- if (require.cache[filePath].parent.children[i].id === filePath) {
130
- require.cache[filePath].parent.children.splice(i, 1)
91
+ ;['preserve', 'present', 'merge'].map(action => {
92
+ let entries = info.file[action]
93
+ if (0 < entries.length) {
94
+ log.info({
95
+ point: 'file-' + action, entries,
96
+ note: '\n' + entries.map((n: any) => n.path.replace(cwd, '.')).join('\n')
97
+ })
131
98
  }
132
- }
133
- }
134
-
99
+ })
135
100
  }
136
101
 
137
102
 
@@ -1,102 +1,25 @@
1
1
 
2
2
  import {
3
- names,
4
3
  cmp,
5
- each,
6
-
7
- Project,
8
- Folder,
9
- Fragment,
10
4
  File,
11
- Content,
5
+ Fragment,
12
6
 
13
7
  } from 'jostraca'
14
8
 
15
9
 
16
10
 
17
11
  const ModelSdk = cmp(function ModelSdk(props: any) {
18
- const { ctx$, ctx$: { model } } = props
19
-
20
-
21
- // console.log('ModelSdk 2', model)
22
-
23
- // TODO: use apidef
24
- // const def = ctx$.fs.readFileSync(model.def.filepath)
12
+ const { spec } = props
25
13
 
26
14
 
27
15
  File({ name: 'sdk.jsonic' }, () => {
28
- Content(`
29
-
30
- @"../node_modules/@voxgig/sdkgen/model/sdkgen.jsonic"
31
-
32
- name: '${model.name}'
33
-
34
- @"api.jsonic"
35
- @"def.jsonic"
36
-
37
- main: sdk: build: &: { name: .$KEY }
38
-
39
- main: sdk: build: js: @"js.jsonic"
40
-
41
- main: sdk: build: rb: @"rb.jsonic"
42
-
43
- main: sdk: build: py: @"py.jsonic"
44
-
45
- main: sdk: build: php: @"php.jsonic"
46
-
47
- main: sdk: build: go: @"go.jsonic"
48
-
49
-
50
-
51
- main: sdk: test: quick: entity: name: foo
52
-
53
-
54
- main: sdk: entity: $.main.api.entity
55
-
56
-
57
-
58
- main: sdk: option: {
59
-
60
- endpoint: {
61
- kind: *String | string
62
- short: "${model.Name} API URL"
63
- }
64
-
65
- apikey: {
66
- kind: *String | string
67
- short: "${model.Name} API Key"
68
- }
69
-
70
- fetch: {
71
- kind: *Any | string
72
- publish: false
73
- }
74
- }
75
- `)
76
-
77
-
78
- each(model.feature).filter((feature: any) => feature.active).map((feature: any) => {
79
-
80
- Content(
81
- `
82
- main: sdk: feature: ${feature.name}: {
83
- active: true
84
- config: {
85
- `)
86
-
87
- Fragment({
88
- from:
89
- `${__dirname}/../../feature/standard/${feature.name}/${feature.name}-config.jsonic`,
90
- indent: ' '
91
- })
92
-
93
- Content(`
94
- }
95
- }
96
-
97
- `)
16
+ Fragment({
17
+ from: __dirname + '/../../project/.sdk/model/sdk.fragment.jsonic',
18
+ replace: {
19
+ NAME: spec.name,
20
+ DEF: spec.def,
21
+ }
98
22
  })
99
-
100
23
  })
101
24
 
102
25
  })
@@ -1,12 +1,11 @@
1
1
 
2
2
 
3
3
  import Path from 'node:path'
4
-
4
+ import * as Fs from 'node:fs'
5
5
 
6
6
  import {
7
7
  names,
8
8
  cmp,
9
- each,
10
9
 
11
10
  Project,
12
11
  Folder,
@@ -22,44 +21,42 @@ import { ModelSdk } from './ModelSdk'
22
21
 
23
22
  // TODO: rename to RootSdk
24
23
  const Root = cmp(function Root(props: any) {
25
- const { model, ctx$ } = props
26
-
27
- const { folder, meta } = ctx$
28
- const { spec } = meta
24
+ const { ctx$, ctx$: { folder }, spec, model } = props
29
25
 
30
- // names(model, model.name)
26
+ // TODO: move to @voxgig/util as duplicated
27
+ model.const = { name: model.name }
28
+ names(model.const, model.name)
29
+ model.const.year = new Date().getFullYear()
31
30
 
32
31
  ctx$.model = model
33
32
 
34
33
  Project({ folder }, () => {
35
-
36
- // console.log('FOLDER', folder)
37
34
  Copy({
38
- from: __dirname + '/../../tm/standard',
39
- exclude: ['.env.local']
35
+ from: __dirname + '/../../project',
40
36
  })
41
37
 
42
- const def = model.def.filepath
43
- if (null != def && '' !== def) {
38
+ const origdef = spec.def
39
+ const projdef = Path.basename(origdef)
40
+ spec.def = projdef
41
+
42
+ Folder({ name: '.sdk' }, () => {
44
43
  Folder({ name: 'def' }, () => {
45
- Copy({ from: def, name: Path.basename(def) })
44
+ if (Fs.existsSync(origdef)) {
45
+ Copy({ from: origdef, to: projdef })
46
+ }
47
+ else {
48
+ File({ name: projdef }, () => {
49
+ Content('# OpenAPI Definition')
50
+ })
51
+ }
46
52
  })
47
- }
48
53
 
49
- Folder({ name: 'model' }, () => {
50
- ModelSdk({})
51
- })
52
-
53
- Folder({ name: 'feature' }, () => {
54
- each(model.feature).map((feature: any) => {
55
- Folder({ name: feature.name }, () => {
56
- Copy({ from: __dirname + '/../../feature/standard/' + feature.name })
57
- })
54
+ Folder({ name: 'model' }, () => {
55
+ ModelSdk({ spec })
58
56
  })
59
57
  })
60
58
 
61
59
  })
62
-
63
60
  })
64
61
 
65
62
 
@@ -1,330 +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 } = require('gubu')
8
- const { Aontu, Context } = require('aontu')
9
-
10
-
11
- const Pkg = require('../package.json')
12
-
13
- const { CreateSdkGen } = require('../dist/create-sdkgen.js')
14
-
15
- // const { Root } = require('../dist/standard/Root')
16
- const rootpath = require.resolve('../dist/standard/Root')
17
-
18
- let DEBUG = false
19
- let CONSOLE = console
20
-
21
-
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
- }
46
- catch(err) {
47
- handleError(err)
48
- }
49
-
50
-
51
-
52
- function exit(err) {
53
- let code = 0
54
- if(err) {
55
- code = 1
56
- }
57
- process.exit(code)
58
- }
59
-
60
-
61
- function generate(options) {
62
- const createSdkGen = CreateSdkGen({
63
- folder: options.folder,
64
- rootpath
65
- })
66
-
67
-
68
- const model = resolveModel(options)
69
-
70
- const spec = {
71
- // TODO: move to CreateSdkGen options
72
- spec: options.spec,
73
- model,
74
- // root: Root,
75
- }
76
-
77
- if(options.watch) {
78
- spec.watch = [
79
- '../tm',
80
- '../feature',
81
- '../def',
82
- '../dist',
83
- ]
84
- createSdkGen.watch(spec)
85
- }
86
- else {
87
- createSdkGen.generate(spec)
88
- }
89
-
90
- }
91
-
92
-
93
- function resolveModel(options) {
94
-
95
- const typespec = `
96
- name: string
97
- year: number
98
- def: filepath: string
99
- feature: &: {
100
- active: *false | boolean
101
- }
102
- `
103
-
104
- const features = options.feature.map(name=>`feature:${name}:active:true`)
105
-
106
- const src = [
107
- typespec,
108
- `name: ${options.name}`,
109
- `year: ${new Date().getFullYear()}`,
110
- `def: filepath: "${options.def || 'def.yml'}"`,
111
- '' === options.model ? '' : `@"${options.model}"`,
112
- ...(options.set||[]),
113
- ...(features||[]),
114
- ].join('\n')
115
- const aopts = {}
116
- const root = Aontu(src, aopts)
117
- const hasErr = root.err && 0 < root.err.length
118
-
119
- // TODO: collect all errors
120
- if (hasErr) {
121
- // console.log('ERROR ROOT', root.err)
122
- throw root.err[0].msg
123
- }
124
-
125
- let genctx = new Context({ root })
126
- const model = root.gen(genctx)
127
-
128
- // TODO: collect all errors
129
- if (genctx.err && 0 < genctx.err.length) {
130
- // console.log(genctx.err)
131
- // console.log('ERROR GEN', genctx.err)
132
- throw new Error(JSON.stringify(genctx.err[0]))
133
- }
134
-
135
- model.def.filename = Path.basename(model.def.filepath)
136
-
137
- // console.log('MODEL')
138
- // console.dir(model,{depth:null})
139
-
140
- return model
141
- }
142
-
143
-
144
- function resolveOptions() {
145
-
146
- const args = parseArgs({
147
- allowPositionals: true,
148
- options: {
149
- folder: {
150
- type: 'string',
151
- short: 'f',
152
- default: '',
153
- },
154
-
155
- def: {
156
- type: 'string',
157
- short: 'd',
158
- default: '',
159
- },
160
-
161
- set: {
162
- type: 'string',
163
- short: 's',
164
- multiple: true,
165
- },
166
-
167
- model: {
168
- type: 'string',
169
- short: 'm',
170
- default: '',
171
- },
172
-
173
- feature: {
174
- type: 'string',
175
- short: 't',
176
- multiple: true,
177
- },
178
-
179
- watch: {
180
- type: 'boolean',
181
- short: 'w',
182
- },
183
-
184
- debug: {
185
- type: 'boolean',
186
- short: 'g',
187
- },
188
-
189
- help: {
190
- type: 'boolean',
191
- short: 'h',
192
- },
193
-
194
- version: {
195
- type: 'boolean',
196
- short: 'v',
197
- },
198
-
199
- }
200
- })
201
-
202
- const options = {
203
- name: args.positionals[0],
204
- folder: '' === args.values.folder ? args.positionals[0] : args.values.folder,
205
- def: args.values.def,
206
- model: args.values.model,
207
- feature: args.values.feature,
208
- set: args.values.set,
209
- watch: !!args.values.watch,
210
- debug: !!args.values.debug,
211
- help: !!args.values.help,
212
- version: !!args.values.version,
213
- }
214
-
215
- return options
216
- }
217
-
218
-
219
- function validateOptions(rawOptions) {
220
- const optShape = Gubu({
221
- name: Fault('The first argument should be the project name.', String),
222
- folder: String,
223
- def: '',
224
- model: '',
225
- feature: [String],
226
- set: [String],
227
- watch: Boolean,
228
- debug: Boolean,
229
- help: Boolean,
230
- version: Boolean,
231
- })
232
-
233
- const err = []
234
- const options = optShape(rawOptions,{err})
235
-
236
- if(err[0]) {
237
- throw new Error(err[0].text)
238
- }
239
-
240
- if('' !== options.def) {
241
- options.def = Path.resolve(options.def)
242
- const stat = statSync(options.def, {throwIfNoEntry:false})
243
- if(null == stat) {
244
- throw new Error('Definition file not found: '+options.def)
245
- }
246
- }
247
-
248
- if('' !== options.model) {
249
- options.model = Path.resolve(options.model)
250
- const stat = statSync(options.model, {throwIfNoEntry:false})
251
- if(null == stat) {
252
- throw new Error('Model file not found: '+options.model)
253
- }
254
- }
255
-
256
- return options
257
- }
258
-
259
-
260
- function handleError(err) {
261
- CONSOLE.log('Voxgig SDK Generator Error:')
262
-
263
- if(DEBUG) {
264
- CONSOLE.log(err)
265
- }
266
- else {
267
- CONSOLE.log(err.message)
268
- }
269
-
270
- exit(err)
271
- }
272
-
273
-
274
- function version() {
275
- CONSOLE.log(Pkg.version)
276
- }
277
-
278
-
279
- function help() {
280
- let s = `
281
- Create a Voxgig SDK Generator project.
282
-
283
- Usage: npm create @voxgig/sdkgen@latest <name> <args>
284
-
285
- where <name> is the name of the SDK project. This is also used to
286
- create a project folder if one is not explictly defined using the -f
287
- argument. If run against an existing folder generated files will be
288
- overwritten.
289
-
290
- <args> are the command arguments:
291
-
292
- --folder <folder> Specific the folder for the SDK project. Optional.
293
- -f <folder> Default: <name> in current folder.
294
-
295
- --def <file> Specify the API definition file (OpenAPI, Swagger, etc)
296
- -d that defines the SDK. Optional.
297
-
298
- --model <file> Specify the SDK model file to customize the SDK. Optional.
299
- -m
300
-
301
- --watch Run in watch mode. The SDK project will be updated if any of the
302
- -w project inputs (such as the spec file) change.
303
-
304
- --debug Print verbose logging.
305
- -d
306
-
307
- --help Print this help message.
308
- -h
309
-
310
- --version Print version number.
311
- -v
312
-
313
-
314
- Examples:
315
-
316
- # Basic usage
317
- > npm create @voxgig/sdkgen@latest foo
318
- # Creates the SDK Project in the folder ./foo
319
-
320
-
321
- # Custom project folder
322
- > npm create @voxgig/sdkgen@latest foo -f ~/Projects/Foo
323
- # Creates the SDK Project in the folder ~/Projects/Foo
324
-
325
-
326
- See also: https://voxgig.com/sdkgen
327
- `
328
-
329
- CONSOLE.log(s)
330
- }
@@ -1 +0,0 @@
1
-