Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-merge-cli

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-merge-cli - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

README.md

32

dist/index.js

@@ -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();

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc