UNPKG

@simbachain/truffle

Version:
150 lines 6.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.pull = exports.handler = exports.builder = exports.describe = exports.command = void 0; /* eslint-disable */ const web3_suites_1 = require("@simbachain/web3-suites"); const chalk_1 = __importDefault(require("chalk")); exports.command = 'pull'; exports.describe = 'pull contract from Blocks and sync in your local project'; exports.builder = { 'id': { 'string': true, 'type': 'string', 'describe': 'design_id for the contract you want to pull from Blocks to your local project', }, 'contractname': { 'string': true, 'type': 'string', 'describe': 'contract name that you want to pull from Blocks to your local project', }, 'pullsourcecode': { 'string': true, 'type': 'boolean', 'describe': 'true/false, as to whether you want to pull source code to simba.json when pulling. defaults to true, and usually should not be changed to false.', 'default': true, }, 'pullsolfiles': { 'string': true, 'type': 'boolean', 'describe': 'true/false, as to whether you want to pull .sol files to your /contracts/ folder during pull', 'default': false, }, 'interactive': { 'string': true, 'type': 'boolean', 'describe': 'true/false, as to whether you want to pull interactively (ie choose which contract .sol files you want to pull)', 'default': false, }, 'usesimbapath': { 'string': true, 'type': 'boolean', 'describe': 'true/false, as to whether you want to pull your SIMBA remote .sol files to contracts/SimbaImports/ dir', 'default': true, }, }; /** * for syncing contractX from your org in simbachain.com with contractX in your project * @param args * args: * args.designID * args.contractName * args.pullSourceCode * args.pullSolFiles * args.interactive * args.useSimbaPath * @returns */ exports.handler = async (args) => { web3_suites_1.SimbaConfig.log.debug(`:: ENTER : ${JSON.stringify(args)}`); const designID = args.id; let interactive = args.interactive; const contractName = args.contractname; let pullSolFiles = args.pullsolfiles; let pullSourceCode = args.pullsourcecode; let useSimbaPath = args.usesimbapath; web3_suites_1.SimbaConfig.log.debug(`:: ENTER : ${JSON.stringify(args)}`); await pull(designID, contractName, pullSourceCode, pullSolFiles, interactive, useSimbaPath); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; }; /** * when pulling your contracts from your blocks organisation, you can "pull" them * into two locations: your local contracts folder (or contracts/simbaimports), and/or * your simba.json * * pulling makes sure that, when working with teams, everyone is working * with the most recent versions of contracts that have been exported to blocks * @param designID * @param contractName * @param pullSourceCode - pull source code to your simba.json * @param pullSolFiles - pull .sol files to your contracts or contracts/simbaimports directory * @param interactive * @param useSimbaPath - pull to contracts/simbaimports * @returns */ async function pull(designID, contractName, pullSourceCode = true, pullSolFiles = false, interactive = false, useSimbaPath = true) { const entryParams = { designID, contractName, pullSourceCode, pullSolFiles, interactive, useSimbaPath, }; web3_suites_1.SimbaConfig.log.debug(`:: ENTER : entryParams : ${JSON.stringify(entryParams)}`); if (designID && contractName) { const message = `${chalk_1.default.redBright(`\nsimba: designid and contractname were both specified. Only one of these parameters can be passed.`)}`; web3_suites_1.SimbaConfig.log.error(message); return; } if (designID && interactive) { const message = `${chalk_1.default.redBright(`\nsimba: designid cannot be specified in interactive mode.`)}`; web3_suites_1.SimbaConfig.log.error(message); return; } if (contractName && interactive) { const message = `${chalk_1.default.redBright(`\nsimba: contractname cannot be specified in interactive mode.`)}`; web3_suites_1.SimbaConfig.log.error(message); return; } if (designID) { const contractDesign = await web3_suites_1.pullContractFromDesignId(designID, useSimbaPath); if (pullSourceCode && contractDesign) { web3_suites_1.pullSourceCodeForSimbaJson(contractDesign); } web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } if (contractName) { if (pullSolFiles && pullSourceCode) { await web3_suites_1.pullMostRecentFromContractName(contractName, undefined, useSimbaPath); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } if (pullSolFiles) { await web3_suites_1.pullMostRecentRecentSolFileFromContractName(contractName, undefined, useSimbaPath); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } if (pullSourceCode) { await web3_suites_1.pullMostRecentSourceCodeFromContractName(contractName); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } // default to pulling sol files and source code for simba.json await web3_suites_1.pullMostRecentFromContractName(contractName, undefined, useSimbaPath); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } if (interactive) { pullSolFiles = true; } await web3_suites_1.pullAllMostRecentSolFilesAndSourceCode(pullSourceCode, pullSolFiles, interactive, useSimbaPath); web3_suites_1.SimbaConfig.log.debug(`:: EXIT :`); return; } exports.pull = pull; //# sourceMappingURL=pull.js.map