Skip to content

Commit

Permalink
Merge branch 'main' into devtest
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiNtD committed Nov 10, 2023
2 parents 011f894 + 501ed2b commit 98cc7b3
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 101 deletions.
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
[![][release-badge]][download]\
[![][prism-badge]][prism launcher]

[release-badge]: https://img.shields.io/github/v/release/RuiNtD/PrismLauncherPortable?label=Prism+Launcher+Portable&style=for-the-badge
[prism-badge]: https://img.shields.io/github/v/release/PrismLauncher/PrismLauncher?label=Prism+Launcher&style=for-the-badge

- [Download]
- [Help]
- [Prism Launcher]

[download]: https://github.com/RuiNtD/PrismLauncherPortable/releases/latest
[help]: https://RuiNtD.github.io/PrismLauncherPortable/PrismLauncherPortable/help.html
[prism launcher]: https://prismlauncher.org/

# Portable Java

PortableApps.com has several portable versions of Java that can be esaily
**TL;DR:** [OpenJDK JRE 64-bit] and [jPortable (64-bit)] (for Minecraft 1.16.5 or older) are recommended.

PortableApps.com has several portable versions of Java that can be easily
installed and updated from the [PortableApps.com Platform](https://portableapps.com/download).
They can be found in the Utilities category and will be automatically detected by Prism Launcher Portable.

| App Name | Java Version |
| ----------- | ------------ |
| jdkPortable | JDK 8 |
| jPortable | JRE 8 |
| OpenJDK | JDK 17 |
| OpenJDK JRE | JRE 17 |

The 64-bit versions of both OpenJDK JRE and jPortable are recommended for Minecraft.
The JDK versions contain extra developer tools that you likely don't need.
The 32-bit versions are likely to crash on newer versions of Minecraft and are not recommended
and the JDK versions contain extra developer tools that you likely don't need.

| App Name | Java Version | Minecraft Version |
| ---------------------- | ---------------- | ------------------ |
| [OpenJDK JRE 64-bit] | Java 17 (64-bit) | MC 1.17 or newer |
| [jPortable (64-bit)] | Java 8 (64-bit) | MC 1.16.5 or older |
| [OpenJDK 64-bit] | JDK 17 (64-bit) | MC 1.17 or newer |
| [jdkPortable (64-bit)] | JDK 8 (64-bit) | MC 1.16.5 or older |
| [OpenJDK JRE] | Java 17 (32-bit) | MC 1.17 or newer |
| [jPortable] | Java 8 (32-bit) | MC 1.16.5 or older |
| [OpenJDK] | JDK 17 (32-bit) | MC 1.17 or newer |
| [jdkPortable] | JDK 8 (32-bit) | MC 1.16.5 or older |

[jdkPortable]: https://portableapps.com/apps/utilities/jdkportable
[jdkPortable (64-bit)]: https://portableapps.com/apps/utilities/jdkportable64
[jPortable]: https://portableapps.com/apps/utilities/java_portable
[jPortable (64-bit)]: https://portableapps.com/apps/utilities/java_portable_64
[OpenJDK]: https://portableapps.com/apps/utilities/OpenJDK
[OpenJDK 64-bit]: https://portableapps.com/apps/utilities/OpenJDK64
[OpenJDK JRE]: https://portableapps.com/apps/utilities/OpenJDKJRE
[OpenJDK JRE 64-bit]: https://portableapps.com/apps/utilities/OpenJDKJRE64

# Migrating from PolyMC Portable

Just copy or move your `Data` folder from `PolyMCPortable` to `PrismLauncherPortable` \
You may have to remove and re-add your accounts before you can launch the game

[download]: https://github.com/RuiNtD/PrismLauncherPortable/releases/latest
[help]: https://RuiNtD.github.io/PrismLauncherPortable/PrismLauncherPortable/help.html
[prism launcher]: https://prismlauncher.org/
[release-badge]: https://img.shields.io/github/v/release/RuiNtD/PrismLauncherPortable?label=Prism+Launcher+Portable&style=for-the-badge
[prism-badge]: https://img.shields.io/github/v/release/PrismLauncher/PrismLauncher?label=Prism+Launcher&style=for-the-badge
8 changes: 5 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"udd": "deno run -r --allow-read=. --allow-write=. --allow-net https://deno.land/x/udd/main.ts deno.json"
},
"imports": {
"std/": "https://deno.land/[email protected]/",
"zod": "https://deno.land/x/[email protected]/mod.ts",
"std/": "https://deno.land/[email protected]/",
"permissions": "https://deno.land/[email protected]/permissions/mod.ts#=",
"dax": "https://deno.land/x/[email protected]/mod.ts",
"ini": "npm:[email protected]",
"zipjs": "https://deno.land/x/[email protected]/index.js"
"zipjs": "https://deno.land/x/[email protected]/index.js",
"zod": "https://deno.land/x/[email protected]/mod.ts"
}
}
206 changes: 206 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions fileinfo.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import * as path from "https://deno.land/[email protected]/path/mod.ts";
import { walk } from "https://deno.land/std@0.196.0/fs/mod.ts";
import { Select } from "https://deno.land/x/[email protected]/prompt/select.ts";
import { format as formatBytes } from "https://deno.land/std@0.196.0/fmt/bytes.ts";
import { crypto, toHashString } from "https://deno.land/std/crypto/mod.ts";
import { stripTrailingSeparators } from "https://deno.land/[email protected]/path/_util.ts";

