openapi-merge-cli
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -12,2 +12,3 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const data_1 = require("openapi-merge/dist/data"); | ||
@@ -21,3 +22,16 @@ const ERROR_LOADING_CONFIG = 1; | ||
.option('-c, --config <config_file>', 'The path to the configuration file for the merge tool.'); | ||
function convertInputs(configInputs) { | ||
class LogWithMillisDiff { | ||
constructor() { | ||
this.prevTime = this.currTime = this.getCurrentTimeMillis(); | ||
} | ||
log(input) { | ||
this.currTime = this.getCurrentTimeMillis(); | ||
console.log(`${input} (+${this.currTime - this.prevTime}ms)`); | ||
this.prevTime = this.currTime; | ||
} | ||
getCurrentTimeMillis() { | ||
return new Date().getTime(); | ||
} | ||
} | ||
function convertInputs(basePath, configInputs, logger) { | ||
const results = []; | ||
@@ -27,3 +41,5 @@ for (let inputIndex = 0; inputIndex < configInputs.length; inputIndex++) { | ||
try { | ||
const rawData = JSON.parse(fs_1.default.readFileSync(input.inputFile).toString('utf-8')); | ||
const fullPath = path_1.default.join(basePath, input.inputFile); | ||
logger.log(`## Loading input ${inputIndex}: ${fullPath}`); | ||
const rawData = JSON.parse(fs_1.default.readFileSync(fullPath).toString('utf-8')); | ||
results.push({ | ||
@@ -42,2 +58,3 @@ oas: rawData, | ||
function main() { | ||
const logger = new LogWithMillisDiff(); | ||
program.parse(process.argv); | ||
@@ -50,4 +67,5 @@ const config = load_configuration_1.loadConfiguration(program.config); | ||
} | ||
console.log(JSON.stringify(config)); | ||
const inputs = convertInputs(config.inputs); | ||
logger.log(`## Loaded the configuration: ${config.inputs.length} inputs`); | ||
const basePath = path_1.default.dirname(program.config || './'); | ||
const inputs = convertInputs(basePath, config.inputs, logger); | ||
if (typeof inputs === 'string') { | ||
@@ -58,2 +76,3 @@ console.error(inputs); | ||
} | ||
logger.log(`## Loaded the inputs into memory, merging the results.`); | ||
const mergeResult = openapi_merge_1.merge(inputs); | ||
@@ -65,5 +84,8 @@ if (data_1.isErrorResult(mergeResult)) { | ||
} | ||
fs_1.default.writeFileSync(config.output, JSON.stringify(mergeResult.output, null, 2)); | ||
const outputFullPath = path_1.default.join(basePath, config.output); | ||
logger.log(`## Inputs merged, writing the results out to '${outputFullPath}'`); | ||
fs_1.default.writeFileSync(outputFullPath, JSON.stringify(mergeResult.output, null, 2)); | ||
logger.log(`## Finished writing to '${outputFullPath}'`); | ||
} | ||
exports.main = main; | ||
main(); |
{ | ||
"name": "openapi-merge-cli", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A cli tool for the openapi-merge library.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
14432
15
248
0
54