Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Make default config
let config = webpackProdConfig(env)
// Merge custom config
try {
config = require(path.join(env.CONFIG_DIR, 'webpack.config.prod.js'))(config, env)
} catch (err) {
}
const compiler = webpack(config)
let sizeMap = null
let buildStats = null
const tasks = new Listr([{
title: 'Build',
task: () => new Listr([{
title: 'Prepare resources',
task: async () => {
sizeMap = await calcSizeMap(env.BUILD_DIR)
}
}, {
title: 'Clean build folder',
task: async () => rimraf.sync(env.BUILD_DIR + '/*')
}, {
title: 'Compile static resources',
task: () => new Promise((resolve, reject) =>
compiler.run(async (err, stats) => {
if (err) reject(err)
if (stats.compilation.errors.length) reject(stats.compilation.errors)
buildStats = stats
async function initInDirectory (print, destPath, database) {
const templatePath = path.resolve(__dirname, '..', '..', 'template')
const dbDriverPackage = getDbDriverPackage(database)
const generatedFiles = [ '.env' ]
const optionalGeneratedFiles = [ '.gitignore' ]
const templateFiles = await recursiveFileList(templatePath)
const packageJsonPath = await locateOrCreatePackageJson(destPath, print)
print('') // just for the newline
await new Listr([
step('Copy boilerplate files', async () => {
await assertFilesCanBeCopied(destPath, templateFiles.concat(generatedFiles))
await copyTemplate(templatePath, templateFiles, destPath)
}),
step('Create .gitignore & .env file', async () => {
await createDotFiles(destPath, { database })
}),
step('Update package.json', async () => {
await patchPackageJson(packageJsonPath, path.join(destPath, 'store.js'), path.join(destPath, 'server.js'))
}),
step('Install dependencies', async () => {
const packages = templateDependencies.concat([ dbDriverPackage ])
await installPackages(packages, destPath)
})
]).run()
}
// Decode sender
const accounts = await web3.eth.getAccounts()
const from = accounts[0]
// Get chain id
const chainId = await web3.eth.net.getId()
if (chainId === 1)
tokenFactoryAddress = tokenFactoryAddress || MAINNET_MINIME_TOKEN_FACTORY
if (chainId === 4)
tokenFactoryAddress = tokenFactoryAddress || RINKEBY_MINIME_TOKEN_FACTORY
transferEnabled = parseArgumentStringIfPossible(transferEnabled)
return new TaskList(
[
{
title: 'Deploy the MiniMeTokenFactory contract',
enabled: () => !web3Utils.isAddress(tokenFactoryAddress),
task: async (ctx, task) => {
const handleProgress = (step, data) => {
switch (step) {
case 1:
task.output = 'Estimating gas...'
break
case 2:
task.output = `Estimated gas: ${data}`
break
case 3:
task.output = 'Waiting for the transaction to be mined...'
break
try {
await access(jsonFileDir, fs.constants.R_OK);
if (jsFile) {
await access(jsFile, fs.constants.R_OK);
}
} catch (err) {
console.error(
"%s does not exist or invalid or no permission to read",
chalk.red.bold("ERROR")
);
process.exit(1);
}
const tasks = new Listr(
[
{
title: "Generating Sdk...",
task: () => generateSDK(options)
}
],
{
exitOnError: false
}
);
await tasks.run();
console.log(
`
%s sdk folder generated successfully with required files
if (options.skipConfirmation) {
return { applyMigration: true }
}
return inquirer.prompt([{
type: 'confirm',
message: 'Do you want to apply the migration',
name: 'applyMigration'
}])
}
const answers = await confirm({ skipConfirmation: argv.yes })
if (answers.applyMigration) {
try {
const successfulMigration = await (new Listr(tasks)).run()
console.log(chalk`🎉 {bold.green Migration successful}`)
return successfulMigration
} catch (err) {
console.error(chalk`🚨 {bold.red Migration unsuccessful}`)
console.error(chalk`{red ${err.message}}\n`)
err.errors.forEach((err) => console.error(chalk`{red ${err}}\n\n`))
await Promise.all(serverErrorsWritten)
console.error(`Please check the errors log for more details: ${errorsFile}`)
terminate(err)
}
} else {
console.warn(chalk`⚠️ {bold.yellow Migration aborted}`)
}
}
export const handler = async function({
reporter,
gasPrice,
network,
tokenAddress,
newController,
silent,
debug,
}) {
const web3 = await ensureWeb3(network)
let txReceipt
const tasks = new TaskList(
[
{
title: 'Changing the MiniMe token controller',
task: async () => {
txReceipt = await changeController(
web3,
tokenAddress,
newController,
gasPrice
)
},
},
],
listrOpts(silent, debug)
)
export const task = async ({ port, reset, silent, debug }) => {
return new TaskList(
[
{
title: 'Check port',
task: async ctx => {
ctx.portTaken = await isPortTaken(port)
if (ctx.portTaken) {
const processData = await find('port', port)
ctx.processID = processData[0].pid
}
},
},
{
title: 'Kill running process',
enabled: ctx => ctx.portTaken && reset,
task: async ctx => {
await execa('kill', [ctx.processID])
export async function task({
dao,
app,
method,
params,
apm,
web3,
wsProvider,
gasPrice,
silent,
debug,
}) {
return new TaskList(
[
{
title: `Executing ${method} on ${dao}`,
task: async (ctx, task) => {
const progressHandler = progress => {
switch (progress) {
case 1:
task.output = `Generating transaction`
break
case 2:
task.output = `Sending transaction`
break
}
}
Object.assign(
export async function deploy (args) {
if (args.dangerDeleteResources) {
danger(
stripIndent`
\n
DANGER: You have used the '--danger-delete-resources' flag so, as part of this stack update
your DynamoDB Tables and/or S3 Buckets may be deleted, including all of its content.
\n
`
);
}
const tasks = new Listr(
[
{
title: 'validating configuration',
task: ctx => {
const {
API_DEFINITIONS,
APP_NAME,
getCloudFrontSettings,
getHostedZoneId,
PROJECT_ROOT,
SETTINGS
} = loadConfig();
const {
appStage,
dangerDeleteResources = false,
function sync(): Listr {
return new Listr([
{
title: 'Collecting package keys',
task: async (ctx: SyncContext) => {
ctx.packageKeys = [];
for (const workspace of Object.keys(workspaceMappings)) {
const workspaceDir = path.resolve(BASE_DIR, 'packages', workspace);
for (const packageName of await fs.readdir(path.resolve(workspaceDir))) {
const packageKey = workspaceMappings[workspace][packageName] || packageName;
ctx.packageKeys.push([workspace, workspaceDir, packageKey, packageName]);
}
}
},
},