1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 08:14:48 +00:00

update json paths

This commit is contained in:
zumbiepig 2024-09-04 10:08:40 -07:00
parent 425a434845
commit 26406bc46b
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE
6 changed files with 12 additions and 12 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
package-lock.json
desktop.ini
public/assets.json
public/resources/data/assets.json
public/resources/scripts/
public/sw.js
public/sw-full.js

View File

@ -35,7 +35,7 @@ if (tscOutput) {
}
console.log(chalk.cyan('Removing old build artifacts...\n'));
await $`rm -rf ./public/resources/scripts/ ./public/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
await $`rm -rf ./public/resources/scripts/ ./public/resources/data/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
console.log(chalk.cyan('Bundling TypeScript and modules...\n'));
const srcFilesArr = getFiles(join(import.meta.dir, 'src'));
@ -57,7 +57,7 @@ await $`bunx javascript-obfuscator ./public/resources/scripts/ --output ./public
console.log(chalk.cyan('Generating assets list...\n'));
const publicDir = join(import.meta.dir, 'public');
writeFileSync(
join(publicDir, 'assets.json'),
join(publicDir, 'resources/data/assets.json'),
JSON.stringify(
getFiles(publicDir).map((asset) => {
return asset.replace(new RegExp(`^${publicDir}`), '').replace(/\/index\.html$/, '/');

View File

@ -19,7 +19,7 @@ function getFiles(baseDir: string, dir?: string, filesArr?: string[]) {
}
console.log(chalk.cyan('Removing old build artifacts...\n'));
await $`rm -rf ./public/resources/scripts/ ./public/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
await $`rm -rf ./public/resources/scripts/ ./public/resources/data/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
console.log(chalk.cyan('Bundling TypeScript and modules...\n'));
const srcFilesArr = getFiles(join(import.meta.dir, 'src'));
@ -38,7 +38,7 @@ await build({
console.log(chalk.cyan('Generating assets list...\n'));
const publicDir = join(import.meta.dir, 'public');
writeFileSync(
join(publicDir, 'assets.json'),
join(publicDir, 'resources/data/assets.json'),
JSON.stringify(
getFiles(publicDir).map((asset) => {
return asset.replace(new RegExp(`^${publicDir}`), '').replace(/\/index\.html$/, '/');

View File

@ -376,7 +376,7 @@ if (window.location.pathname === '/') {
const titleBarText = document.getElementById('title-bar-text');
const lastVersion = storage.local.get('lastVersion');
const updateData = (await (await fetch('/resources/data.json')).json()).updates;
const updateData = (await (await fetch('/resources/data/main.json')).json()).updates;
const currentVersion = updateData[0].version;
const changelog = updateData[0].changelog.map((change: string) => ` - ${change}`).join('\n');
@ -417,7 +417,7 @@ if (window.location.pathname === '/settings/') {
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
// const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
// const adsCheckbox = document.getElementById('ads-checkbox') as HTMLInputElement;
const themeData: { id: string; name: string }[] = (await (await fetch('/resources/data.json')).json()).themes;
const themeData: { id: string; name: string }[] = (await (await fetch('/resources/data/main.json')).json()).themes;
themeData.forEach((theme: { id: string; name: string }) => {
const option = document.createElement('option');
@ -467,7 +467,7 @@ if (window.location.pathname === '/settings/') {
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
// const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement;
const themeData: { id: string; name: string }[] = (await (await fetch('/resources/data.json')).json()).themes;
const themeData: { id: string; name: string }[] = (await (await fetch('/resources/data/main.json')).json()).themes;
themeData.forEach((theme: { id: string; name: string }) => {
const option = document.createElement('option');
@ -500,7 +500,7 @@ if (window.location.pathname === '/settings/') {
// storage.local.set('offlineCache', offlineCheckbox.checked);
storage.local.set('showAds', true);
storage.local.set('mods', []);
storage.local.set('lastVersion', (await (await fetch('/resources/data.json')).json()).updates[0].version);
storage.local.set('lastVersion', (await (await fetch('/resources/data/main.json')).json()).updates[0].version);
/* if (offlineCheckbox.checked) {
sw.register('/sw-full.js');
@ -520,7 +520,7 @@ if (window.location.pathname === '/settings/') {
} else if (window.location.pathname === '/mods/mods/' || window.location.pathname === '/mods/resourcepacks/') {
document.addEventListener('DOMContentLoaded', async () => {
const addonType: 'mods' | 'resourcepacks' = window.location.pathname === '/mods/mods/' ? 'mods' : 'resourcepacks';
const addonData: { id: string; name: string; description: string; author: string; authorLink: string; source: string }[] = (await (await fetch('/resources/data.json')).json()).addons;
const addonData: { id: string; name: string; description: string; author: string; authorLink: string; source: string }[] = (await (await fetch('/resources/data/main.json')).json()).addons;
const modList = document.querySelector('.mod-list');
// @ts-expect-error
addonData[addonType].forEach((addon) => {
@ -551,7 +551,7 @@ if (window.location.pathname === '/settings/') {
} else if (window.location.pathname === '/updates/') {
document.addEventListener('DOMContentLoaded', async () => {
const updatesContainer = document.getElementById('updates-container');
const updateData: { version: string; changelog: string[] }[] = (await (await fetch('/resources/data.json')).json()).updates;
const updateData: { version: string; changelog: string[] }[] = (await (await fetch('/resources/data/main.json')).json()).updates;
updateData.forEach((update) => {
const versionHeader = document.createElement('strong');
versionHeader.textContent = `MineXLauncher ${update.version}`;

View File

@ -5,7 +5,7 @@ const cacheName = `minexlauncher-full-v${cacheVersion}`;
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(cacheName).then(async (cache) => {
const response = await fetch('/assets.json');
const response = await fetch('/resources/data/assets.json');
const cacheAssets = await response.json();
const totalAssets = cacheAssets.length;
let cachedAssets = 0;