Skip to content

Commit

Permalink
fix: default env to master (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya authored Jul 26, 2018
1 parent f7973b3 commit af94ffe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const run = async function (argv) {
const batches = parseResult.batches

if (parseResult.hasValidationErrors()) {
renderValidationErrors(batches)
renderValidationErrors(batches, argv.environmentId)
process.exit(1)
}

Expand All @@ -99,7 +99,7 @@ const run = async function (argv) {
process.exit(1)
}

await renderPlan(batches)
await renderPlan(batches, argv.environmentId)

const serverErrorsWritten = []

Expand Down
2 changes: 1 addition & 1 deletion src/bin/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getEnvConfig (): ClientConfig {
{}
}

function getArgvConfig ({spaceId, environmentId, accessToken}): ClientConfig {
function getArgvConfig ({spaceId, environmentId = 'master', accessToken}): ClientConfig {
const config = {
spaceId,
environmentId,
Expand Down
7 changes: 4 additions & 3 deletions src/bin/lib/render-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const renderBatch = function (batch: RequestBatch) {
console.log(message.join('\n'))
}

const renderPlan = (batches: RequestBatch[]) => {
const renderPlan = (batches: RequestBatch[], environment: string) => {
console.log(chalk`{bold.green The following migration has been planned}\n`)
console.log(chalk`{bold.underline Environment}: {bold.yellow ${environment}}\n`)
for (const batch of batches) {
renderBatch(batch)

Expand All @@ -37,9 +38,9 @@ const renderPlan = (batches: RequestBatch[]) => {
}
}

const renderValidationErrors = (batches: RequestBatch[]) => {
const renderValidationErrors = (batches: RequestBatch[], environment: string) => {
console.error(chalk`{bold.red The following migration has been planned but cannot be run because it contains errors}\n\n`)
renderPlan(batches)
renderPlan(batches, environment)
console.error(chalk`🚨 {bold.red Migration unsuccessful}`)
}

Expand Down

0 comments on commit af94ffe

Please sign in to comment.