Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@contentstack/cli-utilities": "~2.0.0-beta.2",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.3.0",
"lodash": "^4.17.23",
Expand Down
12 changes: 6 additions & 6 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import * as csv from 'fast-csv';
import { copy } from 'fs-extra';
import { v4 as uuid } from 'uuid';
Expand Down Expand Up @@ -55,7 +55,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
minWidth: 7,
header: 'Fix Status',
get: (row: any) => {
return row.fixStatus === 'Fixed' ? chalk.greenBright(row.fixStatus) : chalk.redBright(row.fixStatus);
return row.fixStatus === 'Fixed' ? getChalk().greenBright(row.fixStatus) : getChalk().redBright(row.fixStatus);
},
},
};
Expand Down Expand Up @@ -548,7 +548,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
value: 'missingRefs',
alias: 'Missing references',
formatter: (cellValue: any) => {
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
return getChalk().red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
},
},
{
Expand Down Expand Up @@ -588,7 +588,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
value: key,
formatter: (cellValue: any) => {
if (key === 'fixStatus' || key === 'Fixable' || key === 'Fixed') {
return chalk.green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
return getChalk().green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
} else if (
key === 'content_types' ||
key === 'branches' ||
Expand All @@ -598,9 +598,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
key === 'Non-Fixable' ||
key === 'Not-Fixed'
) {
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
return getChalk().red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
} else {
return chalk.white(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
return getChalk().white(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
}
},
}));
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-audit/src/types/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Color } from "chalk";
import type { ForegroundColorName } from 'chalk';
import { PrintOptions } from "@contentstack/cli-utilities";

import config from "../config";
Expand Down Expand Up @@ -26,7 +26,7 @@ export type LoggerType = "info" | "warn" | "error" | "debug" | 'hidden';
export type PrintType = {
message: string;
bold?: boolean;
color?: typeof Color;
color?: ForegroundColorName;
};

