track-cli 3.0.0-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +3 -0
- package/esm/_dnt.polyfills.d.ts +6 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/_dnt.shims.d.ts +19 -0
- package/esm/_dnt.shims.js +78 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.js +473 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.js +18 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.js +8 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.js +12 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.d.ts +50 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.js +545 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.d.ts +55 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.js +57 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.d.ts +38 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.js +93 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.d.ts +22 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.js +28 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.d.ts +49 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.js +60 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.d.ts +43 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.d.ts +21 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.js +29 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.js +44 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.js +38 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.d.ts +15 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.js +96 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.d.ts +35 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.js +80 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.d.ts +51 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.js +244 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.js +74 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.d.ts +27 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.js +55 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.d.ts +33 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.js +75 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.js +43 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.js +68 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.js +53 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.d.ts +102 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.js +163 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.d.ts +37 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.js +216 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.d.ts +16 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.js +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.d.ts +29 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.js +88 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.js +158 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.d.ts +39 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.js +46 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.js +3 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.d.ts +11 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.js +161 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.js +36 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.d.ts +83 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.js +361 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.d.ts +9 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.js +33 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.d.ts +86 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.js +442 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.js +5 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.d.ts +91 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.js +909 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.js +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.d.ts +76 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.js +154 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.d.ts +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.js +105 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.d.ts +831 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.js +1701 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.js +201 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.js +141 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.d.ts +21 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.js +285 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.d.ts +8 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.js +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.d.ts +45 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.js +323 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.js +34 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.js +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.d.ts +41 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.js +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.js +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.js +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.js +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.js +29 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.js +12 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.d.ts +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.js +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.d.ts +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.js +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.js +55 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.js +102 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.js +75 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.d.ts +60 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.js +117 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.js +106 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.js +157 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.d.ts +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.d.ts +33 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.js +402 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.js +11 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.js +4 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.d.ts +59 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.d.ts +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.js +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.d.ts +78 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.js +128 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +99 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.js +529 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.d.ts +49 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.js +74 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.d.ts +135 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.js +237 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.d.ts +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.js +60 -0
- package/esm/package.json +3 -0
- package/esm/src/action/add.d.ts +1 -0
- package/esm/src/action/add.js +57 -0
- package/esm/src/action/clone.d.ts +6 -0
- package/esm/src/action/clone.js +108 -0
- package/esm/src/action/lang.d.ts +1 -0
- package/esm/src/action/lang.js +40 -0
- package/esm/src/action/pull.d.ts +1 -0
- package/esm/src/action/pull.js +22 -0
- package/esm/src/action/remove.d.ts +4 -0
- package/esm/src/action/remove.js +67 -0
- package/esm/src/action/reset.d.ts +1 -0
- package/esm/src/action/reset.js +21 -0
- package/esm/src/action/run.d.ts +4 -0
- package/esm/src/action/run.js +163 -0
- package/esm/src/action/status.d.ts +1 -0
- package/esm/src/action/status.js +5 -0
- package/esm/src/main.d.ts +2 -0
- package/esm/src/main.js +96 -0
- package/esm/src/meta.d.ts +3 -0
- package/esm/src/meta.js +51 -0
- package/esm/src/orca/client.d.ts +20 -0
- package/esm/src/orca/client.js +152 -0
- package/esm/src/orca/types.d.ts +54 -0
- package/esm/src/orca/types.js +12 -0
- package/esm/src/shared/config.d.ts +24 -0
- package/esm/src/shared/config.js +24 -0
- package/esm/src/shared/errors.d.ts +82 -0
- package/esm/src/shared/errors.js +228 -0
- package/esm/src/shared/file.d.ts +30 -0
- package/esm/src/shared/file.js +110 -0
- package/esm/src/shared/mod.d.ts +40 -0
- package/esm/src/shared/mod.js +383 -0
- package/esm/src/shared/types.d.ts +12 -0
- package/esm/src/shared/types.js +1 -0
- package/esm/src/track/client.d.ts +60 -0
- package/esm/src/track/client.js +268 -0
- package/esm/src/track/types.d.ts +210 -0
- package/esm/src/track/types.js +40 -0
- package/package.json +35 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../_dnt.shims.js";
|
|
2
|
+
import { Command } from "../command.js";
|
|
3
|
+
import { UnknownCommandError } from "../_errors.js";
|
|
4
|
+
import { CommandType } from "../types/command.js";
|
|
5
|
+
/** Generates well formatted and colored help output for specified command. */
|
|
6
|
+
export class HelpCommand extends Command {
|
|
7
|
+
constructor(cmd) {
|
|
8
|
+
super();
|
|
9
|
+
return this
|
|
10
|
+
.type("command", new CommandType())
|
|
11
|
+
.arguments("[command:command]")
|
|
12
|
+
.description("Show this help or the help of a sub-command.")
|
|
13
|
+
.noGlobals()
|
|
14
|
+
.action(async (_, name) => {
|
|
15
|
+
if (!cmd) {
|
|
16
|
+
cmd = name
|
|
17
|
+
? this.getGlobalParent()?.getBaseCommand(name)
|
|
18
|
+
: this.getGlobalParent();
|
|
19
|
+
}
|
|
20
|
+
if (!cmd) {
|
|
21
|
+
const cmds = this.getGlobalParent()?.getCommands();
|
|
22
|
+
throw new UnknownCommandError(name ?? "", cmds ?? [], [
|
|
23
|
+
this.getName(),
|
|
24
|
+
...this.getAliases(),
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
await cmd.checkVersion();
|
|
28
|
+
cmd.showHelp();
|
|
29
|
+
if (this.shouldExit()) {
|
|
30
|
+
dntShim.Deno.exit(0);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./command.js";
|
|
3
|
+
export * from "./completions/mod.js";
|
|
4
|
+
export * from "./help/mod.js";
|
|
5
|
+
export * from "./upgrade/mod.js";
|
|
6
|
+
export * from "./types/action_list.js";
|
|
7
|
+
export * from "./types/boolean.js";
|
|
8
|
+
export * from "./types/child_command.js";
|
|
9
|
+
export * from "./types/command.js";
|
|
10
|
+
export * from "./types/enum.js";
|
|
11
|
+
export * from "./types/file.js";
|
|
12
|
+
export * from "./types/integer.js";
|
|
13
|
+
export * from "./types/number.js";
|
|
14
|
+
export * from "./types/string.js";
|
|
15
|
+
export * from "./type.js";
|
|
16
|
+
export { ValidationError } from "./_errors.js";
|
|
17
|
+
export { type ValidationErrorOptions } from "./_errors.js";
|
|
18
|
+
export * from "./deprecated.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./command.js";
|
|
3
|
+
export * from "./completions/mod.js";
|
|
4
|
+
export * from "./help/mod.js";
|
|
5
|
+
export * from "./upgrade/mod.js";
|
|
6
|
+
export * from "./types/action_list.js";
|
|
7
|
+
export * from "./types/boolean.js";
|
|
8
|
+
export * from "./types/child_command.js";
|
|
9
|
+
export * from "./types/command.js";
|
|
10
|
+
export * from "./types/enum.js";
|
|
11
|
+
export * from "./types/file.js";
|
|
12
|
+
export * from "./types/integer.js";
|
|
13
|
+
export * from "./types/number.js";
|
|
14
|
+
export * from "./types/string.js";
|
|
15
|
+
export * from "./type.js";
|
|
16
|
+
export { ValidationError } from "./_errors.js";
|
|
17
|
+
export * from "./deprecated.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Command } from "./command.js";
|
|
2
|
+
import { TypeOrTypeHandler } from "./types.js";
|
|
3
|
+
import type { ArgumentValue, CompleteHandlerResult, ValuesHandlerResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Base class for custom types.
|
|
6
|
+
*
|
|
7
|
+
* **Custom type example:**
|
|
8
|
+
* ```
|
|
9
|
+
* export class ColorType extends Type<string> {
|
|
10
|
+
* public parse({ label, name, value, type }: ArgumentValue): string {
|
|
11
|
+
* if (["red", "blue"].includes(value)) {
|
|
12
|
+
* trow new Error(
|
|
13
|
+
* `${label} "${name}" must be of type "${type}", but got "${value}".` +
|
|
14
|
+
* "Valid colors are: red, blue"
|
|
15
|
+
* );
|
|
16
|
+
* }
|
|
17
|
+
* return value;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* public complete(): string[] {
|
|
21
|
+
* return ["red", "blue"];
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class Type<TValue> {
|
|
27
|
+
abstract parse(type: ArgumentValue): TValue;
|
|
28
|
+
/**
|
|
29
|
+
* Returns values displayed in help text. If no complete method is provided,
|
|
30
|
+
* these values are also used for shell completions.
|
|
31
|
+
*/
|
|
32
|
+
values?(cmd: Command, parent?: Command): ValuesHandlerResult;
|
|
33
|
+
/**
|
|
34
|
+
* Returns shell completion values. If no complete method is provided,
|
|
35
|
+
* values from the values method are used.
|
|
36
|
+
*/
|
|
37
|
+
complete?(cmd: Command, parent?: Command): CompleteHandlerResult;
|
|
38
|
+
}
|
|
39
|
+
export declare namespace Type {
|
|
40
|
+
type infer<TType, TDefault = TType> = TType extends TypeOrTypeHandler<infer Value> ? Value : TDefault;
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for custom types.
|
|
3
|
+
*
|
|
4
|
+
* **Custom type example:**
|
|
5
|
+
* ```
|
|
6
|
+
* export class ColorType extends Type<string> {
|
|
7
|
+
* public parse({ label, name, value, type }: ArgumentValue): string {
|
|
8
|
+
* if (["red", "blue"].includes(value)) {
|
|
9
|
+
* trow new Error(
|
|
10
|
+
* `${label} "${name}" must be of type "${type}", but got "${value}".` +
|
|
11
|
+
* "Valid colors are: red, blue"
|
|
12
|
+
* );
|
|
13
|
+
* }
|
|
14
|
+
* return value;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* public complete(): string[] {
|
|
18
|
+
* return ["red", "blue"];
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class Type {
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from "../command.js";
|
|
2
|
+
import { StringType } from "./string.js";
|
|
3
|
+
/** Completion list type. */
|
|
4
|
+
export declare class ActionListType extends StringType {
|
|
5
|
+
protected cmd: Command;
|
|
6
|
+
constructor(cmd: Command);
|
|
7
|
+
/** Complete action names. */
|
|
8
|
+
complete(): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StringType } from "./string.js";
|
|
2
|
+
/** Completion list type. */
|
|
3
|
+
export class ActionListType extends StringType {
|
|
4
|
+
constructor(cmd) {
|
|
5
|
+
super();
|
|
6
|
+
Object.defineProperty(this, "cmd", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: cmd
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** Complete action names. */
|
|
14
|
+
complete() {
|
|
15
|
+
return this.cmd.getCompletions()
|
|
16
|
+
.map((type) => type.name)
|
|
17
|
+
// filter unique values
|
|
18
|
+
.filter((value, index, self) => self.indexOf(value) === index);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArgumentValue } from "../types.js";
|
|
2
|
+
import { Type } from "../type.js";
|
|
3
|
+
/** Boolean type with auto completion. Allows `true`, `false`, `0` and `1`. */
|
|
4
|
+
export declare class BooleanType extends Type<boolean> {
|
|
5
|
+
/** Parse boolean type. */
|
|
6
|
+
parse(type: ArgumentValue): boolean;
|
|
7
|
+
/** Complete boolean type. */
|
|
8
|
+
complete(): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { boolean } from "../../flags/types/boolean.js";
|
|
2
|
+
import { Type } from "../type.js";
|
|
3
|
+
/** Boolean type with auto completion. Allows `true`, `false`, `0` and `1`. */
|
|
4
|
+
export class BooleanType extends Type {
|
|
5
|
+
/** Parse boolean type. */
|
|
6
|
+
parse(type) {
|
|
7
|
+
return boolean(type);
|
|
8
|
+
}
|
|
9
|
+
/** Complete boolean type. */
|
|
10
|
+
complete() {
|
|
11
|
+
return ["true", "false"];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from "../command.js";
|
|
2
|
+
import { StringType } from "./string.js";
|
|
3
|
+
/** String type with auto completion of child command names. */
|
|
4
|
+
export declare class ChildCommandType extends StringType {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(cmd?: Command);
|
|
7
|
+
/** Complete child command names. */
|
|
8
|
+
complete(cmd: Command): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ChildCommandType_cmd;
|
|
13
|
+
import { StringType } from "./string.js";
|
|
14
|
+
/** String type with auto completion of child command names. */
|
|
15
|
+
export class ChildCommandType extends StringType {
|
|
16
|
+
constructor(cmd) {
|
|
17
|
+
super();
|
|
18
|
+
_ChildCommandType_cmd.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _ChildCommandType_cmd, cmd, "f");
|
|
20
|
+
}
|
|
21
|
+
/** Complete child command names. */
|
|
22
|
+
complete(cmd) {
|
|
23
|
+
return (__classPrivateFieldGet(this, _ChildCommandType_cmd, "f") ?? cmd)?.getCommands(false)
|
|
24
|
+
.map((cmd) => cmd.getName()) || [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
_ChildCommandType_cmd = new WeakMap();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "../command.js";
|
|
2
|
+
import { StringType } from "./string.js";
|
|
3
|
+
/** String type with auto completion of sibling command names. */
|
|
4
|
+
export declare class CommandType extends StringType {
|
|
5
|
+
/** Complete sub-command names of global parent command. */
|
|
6
|
+
complete(_cmd: Command, parent?: Command): string[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StringType } from "./string.js";
|
|
2
|
+
/** String type with auto completion of sibling command names. */
|
|
3
|
+
export class CommandType extends StringType {
|
|
4
|
+
/** Complete sub-command names of global parent command. */
|
|
5
|
+
complete(_cmd, parent) {
|
|
6
|
+
return parent?.getCommands(false)
|
|
7
|
+
.map((cmd) => cmd.getName()) || [];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Type } from "../type.js";
|
|
2
|
+
import type { ArgumentValue } from "../types.js";
|
|
3
|
+
/** Enum type. Allows only provided values. */
|
|
4
|
+
export declare class EnumType<TValue extends string | number | boolean> extends Type<TValue> {
|
|
5
|
+
private readonly allowedValues;
|
|
6
|
+
constructor(values: ReadonlyArray<TValue> | Record<string, TValue>);
|
|
7
|
+
parse(type: ArgumentValue): TValue;
|
|
8
|
+
values(): Array<TValue>;
|
|
9
|
+
complete(): Array<TValue>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from "../type.js";
|
|
2
|
+
import { InvalidTypeError } from "../../flags/_errors.js";
|
|
3
|
+
/** Enum type. Allows only provided values. */
|
|
4
|
+
export class EnumType extends Type {
|
|
5
|
+
constructor(values) {
|
|
6
|
+
super();
|
|
7
|
+
Object.defineProperty(this, "allowedValues", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
this.allowedValues = Array.isArray(values) ? values : Object.values(values);
|
|
14
|
+
}
|
|
15
|
+
parse(type) {
|
|
16
|
+
for (const value of this.allowedValues) {
|
|
17
|
+
if (value.toString() === type.value) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
throw new InvalidTypeError(type, this.allowedValues.slice());
|
|
22
|
+
}
|
|
23
|
+
values() {
|
|
24
|
+
return this.allowedValues.slice();
|
|
25
|
+
}
|
|
26
|
+
complete() {
|
|
27
|
+
return this.values();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StringType } from "./string.js";
|
|
2
|
+
// export interface FileTypeOptions {
|
|
3
|
+
// dirsOnly?: boolean;
|
|
4
|
+
// pattern?: string;
|
|
5
|
+
// ignore?: Array<string>;
|
|
6
|
+
// }
|
|
7
|
+
/** Integer type. */
|
|
8
|
+
export class FileType extends StringType {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ArgumentOptions, ArgumentValue, DefaultValue, FlagOptions, TypeHandler, ValueHandler } from "../flags/types.js";
|
|
2
|
+
import type { ValidationError } from "./_errors.js";
|
|
3
|
+
import type { Command } from "./command.js";
|
|
4
|
+
import type { HelpOptions } from "./help/_help_generator.js";
|
|
5
|
+
import type { Type } from "./type.js";
|
|
6
|
+
export type { ArgumentValue, DefaultValue, TypeHandler };
|
|
7
|
+
type Merge<T, V> = T extends void ? V : V extends void ? T : T & V;
|
|
8
|
+
export type TypeOrTypeHandler<TValue> = Type<TValue> | TypeHandler<TValue>;
|
|
9
|
+
type Id<TValue> = TValue extends Record<string, unknown> ? TValue extends infer U ? {
|
|
10
|
+
[K in keyof U]: Id<U[K]>;
|
|
11
|
+
} : never : TValue;
|
|
12
|
+
export type MapTypes<T> = T extends Record<string, unknown> | Array<unknown> ? {
|
|
13
|
+
[K in keyof T]: MapTypes<T[K]>;
|
|
14
|
+
} : Type.infer<T>;
|
|
15
|
+
/** Description handler. */
|
|
16
|
+
export type Description<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> = string | DescriptionHandler<TOptions, TArguments, TGlobals, TParentGlobals, TTypes, TGlobalTypes, TParentTypes, TParentCommand>;
|
|
17
|
+
/** Description handler. */
|
|
18
|
+
export type DescriptionHandler<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> = (this: Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>) => string;
|
|
19
|
+
/** Action handler for commands and options. */
|
|
20
|
+
export type ActionHandler<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> = (this: Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>, options: MapTypes<Merge<TParentGlobals, Merge<TGlobals, TOptions>>>, ...args: MapTypes<TArguments>) => unknown | Promise<unknown>;
|
|
21
|
+
/** Argument details. */
|
|
22
|
+
export interface Argument extends ArgumentOptions {
|
|
23
|
+
/** Argument name. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Shell completion action. */
|
|
26
|
+
action: string;
|
|
27
|
+
/** Arguments type. */
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
/** Result of `cmd.parse()` method. */
|
|
31
|
+
export interface CommandResult<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> {
|
|
32
|
+
options: Id<Merge<Merge<TParentGlobals, TGlobals>, TOptions>>;
|
|
33
|
+
args: TArguments;
|
|
34
|
+
literal: string[];
|
|
35
|
+
cmd: Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>;
|
|
36
|
+
}
|
|
37
|
+
export type OptionValueHandler<TValue = any, TReturn = TValue> = ValueHandler<TValue, TReturn>;
|
|
38
|
+
type ExcludedCommandOptions = "name" | "args" | "type" | "optionalValue" | "requiredValue" | "aliases" | "variadic" | "list" | "value" | "default";
|
|
39
|
+
/** Command option options. */
|
|
40
|
+
export interface GlobalOptionOptions<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> extends Omit<FlagOptions, ExcludedCommandOptions> {
|
|
41
|
+
override?: boolean;
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
action?: ActionHandler<TOptions, TArguments, TGlobals, TParentGlobals, TTypes, TGlobalTypes, TParentTypes, TParentCommand>;
|
|
44
|
+
prepend?: boolean;
|
|
45
|
+
value?: OptionValueHandler;
|
|
46
|
+
default?: DefaultValue;
|
|
47
|
+
}
|
|
48
|
+
export interface OptionOptions<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> extends GlobalOptionOptions<TOptions, TArguments, TGlobals, TParentGlobals, TTypes, TGlobalTypes, TParentTypes, TParentCommand> {
|
|
49
|
+
global?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Command option settings. */
|
|
52
|
+
export interface Option<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> extends OptionOptions<TOptions, TArguments, TGlobals, TParentGlobals, TTypes, TGlobalTypes, TParentTypes, TParentCommand>, Omit<FlagOptions, "value"> {
|
|
53
|
+
description: string;
|
|
54
|
+
flags: Array<string>;
|
|
55
|
+
typeDefinition?: string;
|
|
56
|
+
args: Argument[];
|
|
57
|
+
groupName?: string;
|
|
58
|
+
}
|
|
59
|
+
export type EnvVarValueHandler<TValue = any, TReturn = TValue> = (val: TValue) => TReturn;
|
|
60
|
+
/** Environment variable options */
|
|
61
|
+
export interface GlobalEnvVarOptions {
|
|
62
|
+
hidden?: boolean;
|
|
63
|
+
required?: boolean;
|
|
64
|
+
prefix?: string | undefined;
|
|
65
|
+
value?: EnvVarValueHandler;
|
|
66
|
+
}
|
|
67
|
+
/** Environment variable options */
|
|
68
|
+
export interface EnvVarOptions extends GlobalEnvVarOptions {
|
|
69
|
+
global?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Environment variable settings. */
|
|
72
|
+
export interface EnvVar extends EnvVarOptions {
|
|
73
|
+
name: string;
|
|
74
|
+
names: string[];
|
|
75
|
+
description: string;
|
|
76
|
+
type: string;
|
|
77
|
+
details: Argument;
|
|
78
|
+
}
|
|
79
|
+
/** Type options. */
|
|
80
|
+
export interface TypeOptions {
|
|
81
|
+
override?: boolean;
|
|
82
|
+
global?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** Type settings. */
|
|
85
|
+
export interface TypeDef extends TypeOptions {
|
|
86
|
+
name: string;
|
|
87
|
+
handler: Type<unknown> | TypeHandler<unknown>;
|
|
88
|
+
}
|
|
89
|
+
/** Example settings. */
|
|
90
|
+
export interface Example {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
}
|
|
94
|
+
/** Completion options. */
|
|
95
|
+
export interface CompleteOptions {
|
|
96
|
+
override?: boolean;
|
|
97
|
+
global?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/** Completion settings. */
|
|
100
|
+
export interface Completion<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> extends CompleteOptions {
|
|
101
|
+
name: string;
|
|
102
|
+
complete: CompleteHandler<TOptions, TArguments, TGlobals, TParentGlobals, TTypes, TGlobalTypes, TParentTypes, TParentCommand>;
|
|
103
|
+
}
|
|
104
|
+
export type CompleteHandlerResult = Array<string | number | boolean> | Promise<Array<string | number | boolean>>;
|
|
105
|
+
export type ValuesHandlerResult = Array<string | number | boolean>;
|
|
106
|
+
/** Type parser method. */
|
|
107
|
+
export type CompleteHandler<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined> = (cmd: Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>, parent?: Command<any>) => CompleteHandlerResult;
|
|
108
|
+
/**
|
|
109
|
+
* Help callback method to print the help.
|
|
110
|
+
* Invoked by the `--help` option and `help` command and the `.getHelp()` and `.showHelp()` methods.
|
|
111
|
+
*/
|
|
112
|
+
export type HelpHandler<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined, TCommand extends Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand> = Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>> = (this: TCommand, cmd: TCommand, options: HelpOptions) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Version callback method to print the version.
|
|
115
|
+
* Invoked by the `--help` option command and the `.getVersion()` and `.showHelp()` methods.
|
|
116
|
+
*/
|
|
117
|
+
export type VersionHandler<TOptions extends Record<string, any> | void = any, TArguments extends Array<unknown> = TOptions extends number ? any : [], TGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TParentGlobals extends Record<string, any> | void = TOptions extends number ? any : void, TTypes extends Record<string, any> | void = TOptions extends number ? any : void, TGlobalTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentTypes extends Record<string, any> | void = TOptions extends number ? any : void, TParentCommand extends Command<any> | undefined = TOptions extends number ? any : undefined, TCommand extends Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand> = Command<TParentGlobals, TParentTypes, TOptions, TArguments, TGlobals, TTypes, TGlobalTypes, TParentCommand>> = (this: TCommand, cmd: TCommand) => string;
|
|
118
|
+
export type ErrorHandler = (error: Error | ValidationError, cmd: Command) => unknown;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Provider, Versions } from "../provider.js";
|
|
2
|
+
export interface DenoLandProviderOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class DenoLandProvider extends Provider {
|
|
6
|
+
name: string;
|
|
7
|
+
private readonly repositoryUrl;
|
|
8
|
+
private readonly registryUrl;
|
|
9
|
+
private readonly moduleName?;
|
|
10
|
+
constructor({ name }?: DenoLandProviderOptions);
|
|
11
|
+
getVersions(name: string): Promise<Versions>;
|
|
12
|
+
getRepositoryUrl(name: string): string;
|
|
13
|
+
getRegistryUrl(name: string, version: string): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../../_dnt.shims.js";
|
|
2
|
+
import { Provider } from "../provider.js";
|
|
3
|
+
export class DenoLandProvider extends Provider {
|
|
4
|
+
constructor({ name } = {}) {
|
|
5
|
+
super();
|
|
6
|
+
Object.defineProperty(this, "name", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: "deno.land"
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "repositoryUrl", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: "https://deno.land/x/"
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "registryUrl", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: "https://deno.land/x/"
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "moduleName", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
this.moduleName = name;
|
|
31
|
+
}
|
|
32
|
+
async getVersions(name) {
|
|
33
|
+
const response = await dntShim.fetch(`https://cdn.deno.land/${this.moduleName ?? name}/meta/versions.json`);
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error("couldn't fetch the latest version - try again after sometime");
|
|
36
|
+
}
|
|
37
|
+
return await response.json();
|
|
38
|
+
}
|
|
39
|
+
getRepositoryUrl(name) {
|
|
40
|
+
return new URL(`${this.moduleName ?? name}/`, this.repositoryUrl).href;
|
|
41
|
+
}
|
|
42
|
+
getRegistryUrl(name, version) {
|
|
43
|
+
return new URL(`${this.moduleName ?? name}@${version}/`, this.registryUrl)
|
|
44
|
+
.href;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Provider, Versions } from "../provider.js";
|
|
2
|
+
export interface GithubProviderOptions {
|
|
3
|
+
repository: string;
|
|
4
|
+
branches?: boolean;
|
|
5
|
+
token?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GithubVersions extends Versions {
|
|
8
|
+
tags: Array<string>;
|
|
9
|
+
branches: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare class GithubProvider extends Provider {
|
|
12
|
+
name: string;
|
|
13
|
+
private readonly repositoryUrl;
|
|
14
|
+
private readonly registryUrl;
|
|
15
|
+
private readonly apiUrl;
|
|
16
|
+
private readonly repositoryName;
|
|
17
|
+
private readonly listBranches?;
|
|
18
|
+
private readonly githubToken?;
|
|
19
|
+
constructor({ repository, branches, token }: GithubProviderOptions);
|
|
20
|
+
getVersions(_name: string): Promise<GithubVersions>;
|
|
21
|
+
getRepositoryUrl(_name: string): string;
|
|
22
|
+
getRegistryUrl(_name: string, version: string): string;
|
|
23
|
+
listVersions(name: string, currentVersion?: string): Promise<void>;
|
|
24
|
+
private getApiUrl;
|
|
25
|
+
private gitFetch;
|
|
26
|
+
}
|