Skip to content

Commit 84ba1c9

Browse files
mdonnalleymshanemc
andauthored
feat: use oclif/core v4 and sf-plugins-core v10 (#1087)
* feat: use oclif/core v4 and sf-plugins-core v10 * fix: bump oclif/core * test: make windows happy * fix(deps): non-beta plugins-core, other bumps --------- Co-authored-by: mshanemc <[email protected]>
1 parent 6e5dfc7 commit 84ba1c9

File tree

12 files changed

+200
-170
lines changed

12 files changed

+200
-170
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
8-
"@oclif/core": "^3.26.4",
9-
"@salesforce/core": "^7.3.9",
8+
"@oclif/core": "^4.0.2",
9+
"@salesforce/core": "^7.3.10",
1010
"@salesforce/kit": "^3.1.1",
11-
"@salesforce/sf-plugins-core": "^9.1.1",
12-
"@salesforce/source-deploy-retrieve": "^11.6.4",
13-
"chalk": "^5.3.0",
11+
"@salesforce/sf-plugins-core": "^10.0.0",
12+
"@salesforce/source-deploy-retrieve": "^11.6.5",
13+
"ansis": "^3.2.0",
1414
"change-case": "^5.4.4",
1515
"is-wsl": "^3.1.0",
1616
"open": "^10.1.0"
1717
},
1818
"devDependencies": {
19-
"@oclif/plugin-command-snapshot": "^5.1.9",
19+
"@oclif/plugin-command-snapshot": "^5.2.1",
2020
"@salesforce/cli-plugins-testkit": "^5.3.9",
21-
"@salesforce/dev-scripts": "^9.1.3",
21+
"@salesforce/dev-scripts": "^10",
2222
"@salesforce/plugin-command-reference": "^3.0.89",
2323
"@salesforce/ts-sinon": "1.4.19",
2424
"eslint-plugin-sf-plugin": "^1.18.5",
2525
"moment": "^2.30.1",
26-
"oclif": "^4.12.1",
26+
"oclif": "^4.13.0",
2727
"ts-node": "^10.9.2",
2828
"typescript": "^5.4.5"
2929
},

src/commands/force/org/create.ts

Lines changed: 2 additions & 2 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

8-
import { Interfaces } from '@oclif/core';
8+
import Interfaces from '@oclif/core/interfaces';
99
import {
1010
Flags,
1111
loglevel,
@@ -45,7 +45,7 @@ export type ScratchOrgProcessObject = {
4545
authFields?: AuthFields;
4646
warnings: string[];
4747
orgId: string;
48-
}
48+
};
4949

5050
export type CreateResult = ScratchOrgProcessObject | SandboxProcessObject;
5151

