build: add pnpm
This commit is contained in:
@@ -1,25 +1,6 @@
|
||||
import { PrismaClient } from 'db'
|
||||
import path from 'path'
|
||||
const prisma = new PrismaClient({
|
||||
log: [
|
||||
{
|
||||
emit: 'event',
|
||||
level: 'query',
|
||||
},
|
||||
{
|
||||
emit: 'stdout',
|
||||
level: 'error',
|
||||
},
|
||||
{
|
||||
emit: 'stdout',
|
||||
level: 'info',
|
||||
},
|
||||
{
|
||||
emit: 'stdout',
|
||||
level: 'warn',
|
||||
},
|
||||
],
|
||||
})
|
||||
import fs from 'fs'
|
||||
|
||||
require('dotenv').config({
|
||||
path: path.join(
|
||||
@@ -32,18 +13,6 @@ require('dotenv').config({
|
||||
),
|
||||
})
|
||||
|
||||
const main = async () => {
|
||||
prisma.$on('query', (e) => {
|
||||
console.log('Query: ' + e.query)
|
||||
console.log('Params: ' + e.params)
|
||||
console.log('Duration: ' + e.duration + 'ms')
|
||||
})
|
||||
const date = new Date()
|
||||
const lastMonth = new Date(date.getFullYear(), date.getMonth() - 1, 10)
|
||||
const answers = await prisma.answer.findMany({
|
||||
where: { createdAt: { lt: lastMonth } },
|
||||
take: 100,
|
||||
})
|
||||
}
|
||||
const main = async () => {}
|
||||
|
||||
main().then()
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
"start:workspaces:migration:recover": "ts-node workspaceMigrationRecover.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"db": "*",
|
||||
"models": "*",
|
||||
"utils": "*",
|
||||
"ts-node": "^10.7.0"
|
||||
"@types/node": "18.6.4",
|
||||
"db": "workspace:*",
|
||||
"models": "workspace:*",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4",
|
||||
"utils": "*"
|
||||
}
|
||||
}
|
||||
|
||||
33
packages/scripts/prepareEmojis.ts
Normal file
33
packages/scripts/prepareEmojis.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import fs from 'fs'
|
||||
|
||||
export const prepareEmojis = () => {
|
||||
const emojiData = JSON.parse(fs.readFileSync('./emojiData.json', 'utf8'))
|
||||
const strippedEmojiData = {
|
||||
'Smileys & Emotion': emojiData['Smileys & Emotion'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
'People & Body': emojiData['People & Body'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
'Animals & Nature': emojiData['Animals & Nature'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
'Food & Drink': emojiData['Food & Drink'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
'Travel & Places': emojiData['Travel & Places'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
Activities: emojiData['Activities'].map(
|
||||
(emoji: { emoji: any }) => emoji.emoji
|
||||
),
|
||||
Objects: emojiData['Objects'].map((emoji: { emoji: any }) => emoji.emoji),
|
||||
Symbols: emojiData['Symbols'].map((emoji: { emoji: any }) => emoji.emoji),
|
||||
Flags: emojiData['Flags'].map((emoji: { emoji: any }) => emoji.emoji),
|
||||
}
|
||||
fs.writeFileSync(
|
||||
'strippedEmojis.json',
|
||||
JSON.stringify(strippedEmojiData),
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
import { Plan, PrismaClient, WorkspaceRole } from 'db'
|
||||
import path from 'path'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
export const migrateWorkspace = async () => {
|
||||
const users = await prisma.user.findMany({
|
||||
where: { workspaces: { none: {} } },
|
||||
include: {
|
||||
folders: true,
|
||||
typebots: true,
|
||||
credentials: true,
|
||||
customDomains: true,
|
||||
CollaboratorsOnTypebots: {
|
||||
include: { typebot: { select: { workspaceId: true } } },
|
||||
},
|
||||
},
|
||||
orderBy: { lastActivityAt: 'desc' },
|
||||
})
|
||||
let i = 1
|
||||
for (const user of users) {
|
||||
console.log('Updating', user.email, `(${i}/${users.length})`)
|
||||
i += 1
|
||||
const newWorkspace = await prisma.workspace.create({
|
||||
data: {
|
||||
name: user.name ? `${user.name}'s workspace` : 'My workspace',
|
||||
members: { create: { userId: user.id, role: WorkspaceRole.ADMIN } },
|
||||
stripeId: user.stripeId,
|
||||
plan: user.plan ?? Plan.FREE,
|
||||
},
|
||||
})
|
||||
await prisma.credentials.updateMany({
|
||||
where: { id: { in: user.credentials.map((c) => c.id) } },
|
||||
data: { workspaceId: newWorkspace.id, ownerId: null },
|
||||
})
|
||||
await prisma.customDomain.updateMany({
|
||||
where: {
|
||||
name: { in: user.customDomains.map((c) => c.name) },
|
||||
ownerId: user.id,
|
||||
},
|
||||
data: { workspaceId: newWorkspace.id, ownerId: null },
|
||||
})
|
||||
await prisma.dashboardFolder.updateMany({
|
||||
where: {
|
||||
id: { in: user.folders.map((c) => c.id) },
|
||||
},
|
||||
data: { workspaceId: newWorkspace.id, ownerId: null },
|
||||
})
|
||||
await prisma.typebot.updateMany({
|
||||
where: {
|
||||
id: { in: user.typebots.map((c) => c.id) },
|
||||
},
|
||||
data: { workspaceId: newWorkspace.id, ownerId: null },
|
||||
})
|
||||
for (const collab of user.CollaboratorsOnTypebots) {
|
||||
if (!collab.typebot.workspaceId) continue
|
||||
await prisma.memberInWorkspace.upsert({
|
||||
where: {
|
||||
userId_workspaceId: {
|
||||
userId: user.id,
|
||||
workspaceId: collab.typebot.workspaceId,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
role: WorkspaceRole.GUEST,
|
||||
userId: user.id,
|
||||
workspaceId: collab.typebot.workspaceId,
|
||||
},
|
||||
update: {},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('dotenv').config({
|
||||
path: path.join(
|
||||
__dirname,
|
||||
process.env.NODE_ENV === 'production' ? '.env.production' : '.env.local'
|
||||
),
|
||||
})
|
||||
|
||||
const main = async () => {
|
||||
await migrateWorkspace()
|
||||
}
|
||||
|
||||
main().then()
|
||||
@@ -1,44 +0,0 @@
|
||||
// See https://github.com/baptisteArno/typebot.io/issues/37
|
||||
|
||||
import { Plan, PrismaClient, WorkspaceRole } from 'db'
|
||||
import path from 'path'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
export const migrateWorkspace = async () => {
|
||||
const user = await prisma.user.findFirst()
|
||||
if (!user) return
|
||||
console.log('Updating', user.email)
|
||||
const newWorkspace = await prisma.workspace.create({
|
||||
data: {
|
||||
name: user.name ? `${user.name}'s workspace` : 'My workspace',
|
||||
members: { create: { userId: user.id, role: WorkspaceRole.ADMIN } },
|
||||
plan: Plan.TEAM,
|
||||
},
|
||||
})
|
||||
await prisma.credentials.updateMany({
|
||||
data: { workspaceId: newWorkspace.id },
|
||||
})
|
||||
await prisma.customDomain.updateMany({
|
||||
data: { workspaceId: newWorkspace.id },
|
||||
})
|
||||
await prisma.dashboardFolder.updateMany({
|
||||
data: { workspaceId: newWorkspace.id },
|
||||
})
|
||||
await prisma.typebot.updateMany({
|
||||
data: { workspaceId: newWorkspace.id },
|
||||
})
|
||||
}
|
||||
|
||||
require('dotenv').config({
|
||||
path: path.join(
|
||||
__dirname,
|
||||
process.env.NODE_ENV === 'production' ? '.env.production' : '.env.local'
|
||||
),
|
||||
})
|
||||
|
||||
const main = async () => {
|
||||
await migrateWorkspace()
|
||||
}
|
||||
|
||||
main().then()
|
||||
Reference in New Issue
Block a user