From 7bf3bbe1d15daa3f9182a0fd04feadbf298cc93b Mon Sep 17 00:00:00 2001 From: Ayobami Akingbade Date: Tue, 7 May 2024 05:52:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(build):=20fix=20lingui=20bui?= =?UTF-8?q?ld=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lingui.config.base.js | 20 +++++++++++++ lingui.config.js | 37 ++---------------------- next.config.base.js | 12 ++++++++ next.config.js | 7 ++--- release.sh | 1 - src/backend/entities/entities.service.ts | 21 ++++++++++++++ src/bin/index.ts | 24 ++++++++------- src/frontend/views/entity/Crud/index.tsx | 1 + src/translations/utils.tsx | 4 --- 9 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 lingui.config.base.js create mode 100644 next.config.base.js delete mode 100755 release.sh diff --git a/lingui.config.base.js b/lingui.config.base.js new file mode 100644 index 000000000..33d73c393 --- /dev/null +++ b/lingui.config.base.js @@ -0,0 +1,20 @@ +const locales = [ + "en-us", // english + "zh-cn", // chinese (simplified) + "zh-tw", // chinese (traditional) + "fr-fr", // french + "es-es", // spanish + "de-de", // german + "it-it", // italian + "ru-ru", // russian + "ja-jp", // japanese + "pt-br", // portuguese + "ko-kr", // korean +]; + +/** @type {import('@lingui/conf').LinguiConfig} */ +module.exports = { + locales, + sourceLocale: "en-us", + pseudoLocale: "pseudo", +}; diff --git a/lingui.config.js b/lingui.config.js index 20b698c65..ea83804ee 100644 --- a/lingui.config.js +++ b/lingui.config.js @@ -1,45 +1,14 @@ const { formatter } = require("@lingui/format-po"); -const locales = [ - "en-us", // english - "zh-cn", // chinese (simplified) - "zh-tw", // chinese (traditional) - "fr-fr", // french - "es-es", // spanish - "de-de", // german - "it-it", // italian - "ru-ru", // russian - "ja-jp", // japanese - "pt-br", // portuguese - "ko-kr", // korean - - // "bn-in", // bengali - // "ar-sa", // arabic - // "pl-pl", // polish - // "tr-tr", // turkish - // "vi-vn", // vietnamese - // "id-id", // indonesian - // "uk-ua", // ukrainian - // "hu-hu", // hungarian - // "ro-ro", // romanian - // "sv-se", // swedish - // "nl-nl", // dutch - // "fa-ir", // persian - // "cs-cz", // czech - // "el-gr", // greek - // "th-th", // thai - // "he-il", // hebrew -]; +const linguiConfigBase = require("./lingui.config.base"); if (process.env.NODE_ENV !== "production") { - locales.push("pseudo"); + linguiConfigBase.locales.push("pseudo"); } /** @type {import('@lingui/conf').LinguiConfig} */ module.exports = { - locales, - sourceLocale: "en-us", - pseudoLocale: "pseudo", + ...linguiConfigBase, catalogs: [ { path: "/src/translations/locales/{locale}", diff --git a/next.config.base.js b/next.config.base.js new file mode 100644 index 000000000..2c90e5eb0 --- /dev/null +++ b/next.config.base.js @@ -0,0 +1,12 @@ +const linguiConfig = require("./lingui.config"); + +/** @type {import('next').NextConfig} */ +const nextConfig = { + reactStrictMode: true, + i18n: { + locales: linguiConfig.locales, + defaultLocale: linguiConfig.sourceLocale, + }, +}; + +module.exports = nextConfig; diff --git a/next.config.js b/next.config.js index 2d962e865..783770c34 100644 --- a/next.config.js +++ b/next.config.js @@ -2,18 +2,15 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: process.env.ANALYZE === "true", }); -const linguiConfig = require("./lingui.config"); +const nextConfigBase = require("./next.config.base"); /** @type {import('next').NextConfig} */ const nextConfig = { + ...nextConfigBase, reactStrictMode: true, experimental: { swcPlugins: [["@lingui/swc-plugin", {}]], }, - i18n: { - locales: linguiConfig.locales, - defaultLocale: linguiConfig.sourceLocale, - }, webpack: (config) => { config.module.rules.push({ test: /\.po$/, diff --git a/release.sh b/release.sh deleted file mode 100755 index 4b9221eb9..000000000 --- a/release.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout release && git rebase master && git push --no-verify && git checkout master && git push --no-verify \ No newline at end of file diff --git a/src/backend/entities/entities.service.ts b/src/backend/entities/entities.service.ts index b341158dc..6a360034b 100644 --- a/src/backend/entities/entities.service.ts +++ b/src/backend/entities/entities.service.ts @@ -67,6 +67,27 @@ export class EntitiesApiService { return primaryField; } + // TODO + // async getEntityPrimaryField(entity: string): Promise { + // const primaryField = (await this.getEntityFields(entity)).filter( + // ({ isId }) => isId + // ); + + // if (primaryField.length === 0) { + // throw new BadRequestError( + // "This entity doesn't have a primary key. Kindly ask your administrator to add one then restart the application and this error will go away." + // ); + // } + + // if (primaryField.length > 1) { + // throw new BadRequestError( + // "This entity has multiple primary keys. Kindly ask your administrator to fix this issue by ensuring only ONE primary key exists then restart the application and this error will go away." + // ); + // } + + // return primaryField[0].name; + // } + async getEntityFromSchema(entity: string): Promise { return (await this.getDBSchemaModels())[entity]; } diff --git a/src/bin/index.ts b/src/bin/index.ts index e81172bb2..7d62c8526 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -80,8 +80,6 @@ const replaceRandomCharaters = (envContent: string) => { copyEnvHere(); - process.stdout.write("\n"); - const endpoint = `http://localhost:${process.env.PORT || 3000}`; console.log(` @@ -104,6 +102,8 @@ const replaceRandomCharaters = (envContent: string) => { `🚀 Application started successfully at ${terminalLink(endpoint, endpoint)}` ); + process.stdout.write("\n"); + const WAIT_FOR_NEXT_TO_START = 1000; /* @@ -116,23 +116,27 @@ const replaceRandomCharaters = (envContent: string) => { fetch(`${endpoint}/api/healthcheck`).catch(() => {}); }, WAIT_FOR_NEXT_TO_START); + let stdSkip = true; + let stdCount = 0; + const STD_SKIP_COUNT = 3; + stdout.on("data", (chunk) => { const data = (chunk || "").toString(); - if (data.startsWith("info")) { + if (stdSkip) { + stdCount += 1; + + if (stdCount > STD_SKIP_COUNT) { + stdSkip = false; + } + return; } process.stdout.write(data); }); - stderr.on("data", (chunk) => { - const data = (chunk || "").toString(); - if (data.startsWith("warn")) { - return; - } - process.stderr.write(data); - }); + stderr.pipe(process.stderr); })().catch((err) => { console.error(err); process.exit(1); diff --git a/src/frontend/views/entity/Crud/index.tsx b/src/frontend/views/entity/Crud/index.tsx index 9bfa27f5d..299eb4d76 100644 --- a/src/frontend/views/entity/Crud/index.tsx +++ b/src/frontend/views/entity/Crud/index.tsx @@ -184,6 +184,7 @@ export function EntityCrudSettings() { return ( {entityFields.data.length > 1 && + // TODO entityFields.data.findIndex((field) => field.isId) === -1 && ( <> diff --git a/src/translations/utils.tsx b/src/translations/utils.tsx index 14154d112..232a2dcac 100644 --- a/src/translations/utils.tsx +++ b/src/translations/utils.tsx @@ -6,10 +6,6 @@ import { I18nProvider } from "@lingui/react"; import languages from "./languages"; async function loadCatalog(locale: string) { - if (process.env.NODE_ENV === "production") { - const { messages } = await import(`./locales/${locale}`); - return messages; - } const { messages } = await import(`./locales/${locale}.po`); return messages;