Skip to content
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

Deep ecosystem integration #11

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ethangreen-dev
Copy link
Member

No description provided.

@ethangreen-dev ethangreen-dev marked this pull request as ready for review January 21, 2025 08:43
Copy link
Collaborator

@ebkr ebkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also be good to update the adding a game document if this affects how we currently add games.

schemaSchema.json Outdated Show resolved Hide resolved
src/model/game/StorePlatform.ts Outdated Show resolved Hide resolved
src/model/schema/ThunderstoreSchema.ts Outdated Show resolved Hide resolved
src/model/schema/ThunderstoreSchema.ts Outdated Show resolved Hide resolved
src/model/schema/ThunderstoreSchema.ts Outdated Show resolved Hide resolved
schema.json Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we have everything included?

Things like categories aren't necessary and don't need to be in here imo. It's a prime target for becoming out of sync and I'd imagine won't actually be used by us anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity mostly. Otherwise we would need to have an additional build step with prunes all unnecessary fields which doesn't seem to offer much for the increase in complexity. This will be mostly ameliorated when we implement runtime schema updates.

Copy link

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the parts where there were many consecutive red lines.

@@ -0,0 +1,384 @@
{
"$defs": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure the defs/refs here make things easier to read, and they don't seem to be defined for reusability. Or is it a technical limitation of ajv? Just wondering if this would be easier to follow without the refs 🤷🏻

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into customizing how pydantic exports the json schema. There's probably a way to prune these unnecessary fields.

"title": "EntryR2",
"type": "object"
},
"EntryThunderstore": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this just called a "Community"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the names of the corresponding pydantic dataclasses from the ecosystem schema repo. They shouldn't have any hold over how we define the types within r2mm, but I'm happy to change them if I'm incorrect.

"title": "ModloaderPackage",
"type": "object"
},
"SchemaEntry": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this called just "Game" or something?

}

static get gameList(): Game[] {
return [...this._gameList];
return EcosystemSchema.r2mm_games.map((game) => {
const r2mm = game.r2modman!;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ! doesn't seem to be necessary here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'll mention later it's because we can't (or I don't know how) to tell the compiler "ok, we've checked and made sure that this field on the module is AOK and cannot be undefined".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least Cursor can infer it directly from the current types, i.e. removing ! doesn't seem to affect inferred type.


// Map distribution values onto the r2mm StorePlatformMetadata type.
// The `identifier` property may not be present, so we check it beforehand to avoid JSON import lint errors.
const distributions = game.distributions.map((x: any) => new StorePlatformMetadata(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use any here when TS can already infer the type of x from game.distributions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a solution to

ERROR in src/model/game/GameManager.ts:38:59
TS7006: Parameter 'x' implicitly has an 'any' type.
    36 |             // Map distribution values onto the r2mm StorePlatformMetadata type.
    37 |             // The `identifier` property may not be present, so we check it beforehand to avoid JSON import lint errors.
  > 38 |             const distributions = game.distributions.map((x) => new StorePlatformMetadata(
       |                                                           ^
    39 |                     GetStorePlatformFromName(x.platform),
    40 |                     x.identifier!
    41 |                 )

however I'm sure there's a better way to do things.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, my IDE currently infers the type (when no type is manually provider) in an awkward but correct looking fashion:

(parameter) x: {
    platform: string;
    identifier: string;
} | {
    platform: string;
    identifier: string;
} | {
    platform: string;
    identifier: null;
} | {
    platform: string;
    identifier: null;
}
```

Perhaps you did some changes afterwards that got rid of the problem?

// Casting is done here to ensure the values are ModLoaderPackageMapping[]
export type GAME_NAME = keyof typeof VARIANTS;
export const MOD_LOADER_VARIANTS: {[key in GAME_NAME]: ModLoaderPackageMapping[]} = VARIANTS;
const OVERRIDES: { [key: string]: [ModLoaderPackageMapping] } = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should it be ModLoaderPackageMapping[] instead of [ModLoaderPackageMapping]?
  2. I think Record<string, [ModLoaderPackageMapping]> would be preferred way to achieve the same thing

@anttimaki
Copy link

Also related to some of @ebkr's comments and some of mine, we might want to refactor the enums in the r2mm codebase to a) be consistent b) use values that can be more easily matched with the values from ecosystem, while keeping them somewhat generic to avoid any weirdly specific names in the ecosystem that mean nothing outside the context of the mod manager.

If we decide to go that way, would probably make sense to do that before these changes?

@ethangreen-dev ethangreen-dev force-pushed the deep-ecosystem-integration branch from 255975e to 5a25f21 Compare January 29, 2025 23:34
This commit and PR largely aim to replace previously hard-coded game and
mod definitions within R2MM with data read directly from the
ecosystem schema (thunderstore-io/ecosystem-schema).

Validation is accomplished through ajv, which allows us to validate the
provided ecosystem-schema document with its cooresponding JSON schema
(ecosystem.json and ecosystemJsonSchema.json).
@ethangreen-dev ethangreen-dev force-pushed the deep-ecosystem-integration branch from 5a25f21 to be1215a Compare January 29, 2025 23:55

const DEFAULT_MELONLOADER_MAPPING = [new ModLoaderPackageMapping("LavaGang-MelonLoader", "", PackageLoader.MELON_LOADER)];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be carried over somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants