mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-12-28 17:44:54 -05:00
Added modrinth-featured
input (#9)
This commit is contained in:
parent
24a3f2d11e
commit
44e418ffe7
5 changed files with 22 additions and 8 deletions
|
@ -90,6 +90,7 @@ jobs:
|
|||
|------|-------------|---------------|----------|
|
||||
| [modrinth-id](#user-content-modrinth-id) | The ID of the Modrinth project to upload to | A value specified in the config file | `AANobbMI` |
|
||||
| [modrinth-token](#user-content-modrinth-token) | A valid token for the Modrinth API | ❌ | `${{ secrets.MODRINTH_TOKEN }}` |
|
||||
| [modrinth-featured](#user-content-modrinth-featured) | Indicates whether the version should be featured on Modrinth or not | `true` | `true` <br> `false` |
|
||||
| [curseforge-id](#user-content-curseforge-id) | The ID of the CurseForge project to upload to | A value specified in the config file | `394468` |
|
||||
| [curseforge-token](#user-content-curseforge-token) | A valid token for the CurseForge API | ❌ | `${{ secrets.CURSEFORGE_TOKEN }}` |
|
||||
| [github-tag](#user-content-github-tag) | The tag name of the release to upload assets to | A tag of the release that triggered the action | `mc1.17.1-0.3.2` |
|
||||
|
@ -218,6 +219,14 @@ A valid token for the Modrinth API. It's required if you want to publish your as
|
|||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
```
|
||||
|
||||
#### modrinth-featured
|
||||
|
||||
Indicates whether the version should be featured on Modrinth or not.
|
||||
|
||||
```yaml
|
||||
modrinth-featured: true
|
||||
```
|
||||
|
||||
#### curseforge-id
|
||||
|
||||
The ID of the CurseForge project to upload to.
|
||||
|
|
|
@ -13,6 +13,10 @@ inputs:
|
|||
description: A valid token for the Modrinth API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
modrinth-featured:
|
||||
description: Indicates whether the version should be featured on Modrinth or not
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
curseforge-id:
|
||||
description: The ID of the CurseForge project to upload to
|
||||
|
|
|
@ -115,8 +115,8 @@ export default abstract class ModPublisher extends Publisher<ModPublisherOptions
|
|||
: metadata?.dependencies || [];
|
||||
const uniqueDependencies = dependencies.filter((x, i, self) => !x.ignore && self.findIndex(y => y.id === x.id && y.kind === x.kind) === i);
|
||||
|
||||
await this.publishMod(id, token, name, version, versionType, loaders, gameVersions, java, changelog, files, uniqueDependencies);
|
||||
await this.publishMod(id, token, name, version, versionType, loaders, gameVersions, java, changelog, files, uniqueDependencies, <Record<string, unknown>><unknown>options);
|
||||
}
|
||||
|
||||
protected abstract publishMod(id: string, token: string, name: string, version: string, versionType: string, loaders: string[], gameVersions: string[], java: string[], changelog: string, files: File[], dependencies: Dependency[]): Promise<void>;
|
||||
protected abstract publishMod(id: string, token: string, name: string, version: string, versionType: string, loaders: string[], gameVersions: string[], java: string[], changelog: string, files: File[], dependencies: Dependency[], options: Record<string, unknown>): Promise<void>;
|
||||
}
|
|
@ -4,6 +4,7 @@ import ModPublisher from "../mod-publisher";
|
|||
import PublisherTarget from "../publisher-target";
|
||||
import Dependency from "../../metadata/dependency";
|
||||
import DependencyKind from "../../metadata/dependency-kind";
|
||||
import { mapBooleanInput } from "../../utils/input-utils";
|
||||
|
||||
const modrinthDependencyKinds = new Map([
|
||||
[DependencyKind.Depends, "required"],
|
||||
|
@ -18,7 +19,8 @@ export default class ModrinthPublisher extends ModPublisher {
|
|||
return PublisherTarget.Modrinth;
|
||||
}
|
||||
|
||||
protected async publishMod(id: string, token: string, name: string, version: string, channel: string, loaders: string[], gameVersions: string[], _java: string[], changelog: string, files: File[], dependencies: Dependency[]): Promise<void> {
|
||||
protected async publishMod(id: string, token: string, name: string, version: string, channel: string, loaders: string[], gameVersions: string[], _java: string[], changelog: string, files: File[], dependencies: Dependency[], options: Record<string, unknown>): Promise<void> {
|
||||
const featured = mapBooleanInput(options.featured, true);
|
||||
const projects = (await Promise.all(dependencies
|
||||
.filter((x, _, self) => (x.kind !== DependencyKind.Suggests && x.kind !== DependencyKind.Includes) || !self.find(y => y.id === x.id && y.kind !== DependencyKind.Suggests && y.kind !== DependencyKind.Includes))
|
||||
.map(async x => ({
|
||||
|
@ -34,6 +36,7 @@ export default class ModrinthPublisher extends ModPublisher {
|
|||
game_versions: gameVersions,
|
||||
version_type: channel,
|
||||
loaders,
|
||||
featured,
|
||||
dependencies: projects
|
||||
};
|
||||
await createVersion(id, data, files, token);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { jest, describe, test, expect } from "@jest/globals";
|
||||
import { describe, test, expect } from "@jest/globals";
|
||||
import { getProject } from "../src/utils/modrinth-utils";
|
||||
|
||||
describe("getProject", () => {
|
||||
test("returned versions have expected ids", async () => {
|
||||
jest.setTimeout(15000);
|
||||
const projects = {
|
||||
"sodium": "AANobbMI",
|
||||
"fabric-api": "P7dR8mSH",
|
||||
|
@ -16,10 +15,9 @@ describe("getProject", () => {
|
|||
const project = await getProject(slug);
|
||||
expect(project).toHaveProperty("id", id);
|
||||
}
|
||||
});
|
||||
}, 15000);
|
||||
|
||||
test("the method returns null if project with the given slug does not exist", async () => {
|
||||
jest.setTimeout(15000);
|
||||
const nonExistentProjects = [
|
||||
"Na-11",
|
||||
"api-fabric",
|
||||
|
@ -33,5 +31,5 @@ describe("getProject", () => {
|
|||
const project = await getProject(slug);
|
||||
expect(project).toBeNull();
|
||||
}
|
||||
});
|
||||
}, 15000);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue