build: 🏗️ Add script package
This commit is contained in:
1
packages/scripts/.env.local.example
Normal file
1
packages/scripts/.env.local.example
Normal file
@ -0,0 +1 @@
|
||||
DATABASE_URL=postgresql://postgres:@localhost:5432/typebot
|
20
packages/scripts/index.ts
Normal file
20
packages/scripts/index.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { PrismaClient } from 'db'
|
||||
import { randomUUID } from 'crypto'
|
||||
import path from 'path'
|
||||
|
||||
require('dotenv').config({
|
||||
path: path.join(
|
||||
__dirname,
|
||||
process.env.NODE_ENV === 'production' ? '.env.prod' : '.env.local'
|
||||
),
|
||||
})
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
const main = async () => {
|
||||
await prisma.user.updateMany({
|
||||
where: { apiToken: null },
|
||||
data: { apiToken: randomUUID() },
|
||||
})
|
||||
}
|
||||
|
||||
main().then()
|
15
packages/scripts/package.json
Normal file
15
packages/scripts/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "scripts",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start:local": "ts-node index.ts",
|
||||
"start:prod": "NODE_ENV=production ts-node index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"db": "*",
|
||||
"ts-node": "^10.5.0"
|
||||
}
|
||||
}
|
13
packages/scripts/tsconfig.json
Normal file
13
packages/scripts/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "dist",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user