mirror of
https://github.com/ow-mods/ow-mod-db.git
synced 2025-12-11 20:15:24 +01:00
add mod db schema (#456)
This commit is contained in:
parent
dfacfb6321
commit
1928fa6690
@ -8,7 +8,8 @@ import { toJsonString } from "./to-json-string";
|
||||
const REPO_URL_BASE = "https://github.com";
|
||||
|
||||
export async function fetchMods(modsJson: string) {
|
||||
const modInfos: ModInfo[] = JSON.parse(modsJson);
|
||||
const modDb: ModDB = JSON.parse(modsJson);
|
||||
const modInfos = modDb.mods;
|
||||
const octokit = getOctokit();
|
||||
|
||||
type OctokitRelease = Awaited<
|
||||
|
||||
4
fetch-mods/globals.d.ts
vendored
4
fetch-mods/globals.d.ts
vendored
@ -1,3 +1,7 @@
|
||||
type ModDB = {
|
||||
mods: ModInfo[];
|
||||
};
|
||||
|
||||
type ModInfo = {
|
||||
name: string;
|
||||
uniqueName: string;
|
||||
|
||||
@ -14,7 +14,11 @@ enum Output {
|
||||
editedExistingMod = "edited-existing-mod",
|
||||
}
|
||||
|
||||
// Mod info from mods.json.
|
||||
// Mod db from mods.json.
|
||||
type ModDB = {
|
||||
mods: ModInfo[];
|
||||
};
|
||||
|
||||
type ModInfo = {
|
||||
name: string;
|
||||
uniqueName: string;
|
||||
@ -58,7 +62,8 @@ async function run() {
|
||||
throw new Error("Invalid repo URL " + repoUrl);
|
||||
}
|
||||
|
||||
const mods: ModInfo[] = JSON.parse(core.getInput(Input.mods));
|
||||
const modDb: ModDB = JSON.parse(core.getInput(Input.mods)).mods;
|
||||
const mods = modDb.mods;
|
||||
|
||||
const newMod: ModInfo = {
|
||||
name,
|
||||
@ -95,16 +100,20 @@ async function run() {
|
||||
existingMod.authorDisplay = newMod.authorDisplay;
|
||||
}
|
||||
|
||||
const newMods: ModInfo[] = existingMod ? mods : [...mods, newMod];
|
||||
const newModDb: ModDB = {
|
||||
mods: existingMod ? mods : [...mods, newMod],
|
||||
};
|
||||
|
||||
const jsonString = JSON.stringify(newMods, null, 2);
|
||||
const jsonString = JSON.stringify(newModDb, null, 2);
|
||||
|
||||
core.setOutput(Output.mods, jsonString);
|
||||
|
||||
const outFile = core.getInput(Input.outFile);
|
||||
|
||||
if (outFile) {
|
||||
writeFile(outFile, jsonString, (error) => { if (error) console.log("Couldn't Write To Mods File: ", error) });
|
||||
writeFile(outFile, jsonString, (error) => {
|
||||
if (error) console.log("Couldn't Write To Mods File: ", error);
|
||||
});
|
||||
}
|
||||
|
||||
if (existingMod) {
|
||||
|
||||
59
mods.schema.json
Normal file
59
mods.schema.json
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Outer Wilds Mod Database Schema",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"mods"
|
||||
],
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"mods": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"uniqueName",
|
||||
"repo"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Human-readable title for your mod."
|
||||
},
|
||||
"uniqueName": {
|
||||
"type": "string",
|
||||
"description": "Your mod's ID, unchangeable and unique within the whole database. IMPORTANT: must match uniqueName from your mod's manifest.json. If you're editing an existing mod, this must match the uniqueName of that mod. This property can't be edited."
|
||||
},
|
||||
"repo": {
|
||||
"type": "string",
|
||||
"description": "GitHub repository that contains the mod's source code and releases."
|
||||
},
|
||||
"required": {
|
||||
"type": "boolean",
|
||||
"description": "Mods marked as required must be installed before starting the game."
|
||||
},
|
||||
"utility": {
|
||||
"type": "boolean",
|
||||
"description": "True if this mod isn't useful by itself, and only serves as a dependency for other mods."
|
||||
},
|
||||
"authorDisplay": {
|
||||
"type": "string",
|
||||
"description": "Custom name to show in the author field for this mod. Useful if your mod is in an organization, or made by multiple people. Leave blank to use the repository owner name."
|
||||
},
|
||||
"parent": {
|
||||
"type": "string",
|
||||
"description": "If this mod is an addon for another mod, place the parent's uniqueName here. For instance, custom planets made with New Horizons would have xen.NewHorizons in this field."
|
||||
},
|
||||
"alpha": {
|
||||
"type": "boolean",
|
||||
"description": "True if this mod is made for Outer Wilds Alpha."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user