let dir = Array.from(Deno.readDirSync("."))
.filter((v) => v.isFile && path.extname(v.name) == ".exe")
import $ from "dax";
import { format as formatBytes } from "std/fmt/bytes.ts";
import { crypto } from "std/crypto/mod.ts";
import { encodeHex } from "std/encoding/hex.ts";

$.setPrintCommand(true);

const dir = Array.from($.path(".").readDirFilePathsSync())
.filter((v) => v.isFileSync() && v.extname() == ".exe")
.map((v) => ({
name: v.name,
time: Deno.statSync(v.name).mtime?.valueOf() || 0,
path: v,
time: v.statSync()?.mtime?.valueOf() || 0,
}))
.sort((a, b) => b.time - a.time)
.map((v) => v.name);
const file: string = await Select.prompt({
message: "Pick a file",
options: dir,
});
.map((v) => v.path);

const file =
dir[
await $.select({
message: "Pick a file",
options: dir.map((v) => v.basename()),
})
];

function formatSize(size: number): string {
return formatBytes(size, {
Expand All @@ -26,26 +30,22 @@ function formatSize(size: number): string {
.replace("i", "");
}

const downloadSize = formatSize((await Deno.stat(file)).size);
const hash = toHashString(
await crypto.subtle.digest("MD5", await Deno.readFile(file))
const downloadSize = formatSize((await file.stat())?.size || 0);
const hash = encodeHex(
await crypto.subtle.digest("MD5", await file.readBytes())
);

const tempDir = await Deno.makeTempDir();
await new Deno.Command(".\\" + file, {
args: [`/DESTINATION=${tempDir}\\`],
}).output();
const tempDir = $.path(await Deno.makeTempDir());
await $`${file} /DESTINATION=${tempDir}\\`;

let tempSize = 0;
for await (const entry of walk(tempDir)) {
for await (const entry of tempDir.walk()) {
if (entry.isDirectory) continue;
const stat = await Deno.stat(entry.path);
tempSize += stat.size;
const stat = await entry.path.stat();
tempSize += stat?.size || 0;
}
const installedSize = formatSize(tempSize);
await Deno.remove(tempDir, { recursive: true });
await tempDir.remove({ recursive: true });

console.log(`
[${downloadSize} download / ${installedSize} installed]
(MD5: ${hash})
`);
$.log(`[${downloadSize} download / ${installedSize} installed]
(MD5: ${hash})`);
5 changes: 0 additions & 5 deletions make.bat

This file was deleted.

2 changes: 0 additions & 2 deletions make_launcher.bat

This file was deleted.

4 changes: 0 additions & 4 deletions test_launcher.bat

This file was deleted.

77 changes: 38 additions & 39 deletions update.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { z } from "zod";

import { join } from "std/path/mod.ts";
import { ensureDir } from "std/fs/mod.ts";
import { grantOrThrow } from "std/permissions/mod.ts";

import $ from "dax";
import { grantOrThrow } from "permissions";
import ini from "ini";
import { ZipReader, HttpReader, Uint8ArrayWriter } from "zipjs";

const GitHubTag = z.object({
name: z.string(),
$.setPrintCommand(true);

const GitHubRelease = z.object({
tag_name: z.string(),
});
const GitHubTags = GitHubTag.array();

const AppInfoIni = z.object({
Version: z.object({
Expand All @@ -20,20 +18,20 @@ const AppInfoIni = z.object({
});
type AppInfoIni = z.infer<typeof AppInfoIni>;

const latestVersion = GitHubTags.parse(
await (
await fetch("https://api.github.com/repos/PrismLauncher/PrismLauncher/tags")
const latestVersion = GitHubRelease.parse(
await $.request(
"https://api.github.com/repos/PrismLauncher/PrismLauncher/releases/latest"
).json()
)[0].name;
).tag_name;

const appPath = join("PrismLauncherPortable", "App");
const appPath = $.path("PrismLauncherPortable").join("App");
await grantOrThrow(
{ name: "read", path: appPath },
{ name: "write", path: appPath }
{ name: "read", path: appPath.toString() },
{ name: "write", path: appPath.toString() }
);

const iniPath = join(appPath, "AppInfo", "appinfo.ini");
const appinfo = <AppInfoIni>ini.parse(await Deno.readTextFile(iniPath));
const iniPath = appPath.join("AppInfo", "appinfo.ini");
const appinfo = <AppInfoIni>ini.parse(await iniPath.readText());
AppInfoIni.parse(appinfo);

const versionArray = appinfo.Version.PackageVersion.split(".");
Expand All @@ -43,15 +41,14 @@ const updateAvailable = currentVersion != latestVersion;
const updateNum = updateAvailable ? 0 : parseInt(versionArray[2]) + 1;
appinfo.Version.DisplayVersion = `${latestVersion} Update ${updateNum}`;
appinfo.Version.PackageVersion = `${latestVersion}.${updateNum}.0`;
console.log(
$.log(
`New version: ${appinfo.Version.DisplayVersion} (${appinfo.Version.PackageVersion})`
);

if (confirm("Update appinfo.ini?")) {
await Deno.writeTextFile(iniPath, ini.stringify(appinfo));
console.log("Updated appinfo.ini");
if (await $.confirm("Update appinfo.ini?")) {
await iniPath.writeText(ini.stringify(appinfo));
$.logStep("Updated appinfo.ini");
}
console.log();

type Download = {
dir: string;
Expand All @@ -75,47 +72,49 @@ const gitignore = `
!.gitignore
`.trimStart();

if (updateAvailable || confirm("Redownload Prism Launcher?")) {
for await (const entry of Deno.readDir(appPath)) {
if (updateAvailable || (await $.confirm("Redownload Prism Launcher?"))) {
$.logLight("Downloading...");

for await (const entry of appPath.readDir()) {
if (!entry.isDirectory) continue;
if (entry.name == "AppInfo") continue;

const path = join(appPath, entry.name);
await Deno.remove(path, { recursive: true });
const path = appPath.join(entry.name);
await path.remove({ recursive: true });
}

for (const download of downloads) {
const path = join(appPath, download.dir);
const path = appPath.join(download.dir);
const url = `${urlBase}/${download.filename}`;

const zipReader = new ZipReader(new HttpReader(url));
const entries = await zipReader.getEntries();

console.log("Downloaded", download.filename);
await ensureDir(path);
await Deno.writeTextFile(join(path, ".gitignore"), gitignore);
$.logStep("Downloaded", download.filename);
await path.ensureDir();
await path.join(".gitignore").writeText(gitignore);

for (const entry of entries) {
if (!entry.getData) continue;
if (entry.filename == "prismlauncher_updater.exe") continue;

const uint8 = await entry.getData(new Uint8ArrayWriter());
const filePath = join(path, entry.filename);
const filePath = path.join(entry.filename);

if (entry.directory) await Deno.mkdir(filePath);
else await Deno.writeFile(filePath, uint8);
if (entry.directory) await filePath.mkdir();
else await filePath.write(uint8);
}
}
}
console.log();

if (updateAvailable || confirm("Create launcher and installer?")) {
const p = new Deno.Command("./make.bat");
await p.output();
if (updateAvailable || (await $.confirm("Create launcher and installer?"))) {
$.logStep("Creating launcher");
await $`PortableApps.comLauncher/PortableApps.comLauncherGenerator.exe $PWD\\PrismLauncherPortable`;
$.logStep("Creating installer");
await $`PortableApps.comInstaller/PortableApps.comInstaller.exe $PWD\\PrismLauncherPortable`;
}
console.log();

console.log(
$.log(
`- ${
updateAvailable ? "Update to" : "Still using"
} [Prism Launcher ${latestVersion}](https://github.com/PrismLauncher/PrismLauncher/releases/tag/${latestVersion})`
Expand Down

0 comments on commit 98cc7b3

Please sign in to comment.