2
0

🧐 Improve inspectTypebot script abort process

This commit is contained in:
Baptiste Arnaud
2024-02-21 10:35:10 +01:00
parent a7eb5cdb5d
commit eec50416fb

View File

@ -1,21 +1,26 @@
import { PrismaClient } from '@typebot.io/prisma' import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils' import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts' import * as p from '@clack/prompts'
import { isCancel } from '@clack/prompts'
const inspectTypebot = async () => { const inspectTypebot = async () => {
await promptAndSetEnvironment('production') await promptAndSetEnvironment('production')
const type = (await p.select({ const type = await p.select<any, 'id' | 'publicId'>({
message: 'Select way', message: 'Select way',
options: [ options: [
{ label: 'ID', value: 'id' }, { label: 'ID', value: 'id' },
{ label: 'Public ID', value: 'publicId' }, { label: 'Public ID', value: 'publicId' },
], ],
})) as 'id' | 'publicId' })
const val = (await p.text({ if (!type || isCancel(type)) process.exit()
const val = await p.text({
message: 'Enter value', message: 'Enter value',
})) as string })
if (!val || isCancel(val)) process.exit()
const prisma = new PrismaClient({ const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'], log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],