Skip to content

Commit

Permalink
chore: lint & format
Browse files Browse the repository at this point in the history
Signed-off-by: InReach [bot] <108850934+InReach-svc@users.noreply.github.com>
  • Loading branch information
InReach-svc committed Apr 3, 2024
1 parent ecd323c commit d44610b
Show file tree
Hide file tree
Showing 14 changed files with 939 additions and 1,212 deletions.
34 changes: 15 additions & 19 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
/* eslint-disable turbo/no-undeclared-env-vars */
// @ts-check
import bundleAnalyze from "@next/bundle-analyzer";
import nextRoutes from "nextjs-routes/config";
import bundleAnalyze from '@next/bundle-analyzer'
import nextRoutes from 'nextjs-routes/config'

import i18nConfig from "./next-i18next.config.js";
import i18nConfig from './next-i18next.config.js'
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful for
* Docker builds.
*/

!process.env.SKIP_ENV_VALIDATION && (await import("./src/env/server.mjs"));
!process.env.SKIP_ENV_VALIDATION && (await import('./src/env/server.mjs'))

const withRoutes = nextRoutes({ outDir: "src/types" });
const withRoutes = nextRoutes({ outDir: 'src/types' })
const withBundleAnalyzer = bundleAnalyze({
enabled: process.env.ANALYZE === "true",
});
enabled: process.env.ANALYZE === 'true',
})

/** @type {import('next').NextConfig} */
const config = {
i18n: i18nConfig.i18n,
reactStrictMode: true,
swcMinify: true,
compiler: {
...(process.env.VERCEL_ENV === "production"
? { removeConsole: { exclude: ["error"] } }
: {}),
...(process.env.VERCEL_ENV === 'production' ? { removeConsole: { exclude: ['error'] } } : {}),
},
images: {
remotePatterns: [
{ protocol: "https", hostname: "placehold.co", pathname: "/**" },
],
remotePatterns: [{ protocol: 'https', hostname: 'placehold.co', pathname: '/**' }],
// domains: ['placehold.co'],
},
experimental: {
outputFileTracingExcludes: {
"*": ["**swc+core**", "**esbuild**"],
'*': ['**swc+core**', '**esbuild**'],
},
webpackBuildWorker: true,
},
eslint: { ignoreDuringBuilds: process.env.VERCEL_ENV !== "production" },
typescript: { ignoreBuildErrors: process.env.VERCEL_ENV !== "production" },
};
eslint: { ignoreDuringBuilds: process.env.VERCEL_ENV !== 'production' },
typescript: { ignoreBuildErrors: process.env.VERCEL_ENV !== 'production' },
}
/**
* Wraps NextJS config with the Bundle Analyzer config.
*
* @param {typeof config} config
* @returns {typeof config}
*/
function defineNextConfig(config) {
return withBundleAnalyzer(withRoutes(config));
return withBundleAnalyzer(withRoutes(config))
}

export default defineNextConfig(config);
export default defineNextConfig(config)
28 changes: 14 additions & 14 deletions prisma/dataMigrationRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
type ListrTask as ListrTaskObj,
type ListrTaskWrapper,
PRESET_TIMER,
} from "listr2";
} from 'listr2'

import * as jobList from "./data-migrations";
import * as jobList from './data-migrations'

/**
* Job Runner
Expand All @@ -21,16 +21,16 @@ const renderOptions = {
bottomBar: 10,
persistentOutput: true,
timer: PRESET_TIMER,
} satisfies ListrJob["options"];
} satisfies ListrJob['options']
const injectOptions = (job: ListrJob): ListrJob => ({
...job,
options: renderOptions,
});
})
const jobs = new Listr<Context>(
Object.values(jobList).map((job) => injectOptions(job)),
{
rendererOptions: {
formatOutput: "wrap",
formatOutput: 'wrap',
timer: PRESET_TIMER,
suffixSkips: true,
},
Expand All @@ -39,17 +39,17 @@ const jobs = new Listr<Context>(
},
exitOnError: false,
forceColor: true,
},
);
}
)

jobs.run();
jobs.run()

export type Context = {
error?: boolean;
};
export type PassedTask = ListrTaskWrapper<Context, ListrDefaultRenderer>;
export type ListrJob = ListrTaskObj<Context, ListrDefaultRenderer>;
error?: boolean
}
export type PassedTask = ListrTaskWrapper<Context, ListrDefaultRenderer>
export type ListrJob = ListrTaskObj<Context, ListrDefaultRenderer>
export type ListrTask = (
ctx: Context,
task: PassedTask,
) => void | Promise<void | Listr<Context, any, any>> | Listr<Context, any, any>;
task: PassedTask
) => void | Promise<void | Listr<Context, any, any>> | Listr<Context, any, any>
61 changes: 28 additions & 33 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,70 @@
/* eslint-disable import/no-unused-modules */

