-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: develop
Are you sure you want to change the base?
Deep ecosystem integration #11
Conversation
There was a problem hiding this 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.
schema.json
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
schemaSchema.json
Outdated
@@ -0,0 +1,384 @@ | |||
{ | |||
"$defs": { |
There was a problem hiding this comment.
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 🤷🏻
There was a problem hiding this comment.
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.
schemaSchema.json
Outdated
"title": "EntryR2", | ||
"type": "object" | ||
}, | ||
"EntryThunderstore": { |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
schemaSchema.json
Outdated
"title": "ModloaderPackage", | ||
"type": "object" | ||
}, | ||
"SchemaEntry": { |
There was a problem hiding this comment.
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!; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
src/r2mm/installing/profile_installers/ModLoaderVariantRecord.ts
Outdated
Show resolved
Hide resolved
src/r2mm/installing/profile_installers/ModLoaderVariantRecord.ts
Outdated
Show resolved
Hide resolved
// 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] } = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should it be
ModLoaderPackageMapping[]
instead of[ModLoaderPackageMapping]
? - I think
Record<string, [ModLoaderPackageMapping]>
would be preferred way to achieve the same thing
src/r2mm/installing/profile_installers/ModLoaderVariantRecord.ts
Outdated
Show resolved
Hide resolved
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? |
255975e
to
5a25f21
Compare
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).
5a25f21
to
be1215a
Compare
|
||
const DEFAULT_MELONLOADER_MAPPING = [new ModLoaderPackageMapping("LavaGang-MelonLoader", "", PackageLoader.MELON_LOADER)]; |
There was a problem hiding this comment.
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.
No description provided.