Skip to content

Commit

Permalink
fix: chalk ^5.0.0 (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Adam Skoufis <askoufis@seek.com.au>
  • Loading branch information
renovate[bot] and askoufis committed Mar 24, 2024
1 parent 252585a commit 1c1702d
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 41 deletions.
7 changes: 7 additions & 0 deletions .changeset/thin-jeans-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@vocab/webpack': patch
'@vocab/phrase': patch
'@vocab/core': patch
---

Replace `chalk` with `picocolors`
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
],
"dependencies": {
"@formatjs/icu-messageformat-parser": "^2.0.10",
"chalk": "^4.1.0",
"chokidar": "^3.4.3",
"debug": "^4.3.1",
"fast-glob": "^3.2.4",
"fastest-validator": "^1.9.0",
"find-up": "^5.0.0",
"intl-messageformat": "^10.0.0",
"picocolors": "^1.0.0",
"prettier": "^2.1.2"
},
"devDependencies": {
Expand Down
28 changes: 13 additions & 15 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { UserConfig } from './types';
import path from 'path';

import chalk from 'chalk';
import pc from 'picocolors';
import findUp from 'find-up';
import Validator from 'fastest-validator';
import { ValidationError } from './ValidationError';
import { trace } from './logger';

const boldCyan = (s: string) => pc.bold(pc.cyan(s));

const validator = new Validator();
const schema = {
$$strict: true,
Expand Down Expand Up @@ -69,11 +71,11 @@ export function validateConfig(c: UserConfig) {
if (v.type === 'objectStrict') {
return `Invalid key(s) ${splitMap(
v.actual,
(m) => `"${chalk.cyan(m)}"`,
)}. Expected one of ${splitMap(v.expected, chalk.green)}`;
(m) => `"${pc.cyan(m)}"`,
)}. Expected one of ${splitMap(v.expected, pc.green)}`;
}
if (v.field) {
return v.message?.replace(v.field, chalk.cyan(v.field));
return v.message?.replace(v.field, pc.cyan(v.field));
}
return v.message;
})
Expand All @@ -87,7 +89,7 @@ export function validateConfig(c: UserConfig) {
if (!languageStrings.includes(c.devLanguage)) {
throw new ValidationError(
'InvalidDevLanguage',
`The dev language "${chalk.bold.cyan(
`The dev language "${boldCyan(
c.devLanguage,
)}" was not found in languages ${languageStrings.join(', ')}.`,
);
Expand All @@ -99,9 +101,7 @@ export function validateConfig(c: UserConfig) {
if (foundLanguages.includes(lang.name)) {
throw new ValidationError(
'DuplicateLanguage',
`The language "${chalk.bold.cyan(
lang.name,
)}" was defined multiple times.`,
`The language "${boldCyan(lang.name)}" was defined multiple times.`,
);
}
foundLanguages.push(lang.name);
Expand All @@ -110,9 +110,7 @@ export function validateConfig(c: UserConfig) {
if (lang.extends && !languageStrings.includes(lang.extends)) {
throw new ValidationError(
'InvalidExtends',
`The language "${chalk.bold.cyan(
lang.name,
)}"'s extends of ${chalk.bold.cyan(
`The language "${boldCyan(lang.name)}"'s extends of ${boldCyan(
lang.extends,
)} was not found in languages ${languageStrings.join(', ')}.`,
);
Expand All @@ -125,7 +123,7 @@ export function validateConfig(c: UserConfig) {
if (foundGeneratedLanguages.includes(generatedLang.name)) {
throw new ValidationError(
'DuplicateGeneratedLanguage',
`The generated language "${chalk.bold.cyan(
`The generated language "${boldCyan(
generatedLang.name,
)}" was defined multiple times.`,
);
Expand All @@ -136,7 +134,7 @@ export function validateConfig(c: UserConfig) {
if (languageStrings.includes(generatedLang.name)) {
throw new ValidationError(
'InvalidGeneratedLanguage',
`The generated language "${chalk.bold.cyan(
`The generated language "${boldCyan(
generatedLang.name,
)}" is already defined as a language.`,
);
Expand All @@ -149,9 +147,9 @@ export function validateConfig(c: UserConfig) {
) {
throw new ValidationError(
'InvalidExtends',
`The generated language "${chalk.bold.cyan(
`The generated language "${boldCyan(
generatedLang.name,
)}"'s extends of ${chalk.bold.cyan(
)}"'s extends of ${boldCyan(
generatedLang.extends,
)} was not found in languages ${languageStrings.join(', ')}.`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/load-translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
TranslationFileMetadata,
TranslationFileContents,
} from './types';
import chalk from 'chalk';
import pc from 'picocolors';

import { trace } from './logger';
import {
Expand Down Expand Up @@ -135,7 +135,7 @@ function getNamespaceByFilePath(

function printValidationError(...params: unknown[]) {
// eslint-disable-next-line no-console
console.error(chalk.red('Error loading translation:'), ...params);
console.error(pc.red('Error loading translation:'), ...params);
}

function getTranslationsFromFile(
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import chalk from 'chalk';
import pc from 'picocolors';
import debug from 'debug';

export const trace = debug(`vocab:core`);

export const log = (...params: unknown[]) => {
// eslint-disable-next-line no-console
console.log(chalk.yellow('Vocab'), ...params);
console.log(pc.yellow('Vocab'), ...params);
};
12 changes: 7 additions & 5 deletions packages/core/src/validate/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import type { UserConfig, LoadedTranslation, LanguageName } from '../types';
import chalk from 'chalk';
import pc from 'picocolors';

import { loadAllTranslations } from '../load-translations';
import { getAltLanguages } from '../utils';
Expand Down Expand Up @@ -60,16 +60,18 @@ export async function validate(config: UserConfig) {
if (!translationValid) {
valid = false;
console.log(
chalk.red`Incomplete translations: "${chalk.bold(
loadedTranslation.relativePath,
)}"`,
pc.red(
`Incomplete translations: "${pc.bold(
loadedTranslation.relativePath,
)}"`,
),
);

for (const lang of Object.keys(result)) {
const missingKeys = result[lang];

console.log(
chalk.yellow(lang),
pc.yellow(lang),
'->',
missingKeys.map((v) => `"${v}"`).join(', '),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/phrase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"license": "MIT",
"dependencies": {
"@vocab/core": "^1.6.1",
"chalk": "^4.1.0",
"csv-stringify": "^6.2.3",
"debug": "^4.3.1",
"form-data": "^3.0.0",
"node-fetch": "^2.6.1"
"node-fetch": "^2.6.1",
"picocolors": "^1.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/phrase/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import chalk from 'chalk';
import pc from 'picocolors';
import debug from 'debug';

export const trace = debug(`vocab:phrase`);

export const log = (...params: unknown[]) => {
// eslint-disable-next-line no-console
console.log(chalk.yellow('Vocab'), ...params);
console.log(pc.yellow('Vocab'), ...params);
};
2 changes: 1 addition & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
],
"dependencies": {
"@vocab/core": "^1.6.1",
"chalk": "^4.1.0",
"cjs-module-lexer": "^1.2.2",
"debug": "^4.3.1",
"es-module-lexer": "^0.10.0",
"picocolors": "^1.0.0",
"virtual-resource-loader": "^1.0.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import chalk from 'chalk';
import pc from 'picocolors';
import debug from 'debug';

export const trace = debug(`vocab:webpack`);

export const log = (...params: unknown[]) => {
// eslint-disable-next-line no-console
console.log(chalk.yellow('Vocab'), ...params);
console.log(pc.yellow('Vocab'), ...params);
};
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c1702d

Please sign in to comment.