From 17c7244940d6f5b38950e78238dbd7b0aa2bc4d5 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 7 Jun 2024 10:49:38 -0500 Subject: [PATCH] fix(deps): reduce chalk --- package.json | 2 +- src/commands/project/delete/source.ts | 4 ++-- src/commands/project/delete/tracking.ts | 7 +++++-- src/commands/project/deploy/quick.ts | 4 ++-- src/commands/project/deploy/resume.ts | 4 ++-- src/commands/project/deploy/start.ts | 4 ++-- src/commands/project/deploy/validate.ts | 4 ++-- src/formatters/deleteResultFormatter.ts | 6 +++--- src/formatters/testResultsFormatter.ts | 12 ++++++------ src/utils/output.ts | 8 ++++---- src/utils/previewOutput.ts | 22 +++++++++++----------- 11 files changed, 40 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index a4e6f14d..bc1b8a76 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@salesforce/source-deploy-retrieve": "^11.6.5", "@salesforce/source-tracking": "^6.3.4", "@salesforce/ts-types": "^2.0.9", - "chalk": "^5.3.0" + "ansis": "^3.2.0" }, "devDependencies": { "@oclif/plugin-command-snapshot": "^5.2.0", diff --git a/src/commands/project/delete/source.ts b/src/commands/project/delete/source.ts index 9dcb0d1c..be15ef1b 100644 --- a/src/commands/project/delete/source.ts +++ b/src/commands/project/delete/source.ts @@ -33,7 +33,7 @@ import { requiredOrgFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core'; -import chalk from 'chalk'; +import ansis from 'ansis'; import { writeConflictTable } from '../../../utils/conflicts.js'; import { isNonDecomposedCustomLabel, isNonDecomposedCustomLabelsOrCustomLabel } from '../../../utils/metadataTypes.js'; import { getFileResponseSuccessProps } from '../../../utils/output.js'; @@ -187,7 +187,7 @@ export class Source extends SfCommand { if (!this.components.length) { // if we didn't find any components to delete, let the user know and exit - this.styledHeader(chalk.blue('Deleted Source')); + this.styledHeader(ansis.blue('Deleted Source')); this.log('No results found'); return; } diff --git a/src/commands/project/delete/tracking.ts b/src/commands/project/delete/tracking.ts index 4660b580..c147114f 100644 --- a/src/commands/project/delete/tracking.ts +++ b/src/commands/project/delete/tracking.ts @@ -6,7 +6,6 @@ */ import { Messages } from '@salesforce/core'; -import chalk from 'chalk'; import { SourceTracking } from '@salesforce/source-tracking'; import { Flags, @@ -14,6 +13,7 @@ import { orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, SfCommand, + StandardColors, } from '@salesforce/sf-plugins-core'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); @@ -47,7 +47,10 @@ export class DeleteTracking extends SfCommand { const { flags } = await this.parse(DeleteTracking); let clearedFiles: string[] = []; - if (flags['no-prompt'] || (await this.confirm({ message: chalk.dim(messages.getMessage('promptMessage')) }))) { + if ( + flags['no-prompt'] || + (await this.confirm({ message: StandardColors.info(messages.getMessage('promptMessage')) })) + ) { const sourceTracking = await SourceTracking.create({ project: this.project!, org: flags['target-org'], diff --git a/src/commands/project/deploy/quick.ts b/src/commands/project/deploy/quick.ts index aba30100..b842bbd8 100644 --- a/src/commands/project/deploy/quick.ts +++ b/src/commands/project/deploy/quick.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import chalk from 'chalk'; +import ansis from 'ansis'; import { Messages, Org } from '@salesforce/core'; import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core'; import { MetadataApiDeploy, RequestStatus } from '@salesforce/source-deploy-retrieve'; @@ -90,7 +90,7 @@ export default class DeployMetadataQuick extends SfCommand { id: jobId, rest: api === API['REST'], }); - this.log(`Deploy ID: ${chalk.bold(deployId)}`); + this.log(`Deploy ID: ${ansis.bold(deployId)}`); if (flags.async) { const asyncFormatter = new AsyncDeployResultFormatter(deployId); diff --git a/src/commands/project/deploy/resume.ts b/src/commands/project/deploy/resume.ts index 9c78e8f3..3dbfe7c0 100644 --- a/src/commands/project/deploy/resume.ts +++ b/src/commands/project/deploy/resume.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import chalk from 'chalk'; +import ansis from 'ansis'; import { EnvironmentVariable, Messages, Org, SfError } from '@salesforce/core'; import { SfCommand, toHelpSection, Flags } from '@salesforce/sf-plugins-core'; import { DeployResult, MetadataApiDeploy } from '@salesforce/source-deploy-retrieve'; @@ -124,7 +124,7 @@ export default class DeployMetadataResume extends SfCommand { jobId ); - this.log(`Deploy ID: ${chalk.bold(jobId)}`); + this.log(`Deploy ID: ${ansis.bold(jobId)}`); new DeployProgress(deploy, this.jsonEnabled()).start(); result = await deploy.pollStatus(500, wait.seconds); diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index 689b335b..cea36046 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import chalk from 'chalk'; +import ansis from 'ansis'; import { EnvironmentVariable, Lifecycle, Messages, OrgConfigProperties, SfError } from '@salesforce/core'; import { DeployVersionData } from '@salesforce/source-deploy-retrieve'; import { Duration } from '@salesforce/kit'; @@ -228,7 +228,7 @@ export default class DeployMetadata extends SfCommand { if (!deploy.id) { throw new SfError('The deploy id is not available.'); } - this.log(`Deploy ID: ${chalk.bold(deploy.id)}`); + this.log(`Deploy ID: ${ansis.bold(deploy.id)}`); if (flags.async) { if (flags['coverage-formatters']) { diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index 6f791377..c1638711 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -6,7 +6,7 @@ */ import * as os from 'node:os'; -import chalk from 'chalk'; +import ansis from 'ansis'; import { EnvironmentVariable, Lifecycle, Messages, OrgConfigProperties, SfError } from '@salesforce/core'; import { CodeCoverageWarnings, DeployVersionData, RequestStatus } from '@salesforce/source-deploy-retrieve'; import { Duration, ensureArray } from '@salesforce/kit'; @@ -193,7 +193,7 @@ export default class DeployMetadataValidate extends SfCommand if (!deploy.id) { throw new SfError('The deploy id is not available.'); } - this.log(`Deploy ID: ${chalk.bold(deploy.id)}`); + this.log(`Deploy ID: ${ansis.bold(deploy.id)}`); if (flags.async) { const asyncFormatter = new AsyncDeployResultFormatter(deploy.id); diff --git a/src/formatters/deleteResultFormatter.ts b/src/formatters/deleteResultFormatter.ts index 634b27d3..9345ff81 100644 --- a/src/formatters/deleteResultFormatter.ts +++ b/src/formatters/deleteResultFormatter.ts @@ -7,7 +7,7 @@ import { Ux } from '@salesforce/sf-plugins-core'; import { DeployResult, FileResponse, FileResponseSuccess, RequestStatus } from '@salesforce/source-deploy-retrieve'; import { ensureArray } from '@salesforce/kit'; -import chalk from 'chalk'; +import ansis from 'ansis'; import { StandardColors } from '@salesforce/sf-plugins-core'; import { DeleteSourceJson, Formatter, TestLevel, isSdrSuccess } from '../utils/types.js'; import { @@ -80,7 +80,7 @@ export class DeleteResultFormatter extends TestResultsFormatter implements Forma } ux.log(''); - ux.styledHeader(chalk.blue('Deleted Source')); + ux.styledHeader(ansis.blue('Deleted Source')); ux.table( successes.map(getFileResponseSuccessProps), { @@ -110,7 +110,7 @@ export class DeleteResultFormatter extends TestResultsFormatter implements Forma error: { header: 'Problem' }, }, { - title: StandardColors.error(chalk.bold(`Component Failures [${failures.length}]`)), + title: StandardColors.error(ansis.bold(`Component Failures [${failures.length}]`)), 'no-truncate': true, } ); diff --git a/src/formatters/testResultsFormatter.ts b/src/formatters/testResultsFormatter.ts index 5a9de963..003502fb 100644 --- a/src/formatters/testResultsFormatter.ts +++ b/src/formatters/testResultsFormatter.ts @@ -5,8 +5,8 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import os from 'node:os'; -import { Ux } from '@salesforce/sf-plugins-core'; -import chalk from 'chalk'; +import { StandardColors, Ux } from '@salesforce/sf-plugins-core'; +import ansis from 'ansis'; import { CodeCoverage, CodeCoverageWarnings, @@ -77,7 +77,7 @@ const displayVerboseTestSuccesses = (resultSuccesses: RunTestResult['successes'] ux.log(); ux.log(success(`Test Success [${successes.length}]`)); for (const test of successes) { - const testName = chalk.underline(`${test.name}.${test.methodName}`); + const testName = ansis.underline(`${test.name}.${test.methodName}`); ux.log(`${check} ${testName}`); } } @@ -91,12 +91,12 @@ const displayVerboseTestFailures = (response: MetadataApiDeployStatus): void => ux.log(); ux.log(error(`Test Failures [${failureCount}]`)); for (const test of failures) { - const testName = chalk.underline(`${test.name}.${test.methodName}`); + const testName = ansis.underline(`${test.name}.${test.methodName}`); ux.log(`• ${testName}`); - ux.log(` ${chalk.dim('message')}: ${test.message}`); + ux.log(` ${StandardColors.info('message')}: ${test.message}`); if (test.stackTrace) { const stackTrace = test.stackTrace.replace(/\n/g, `${os.EOL} `); - ux.log(` ${chalk.dim('stacktrace')}: ${os.EOL} ${stackTrace}`); + ux.log(` ${StandardColors.info('stacktrace')}: ${os.EOL} ${stackTrace}`); } ux.log(); } diff --git a/src/utils/output.ts b/src/utils/output.ts index fbc89724..7e9fcbef 100644 --- a/src/utils/output.ts +++ b/src/utils/output.ts @@ -6,12 +6,12 @@ */ import * as path from 'node:path'; -import chalk from 'chalk'; +import ansis from 'ansis'; import { StandardColors } from '@salesforce/sf-plugins-core'; import { FileResponse, FileResponseFailure, FileResponseSuccess } from '@salesforce/source-deploy-retrieve'; export function tableHeader(message: string): string { - return chalk.blue.bold(message); + return ansis.blue.bold(message); } export const makePathRelative = (fr: T): T => @@ -49,11 +49,11 @@ export const getFileResponseSuccessProps = ( }); export function error(message: string): string { - return StandardColors.error(chalk.bold(message)); + return StandardColors.error(ansis.bold(message)); } export function success(message: string): string { - return StandardColors.success(chalk.bold(message)); + return StandardColors.success(ansis.bold(message)); } export const check = StandardColors.success('✓'); diff --git a/src/utils/previewOutput.ts b/src/utils/previewOutput.ts index 2d506983..e729fa97 100644 --- a/src/utils/previewOutput.ts +++ b/src/utils/previewOutput.ts @@ -8,7 +8,7 @@ import { isAbsolute, relative, resolve } from 'node:path'; import { Ux } from '@salesforce/sf-plugins-core'; import { StandardColors } from '@salesforce/sf-plugins-core'; -import chalk from 'chalk'; +import ansis from 'ansis'; import { Messages } from '@salesforce/core'; import { ComponentSet, @@ -211,10 +211,10 @@ export const compileResults = ({ const printDeployTable = (files: PreviewFile[]): void => { ux.log(); if (files.length === 0) { - ux.log(chalk.dim(messages.getMessage('deploy.none'))); + ux.log(StandardColors.info(messages.getMessage('deploy.none'))); } else { // not using table title property to avoid all the ASCII art - ux.log(StandardColors.success(chalk.bold(messages.getMessage('deploy.header', [files.length])))); + ux.log(StandardColors.success(ansis.bold(messages.getMessage('deploy.header', [files.length])))); ux.table(files, columns); } }; @@ -222,10 +222,10 @@ const printDeployTable = (files: PreviewFile[]): void => { const printRetrieveTable = (files: PreviewFile[]): void => { ux.log(); if (files.length === 0) { - ux.log(chalk.dim(messages.getMessage('retrieve.none'))); + ux.log(StandardColors.info(messages.getMessage('retrieve.none'))); } else { // not using table title property to avoid all the ASCII art - ux.log(StandardColors.success(chalk.bold(messages.getMessage('retrieve.header', [files.length])))); + ux.log(StandardColors.success(ansis.bold(messages.getMessage('retrieve.header', [files.length])))); ux.table(files, columns); } }; @@ -233,9 +233,9 @@ const printRetrieveTable = (files: PreviewFile[]): void => { const printDeleteTable = (files: PreviewFile[]): void => { ux.log(); if (files.length === 0) { - ux.log(chalk.dim(messages.getMessage('delete.none'))); + ux.log(StandardColors.info(messages.getMessage('delete.none'))); } else { - ux.log(StandardColors.warning(chalk.bold(messages.getMessage('delete.header', [files.length])))); + ux.log(StandardColors.warning(ansis.bold(messages.getMessage('delete.header', [files.length])))); ux.table(files, columns); } }; @@ -243,9 +243,9 @@ const printDeleteTable = (files: PreviewFile[]): void => { const printConflictsTable = (files: PreviewFile[]): void => { ux.log(); if (files.length === 0) { - ux.log(chalk.dim(messages.getMessage('conflicts.none'))); + ux.log(StandardColors.info(messages.getMessage('conflicts.none'))); } else { - ux.log(StandardColors.error(chalk.bold(messages.getMessage('conflicts.header', [files.length])))); + ux.log(StandardColors.error(ansis.bold(messages.getMessage('conflicts.header', [files.length])))); ux.table(files, columns, { sort: 'path' }); } }; @@ -253,9 +253,9 @@ const printConflictsTable = (files: PreviewFile[]): void => { const printIgnoredTable = (files: PreviewFile[], baseOperation: BaseOperation): void => { ux.log(); if (files.length === 0) { - ux.log(chalk.dim(messages.getMessage('ignored.none'))); + ux.log(StandardColors.info(messages.getMessage('ignored.none'))); } else { - ux.log(chalk.dim(messages.getMessage('ignored.header', [files.length, baseOperation]))); + ux.log(StandardColors.info(messages.getMessage('ignored.header', [files.length, baseOperation]))); ux.table(files, columns, { sort: 'path' }); } };