2018-06-12 16:50:45 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
var Path = require('path');
|
|
|
|
|
|
|
|
require('shelljs/global');
|
|
|
|
set('-e');
|
|
|
|
|
|
|
|
var TARGET_DIR = 'dist'
|
|
|
|
if (process.argv[2]) {
|
|
|
|
TARGET_DIR = process.argv[2]
|
|
|
|
}
|
|
|
|
|
|
|
|
var APIS = ls('api')
|
|
|
|
if (process.argv[3]) {
|
|
|
|
APIS = [process.argv[3]]
|
|
|
|
}
|
|
|
|
|
2020-03-18 13:00:08 +00:00
|
|
|
mkdir('-p', TARGET_DIR);
|
2018-06-12 16:50:45 +00:00
|
|
|
cp('-R', 'web/*', TARGET_DIR + '/');
|
|
|
|
|
|
|
|
APIS.forEach(function (api) {
|
|
|
|
var basedir = 'api/' + api + '/spec/';
|
|
|
|
var targetdir = TARGET_DIR + '/api/' + api;
|
|
|
|
mkdir('-p', targetdir);
|
|
|
|
exec('npm run swagger bundle -- --basedir ' + basedir + ' -o ' + targetdir + '/swagger.json');
|
|
|
|
exec('npm run swagger bundle -- --basedir ' + basedir + ' --yaml -o ' + targetdir + '/swagger.yaml');
|
|
|
|
});
|
|
|
|
|
|
|
|
var SWAGGER_UI_DIST = Path.dirname(require.resolve('swagger-ui'));
|
|
|
|
rm('-rf', TARGET_DIR + '/swagger-ui/')
|
|
|
|
cp('-R', SWAGGER_UI_DIST, TARGET_DIR + '/swagger-ui/')
|
2022-04-05 10:30:10 +00:00
|
|
|
// sed('-i', 'http://petstore.swagger.io/v2/swagger.json', '../swagger.json', TARGET_DIR + '/swagger-ui/index.html')
|