@loontail/minecraft-kit 0.2.0 → 0.3.0
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/README.md +2 -0
- package/dist/cli/index.js +48 -34
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +44 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -576,11 +576,16 @@ interface ExtractNativeAction {
|
|
|
576
576
|
readonly destination: string;
|
|
577
577
|
readonly exclude: readonly string[];
|
|
578
578
|
}
|
|
579
|
-
/**
|
|
579
|
+
/**
|
|
580
|
+
* A Forge processor invocation. `Main-Class` is intentionally NOT carried here — the
|
|
581
|
+
* runner reads it from `classpath[0]`'s manifest at execution time, because the JAR is
|
|
582
|
+
* not guaranteed to exist on disk during planning (newer Forge versions ship some
|
|
583
|
+
* processor JARs as regular Maven libraries instead of bundling them in the installer).
|
|
584
|
+
*/
|
|
580
585
|
interface RunForgeProcessorAction {
|
|
581
586
|
readonly kind: typeof InstallActionKinds.RUN_FORGE_PROCESSOR;
|
|
582
587
|
readonly index: number;
|
|
583
|
-
|
|
588
|
+
/** First entry is the processor JAR; remaining entries are its declared classpath. */
|
|
584
589
|
readonly classpath: readonly string[];
|
|
585
590
|
readonly args: readonly string[];
|
|
586
591
|
readonly outputs: Readonly<Record<string, string>>;
|
package/dist/index.js
CHANGED
|
@@ -551,14 +551,16 @@ function planLibraryDownloads(input) {
|
|
|
551
551
|
);
|
|
552
552
|
if (!seenPaths.has(targetPath)) {
|
|
553
553
|
seenPaths.add(targetPath);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
554
|
+
if (artifact.url) {
|
|
555
|
+
downloads.push({
|
|
556
|
+
kind: InstallActionKinds.DOWNLOAD_FILE,
|
|
557
|
+
url: artifact.url,
|
|
558
|
+
target: targetPath,
|
|
559
|
+
...artifact.sha1 !== void 0 ? { expectedSha1: artifact.sha1 } : {},
|
|
560
|
+
...artifact.size !== void 0 ? { expectedSize: artifact.size } : {},
|
|
561
|
+
category: input.category
|
|
562
|
+
});
|
|
563
|
+
}
|
|
562
564
|
classpathFiles.push(targetPath);
|
|
563
565
|
}
|
|
564
566
|
}
|
|
@@ -567,14 +569,16 @@ function planLibraryDownloads(input) {
|
|
|
567
569
|
const targetPath = path.join(targetPaths.librariesDir(input.directory), native.relativePath);
|
|
568
570
|
if (!seenPaths.has(targetPath)) {
|
|
569
571
|
seenPaths.add(targetPath);
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
572
|
+
if (native.url) {
|
|
573
|
+
downloads.push({
|
|
574
|
+
kind: InstallActionKinds.DOWNLOAD_FILE,
|
|
575
|
+
url: native.url,
|
|
576
|
+
target: targetPath,
|
|
577
|
+
...native.sha1 !== void 0 ? { expectedSha1: native.sha1 } : {},
|
|
578
|
+
...native.size !== void 0 ? { expectedSize: native.size } : {},
|
|
579
|
+
category: input.category
|
|
580
|
+
});
|
|
581
|
+
}
|
|
578
582
|
}
|
|
579
583
|
nativeExtractions.push({
|
|
580
584
|
kind: InstallActionKinds.EXTRACT_NATIVE,
|
|
@@ -1379,7 +1383,7 @@ async function buildProcessorActions(input) {
|
|
|
1379
1383
|
continue;
|
|
1380
1384
|
}
|
|
1381
1385
|
if (!evaluateRules([], { system: input.system })) ;
|
|
1382
|
-
const action =
|
|
1386
|
+
const action = buildProcessorAction({
|
|
1383
1387
|
processor,
|
|
1384
1388
|
directory: input.directory,
|
|
1385
1389
|
tokens,
|
|
@@ -1394,19 +1398,11 @@ function processorAppliesToClient(processor) {
|
|
|
1394
1398
|
if (!processor.sides || processor.sides.length === 0) return true;
|
|
1395
1399
|
return processor.sides.includes("client");
|
|
1396
1400
|
}
|
|
1397
|
-
|
|
1401
|
+
function buildProcessorAction(input) {
|
|
1398
1402
|
const jarPath = path.join(
|
|
1399
1403
|
targetPaths.librariesDir(input.directory),
|
|
1400
1404
|
mavenRelativePathFor(input.processor.jar)
|
|
1401
1405
|
);
|
|
1402
|
-
const mainClass = await readJarMainClass(jarPath);
|
|
1403
|
-
if (!mainClass) {
|
|
1404
|
-
throw new MinecraftKitError(
|
|
1405
|
-
"FORGE_INSTALLER_INVALID",
|
|
1406
|
-
`Processor jar has no Main-Class: ${input.processor.jar}`,
|
|
1407
|
-
{ context: { filePath: jarPath } }
|
|
1408
|
-
);
|
|
1409
|
-
}
|
|
1410
1406
|
const classpath = [
|
|
1411
1407
|
jarPath,
|
|
1412
1408
|
...input.processor.classpath.map(
|
|
@@ -1425,7 +1421,6 @@ async function buildProcessorAction(input) {
|
|
|
1425
1421
|
return {
|
|
1426
1422
|
kind: InstallActionKinds.RUN_FORGE_PROCESSOR,
|
|
1427
1423
|
index: input.index,
|
|
1428
|
-
mainClass,
|
|
1429
1424
|
classpath,
|
|
1430
1425
|
args,
|
|
1431
1426
|
outputs
|
|
@@ -1767,16 +1762,32 @@ function isWrite(action) {
|
|
|
1767
1762
|
}
|
|
1768
1763
|
async function runProcessor(input) {
|
|
1769
1764
|
const startedAt = Date.now();
|
|
1765
|
+
const processorJar = input.action.classpath[0];
|
|
1766
|
+
if (processorJar === void 0) {
|
|
1767
|
+
throw new MinecraftKitError(
|
|
1768
|
+
"FORGE_INSTALLER_INVALID",
|
|
1769
|
+
"Forge processor has an empty classpath",
|
|
1770
|
+
{ context: { processorIndex: input.action.index } }
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
const mainClass = await readJarMainClass(processorJar);
|
|
1774
|
+
if (!mainClass) {
|
|
1775
|
+
throw new MinecraftKitError(
|
|
1776
|
+
"FORGE_INSTALLER_INVALID",
|
|
1777
|
+
`Forge processor jar has no Main-Class: ${processorJar}`,
|
|
1778
|
+
{ context: { filePath: processorJar } }
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1770
1781
|
const classpathSeparator = process.platform === "win32" ? ";" : ":";
|
|
1771
1782
|
const args = [
|
|
1772
1783
|
"-cp",
|
|
1773
1784
|
input.action.classpath.join(classpathSeparator),
|
|
1774
|
-
|
|
1785
|
+
mainClass,
|
|
1775
1786
|
...input.action.args
|
|
1776
1787
|
];
|
|
1777
1788
|
input.onEvent?.({
|
|
1778
1789
|
type: "forge:processor-started",
|
|
1779
|
-
processor: { index: input.action.index, mainClass
|
|
1790
|
+
processor: { index: input.action.index, mainClass },
|
|
1780
1791
|
total: input.total
|
|
1781
1792
|
});
|
|
1782
1793
|
const stderrTail = [];
|
|
@@ -1791,11 +1802,11 @@ async function runProcessor(input) {
|
|
|
1791
1802
|
if (exit.code !== 0) {
|
|
1792
1803
|
throw new MinecraftKitError(
|
|
1793
1804
|
"FORGE_PROCESSOR_FAILED",
|
|
1794
|
-
`Forge processor exited with code ${exit.code ?? "(signal)"}: ${
|
|
1805
|
+
`Forge processor exited with code ${exit.code ?? "(signal)"}: ${mainClass}`,
|
|
1795
1806
|
{
|
|
1796
1807
|
context: {
|
|
1797
1808
|
exitCode: exit.code ?? void 0,
|
|
1798
|
-
mainClass
|
|
1809
|
+
mainClass,
|
|
1799
1810
|
stderr: stderrTail.join("\n")
|
|
1800
1811
|
}
|
|
1801
1812
|
}
|
|
@@ -1803,7 +1814,7 @@ async function runProcessor(input) {
|
|
|
1803
1814
|
}
|
|
1804
1815
|
input.onEvent?.({
|
|
1805
1816
|
type: "forge:processor-completed",
|
|
1806
|
-
processor: { index: input.action.index, mainClass
|
|
1817
|
+
processor: { index: input.action.index, mainClass },
|
|
1807
1818
|
exitCode: exit.code ?? 0,
|
|
1808
1819
|
durationMs: Date.now() - startedAt
|
|
1809
1820
|
});
|
|
@@ -1818,7 +1829,7 @@ async function runProcessor(input) {
|
|
|
1818
1829
|
}
|
|
1819
1830
|
input.onEvent?.({
|
|
1820
1831
|
type: "forge:processor-output-verified",
|
|
1821
|
-
processor: { index: input.action.index, mainClass
|
|
1832
|
+
processor: { index: input.action.index, mainClass },
|
|
1822
1833
|
path: outputPath
|
|
1823
1834
|
});
|
|
1824
1835
|
}
|