@dethcrypto/eth-sdk
Version:
🛠Generate type-safe, lightweight SDK for your Ethereum smart contracts
48 lines • 1.91 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
const chalk_1 = __importDefault(require("chalk"));
const debug_1 = __importDefault(require("debug"));
const ora_1 = __importDefault(require("ora"));
const path_1 = require("path");
const abi_management_1 = require("./abi-management");
const client_1 = require("./client");
const config_1 = require("./config");
const parseArgs_1 = require("./parseArgs");
const formatError_1 = require("./peripherals/formatError");
const fs_1 = require("./peripherals/fs");
const d = (0, debug_1.default)('@dethcrypto/eth-sdk:cli');
async function main() {
const cwd = process.cwd();
let ctx;
try {
const cliArgs = (0, parseArgs_1.parseArgs)({ argv: process.argv, cwd });
const fs = fs_1.realFs;
d('Parsed args', cliArgs);
const configPath = (0, config_1.findConfigFile)(cliArgs, fs);
const config = await (0, config_1.readConfig)(configPath, require);
ctx = { cliArgs, config, fs };
}
catch (error) {
console.error((0, formatError_1.formatError)(error));
process.exit(1);
}
console.log(`Loaded sdk definition from ${chalk_1.default.green(ctx.cliArgs.workingDirPath)}`);
await spin('Getting ABIs', (0, abi_management_1.gatherABIs)(ctx));
await spin('Generating client', (0, client_1.generateSdk)(ctx));
console.log(`SDK generated to: ${(0, path_1.relative)(cwd, ctx.config.outputPath)}`);
}
exports.main = main;
async function spin(text, promise) {
ora_1.default.promise(promise, { text, spinner: 'dots3', color: 'magenta' });
return await promise;
}
main().catch((error) => {
console.error(error);
process.exit(1);
});
//# sourceMappingURL=cli.js.map