export type JSONFlagOptions = {
Expand Down
9 changes: 5 additions & 4 deletions packages/contentstack-audit/src/util/log.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import map from 'lodash/map';
import winston from 'winston';
import chalk, { Chalk } from 'chalk';
import { getChalk, ChalkInstance } from '@contentstack/cli-utilities';
import replace from 'lodash/replace';
import isObject from 'lodash/isObject';
import { normalize, resolve } from 'path';
Expand Down Expand Up @@ -170,10 +170,11 @@ export default class Logger {
* @param printInput - An array of objects with the following properties:
*/
export function print(printInput: Array<PrintType>): void {
const chalk = getChalk();
const str = map(printInput, ({ message, bold, color }: PrintType) => {
let chalkFn: Chalk = chalk;
if (color) chalkFn = chalkFn[color];
if (bold) chalkFn = chalkFn.bold;
let chalkFn: ChalkInstance = chalk;
if (color) chalkFn = chalkFn[color] as ChalkInstance;
if (bold) chalkFn = chalkFn.bold as ChalkInstance;

return chalkFn(message);
}).join(' ');
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"@contentstack/cli-utilities": "~2.0.0-beta.2",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"just-diff": "^6.0.2",
"lodash": "^4.17.23"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-branches/src/branch/merge-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os from 'os';
import path from 'path';
import forEach from 'lodash/forEach';
import { cliux } from '@contentstack/cli-utilities';
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import { MergeInputOptions, MergeSummary } from '../interfaces';
import {
selectMergeStrategy,
Expand Down Expand Up @@ -140,15 +140,15 @@ export default class MergeHandler {
const strategyName = this.mergeSettings.strategy;

if (allEmpty) {
cliux.print(chalk.red(`No items selected according to the '${strategyName}' strategy.`));
cliux.print(getChalk().red(`No items selected according to the '${strategyName}' strategy.`));
process.exit(1);
}

for (const [type, { exists, empty }] of Object.entries(moduleStatus)) {
if (exists && empty) {
const readable = type === 'contentType' ? 'Content Types' : 'Global fields';
cliux.print('\n')
cliux.print(chalk.yellow(`Note: No ${readable} selected according to the '${strategyName}' strategy.`));
cliux.print(getChalk().yellow(`Note: No ${readable} selected according to the '${strategyName}' strategy.`));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TableHeader,
} from '@contentstack/cli-utilities';
import { getbranchesList, getbranchConfig, interactive, handleErrorMsg } from '../../../utils/index';
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
export default class BranchListCommand extends Command {
static description: string = messageHandler.parse('List the branches'); // Note: Update the description

Expand Down Expand Up @@ -54,10 +54,10 @@ export default class BranchListCommand extends Command {

if (!verbose) {
currentBranch[0]?.Source
? cliux.print(`* ${chalk.bold(currentBranch[0].Branch)} (source: ${currentBranch[0].Source})`, {
? cliux.print(`* ${getChalk().bold(currentBranch[0].Branch)} (source: ${currentBranch[0].Source})`, {
color: 'blue',
})
: cliux.print(`* ${chalk.bold(currentBranch[0].Branch)}`, {
: cliux.print(`* ${getChalk().bold(currentBranch[0].Branch)}`, {
color: 'blue',
});

Expand Down
20 changes: 10 additions & 10 deletions packages/contentstack-branches/src/utils/branch-diff-utility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import forEach from 'lodash/forEach';
import padStart from 'lodash/padStart';
import startCase from 'lodash/startCase';
Expand Down Expand Up @@ -196,19 +196,19 @@ function printCompactTextView(branchTextRes: BranchCompactTextRes): void {
cliux.print(' ');
forEach(branchTextRes.added, (diff: BranchDiffRes) => {
if (diff.merge_strategy !== 'ignore') {
cliux.print(chalk.green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
cliux.print(getChalk().green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
}
});

forEach(branchTextRes.modified, (diff: BranchDiffRes) => {
if (diff.merge_strategy !== 'ignore') {
cliux.print(chalk.blue(`± '${diff.title}' ${startCase(camelCase(diff.type))}`));
cliux.print(getChalk().blue(`± '${diff.title}' ${startCase(camelCase(diff.type))}`));
}
});

forEach(branchTextRes.deleted, (diff: BranchDiffRes) => {
if (diff.merge_strategy !== 'ignore') {
cliux.print(chalk.red(`- '${diff.title}' ${startCase(camelCase(diff.type))}`));
cliux.print(getChalk().red(`- '${diff.title}' ${startCase(camelCase(diff.type))}`));
}
});
}
Expand Down Expand Up @@ -442,16 +442,16 @@ function printVerboseTextView(branchTextRes: BranchDiffVerboseRes): void {
if (branchTextRes.modified?.length || branchTextRes.added?.length || branchTextRes.deleted?.length) {
cliux.print(' ');
forEach(branchTextRes.added, (diff: BranchDiffRes) => {
cliux.print(chalk.green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
cliux.print(getChalk().green(`+ '${diff.title}' ${startCase(camelCase(diff.type))}`));
});

forEach(branchTextRes.modified, (diff: BranchModifiedDetails) => {
cliux.print(chalk.blue(`± '${diff.moduleDetails.title}' ${startCase(camelCase(diff.moduleDetails.type))}`));
cliux.print(getChalk().blue(`± '${diff.moduleDetails.title}' ${startCase(camelCase(diff.moduleDetails.type))}`));
printModifiedFields(diff.modifiedFields);
});

forEach(branchTextRes.deleted, (diff: BranchDiffRes) => {
cliux.print(chalk.red(`- '${diff.title}' ${startCase(camelCase(diff.type))}`));
cliux.print(getChalk().red(`- '${diff.title}' ${startCase(camelCase(diff.type))}`));
});
}
}
Expand All @@ -466,17 +466,17 @@ function printModifiedFields(modfiedFields: ModifiedFieldsInput): void {
forEach(modfiedFields.modified, (diff: ModifiedFieldsType) => {
const field: string = diff.field ? `${diff.field}` : 'field';
const fieldDetail = diff.path ? `(${diff.path}) ${field}`: `${field}`;
cliux.print(` ${chalk.blue(`± "${diff.displayName}" ${fieldDetail}`)}`);
cliux.print(` ${getChalk().blue(`± "${diff.displayName}" ${fieldDetail}`)}`);
});

forEach(modfiedFields.added, (diff: ModifiedFieldsType) => {
const field: string = diff.field ? `${diff.field} field` : 'field';
cliux.print(` ${chalk.green(`+ "${diff.displayName}" (${diff.path}) ${field}`)}`);
cliux.print(` ${getChalk().green(`+ "${diff.displayName}" (${diff.path}) ${field}`)}`);
});

forEach(modfiedFields.deleted, (diff: ModifiedFieldsType) => {
const field: string = diff.field ? `${diff.field} field` : 'field';
cliux.print(` ${chalk.red(`- "${diff.displayName}" (${diff.path}) ${field}`)}`);
cliux.print(` ${getChalk().red(`- "${diff.displayName}" (${diff.path}) ${field}`)}`);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@contentstack/cli-utilities": "~2.0.0-beta.2",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"inquirer": "12.11.1",
"lodash": "^4.17.23",
"merge": "^2.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-clone/src/core/util/clone-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ora, default as ora } from 'ora';
import * as path from 'path';
import inquirer from 'inquirer';
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import * as fs from 'fs';
import { rimraf } from 'rimraf';
import { CustomAbortController } from './abort-controller';
Expand Down Expand Up @@ -170,7 +170,7 @@ export class CloneHandler {
}

displayBackOptionMessage(): void {
process.stdout.write(chalk.cyan('\nPress shift & left arrow together to undo the operation\n'));
process.stdout.write(getChalk().cyan('\nPress shift & left arrow together to undo the operation\n'));
}

setBackKeyPressHandler(backKeyPressHandler: (...args: any[]) => void): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"async": "^3.2.6",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"lodash": "^4.17.23",
"merge": "^2.1.1",
"mkdirp": "^1.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export/src/export/modules/assets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import map from 'lodash/map';
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import chunk from 'lodash/chunk';
import first from 'lodash/first';
import merge from 'lodash/merge';
Expand Down Expand Up @@ -57,7 +57,7 @@ export default class ExportAssets extends BaseClass {
log.debug('Fetching assets and folders count...', this.exportConfig.context);
// NOTE step 1: Get assets and it's folder count in parallel
const [assetsCount, assetsFolderCount] = await this.withLoadingSpinner(
`${chalk.bold('ASSETS')}: Analyzing stack content...`,
`${getChalk().bold('ASSETS')}: Analyzing stack content...`,
() => Promise.all([this.getAssetsCount(), this.getAssetsCount(true)]),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import-setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@contentstack/cli-utilities": "~2.0.0-beta.2",
"@oclif/core": "^4.3.0",
"big-json": "^3.2.0",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"fs-extra": "^11.3.0",
"lodash": "^4.17.23",
"merge": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as chalk from 'chalk';
import { log, fsUtil } from '../../utils';
import { join } from 'path';
import { AssetRecord, ImportConfig, ModuleClassParams } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as chalk from 'chalk';
import { log, fsUtil } from '../../utils';
import { join } from 'path';
import { ImportConfig, ModuleClassParams } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as chalk from 'chalk';
import { log, fsUtil } from '../../utils';
import { join } from 'path';
import { ImportConfig, ModuleClassParams } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as chalk from 'chalk';
import { log, fsUtil } from '../../utils';
import { join } from 'path';
import { ImportConfig, ModuleClassParams } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import { log as defaultLog } from '@contentstack/cli-utilities';
import { ImportConfig } from 'src/types';

Expand All @@ -22,8 +22,8 @@ export const validateBranch = async (
const data = await stackAPIClient.branch(branch).fetch();
if (data && typeof data === 'object') {
if (data.error_message) {
log.error(chalk.red(data.error_message), { error: data.error_message });
log.error(chalk.red('No branch found with the name ' + branch), { branch });
log.error(getChalk().red(data.error_message), { error: data.error_message });
log.error(getChalk().red('No branch found with the name ' + branch), { branch });
reject({ message: 'No branch found with the name ' + branch, error: data.error_message });
} else {
resolve(data);
Expand All @@ -32,7 +32,7 @@ export const validateBranch = async (
reject({ message: 'No branch found with the name ' + branch, error: {} });
}
} catch (error) {
log.error(chalk.red('No branch found with the name ' + branch), { error, branch });
log.error(getChalk().red('No branch found with the name ' + branch), { error, branch });
reject({ message: 'No branch found with the name ' + branch, error });
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@oclif/core": "^4.3.0",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
"chalk": "^4.1.2",
"chalk": "^5.6.2",
"debug": "^4.4.3",
"fs-extra": "^11.3.3",
"lodash": "^4.17.23",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import map from 'lodash/map';
import omit from 'lodash/omit';
import find from 'lodash/find';
Expand Down Expand Up @@ -551,7 +551,7 @@ export default class ImportMarketplaceApps extends BaseClass {

if (
await cliux.confirm(
chalk.yellow(
getChalk().yellow(
'WARNING!!! The above error may have an impact if the failed app is referenced in entries/content type. Would you like to proceed? (y/n)',
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { getChalk } from '@contentstack/cli-utilities';
import map from 'lodash/map';
import find from 'lodash/find';
import { join } from 'node:path';
Expand Down Expand Up @@ -290,7 +290,7 @@ export default class ImportWorkflows extends BaseClass {
} else {
if (workflow.admin_users !== undefined) {
log.info(
chalk.yellow('We are skipping import of `Workflow superuser(s)` from workflow'),
getChalk().yellow('We are skipping import of `Workflow superuser(s)` from workflow'),
this.importConfig.context,
);
delete workflow.admin_users;
Expand Down
1 change: 0 additions & 1 deletion packages/contentstack-import/src/utils/common-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import { PATH_CONSTANTS } from '../constants';
import { readFileSync, readdirSync, readFile, fileExistsSync } from './file-helper';

import chalk from 'chalk';
import defaultConfig from '../config';
import promiseLimit from 'promise-limit';
import { ImportConfig } from '../types';
Expand Down
Loading
Loading