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

abi2oas

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abi2oas - npm Package Compare versions

Comparing version 0.0.5 to 0.0.7

15

index.js
#!/usr/bin/env node
const OpenAPIGenerator = require('./OpenAPIGenerator');
const fs = require('fs');
const path = require('path');
const program = require('commander');
const { errorClose } = require('./util');
const { errorClose, paddedLog } = require('./util');
program
.version('0.0.5')
.version('0.0.7')
.name('abi2oas')

@@ -20,13 +18,10 @@ .description("Autogenerate an Open API JSON corresponding to the functions in a smart contract's ABI. \n Call with the paths to your config file and your desired OpenAPI output file.")

program.on('--help', () => {
console.log('');
console.log(' For more information about configuration and generation, view the abi2oas homepage on GitHub.');
console.log('');
paddedLog(' For more information about configuration and generation, view the abi2oas homepage on GitHub.');
});
if (require.main === module) {
let args = process.argv;
if (args.length-1 !== 2) return errorClose(`abi2oas requires 2 arguments, not ${args.length - 1}.`)
program.parse(args);
if (!process.args || process.args.length !== 2) return errorClose(`abi2oas CLI called with incorrect number of args; it takes 2.`);
program.parse(process.argv);
} else {
module.exports = OpenAPIGenerator;
}

@@ -12,3 +12,3 @@ let fs = require("fs");

const { isJSONFile, isWritable, isString, errorClose } = require('./util');
const { isJSONFile, isString, errorClose, paddedLog } = require('./util');

@@ -115,2 +115,3 @@

}
paddedLog(`Successfully generated OpenAPI JSON for contract "${openAPIObj.info.title}", view result at "${path.resolve(__dirname, file_path)}"`);
return openAPIObj;

@@ -131,4 +132,4 @@ }

}
if (!isString(file_path)) return errorClose("Provided output path was not a string.");
if (!isJSONFile(file_path)) return errorClose(`Specified output file "${file_path}" is not a JSON file.`)
if (!isWritable(path.dirname(file_path))) return errorClose(`Specified output directory "${path.dirname(file_path)}" is not writable.`)

@@ -135,0 +136,0 @@ let generator = new OpenAPIGenerator(config);

{
"name": "abi2oas",
"version": "0.0.5",
"version": "0.0.7",
"description": "Ingests a smart contract's ABI and autogenerates OpenAPI JSON, ready for Swagger codegen.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,12 +1,25 @@

const path = require('path');
const fs = require('fs');
const isString = thing => typeof thing === 'string';
const isJSONFile = thing => path.extname(thing).toLowerCase() === '.json';
const paddedLog = (msg) =>{
console.log("");
console.log(msg);
console.log("");
};
const errorClose = (msg) => {
let errorMsg = `Error: ${msg} Run "abi2oas --help" to see command syntax, or view the README on the GitHub repo.`
paddedLog(errorMsg)
return new Error(errorMsg);
};
module.exports = {
isString : thing => typeof thing === 'string',
isJSONFile : thing => path.extname(thing).toLowerCase() === '.json',
isWritable : dirname => fs.access(dirname, fs.constants.W_OK, err => !!err ),
errorClose : (msg) => {
let errorMsg = `Error: ${msg} Run "abi2oas --help" to see command syntax, or view the README on the GitHub repo.`
console.log("");
console.error(errorMsg);
console.log("");
return new Error(errorMsg);
}
isString : isString,
isJSONFile : isJSONFile,
errorClose : errorClose,
paddedLog : paddedLog
}
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