This repository was archived by the owner on Mar 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathforce.ts
More file actions
106 lines (97 loc) · 4.54 KB
/
force.ts
File metadata and controls
106 lines (97 loc) · 4.54 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This is a doc command
/* istanbul ignore file */
import got from 'got';
import { Help } from '@oclif/core';
import { ProxyAgent } from 'proxy-agent';
import { ConfigAggregator } from '@salesforce/core';
import { SfCommand } from '@salesforce/sf-plugins-core';
const getAsciiSignature = (apiVersion: string): string => `
DX DX DX
DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX
DX DX DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX
DX DX DX DX DX
DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX DX DX
DX DX DX DX DX DX DX DX DX
DX DX DX DX
DX DX DX DX DX DX
DX DX DX DX DX DX v${apiVersion}
DX DX DX
* Salesforce CLI Release Notes: https://github.com/forcedotcom/cli/tree/main/releasenotes
* Salesforce DX Setup Guide: https://sfdc.co/sfdx_setup_guide
* Salesforce DX Developer Guide: https://sfdc.co/sfdx_dev_guide
* Salesforce CLI Command Reference: https://sfdc.co/sfdx_cli_reference
* Salesforce Extensions for VS Code: https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode
`;
const getCurrentApiVersion = async (): Promise<string> => {
const apiFromConfig = ConfigAggregator.getValue('apiVersion').value as string;
if (apiFromConfig) {
return apiFromConfig;
}
const url = 'https://mdcoverage.secure.force.com/services/apexrest/report';
return `${(
JSON.parse(
(
await got(url, {
agent: { https: new ProxyAgent() },
})
).body
) as {
versions: { selected: number };
}
).versions.selected.toString()}.0`;
};
export type ForceCommandResult = { apiVersion: string };
export class ForceCommand extends SfCommand<ForceCommandResult> {
public static readonly hidden = true;
public static readonly examples = [];
public static state = 'deprecated';
public static readonly deprecationOptions = {
message: 'Use "org display" to see the API version of any org.',
};
// eslint-disable-next-line sf-plugin/no-hardcoded-messages-commands
public static readonly summary = 'Display the ASCII art logo for the Salesforce CLI';
public async run(): Promise<ForceCommandResult> {
const apiVersion = await getCurrentApiVersion();
this.log(getAsciiSignature(apiVersion));
return { apiVersion };
}
// overrides the help so that it shows the help for the `force` topic and not "help" for this command
protected _help(): void {
const help = new Help(this.config);
// We need to include force in the args for topics to be shown
void help.showHelp(process.argv.slice(2));
return this.exit(0);
}
}