From 7d59cd9bfbfebaccc93811a50cc698e46e6c862b Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Mon, 2 Dec 2024 10:34:57 +0100 Subject: infra(unicorn): prefer-export-from (#3272) --- scripts/generate-locales.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-locales.ts b/scripts/generate-locales.ts index 13fe70fd..b4bc2311 100644 --- a/scripts/generate-locales.ts +++ b/scripts/generate-locales.ts @@ -427,10 +427,14 @@ async function normalizeLocaleFile(filePath: string, definitionKey: string) { const locales = await readdir(pathLocales); removeIndexTs(locales); +// src/locale/index.ts (Faker Imports and Exports) let localeIndexImports = ''; let localeIndexExportsIndividual = ''; let localeIndexExportsGrouped = ''; +// src/locales/index.ts (Locale Data Imports and Exports) let localesIndexImports = ''; +let localesIndexExportsIndividual = ''; +let localesIndexExportsGrouped = ''; let localizationLocales = '| Locale | Name | Faker |\n| :--- | :--- | :--- |\n'; const promises: Array> = []; @@ -459,9 +463,11 @@ for (const locale of locales) { )}`; localeIndexImports += `import { faker as ${localizedFaker} } from './${locale}';\n`; - localeIndexExportsIndividual += ` ${localizedFaker},\n`; + localeIndexExportsIndividual += `export { faker as ${localizedFaker} } from './${locale}';\n`; localeIndexExportsGrouped += ` ${locale}: ${localizedFaker},\n`; localesIndexImports += `import { default as ${locale} } from './${locale}';\n`; + localesIndexExportsIndividual += `export { default as ${locale} } from './${locale}';\n`; + localesIndexExportsGrouped += ` ${locale},\n`; localizationLocales += `| \`${locale}\` | ${localeTitle} | \`${localizedFaker}\` |\n`; promises.push( @@ -484,9 +490,7 @@ let localeIndexContent = ` ${localeIndexImports} - export { ${localeIndexExportsIndividual} - }; export const allFakers = { ${localeIndexExportsGrouped} @@ -503,9 +507,11 @@ let localesIndexContent = ` ${localesIndexImports} - export { ${locales.join(',')} }; + ${localesIndexExportsIndividual} - export const allLocales = { ${locales.join(',')} }; + export const allLocales = { + ${localesIndexExportsGrouped} + } as const; `; localesIndexContent = await formatTypescript(localesIndexContent); -- cgit v1.2.3