generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
53 lines (47 loc) · 1.83 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { ux } from '@oclif/core';
import { RepositoryInfo, retrieveKnownRepositories } from '../../repositories.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-release-management', 'repositories');
export type RepositoryResult = RepositoryInfo[];
export default class Repositories extends SfCommand<RepositoryResult> {
public static readonly summary = messages.getMessage('description');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
public static readonly flags = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(ux.table.flags() as any),
};
public async run(): Promise<RepositoryResult> {
const { flags } = await this.parse(Repositories);
const repositories = await retrieveKnownRepositories();
if (!flags.json) {
ux.table(
repositories,
{
organization: {},
name: {},
url: {},
packages: {
get: (row: RepositoryInfo): string => row.packages.map((pkg) => `${pkg.type} ${pkg.name}`).join('\n'),
extended: true,
},
},
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
printLine: this.log.bind(this),
...flags, // parsed flags
}
);
}
return repositories;
}
}