Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try catch around cdk bootstrap to catch deletion rejections #225

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build || echo 'Warning: @casimir/web build failed because script + dependency issues are unresolved. Disregard this warning and any listed errors above if @casimir/web is not needed for the current project build.' && exit 0",
"build": "vue-tsc --noEmit && vite build || echo '@casimir/web build failed because script + dependency issues are unresolved. Disregard any errors listed above this line.' && exit 0",
"preview": "vite preview"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions infrastructure/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"pretest": "export PROJECT=casimir && export STAGE=test",
"test": "jest",
"cdk:bootstrap": "npx cdk bootstrap",
"cdk:metadata": "npx cdk metadata",
"cdk:synth": "npx cdk synth --no-staging"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions scripts/ethereum/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { $, argv, echo, chalk } from 'zx'
import { getSecret } from '@casimir/aws-helpers'
import { getWallet } from '@casimir/ethers-helpers'

/**
* Run local a local Ethereum node and deploy contracts
Expand Down Expand Up @@ -30,7 +29,7 @@ void async function () {
}

// Enable 12-second interval mining for dev networks
process.env.INTERVAL_MINING = 'false'
process.env.INTERVAL_MINING = 'true'

// Using hardhat local or fork network
process.env.MOCK_CHAINLINK = 'true'
Expand Down
20 changes: 14 additions & 6 deletions scripts/local/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ const forks = {
}
}

console.log('Profile', process.env.PROFILE)

/** The name of the CDK project */
const project = process.env.PROJECT || 'casimir'

/** The default development stage of the CDK project */
const stage = process.env.STAGE || 'dev'

/** Pascal case representations of CDK variables */
const Project = pascalCase(project as string)
const Stage = pascalCase(stage as string)

/**
* Run a Casimir dev server
*
Expand Down Expand Up @@ -78,17 +84,19 @@ void async function () {
const infrastructure = apps[app as keyof typeof apps].infrastructure
const services = apps[app as keyof typeof apps].services

await $`npm run cdk:bootstrap --workspace @casimir/cdk`
/** Skip bootstrap if stack exists for current stage (and cdk:bootstrap throws) */
try {
await $`npm run cdk:bootstrap --workspace @casimir/cdk`
} catch {
echo(chalk.bgBlackBright('CDK Toolkit stack for ') + chalk.bgBlue(`${Project}${Stage}`) + chalk.bgBlackBright(' was already bootstrapped. Disregard any CDK errors listed above this line.'))
}
await $`npm run cdk:synth --workspace @casimir/cdk`

let port = 4000
for (const service of services) {
process.env[`PUBLIC_${service.toUpperCase()}_PORT`] = `${port}`

$`npm run watch --workspace @casimir/${service}`

const Project = pascalCase(process.env.PROJECT as string)
const Stage = pascalCase(process.env.STAGE as string)
const Service = pascalCase(service)

try {
Expand All @@ -103,8 +111,8 @@ void async function () {
--warm-containers "LAZY" \
--port ${port} \
--template infrastructure/${infrastructure}/cdk.out/${Project}${Service}Stack${Stage}.template.json \
--log-file "services/${service}/mock-logs.txt"` // \
// --profile ${'consensus-networks-dev'}`
--log-file "services/${service}/mock-logs.txt" \
--profile ${process.env.PROFILE || 'consensus-networks-dev'}`

++port
}
Expand Down