Fake test data for the file manager and declaration for assets

This commit is contained in:
Ben
2023-10-02 19:48:53 -05:00
parent 85b7bf6778
commit a99935bab9
48 changed files with 299 additions and 0 deletions

3
src/declaration.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
declare module "*.png";
declare module "*.jpeg";
declare module "*.mp3";

View File

@@ -0,0 +1,48 @@
import path from 'path';
import { Downloader } from '../libs';
import config from '../config.json';
(async () => {
const downloader = new Downloader({
bucket: config.aws.bucket,
root: path.resolve('../../../mockGame/'),
s3config: config.aws,
});
// downloader.on('start', ({response}) => {
// console.log(response.ETag);
// });
downloader.on('batchData', (params) => {
console.log('Downloads: ', params.downloadsStarted);
console.log('Percentage: ', params.percentage);
});
downloader.on('batchStart', (params) => {
console.log('Batch End: ', params);
});
downloader.on('batchEnd', (params) => {
console.log('Batch End: ', params);
});
downloader.on('error', (params) => {
console.log('An Error Occurred: ', params.error?.message);
});
try {
await downloader.downloadFiles([
{ remotePath: 'addOns/AIO_Cklient.zip', localPath: 'AIO_Client.zip' },
{ remotePath: 'base/Wow.exe', localPath: 'WoW-test.exe'}
]);
} catch(Error) {
// do nothing;
}
// await downloader.downloadFile('addOns/AIO_Client.zip', 'AIO_Client.zip');
})();

View File

@@ -0,0 +1,139 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
/* eslint-disable-next-line prefer-destructuring */
import path from 'path';
import fs from 'fs/promises';
import FileManager, {
HDPatchList,
extraHDList,
featuresList,
reservedAraxiaList
} from '../libs/FileManager';
describe('FileManager', () => {
const testDirectories = [
'testdata/patched',
'testdata/full-install',
'testdata/unpatched',
'testdata/partial-patch',
];
let basePath:string;
let fileManager:FileManager;
describe('Test A HD Patched client', () => {
beforeAll(() => {
basePath = testDirectories[0]; // get the HD patched directory
fileManager = new FileManager(basePath);
});
afterEach(async () => {
for(const patch of reservedAraxiaList) {
const patchPath = path.join(__dirname, basePath, 'Data', patch.name);
try {
await fs.rmdir(patchPath);
// console.log('removed file: ',patchPath);
} catch(err) {
// DO NOTHING
}
}
});
it('should return installed patches', async () => {
const result = await fileManager.GetInstalledHDPatches();
expect(result).toStrictEqual(HDPatchList);
});
it('should have no missing patches', async () => {
const result = await fileManager.GetMissingHDPatches();
expect(result).toHaveLength(0);
});
it('should be missing extra HD patches', async () => {
const result = await fileManager.GetMissingExtraHDPatches();
expect(result).toStrictEqual(extraHDList);
});
it('should show HD patches are installed', async () => {
const result = await fileManager.IsHDSetup();
expect(result).toBeTruthy();
});
it('should show HDExtra patches are not installed', async () => {
const result = await fileManager.IsHDExtraSetup();
expect(result).toBeFalsy();
});
it('should show Feature patches are not installed', async () => {
const result = await fileManager.IsFeaturesSetup();
expect(result).toBeFalsy();
});
it('should be missing feature patches', async () => {
const result = await fileManager.GetMissingFeaturePatches();
expect(result).toStrictEqual(featuresList);
});
it('should not have araxia installed', async () => {
let result = await fileManager.GetInstalledAraxiaPatches();
expect(result).toHaveLength(0);
result = await fileManager.GetMissingAraxiaPatches();
expect(result).toStrictEqual(reservedAraxiaList);
const installed = await fileManager.IsAraxiaSetup();
expect(installed).toBeFalsy();
});
it('should install araxia', async () => {
await fileManager.CreateAraxiaPatches();
const installed = await fileManager.IsAraxiaSetup();
expect(installed).toBeTruthy();
});
}); // end describe('Test an HD Patched client')
describe('Test Fully Patched client', () => {
beforeAll(() => {
basePath = testDirectories[1]; // get the HD patched directory
fileManager = new FileManager(basePath);
});
it('should return installed patches', async () => {
const result = await fileManager.GetInstalledHDPatches();
expect(result).toEqual(HDPatchList);
});
it('should have no missing patches', async () => {
const result = await fileManager.GetMissingHDPatches();
expect(result).toHaveLength(0);
});
it('should show HD patches are installed', async () => {
const result = await fileManager.IsHDSetup();
expect(result).toBeTruthy();
});
it('should show HDExtra patches are installed', async () => {
const result = await fileManager.IsHDExtraSetup();
expect(result).toBeTruthy();
});
it('should show Feature patches are installed', async () => {
const result = await fileManager.IsFeaturesSetup();
expect(result).toBeTruthy();
});
it('should be missing feature patches', async () => {
const result = await fileManager.GetMissingFeaturePatches();
expect(result).toStrictEqual([]);
});
it('should have araxia installed', async () => {
const installed = await fileManager.IsAraxiaSetup();
expect(installed).toBeTruthy();
});
}); // end describe('Fully Patched client')
});

