Skip to content

Commit

Permalink
add option to export only db text
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Feb 23, 2024
1 parent 083066c commit e9fd88f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions apps/app/lib/generators/translationKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import prettier from 'prettier'

import fs from 'fs'

import { prisma } from '@weareinreach/db'
import { prisma, type Prisma } from '@weareinreach/db'
import { type PassedTask } from 'lib/generate'

const localePath = 'public/locales/en'
Expand All @@ -24,10 +24,22 @@ const countKeys = (obj: Output): number => Object.keys(flatten(obj)).length
export const generateTranslationKeys = async (task: PassedTask) => {
const prettierOpts = (await prettier.resolveConfig(__filename)) ?? undefined

const where = (): Prisma.TranslationNamespaceWhereInput | undefined => {
switch (true) {
case !!process.env.EXPORT_ALL: {
return undefined
}
case !!process.env.EXPORT_DB: {
return { name: 'org-data' }
}
default: {
return { exportFile: true }
}
}
}

const data = await prisma.translationNamespace.findMany({
where: {
exportFile: process.env.EXPORT_ALL ? undefined : true,
},
where: where(),
include: {
keys: {
orderBy: {
Expand Down

0 comments on commit e9fd88f

Please sign in to comment.