Skip to content

Commit 0ebac7c

Browse files
authored
feat: use sf-plugins-core and oclif/core v2 (#484)
* feat: bump sf-plugins-core and oclif/core * chore: bump deps
1 parent 4f906f2 commit 0ebac7c

File tree

5 files changed

+148
-101
lines changed

5 files changed

+148
-101
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^1.24.0",
8+
"@oclif/core": "^2.0.7",
99
"@salesforce/core": "^3.32.12",
1010
"@salesforce/kit": "^1.8.2",
11-
"@salesforce/sf-plugins-core": "^1.21.8",
11+
"@salesforce/sf-plugins-core": "^2.0.1",
1212
"@salesforce/source-deploy-retrieve": "^7.6.0",
1313
"@salesforce/source-tracking": "^2.2.19",
1414
"chalk": "^4.1.2",
@@ -18,10 +18,10 @@
1818
},
1919
"devDependencies": {
2020
"@oclif/plugin-command-snapshot": "^3.2.16",
21-
"@salesforce/cli-plugins-testkit": "^3.2.17",
21+
"@salesforce/cli-plugins-testkit": "^3.2.18",
2222
"@salesforce/dev-config": "^3.1.0",
2323
"@salesforce/dev-scripts": "^3.1.0",
24-
"@salesforce/plugin-command-reference": "^2.2.8",
24+
"@salesforce/plugin-command-reference": "^2.2.10",
2525
"@salesforce/plugin-config": "^2.3.0",
2626
"@salesforce/plugin-functions": "^1.17.4",
2727
"@salesforce/plugin-source": "^2.3.16",

src/utils/conflicts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { CliUx } from '@oclif/core';
8+
import { ux } from '@oclif/core';
99
import { ConflictResponse } from '@salesforce/source-tracking';
1010

1111
export const writeConflictTable = (conflicts: ConflictResponse[]): void => {
1212
// Interfaces cannot be casted to Record<string, unknown> so we have to cast to unknown first
1313
// See https://github.com/microsoft/TypeScript/issues/15300
14-
CliUx.ux.table(conflicts as unknown as Array<Record<string, unknown>>, {
14+
ux.table(conflicts as unknown as Array<Record<string, unknown>>, {
1515
state: { header: 'STATE' },
1616
fullName: { header: 'FULL NAME' },
1717
type: { header: 'TYPE' },

src/utils/output.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import * as os from 'os';
99
import * as path from 'path';
10-
import { CliUx } from '@oclif/core';
10+
import { ux } from '@oclif/core';
1111
import { blue, bold, dim, underline } from 'chalk';
1212
import {
1313
DeployResult,
@@ -183,7 +183,7 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
183183
replaced,
184184
}))
185185
);
186-
CliUx.ux.table(
186+
ux.table(
187187
replacements,
188188
{
189189
filePath: { header: 'PROJECT PATH' },
@@ -209,9 +209,9 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
209209
};
210210
const title = 'Deployed Source';
211211
const options = { title: tableHeader(title) };
212-
CliUx.ux.log();
212+
ux.log();
213213

214-
CliUx.ux.table(
214+
ux.table(
215215
successes.map((s) => ({ filePath: s.filePath, fullName: s.fullName, type: s.type, state: s.state })),
216216
columns,
217217
options
@@ -230,8 +230,8 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
230230
error: { header: 'Problem' },
231231
};
232232
const options = { title: error(`Component Failures [${failures.length}]`) };
233-
CliUx.ux.log();
234-
CliUx.ux.table(
233+
ux.log();
234+
ux.table(
235235
failures.map((f) => ({ problemType: f.problemType, fullName: f.fullName, error: f.error })),
236236
columns,
237237
options
@@ -250,14 +250,14 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
250250
};
251251

252252
const options = { title: tableHeader('Deleted Source') };
253-
CliUx.ux.log();
253+
ux.log();
254254

255-
CliUx.ux.table(getFileResponseSuccessProps(deletions), columns, options);
255+
ux.table(getFileResponseSuccessProps(deletions), columns, options);
256256
}
257257

258258
private displayTestResults(): void {
259259
if (this.testLevel === TestLevel.NoTestRun) {
260-
CliUx.ux.log();
260+
ux.log();
261261
return;
262262
}
263263

@@ -268,27 +268,27 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
268268
this.displayVerboseTestCoverage();
269269
}
270270

271-
CliUx.ux.log();
272-
CliUx.ux.log(tableHeader('Test Results Summary'));
271+
ux.log();
272+
ux.log(tableHeader('Test Results Summary'));
273273
const passing = this.result.response.numberTestsCompleted ?? 0;
274274
const failing = this.result.response.numberTestErrors ?? 0;
275275
const total = this.result.response.numberTestsTotal ?? 0;
276276
const time = this.result.response.details.runTestResult?.totalTime ?? 0;
277-
CliUx.ux.log(`Passing: ${passing}`);
278-
CliUx.ux.log(`Failing: ${failing}`);
279-
CliUx.ux.log(`Total: ${total}`);
280-
if (time) CliUx.ux.log(`Time: ${time}`);
277+
ux.log(`Passing: ${passing}`);
278+
ux.log(`Failing: ${failing}`);
279+
ux.log(`Total: ${total}`);
280+
if (time) ux.log(`Time: ${time}`);
281281
}
282282

283283
private displayVerboseTestSuccesses(): void {
284284
const successes = ensureArray(this.result.response.details.runTestResult?.successes);
285285
if (successes.length > 0) {
286286
const testSuccesses = sortTestResults(successes) as Successes[];
287-
CliUx.ux.log();
288-
CliUx.ux.log(success(`Test Success [${successes.length}]`));
287+
ux.log();
288+
ux.log(success(`Test Success [${successes.length}]`));
289289
for (const test of testSuccesses) {
290290
const testName = underline(`${test.name}.${test.methodName}`);
291-
CliUx.ux.log(`${check} ${testName}`);
291+
ux.log(`${check} ${testName}`);
292292
}
293293
}
294294
}
@@ -298,26 +298,26 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
298298
const failures = ensureArray(this.result.response.details.runTestResult?.failures);
299299
const failureCount = this.result.response.details.runTestResult?.numFailures;
300300
const testFailures = sortTestResults(failures) as Failures[];
301-
CliUx.ux.log();
302-
CliUx.ux.log(error(`Test Failures [${failureCount}]`));
301+
ux.log();
302+
ux.log(error(`Test Failures [${failureCount}]`));
303303
for (const test of testFailures) {
304304
const testName = underline(`${test.name}.${test.methodName}`);
305305
const stackTrace = test.stackTrace.replace(/\n/g, `${os.EOL} `);
306-
CliUx.ux.log(`• ${testName}`);
307-
CliUx.ux.log(` ${dim('message')}: ${test.message}`);
308-
CliUx.ux.log(` ${dim('stacktrace')}: ${os.EOL} ${stackTrace}`);
309-
CliUx.ux.log();
306+
ux.log(`• ${testName}`);
307+
ux.log(` ${dim('message')}: ${test.message}`);
308+
ux.log(` ${dim('stacktrace')}: ${os.EOL} ${stackTrace}`);
309+
ux.log();
310310
}
311311
}
312312

313313
private displayVerboseTestCoverage(): void {
314314
const codeCoverage = ensureArray(this.result.response.details.runTestResult?.codeCoverage);
315315
if (codeCoverage.length) {
316316
const coverage = codeCoverage.sort((a, b) => (a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1));
317-
CliUx.ux.log();
318-
CliUx.ux.log(tableHeader('Apex Code Coverage'));
317+
ux.log();
318+
ux.log(tableHeader('Apex Code Coverage'));
319319

320-
CliUx.ux.table(coverage.map(coverageOutput), {
320+
ux.table(coverage.map(coverageOutput), {
321321
name: { header: 'Name' },
322322
numLocations: { header: '% Covered' },
323323
lineNotCovered: { header: 'Uncovered Lines' },
@@ -334,7 +334,7 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
334334

335335
export class DeployReportResultFormatter extends DeployResultFormatter {
336336
public display(): void {
337-
CliUx.ux.log(`${this.result.response.id}... ${this.result.response.status}`);
337+
ux.log(`${this.result.response.id}... ${this.result.response.status}`);
338338

339339
const response = Object.entries(this.result.response).reduce<Array<{ key: string; value: unknown }>>(
340340
(result, [key, value]) => {
@@ -350,15 +350,15 @@ export class DeployReportResultFormatter extends DeployResultFormatter {
350350
[]
351351
);
352352

353-
CliUx.ux.log();
354-
CliUx.ux.table(response, { key: {}, value: {} }, { title: tableHeader('Deploy Info') });
353+
ux.log();
354+
ux.table(response, { key: {}, value: {} }, { title: tableHeader('Deploy Info') });
355355

356356
const opts = Object.entries(this.flags).reduce<Array<{ key: string; value: unknown }>>((result, [key, value]) => {
357357
if (key === 'timestamp') return result;
358358
return result.concat({ key, value });
359359
}, []);
360-
CliUx.ux.log();
361-
CliUx.ux.table(opts, { key: {}, value: {} }, { title: tableHeader('Deploy Options') });
360+
ux.log();
361+
ux.table(opts, { key: {}, value: {} }, { title: tableHeader('Deploy Options') });
362362
super.display();
363363
}
364364
}
@@ -371,11 +371,11 @@ export class AsyncDeployResultFormatter implements Formatter<AsyncDeployResultJs
371371
}
372372

373373
public display(): void {
374-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployQueued'));
375-
CliUx.ux.log();
376-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployResume', [this.id]));
377-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployStatus', [this.id]));
378-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployCancel', [this.id]));
374+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployQueued'));
375+
ux.log();
376+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployResume', [this.id]));
377+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployStatus', [this.id]));
378+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployCancel', [this.id]));
379379
}
380380
}
381381

@@ -388,9 +388,9 @@ export class DeployCancelResultFormatter implements Formatter<DeployResultJson>
388388

389389
public display(): void {
390390
if (this.result.response.status === RequestStatus.Canceled) {
391-
CliUx.ux.log(`Successfully canceled ${this.result.response.id}`);
391+
ux.log(`Successfully canceled ${this.result.response.id}`);
392392
} else {
393-
CliUx.ux.error(`Could not cancel ${this.result.response.id}`);
393+
ux.error(`Could not cancel ${this.result.response.id}`);
394394
}
395395
}
396396
}
@@ -403,9 +403,9 @@ export class AsyncDeployCancelResultFormatter implements Formatter<AsyncDeployRe
403403
}
404404

405405
public display(): void {
406-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployCancelQueued'));
407-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployResume', [this.id]));
408-
CliUx.ux.log(deployAsyncMessages.getMessage('info.AsyncDeployStatus', [this.id]));
406+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployCancelQueued'));
407+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployResume', [this.id]));
408+
ux.log(deployAsyncMessages.getMessage('info.AsyncDeployStatus', [this.id]));
409409
}
410410
}
411411

@@ -441,9 +441,9 @@ export class RetrieveResultFormatter implements Formatter<RetrieveResultJson> {
441441
};
442442
const title = 'Retrieved Source';
443443
const options = { title: tableHeader(title) };
444-
CliUx.ux.log();
444+
ux.log();
445445

446-
CliUx.ux.table(getFileResponseSuccessProps(successes), columns, options);
446+
ux.table(getFileResponseSuccessProps(successes), columns, options);
447447
}
448448

449449
private async displayPackages(): Promise<void> {
@@ -455,8 +455,8 @@ export class RetrieveResultFormatter implements Formatter<RetrieveResultJson> {
455455
};
456456
const title = 'Retrieved Packages';
457457
const options = { title: tableHeader(title) };
458-
CliUx.ux.log();
459-
CliUx.ux.table(packages, columns, options);
458+
ux.log();
459+
ux.table(packages, columns, options);
460460
}
461461
}
462462

@@ -488,10 +488,10 @@ export class MetadataRetrieveResultFormatter implements Formatter<MetadataRetrie
488488

489489
// eslint-disable-next-line @typescript-eslint/require-await
490490
public async display(): Promise<void> {
491-
CliUx.ux.log(retrieveMessages.getMessage('info.WroteZipFile', [this.zipFilePath]));
491+
ux.log(retrieveMessages.getMessage('info.WroteZipFile', [this.zipFilePath]));
492492
if (this.opts.unzip) {
493493
const extractPath = path.join(this.opts['target-metadata-dir'], path.parse(this.opts['zip-file-name']).name);
494-
CliUx.ux.log(retrieveMessages.getMessage('info.ExtractedZipFile', [this.zipFilePath, extractPath]));
494+
ux.log(retrieveMessages.getMessage('info.ExtractedZipFile', [this.zipFilePath, extractPath]));
495495
}
496496
}
497497
}

src/utils/previewOutput.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import * as path from 'path';
8-
import { CliUx } from '@oclif/core';
8+
import { ux } from '@oclif/core';
99
import { StandardColors } from '@salesforce/sf-plugins-core';
1010
import { bold, dim } from 'chalk';
1111
import { Messages } from '@salesforce/core';
@@ -202,54 +202,54 @@ export const compileResults = ({
202202
};
203203

204204
const printDeployTable = (files: PreviewFile[]): void => {
205-
CliUx.ux.log();
205+
ux.log();
206206
if (files.length === 0) {
207-
CliUx.ux.log(dim(messages.getMessage('deploy.none')));
207+
ux.log(dim(messages.getMessage('deploy.none')));
208208
} else {
209209
// not using table title property to avoid all the ASCII art
210-
CliUx.ux.log(StandardColors.success(bold(messages.getMessage('deploy.header', [files.length]))));
211-
CliUx.ux.table<PreviewFile>(files, columns);
210+
ux.log(StandardColors.success(bold(messages.getMessage('deploy.header', [files.length]))));
211+
ux.table<PreviewFile>(files, columns);
212212
}
213213
};
214214

215215
const printRetrieveTable = (files: PreviewFile[]): void => {
216-
CliUx.ux.log();
216+
ux.log();
217217
if (files.length === 0) {
218-
CliUx.ux.log(dim(messages.getMessage('retrieve.none')));
218+
ux.log(dim(messages.getMessage('retrieve.none')));
219219
} else {
220220
// not using table title property to avoid all the ASCII art
221-
CliUx.ux.log(StandardColors.success(bold(messages.getMessage('retrieve.header', [files.length]))));
222-
CliUx.ux.table<PreviewFile>(files, columns);
221+
ux.log(StandardColors.success(bold(messages.getMessage('retrieve.header', [files.length]))));
222+
ux.table<PreviewFile>(files, columns);
223223
}
224224
};
225225

226226
const printDeleteTable = (files: PreviewFile[]): void => {
227-
CliUx.ux.log();
227+
ux.log();
228228
if (files.length === 0) {
229-
CliUx.ux.log(dim(messages.getMessage('delete.none')));
229+
ux.log(dim(messages.getMessage('delete.none')));
230230
} else {
231-
CliUx.ux.log(StandardColors.warning(bold(messages.getMessage('delete.header', [files.length]))));
232-
CliUx.ux.table<PreviewFile>(files, columns);
231+
ux.log(StandardColors.warning(bold(messages.getMessage('delete.header', [files.length]))));
232+
ux.table<PreviewFile>(files, columns);
233233
}
234234
};
235235

236236
const printConflictsTable = (files: PreviewFile[]): void => {
237-
CliUx.ux.log();
237+
ux.log();
238238
if (files.length === 0) {
239-
CliUx.ux.log(dim(messages.getMessage('conflicts.none')));
239+
ux.log(dim(messages.getMessage('conflicts.none')));
240240
} else {
241-
CliUx.ux.log(StandardColors.error(bold(messages.getMessage('conflicts.header', [files.length]))));
242-
CliUx.ux.table<PreviewFile>(files, columns, { sort: 'path' });
241+
ux.log(StandardColors.error(bold(messages.getMessage('conflicts.header', [files.length]))));
242+
ux.table<PreviewFile>(files, columns, { sort: 'path' });
243243
}
244244
};
245245

246246
const printIgnoredTable = (files: PreviewFile[], baseOperation: BaseOperation): void => {
247-
CliUx.ux.log();
247+
ux.log();
248248
if (files.length === 0) {
249-
CliUx.ux.log(dim(messages.getMessage('ignored.none')));
249+
ux.log(dim(messages.getMessage('ignored.none')));
250250
} else {
251-
CliUx.ux.log(dim(messages.getMessage('ignored.header', [files.length, baseOperation])));
252-
CliUx.ux.table<PreviewFile>(files, columns, { sort: 'path' });
251+
ux.log(dim(messages.getMessage('ignored.header', [files.length, baseOperation])));
252+
ux.table<PreviewFile>(files, columns, { sort: 'path' });
253253
}
254254
};
255255

0 commit comments

Comments
 (0)