Skip to content

Commit

Permalink
fix(deps): reduce chalk (#1042)
Browse files Browse the repository at this point in the history
* feat: use oclif/core v4 and sf-plugins-core v10

* chore: use sf-plugins-core 10

* chore: bump to non-beta

* chore: lockfile sdr

* fix(deps): reduce chalk

* chore: bump STL

* chore: bump things

---------

Co-authored-by: Mike Donnalley <[email protected]>
  • Loading branch information
mshanemc and mdonnalley authored Jun 10, 2024
1 parent ce84c49 commit d09203a
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 287 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
"@salesforce/apex-node": "^6.1.2",
"@salesforce/core": "^7.3.11",
"@salesforce/kit": "^3.1.2",
"@salesforce/plugin-info": "^3.3.4",
"@salesforce/plugin-info": "^3.3.6",
"@salesforce/sf-plugins-core": "^10.0.0",
"@salesforce/source-deploy-retrieve": "^11.6.5",
"@salesforce/source-deploy-retrieve": "^11.6.6",
"@salesforce/source-tracking": "^6.5.1",
"@salesforce/ts-types": "^2.0.9",
"chalk": "^5.3.0"
"ansis": "^3.2.0"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^5.2.0",
"@salesforce/cli-plugins-testkit": "^5.3.9",
"@salesforce/cli-plugins-testkit": "^5.3.10",
"@salesforce/dev-scripts": "^10.1.0",
"@salesforce/plugin-command-reference": "^3.1.0",
"@salesforce/plugin-command-reference": "^3.1.1",
"@salesforce/schemas": "^1.9.0",
"@salesforce/source-testkit": "^2.2.22",
"@salesforce/source-testkit": "^2.2.26",
"@salesforce/ts-sinon": "^1.4.19",
"cross-env": "^7.0.3",
"eslint-plugin-sf-plugin": "^1.18.4",
"oclif": "^4.13.1",
"eslint-plugin-sf-plugin": "^1.18.5",
"oclif": "^4.13.5",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/project/delete/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -187,7 +187,7 @@ export class Source extends SfCommand<DeleteSourceJson> {

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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/commands/project/delete/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
*/

import { Messages } from '@salesforce/core';
import chalk from 'chalk';
import { SourceTracking } from '@salesforce/source-tracking';
import {
Flags,
loglevel,
orgApiVersionFlagWithDeprecations,
requiredOrgFlagWithDeprecations,
SfCommand,
StandardColors,
} from '@salesforce/sf-plugins-core';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand Down Expand Up @@ -47,7 +47,10 @@ export class DeleteTracking extends SfCommand<DeleteTrackingResult> {
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'],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/project/deploy/quick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -90,7 +90,7 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/project/deploy/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -124,7 +124,7 @@ export default class DeployMetadataResume extends SfCommand<DeployResultJson> {
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);

Expand Down
4 changes: 2 additions & 2 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -228,7 +228,7 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
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']) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/project/deploy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -193,7 +193,7 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
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);
Expand Down
6 changes: 3 additions & 3 deletions src/formatters/deleteResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
{
Expand Down Expand Up @@ -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(`Component Failures [${failures.length}]`),
'no-truncate': true,
}
);
Expand Down
13 changes: 7 additions & 6 deletions src/formatters/testResultsFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* 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 } from '@salesforce/sf-plugins-core/StandardColors';
import { Ux } from '@salesforce/sf-plugins-core/Ux';
import ansis from 'ansis';
import {
CodeCoverage,
CodeCoverageWarnings,
Expand Down Expand Up @@ -77,7 +78,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}`);
}
}
Expand All @@ -91,12 +92,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();
}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T extends FileResponse | FileResponseSuccess | FileResponseFailure>(fr: T): T =>
Expand Down Expand Up @@ -49,11 +49,11 @@ export const getFileResponseSuccessProps = (
});

export function error(message: string): string {
return StandardColors.error(chalk.bold(message));
return StandardColors.error(message);
}

export function success(message: string): string {
return StandardColors.success(chalk.bold(message));
return StandardColors.success(message);
}

export const check = StandardColors.success('✓');
21 changes: 10 additions & 11 deletions src/utils/previewOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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 { Messages } from '@salesforce/core';
import {
ComponentSet,
Expand Down Expand Up @@ -211,51 +210,51 @@ 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(messages.getMessage('deploy.header', [files.length])));
ux.table<PreviewFile>(files, columns);
}
};

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(messages.getMessage('retrieve.header', [files.length])));
ux.table<PreviewFile>(files, columns);
}
};

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(messages.getMessage('delete.header', [files.length])));
ux.table<PreviewFile>(files, columns);
}
};

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(messages.getMessage('conflicts.header', [files.length])));
ux.table<PreviewFile>(files, columns, { sort: 'path' });
}
};

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<PreviewFile>(files, columns, { sort: 'path' });
}
};
Expand Down
Loading

0 comments on commit d09203a

Please sign in to comment.