Skip to content

Commit a3fec5c

Browse files
Merge pull request #20 from contentstack/fix/dx-4465-upgrade-chalk-to-v5
Fix/dx 4465 upgrade chalk to v5
2 parents a0509e7 + 290ae69 commit a3fec5c

File tree

57 files changed

+1580
-1297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1580
-1297
lines changed

.talismanrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fileignoreconfig:
2-
- filename: pnpm-lock.yaml
3-
checksum: 901fcf828dc9d8d85277c767cd468791388a4a3b0cb30525bcdcb86d009be6f4
4-
version: '1.0'
2+
- filename: pnpm-lock.yaml
3+
checksum: 0a12c6c1e4df121f6a217425ef0bd7b1acccc1cd3f972157f7ca7480281277fd
4+
version: "1.0"

packages/contentstack-audit/.mocharc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"require": [
33
"test/helpers/init.js",
4-
"ts-node/register"
4+
"ts-node/register",
5+
"test/helpers/mocha-root-hooks.js"
56
],
67
"watch-extensions": [
78
"ts"

packages/contentstack-audit/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "2.0.0-beta.7",
3+
"version": "2.0.0-beta.8",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -18,11 +18,11 @@
1818
"/oclif.manifest.json"
1919
],
2020
"dependencies": {
21-
"@contentstack/cli-command": "~2.0.0-beta.3",
22-
"@contentstack/cli-utilities": "~2.0.0-beta.3",
21+
"@contentstack/cli-command": "~2.0.0-beta.4",
22+
"@contentstack/cli-utilities": "~2.0.0-beta.4",
2323
"@oclif/core": "^4.3.0",
2424
"@oclif/plugin-help": "^6.2.28",
25-
"chalk": "^4.1.2",
25+
"chalk": "^5.6.2",
2626
"fast-csv": "^4.3.6",
2727
"fs-extra": "^11.3.0",
2828
"lodash": "^4.17.23",

packages/contentstack-audit/src/audit-base-command.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk';
1+
import { getChalk } from '@contentstack/cli-utilities';
22
import * as csv from 'fast-csv';
33
import { copy } from 'fs-extra';
44
import { v4 as uuid } from 'uuid';
@@ -55,7 +55,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
5555
minWidth: 7,
5656
header: 'Fix Status',
5757
get: (row: any) => {
58-
return row.fixStatus === 'Fixed' ? chalk.greenBright(row.fixStatus) : chalk.redBright(row.fixStatus);
58+
return row.fixStatus === 'Fixed' ? getChalk().greenBright(row.fixStatus) : getChalk().redBright(row.fixStatus);
5959
},
6060
},
6161
};
@@ -548,7 +548,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
548548
value: 'missingRefs',
549549
alias: 'Missing references',
550550
formatter: (cellValue: any) => {
551-
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
551+
return getChalk().red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
552552
},
553553
},
554554
{
@@ -588,7 +588,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
588588
value: key,
589589
formatter: (cellValue: any) => {
590590
if (key === 'fixStatus' || key === 'Fixable' || key === 'Fixed') {
591-
return chalk.green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
591+
return getChalk().green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
592592
} else if (
593593
key === 'content_types' ||
594594
key === 'branches' ||
@@ -598,9 +598,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
598598
key === 'Non-Fixable' ||
599599
key === 'Not-Fixed'
600600
) {
601-
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
601+
return getChalk().red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
602602
} else {
603-
return chalk.white(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
603+
return getChalk().white(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
604604
}
605605
},
606606
}));

packages/contentstack-audit/src/types/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Color } from "chalk";
1+
import type { ForegroundColorName } from 'chalk';
22
import { PrintOptions } from "@contentstack/cli-utilities";
33

44
import config from "../config";
@@ -26,7 +26,7 @@ export type LoggerType = "info" | "warn" | "error" | "debug" | 'hidden';
2626
export type PrintType = {
2727
message: string;
2828
bold?: boolean;
29-
color?: typeof Color;
29+
color?: ForegroundColorName;
3030
};
3131

3232
export type JSONFlagOptions = {

packages/contentstack-audit/src/util/log.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import map from 'lodash/map';
22
import winston from 'winston';
3-
import chalk, { Chalk } from 'chalk';
3+
import { getChalk, ChalkInstance } from '@contentstack/cli-utilities';
44
import replace from 'lodash/replace';
55
import isObject from 'lodash/isObject';
66
import { normalize, resolve } from 'path';
@@ -170,10 +170,11 @@ export default class Logger {
170170
* @param printInput - An array of objects with the following properties:
171171
*/
172172
export function print(printInput: Array<PrintType>): void {
173+
const chalk = getChalk();
173174
const str = map(printInput, ({ message, bold, color }: PrintType) => {
174-
let chalkFn: Chalk = chalk;
175-
if (color) chalkFn = chalkFn[color];
176-
if (bold) chalkFn = chalkFn.bold;
175+
let chalkFn: ChalkInstance = chalk;
176+
if (color) chalkFn = chalkFn[color] as ChalkInstance;
177+
if (bold) chalkFn = chalkFn.bold as ChalkInstance;
177178

178179
return chalkFn(message);
179180
}).join(' ');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @contentstack/cli-utilities uses lazy-loaded Chalk 5; preload before tests that hit cliux.
3+
*/
4+
const { loadChalk } = require('@contentstack/cli-utilities');
5+
6+
exports.mochaHooks = {
7+
beforeAll() {
8+
this.timeout(30_000);
9+
return loadChalk();
10+
},
11+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": ["test/helpers/mocha-root-hooks.js"],
3+
"recursive": true,
4+
"timeout": 60000
5+
}

packages/contentstack-bootstrap/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "2.0.0-beta.12",
4+
"version": "2.0.0-beta.13",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -16,10 +16,10 @@
1616
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
1717
},
1818
"dependencies": {
19-
"@contentstack/cli-cm-seed": "~2.0.0-beta.11",
20-
"@contentstack/cli-command": "~2.0.0-beta.3",
21-
"@contentstack/cli-utilities": "~2.0.0-beta.3",
22-
"@contentstack/cli-config": "~2.0.0-beta.4",
19+
"@contentstack/cli-cm-seed": "~2.0.0-beta.12",
20+
"@contentstack/cli-command": "~2.0.0-beta.4",
21+
"@contentstack/cli-utilities": "~2.0.0-beta.4",
22+
"@contentstack/cli-config": "~2.0.0-beta.5",
2323
"@oclif/core": "^4.3.0",
2424
"@oclif/plugin-help": "^6.2.37",
2525
"inquirer": "12.11.1",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @contentstack/cli-utilities uses lazy-loaded Chalk 5; preload before tests that hit cliux.
3+
*/
4+
const { loadChalk } = require('@contentstack/cli-utilities');
5+
6+
exports.mochaHooks = {
7+
beforeAll() {
8+
this.timeout(30_000);
9+
return loadChalk();
10+
},
11+
};

0 commit comments

Comments
 (0)