UNPKG

5.14 kBTypeScriptView Raw
1import { MinecraftFolder, MinecraftLocation, Version as VersionJson } from "@xmcl/core";
2import { AbortableTask } from "@xmcl/task";
3import { InstallSideOption, LibraryOptions } from "./minecraft";
4import { SpawnJavaOptions } from "./utils";
5export interface PostProcessor {
6 /**
7 * The executable jar path
8 */
9 jar: string;
10 /**
11 * The classpath to run
12 */
13 classpath: string[];
14 args: string[];
15 outputs?: {
16 [key: string]: string;
17 };
18 sides?: Array<"client" | "server">;
19}
20export interface InstallProfile {
21 spec?: number;
22 /**
23 * The type of this installation, like "forge"
24 */
25 profile: string;
26 /**
27 * The version of this installation
28 */
29 version: string;
30 /**
31 * The version json path
32 */
33 json: string;
34 /**
35 * The maven artifact name: <org>:<artifact-id>:<version>
36 */
37 path: string;
38 /**
39 * The minecraft version
40 */
41 minecraft: string;
42 /**
43 * The processor shared variables. The key is the name of variable to replace.
44 *
45 * The value of client/server is the value of the variable.
46 */
47 data?: {
48 [key: string]: {
49 client: string;
50 server: string;
51 };
52 };
53 /**
54 * The post processor. Which require java to run.
55 */
56 processors?: Array<PostProcessor>;
57 /**
58 * The required install profile libraries
59 */
60 libraries: VersionJson.NormalLibrary[];
61 /**
62 * Legacy format
63 */
64 versionInfo?: VersionJson;
65}
66export interface InstallProfileOption extends LibraryOptions, InstallSideOption, SpawnJavaOptions {
67 /**
68 * New forge (>=1.13) require java to install. Can be a executor or java executable path.
69 */
70 java?: string;
71}
72/**
73 * Resolve processors in install profile
74 */
75export declare function resolveProcessors(side: "client" | "server", installProfile: InstallProfile, minecraft: MinecraftFolder): {
76 args: string[];
77 outputs: {
78 [x: string]: string;
79 } | undefined;
80 /**
81 * The executable jar path
82 */
83 jar: string;
84 /**
85 * The classpath to run
86 */
87 classpath: string[];
88 sides?: ("client" | "server")[] | undefined;
89}[];
90/**
91 * Post process the post processors from `InstallProfile`.
92 *
93 * @param processors The processor info
94 * @param minecraft The minecraft location
95 * @param java The java executable path
96 * @throws {@link PostProcessError}
97 */
98export declare function postProcess(processors: PostProcessor[], minecraft: MinecraftFolder, javaOptions: SpawnJavaOptions): Promise<void>;
99/**
100 * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies.
101 *
102 * @param installProfile The install profile
103 * @param minecraft The minecraft location
104 * @param options The options to install
105 * @throws {@link PostProcessError}
106 */
107export declare function installByProfile(installProfile: InstallProfile, minecraft: MinecraftLocation, options?: InstallProfileOption): Promise<void>;
108/**
109 * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies.
110 *
111 * @param installProfile The install profile
112 * @param minecraft The minecraft location
113 * @param options The options to install
114 */
115export declare function installByProfileTask(installProfile: InstallProfile, minecraft: MinecraftLocation, options?: InstallProfileOption): import("@xmcl/task").TaskRoutine<void>;
116export declare class PostProcessBadJarError extends Error {
117 jarPath: string;
118 causeBy: Error;
119 constructor(jarPath: string, causeBy: Error);
120 error: string;
121}
122export declare class PostProcessNoMainClassError extends Error {
123 jarPath: string;
124 constructor(jarPath: string);
125 error: string;
126}
127export declare class PostProcessFailedError extends Error {
128 jarPath: string;
129 commands: string[];
130 constructor(jarPath: string, commands: string[], message: string);
131 error: string;
132}
133/**
134 * Post process the post processors from `InstallProfile`.
135 *
136 * @param processors The processor info
137 * @param minecraft The minecraft location
138 * @param java The java executable path
139 * @throws {@link PostProcessError}
140 */
141export declare class PostProcessingTask extends AbortableTask<void> {
142 private processors;
143 private minecraft;
144 private java;
145 readonly name: string;
146 private pointer;
147 private activeProcess;
148 constructor(processors: PostProcessor[], minecraft: MinecraftFolder, java: SpawnJavaOptions);
149 protected findMainClass(lib: string): Promise<string>;
150 protected isInvalid(outputs: Required<PostProcessor>["outputs"]): Promise<boolean>;
151 protected postProcess(mc: MinecraftFolder, proc: PostProcessor, javaOptions: SpawnJavaOptions): Promise<void>;
152 protected process(): Promise<void>;
153 protected abort(isCancelled: boolean): Promise<void>;
154 protected isAbortedError(e: any): boolean;
155}
156//# sourceMappingURL=profile.d.ts.map
\No newline at end of file