Connect, collaborate, and grow with a community of TypeScript developers
chore: add scripts
bautistaaac7211895207b
diff --git a/packages/db/seed/prod.ts b/packages/db/seed/prod.tsindex 1bb846fe..3c55ce08 100644--- a/packages/db/seed/prod.ts+++ b/packages/db/seed/prod.ts@@ -13,7 +13,7 @@ const __dirname = path.dirname(__filename);const challengePath = path.join(__dirname, '../../../challenges');-export const slugify = (str: string) => str.toLowerCase().replace(/\s/g, '-');+const slugify = (str: string) => str.toLowerCase().replace(/\s/g, '-');const TYPE_CHALLENGE_ID = uuidByString('type-challenges');const TYPEHERO_ID = uuidByString('typehero');diff --git a/packages/db/temp/update-ported-challenges.ts b/packages/db/temp/update-ported-challenges.tsnew file mode 100644index 00000000..ad98ab33--- /dev/null+++ b/packages/db/temp/update-ported-challenges.ts@@ -0,0 +1,54 @@+import uuidByString from 'uuid-by-string';+import { loadChallengesFromTypeChallenge } from '../mocks/challenges.mock';+import { prisma } from '../src';++export const slugify = (str: string) => str.toLowerCase().replace(/\s/g, '-');+const TYPE_CHALLENGE_ID = uuidByString('type-challenges');++try {+ const transactions = [];+ const typeChallengeUser = await prisma.user.upsert({+ where: { id: TYPE_CHALLENGE_ID },+ update: {},+ create: {+ id: TYPE_CHALLENGE_ID,+ email: '[email protected]',+ name: 'Type Challenges',+ userLinks: {+ create: {+ url: 'https://tsch.js.org/',+ },+ },+ },+ });+ const challengesFromTypeChallenges = await loadChallengesFromTypeChallenge(true);++ const typeChallengeAccount = await prisma.user.findFirstOrThrow({+ where: {+ id: typeChallengeUser.id,+ },+ });+ for (const portedChallenge of challengesFromTypeChallenges) {+ // transactions.push(+ await prisma.challenge.upsert({+ where: {+ slug: portedChallenge.slug,+ },+ update: {+ ...portedChallenge,+ },+ create: {+ ...portedChallenge,+ userId: typeChallengeAccount.id,+ },+ });+ // );+ }++ // await prisma.$transaction(transactions);+ await prisma.$disconnect();+} catch (e) {+ console.error(e);+ await prisma.$disconnect();+ process.exit(1);+}