Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Do the actual Github diff
try {
const path = `${targetApp.repo}/compare/${downstreamApp.hash}...${targetApp.hash}`
const headers: { authorization: string; 'user-agent'?: string} = {authorization: 'token ' + githubToken}
if (herokuUserAgent) {
headers['user-agent'] = herokuUserAgent
}
const githubDiff: any = await HTTP.get(`https://api.github.com/repos/${path}`, {
headers,
}).then(res => res.body)
cli.log('')
cli.styledHeader(`${color.app(targetApp.name)} is ahead of ${color.app(downstreamApp.name)} by ${githubDiff.ahead_by} commit${githubDiff.ahead_by === 1 ? '' : 's'}`)
const mapped = githubDiff.commits.map((commit: any) => {
return {
sha: commit.sha.substring(0, 7),
date: commit.commit.author.date,
author: commit.commit.author.name,
message: commit.commit.message.split('\n')[0],
}
}).reverse()
cli.table(mapped, {
sha: {
header: 'SHA',
},
date: {},
author: {},
message: {},
})
async dispatchEvent(event: optimizely.Event, callback: () => void) {
if (this.config.url) {
event.url = this.config.url
}
event = await (this.config.interactive ? editEvent(event) : Promise.resolve(event))
if (!event) {
cli.info('Event is empty; Aborting dispatch')
return
}
cli.action.start('Dispatching event')
cli.styledHeader('Event')
cli.styledJSON(event)
defaultEventDispatcher.dispatchEvent(event, (resp: any) => {
callback()
cli.action.stop()
if (resp) {
cli.styledHeader('Response')
cli.styledObject(
{
status: resp.statusCode,
headers: resp.headers
},
['status', 'headers']
)
}
})
let {body} = await HTTP.get(host + apiPath)
if (flags.json) {
cli.styledJSON(body)
return
}
for (let item of body.status) {
let message = printStatus(item.status)
this.log(`${(item.system + ':').padEnd(11)}${message}`)
}
for (let incident of body.incidents) {
cli.log()
cli.styledHeader(`${incident.title} ${color.yellow(incident.created_at)} ${color.cyan(incident.full_url)}`)
let padding = maxBy(incident.updates, (i: any) => i.update_type.length).update_type.length + 0
for (let u of incident.updates) {
cli.log(`${color.yellow(u.update_type.padEnd(padding))} ${new Date(u.updated_at).toISOString()} (${distanceInWordsToNow(new Date(u.updated_at))} ago)`)
cli.log(`${u.contents}\n`)
}
}
}
}
async runReplaces (sync_action : SyncAction, override_replace_cache = false) {
const to_env_dbs = await sync_action.to_envs.getDBConfigs()
ux.log()
ux.styledHeader(`Replacing urls`)
ux.log()
for(let from_domain of sync_action.from.app.domains) {
let skip_from_domain = false
for(let to_env of sync_action.to_envs.envs) {
const mutations = [
from_domain.host,
from_domain.host.replace(/ä/ig, 'a').replace(/ö/ig, 'o').replace(/ü/ig, 'u').replace(/ß/ig, 'ss')
]
let replacements = []
for(let mut of mutations) {
replacements.push({
prefix : "https", host : mut
})
replacements.push({
export default async function renderPipeline(
heroku: APIClient,
pipeline: Heroku.Pipeline,
pipelineApps: Array,
{withOwners, showOwnerWarning} = {withOwners: false, showOwnerWarning: false}) {
cli.styledHeader(pipeline.name!)
let owner
if (pipeline.owner) {
owner = await getOwner(heroku, pipelineApps, pipeline)
cli.log(`owner: ${owner}`)
}
cli.log('')
const columns: Table.table.Columns = {
name: {
header: 'app name',
get(row) {
return color.app(row.name || '')
},
async confirmProcess (sync_action : SyncAction) {
ux.log()
ux.styledHeader("Confirmation")
ux.log()
ux.log(`Operations that are about to be done:`)
for(let to_env of sync_action.to_envs.envs) {
ux.log(` - From ${Colors.env(sync_action.from.name, sync_action.from.app.name)} -> ${Colors.env(to_env.name, (!(to_env.app instanceof LocalApp)) ? to_env.app.name : null)}`)
}
ux.log()
if(!await ux.confirm(`Are you sure you want to do this?`)) {
ux.error(`Cancelled the operation.`)
}
}
async run() {
const {flags} = this.parse(Pipelines)
const {body: pipelines} = await this.heroku.get('/pipelines')
if (flags.json) {
cli.styledJSON(pipelines)
} else {
cli.styledHeader('My Pipelines')
for (const pipeline of pipelines) {
cli.log(pipeline.name)
}
}
}
}
async run() {
const {flags} = this.parse(DomainsIndex)
const {body: domains} = await this.heroku.get>(`/apps/${flags.app}/domains`)
const herokuDomain = domains.find(domain => domain.kind === 'heroku')
const customDomains = domains.filter(domain => domain.kind === 'custom')
if (flags.json) {
cli.styledJSON(domains)
} else {
cli.styledHeader(`${flags.app} Heroku Domain`)
cli.log(herokuDomain && herokuDomain.hostname)
if (customDomains && customDomains.length > 0) {
cli.log()
cli.styledHeader(`${flags.app} Custom Domains`)
cli.table(customDomains, {
hostname: {header: 'Domain Name'},
kind: {header: 'DNS Record Type', get: domain => {
if (domain.hostname) {
return isApexDomain(domain.hostname) ? 'ALIAS or ANAME' : 'CNAME'
}
}},
cname: {header: 'DNS Target'},
acm_status: {header: 'ACM Status', extended: true},
acm_status_reason: {header: 'ACM Status', extended: true}
}, {
...flags,
'no-truncate': true
})
}
}