From f7ee4b592035a8390c1e09b3c2624f4475d55c43 Mon Sep 17 00:00:00 2001 From: Levende Date: Sun, 26 May 2024 16:43:05 +0200 Subject: [PATCH] fix: replace color library by native color to console log (#43) * fit: fix github workflow * fit: fix github workflow * fit: fix github workflow * fix: replace color library by native color to console log --- .changeset/fresh-carrots-allow.md | 5 +++++ .changeset/great-walls-bake.md | 5 +++++ .changeset/silver-wombats-kick.md | 5 +++++ .changeset/stupid-ears-pretend.md | 5 +++++ package.json | 1 - pnpm-lock.yaml | 3 --- src/index.ts | 18 ++++++++++-------- src/utils/summary.ts | 3 +-- 8 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 .changeset/fresh-carrots-allow.md create mode 100644 .changeset/great-walls-bake.md create mode 100644 .changeset/silver-wombats-kick.md create mode 100644 .changeset/stupid-ears-pretend.md diff --git a/.changeset/fresh-carrots-allow.md b/.changeset/fresh-carrots-allow.md new file mode 100644 index 0000000..ad12203 --- /dev/null +++ b/.changeset/fresh-carrots-allow.md @@ -0,0 +1,5 @@ +--- +"unused-i18n": patch +--- + +fix dist folder not encluded diff --git a/.changeset/great-walls-bake.md b/.changeset/great-walls-bake.md new file mode 100644 index 0000000..6f8ae6e --- /dev/null +++ b/.changeset/great-walls-bake.md @@ -0,0 +1,5 @@ +--- +"unused-i18n": patch +--- + +fix bug on release diff --git a/.changeset/silver-wombats-kick.md b/.changeset/silver-wombats-kick.md new file mode 100644 index 0000000..a293324 --- /dev/null +++ b/.changeset/silver-wombats-kick.md @@ -0,0 +1,5 @@ +--- +"unused-i18n": patch +--- + +replace color library by native color to console log diff --git a/.changeset/stupid-ears-pretend.md b/.changeset/stupid-ears-pretend.md new file mode 100644 index 0000000..045db33 --- /dev/null +++ b/.changeset/stupid-ears-pretend.md @@ -0,0 +1,5 @@ +--- +"unused-i18n": patch +--- + +fix changeset diff --git a/package.json b/package.json index 6bb2cdc..dbb1b2e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "coverage": "vitest run --coverage" }, "dependencies": { - "ansi-colors": "^4.1.3", "commander": "^12.1.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c820933..89286ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - ansi-colors: - specifier: ^4.1.3 - version: 4.1.3 commander: specifier: ^12.1.0 version: 12.1.0 diff --git a/src/index.ts b/src/index.ts index 9a8fc6f..8457ef4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ import * as fs from 'fs' import { loadConfig } from './utils/loadConfig' -import c from 'ansi-colors' import { getMissingTranslations } from './utils/missingTranslations' import { summary } from './utils/summary' import { searchFilesRecursively } from './lib/search' @@ -80,14 +79,13 @@ export const processTranslations = async ({ totalUnusedLocales += pathUnusedLocalesCount const formattedMissingTranslations = missingTranslations - .map((translation) => c.red(` ${translation}`)) + .map((translation) => `\x1b[31m${translation}\x1b[0m`) .join('\n') const message = missingTranslations.length - ? `Missing translations for ${c.yellow(localeFilePath)}: ${c.red( - `${pathUnusedLocalesCount}` - )} \n${formattedMissingTranslations}` - : c.green(`No missing translations for ${c.yellow(localeFilePath)}`) + ? `Missing translations for \x1b[33m${localeFilePath}\x1b[0m : \x1b[31m${pathUnusedLocalesCount} \n${formattedMissingTranslations}\x1b[0m` + : `\x1b[32mNo missing translations for \x1b[33m${localeFilePath}\x1b[0m\x1b[0m` + unusedLocalesCountByPath.push({ path: localPath, messages: message, @@ -101,7 +99,7 @@ export const processTranslations = async ({ }) : null } else { - const warningMessage = c.red(`Locale file not found: ${localeFilePath}`) + const warningMessage = `\x1b[31mLocale file not found: ${localeFilePath}\x1b[0m` unusedLocalesCountByPath.push({ path: localPath, @@ -111,5 +109,9 @@ export const processTranslations = async ({ }) const endTime = performance.now() summary({ unusedLocalesCountByPath, totalUnusedLocales }) - console.log(c.dim(`Duration : ${(endTime - startTime).toFixed(0)}ms`)) + console.log( + `\x1b[38;2;128;128;128mDuration : ${(endTime - startTime).toFixed( + 0 + )}ms\x1b[0m` + ) } diff --git a/src/utils/summary.ts b/src/utils/summary.ts index b3ddf4c..7ad3c62 100644 --- a/src/utils/summary.ts +++ b/src/utils/summary.ts @@ -1,5 +1,4 @@ import { SummaryArgs } from '../types/types' -import c from 'ansi-colors' export const summary = ({ unusedLocalesCountByPath, @@ -12,5 +11,5 @@ export const summary = ({ } }) - console.log(`Total unused locales: ${c.yellow(`${totalUnusedLocales}`)}`) + console.log(`Total unused locales: \x1b[33m${totalUnusedLocales}\x1b[0m`) }