Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!coupling) {
cli.error(`This app (${targetAppName}) does not seem to be a part of any pipeline`)
return
}
const targetAppId = coupling.app!.id!
cli.action.start('Fetching apps from pipeline')
const allApps = await listPipelineApps(this.heroku, coupling.pipeline!.id!)
cli.action.stop()
const sourceStage = coupling.stage
if (!sourceStage) {
return cli.error(`Unable to diff ${targetAppName}`)
}
const downstreamStage = PROMOTION_ORDER[PROMOTION_ORDER.indexOf(sourceStage) + 1]
if (!downstreamStage || PROMOTION_ORDER.indexOf(sourceStage) < 0) {
return cli.error(`Unable to diff ${targetAppName}`)
}
const downstreamApps = allApps.filter(function (app) {
return app.coupling.stage === downstreamStage
})
if (downstreamApps.length === 0) {
return cli.error(`Cannot diff ${targetAppName} as there are no downstream apps configured`)
}
// Fetch GitHub repo/latest release hash for [target, downstream[0], .., downstream[n]] apps
try {
({compiled, importedFiles} = await c.solidity(contractFile, contractFileContent, solcVersion))
// Check if the contract exists
if (!(contractName in compiled.contracts[contractFile])) {
cli.error(`Contract ${contractName} not found.`)
cli.action.stop('failed')
return
}
} catch (error) {
if (error.message !== undefined) {
cli.error(error.message, {exit: false})
}
if (error.errors !== undefined) {
for (let err of error.errors) {
cli.error(err.formattedMessage, {exit: false})
}
}
cli.action.stop('failed')
return
}
if (compiled.errors !== undefined) {
for (let warning of compiled.errors) {
cli.warn(warning.formattedMessage)
}
}
cli.action.stop('done')
// Analyze the contract code
cli.action.start(`Analyzing contract ${contractName}`)
sshProc.on('close', () => {
// there was a problem connecting with the ssh key
if (lastErr.length > 0 && lastErr.includes('Permission denied')) {
cli.error('There was a problem connecting to the dyno.')
if (process.env.SSH_AUTH_SOCK) {
cli.error('Confirm that your ssh key is added to your agent by running `ssh-add`.')
}
cli.error('Check that your ssh key has been uploaded to heroku with `heroku keys:add`.')
cli.error(`See ${color.cyan('https://devcenter.heroku.com/articles/one-off-dynos#shield-private-spaces')}`)
}
// cleanup local server
localServer.close()
})
this.p
sshProc.on('close', () => {
// there was a problem connecting with the ssh key
if (lastErr.length > 0 && lastErr.includes('Permission denied')) {
cli.error('There was a problem connecting to the dyno.')
if (process.env.SSH_AUTH_SOCK) {
cli.error('Confirm that your ssh key is added to your agent by running `ssh-add`.')
}
cli.error('Check that your ssh key has been uploaded to heroku with `heroku keys:add`.')
cli.error(`See ${color.cyan('https://devcenter.heroku.com/articles/one-off-dynos#shield-private-spaces')}`)
}
// cleanup local server
localServer.close()
})
this.p
cli.action.start(`Compiling contract ${contractFile}`)
const c = new Compiler()
let compiled
let importedFiles
try {
({compiled, importedFiles} = await c.solidity(contractFile, contractFileContent, solcVersion))
// Check if the contract exists
if (!(contractName in compiled.contracts[contractFile])) {
cli.error(`Contract ${contractName} not found.`)
cli.action.stop('failed')
return
}
} catch (error) {
if (error.message !== undefined) {
cli.error(error.message, {exit: false})
}
if (error.errors !== undefined) {
for (let err of error.errors) {
cli.error(err.formattedMessage, {exit: false})
}
}
cli.action.stop('failed')
return
}
if (compiled.errors !== undefined) {
for (let warning of compiled.errors) {
cli.warn(warning.formattedMessage)
}
}
async exec(args: string[]): Promise {
debug('exec: git %o', args)
try {
const {stdout, stderr} = await execFile('git', args)
if (stderr) process.stderr.write(stderr)
return stdout.trim()
} catch (err) {
if (err.code === 'ENOENT') {
ux.error('Git must be installed to use the Heroku CLI. See instructions here: http://git-scm.com')
}
throw err
}
}
async handleMultipleEnvs () {
ux.warn(`There is multiple db env variables defined (${this.constructEnvList(this.db_envs)}), which one is it?`)
while(!this.db_env_name.length) {
const db_env_name = await ux.prompt(`The db env variable name`) as string
if(!this.hasAppEnv(db_env_name)) {
ux.warn(`That env variable name (${Colors.env(db_env_name)}) doesn't exist in app (${Colors.app(this.name)})`);
if(!(await ux.confirm("Want to to try again?"))) {
ux.error(`Ok, cannot resolve the db env variable name, so quitting.`)
}
} else {
this.db_env_name = db_env_name
}
}
return true
}
static async toolExists () {
if(!commandExists.sync("mysql")) {
ux.error(`It seems that ${Colors.cmd("mysql")} -command doesn't exist! Have you installed mysql?`)
}
if(!commandExists.sync("mysqldump")) {
ux.error(`It seems that ${Colors.cmd("mysqldump")} -command doesn't exist! Have you installed mysql?`)
}
}
async getEnvWithName (name : string) {
for(let env of this.environments) {
if(env.name == name) {
return env
}
}
ux.error(`Could not find environment with the name ${name}.`)
}
async handleEnvNotRecognized () {
ux.warn(`Could not find any of the recognized db env variable names in the app ${Colors.app(this.name)}.`);
ux.warn(`These are the searched db env variable names: ${this.constructEnvList(this.db_envs)}`);
ux.log();
while(!this.db_env_name) {
const input_variable_name = await ux.confirm("Do you want to input the db environment variable name? ")
if(!input_variable_name) {
ux.error(`Ok, cannot resolve the db env variable name, so quitting.`)
return false
}
const new_env = await ux.prompt(`Type in the env variable in the app ${Colors.app(this.name)}`)
const exists = await this.hasAppEnv(new_env);
if(!exists) {
ux.warn(`The ${Colors.app(new_env)} -app doesn't have that env variable .`);
continue
}
this.db_env_name = new_env;
}
return true