@kzheart_/mc-pilot 0.8.1 → 0.9.1
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/data/variants.json +12 -12
- package/dist/commands/chat.js +3 -3
- package/dist/commands/client.d.ts +1 -1
- package/dist/commands/client.js +4 -4
- package/dist/commands/gui.js +8 -3
- package/dist/commands/plugin.js +3 -3
- package/dist/commands/project.js +22 -30
- package/dist/commands/request-helpers.d.ts +2 -0
- package/dist/commands/request-helpers.js +18 -0
- package/dist/commands/screenshot.js +10 -7
- package/dist/commands/server.js +7 -7
- package/dist/download/VersionMatrix.js +14 -14
- package/dist/download/client/ClientDownloader.js +1 -1
- package/dist/index.js +3 -0
- package/dist/instance/ClientInstanceManager.d.ts +1 -0
- package/dist/instance/ClientInstanceManager.js +105 -98
- package/dist/instance/ServerInstanceManager.d.ts +5 -0
- package/dist/instance/ServerInstanceManager.js +85 -3
- package/dist/util/command-log.d.ts +12 -0
- package/dist/util/command-log.js +13 -0
- package/dist/util/command.js +2 -2
- package/dist/util/context.d.ts +3 -0
- package/dist/util/context.js +10 -3
- package/dist/util/global-state.d.ts +4 -0
- package/dist/util/global-state.js +22 -0
- package/dist/util/net.d.ts +1 -0
- package/dist/util/net.js +14 -12
- package/dist/util/paths.d.ts +2 -0
- package/dist/util/paths.js +6 -0
- package/dist/util/project.d.ts +16 -4
- package/dist/util/project.js +63 -8
- package/dist/util/state.d.ts +5 -0
- package/dist/util/state.js +81 -2
- package/package.json +1 -1
- package/scripts/launch-fabric-client.mjs +13 -5
package/data/variants.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"loader": "fabric",
|
|
10
10
|
"support": "ready",
|
|
11
11
|
"validation": "verified",
|
|
12
|
-
"modVersion": "0.
|
|
12
|
+
"modVersion": "0.9.1",
|
|
13
13
|
"fabricLoaderVersion": "0.16.14",
|
|
14
14
|
"yarnMappings": "1.18.2+build.4",
|
|
15
15
|
"javaVersion": 17,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"loader": "fabric",
|
|
22
22
|
"support": "ready",
|
|
23
23
|
"validation": "verified",
|
|
24
|
-
"modVersion": "0.
|
|
24
|
+
"modVersion": "0.9.1",
|
|
25
25
|
"fabricLoaderVersion": "0.16.14",
|
|
26
26
|
"yarnMappings": "1.20.1+build.10",
|
|
27
27
|
"javaVersion": 17,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"loader": "forge",
|
|
34
34
|
"support": "planned",
|
|
35
35
|
"validation": "planned",
|
|
36
|
-
"modVersion": "0.
|
|
36
|
+
"modVersion": "0.9.1",
|
|
37
37
|
"forgeVersion": "47.3.0",
|
|
38
38
|
"javaVersion": 17
|
|
39
39
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"loader": "fabric",
|
|
44
44
|
"support": "ready",
|
|
45
45
|
"validation": "verified",
|
|
46
|
-
"modVersion": "0.
|
|
46
|
+
"modVersion": "0.9.1",
|
|
47
47
|
"fabricLoaderVersion": "0.16.14",
|
|
48
48
|
"yarnMappings": "1.20.2+build.4",
|
|
49
49
|
"javaVersion": 17,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"loader": "forge",
|
|
56
56
|
"support": "planned",
|
|
57
57
|
"validation": "planned",
|
|
58
|
-
"modVersion": "0.
|
|
58
|
+
"modVersion": "0.9.1",
|
|
59
59
|
"forgeVersion": "48.1.0",
|
|
60
60
|
"javaVersion": 17
|
|
61
61
|
},
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"loader": "fabric",
|
|
66
66
|
"support": "ready",
|
|
67
67
|
"validation": "verified",
|
|
68
|
-
"modVersion": "0.
|
|
68
|
+
"modVersion": "0.9.1",
|
|
69
69
|
"fabricLoaderVersion": "0.16.14",
|
|
70
70
|
"yarnMappings": "1.20.4+build.3",
|
|
71
71
|
"javaVersion": 17,
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"loader": "forge",
|
|
78
78
|
"support": "planned",
|
|
79
79
|
"validation": "planned",
|
|
80
|
-
"modVersion": "0.
|
|
80
|
+
"modVersion": "0.9.1",
|
|
81
81
|
"forgeVersion": "49.0.49",
|
|
82
82
|
"javaVersion": 17
|
|
83
83
|
},
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"loader": "neoforge",
|
|
88
88
|
"support": "planned",
|
|
89
89
|
"validation": "planned",
|
|
90
|
-
"modVersion": "0.
|
|
90
|
+
"modVersion": "0.9.1",
|
|
91
91
|
"neoforgeVersion": "20.4.237",
|
|
92
92
|
"javaVersion": 17
|
|
93
93
|
},
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"loader": "fabric",
|
|
98
98
|
"support": "ready",
|
|
99
99
|
"validation": "verified",
|
|
100
|
-
"modVersion": "0.
|
|
100
|
+
"modVersion": "0.9.1",
|
|
101
101
|
"fabricLoaderVersion": "0.16.14",
|
|
102
102
|
"yarnMappings": "1.21.1+build.3",
|
|
103
103
|
"javaVersion": 21,
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"loader": "neoforge",
|
|
110
110
|
"support": "planned",
|
|
111
111
|
"validation": "planned",
|
|
112
|
-
"modVersion": "0.
|
|
112
|
+
"modVersion": "0.9.1",
|
|
113
113
|
"neoforgeVersion": "21.1.77",
|
|
114
114
|
"javaVersion": 21
|
|
115
115
|
},
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"loader": "fabric",
|
|
120
120
|
"support": "ready",
|
|
121
121
|
"validation": "verified",
|
|
122
|
-
"modVersion": "0.
|
|
122
|
+
"modVersion": "0.9.1",
|
|
123
123
|
"fabricLoaderVersion": "0.16.14",
|
|
124
124
|
"yarnMappings": "1.21.4+build.1",
|
|
125
125
|
"javaVersion": 21,
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"loader": "neoforge",
|
|
132
132
|
"support": "planned",
|
|
133
133
|
"validation": "planned",
|
|
134
|
-
"modVersion": "0.
|
|
134
|
+
"modVersion": "0.9.1",
|
|
135
135
|
"neoforgeVersion": "21.4.75",
|
|
136
136
|
"javaVersion": 21
|
|
137
137
|
}
|
package/dist/commands/chat.js
CHANGED
|
@@ -11,7 +11,7 @@ function normalizeChatCommand(text) {
|
|
|
11
11
|
return command;
|
|
12
12
|
}
|
|
13
13
|
async function executeServerCommand(context, serverName, command) {
|
|
14
|
-
const manager = new ServerInstanceManager(context.globalState, context.
|
|
14
|
+
const manager = new ServerInstanceManager(context.globalState, context.projectId);
|
|
15
15
|
const result = await manager.exec(serverName, command);
|
|
16
16
|
return {
|
|
17
17
|
...result,
|
|
@@ -50,7 +50,7 @@ export function createChatCommand() {
|
|
|
50
50
|
if (preferredClient) {
|
|
51
51
|
return sendClientRequest(context, preferredClient, "chat.command", { command: commandText });
|
|
52
52
|
}
|
|
53
|
-
if (!context.
|
|
53
|
+
if (!context.projectId) {
|
|
54
54
|
return sendClientRequest(context, undefined, "chat.command", { command: commandText });
|
|
55
55
|
}
|
|
56
56
|
const serverName = options.server ?? context.activeProfile?.server;
|
|
@@ -65,7 +65,7 @@ export function createChatCommand() {
|
|
|
65
65
|
if (via !== "server") {
|
|
66
66
|
throw new MctError({ code: "INVALID_PARAMS", message: `--via must be \"auto\", \"server\" or \"client\", got: ${via}` }, 4);
|
|
67
67
|
}
|
|
68
|
-
if (!context.
|
|
68
|
+
if (!context.projectId) {
|
|
69
69
|
throw new MctError({ code: "NO_PROJECT", message: "--via server requires a project context. Use --via client or run inside an mct project." }, 4);
|
|
70
70
|
}
|
|
71
71
|
const serverName = options.server ?? context.activeProfile?.server;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import type { CommandContext } from "../util/context.js";
|
|
3
|
-
export declare function resolveProfileServerAddress(context: Pick<CommandContext, "
|
|
3
|
+
export declare function resolveProfileServerAddress(context: Pick<CommandContext, "projectId" | "activeProfile" | "globalState">, explicitServer: string | undefined, loadPort?: (projectId: string, serverName: string) => Promise<number>): Promise<string | undefined>;
|
|
4
4
|
export declare function createClientCommand(): Command;
|
package/dist/commands/client.js
CHANGED
|
@@ -17,13 +17,13 @@ export async function resolveProfileServerAddress(context, explicitServer, loadP
|
|
|
17
17
|
if (explicitServer) {
|
|
18
18
|
return explicitServer;
|
|
19
19
|
}
|
|
20
|
-
if (!context.
|
|
20
|
+
if (!context.projectId || !context.activeProfile?.server) {
|
|
21
21
|
return undefined;
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
24
|
const port = loadPort
|
|
25
|
-
? await loadPort(context.
|
|
26
|
-
: (await new ServerInstanceManager(context.globalState, context.
|
|
25
|
+
? await loadPort(context.projectId, context.activeProfile.server)
|
|
26
|
+
: (await new ServerInstanceManager(context.globalState, context.projectId).loadMeta(context.activeProfile.server)).port;
|
|
27
27
|
return `127.0.0.1:${port}`;
|
|
28
28
|
}
|
|
29
29
|
catch {
|
|
@@ -91,7 +91,7 @@ export function createClientCommand() {
|
|
|
91
91
|
sourcePath = cacheArtifactPath;
|
|
92
92
|
}
|
|
93
93
|
catch {
|
|
94
|
-
const modVersion = variant.modVersion ?? "0.1
|
|
94
|
+
const modVersion = variant.modVersion ?? "0.9.1";
|
|
95
95
|
const baseUrl = process.env.MCT_MOD_DOWNLOAD_BASE_URL || "https://github.com/kzheart/mc-pilot/releases/download";
|
|
96
96
|
const downloadUrl = `${baseUrl}/v${modVersion}/${artifactFileName}`;
|
|
97
97
|
await downloadFile(downloadUrl, cacheArtifactPath, fetch);
|
package/dist/commands/gui.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { wrapCommand } from "../util/command.js";
|
|
3
|
+
import { createRequestAction, parseNumberList, resolveScreenshotOutputPath, sendClientRequest, withTransportTimeoutBuffer } from "./request-helpers.js";
|
|
3
4
|
export function createGuiCommand() {
|
|
4
5
|
const command = new Command("gui").description("GUI / container interaction (use \"gui snapshot\" to inspect slot indices and contents)");
|
|
5
6
|
command.command("info").description("Get current GUI info (title, type, slot count)").action(createRequestAction("gui.info", () => ({})));
|
|
@@ -43,7 +44,11 @@ export function createGuiCommand() {
|
|
|
43
44
|
command
|
|
44
45
|
.command("screenshot")
|
|
45
46
|
.description("Take a screenshot of the current GUI")
|
|
46
|
-
.
|
|
47
|
-
.action(
|
|
47
|
+
.option("--output <path>", "Output file path (default: project screenshot directory)")
|
|
48
|
+
.action(wrapCommand(async (context, { options, globalOptions }) => {
|
|
49
|
+
return sendClientRequest(context, globalOptions.client ?? context.activeProfile?.clients[0], "gui.screenshot", {
|
|
50
|
+
output: resolveScreenshotOutputPath(context, options.output, "gui")
|
|
51
|
+
});
|
|
52
|
+
}));
|
|
48
53
|
return command;
|
|
49
54
|
}
|
package/dist/commands/plugin.js
CHANGED
|
@@ -69,11 +69,11 @@ export function createPluginCommand() {
|
|
|
69
69
|
.description("Install a plugin (with dependencies) to a server")
|
|
70
70
|
.argument("<id>", "Plugin ID")
|
|
71
71
|
.requiredOption("--server <name>", "Target server instance name")
|
|
72
|
-
.option("--project <
|
|
72
|
+
.option("--project <id>", "Project ID")
|
|
73
73
|
.action(wrapCommand(async (context, { args, options }) => {
|
|
74
|
-
const project = options.project ?? context.
|
|
74
|
+
const project = options.project ?? context.projectId;
|
|
75
75
|
if (!project) {
|
|
76
|
-
throw new MctError({ code: "NO_PROJECT", message: "No project specified. Use --project or run from a project directory." }, 4);
|
|
76
|
+
throw new MctError({ code: "NO_PROJECT", message: "No project specified. Use --project <id> or run from a project directory." }, 4);
|
|
77
77
|
}
|
|
78
78
|
const manager = new PluginCatalogManager();
|
|
79
79
|
return manager.install(args[0], project, options.server);
|
package/dist/commands/project.js
CHANGED
|
@@ -4,34 +4,26 @@ import { ServerInstanceManager } from "../instance/ServerInstanceManager.js";
|
|
|
4
4
|
import { ClientInstanceManager } from "../instance/ClientInstanceManager.js";
|
|
5
5
|
import { MctError } from "../util/errors.js";
|
|
6
6
|
import { wrapCommand } from "../util/command.js";
|
|
7
|
-
import {
|
|
7
|
+
import { createDefaultProjectFile, loadProjectFileForCwd, resolveProjectFilePath, resolveProfile, writeProjectFile, } from "../util/project.js";
|
|
8
8
|
export function createInitCommand() {
|
|
9
9
|
return new Command("init")
|
|
10
|
-
.description("Initialize a new MC Pilot project
|
|
10
|
+
.description("Initialize a new MC Pilot project for the current directory")
|
|
11
11
|
.option("--name <name>", "Project name (default: directory name)")
|
|
12
12
|
.action(wrapCommand(async (context, { options }) => {
|
|
13
|
-
const existing = await
|
|
13
|
+
const existing = await loadProjectFileForCwd(context.cwd);
|
|
14
14
|
if (existing) {
|
|
15
|
-
throw new MctError({ code: "PROJECT_EXISTS", message:
|
|
15
|
+
throw new MctError({ code: "PROJECT_EXISTS", message: `Project config already exists for this directory: ${existing.filePath}` }, 4);
|
|
16
16
|
}
|
|
17
17
|
const projectName = options.name ?? path.basename(context.cwd);
|
|
18
|
-
const project =
|
|
19
|
-
|
|
20
|
-
profiles: {},
|
|
21
|
-
screenshot: {
|
|
22
|
-
outputDir: "./screenshots"
|
|
23
|
-
},
|
|
24
|
-
timeout: {
|
|
25
|
-
serverReady: 120,
|
|
26
|
-
clientReady: 60,
|
|
27
|
-
default: 10
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
await writeProjectFile(context.cwd, project);
|
|
18
|
+
const project = createDefaultProjectFile(context.cwd, projectName);
|
|
19
|
+
await writeProjectFile(project.projectId, project);
|
|
31
20
|
return {
|
|
32
21
|
created: true,
|
|
22
|
+
projectId: project.projectId,
|
|
33
23
|
project: projectName,
|
|
34
|
-
|
|
24
|
+
rootDir: project.rootDir,
|
|
25
|
+
file: resolveProjectFilePath(project.projectId),
|
|
26
|
+
configPath: resolveProjectFilePath(project.projectId)
|
|
35
27
|
};
|
|
36
28
|
}));
|
|
37
29
|
}
|
|
@@ -40,8 +32,8 @@ export function createDeployCommand() {
|
|
|
40
32
|
.description("Deploy plugin JARs to the server instance")
|
|
41
33
|
.option("--profile <name>", "Profile name")
|
|
42
34
|
.action(wrapCommand(async (context, { options }) => {
|
|
43
|
-
const { projectFile,
|
|
44
|
-
if (!projectFile || !
|
|
35
|
+
const { projectFile, projectId, projectRootDir } = context;
|
|
36
|
+
if (!projectFile || !projectId || !projectRootDir) {
|
|
45
37
|
throw new MctError({ code: "NO_PROJECT", message: "No project context. Run 'mct init' first." }, 4);
|
|
46
38
|
}
|
|
47
39
|
const profile = resolveProfile(projectFile, options.profile ?? projectFile.defaultProfile);
|
|
@@ -51,8 +43,8 @@ export function createDeployCommand() {
|
|
|
51
43
|
if (!profile.deployPlugins || profile.deployPlugins.length === 0) {
|
|
52
44
|
return { deployed: [], message: "No deployPlugins configured in profile" };
|
|
53
45
|
}
|
|
54
|
-
const manager = new ServerInstanceManager(context.globalState,
|
|
55
|
-
const deployed = await manager.deploy(profile.server, profile.deployPlugins,
|
|
46
|
+
const manager = new ServerInstanceManager(context.globalState, projectId);
|
|
47
|
+
const deployed = await manager.deploy(profile.server, profile.deployPlugins, projectRootDir);
|
|
56
48
|
return { deployed, server: profile.server };
|
|
57
49
|
}));
|
|
58
50
|
}
|
|
@@ -62,20 +54,20 @@ export function createUpCommand() {
|
|
|
62
54
|
.option("--profile <name>", "Profile name")
|
|
63
55
|
.option("--eula", "Auto-accept EULA")
|
|
64
56
|
.action(wrapCommand(async (context, { options }) => {
|
|
65
|
-
const { projectFile,
|
|
66
|
-
if (!projectFile || !
|
|
57
|
+
const { projectFile, projectId, projectRootDir } = context;
|
|
58
|
+
if (!projectFile || !projectId || !projectRootDir) {
|
|
67
59
|
throw new MctError({ code: "NO_PROJECT", message: "No project context. Run 'mct init' first." }, 4);
|
|
68
60
|
}
|
|
69
61
|
const profile = resolveProfile(projectFile, options.profile ?? projectFile.defaultProfile);
|
|
70
62
|
if (!profile) {
|
|
71
63
|
throw new MctError({ code: "NO_PROFILE", message: "No profile specified and no defaultProfile set" }, 4);
|
|
72
64
|
}
|
|
73
|
-
const serverManager = new ServerInstanceManager(context.globalState,
|
|
65
|
+
const serverManager = new ServerInstanceManager(context.globalState, projectId);
|
|
74
66
|
const clientManager = new ClientInstanceManager(context.globalState);
|
|
75
67
|
const results = {};
|
|
76
68
|
// 1. Deploy plugins
|
|
77
69
|
if (profile.deployPlugins && profile.deployPlugins.length > 0) {
|
|
78
|
-
results.deployed = await serverManager.deploy(profile.server, profile.deployPlugins,
|
|
70
|
+
results.deployed = await serverManager.deploy(profile.server, profile.deployPlugins, projectRootDir);
|
|
79
71
|
}
|
|
80
72
|
// 2. Start server
|
|
81
73
|
results.server = await serverManager.start(profile.server, { eula: options.eula });
|
|
@@ -109,15 +101,15 @@ export function createDownCommand() {
|
|
|
109
101
|
.description("Stop server and clients for the active profile")
|
|
110
102
|
.option("--profile <name>", "Profile name")
|
|
111
103
|
.action(wrapCommand(async (context, { options }) => {
|
|
112
|
-
const { projectFile,
|
|
113
|
-
if (!projectFile || !
|
|
104
|
+
const { projectFile, projectId } = context;
|
|
105
|
+
if (!projectFile || !projectId) {
|
|
114
106
|
throw new MctError({ code: "NO_PROJECT", message: "No project context. Run 'mct init' first." }, 4);
|
|
115
107
|
}
|
|
116
108
|
const profile = resolveProfile(projectFile, options.profile ?? projectFile.defaultProfile);
|
|
117
109
|
if (!profile) {
|
|
118
110
|
throw new MctError({ code: "NO_PROFILE", message: "No profile specified and no defaultProfile set" }, 4);
|
|
119
111
|
}
|
|
120
|
-
const serverManager = new ServerInstanceManager(context.globalState,
|
|
112
|
+
const serverManager = new ServerInstanceManager(context.globalState, projectId);
|
|
121
113
|
const clientManager = new ClientInstanceManager(context.globalState);
|
|
122
114
|
const results = {};
|
|
123
115
|
// Stop clients first
|
|
@@ -155,7 +147,7 @@ export function createUseCommand() {
|
|
|
155
147
|
}, 4);
|
|
156
148
|
}
|
|
157
149
|
projectFile.defaultProfile = profileName;
|
|
158
|
-
await writeProjectFile(
|
|
150
|
+
await writeProjectFile(projectFile.projectId, projectFile);
|
|
159
151
|
return {
|
|
160
152
|
defaultProfile: profileName,
|
|
161
153
|
profile: projectFile.profiles[profileName]
|
|
@@ -7,6 +7,8 @@ export interface RequestPayload<TOptions> {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function sendClientRequest(context: CommandContext, clientName: string | undefined, action: string, params: Record<string, unknown>, timeoutSeconds?: number): Promise<unknown>;
|
|
9
9
|
export declare function resolvePreferredClientName(context: CommandContext, globalOptions: GlobalOptions): string | undefined;
|
|
10
|
+
export declare function resolveProjectRelativePath(context: CommandContext, targetPath: string): string;
|
|
11
|
+
export declare function resolveScreenshotOutputPath(context: CommandContext, output: string | undefined, prefix: "screenshot" | "gui"): string;
|
|
10
12
|
export declare function createRequestAction<TOptions = Record<string, any>>(action: string, buildParams: (payload: RequestPayload<TOptions>) => Record<string, unknown>, timeoutSelector?: (payload: RequestPayload<TOptions>, context: CommandContext) => number | undefined): (this: Command, ...input: unknown[]) => Promise<void>;
|
|
11
13
|
export declare function parseJson(text: string, fieldName: string): Record<string, unknown>;
|
|
12
14
|
export declare function parseNumberList(text: string): number[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { ClientInstanceManager } from "../instance/ClientInstanceManager.js";
|
|
3
4
|
import { WebSocketClient } from "../client/WebSocketClient.js";
|
|
4
5
|
import { MctError } from "../util/errors.js";
|
|
@@ -12,6 +13,23 @@ export async function sendClientRequest(context, clientName, action, params, tim
|
|
|
12
13
|
export function resolvePreferredClientName(context, globalOptions) {
|
|
13
14
|
return globalOptions.client ?? context.activeProfile?.clients[0];
|
|
14
15
|
}
|
|
16
|
+
export function resolveProjectRelativePath(context, targetPath) {
|
|
17
|
+
if (path.isAbsolute(targetPath)) {
|
|
18
|
+
return targetPath;
|
|
19
|
+
}
|
|
20
|
+
return path.resolve(context.projectRootDir ?? context.cwd, targetPath);
|
|
21
|
+
}
|
|
22
|
+
export function resolveScreenshotOutputPath(context, output, prefix) {
|
|
23
|
+
if (output) {
|
|
24
|
+
return resolveProjectRelativePath(context, output);
|
|
25
|
+
}
|
|
26
|
+
const outputDir = context.projectFile?.screenshot?.outputDir;
|
|
27
|
+
if (!outputDir) {
|
|
28
|
+
throw new MctError({ code: "INVALID_PARAMS", message: "--output is required outside a project context." }, 4);
|
|
29
|
+
}
|
|
30
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
31
|
+
return path.join(outputDir, `${prefix}-${timestamp}.png`);
|
|
32
|
+
}
|
|
15
33
|
export function createRequestAction(action, buildParams, timeoutSelector) {
|
|
16
34
|
return wrapCommand(async (context, payload) => {
|
|
17
35
|
const timeout = timeoutSelector?.(payload, context);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { wrapCommand } from "../util/command.js";
|
|
3
|
+
import { resolveScreenshotOutputPath, sendClientRequest } from "./request-helpers.js";
|
|
3
4
|
export function createScreenshotCommand() {
|
|
4
5
|
return new Command("screenshot")
|
|
5
6
|
.description("Take a screenshot")
|
|
6
|
-
.
|
|
7
|
+
.option("--output <path>", "Output file path (default: project screenshot directory)")
|
|
7
8
|
.option("--region <region>", "Capture a sub-region, format: x,y,w,h")
|
|
8
9
|
.option("--gui", "Capture the current GUI screen")
|
|
9
|
-
.action(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
.action(wrapCommand(async (context, { options, globalOptions }) => {
|
|
11
|
+
return sendClientRequest(context, globalOptions.client ?? context.activeProfile?.clients[0], "capture.screenshot", {
|
|
12
|
+
output: resolveScreenshotOutputPath(context, options.output, "screenshot"),
|
|
13
|
+
region: options.region,
|
|
14
|
+
gui: Boolean(options.gui)
|
|
15
|
+
});
|
|
16
|
+
}));
|
|
14
17
|
}
|
package/dist/commands/server.js
CHANGED
|
@@ -5,10 +5,10 @@ import { ServerInstanceManager } from "../instance/ServerInstanceManager.js";
|
|
|
5
5
|
import { MctError } from "../util/errors.js";
|
|
6
6
|
import { wrapCommand } from "../util/command.js";
|
|
7
7
|
function requireProject(context) {
|
|
8
|
-
if (!context.
|
|
9
|
-
throw new MctError({ code: "NO_PROJECT", message: "No project context. Run 'mct init' first or use --project <
|
|
8
|
+
if (!context.projectId) {
|
|
9
|
+
throw new MctError({ code: "NO_PROJECT", message: "No project context. Run 'mct init' first or use --project <id>" }, 4);
|
|
10
10
|
}
|
|
11
|
-
return context.
|
|
11
|
+
return context.projectId;
|
|
12
12
|
}
|
|
13
13
|
function resolveServerName(context, explicit) {
|
|
14
14
|
if (explicit)
|
|
@@ -90,13 +90,13 @@ export function createServerCommand() {
|
|
|
90
90
|
.argument("[name]", "Server instance name (omit to show all in project)")
|
|
91
91
|
.option("--all", "Show running servers across all projects")
|
|
92
92
|
.action(wrapCommand(async (context, { args, options }) => {
|
|
93
|
-
if (options.all || (!context.
|
|
93
|
+
if (options.all || (!context.projectId && !args[0])) {
|
|
94
94
|
return ServerInstanceManager.statusAll(context.globalState);
|
|
95
95
|
}
|
|
96
|
-
if (!context.
|
|
97
|
-
throw new MctError({ code: "NO_PROJECT", message: "No project context. Omit the name to inspect all running servers, or use --project <
|
|
96
|
+
if (!context.projectId) {
|
|
97
|
+
throw new MctError({ code: "NO_PROJECT", message: "No project context. Omit the name to inspect all running servers, or use --project <id>." }, 4);
|
|
98
98
|
}
|
|
99
|
-
const manager = new ServerInstanceManager(context.globalState, context.
|
|
99
|
+
const manager = new ServerInstanceManager(context.globalState, context.projectId);
|
|
100
100
|
return manager.status(args[0]);
|
|
101
101
|
}));
|
|
102
102
|
command
|
|
@@ -10,9 +10,9 @@ const VERSION_MATRIX = [
|
|
|
10
10
|
spigot: { supported: true, requiresBuildTools: true }
|
|
11
11
|
},
|
|
12
12
|
clients: {
|
|
13
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
13
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1", validation: "verified" },
|
|
14
14
|
forge: { supported: false, notes: "不支持此版本" },
|
|
15
|
-
neoforge: { supported: true, loaderVersion: "21.4.x", modVersion: "0.
|
|
15
|
+
neoforge: { supported: true, loaderVersion: "21.4.x", modVersion: "0.9.1" }
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
{
|
|
@@ -25,9 +25,9 @@ const VERSION_MATRIX = [
|
|
|
25
25
|
spigot: { supported: true, requiresBuildTools: true }
|
|
26
26
|
},
|
|
27
27
|
clients: {
|
|
28
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
28
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1", validation: "verified" },
|
|
29
29
|
forge: { supported: false, notes: "不支持此版本" },
|
|
30
|
-
neoforge: { supported: true, loaderVersion: "21.1.x", modVersion: "0.
|
|
30
|
+
neoforge: { supported: true, loaderVersion: "21.1.x", modVersion: "0.9.1" }
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
{
|
|
@@ -40,8 +40,8 @@ const VERSION_MATRIX = [
|
|
|
40
40
|
spigot: { supported: true, requiresBuildTools: true }
|
|
41
41
|
},
|
|
42
42
|
clients: {
|
|
43
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
44
|
-
forge: { supported: true, loaderVersion: "49.0.49", modVersion: "0.
|
|
43
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1" },
|
|
44
|
+
forge: { supported: true, loaderVersion: "49.0.49", modVersion: "0.9.1" },
|
|
45
45
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
46
46
|
}
|
|
47
47
|
},
|
|
@@ -55,7 +55,7 @@ const VERSION_MATRIX = [
|
|
|
55
55
|
spigot: { supported: true, requiresBuildTools: true }
|
|
56
56
|
},
|
|
57
57
|
clients: {
|
|
58
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
58
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1", validation: "verified" },
|
|
59
59
|
forge: { supported: false, notes: "当前未接入此 loader" },
|
|
60
60
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
61
61
|
}
|
|
@@ -70,7 +70,7 @@ const VERSION_MATRIX = [
|
|
|
70
70
|
spigot: { supported: true, requiresBuildTools: true }
|
|
71
71
|
},
|
|
72
72
|
clients: {
|
|
73
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
73
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1" },
|
|
74
74
|
forge: { supported: false, notes: "当前未接入此 loader" },
|
|
75
75
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
76
76
|
}
|
|
@@ -85,8 +85,8 @@ const VERSION_MATRIX = [
|
|
|
85
85
|
spigot: { supported: true, requiresBuildTools: true }
|
|
86
86
|
},
|
|
87
87
|
clients: {
|
|
88
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
89
|
-
forge: { supported: true, loaderVersion: "47.x", modVersion: "0.
|
|
88
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1" },
|
|
89
|
+
forge: { supported: true, loaderVersion: "47.x", modVersion: "0.9.1" },
|
|
90
90
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
91
91
|
}
|
|
92
92
|
},
|
|
@@ -100,8 +100,8 @@ const VERSION_MATRIX = [
|
|
|
100
100
|
spigot: { supported: true, requiresBuildTools: true }
|
|
101
101
|
},
|
|
102
102
|
clients: {
|
|
103
|
-
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.
|
|
104
|
-
forge: { supported: true, loaderVersion: "40.x", modVersion: "0.
|
|
103
|
+
fabric: { supported: true, loaderVersion: "0.16.14", modVersion: "0.9.1", validation: "verified" },
|
|
104
|
+
forge: { supported: true, loaderVersion: "40.x", modVersion: "0.9.1" },
|
|
105
105
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
106
106
|
}
|
|
107
107
|
},
|
|
@@ -116,7 +116,7 @@ const VERSION_MATRIX = [
|
|
|
116
116
|
},
|
|
117
117
|
clients: {
|
|
118
118
|
fabric: { supported: false, notes: "当前未接入此版本 mod" },
|
|
119
|
-
forge: { supported: true, loaderVersion: "36.x", modVersion: "0.
|
|
119
|
+
forge: { supported: true, loaderVersion: "36.x", modVersion: "0.9.1" },
|
|
120
120
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
121
121
|
}
|
|
122
122
|
},
|
|
@@ -131,7 +131,7 @@ const VERSION_MATRIX = [
|
|
|
131
131
|
},
|
|
132
132
|
clients: {
|
|
133
133
|
fabric: { supported: false, notes: "不支持此版本" },
|
|
134
|
-
forge: { supported: true, loaderVersion: "14.23.x", modVersion: "0.
|
|
134
|
+
forge: { supported: true, loaderVersion: "14.23.x", modVersion: "0.9.1" },
|
|
135
135
|
neoforge: { supported: false, notes: "不支持此版本" }
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -51,7 +51,7 @@ export async function resolveArtifact(cwd, variant, cacheManager, fetchImpl = fe
|
|
|
51
51
|
}
|
|
52
52
|
catch { }
|
|
53
53
|
// 3. Download from GitHub Releases
|
|
54
|
-
const modVersion = variant.modVersion ?? "0.1
|
|
54
|
+
const modVersion = variant.modVersion ?? "0.9.1";
|
|
55
55
|
const releaseTag = `v${modVersion}`;
|
|
56
56
|
const downloadUrl = `${GITHUB_RELEASE_BASE_URL}/${releaseTag}/${artifactFileName}`;
|
|
57
57
|
try {
|
package/dist/index.js
CHANGED
|
@@ -53,7 +53,10 @@ export function buildProgram() {
|
|
|
53
53
|
.action(wrapCommand(async (context) => {
|
|
54
54
|
return {
|
|
55
55
|
cwd: context.cwd,
|
|
56
|
+
projectId: context.projectId,
|
|
56
57
|
project: context.projectName,
|
|
58
|
+
projectRootDir: context.projectRootDir,
|
|
59
|
+
projectConfigPath: context.projectConfigPath,
|
|
57
60
|
activeProfile: context.activeProfile,
|
|
58
61
|
globalStateDir: context.globalState.getRootDir()
|
|
59
62
|
};
|