View File

@@ -0,0 +1,109 @@
const fs = require('fs');
const path = require('path');
// Define the list of patch files
/**
* List of patches that modify the client heavily to add HD textures
* to character, environment, creature, and spell effects.
*/
const HDPatchList = [
{ name: 'patch-9.MPQ', description: 'Added HD music from cataclym expansion'},
{ name: 'patch-A.MPQ', description: 'Character models and armor'},
{ name: 'patch-B.MPQ', description: 'Player models and armor'},
{ name: 'patch-C.MPQ', description: 'Trees and Flowers'},
{ name: 'patch-E.MPQ', description: 'Creature models'},
{ name: 'patch-F.MPQ', description: 'Creature models'},
{ name: 'patch-G.MPQ', description: 'Spell effects'},
{ name: 'patch-T.MPQ', description: 'Environment textures'},
{ name: 'patch-U.MPQ', description: 'Battlegrounds'},
];
/**
* These are optional extras that do not change the base game as much
* as the HDPatch set does.
*/
const extraHDList = [
{ name: 'patch-D.MPQ', description: 'Goblin models'},
{ name: 'patch-5.MPQ', description: 'Totems'},
{ name: 'patch-J.MPQ', description: 'Druids and updated animal forms'},
{ name: 'patch-S.MPQ', description: 'Liquid textures and sun rays / lighting effects'},
];
/**
* Additional patches that add features to the game.
*/
const featuresList = [
{ name: 'patch-A.MPQ', description: 'All Races All Classes'},
{ name: 'patch-4.MPQ', description: 'Adds all races and classes to character creation'},
{ name: 'patch-7.MPQ', description: 'Adds rmember password and HD loading screens'},
{ name: 'patch-L.MPQ', description: 'Adds Blood to the game'},
];
/**
* These are patches that are reserved for use by Araxia client patcher
* to update game files over time with new content.
*/
const reservedAraxiaList = [
{ name: 'patch-Z.MPQ', description: 'Early load patch for pre letter patched content (use rarely)'},
{ name: 'patch-8.MPQ', description: 'Contains custom DBC file updates'},
{ name: 'patch-6.MPQ', description: 'Future Store content'},
];
// Define the base directory where the files should be created (current directory)
const baseDirectory = process.cwd();
// Check if the -random argument is passed
const excludeRandomFile = process.argv.includes('-random');
const allFiles = process.argv.includes('-all');
if (excludeRandomFile) {
// Generate a random index to exclude a file
const randomIndex = Math.floor(Math.random() * HDPatchList.length);
const excludedFile = HDPatchList[randomIndex];
console.log(`Excluding random file: ${excludedFile.name}`);
// Create empty files for each patch file except the excluded one
HDPatchList.forEach((patch) => {
if (patch !== excludedFile) {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
}
});
} else if(allFiles) {
// Create empty files for each patch file in the list
HDPatchList.forEach((patch) => {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
});
extraHDList.forEach((patch) => {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
});
featuresList.forEach((patch) => {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
});
reservedAraxiaList.forEach((patch) => {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
});
} else {
// Create empty files for each patch file in the list
HDPatchList.forEach((patch) => {
const filePath = path.join(baseDirectory, patch.name);
fs.writeFileSync(filePath, ''); // Create an empty file
console.log(`Created empty file: ${filePath}`);
});
}
console.log('Empty files creation completed.')

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File