Skip to content

Commit 1713848

Browse files
authored
feat: use oclif/core v4 (#1111)
1 parent ffef92b commit 1713848

File tree

6 files changed

+218
-166
lines changed

6 files changed

+218
-166
lines changed

messages/repositories.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,35 @@ For more information on the list of repositories, visit https://github.com/sales
88
- <%= config.bin %> <%= command.id %> --columns=url --filter='Name=sfdx-core' --no-header | xargs open
99

1010
- <%= config.bin %> <%= command.id %> --json | jq -r '.result[] | select(.name=="sfdx-core") | .packages[] | .url
11+
12+
# flags.columns.summary
13+
14+
Only show provided columns (comma-separated).
15+
16+
# flags.csv.summary
17+
18+
Output is csv format.
19+
20+
# flags.extended.summary
21+
22+
Show extra columns.
23+
24+
# flags.filter.summary
25+
26+
Filter property by partial string matching, ex: name=foo.
27+
28+
# flags.no-header.summary
29+
30+
Hide table header from output.
31+
32+
# flags.no-truncate.summary
33+
34+
Do not truncate output to fit screen.
35+
36+
# flags.output.summary
37+
38+
Output in a more machine friendly format.
39+
40+
# flags.sort.summary
41+
42+
Property to sort by (prepend '-' for descending).

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"sf-release": "bin/run.js"
1010
},
1111
"dependencies": {
12-
"@oclif/core": "^3.26.4",
12+
"@oclif/core": "^4",
1313
"@octokit/core": "^4.2.4",
1414
"@octokit/plugin-paginate-rest": "^6.1.2",
1515
"@octokit/plugin-throttling": "^5.2.3",
@@ -18,7 +18,7 @@
1818
"@salesforce/kit": "^3.1.2",
1919
"@salesforce/plugin-command-reference": "^3.0.83",
2020
"@salesforce/plugin-trust": "^3.7.0",
21-
"@salesforce/sf-plugins-core": "^9.1.1",
21+
"@salesforce/sf-plugins-core": "^10.0.0",
2222
"@salesforce/ts-types": "^2.0.9",
2323
"aws-sdk": "^2.1632.0",
2424
"chalk": "^5.3.0",
@@ -34,7 +34,7 @@
3434
},
3535
"devDependencies": {
3636
"@oclif/plugin-command-snapshot": "^5.2.0",
37-
"@salesforce/dev-scripts": "^9.1.2",
37+
"@salesforce/dev-scripts": "^10",
3838
"@salesforce/ts-sinon": "1.4.19",
3939
"@types/semver": "^7.5.8",
4040
"@types/shelljs": "^0.8.15",

src/commands/cli/install/test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import path from 'node:path';
99
import os from 'node:os';
1010
import fs from 'node:fs/promises';
1111
import shelljs from 'shelljs';
12-
import { ux } from '@oclif/core';
13-
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
12+
import { Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
1413
import { Messages } from '@salesforce/core';
1514
import { ensure } from '@salesforce/ts-types';
1615
import got from 'got';
@@ -21,6 +20,8 @@ import { AmazonS3, download } from '../../../amazonS3.js';
2120
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2221
const messages = Messages.loadMessages('@salesforce/plugin-release-management', 'cli.install.test');
2322

23+
const ux = new Ux();
24+
2425
type Results = Record<string, Record<CLI, boolean>>;
2526

2627
namespace Method {
@@ -35,7 +36,7 @@ namespace Method {
3536
channel: Channel;
3637
method: Type;
3738
directory: string;
38-
}
39+
};
3940

4041
export abstract class Base {
4142
private static TEST_TARGETS = {
@@ -175,15 +176,15 @@ class Tarball extends Method.Base {
175176
const dir = path.join(this.options.directory, path.basename(file).replace(/\./g, '-'));
176177
await fs.mkdir(dir, { recursive: true });
177178
return new Promise((resolve, reject) => {
178-
ux.action.start(`Unpacking ${chalk.cyan(path.basename(file))} to ${dir}`);
179+
ux.spinner.start(`Unpacking ${chalk.cyan(path.basename(file))} to ${dir}`);
179180
const cmd =
180181
process.platform === 'win32'
181182
? `tar -xf ${file} -C ${dir} --strip-components 1 --exclude node_modules/.bin`
182183
: `tar -xf ${file} -C ${dir} --strip-components 1`;
183184
const opts = process.platform === 'win32' ? { shell: 'powershell.exe' } : {};
184185
shelljs.exec(cmd, { ...opts, silent: true }, (code: number, stdout: string, stderr: string) => {
185186
if (code === 0) {
186-
ux.action.stop();
187+
ux.spinner.stop();
187188
ux.log(stdout);
188189
resolve(dir);
189190
} else {
@@ -261,18 +262,18 @@ class Npm extends Method.Base {
261262
}
262263

263264
private async install(): Promise<void> {
264-
ux.action.start(`Installing: ${chalk.cyan(this.package)}`);
265+
ux.spinner.start(`Installing: ${chalk.cyan(this.package)}`);
265266
return new Promise((resolve, reject) => {
266267
shelljs.exec(
267268
`npm install ${this.package}`,
268269
{ silent: true, cwd: this.options.directory },
269270
(code, stdout, stderr) => {
270271
if (code === 0) {
271-
ux.action.stop();
272+
ux.spinner.stop();
272273
ux.log(stdout);
273274
resolve();
274275
} else {
275-
ux.action.stop('Failed');
276+
ux.spinner.stop('Failed');
276277
ux.log(stdout);
277278
ux.log(stderr);
278279
reject();

src/commands/repositories/index.ts

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
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 { SfCommand } from '@salesforce/sf-plugins-core';
8+
/* eslint-disable sf-plugin/no-hardcoded-messages-flags */
9+
10+
import { Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
911
import { Messages } from '@salesforce/core';
10-
import { ux } from '@oclif/core';
1112
import { RepositoryInfo, retrieveKnownRepositories } from '../../repositories.js';
1213

1314
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
@@ -19,35 +20,64 @@ export default class Repositories extends SfCommand<RepositoryResult> {
1920
public static readonly description = messages.getMessage('description');
2021
public static readonly examples = messages.getMessages('examples');
2122

22-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2323
public static readonly flags = {
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
...(ux.table.flags() as any),
24+
columns: Flags.string({
25+
summary: messages.getMessage('flags.columns.summary'),
26+
exclusive: ['extended'],
27+
}),
28+
csv: Flags.boolean({
29+
summary: messages.getMessage('flags.csv.summary'),
30+
exclusive: ['no-truncate'],
31+
}),
32+
extended: Flags.boolean({
33+
char: 'x',
34+
summary: messages.getMessage('flags.extended.summary'),
35+
exclusive: ['columns'],
36+
}),
37+
filter: Flags.string({
38+
summary: messages.getMessage('flags.filter.summary'),
39+
}),
40+
'no-header': Flags.boolean({
41+
summary: messages.getMessage('flags.no-header.summary'),
42+
exclusive: ['csv'],
43+
}),
44+
'no-truncate': Flags.boolean({
45+
summary: messages.getMessage('flags.no-truncate.summary'),
46+
exclusive: ['csv'],
47+
}),
48+
output: Flags.string({
49+
summary: messages.getMessage('flags.output.summary'),
50+
exclusive: ['no-truncate', 'csv'],
51+
options: ['csv', 'json', 'yaml'],
52+
}),
53+
sort: Flags.string({
54+
summary: messages.getMessage('flags.sort.summary'),
55+
}),
2656
};
2757

2858
public async run(): Promise<RepositoryResult> {
2959
const { flags } = await this.parse(Repositories);
3060
const repositories = await retrieveKnownRepositories();
61+
const ux = new Ux({ jsonEnabled: flags.json ?? false });
3162

32-
if (!flags.json) {
33-
ux.table(
34-
repositories,
35-
{
36-
organization: {},
37-
name: {},
38-
url: {},
39-
packages: {
40-
get: (row: RepositoryInfo): string => row.packages.map((pkg) => `${pkg.type} ${pkg.name}`).join('\n'),
41-
extended: true,
42-
},
63+
ux.table(
64+
repositories,
65+
{
66+
organization: {},
67+
name: {},
68+
url: {},
69+
packages: {
70+
get: (row: RepositoryInfo): string => row.packages.map((pkg) => `${pkg.type} ${pkg.name}`).join('\n'),
71+
extended: true,
4372
},
44-
{
45-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
46-
printLine: this.log.bind(this),
47-
...flags, // parsed flags
48-
}
49-
);
50-
}
73+
},
74+
{
75+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76+
printLine: this.log.bind(this),
77+
...flags, // parsed flags
78+
}
79+
);
80+
5181
return repositories;
5282
}
5383
}

src/dependencies.ts

Lines changed: 3 additions & 3 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 { Env } from '@salesforce/kit';
8-
import { OutputFlags } from '@oclif/core/lib/interfaces/parser.js';
8+
import { OutputFlags } from '@oclif/core/parser';
99

1010
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1111
type Flags = OutputFlags<any>;
@@ -16,14 +16,14 @@ type Dependency = {
1616
name: string;
1717
type: DependencyType;
1818
condition?: ConditionFn;
19-
}
19+
};
2020

2121
type Result = {
2222
name: string;
2323
type: DependencyType;
2424
passed: boolean;
2525
message?: string;
26-
}
26+
};
2727

2828
const DEPENDENCIES: Dependency[] = [
2929
{

0 commit comments

Comments
 (0)