Skip to content

Commit

Permalink
Move users db clean to service script
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Oct 19, 2023
1 parent 3323e41 commit 5ce68b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
13 changes: 0 additions & 13 deletions scripts/root/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,4 @@ void async function () {
} else {
run('npm run dev --workspace @casimir/web')
}

if (process.env.MOCK_SERVICES === 'true') {
process.on('SIGINT', () => {
const mocked: string[] = []
if (process.env.MOCK_SERVICES === 'true') mocked.push(...Object.keys(services))
const cleaners = mocked.map(mock => `npm run clean --workspace @casimir/${mock}`).join(' & ')
if (cleaners.length) {
console.log(`\n🧹 Cleaning up: ${mocked.map(mock => `@casimir/${mock}`).join(', ')}`)
runSync(`${cleaners}`)
}
process.exit()
})
}
}()
9 changes: 8 additions & 1 deletion services/users/scripts/db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import os from 'os'
import { run } from '@casimir/shell'
import { run, runSync } from '@casimir/shell'
import { getSecret, loadCredentials } from '@casimir/aws'
import { JsonSchema, Schema, accountSchema, nonceSchema, operatorSchema, userSchema, userAccountSchema } from '@casimir/data'

Expand Down Expand Up @@ -65,4 +65,11 @@ void async function () {
}

await run(`atlas schema apply --url "postgres://postgres:password@localhost:5432/users?sslmode=disable" --to "file://${sqlDir}/schema.sql" --dev-url "docker://postgres/15" --auto-approve`)

if (process.env.MOCK_SERVICES === 'true') {
process.on('SIGINT', () => {
runSync('npm run clean --workspace @casimir/users')
process.exit()
})
}
}()

0 comments on commit 5ce68b2

Please sign in to comment.