Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fileignoreconfig:
- filename: pnpm-lock.yaml
checksum: 901fcf828dc9d8d85277c767cd468791388a4a3b0cb30525bcdcb86d009be6f4
version: '1.0'
- filename: pnpm-lock.yaml
checksum: 0a12c6c1e4df121f6a217425ef0bd7b1acccc1cd3f972157f7ca7480281277fd
version: "1.0"
3 changes: 2 additions & 1 deletion packages/contentstack-audit/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"require": [
"test/helpers/init.js",
"ts-node/register"
"ts-node/register",
"test/helpers/mocha-root-hooks.js"
],
"watch-extensions": [
"ts"
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.8",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -18,11 +18,11 @@
"/oclif.manifest.json"
],
"dependencies": {
"@contentstack/cli-command": "~2.0.0-beta.3",
"@contentstack/cli-utilities": "~2.0.0-beta.3",
"@contentstack/cli-command": "~2.0.0-beta.4",
"@contentstack/cli-utilities": "~2.0.0-beta.4",
"@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
11 changes: 11 additions & 0 deletions packages/contentstack-audit/test/helpers/mocha-root-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @contentstack/cli-utilities uses lazy-loaded Chalk 5; preload before tests that hit cliux.
*/
const { loadChalk } = require('@contentstack/cli-utilities');

exports.mochaHooks = {
beforeAll() {
this.timeout(30_000);
return loadChalk();
},
};
5 changes: 5 additions & 0 deletions packages/contentstack-bootstrap/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": ["test/helpers/mocha-root-hooks.js"],
"recursive": true,
"timeout": 60000
}
10 changes: 5 additions & 5 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "2.0.0-beta.12",
"version": "2.0.0-beta.13",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -16,10 +16,10 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~2.0.0-beta.11",
"@contentstack/cli-command": "~2.0.0-beta.3",
"@contentstack/cli-utilities": "~2.0.0-beta.3",
"@contentstack/cli-config": "~2.0.0-beta.4",
"@contentstack/cli-cm-seed": "~2.0.0-beta.12",
"@contentstack/cli-command": "~2.0.0-beta.4",
"@contentstack/cli-utilities": "~2.0.0-beta.4",
"@contentstack/cli-config": "~2.0.0-beta.5",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.37",
"inquirer": "12.11.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @contentstack/cli-utilities uses lazy-loaded Chalk 5; preload before tests that hit cliux.
*/
const { loadChalk } = require('@contentstack/cli-utilities');

exports.mochaHooks = {
beforeAll() {
this.timeout(30_000);
return loadChalk();
},
};
3 changes: 2 additions & 1 deletion packages/contentstack-branches/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"require": [
"test/helpers/init.js",
"ts-node/register",
"source-map-support/register"
"source-map-support/register",
"test/helpers/mocha-root-hooks.js"
],
"watch-extensions": [
"ts"
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~2.0.0-beta.3",
"@contentstack/cli-command": "~2.0.0-beta.4",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"@contentstack/cli-utilities": "~2.0.0-beta.3",
"chalk": "^4.1.2",
"@contentstack/cli-utilities": "~2.0.0-beta.4",
"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
11 changes: 11 additions & 0 deletions packages/contentstack-branches/test/helpers/mocha-root-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @contentstack/cli-utilities uses lazy-loaded Chalk 5; preload before tests that hit cliux.
*/
const { loadChalk } = require('@contentstack/cli-utilities');

exports.mochaHooks = {
beforeAll() {
this.timeout(30_000);
return loadChalk();
},
};
2 changes: 1 addition & 1 deletion packages/contentstack-clone/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": ["test/helpers/init.js", "ts-node/register", "source-map-support/register"],
"require": ["test/helpers/init.js", "ts-node/register", "source-map-support/register", "test/helpers/mocha-root-hooks.js"],
"watch-extensions": [
"ts"
],
Expand Down
12 changes: 6 additions & 6 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@contentstack/cli-cm-clone",
"description": "Contentstack stack clone plugin",
"version": "2.0.0-beta.13",
"version": "2.0.0-beta.14",
"author": "Contentstack",
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~2.0.0-beta.12",
"@contentstack/cli-cm-import": "~2.0.0-beta.12",
"@contentstack/cli-command": "~2.0.0-beta.3",
"@contentstack/cli-utilities": "~2.0.0-beta.3",
"@contentstack/cli-cm-export": "~2.0.0-beta.13",
"@contentstack/cli-cm-import": "~2.0.0-beta.13",
"@contentstack/cli-command": "~2.0.0-beta.4",
"@contentstack/cli-utilities": "~2.0.0-beta.4",
"@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
Loading
Loading