@team-supercharge/oasg 13.2.0-feature-csharp-functions-c1cbb3b0.0 → 13.2.0-feature-csharp-functions-953cbbf4.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/exec.js +3 -2
- package/bin/oasg +129 -161
- package/package.json +1 -1
package/bin/exec.js
CHANGED
@@ -3,8 +3,9 @@ const { execSync } = require('child_process');
|
|
3
3
|
|
4
4
|
function exec(command, stdio) {
|
5
5
|
try {
|
6
|
-
execSync(
|
7
|
-
}
|
6
|
+
execSync(command, { stdio: stdio || 'inherit' });
|
7
|
+
}
|
8
|
+
catch (e) {
|
8
9
|
console.error(e.message);
|
9
10
|
exit(1);
|
10
11
|
}
|
package/bin/oasg
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
const fs = require('fs');
|
4
4
|
const crypto = require('crypto');
|
5
5
|
const ajv = new (require('ajv'))({
|
6
|
-
strict: 'log'
|
6
|
+
strict: 'log'
|
7
7
|
});
|
8
8
|
const YAML = require('yamljs');
|
9
9
|
const refParser = require('@apidevtools/json-schema-ref-parser');
|
@@ -33,23 +33,23 @@ const PROXY_PORT = '9999';
|
|
33
33
|
|
34
34
|
const DEFAULT_GENERATOR_MAPPING = {
|
35
35
|
// client targets
|
36
|
-
android:
|
37
|
-
angular:
|
38
|
-
feign:
|
39
|
-
|
40
|
-
flutter:
|
41
|
-
ios:
|
42
|
-
python:
|
43
|
-
react:
|
36
|
+
"android": { version: '7.0.1', generator: 'kotlin' },
|
37
|
+
"angular": { version: '7.0.1', generator: 'typescript-angular' },
|
38
|
+
"feign": { version: '7.0.1', generator: 'spring' },
|
39
|
+
"feign-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
|
40
|
+
"flutter": { version: '7.0.1', generator: 'dart-dio' },
|
41
|
+
"ios": { version: '7.0.1', generator: 'swift5' },
|
42
|
+
"python": { version: '7.0.1', generator: 'python' },
|
43
|
+
"react": { version: '7.0.1', generator: 'typescript-fetch' },
|
44
44
|
// server targets
|
45
|
-
nestjs:
|
46
|
-
spring:
|
47
|
-
|
48
|
-
|
45
|
+
"nestjs": { version: '7.0.1', generator: 'typescript-angular' },
|
46
|
+
"spring": { version: '7.0.1', generator: 'spring' },
|
47
|
+
"spring-kotlin": { version: '7.0.1', generator: 'kotlin-spring' },
|
48
|
+
"csharp-functions": { version: '7.0.1', generator: 'csharp-functions' },
|
49
49
|
// misc targets
|
50
|
-
|
51
|
-
openapi:
|
52
|
-
stubby:
|
50
|
+
"contract-testing": { version: '4.3.1', generator: 'typescript-node' },
|
51
|
+
"openapi": { version: undefined, generator: undefined },
|
52
|
+
"stubby": { version: '4.3.1', generator: 'stubby' },
|
53
53
|
};
|
54
54
|
const DEFAULT_KTLINT_VERSION = '1.0.0';
|
55
55
|
const BIN_FOLDER = 'out/.bin';
|
@@ -59,8 +59,8 @@ const CONFIG_FILE_NAME = 'config.json';
|
|
59
59
|
const DEFAULT_SOURCE = {
|
60
60
|
id: 'default',
|
61
61
|
type: 'simple',
|
62
|
-
input: 'api/openapi.yaml'
|
63
|
-
}
|
62
|
+
input: 'api/openapi.yaml'
|
63
|
+
}
|
64
64
|
|
65
65
|
let config;
|
66
66
|
|
@@ -76,93 +76,71 @@ async function run() {
|
|
76
76
|
// handle command line
|
77
77
|
require('yargs')
|
78
78
|
// lint
|
79
|
-
.command(
|
80
|
-
|
81
|
-
|
82
|
-
(yargs) => {
|
83
|
-
yargs.positional('source', {
|
79
|
+
.command(['lint [source]', 'l'], 'lint definitions', (yargs) => {
|
80
|
+
yargs
|
81
|
+
.positional('source', {
|
84
82
|
describe: 'specify a source (optional)',
|
85
|
-
default: undefined
|
86
|
-
})
|
87
|
-
|
88
|
-
(argv) => lint(argv)
|
89
|
-
)
|
83
|
+
default: undefined
|
84
|
+
})
|
85
|
+
}, (argv) => lint(argv))
|
90
86
|
|
91
87
|
// serve
|
92
|
-
.command(
|
93
|
-
|
94
|
-
|
95
|
-
(yargs) => {
|
96
|
-
yargs.positional('source', {
|
88
|
+
.command(['serve [source]', 's'], 'serve definition', (yargs) => {
|
89
|
+
yargs
|
90
|
+
.positional('source', {
|
97
91
|
describe: 'specify a source',
|
98
|
-
default: 'default'
|
99
|
-
})
|
100
|
-
|
101
|
-
(argv) => serve(argv)
|
102
|
-
)
|
92
|
+
default: 'default'
|
93
|
+
})
|
94
|
+
}, (argv) => serve(argv))
|
103
95
|
|
104
96
|
// proxy
|
105
|
-
.command(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
demandOption: true,
|
118
|
-
});
|
119
|
-
},
|
120
|
-
(argv) => proxy(argv)
|
121
|
-
)
|
97
|
+
.command(['proxy [source]', 'p'], 'serve definition', (yargs) => {
|
98
|
+
yargs
|
99
|
+
.positional('source', {
|
100
|
+
describe: 'specify a source',
|
101
|
+
default: 'default'
|
102
|
+
})
|
103
|
+
.option('server', {
|
104
|
+
describe: 'specify a server (from "servers" array)',
|
105
|
+
alias: 's',
|
106
|
+
demandOption: true
|
107
|
+
})
|
108
|
+
}, (argv) => proxy(argv))
|
122
109
|
|
123
110
|
// generate
|
124
|
-
.command(
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
type: 'boolean',
|
140
|
-
});
|
141
|
-
},
|
142
|
-
(argv) => generate(argv)
|
143
|
-
)
|
111
|
+
.command(['generate [target]', 'g'], 'generate packages', (yargs) => {
|
112
|
+
yargs
|
113
|
+
.positional('target', {
|
114
|
+
describe: 'specify a target (optional)',
|
115
|
+
default: undefined
|
116
|
+
})
|
117
|
+
.option('artifactVersion', {
|
118
|
+
describe: 'Specify an artifactVersion (optional). \nIf you do not specify it, the tool uses the root package.json\'s version field.',
|
119
|
+
default: undefined
|
120
|
+
})
|
121
|
+
.option('preRelease', {
|
122
|
+
describe: 'Generate as pre-release (optional). \nHow a pre-release is handled varies between different target types.',
|
123
|
+
type: 'boolean'
|
124
|
+
})
|
125
|
+
}, (argv) => generate(argv))
|
144
126
|
|
145
127
|
// publish
|
146
|
-
.command(
|
147
|
-
|
148
|
-
'
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
type: 'boolean',
|
158
|
-
});
|
159
|
-
},
|
160
|
-
(argv) => publish(argv)
|
161
|
-
)
|
128
|
+
.command(['publish [target]', 'p'], 'publish packages', (yargs) => {
|
129
|
+
yargs
|
130
|
+
.positional('target', {
|
131
|
+
describe: 'specifiy a target (optional)',
|
132
|
+
default: undefined
|
133
|
+
})
|
134
|
+
.option('preRelease', {
|
135
|
+
describe: 'Publish as pre-release (optional). \nHow a pre-release is handled varies between different target types.',
|
136
|
+
type: 'boolean'
|
137
|
+
})
|
138
|
+
}, (argv) => publish(argv))
|
162
139
|
|
163
140
|
// options
|
164
141
|
.demandCommand(1, 'You need to specify a command!')
|
165
|
-
.strict()
|
142
|
+
.strict()
|
143
|
+
.argv
|
166
144
|
}
|
167
145
|
|
168
146
|
function checkVersionMismatch() {
|
@@ -182,7 +160,7 @@ function checkVersionMismatch() {
|
|
182
160
|
function checkRequiredCommands() {
|
183
161
|
const missing = [];
|
184
162
|
|
185
|
-
REQUIRED_COMMANDS.forEach(
|
163
|
+
REQUIRED_COMMANDS.forEach(command => {
|
186
164
|
if (!commandExistsSync(command)) {
|
187
165
|
missing.push(command);
|
188
166
|
}
|
@@ -213,10 +191,10 @@ async function parseConfig() {
|
|
213
191
|
}
|
214
192
|
|
215
193
|
// validate config schema
|
216
|
-
let schema = YAML.load(`${__dirname}/../config.schema.yml`)
|
194
|
+
let schema = YAML.load(`${__dirname}/../config.schema.yml`)
|
217
195
|
schema = await refParser.dereference(schema);
|
218
196
|
schema = mergeAllOf(schema, { ignoreAdditionalProperties: true });
|
219
|
-
ajv.addVocabulary([
|
197
|
+
ajv.addVocabulary(["sources", "targets"]);
|
220
198
|
const valid = ajv.validate(schema, config);
|
221
199
|
|
222
200
|
if (!valid) {
|
@@ -230,7 +208,7 @@ async function parseConfig() {
|
|
230
208
|
}
|
231
209
|
|
232
210
|
// set default source values
|
233
|
-
config.sources.forEach(
|
211
|
+
config.sources.forEach(s => {
|
234
212
|
if (s.bundle === undefined) {
|
235
213
|
s.bundle = true;
|
236
214
|
}
|
@@ -249,14 +227,14 @@ async function parseConfig() {
|
|
249
227
|
});
|
250
228
|
|
251
229
|
// set default source to targets with undefined
|
252
|
-
config.targets.forEach(
|
230
|
+
config.targets.forEach(t => {
|
253
231
|
if (!t.source) {
|
254
232
|
t.source = 'default';
|
255
233
|
}
|
256
234
|
});
|
257
235
|
|
258
236
|
// set default generator values to targets with undefined
|
259
|
-
config.targets.forEach(
|
237
|
+
config.targets.forEach(t => {
|
260
238
|
if (!t.generator) {
|
261
239
|
t.generator = DEFAULT_GENERATOR_MAPPING[t.type].version;
|
262
240
|
}
|
@@ -268,20 +246,20 @@ async function parseConfig() {
|
|
268
246
|
exit(1);
|
269
247
|
}
|
270
248
|
}
|
271
|
-
})
|
249
|
+
})
|
272
250
|
|
273
251
|
// set default ktlint to android targets with undefined
|
274
|
-
config.targets.forEach(
|
252
|
+
config.targets.forEach(t => {
|
275
253
|
//TODO: handle different types of platform
|
276
254
|
if (t.type === 'android') {
|
277
255
|
if (!t.formatter) {
|
278
256
|
t.formatter = DEFAULT_KTLINT_VERSION;
|
279
257
|
}
|
280
258
|
}
|
281
|
-
})
|
259
|
+
})
|
282
260
|
|
283
261
|
// validate uniqueness of source IDs
|
284
|
-
const sourceIds = config.sources.map(
|
262
|
+
const sourceIds = config.sources.map(s => s.id);
|
285
263
|
const duplicateSourceIds = findDuplicates(sourceIds);
|
286
264
|
|
287
265
|
if (duplicateSourceIds.length > 0) {
|
@@ -290,7 +268,7 @@ async function parseConfig() {
|
|
290
268
|
}
|
291
269
|
|
292
270
|
// validate uniqueness of target IDs
|
293
|
-
const targetIds = config.targets.map(
|
271
|
+
const targetIds = config.targets.map(t => t.id);
|
294
272
|
const duplicateTargetIds = findDuplicates(targetIds);
|
295
273
|
|
296
274
|
if (duplicateTargetIds.length > 0) {
|
@@ -299,7 +277,7 @@ async function parseConfig() {
|
|
299
277
|
}
|
300
278
|
|
301
279
|
// validate targets have valid sources
|
302
|
-
config.targets.forEach(
|
280
|
+
config.targets.forEach(t => {
|
303
281
|
if (!sourceIds.includes(t.source)) {
|
304
282
|
console.error(`source: ${t.source} not found for target: ${t.id}`);
|
305
283
|
exit(1);
|
@@ -307,8 +285,8 @@ async function parseConfig() {
|
|
307
285
|
});
|
308
286
|
|
309
287
|
// validate unused sources
|
310
|
-
const usedSources = config.targets.map(
|
311
|
-
config.sources.forEach(
|
288
|
+
const usedSources = config.targets.map(t => t.source);
|
289
|
+
config.sources.forEach(s => {
|
312
290
|
if (!usedSources.includes(s.id)) {
|
313
291
|
console.error(`source: ${s.id} is not used in any of the targets`);
|
314
292
|
exit(1);
|
@@ -316,7 +294,7 @@ async function parseConfig() {
|
|
316
294
|
});
|
317
295
|
|
318
296
|
// validate source inputs exists
|
319
|
-
config.sources.forEach(
|
297
|
+
config.sources.forEach(s => {
|
320
298
|
switch (s.type) {
|
321
299
|
case 'simple':
|
322
300
|
if (!fs.existsSync(s.input)) {
|
@@ -327,12 +305,12 @@ async function parseConfig() {
|
|
327
305
|
break;
|
328
306
|
|
329
307
|
case 'merged':
|
330
|
-
s.inputs.forEach(
|
308
|
+
s.inputs.forEach(i => {
|
331
309
|
if (fs.existsSync(i)) {
|
332
310
|
return;
|
333
311
|
}
|
334
312
|
const matches = globSync(i);
|
335
|
-
if (matches.every(
|
313
|
+
if (matches.every(m => fs.existsSync(m))) {
|
336
314
|
return;
|
337
315
|
}
|
338
316
|
console.error(`input file: ${i} not found for source: ${s.id}`);
|
@@ -357,11 +335,7 @@ async function buildSources(sourceIds) {
|
|
357
335
|
continue;
|
358
336
|
}
|
359
337
|
|
360
|
-
console.log(
|
361
|
-
`\n=====\n id:\t\t${source.id}\n type:\t\t${source.type}\n bundle:\t${source.bundle}\n sortSchemas:\t${
|
362
|
-
source.sortSchemas
|
363
|
-
}\n decorators: \t${JSON.stringify(source.decorators)}\n cleanup:\t${source.cleanup}\n---\n`
|
364
|
-
);
|
338
|
+
console.log(`\n=====\n id:\t\t${source.id}\n type:\t\t${source.type}\n bundle:\t${source.bundle}\n sortSchemas:\t${source.sortSchemas}\n decorators: \t${JSON.stringify(source.decorators)}\n cleanup:\t${source.cleanup}\n---\n`);
|
365
339
|
|
366
340
|
let file;
|
367
341
|
|
@@ -392,8 +366,8 @@ async function lint(argv) {
|
|
392
366
|
|
393
367
|
// gather and deduplicate input files
|
394
368
|
let inputs = [];
|
395
|
-
sourceIds.forEach(
|
396
|
-
const source = config.sources.find(
|
369
|
+
sourceIds.forEach(sourceId => {
|
370
|
+
const source = config.sources.find(s => s.id === sourceId);
|
397
371
|
|
398
372
|
switch (source.type) {
|
399
373
|
case 'simple':
|
@@ -401,9 +375,9 @@ async function lint(argv) {
|
|
401
375
|
break;
|
402
376
|
|
403
377
|
case 'merged':
|
404
|
-
source.inputs.forEach(
|
378
|
+
source.inputs.forEach(i => inputs.push(i));
|
405
379
|
}
|
406
|
-
})
|
380
|
+
})
|
407
381
|
inputs = Array.from(new Set(inputs));
|
408
382
|
|
409
383
|
exec(`npx spectral lint --fail-severity warn ${inputs.join(' ')}`);
|
@@ -421,16 +395,16 @@ async function serve(argv) {
|
|
421
395
|
const app = express();
|
422
396
|
|
423
397
|
// configure proxying
|
424
|
-
const proxyHost = function
|
398
|
+
const proxyHost = function(request) {
|
425
399
|
const url = new URL(request.query.u);
|
426
400
|
return url.origin;
|
427
401
|
};
|
428
402
|
|
429
403
|
const proxyOptions = {
|
430
|
-
proxyReqPathResolver: function
|
404
|
+
proxyReqPathResolver: function(request) {
|
431
405
|
const url = new URL(request.query.u);
|
432
406
|
return `${url.pathname}${url.search}${url.hash}`;
|
433
|
-
}
|
407
|
+
}
|
434
408
|
};
|
435
409
|
app.use('/proxy', expressHttpProxy(proxyHost, proxyOptions));
|
436
410
|
|
@@ -438,15 +412,15 @@ async function serve(argv) {
|
|
438
412
|
var swaggerOptions = {
|
439
413
|
swaggerOptions: {
|
440
414
|
showMutatedRequest: false,
|
441
|
-
requestInterceptor: function
|
415
|
+
requestInterceptor: function(request) {
|
442
416
|
if (request.url.startsWith('http://localhost')) {
|
443
417
|
return request;
|
444
418
|
}
|
445
419
|
|
446
420
|
request.url = '/proxy?u=' + encodeURIComponent(request.url);
|
447
421
|
return request;
|
448
|
-
}
|
449
|
-
}
|
422
|
+
}
|
423
|
+
}
|
450
424
|
};
|
451
425
|
app.use('/', swaggerUi.serve, swaggerUi.setup(document, swaggerOptions));
|
452
426
|
|
@@ -466,7 +440,7 @@ async function proxy(argv) {
|
|
466
440
|
const document = YAML.load(input);
|
467
441
|
|
468
442
|
// validate server name
|
469
|
-
const validServerNames = document.servers.map(
|
443
|
+
const validServerNames = document.servers.map(s => s.description);
|
470
444
|
const serverName = argv.server;
|
471
445
|
|
472
446
|
if (!validServerNames.includes(serverName)) {
|
@@ -475,7 +449,7 @@ async function proxy(argv) {
|
|
475
449
|
}
|
476
450
|
|
477
451
|
// validate server url
|
478
|
-
const server = document.servers.find(
|
452
|
+
const server = document.servers.find(s => s.description === serverName);
|
479
453
|
if (!server.url) {
|
480
454
|
console.error(`url must be defined for server ${server.description}`);
|
481
455
|
exit(1);
|
@@ -496,8 +470,8 @@ async function generate(argv) {
|
|
496
470
|
|
497
471
|
console.log(`generate targets: ${targetIds}`);
|
498
472
|
|
499
|
-
targetIds.forEach(
|
500
|
-
const target = config.targets.find(
|
473
|
+
targetIds.forEach(targetId => {
|
474
|
+
const target = config.targets.find(t => t.id === targetId);
|
501
475
|
|
502
476
|
// handle docs target
|
503
477
|
if (target.type === 'openapi') {
|
@@ -517,11 +491,7 @@ async function generate(argv) {
|
|
517
491
|
const templateDir = customizeTemplates(target);
|
518
492
|
|
519
493
|
// run generation
|
520
|
-
exec(
|
521
|
-
`${__dirname}/../targets/${target.type}/generate.sh ${VERSION} ${binary} ${CONFIG_FILE_NAME} ${target.id} ${
|
522
|
-
sources[target.source]
|
523
|
-
} ${formatter} ${target.generatorId} ${preRelease.toString()} ${templateDir}`
|
524
|
-
);
|
494
|
+
exec(`bash -e ${__dirname}/../targets/${target.type}/generate.sh ${VERSION} ${binary} ${CONFIG_FILE_NAME} ${target.id} ${sources[target.source]} ${formatter} ${target.generatorId} ${preRelease.toString()} ${templateDir}`);
|
525
495
|
});
|
526
496
|
}
|
527
497
|
|
@@ -533,8 +503,8 @@ async function publish(argv) {
|
|
533
503
|
|
534
504
|
console.log(`publish targets: ${targetIds}`);
|
535
505
|
|
536
|
-
targetIds.forEach(
|
537
|
-
const target = config.targets.find(
|
506
|
+
targetIds.forEach(targetId => {
|
507
|
+
const target = config.targets.find(t => t.id === targetId);
|
538
508
|
|
539
509
|
// handle docs target
|
540
510
|
if (target.type === 'openapi') {
|
@@ -550,17 +520,13 @@ async function publish(argv) {
|
|
550
520
|
formatter = fetchFormatter(target);
|
551
521
|
}
|
552
522
|
|
553
|
-
exec(
|
554
|
-
`${__dirname}/../targets/${target.type}/publish.sh ${VERSION} ${binary} ${CONFIG_FILE_NAME} ${target.id} ${
|
555
|
-
sources[target.source]
|
556
|
-
} ${formatter} ${target.generatorId} ${preRelease.toString()}`
|
557
|
-
);
|
523
|
+
exec(`bash -e ${__dirname}/../targets/${target.type}/publish.sh ${VERSION} ${binary} ${CONFIG_FILE_NAME} ${target.id} ${sources[target.source]} ${formatter} ${target.generatorId} ${preRelease.toString()}`);
|
558
524
|
});
|
559
525
|
}
|
560
526
|
|
561
527
|
function fetchBinary(target) {
|
562
528
|
// determine binary
|
563
|
-
const generator = target.generator
|
529
|
+
const generator = target.generator
|
564
530
|
const binary = {};
|
565
531
|
|
566
532
|
if (generator.startsWith('http')) {
|
@@ -568,7 +534,8 @@ function fetchBinary(target) {
|
|
568
534
|
|
569
535
|
const hash = crypto.createHash('sha256').update(binary.url).digest('hex').substring(0, 8);
|
570
536
|
binary.name = `openapi-generator-cli-${hash}.jar`;
|
571
|
-
}
|
537
|
+
}
|
538
|
+
else {
|
572
539
|
binary.url = `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${generator}/openapi-generator-cli-${generator}.jar`;
|
573
540
|
binary.name = `openapi-generator-cli-${generator}.jar`;
|
574
541
|
}
|
@@ -582,24 +549,26 @@ function fetchBinary(target) {
|
|
582
549
|
|
583
550
|
// download binary
|
584
551
|
console.log(`... downloading ${binary.url} ==> ${binaryPath}`);
|
585
|
-
exec(`mkdir -p ${BIN_FOLDER}`);
|
586
|
-
exec(`wget ${binary.url} -q -O ${binaryPath}`);
|
587
|
-
exec(`chmod +x ${binaryPath}`);
|
552
|
+
exec(`bash -e -c "mkdir -p ${BIN_FOLDER}"`);
|
553
|
+
exec(`bash -e -c "wget ${binary.url} -q -O ${binaryPath}"`);
|
554
|
+
exec(`bash -e -c "chmod +x ${binaryPath}"`);
|
588
555
|
return binaryPath;
|
589
556
|
}
|
590
557
|
|
591
558
|
function fetchFormatter(target) {
|
592
559
|
// determine binary
|
593
|
-
const formatter = target.formatter
|
560
|
+
const formatter = target.formatter
|
594
561
|
const binary = {};
|
595
562
|
|
563
|
+
|
596
564
|
//TODO: handle different types of platforms
|
597
565
|
if (formatter.startsWith('http')) {
|
598
566
|
binary.url = formatter;
|
599
567
|
|
600
568
|
const hash = crypto.createHash('sha256').update(binary.url).digest('hex').substring(0, 8);
|
601
569
|
binary.name = `ktlint-${hash}`;
|
602
|
-
}
|
570
|
+
}
|
571
|
+
else {
|
603
572
|
binary.url = `https://github.com/pinterest/ktlint/releases/download/${formatter}/ktlint`;
|
604
573
|
binary.name = `ktlint-${formatter}`;
|
605
574
|
}
|
@@ -613,9 +582,9 @@ function fetchFormatter(target) {
|
|
613
582
|
|
614
583
|
// download binary
|
615
584
|
console.log(`... downloading ${binary.url} ==> ${binaryPath}`);
|
616
|
-
exec(`mkdir -p ${BIN_FOLDER}`);
|
617
|
-
exec(`wget ${binary.url} -q -O ${binaryPath}`);
|
618
|
-
exec(`chmod +x ${binaryPath}`);
|
585
|
+
exec(`bash -e -c "mkdir -p ${BIN_FOLDER}"`);
|
586
|
+
exec(`bash -e -c "wget ${binary.url} -q -O ${binaryPath}"`);
|
587
|
+
exec(`bash -e -c "chmod +x ${binaryPath}"`);
|
619
588
|
return binaryPath;
|
620
589
|
}
|
621
590
|
|
@@ -626,12 +595,12 @@ function customizeTemplates(target) {
|
|
626
595
|
const targetTemplateDir = `${__dirname}/../targets/${target.type}/templates`;
|
627
596
|
|
628
597
|
if (fs.existsSync(templateDir)) {
|
629
|
-
|
598
|
+
exec(`bash -e -c "rm -rf ${templateDir}"`);
|
630
599
|
}
|
631
|
-
exec(`mkdir -p ${templateDir}`);
|
600
|
+
exec(`bash -e -c "mkdir -p ${templateDir}"`);
|
632
601
|
|
633
602
|
if (fs.existsSync(targetTemplateDir)) {
|
634
|
-
exec(`cp -R ${targetTemplateDir}/* ${templateDir}`);
|
603
|
+
exec(`bash -e -c "cp -R ${targetTemplateDir}/* ${templateDir}"`);
|
635
604
|
}
|
636
605
|
|
637
606
|
if (target.templateDir) {
|
@@ -640,7 +609,7 @@ function customizeTemplates(target) {
|
|
640
609
|
exit(1);
|
641
610
|
}
|
642
611
|
|
643
|
-
exec(`cp -R ${target.templateDir}/* ${templateDir}`);
|
612
|
+
exec(`bash -e -c "cp -R ${target.templateDir}/* ${templateDir}`);
|
644
613
|
}
|
645
614
|
|
646
615
|
return templateDir;
|
@@ -659,7 +628,7 @@ function determineSourceIds(argv) {
|
|
659
628
|
}
|
660
629
|
|
661
630
|
function validSourceIds() {
|
662
|
-
return config.sources.map(
|
631
|
+
return config.sources.map(s => s.id);
|
663
632
|
}
|
664
633
|
|
665
634
|
function checkSourceId(sourceId) {
|
@@ -683,8 +652,8 @@ function determineTargetIds(argv) {
|
|
683
652
|
|
684
653
|
function sourceIdsFromTargetIds(targetIds) {
|
685
654
|
const sourceIds = [];
|
686
|
-
targetIds.forEach(
|
687
|
-
const target = config.targets.find(
|
655
|
+
targetIds.forEach(targetId => {
|
656
|
+
const target = config.targets.find(t => t.id === targetId);
|
688
657
|
if (target.source) {
|
689
658
|
sourceIds.push(target.source);
|
690
659
|
}
|
@@ -693,7 +662,7 @@ function sourceIdsFromTargetIds(targetIds) {
|
|
693
662
|
}
|
694
663
|
|
695
664
|
function validTargetIds() {
|
696
|
-
return config.targets.map(
|
665
|
+
return config.targets.map(t => t.id);
|
697
666
|
}
|
698
667
|
|
699
668
|
function checkTargetId(targetId) {
|
@@ -705,9 +674,8 @@ function checkTargetId(targetId) {
|
|
705
674
|
|
706
675
|
// find duplicates
|
707
676
|
function findDuplicates(arr) {
|
708
|
-
return arr.reduce(function
|
709
|
-
if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el);
|
710
|
-
return acc;
|
677
|
+
return arr.reduce(function(acc, el, i, arr) {
|
678
|
+
if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;
|
711
679
|
}, []);
|
712
680
|
}
|
713
681
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@team-supercharge/oasg",
|
3
|
-
"version": "13.2.0-feature-csharp-functions-
|
3
|
+
"version": "13.2.0-feature-csharp-functions-953cbbf4.0",
|
4
4
|
"description": "Node-based tool to lint OpenAPI documents and generate clients, servers and documentation from them",
|
5
5
|
"author": "Supercharge",
|
6
6
|
"license": "MIT",
|