Skip to content

Commit a034fba

Browse files
github-actions[bot]ci010
authored andcommitted
chore: bump version 2.6.3
1 parent e0fa4ba commit a034fba

File tree

5 files changed

+157
-9
lines changed

5 files changed

+157
-9
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.6.3
4+
### @xmcl/installer@2.6.3
5+
#### Bug Fixes
6+
7+
- fix: diagnose libraries for install profile ([f4df3752c6781fff43de562419063477fa85e39c](https://github.com/voxelum/minecraft-launcher-core-node/commit/f4df3752c6781fff43de562419063477fa85e39c))
8+
- fix: wrong forge installer maven path ([d5babfdbf18fc3c384b09f65e3d02e21ab0c0c44](https://github.com/voxelum/minecraft-launcher-core-node/commit/d5babfdbf18fc3c384b09f65e3d02e21ab0c0c44))
9+
- fix: catch the error in sync code ([bb9942988be2e66a2a09373052d200d6571a4ef3](https://github.com/voxelum/minecraft-launcher-core-node/commit/bb9942988be2e66a2a09373052d200d6571a4ef3))
10+
- fix: ensure forge url normalized ([b7240061d41733d83cad79994dfc265df42d288f](https://github.com/voxelum/minecraft-launcher-core-node/commit/b7240061d41733d83cad79994dfc265df42d288f))
11+
12+
313
## 2.6.2
414
### @xmcl/installer@2.6.2
515
#### Bug Fixes

USAGE.md

Lines changed: 143 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ Get the forge version info and install forge from it.
9494
await ForgeInstaller.install(firstVersionOnPage, minecraftLocation);
9595
```
9696

97+
If you know forge version and minecraft version. You can directly do such:
98+
99+
```ts
100+
import { ForgeInstaller } from "@xmcl/installer";
101+
const forgeVersion = 'a-forge-version'; // like 31.1.27
102+
await ForgeInstaller.install({ version: forgeVersion, mcversion: '1.15.2' }, minecraftLocation);
103+
```
104+
97105
Notice that this installation doesn't ensure full libraries installation.
98106
Please run `Installer.installDependencies` afther that.
99107

@@ -126,8 +134,11 @@ For example, if you want to download the library `commons-io:commons-io:2.5` fro
126134
}
127135
// return undefined if you don't want to change lib url
128136
return undefined;
129-
}
137+
},
138+
mavenHost: ['https://www.your-other-maven.org'], // you still can use this to add other maven
130139
});
140+
141+
// it will first try you libraryHost url and then try mavenHost url.
131142
```
132143

133144
To swap the assets host, you can just assign the assets host url to the options
@@ -210,7 +221,19 @@ Get the report of the version. It can check if version missing assets/libraries.
210221
const minecraftLocation: string;
211222
const minecraftVersionId: string;
212223

213-
const report: Diagnosis.Report = await Diagnosis.diagnose(minecraftLocation, minecraftVersionId);
224+
const report: Diagnosis.MinecraftIssueReport = await Diagnosis.diagnose(minecraftLocation, minecraftVersionId);
225+
226+
const issues: Diagnosis.MinecraftIssues[] = report.issues;
227+
228+
for (let issue of issues) {
229+
switch (issue.role) {
230+
case "minecraftJar": // your jar has problem
231+
case "versionJson": // your json has problem
232+
case "library": // your lib might be missing or corrupted
233+
case "assets": // some assets are missing or corrupted
234+
// and so on
235+
}
236+
}
214237
```
215238

216239

@@ -426,9 +449,18 @@ Parse minecraft version as a resolved version, which is used for launching proce
426449
Read sever info (server ip, port) and fetch its status (ping, server motd):
427450

428451
```ts
429-
import { fetchStatus, Status } from '@xmcl/client'
430-
// or you want the raw json
431-
const rawStatusJson: Status = await fetchStatus(info);
452+
import { queryStatus, Status, QueryOptions } from '@xmcl/client'
453+
const serverInfo = {
454+
host: 'your host',
455+
port: 25565, // be default
456+
};
457+
const options: QueryOptions = {
458+
/**
459+
* see http://wiki.vg/Protocol_version_numbers
460+
*/
461+
protocol: 203,
462+
};
463+
const rawStatusJson: Status = await fetchStatus(info, options);
432464
```
433465

434466
### Progress Moniting
@@ -478,6 +510,112 @@ Therefore you can just treat the `TaskRuntime` object a stateless event emitter.
478510
// the error will still reject to the promise
479511
```
480512

513+
### Progress Moniting on Installation
514+
515+
Most install function has a corresponding task function. For example, `install` function has the function name `installTask` which is the task version monitor the progress of install.
516+
517+
Here is the example of just moniting the install task overall progress:
518+
519+
```ts
520+
521+
let task: Task<ResolvedVersion> = installTask('client', versionMetadata, mcLocation);
522+
let taskHandle: TaskHandle<ResolvedVersion> = task.execute();
523+
524+
let rootTask: Task.State;
525+
taskHandle.on('execute', (task, parentTask) => {
526+
if (parentTask) {
527+
// remember which is the root tas
528+
rootTask = task;
529+
} else {
530+
// other child task executed
531+
}
532+
});
533+
taskHandle.on('update', ({ progress, total, message }, taskState) => {
534+
if (rootTask === taskState) {
535+
// root task update
536+
// you should update your ui progress
537+
} else {
538+
// other task update
539+
}
540+
});
541+
542+
// wait task finish
543+
await taskHandle.wait();
544+
545+
```
546+
547+
The task is designed to organize the all the works in a tree like structure.
548+
549+
The `installTask` has such parent/child structure
550+
551+
- install
552+
- installVersion
553+
- json
554+
- jar
555+
- installDependencies
556+
- installAssets
557+
- assetsJson
558+
- asset
559+
- installLibraries
560+
- library
561+
562+
To generally display this tree in UI. You can identify the task by its `path`.
563+
564+
```ts
565+
function updateTaskUI(task: Task.State, progress: number, total?: number) {
566+
// you can use task.path as identifier
567+
// and update the task on UI
568+
}
569+
570+
// taskHandle is the installTask handle
571+
taskHandle.on('update', ({ progress, total, message }, taskState) => {
572+
let path = taskState.path;
573+
// the path is concated from each tasks' name
574+
// it can be "install", "install.installVersion", "install.installVersion.jar"
575+
// "install.installDependencies.installAssets.assetsJson" or so on...
576+
updateTaskUI(taskState, progress, total);
577+
});
578+
```
579+
580+
If you think that's not good enough, you can assign the id to the task state by yourself.
581+
582+
In this simple case, you will enconter type error in typescript!
583+
584+
```ts
585+
taskHandle.on('execute', (task, parentTask) => {
586+
task.id = 'your-generated-id'; // type error
587+
});
588+
taskHandle.on('update', ({ progress, total, message }, taskState) => {
589+
updateTaskUI(taskState, progress, total);
590+
});
591+
function updateTaskUI(task: Task.State, progress: number, total?: number) {
592+
// update the task by task.id
593+
}
594+
```
595+
596+
You can override the type by yourself, or you can use task state factory:
597+
598+
```ts
599+
interface TaskState extends Task.State {
600+
id: string;
601+
}
602+
const factory: Task.StateFactory<TaskState> = n => ({
603+
...n,
604+
id: generateIdByYourselft(),
605+
});
606+
607+
const runtime: TaskRuntime<TaskState> = Task.createRuntime(factory);
608+
const task: Task<ResolvedVersion> = installTask('client', versionMetadata, mcLocation);
609+
610+
runtime.submit(task); // use runtime submit!
611+
612+
// listen the task event from runtime!
613+
runtime.on('update', ({progress, total}, state) => {
614+
task.id; // this will not have type error!
615+
});
616+
```
617+
618+
481619
### Read and Write NBT
482620

483621
You can simply deserialize/serialize nbt.

docs/site/definitions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ export interface Issue {
13901390
receivedChecksum: string;
13911391
}
13921392
export declare type MinecraftIssues = LibraryIssue | MinecraftJarIssue | VersionJsonIssue | AssetIssue | AssetIndexIssue;
1393-
export declare type InstallIssues = Issue;
1393+
export declare type InstallIssues = ProcessorIssue | LibraryIssue;
13941394
export interface ProcessorIssue extends Issue {
13951395
role: "processor";
13961396
/**
@@ -1445,7 +1445,7 @@ export interface MinecraftIssueReport {
14451445
export interface InstallProfileIssueReport {
14461446
minecraftLocation: MinecraftFolder;
14471447
installProfile: InstallProfile;
1448-
issues: ProcessorIssue[];
1448+
issues: InstallIssues[];
14491449
}
14501450
/**
14511451
* Diagnose the version. It will check the version json/jar, libraries and assets.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "2.6.2",
3+
"version": "2.6.3",
44
"scripts": {
55
"build": "npm run lint && npm run compile && node scripts/generate-definition.js && npm run build:readme",
66
"build:clean": "node scripts/clean.js",

packages/installer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xmcl/installer",
3-
"version": "2.6.2",
3+
"version": "2.6.3",
44
"main": "./index.cjs.js",
55
"module": "./index.js",
66
"description": "Provides Minecraft/Forge/Fabric/Liteloader installers",

0 commit comments

Comments
 (0)