1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
diff --git a/cli/commands/upgrade.ts b/cli/commands/upgrade.ts
deleted file mode 100644
index 279f073..0000000
--- a/cli/commands/upgrade.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import {
- Provider,
- UpgradeCommand,
- UpgradeOptions,
-} from "https://deno.land/x/cliffy@v0.25.7/command/upgrade/mod.ts";
-import { Versions } from "https://deno.land/x/cliffy@v0.25.7/command/upgrade/provider.ts";
-
-const UPGRADE_URL = "https://fabricmc.net/cli";
-const COMMAND_NAME = "fabric";
-
-export function upgradeCommand() {
- const command = new UpgradeCommand({
- provider: new UpdateProvider(),
- })
- .description("Upgrade Fabric CLI tools executable to latest version");
-
- command.removeOption("--version");
- command.removeOption("--force");
- command.removeOption("--list-versions");
- return command;
-}
-
-class UpdateProvider extends Provider {
- name = COMMAND_NAME;
-
- // Code edited from the default Provider
- override async upgrade(
- {}: UpgradeOptions,
- ): Promise<void> {
- const args = [
- "install",
- "--force",
- "--reload",
- "--quiet",
- "--global",
- "-A",
- "--name",
- COMMAND_NAME,
- UPGRADE_URL,
- ];
-
- const command = new Deno.Command(Deno.execPath(), {
- args,
- });
-
- const { success, stderr } = await command.output();
-
- if (!success) {
- await Deno.stderr.write(stderr);
- throw new Error(
- `Failed to upgrade ${COMMAND_NAME}!`,
- );
- }
-
- console.info(
- `Successfully upgraded!`,
- );
- }
-
- override getVersions(_: string): Promise<Versions> {
- return Promise.resolve({
- latest: "latest",
- versions: ["latest"],
- });
- }
-
- override getRepositoryUrl(_: string): string {
- throw new Error("Method not implemented.");
- }
-
- override getRegistryUrl(_: string, __: string): string {
- throw new Error("Method not implemented.");
- }
-
- override isOutdated(
- _: string,
- __: string,
- ___: string,
- ): Promise<boolean> {
- return Promise.resolve(true);
- }
-}
diff --git a/cli/main.ts b/cli/main.ts
index 616788c..641aadb 100755
--- a/cli/main.ts
+++ b/cli/main.ts
@@ -7,7 +7,6 @@ import {
CompletionsCommand,
} from "https://deno.land/x/cliffy@v0.25.7/command/mod.ts";
import { initCommand } from "./commands/init.ts";
-import { upgradeCommand } from "./commands/upgrade.ts";
// Replaced by esbuild.
declare let __VERSION__: string;
@@ -24,7 +23,6 @@ if (import.meta.main) {
Deno.exit(0);
})
.command("init", initCommand())
- .command("upgrade", upgradeCommand())
.command("completions", new CompletionsCommand());
await cmd.parse();
|