Skip to content

Commit

Permalink
feat: support error codes help section
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Mar 31, 2022
1 parent d258ce7 commit 4852a4f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"/messages"
],
"dependencies": {
"@oclif/core": "^1.6.0",
"@salesforce/core": "^3.7.9",
"@oclif/core": "^1.6.3",
"@salesforce/core": "^3.11.0",
"@salesforce/kit": "^1.5.34",
"@salesforce/ts-types": "^1.5.20",
"chalk": "^2.4.2",
Expand Down
38 changes: 21 additions & 17 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,31 @@ export type HelpSection = {
*/
export function toHelpSection(
header: string,
...vars: Array<OrgConfigProperties | SfdxPropertyKeys | EnvironmentVariable | string>
...vars: Array<OrgConfigProperties | SfdxPropertyKeys | EnvironmentVariable | string | Record<string, string>>
): HelpSection {
const body = vars
.map((v) => {
const orgConfig = ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => {
return key === v;
});
if (orgConfig) {
return { name: orgConfig.key, description: orgConfig.description };
}
const sfdxProperty = SFDX_ALLOWED_PROPERTIES.find(({ key }) => key === v);
if (sfdxProperty) {
return { name: sfdxProperty.key.valueOf(), description: sfdxProperty.description };
}
const envVar = Object.entries(SUPPORTED_ENV_VARS).find(([k]) => k === v);
.flatMap((v) => {
if (typeof v === 'string') {
const orgConfig = ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => {
return key === v;
});
if (orgConfig) {
return { name: orgConfig.key, description: orgConfig.description };
}
const sfdxProperty = SFDX_ALLOWED_PROPERTIES.find(({ key }) => key === v);
if (sfdxProperty) {
return { name: sfdxProperty.key.valueOf(), description: sfdxProperty.description };
}
const envVar = Object.entries(SUPPORTED_ENV_VARS).find(([k]) => k === v);

if (envVar) {
const [eKey, data] = envVar;
return { name: eKey, description: data.description };
if (envVar) {
const [eKey, data] = envVar;
return { name: eKey, description: data.description };
}
return undefined;
} else {
return Object.entries(v).map(([name, description]) => ({ name, description }));
}
return undefined;
})
.filter((b) => b);
return { header, body };
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@
widest-line "^3.1.0"
wrap-ansi "^7.0.0"

"@oclif/core@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.6.0.tgz#a91333275cd43a49097158f4ae8e15ccf718bd48"
integrity sha512-JHerjgRd29EtUVpDIrzohq2XdxJfgmZVGHAFlf75QVhLGFaleopZAQNBXkHkxG//kGib0LhyVGW7azcFKzr1eQ==
"@oclif/core@^1.6.3":
version "1.6.3"
resolved "https://registry.npmjs.org/@oclif/core/-/core-1.6.3.tgz#3d1dd4e033f5512ac35963a73878257142390838"
integrity sha512-a3DrPNlOYemwnzxuJ3tINjqpMVIYe56Mg+XaQo0nGsqGSk69wF5Q/hD8plsWrtwdkeIxwxhgl7T699EJypAUwg==
dependencies:
"@oclif/linewrap" "^1.0.0"
"@oclif/screen" "^3.0.2"
Expand Down Expand Up @@ -618,10 +618,10 @@
mv "~2"
safe-json-stringify "~1"

"@salesforce/core@^3.7.9":
version "3.7.9"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.7.9.tgz#bcef443046e8680bf80c31a3d0a0740e1d83314e"
integrity sha512-yR+0DKWH55T/tU1y55VVFm9s5B8eMIZdVXch/b1FeFfEpycF/tYbbUcsSyV+oo8xEsJ6lxNj+P9m41izoWh2Sw==
"@salesforce/core@^3.11.0":
version "3.11.0"
resolved "https://registry.npmjs.org/@salesforce/core/-/core-3.11.0.tgz#e1ec10189103a9133117af938156fb9f3eb2aef2"
integrity sha512-OqEkFfgfL2WvuzasjgrsGVa2SB00FCdfu09hPBK3URnR418+ztk283TDNOQ15AGW5oI8EWdEEKpOI+oAXmWS3A==
dependencies:
"@oclif/core" "^1.5.1"
"@salesforce/bunyan" "^2.0.0"
Expand Down

0 comments on commit 4852a4f

Please sign in to comment.