Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var path = require('path');
var resolve = require('resolve');
var program = require('commander');
var chalk = require('chalk');
var semver = require('semver');
var updateNotifier = require('./update-notifier');
var pkg = require('../package.json');
var argvs = process.argv;
var command = argvs[2];
// check nodejs version
if (!semver.satisfies(process.version, pkg.engines.node)) {
console.log(chalk.red.bold('Require nodejs version ' + pkg.engines.node + ', current ' + process.version));
console.log('Download the latest nodejs here ' + chalk.green('https://nodejs.org/en/download/'));
process.exit();
}
// program definiation
program
.version(pkg.version)
.usage(' [options]');
// dirs to find plugins
var moduleDirs = [
path.join(__dirname, '..', 'node_modules'),
path.join(__dirname, '..', '..')
];
program._moduleDirs = moduleDirs;
// locate the plugin
function parserFunction(className, key, fileName) {
if(debug) console.log('parsing: '+chalk.blue(className)+' '+chalk.cyan(key)+' '+chalk.green(fileName))
// checking if function already exists, if not also add name without class
if(className == 'function') {
parserAbstractFunction(key, fileName);
parserAbstractFunction('function.'+key, fileName);
}
else if(className != 'class') {
parserAbstractFunction(className + '.' + key, fileName, className);
}
if( typeof mapping[key] == 'undefined' && !fs.existsSync(DOC_DIR + '/function.' + key + '.html') ) {
mapping[key] = 1;
parserAbstractFunction(key, fileName);
}
}
async function buildHTML(state) {
const {
routes,
config: { paths, maxThreads },
} = state
time(chalk.green('[\u2713] HTML Exported'))
// in case of an absolute path for DIST we must tell node to load the modules
// from our project root
if (!paths.DIST.startsWith(paths.ROOT)) {
process.env.NODE_PATH = paths.NODE_MODULES
require('module').Module._initPaths()
}
// Single threaded export
if (maxThreads <= 1) {
console.log('Exporting HTML...')
await require('./exportRoutes.sync').default(state)
} else {
// Multi-threaded export
const threads = Math.min(cores, maxThreads)
const htmlProgress = progress(routes.length)
// Get the site props
const siteData = await config.getSiteData({ dev: true })
// Resolve the base HTML template
const Component = config.Document || DefaultDocument
// Render an index.html placeholder
await createIndexFilePlaceholder({
config,
Component,
siteData,
})
// Build the dynamic routes file (react-static-routes)
if (!silent) console.log('=> Building Routes...')
console.time(chalk.green('=> [\u2713] Routes Built'))
await prepareRoutes(config, { dev: true })
console.timeEnd(chalk.green('=> [\u2713] Routes Built'))
// Build the JS bundle
await startDevServer({ config })
}
api.getUserInfo(msg.senderID, (err, uinfo) => {
// If there are attachments, grab their URLs to render them as text instead
const atts = msg.attachments.map(a => a.url || a.facebookUrl).filter(a => a);
const atext = atts.length > 0 ? `${msg.body} [${atts.join(", ")}]` : msg.body;
// Log the incoming message and reset the prompt
const name = getTitle(tinfo, uinfo);
newPrompt(`${chalk.blue(uinfo[msg.senderID].firstName)} in ${chalk.green(name)} ${atext}`, rl);
// Show up the notification for the new incoming message
notifier.notify({
"title": 'Messenger CLI',
"message": `New message from ${name}`,
"icon": path.resolve(__dirname, 'assets', 'images', 'messenger-icon.png')
});
});
});
Initializer.prototype.init = function () {
console.log(chalk.green('Initializing new project...'));
this.extractTemplateFile('package.json');
};
Initializer.prototype.extractTemplateFile = function (filename) {
let validData = parsedData.filter(row =>
web3.utils.isAddress(row[0]) &&
!isNaN(row[1])
);
let invalidRows = parsedData.filter(row => !validData.includes(row));
if (invalidRows.length > 0) {
console.log(chalk.red(`The following lines from csv file are not valid: ${invalidRows.map(r => parsedData.indexOf(r) + 1).join(',')} `));
}
let batches = common.splitIntoBatches(validData, 100);
let [investorArray, taxArray] = common.transposeBatches(batches);
for (let batch = 0; batch < batches.length; batch++) {
taxArray[batch] = taxArray[batch].map(t => web3.utils.toWei((t / 100).toString()));
console.log(`Batch ${batch + 1} - Attempting to set multiple tax rates to accounts: \n\n`, investorArray[batch], '\n');
let action = await currentDividendsModule.methods.setWithholding(investorArray[batch], taxArray[batch]);
let receipt = await common.sendTransaction(action);
console.log(chalk.green('Multiple tax rates have benn set successfully!'));
console.log(`${receipt.gasUsed} gas used.Spent: ${web3.utils.fromWei((new web3.utils.BN(receipt.gasUsed)).mul(new web3.utils.BN(defaultGasPrice)))} ETH`);
}
}
}
);
const parsedSchema = parseSchema(
fs.readFileSync(path.resolve(config.schemaPath), 'utf8'),
config
);
console.log(
chalk.yellow(
`Generating ${config.mode === 'FLOW' ? 'Flow' : 'TypeScript'} assets...`
)
);
generateAssets(config, parsedSchema);
console.log(chalk.green('Done!'));
bb.startWatchProcess((allFiles) => {
console.log(chalk.green("Starting compilation."));
return compileProcess
.refresh(allFiles)
.then(forceInteractiveRecompile);
});
});
if (await isIdAssigned(aragonId, options)) {
throw Error(`${aragonId} is already assigned.`)
}
},
},
{
title: 'Assigning Id',
task: async () => assignId(dao, aragonId, { ...options, gasPrice }),
},
],
listrOpts(silent, debug)
)
await tasks.run()
reporter.newLine()
reporter.success(`${green(aragonId)} successfully assigned to ${dao}`)
}