src/commands/org/list.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core';
99
import { AuthInfo, ConfigAggregator, ConfigInfo, Connection, Org, SfError, Messages, Logger } from '@salesforce/core';
1010
import { Interfaces } from '@oclif/core';
11-
import chalk, { ChalkInstance } from 'chalk';
11+
import ansis, { type Ansis } from 'ansis';
1212
import { OrgListUtil, identifyActiveOrgByStatus } from '../../shared/orgListUtil.js';
1313
import { getStyledObject } from '../../shared/orgHighlighter.js';
1414
import { ExtendedAuthFields, FullyPopulatedScratchOrgFields } from '../../shared/orgTypes.js';
@@ -163,18 +163,18 @@ Legend: ${defaultHubEmoji}=Default DevHub, ${defaultOrgEmoji}=Default Org ${
163163
const allOrgs: Array<FullyPopulatedScratchOrgFields | ExtendedAuthFieldsWithType> = [
164164
...devHubs
165165
.map(addType('DevHub'))
166-
.map(colorEveryFieldButConnectedStatus(chalk.cyanBright))
166+
.map(colorEveryFieldButConnectedStatus(ansis.cyanBright))
167167
.map((row) => getStyledObject(row))
168168
.map(statusToEmoji),
169169

170170
...other
171-
.map(colorEveryFieldButConnectedStatus(chalk.magentaBright))
171+
.map(colorEveryFieldButConnectedStatus(ansis.magentaBright))
172172
.map((row) => getStyledObject(row))
173173
.map(statusToEmoji),
174174

175175
...sandboxes
176176
.map(addType('Sandbox'))
177-
.map(colorEveryFieldButConnectedStatus(chalk.yellowBright))
177+
.map(colorEveryFieldButConnectedStatus(ansis.yellowBright))
178178
.map((row) => getStyledObject(row))
179179
.map(statusToEmoji),
180180

@@ -254,7 +254,7 @@ const addType =
254254
(val: ExtendedAuthFields): ExtendedAuthFieldsWithType => ({ ...val, type });
255255

256256
const colorEveryFieldButConnectedStatus =
257-
(colorFn: ChalkInstance) =>
257+
(colorFn: Ansis) =>
258258
(row: ExtendedAuthFieldsWithType): ExtendedAuthFieldsWithType =>
259259
Object.fromEntries(
260260
Object.entries(row).map(([key, val]) => [

src/shared/orgHighlighter.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import chalk, { ChalkInstance } from 'chalk';
7+
import ansis, { type Ansis } from 'ansis';
88
import { ExtendedAuthFields, FullyPopulatedScratchOrgFields } from './orgTypes.js';
99

10-
const styledProperties = new Map<string, Map<string, ChalkInstance>>([
10+
const styledProperties = new Map<string, Map<string, Ansis>>([
1111
[
1212
'status',
1313
new Map([
14-
['Active', chalk.green],
15-
['else', chalk.red],
14+
['Active', ansis.green],
15+
['else', ansis.red],
1616
]),
1717
],
1818
[
1919
'connectedStatus',
2020
new Map([
21-
['Connected', chalk.green],
22-
['Active', chalk.green],
23-
['else', chalk.red],
21+
['Connected', ansis.green],
22+
['Active', ansis.green],
23+
['else', ansis.red],
2424
]),
2525
],
2626
]);
@@ -31,8 +31,8 @@ export const getStyledValue = (key: string, value: string): string => {
3131
if (!prop) return value;
3232

3333
// I'm not sure how to type the inner Map so that it knows else is definitely there
34-
const chalkMethod = prop.get(value) ?? (prop.get('else') as ChalkInstance);
35-
return chalkMethod(value);
34+
const colorMethod = prop.get(value) ?? (prop.get('else') as Ansis);
35+
return colorMethod(value);
3636
};
3737

3838
export const getStyledObject = <T extends ExtendedAuthFields | FullyPopulatedScratchOrgFields>(objectToStyle: T): T =>

src/shared/sandboxProgress.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os from 'node:os';
88
import { StatusEvent, ResultEvent, SandboxProcessObject } from '@salesforce/core';
99
import { Ux } from '@salesforce/sf-plugins-core';
10-
import { ux } from '@oclif/core';
1110
import { getClockForSeconds } from '../shared/timeUtils.js';
1211
import { StagedProgress } from './stagedProgress.js';
1312
import { isDefined } from './utils.js';
@@ -17,6 +16,8 @@ const columns: Ux.Table.Columns<{ key: string; value: string }> = {
1716
value: { header: 'Value' },
1817
};
1918

19+
const ux = new Ux();
20+
2021
export type SandboxProgressData = {
2122
id: string;
2223
status: string;

src/shared/scratchOrgOutput.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import { ScratchOrgLifecycleEvent, scratchOrgLifecycleStages } from '@salesforce/core';
8-
import chalk from 'chalk';
8+
import ansis from 'ansis';
99
import { capitalCase } from 'change-case';
1010
import { StandardColors } from '@salesforce/sf-plugins-core';
1111

12-
const boldBlue = (input: string): string => chalk.rgb(81, 176, 235).bold(input);
13-
const boldPurple = (input: string): string => chalk.rgb(157, 129, 221).bold(input);
12+
const boldBlue = (input: string): string => ansis.rgb(81, 176, 235).bold(input);
13+
const boldPurple = (input: string): string => ansis.rgb(157, 129, 221).bold(input);
1414

1515
export const buildStatus = (data: ScratchOrgLifecycleEvent, baseUrl: string): string => `
1616
RequestId: ${formatRequest(baseUrl, data.scratchOrgInfo?.Id)}
@@ -31,7 +31,7 @@ export const formatStage = (currentStage: ScratchOrgLifecycleEvent['stage']): st
3131
.join('\n');
3232

3333
export const formatRequest = (baseUrl: string, id?: string): string =>
34-
`${id ? `${chalk.bold(id)} (${baseUrl}/${id})` : ''}`;
34+
`${id ? `${ansis.bold(id)} (${baseUrl}/${id})` : ''}`;
3535

3636
export const formatUsername = (username?: string): string => `${username ? `${boldBlue(username)} ` : ''}`;
3737
export const formatOrgId = (id?: string): string => `${id ? `${boldBlue(id)} ` : ''}`;

src/shared/stagedProgress.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import os from 'node:os';
8-
import chalk, { ChalkInstance } from 'chalk';
8+
import ansis, { type Ansis } from 'ansis';
99
import { StandardColors } from '@salesforce/sf-plugins-core';
1010
import { SfError } from '@salesforce/core';
1111

1212
const compareStages = ([, aValue]: [string, StageAttributes], [, bValue]: [string, StageAttributes]): number =>
1313
aValue.index - bValue.index;
1414

15-
export const boldPurple = chalk.rgb(157, 129, 221).bold;
15+
export const boldPurple = ansis.rgb(157, 129, 221).bold;
1616

1717
export type State = 'inProgress' | 'completed' | 'failed' | 'unknown';
1818

1919
export type StageAttributes = {
2020
state: State;
2121
char: string;
22-
color: ChalkInstance;
22+
color: Ansis;
2323
index: number;
2424
visited: boolean;
2525
};
2626

2727
export const StateConstants: { [stage: string]: Omit<StageAttributes, 'index'> } = {
2828
inProgress: { color: boldPurple, char: '…', visited: false, state: 'inProgress' },
2929
completed: { color: StandardColors.success, char: '✓', visited: false, state: 'completed' },
30-
failed: { color: chalk.bold.red, char: '✖', visited: false, state: 'failed' },
31-
unknown: { color: chalk.dim, char: '…', visited: false, state: 'unknown' },
30+
failed: { color: ansis.bold.red, char: '✖', visited: false, state: 'failed' },
31+
unknown: { color: ansis.dim, char: '…', visited: false, state: 'unknown' },
3232
};
3333

3434
export type Stage = {

test/shared/orgHighlighter.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import { expect } from 'chai';
8-
import chalk from 'chalk';
8+
import ansis from 'ansis';
99
import { ExtendedAuthFields } from '../../src/shared/orgTypes.js';
1010
import { getStyledObject, getStyledValue } from '../../src/shared/orgHighlighter.js';
1111

1212
describe('highlights value from key-value pair', () => {
1313
it('colors matching property/value green', () => {
14-
expect(getStyledValue('status', 'Active')).to.equal(chalk.green('Active'));
14+
expect(getStyledValue('status', 'Active')).to.equal(ansis.green('Active'));
1515
});
1616
it('colors matching property/non-matching value red', () => {
17-
expect(getStyledValue('status', 'otherVal')).to.equal(chalk.red('otherVal'));
17+
expect(getStyledValue('status', 'otherVal')).to.equal(ansis.red('otherVal'));
1818
});
1919
it('ignores a non matched property', () => {
2020
expect(getStyledValue('otherProp', 'otherVal')).to.equal('otherVal');
@@ -30,9 +30,9 @@ describe('highlights object with green, red, and non-colored', () => {
3030
// I know it's not, but it's a test
3131
} as unknown as ExtendedAuthFields;
3232
expect(getStyledObject(object)).to.deep.equal({
33-
status: chalk.green('Active'),
33+
status: ansis.green('Active'),
3434
otherProp: 'foo',
35-
connectedStatus: chalk.red('Not found'),
35+
connectedStatus: ansis.red('Not found'),
3636
});
3737
});
3838
});

test/shared/stagedProgress.test.ts

Lines changed: 2 additions & 2 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 { expect } from 'chai';
8-
import chalk from 'chalk';
8+
import ansis from 'ansis';
99
import { StagedProgress, StateConstants } from '../../src/shared/stagedProgress.js';
1010
import { SandboxStatusData } from '../../src/shared/sandboxProgress.js';
1111

@@ -73,7 +73,7 @@ describe('stagedProgress', () => {
7373
const formattedStages = stagedProgress.formatStages();
7474
expect(formattedStages).to.be.ok;
7575
expect(formattedStages).to.include(StateConstants.unknown.char);
76-
expect(formattedStages).to.include(chalk.dim(''));
76+
expect(formattedStages).to.include(ansis.dim(''));
7777
});
7878
it('should get formatted stages - pending in progress', () => {
7979
stagedProgress.updateStages('Pending', 'inProgress');

test/unit/force/org/delete.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ describe('[DEPRECATED] force:org:delete', () => {
3131
sfCommandUxStubs = stubSfCommandUx($$.SANDBOX);
3232
});
3333

34-
it('will throw an error when no default set', async () => {
35-
await $$.stubConfig({});
36-
try {
37-
await LegacyDelete.run();
38-
expect.fail('should have thrown an error');
39-
} catch (e) {
40-
const err = e as SfError;
41-
expect(err.name).to.equal('MissingUsernameError');
42-
expect(err.message).to.equal(messages.getMessage('missingUsername'));
43-
}
44-
});
45-
4634
it('will prompt before attempting to delete', async () => {
4735
await $$.stubConfig({ 'target-org': testOrg.username });
4836
const res = await LegacyDelete.run([]);
@@ -64,6 +52,18 @@ describe('[DEPRECATED] force:org:delete', () => {
6452
expect(res).to.deep.equal({ orgId: testOrg.orgId, username: testOrg.username });
6553
});
6654

55+
it('will throw an error when no default set', async () => {
56+
await $$.stubConfig({});
57+
try {
58+
await LegacyDelete.run();
59+
expect.fail('should have thrown an error');
60+
} catch (e) {
61+
const err = e as SfError;
62+
expect(err.name).to.equal('MissingUsernameError');
63+
expect(err.message).to.equal(messages.getMessage('missingUsername'));
64+
}
65+
});
66+
6767
it('will determine sandbox vs scratch org and delete sandbox', async () => {
6868
$$.SANDBOX.stub(SandboxAccessor.prototype, 'hasFile').resolves(true);
6969
const res = await LegacyDelete.run(['--target-org', testOrg.username]);

0 commit comments

Comments
 (0)