Skip to content

SkyBlock Rewrite #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 14, 2025
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/scripts/checkCoverage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* v8 ignore next 1000 */

import { parseString } from 'xml2js';
import { readFile } from 'fs';

Expand Down
98 changes: 98 additions & 0 deletions .github/scripts/generateIndexFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* v8 ignore next 1000 */

import { readdir } from 'fs/promises';
import { writeFileSync } from 'fs';

async function scanDirectory(directoryPath: string, goDeep: boolean = true): Promise<string[]> {
const filePaths: string[] = [];
const files = await readdir(directoryPath, { withFileTypes: true });

for (const file of files) {
const fullPath = directoryPath + file.name;
if (file.isDirectory() && goDeep) {
const paths = await scanDirectory(`${fullPath}/`);
paths.forEach((path) => filePaths.push(path));
} else {
if (fullPath.endsWith('.test.ts')) continue;
if (fullPath.endsWith('index.ts')) continue;
filePaths.push(fullPath.replaceAll('./src/', './'));
}
}

return filePaths;
}

async function generateBaseIndex() {
const lines: string[] = [
'/* v8 ignore next 1000 */',
'/* eslint-disable max-len */',
'',
'',
"import Client from './Client.js';",
"import Errors from './Errors.js';",
''
];

const importNames: string[] = [];

const typesPaths = await scanDirectory('./src/Types/');
typesPaths.forEach((path) => {
const fixedPath = path.replaceAll('.ts', '.js');
lines.push(`export * from '${fixedPath}';`);
});

lines.push('');

const structuresPaths = await scanDirectory('./src/Structures/');
const fixedStructuresPaths: string[] = [];

structuresPaths.forEach((path) => {
const importName = path.split('.ts')[0].split('/')[path.split('.ts')[0].split('/').length - 1];
importNames.push(importName);
const fixedPath = path.replaceAll('.ts', '.js');
fixedStructuresPaths.push(`import ${importName} from '${fixedPath}';`);
});

fixedStructuresPaths.sort().forEach((path) => lines.push(path));

lines.push('');
lines.push('export default {');
lines.push('Client,');
lines.push('Errors,');
lines.push('');

importNames.sort().forEach((importName) => lines.push(`${importName},`));
lines.push('};');
lines.push('');

writeFileSync('./src/index.ts', lines.join('\n'));
}

async function generateAPIIndex() {
const lines: string[] = ['/* v8 ignore next 400 */', ''];

const importNames: string[] = [];

const apiPaths = await scanDirectory('./src/API/', false);
const fixedAPIPaths: string[] = [];

apiPaths.forEach((path) => {
const importName = path.split('.ts')[0].split('/')[path.split('.ts')[0].split('/').length - 1];
importNames.push(importName);
const fixedPath = path.replaceAll('.ts', '.js').replaceAll('./API/', './');
fixedAPIPaths.push(`import ${importName} from '${fixedPath}';`);
});

fixedAPIPaths.sort().forEach((path) => lines.push(path));

lines.push('');
lines.push('export default {');
importNames.sort().forEach((importName) => lines.push(`${importName},`));
lines.push('};');
lines.push('');

writeFileSync('./src/API/index.ts', lines.join('\n'));
}

generateBaseIndex();
generateAPIIndex();
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
"packageManager": "[email protected]",
"author": "Kathund",
"dependencies": {
"farming-weight": "^0.8.2",
"minecraft-data": "^3.85.0",
"node-cache": "^5.1.2",
"prismarine-nbt": "^2.7.0",
"rss-parser": "^3.13.0",
"skyhelper-networth": "^1.27.3"
"rss-parser": "^3.13.0"
},
"license": "MIT",
"readme": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn?tab=readme-ov-file#hypixel-api--reborn",
Expand Down
Loading