import { PrismaClient } from "@prisma/client";
import { PrismaClient } from '@prisma/client'

import fs from "fs";
import path from "path";
import fs from 'fs'
import path from 'path'

import { categories } from "./seedData/categories";
import { partnerData } from "./seedData/partners";
import { pronouns } from "./seedData/pronouns";
import { categories } from './seedData/categories'
import { partnerData } from './seedData/partners'
import { pronouns } from './seedData/pronouns'

const prisma = new PrismaClient();
const prisma = new PrismaClient()

async function main() {
const categoryResult = await prisma.storyCategory.createMany({
data: categories,
skipDuplicates: true,
});
console.log(`Categories created: ${categoryResult.count}`);
})
console.log(`Categories created: ${categoryResult.count}`)

const pronounResult = await prisma.pronouns.createMany({
data: pronouns,
skipDuplicates: true,
});
console.log(`Pronoun records created: ${pronounResult.count}`);
})
console.log(`Pronoun records created: ${pronounResult.count}`)

const partnerResult = await prisma.partnerOrg.createMany({
data: partnerData,
skipDuplicates: true,
});
console.log(`Partner records created: ${partnerResult.count}`);
})
console.log(`Partner records created: ${partnerResult.count}`)
const output: Record<string, unknown> = {
categories: await prisma.storyCategory.findMany(),
pronouns: await prisma.pronouns.findMany(),
partners: await prisma.partnerOrg.findMany(),
};
}

if (fs.existsSync(path.resolve(__dirname, "./seedData/stories.ts"))) {
const stories = await import("./seedData/stories");
if (fs.existsSync(path.resolve(__dirname, './seedData/stories.ts'))) {
const stories = await import('./seedData/stories')
const storiesResult = await prisma.story.createMany({
data: stories.stories,
skipDuplicates: true,
});
console.log(`Stories created: ${storiesResult.count}`);
})
console.log(`Stories created: ${storiesResult.count}`)
const linkCategories = await prisma.storyToCategory.createMany({
data: stories.links.categories,
skipDuplicates: true,
});
})
const linkPronouns = await prisma.pronounsToStory.createMany({
data: stories.links.pronouns,
skipDuplicates: true,
});
console.log(
`Links -> categories: ${linkCategories.count}, pronouns: ${linkPronouns.count}`,
);
})
console.log(`Links -> categories: ${linkCategories.count}, pronouns: ${linkPronouns.count}`)
output.storiesResult = await prisma.story.findMany({
select: { id: true, name: true },
});
})
}

fs.writeFileSync(
path.resolve(__dirname, "seedresult.json"),
JSON.stringify(output),
);
fs.writeFileSync(path.resolve(__dirname, 'seedresult.json'), JSON.stringify(output))
}

main()
.then(async () => {
await prisma.$disconnect();
await prisma.$disconnect()
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
console.error(e)
await prisma.$disconnect()
process.exit(1)
})
36 changes: 18 additions & 18 deletions prisma/seedData/pronouns.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { type Prisma } from "@prisma/client";
import { type Prisma } from '@prisma/client'

export const pronouns: Prisma.PronounsCreateManyInput[] = [
{
id: "clienra200007pexbweivoffq",
pronounsEN: "They/Them/Theirs",
pronounsES: "Elle",
tag: "they",
id: 'clienra200007pexbweivoffq',
pronounsEN: 'They/Them/Theirs',
pronounsES: 'Elle',
tag: 'they',
},
{
id: "clienra200008pexbpobaxztr",
pronounsEN: "He/Him/His",
pronounsES: "Él",
tag: "he",
id: 'clienra200008pexbpobaxztr',
pronounsEN: 'He/Him/His',
pronounsES: 'Él',
tag: 'he',
},
{
id: "clienra200009pexb5wyo4bkt",
pronounsEN: "Any pronouns",
pronounsES: "Cualquier pronombre",
tag: "any",
id: 'clienra200009pexb5wyo4bkt',
pronounsEN: 'Any pronouns',
pronounsES: 'Cualquier pronombre',
tag: 'any',
},
{
id: "clienra20000apexb4zhmhq3d",
pronounsEN: "No pronouns",
pronounsES: "No pronombres",
tag: "none",
id: 'clienra20000apexb4zhmhq3d',
pronounsEN: 'No pronouns',
pronounsES: 'No pronombres',
tag: 'none',
},
];
]
Loading

0 comments on commit d44610b

Please sign in to comment.