diff --git a/.gitignore b/.gitignore index b9db62288..408488c5d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules .next .env .env.local +.env.prod workspace.code-workspace .DS_Store .turbo diff --git a/packages/scripts/.env.local.example b/packages/scripts/.env.local.example new file mode 100644 index 000000000..ea6bd6407 --- /dev/null +++ b/packages/scripts/.env.local.example @@ -0,0 +1 @@ +DATABASE_URL=postgresql://postgres:@localhost:5432/typebot \ No newline at end of file diff --git a/packages/scripts/index.ts b/packages/scripts/index.ts new file mode 100644 index 000000000..7fcb3480a --- /dev/null +++ b/packages/scripts/index.ts @@ -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() diff --git a/packages/scripts/package.json b/packages/scripts/package.json new file mode 100644 index 000000000..15ef66c75 --- /dev/null +++ b/packages/scripts/package.json @@ -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" + } +} diff --git a/packages/scripts/tsconfig.json b/packages/scripts/tsconfig.json new file mode 100644 index 000000000..27ba6d64e --- /dev/null +++ b/packages/scripts/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es5", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "sourceMap": true, + "outDir": "dist", + "moduleResolution": "node", + "allowSyntheticDefaultImports": true + } +} diff --git a/yarn.lock b/yarn.lock index e995896bf..b702dd774 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10563,9 +10563,9 @@ pend@~1.2.0: resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= -"php-parser@git+https://github.com/glayzzle/php-parser.git#27abcb2337ac6450c068ef064982dfabf77916a5": +"php-parser@https://github.com/glayzzle/php-parser#27abcb2337ac6450c068ef064982dfabf77916a5": version "3.0.2" - resolved "git+https://github.com/glayzzle/php-parser.git#27abcb2337ac6450c068ef064982dfabf77916a5" + resolved "https://github.com/glayzzle/php-parser#27abcb2337ac6450c068ef064982dfabf77916a5" picocolors@^1.0.0: version "1.0.0"