mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 01:41:05 -05:00
parent
3eb68e07b5
commit
21760b2c91
5 changed files with 13 additions and 10 deletions
|
@ -50,7 +50,9 @@ export class CurseForgeUploader extends GenericPlatformUploader<CurseForgeUpload
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected async uploadCore(request: CurseForgeUploadRequest): Promise<CurseForgeUploadReport> {
|
protected async uploadCore(request: CurseForgeUploadRequest): Promise<CurseForgeUploadReport> {
|
||||||
ArgumentError.throwIfNullOrEmpty(request.id, "request.id");
|
ArgumentError.throwIfNullOrEmpty(request.id, "request.id", "A project ID is required to upload files to CurseForge.");
|
||||||
|
ArgumentError.throwIfNullOrEmpty(request.loaders, "request.loaders", "At least one loader should be specified to upload files to CurseForge.");
|
||||||
|
ArgumentError.throwIfNullOrEmpty(request.gameVersions, "request.gameVersions", "At least one game version should be specified to upload files to CurseForge.");
|
||||||
|
|
||||||
const api = new CurseForgeUploadApiClient({ token: request.token.unwrap(), fetch: this._fetch });
|
const api = new CurseForgeUploadApiClient({ token: request.token.unwrap(), fetch: this._fetch });
|
||||||
const eternalApi = new CurseForgeEternalApiClient({ fetch: this._fetch });
|
const eternalApi = new CurseForgeEternalApiClient({ fetch: this._fetch });
|
||||||
|
|
|
@ -154,8 +154,8 @@ export abstract class GenericPlatformUploader<TOptions extends GenericPlatformUp
|
||||||
*/
|
*/
|
||||||
async upload(request: TRequest): Promise<TReport> {
|
async upload(request: TRequest): Promise<TReport> {
|
||||||
ArgumentNullError.throwIfNull(request, "request");
|
ArgumentNullError.throwIfNull(request, "request");
|
||||||
ArgumentNullError.throwIfNull(request.token, "request.token");
|
ArgumentNullError.throwIfNull(request.token, "request.token", `A token is required to upload files to ${PlatformType.friendlyNameOf(this.platform)}.`);
|
||||||
ArgumentNullError.throwIfNullOrEmpty(request.files, "request.files");
|
ArgumentNullError.throwIfNullOrEmpty(request.files, "request.files", "No files to upload were specified. Please include at least one file in the request.");
|
||||||
|
|
||||||
const platformName = PlatformType.friendlyNameOf(this.platform);
|
const platformName = PlatformType.friendlyNameOf(this.platform);
|
||||||
const maxAttempts = request.retryAttempts ?? DEFAULT_RETRY_ATTEMPTS;
|
const maxAttempts = request.retryAttempts ?? DEFAULT_RETRY_ATTEMPTS;
|
||||||
|
|
|
@ -42,12 +42,8 @@ export class GitHubUploader extends GenericPlatformUploader<GitHubUploaderOption
|
||||||
* @param options - The options to use for the uploader.
|
* @param options - The options to use for the uploader.
|
||||||
*/
|
*/
|
||||||
constructor(options: GitHubUploaderOptions) {
|
constructor(options: GitHubUploaderOptions) {
|
||||||
ArgumentNullError.throwIfNull(options, "options");
|
|
||||||
ArgumentNullError.throwIfNull(options.githubContext, "options.githubContext");
|
|
||||||
ArgumentNullError.throwIfNull(options.githubContext.repo, "options.githubContext.repo");
|
|
||||||
|
|
||||||
super(options);
|
super(options);
|
||||||
this._context = options.githubContext;
|
this._context = options?.githubContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +57,8 @@ export class GitHubUploader extends GenericPlatformUploader<GitHubUploaderOption
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected async uploadCore(request: GitHubUploadRequest): Promise<GitHubUploadReport> {
|
protected async uploadCore(request: GitHubUploadRequest): Promise<GitHubUploadReport> {
|
||||||
|
ArgumentNullError.throwIfNull(this._context?.repo, "context.repo", "The information about the repository is required to upload files to GitHub.");
|
||||||
|
|
||||||
const api = new GitHubApiClient({ token: request.token.unwrap(), fetch: this._fetch, baseUrl: this._context.apiUrl });
|
const api = new GitHubApiClient({ token: request.token.unwrap(), fetch: this._fetch, baseUrl: this._context.apiUrl });
|
||||||
const repo = this._context.repo;
|
const repo = this._context.repo;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,10 @@ export class ModrinthUploader extends GenericPlatformUploader<ModrinthUploaderOp
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected async uploadCore(request: ModrinthUploadRequest): Promise<ModrinthUploadReport> {
|
protected async uploadCore(request: ModrinthUploadRequest): Promise<ModrinthUploadReport> {
|
||||||
ArgumentError.throwIfNullOrEmpty(request.id, "request.id");
|
ArgumentError.throwIfNullOrEmpty(request.id, "request.id", "A project ID is required to upload files to Modrinth.");
|
||||||
|
ArgumentError.throwIfNullOrEmpty(request.version, "request.version", "A version number is required to upload files to Modrinth.");
|
||||||
|
ArgumentError.throwIfNullOrEmpty(request.loaders, "request.loaders", "At least one loader should be specified to upload files to Modrinth.");
|
||||||
|
ArgumentError.throwIfNullOrEmpty(request.gameVersions, "request.gameVersions", "At least one game version should be specified to upload files to Modrinth.");
|
||||||
|
|
||||||
const api = new ModrinthApiClient({ token: request.token.unwrap(), fetch: this._fetch });
|
const api = new ModrinthApiClient({ token: request.token.unwrap(), fetch: this._fetch });
|
||||||
const unfeatureMode = request.unfeatureMode ?? (request.featured ? ModrinthUnfeatureMode.SUBSET : ModrinthUnfeatureMode.NONE);
|
const unfeatureMode = request.unfeatureMode ?? (request.featured ? ModrinthUnfeatureMode.SUBSET : ModrinthUnfeatureMode.NONE);
|
||||||
|
|
|
@ -99,7 +99,7 @@ async function publish(action: Action, githubContext: GitHubContext, logger: Log
|
||||||
* @returns A promise that resolves to the options with default values filled in.
|
* @returns A promise that resolves to the options with default values filled in.
|
||||||
*/
|
*/
|
||||||
async function fillInDefaultValues<T extends McPublishInput[P], P extends PlatformType>(options: T, platform: P, githubContext: GitHubContext, reader?: LoaderMetadataReader): Promise<T> {
|
async function fillInDefaultValues<T extends McPublishInput[P], P extends PlatformType>(options: T, platform: P, githubContext: GitHubContext, reader?: LoaderMetadataReader): Promise<T> {
|
||||||
ArgumentError.throwIfNullOrEmpty(options.files, "options.files");
|
ArgumentError.throwIfNullOrEmpty(options.files, "options.files", "No files found for the specified glob. Please ensure the glob is correct and files matching the pattern exist in the specified directory.");
|
||||||
|
|
||||||
options = { ...options };
|
options = { ...options };
|
||||||
const primaryFile = options.files[0];
|
const primaryFile = options.files[0];
|
||||||
|
|
Loading…
Reference in a new issue