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,118 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../../_dnt.shims.js";
|
|
2
|
+
import { Provider } from "../provider.js";
|
|
3
|
+
import { bold, brightBlue } from "../../deps.js";
|
|
4
|
+
export class GithubProvider extends Provider {
|
|
5
|
+
constructor({ repository, branches = true, token }) {
|
|
6
|
+
super();
|
|
7
|
+
Object.defineProperty(this, "name", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: "github"
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "repositoryUrl", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: "https://github.com/"
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "registryUrl", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: "https://raw.githubusercontent.com/"
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "apiUrl", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: "https://api.github.com/repos/"
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "repositoryName", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "listBranches", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "githubToken", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
this.repositoryName = repository;
|
|
50
|
+
this.listBranches = branches;
|
|
51
|
+
this.githubToken = token;
|
|
52
|
+
}
|
|
53
|
+
async getVersions(_name) {
|
|
54
|
+
const [tags, branches] = await Promise.all([
|
|
55
|
+
this.gitFetch("git/refs/tags"),
|
|
56
|
+
this.gitFetch("branches"),
|
|
57
|
+
]);
|
|
58
|
+
const tagNames = tags
|
|
59
|
+
.map((tag) => tag.ref.replace(/^refs\/tags\//, ""))
|
|
60
|
+
.reverse();
|
|
61
|
+
const branchNames = branches
|
|
62
|
+
.sort((a, b) => (a.protected === b.protected) ? 0 : (a.protected ? 1 : -1))
|
|
63
|
+
.map((tag) => `${tag.name} ${tag.protected ? `(${bold("Protected")})` : ""}`)
|
|
64
|
+
.reverse();
|
|
65
|
+
return {
|
|
66
|
+
versions: [
|
|
67
|
+
...tagNames,
|
|
68
|
+
...branchNames,
|
|
69
|
+
],
|
|
70
|
+
latest: tagNames[0],
|
|
71
|
+
tags: tagNames,
|
|
72
|
+
branches: branchNames,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
getRepositoryUrl(_name) {
|
|
76
|
+
return new URL(`${this.repositoryName}/`, this.repositoryUrl).href;
|
|
77
|
+
}
|
|
78
|
+
getRegistryUrl(_name, version) {
|
|
79
|
+
return new URL(`${this.repositoryName}/${version}/`, this.registryUrl).href;
|
|
80
|
+
}
|
|
81
|
+
async listVersions(name, currentVersion) {
|
|
82
|
+
const { tags, branches } = await this.getVersions(name);
|
|
83
|
+
const showBranches = !!this.listBranches && branches.length > 0;
|
|
84
|
+
const indent = showBranches ? 2 : 0;
|
|
85
|
+
if (showBranches) {
|
|
86
|
+
console.log("\n" + " ".repeat(indent) + bold(brightBlue("Tags:\n")));
|
|
87
|
+
}
|
|
88
|
+
super.printVersions(tags, currentVersion, { indent });
|
|
89
|
+
if (showBranches) {
|
|
90
|
+
console.log("\n" + " ".repeat(indent) + bold(brightBlue("Branches:\n")));
|
|
91
|
+
super.printVersions(branches, currentVersion, { maxCols: 5, indent });
|
|
92
|
+
console.log();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
getApiUrl(endpoint) {
|
|
96
|
+
return new URL(`${this.repositoryName}/${endpoint}`, this.apiUrl).href;
|
|
97
|
+
}
|
|
98
|
+
async gitFetch(endpoint) {
|
|
99
|
+
const headers = new dntShim.Headers({ "Content-Type": "application/json" });
|
|
100
|
+
if (this.githubToken) {
|
|
101
|
+
headers.set("Authorization", this.githubToken ? `token ${this.githubToken}` : "");
|
|
102
|
+
}
|
|
103
|
+
const response = await dntShim.fetch(this.getApiUrl(endpoint), {
|
|
104
|
+
method: "GET",
|
|
105
|
+
cache: "default",
|
|
106
|
+
headers,
|
|
107
|
+
});
|
|
108
|
+
if (!response.status) {
|
|
109
|
+
throw new Error("couldn't fetch versions - try again after sometime");
|
|
110
|
+
}
|
|
111
|
+
const data = await response.json();
|
|
112
|
+
if (typeof data === "object" && "message" in data &&
|
|
113
|
+
"documentation_url" in data) {
|
|
114
|
+
throw new Error(data.message + " " + data.documentation_url);
|
|
115
|
+
}
|
|
116
|
+
return data;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Provider, Versions } from "../provider.js";
|
|
2
|
+
export interface NestLandProviderOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class NestLandProvider extends Provider {
|
|
6
|
+
name: string;
|
|
7
|
+
private readonly repositoryUrl;
|
|
8
|
+
private readonly registryUrl;
|
|
9
|
+
private readonly moduleName?;
|
|
10
|
+
constructor({ name }?: NestLandProviderOptions);
|
|
11
|
+
getVersions(name: string): Promise<Versions>;
|
|
12
|
+
getRepositoryUrl(name: string): string;
|
|
13
|
+
getRegistryUrl(name: string, version: string): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../../_dnt.shims.js";
|
|
2
|
+
import { Provider } from "../provider.js";
|
|
3
|
+
export class NestLandProvider extends Provider {
|
|
4
|
+
constructor({ name } = {}) {
|
|
5
|
+
super();
|
|
6
|
+
Object.defineProperty(this, "name", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: "nest.land"
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "repositoryUrl", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: "https://nest.land/package/"
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "registryUrl", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: "https://x.nest.land/"
|
|
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://nest.land/api/package-client`, {
|
|
34
|
+
method: "post",
|
|
35
|
+
body: JSON.stringify({ data: { name: this.moduleName ?? name } }),
|
|
36
|
+
headers: { "Content-Type": "application/json" },
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new Error("couldn't fetch the latest version - try again after sometime");
|
|
40
|
+
}
|
|
41
|
+
const { body: { latestVersion, packageUploadNames } } = await response
|
|
42
|
+
.json();
|
|
43
|
+
return {
|
|
44
|
+
latest: latestVersion,
|
|
45
|
+
versions: packageUploadNames.map((version) => version.replace(new RegExp(`^${this.moduleName ?? name}@`), "")).reverse(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
getRepositoryUrl(name) {
|
|
49
|
+
return new URL(`${this.moduleName ?? name}/`, this.repositoryUrl).href;
|
|
50
|
+
}
|
|
51
|
+
getRegistryUrl(name, version) {
|
|
52
|
+
return new URL(`${this.moduleName ?? name}@${version}/`, this.registryUrl)
|
|
53
|
+
.href;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Versions {
|
|
2
|
+
latest: string;
|
|
3
|
+
versions: Array<string>;
|
|
4
|
+
}
|
|
5
|
+
export interface UpgradeOptions {
|
|
6
|
+
name: string;
|
|
7
|
+
from?: string;
|
|
8
|
+
to: string;
|
|
9
|
+
args?: Array<string>;
|
|
10
|
+
main?: string;
|
|
11
|
+
importMap?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class Provider {
|
|
14
|
+
abstract readonly name: string;
|
|
15
|
+
protected readonly maxListSize: number;
|
|
16
|
+
private maxCols;
|
|
17
|
+
abstract getVersions(name: string): Promise<Versions>;
|
|
18
|
+
abstract getRepositoryUrl(name: string): string;
|
|
19
|
+
abstract getRegistryUrl(name: string, version: string): string;
|
|
20
|
+
isOutdated(name: string, currentVersion: string, targetVersion: string): Promise<boolean>;
|
|
21
|
+
upgrade({ name, from, to, importMap, main, args }: UpgradeOptions): Promise<void>;
|
|
22
|
+
listVersions(name: string, currentVersion?: string): Promise<void>;
|
|
23
|
+
protected printVersions(versions: Array<string>, currentVersion?: string, { maxCols, indent }?: {
|
|
24
|
+
maxCols?: number;
|
|
25
|
+
indent?: number;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../_dnt.shims.js";
|
|
2
|
+
import { bold, brightBlue, cyan, green, red, yellow } from "../deps.js";
|
|
3
|
+
import { ValidationError } from "../_errors.js";
|
|
4
|
+
import { Table } from "../../table/table.js";
|
|
5
|
+
export class Provider {
|
|
6
|
+
constructor() {
|
|
7
|
+
Object.defineProperty(this, "maxListSize", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: 25
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "maxCols", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: 8
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async isOutdated(name, currentVersion, targetVersion) {
|
|
21
|
+
const { latest, versions } = await this.getVersions(name);
|
|
22
|
+
if (targetVersion === "latest") {
|
|
23
|
+
targetVersion = latest;
|
|
24
|
+
}
|
|
25
|
+
// Check if requested version exists.
|
|
26
|
+
if (targetVersion && !versions.includes(targetVersion)) {
|
|
27
|
+
throw new ValidationError(`The provided version ${bold(red(targetVersion))} is not found.\n\n ${cyan(`Visit ${brightBlue(this.getRepositoryUrl(name))} for available releases or run again with the ${(yellow("-l"))} or ${(yellow("--list-versions"))} command.`)}`);
|
|
28
|
+
}
|
|
29
|
+
// Check if requested version is already the latest available version.
|
|
30
|
+
if (latest && latest === currentVersion && latest === targetVersion) {
|
|
31
|
+
console.warn(yellow(`You're already using the latest available version ${currentVersion} of ${name}.`));
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// Check if requested version is already installed.
|
|
35
|
+
if (targetVersion && currentVersion === targetVersion) {
|
|
36
|
+
console.warn(yellow(`You're already using version ${currentVersion} of ${name}.`));
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
async upgrade({ name, from, to, importMap, main = `${name}.ts`, args = [] }) {
|
|
42
|
+
if (to === "latest") {
|
|
43
|
+
const { latest } = await this.getVersions(name);
|
|
44
|
+
to = latest;
|
|
45
|
+
}
|
|
46
|
+
const registry = new URL(main, this.getRegistryUrl(name, to)).href;
|
|
47
|
+
const cmd = [dntShim.Deno.execPath(), "install"];
|
|
48
|
+
if (importMap) {
|
|
49
|
+
const importJson = new URL(importMap, this.getRegistryUrl(name, to)).href;
|
|
50
|
+
cmd.push("--import-map", importJson);
|
|
51
|
+
}
|
|
52
|
+
if (args.length) {
|
|
53
|
+
cmd.push(...args, "--force", "--name", name, registry);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
cmd.push("--no-check", "--quiet", "--force", "--name", name, registry);
|
|
57
|
+
}
|
|
58
|
+
const process = dntShim.Deno.run({ cmd, stdout: "piped", stderr: "piped" });
|
|
59
|
+
const [status, stderr] = await Promise.all([
|
|
60
|
+
process.status(),
|
|
61
|
+
process.stderrOutput(),
|
|
62
|
+
process.output(),
|
|
63
|
+
]);
|
|
64
|
+
if (!status.success) {
|
|
65
|
+
process.close();
|
|
66
|
+
await dntShim.Deno.stderr.write(stderr);
|
|
67
|
+
throw new Error(`Failed to upgrade ${name} from ${from} to version ${to}!`);
|
|
68
|
+
}
|
|
69
|
+
process.close();
|
|
70
|
+
console.info(`Successfully upgraded ${name} from ${from} to version ${to}! (${this.getRegistryUrl(name, to)})`);
|
|
71
|
+
}
|
|
72
|
+
async listVersions(name, currentVersion) {
|
|
73
|
+
const { versions } = await this.getVersions(name);
|
|
74
|
+
this.printVersions(versions, currentVersion);
|
|
75
|
+
}
|
|
76
|
+
printVersions(versions, currentVersion, { maxCols = this.maxCols, indent = 0 } = {}) {
|
|
77
|
+
versions = versions.slice();
|
|
78
|
+
if (versions?.length) {
|
|
79
|
+
versions = versions.map((version) => currentVersion && currentVersion === version
|
|
80
|
+
? green(`* ${version}`)
|
|
81
|
+
: ` ${version}`);
|
|
82
|
+
if (versions.length > this.maxListSize) {
|
|
83
|
+
const table = new Table().indent(indent);
|
|
84
|
+
const rowSize = Math.ceil(versions.length / maxCols);
|
|
85
|
+
const colSize = Math.min(versions.length, maxCols);
|
|
86
|
+
let versionIndex = 0;
|
|
87
|
+
for (let colIndex = 0; colIndex < colSize; colIndex++) {
|
|
88
|
+
for (let rowIndex = 0; rowIndex < rowSize; rowIndex++) {
|
|
89
|
+
if (!table[rowIndex]) {
|
|
90
|
+
table[rowIndex] = [];
|
|
91
|
+
}
|
|
92
|
+
table[rowIndex][colIndex] = versions[versionIndex++];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
console.log(table.toString());
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(versions.map((version) => " ".repeat(indent) + version).join("\n"));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from "../command.js";
|
|
2
|
+
import type { Provider, Versions } from "./provider.js";
|
|
3
|
+
export interface UpgradeCommandOptions<TProvider extends Provider = Provider, TProviders extends TProvider | Array<TProvider> = TProvider | Array<TProvider>> {
|
|
4
|
+
provider: TProviders;
|
|
5
|
+
main?: string;
|
|
6
|
+
importMap?: string;
|
|
7
|
+
args?: Array<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare class UpgradeCommand extends Command {
|
|
10
|
+
private readonly providers;
|
|
11
|
+
constructor({ provider, main, args, importMap }: UpgradeCommandOptions);
|
|
12
|
+
getAllVersions(): Promise<Array<string>>;
|
|
13
|
+
getLatestVersion(): Promise<string>;
|
|
14
|
+
getVersions(): Promise<Versions>;
|
|
15
|
+
private getProvider;
|
|
16
|
+
private getProviderNames;
|
|
17
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as dntShim from "../../../../../../_dnt.shims.js";
|
|
2
|
+
import { Command } from "../command.js";
|
|
3
|
+
import { ValidationError } from "../../flags/_errors.js";
|
|
4
|
+
import { EnumType } from "../types/enum.js";
|
|
5
|
+
export class UpgradeCommand extends Command {
|
|
6
|
+
constructor({ provider, main, args, importMap }) {
|
|
7
|
+
super();
|
|
8
|
+
Object.defineProperty(this, "providers", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
this.providers = Array.isArray(provider) ? provider : [provider];
|
|
15
|
+
if (!this.providers.length) {
|
|
16
|
+
throw new Error(`No upgrade provider defined!`);
|
|
17
|
+
}
|
|
18
|
+
this
|
|
19
|
+
.description(() => `Upgrade ${this.getMainCommand().getName()} executable to latest or given version.`)
|
|
20
|
+
.noGlobals()
|
|
21
|
+
.type("provider", new EnumType(this.getProviderNames()))
|
|
22
|
+
.option("-r, --registry <name:provider>", `The registry name from which to upgrade.`, {
|
|
23
|
+
default: this.getProvider().name,
|
|
24
|
+
hidden: this.providers.length < 2,
|
|
25
|
+
value: (registry) => this.getProvider(registry),
|
|
26
|
+
})
|
|
27
|
+
.option("-l, --list-versions", "Show available versions.", {
|
|
28
|
+
action: async ({ registry }) => {
|
|
29
|
+
await registry.listVersions(this.getMainCommand().getName(), this.getVersion());
|
|
30
|
+
dntShim.Deno.exit(0);
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
.option("--version <version:string:version>", "The version to upgrade to.", { default: "latest" })
|
|
34
|
+
.option("-f, --force", "Replace current installation even if not out-of-date.")
|
|
35
|
+
.complete("version", () => this.getAllVersions())
|
|
36
|
+
.action(async ({ registry, version: targetVersion, force }) => {
|
|
37
|
+
const name = this.getMainCommand().getName();
|
|
38
|
+
const currentVersion = this.getVersion();
|
|
39
|
+
if (force || !currentVersion ||
|
|
40
|
+
await registry.isOutdated(name, currentVersion, targetVersion)) {
|
|
41
|
+
await registry.upgrade({
|
|
42
|
+
name,
|
|
43
|
+
main,
|
|
44
|
+
importMap,
|
|
45
|
+
from: currentVersion,
|
|
46
|
+
to: targetVersion,
|
|
47
|
+
args,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async getAllVersions() {
|
|
53
|
+
const { versions } = await this.getVersions();
|
|
54
|
+
return versions;
|
|
55
|
+
}
|
|
56
|
+
async getLatestVersion() {
|
|
57
|
+
const { latest } = await this.getVersions();
|
|
58
|
+
return latest;
|
|
59
|
+
}
|
|
60
|
+
getVersions() {
|
|
61
|
+
return this.getProvider().getVersions(this.getMainCommand().getName());
|
|
62
|
+
}
|
|
63
|
+
getProvider(name) {
|
|
64
|
+
const provider = name
|
|
65
|
+
? this.providers.find((provider) => provider.name === name)
|
|
66
|
+
: this.providers[0];
|
|
67
|
+
if (!provider) {
|
|
68
|
+
throw new ValidationError(`Unknown provider "${name}"`);
|
|
69
|
+
}
|
|
70
|
+
return provider;
|
|
71
|
+
}
|
|
72
|
+
getProviderNames() {
|
|
73
|
+
return this.providers.map((provider) => provider.name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ArgumentValue, FlagOptions } from "./types.js";
|
|
2
|
+
export declare class FlagsError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class UnknownRequiredOptionError extends FlagsError {
|
|
6
|
+
constructor(option: string, options: Array<FlagOptions>);
|
|
7
|
+
}
|
|
8
|
+
export declare class UnknownConflictingOptionError extends FlagsError {
|
|
9
|
+
constructor(option: string, options: Array<FlagOptions>);
|
|
10
|
+
}
|
|
11
|
+
export declare class UnknownTypeError extends FlagsError {
|
|
12
|
+
constructor(type: string, types: Array<string>);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A validation error is thrown when the command is wrongly used by the user.
|
|
16
|
+
* For example: If the user passes some invalid options or arguments to the
|
|
17
|
+
* command.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ValidationError extends FlagsError {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class DuplicateOptionError extends ValidationError {
|
|
23
|
+
constructor(name: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class InvalidOptionError extends ValidationError {
|
|
26
|
+
constructor(option: string, options: Array<FlagOptions>);
|
|
27
|
+
}
|
|
28
|
+
export declare class UnknownOptionError extends ValidationError {
|
|
29
|
+
constructor(option: string, options: Array<FlagOptions>);
|
|
30
|
+
}
|
|
31
|
+
export declare class MissingOptionValueError extends ValidationError {
|
|
32
|
+
constructor(option: string);
|
|
33
|
+
}
|
|
34
|
+
export declare class InvalidOptionValueError extends ValidationError {
|
|
35
|
+
constructor(option: string, expected: string, value: string);
|
|
36
|
+
}
|
|
37
|
+
export declare class UnexpectedOptionValueError extends ValidationError {
|
|
38
|
+
constructor(option: string, value: string);
|
|
39
|
+
}
|
|
40
|
+
export declare class OptionNotCombinableError extends ValidationError {
|
|
41
|
+
constructor(option: string);
|
|
42
|
+
}
|
|
43
|
+
export declare class ConflictingOptionError extends ValidationError {
|
|
44
|
+
constructor(option: string, conflictingOption: string);
|
|
45
|
+
}
|
|
46
|
+
export declare class DependingOptionError extends ValidationError {
|
|
47
|
+
constructor(option: string, dependingOption: string);
|
|
48
|
+
}
|
|
49
|
+
export declare class MissingRequiredOptionError extends ValidationError {
|
|
50
|
+
constructor(option: string);
|
|
51
|
+
}
|
|
52
|
+
export declare class UnexpectedRequiredArgumentError extends ValidationError {
|
|
53
|
+
constructor(arg: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class UnexpectedArgumentAfterVariadicArgumentError extends ValidationError {
|
|
56
|
+
constructor(arg: string);
|
|
57
|
+
}
|
|
58
|
+
export declare class InvalidTypeError extends ValidationError {
|
|
59
|
+
constructor({ label, name, value, type }: ArgumentValue, expected?: Array<string | number | boolean>);
|
|
60
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { didYouMeanOption, didYouMeanType, getFlag } from "./_utils.js";
|
|
2
|
+
export class FlagsError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
Object.setPrototypeOf(this, FlagsError.prototype);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class UnknownRequiredOptionError extends FlagsError {
|
|
9
|
+
constructor(option, options) {
|
|
10
|
+
super(`Unknown required option "${getFlag(option)}".${didYouMeanOption(option, options)}`);
|
|
11
|
+
Object.setPrototypeOf(this, UnknownRequiredOptionError.prototype);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class UnknownConflictingOptionError extends FlagsError {
|
|
15
|
+
constructor(option, options) {
|
|
16
|
+
super(`Unknown conflicting option "${getFlag(option)}".${didYouMeanOption(option, options)}`);
|
|
17
|
+
Object.setPrototypeOf(this, UnknownConflictingOptionError.prototype);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class UnknownTypeError extends FlagsError {
|
|
21
|
+
constructor(type, types) {
|
|
22
|
+
super(`Unknown type "${type}".${didYouMeanType(type, types)}`);
|
|
23
|
+
Object.setPrototypeOf(this, UnknownTypeError.prototype);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/* Validation errors. */
|
|
27
|
+
/**
|
|
28
|
+
* A validation error is thrown when the command is wrongly used by the user.
|
|
29
|
+
* For example: If the user passes some invalid options or arguments to the
|
|
30
|
+
* command.
|
|
31
|
+
*/
|
|
32
|
+
export class ValidationError extends FlagsError {
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class DuplicateOptionError extends ValidationError {
|
|
39
|
+
constructor(name) {
|
|
40
|
+
super(`Option "${getFlag(name).replace(/^--no-/, "--")}" can only occur once, but was found several times.`);
|
|
41
|
+
Object.setPrototypeOf(this, DuplicateOptionError.prototype);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class InvalidOptionError extends ValidationError {
|
|
45
|
+
constructor(option, options) {
|
|
46
|
+
super(`Invalid option "${getFlag(option)}".${didYouMeanOption(option, options)}`);
|
|
47
|
+
Object.setPrototypeOf(this, InvalidOptionError.prototype);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class UnknownOptionError extends ValidationError {
|
|
51
|
+
constructor(option, options) {
|
|
52
|
+
super(`Unknown option "${getFlag(option)}".${didYouMeanOption(option, options)}`);
|
|
53
|
+
Object.setPrototypeOf(this, UnknownOptionError.prototype);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class MissingOptionValueError extends ValidationError {
|
|
57
|
+
constructor(option) {
|
|
58
|
+
super(`Missing value for option "${getFlag(option)}".`);
|
|
59
|
+
Object.setPrototypeOf(this, MissingOptionValueError.prototype);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class InvalidOptionValueError extends ValidationError {
|
|
63
|
+
constructor(option, expected, value) {
|
|
64
|
+
super(`Option "${getFlag(option)}" must be of type "${expected}", but got "${value}".`);
|
|
65
|
+
Object.setPrototypeOf(this, InvalidOptionValueError.prototype);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class UnexpectedOptionValueError extends ValidationError {
|
|
69
|
+
constructor(option, value) {
|
|
70
|
+
super(`Option "${getFlag(option)}" doesn't take a value, but got "${value}".`);
|
|
71
|
+
Object.setPrototypeOf(this, InvalidOptionValueError.prototype);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export class OptionNotCombinableError extends ValidationError {
|
|
75
|
+
constructor(option) {
|
|
76
|
+
super(`Option "${getFlag(option)}" cannot be combined with other options.`);
|
|
77
|
+
Object.setPrototypeOf(this, OptionNotCombinableError.prototype);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export class ConflictingOptionError extends ValidationError {
|
|
81
|
+
constructor(option, conflictingOption) {
|
|
82
|
+
super(`Option "${getFlag(option)}" conflicts with option "${getFlag(conflictingOption)}".`);
|
|
83
|
+
Object.setPrototypeOf(this, ConflictingOptionError.prototype);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class DependingOptionError extends ValidationError {
|
|
87
|
+
constructor(option, dependingOption) {
|
|
88
|
+
super(`Option "${getFlag(option)}" depends on option "${getFlag(dependingOption)}".`);
|
|
89
|
+
Object.setPrototypeOf(this, DependingOptionError.prototype);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class MissingRequiredOptionError extends ValidationError {
|
|
93
|
+
constructor(option) {
|
|
94
|
+
super(`Missing required option "${getFlag(option)}".`);
|
|
95
|
+
Object.setPrototypeOf(this, MissingRequiredOptionError.prototype);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class UnexpectedRequiredArgumentError extends ValidationError {
|
|
99
|
+
constructor(arg) {
|
|
100
|
+
super(`An required argument cannot follow an optional argument, but "${arg}" is defined as required.`);
|
|
101
|
+
Object.setPrototypeOf(this, UnexpectedRequiredArgumentError.prototype);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class UnexpectedArgumentAfterVariadicArgumentError extends ValidationError {
|
|
105
|
+
constructor(arg) {
|
|
106
|
+
super(`An argument cannot follow an variadic argument, but got "${arg}".`);
|
|
107
|
+
Object.setPrototypeOf(this, UnexpectedArgumentAfterVariadicArgumentError.prototype);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export class InvalidTypeError extends ValidationError {
|
|
111
|
+
constructor({ label, name, value, type }, expected) {
|
|
112
|
+
super(`${label} "${name}" must be of type "${type}", but got "${value}".` + (expected
|
|
113
|
+
? ` Expected values: ${expected.map((value) => `"${value}"`).join(", ")}`
|
|
114
|
+
: ""));
|
|
115
|
+
Object.setPrototypeOf(this, MissingOptionValueError.prototype);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FlagOptions } from "./types.js";
|
|
2
|
+
/** Convert param case string to camel case. */
|
|
3
|
+
export declare function paramCaseToCamelCase(str: string): string;
|
|
4
|
+
/** Convert underscore case string to camel case. */
|
|
5
|
+
export declare function underscoreToCamelCase(str: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Find option by flag, name or alias.
|
|
8
|
+
*
|
|
9
|
+
* @param flags Source options array.
|
|
10
|
+
* @param name Name of the option.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getOption<O extends FlagOptions>(flags: Array<O>, name: string): O | undefined;
|
|
13
|
+
export declare function didYouMeanOption(option: string, options: Array<FlagOptions>): string;
|
|
14
|
+
export declare function didYouMeanType(type: string, types: Array<string>): string;
|
|
15
|
+
export declare function didYouMean(message: string, type: string, types: Array<string>): string;
|
|
16
|
+
export declare function getFlag(name: string): string;
|
|
17
|
+
export declare function matchWildCardOptions(name: string, flags: Array<FlagOptions>): FlagOptions | undefined;
|
|
18
|
+
export declare function getDefaultValue(option: FlagOptions): unknown;
|