Skip to content

Commit

Permalink
fix: types in custom help
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 5, 2023
1 parent ac358af commit 3ecb802
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 144 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
]
},
"dependencies": {
"@oclif/core": "3.0.0",
"@oclif/core": "3.0.2",
"@oclif/plugin-autocomplete": "2.3.9",
"@oclif/plugin-commands": "2.2.28",
"@oclif/plugin-help": "5.2.20",
Expand Down
26 changes: 8 additions & 18 deletions src/help/sfCommandHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Command, CommandHelp, HelpSection, HelpSectionRenderer, Interfaces } from '@oclif/core';
import { SfCommandInterface } from '@salesforce/sf-plugins-core';
type SectionType = { header: string; generate: HelpSectionRenderer };

export class SfCommandHelp extends CommandHelp {
private shortHelp = false;
public constructor(
public command: Command.Cached,
public command: Command.Loadable,
public config: Interfaces.Config,
public opts: Interfaces.HelpOptions
) {
Expand All @@ -31,34 +30,25 @@ export class SfCommandHelp extends CommandHelp {
if (this.shortHelp) {
return sections.filter(({ header }) => ['USAGE', 'ARGUMENTS', 'FLAGS'].includes(header));
}
const additionaSfSections: SectionType[] = [
const additionalSfSections: SectionType[] = [
{
header: 'CONFIGURATION VARIABLES',
generate: ({ cmd }): HelpSection => {
const sfCommand = cmd as SfCommandInterface;
return sfCommand.configurationVariablesSection;
},
generate: ({ cmd }) => cmd.configurationVariablesSection as HelpSection,
},
{
header: 'ENVIRONMENT VARIABLES',
generate: ({ cmd }): HelpSection => {
const sfCommand = cmd as SfCommandInterface;
return sfCommand.envVariablesSection;
},
generate: ({ cmd }) => cmd.envVariablesSection as HelpSection,
},
{
header: 'ERROR CODES',
generate: ({ cmd }): HelpSection => {
const sfCommand = cmd as SfCommandInterface;
return sfCommand.errorCodes;
},
generate: ({ cmd }) => cmd.errorCodes as HelpSection,
},
];
const flagsIndex =
(sections.findIndex((section) => section.header === 'FLAG DESCRIPTIONS') || sections.length - 1) + 1;
sections.splice(flagsIndex, 0, additionaSfSections[0]);
sections.splice(flagsIndex + 1, 0, additionaSfSections[1]);
sections.splice(flagsIndex + 2, 0, additionaSfSections[2]);
sections.splice(flagsIndex, 0, additionalSfSections[0]);
sections.splice(flagsIndex + 1, 0, additionalSfSections[1]);
sections.splice(flagsIndex + 2, 0, additionalSfSections[2]);
return sections;
}
}
2 changes: 1 addition & 1 deletion src/help/sfHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class SfHelp extends Help {
return super.showHelp(argv);
}

protected getCommandHelpClass(command: Command.Cached): CommandHelp {
protected getCommandHelpClass(command: Command.Loadable): CommandHelp {
this.commandHelpClass = super.getCommandHelpClass(command) as SfCommandHelp;
this.commandHelpClass.showShortHelp = this.showShortHelp;
return this.commandHelpClass;
Expand Down
140 changes: 16 additions & 124 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,7 @@
dependencies:
eslint-visitor-keys "^3.3.0"

"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.1":
version "4.6.2"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.6.2.tgz#1816b5f6948029c5eaacb0703b850ee0cb37d8f8"
integrity sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==

"@eslint-community/regexpp@^4.5.1":
"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.8.1.tgz#8c4bb756cc2aa7eaf13cfa5e69c83afb3260c20c"
integrity sha512-PWiOzLIUAjN/w5K17PoF4n6sKBw0gqLHPhywmYHP4t1VFQQVYeb1yWsJwnMVEMl3tUHME7X/SJPZLmtG7XBDxQ==
Expand Down Expand Up @@ -1068,10 +1063,10 @@
read-package-json-fast "^3.0.0"
which "^4.0.0"

"@oclif/[email protected].0", "@oclif/core@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.0.tgz#9326d1cbd036ce20a1cda5e1854c1ec4d50dd717"
integrity sha512-zFHDOizZxRmmuPe6Jba3lLPXpjBxDNWIWSiV87E5DdSbzBPiUsWgXUNfDQENP2EL1vdRIPOeTPmFyob7K1tbBg==
"@oclif/[email protected].2", "@oclif/core@^3.0.0", "@oclif/core@^3.0.1":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.2.tgz#38632330fe5b5605a46ddc53136e8d643453953f"
integrity sha512-DOJKsUFGtJwVE1oecTH6fqrgxs3NFBbHuuIJnJrb3RYGy+Ql6rE9SPu2o7tVPlkXxtavYo9vwGo24rreFodONw==
dependencies:
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
Expand Down Expand Up @@ -1133,37 +1128,6 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.1.tgz#a4618723070871c65dd12a93935f61043131839d"
integrity sha512-OFFb228qBLgBGDctc0+kjOEw2U91TJZ7apwNihCLgUKjL8sVUZvxT6ydFurcNUeJIRpn/4vLzZ+67mFnpV7I0w==
dependencies:
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
cardinal "^2.1.1"
chalk "^4.1.2"
clean-stack "^3.0.1"
cli-progress "^3.12.0"
debug "^4.3.4"
ejs "^3.1.8"
get-package-type "^0.1.0"
globby "^11.1.0"
hyperlinker "^1.0.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
js-yaml "^3.14.1"
natural-orderby "^2.0.3"
object-treeify "^1.1.33"
password-prompt "^1.1.2"
slice-ansi "^4.0.0"
string-width "^4.2.3"
strip-ansi "^6.0.1"
supports-color "^8.1.1"
supports-hyperlinks "^2.2.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/[email protected]":
version "2.3.9"
resolved "https://registry.yarnpkg.com/@oclif/plugin-autocomplete/-/plugin-autocomplete-2.3.9.tgz#7a8204cd4904cd00edc769ddc42455f2b3b197e4"
Expand Down Expand Up @@ -3033,7 +2997,7 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

aws-sdk@^2.1231.0, aws-sdk@^2.1468.0:
aws-sdk@^2.1231.0, aws-sdk@^2.1467.0, aws-sdk@^2.1468.0:
version "2.1468.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1468.0.tgz#28be5d5c6e41aebdf089be7eeb9b67d44bf2f629"
integrity sha512-1DAa0UA779M0VyKKPjTPDtox4KOyFrHnGDLbJrDKzqylC+O0DMR4kh9Oy2vfErhwFwsiPUvWgkknddVS+igVGA==
Expand All @@ -3049,22 +3013,6 @@ aws-sdk@^2.1231.0, aws-sdk@^2.1468.0:
uuid "8.0.0"
xml2js "0.5.0"

aws-sdk@^2.1467.0:
version "2.1467.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1467.0.tgz#e3f2217ca8592b06021286bac304a58d2635fdb2"
integrity sha512-XJNbV2ORQB6XanyBLPJBjvm6axWlblFdyFHa+ZaUK4Kp3cZBggy53+0PMxS3bAGJKcP6h2pZQio9xZMCoebAKQ==
dependencies:
buffer "4.9.2"
events "1.1.1"
ieee754 "1.1.13"
jmespath "0.16.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
util "^0.12.4"
uuid "8.0.0"
xml2js "0.5.0"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
Expand Down Expand Up @@ -3432,7 +3380,7 @@ cardinal@^2.1.1:
ansicolors "~0.3.2"
redeyed "~2.1.0"

chai@^4.3.10:
chai@^4.3.10, chai@^4.3.7:
version "4.3.10"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.10.tgz#d784cec635e3b7e2ffb66446a63b4e33bd390384"
integrity sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==
Expand All @@ -3445,19 +3393,6 @@ chai@^4.3.10:
pathval "^1.1.1"
type-detect "^4.0.8"

chai@^4.3.7:
version "4.3.8"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.8.tgz#40c59718ad6928da6629c70496fe990b2bb5b17c"
integrity sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==
dependencies:
assertion-error "^1.1.0"
check-error "^1.0.2"
deep-eql "^4.1.2"
get-func-name "^2.0.0"
loupe "^2.3.1"
pathval "^1.1.1"
type-detect "^4.0.5"

chainsaw@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98"
Expand Down Expand Up @@ -4861,50 +4796,7 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

eslint@^8.41.0:
version "8.49.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.49.0.tgz#09d80a89bdb4edee2efcf6964623af1054bf6d42"
integrity sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@eslint-community/regexpp" "^4.6.1"
"@eslint/eslintrc" "^2.1.2"
"@eslint/js" "8.49.0"
"@humanwhocodes/config-array" "^0.11.11"
"@humanwhocodes/module-importer" "^1.0.1"
"@nodelib/fs.walk" "^1.2.8"
ajv "^6.12.4"
chalk "^4.0.0"
cross-spawn "^7.0.2"
debug "^4.3.2"
doctrine "^3.0.0"
escape-string-regexp "^4.0.0"
eslint-scope "^7.2.2"
eslint-visitor-keys "^3.4.3"
espree "^9.6.1"
esquery "^1.4.2"
esutils "^2.0.2"
fast-deep-equal "^3.1.3"
file-entry-cache "^6.0.1"
find-up "^5.0.0"
glob-parent "^6.0.2"
globals "^13.19.0"
graphemer "^1.4.0"
ignore "^5.2.0"
imurmurhash "^0.1.4"
is-glob "^4.0.0"
is-path-inside "^3.0.3"
js-yaml "^4.1.0"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.4.1"
lodash.merge "^4.6.2"
minimatch "^3.1.2"
natural-compare "^1.4.0"
optionator "^0.9.3"
strip-ansi "^6.0.1"
text-table "^0.2.0"

eslint@^8.50.0:
eslint@^8.41.0, eslint@^8.50.0:
version "8.50.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.50.0.tgz#2ae6015fee0240fcd3f83e1e25df0287f487d6b2"
integrity sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==
Expand Down Expand Up @@ -10351,20 +10243,20 @@ [email protected]:
minimatch "^5.1.0"
shiki "^0.11.1"

"typescript@^4.6.4 || ^5.0.0", typescript@~5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
"typescript@^4.6.4 || ^5.0.0", typescript@^5:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==

typescript@^4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

typescript@^5:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
typescript@~5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

uglify-js@^3.1.4:
version "3.17.4"
Expand Down

0 comments on commit 3ecb802

Please sign in to comment.