Skip to content

Commit

Permalink
Add support for other modloaders
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Aug 13, 2024
1 parent ece00b8 commit c4a315c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ Will output to standard output something in the form of:

Entries are sorted by file upload date.

By default, mods for the Forge modloader will be fetched, but any other modloader can be fetched as follows:

```bash
$ forge-update-generator cyclops-core NeoForge
```

```bash
$ forge-update-generator cyclops-core Fabric
```

### Experimental: Generate update file and fetch changelogs

If you pass the `-c` option, changelogs will be fetched from their respective CurseForge page.
Expand Down
9 changes: 5 additions & 4 deletions bin/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { ForgeUpdateJsonCreator } from '../lib/ForgeUpdateJsonCreator';

// Process CLI args
const args = minimist(process.argv.slice(2));
if (args.help || args._.length !== 1) {
process.stdout.write(`forge-update-generator Detects new Cyclops mod versions
if (args.help || !(args._.length === 1 || args._.length === 2)) {
process.stdout.write(`forge-update-generator Detects new mod versions
Usage:
forge-update-generator modname
forge-update-generator modname [modloader]
Options:
-c if changelogs should be fetched from CurseForge via HTML scraping
--help print this help message
Expand All @@ -20,12 +20,13 @@ Options:
}

async function run(): Promise<void> {
const modLoader = args._[1];
const dataCurseforge = await new CurseforgeLoader().load(args._[0]);
const changelogLoader = args.c ? new CurseforgeChangelogLoader() : new DeferredChangelogLoader();
if ('initialize' in changelogLoader) {
await changelogLoader.initialize();
}
const dataForge = await new ForgeUpdateJsonCreator(changelogLoader).generate(dataCurseforge);
const dataForge = await new ForgeUpdateJsonCreator(changelogLoader).generate(dataCurseforge, modLoader);
if ('deinitialize' in changelogLoader) {
await changelogLoader.deinitialize();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ForgeUpdateJsonCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ForgeUpdateJsonCreator {
this.changelogLoader = changelogLoader;
}

public async generate(dataCurseforge: ICurseforgeData): Promise<IForgeUpdateData> {
public async generate(dataCurseforge: ICurseforgeData, modLoader?: string): Promise<IForgeUpdateData> {
const dataForge: IForgeUpdateData = {
homepage: dataCurseforge.urls.curseforge,
promos: {},
Expand All @@ -21,9 +21,9 @@ export class ForgeUpdateJsonCreator {
const latestMcVersions: Record<string, string> = {};
const recommendedMcVersions: Record<string, string> = {};
for (const file of dataCurseforge.files) {
if (file.versions.includes('Forge')) {
if (file.versions.includes(modLoader || 'Forge')) {
// Determine MC and mod version
const mcVersion = file.version;
const mcVersion: string = file.versions.find(version => version.includes('.'))!;
const match = /-([^-]*)\.jar/u.exec(file.name);
if (!match) {
continue;
Expand Down

0 comments on commit c4a315c

Please sign in to comment.