UNPKG

create-tezos-smart-contract

Version:

Node.js toolset to write, test and deploy Tezos smart contracts

40 lines (39 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compile = exports.addCompileCommand = void 0; const console_1 = require("../../console"); const bundle_1 = require("../../modules/bundle"); const ligo_1 = require("../../modules/ligo"); const parameters_1 = require("../../modules/ligo/parameters"); const addCompileCommand = (program, debugHook) => { program .command('compile') .description('Compile contract(s) using LIGO compiler.') .option('-c, --contract <contract>', 'Compile a single smart contract source file') .option('-l, --ligo-version <version>', `Choose a specific LIGO version. Default is "${ligo_1.DEFAULT_LIGO_VERSION}"`) .option('-f, --force', 'Force the compilation avoiding LIGO version warnings') .action((options) => { (0, exports.compile)(options); }) .hook('preAction', debugHook); }; exports.addCompileCommand = addCompileCommand; // Run LIGO compiler const compile = async (options) => { (0, console_1.em)(`Compiling contracts...\n`); // Read configfile const contractsBundle = new bundle_1.ContractsBundle((0, console_1.getCWD)()); const { ligoVersion } = await contractsBundle.readConfigFile(); // Extract the needed settings, with typecheck const compilerConfig = { ligoVersion, }; // Validate versions if (options.ligoVersion) { options.ligoVersion = (0, parameters_1.toLigoVersion)(options.ligoVersion); } // Build final options const compilerOptions = Object.assign({}, compilerConfig, options); await (0, ligo_1.compileWithLigo)(contractsBundle, compilerOptions); }; exports.compile = compile;