diff --git a/src/parser.ts b/src/parser.ts index f4b88af..316ee52 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -1,5 +1,5 @@ import * as toml from "toml"; -import Resource from "./resource"; +import { Resource } from "./resource"; import { UrlProvider, ModrinthProvider, @@ -155,7 +155,7 @@ export class Packwiz { /** * Parses a packwiz.toml file and returns its contents. * - * @param indexFilePath - The path of the TOML file. + * @param filePath - The path of the TOML file. * @returns The parsed file as a structured class. */ export async function parsePackwiz(filePath: string): Promise { diff --git a/src/provider.ts b/src/provider.ts index dee739e..82e8ad0 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -1,15 +1,36 @@ -import Resource from "./resource"; +import { Resource } from "./resource"; import { HashFormat } from "./enums/hash-format"; +/** + * Provides a base class for URL-based providers. + */ export class UrlProvider { + /** + * Creates a new UrlProvider instance. + * @param hash - A hash string used for identifying or verifying the resource. + * @param hashFormat - The format of the provided hash. + * @param url - A Resource instance representing the URL. + */ constructor( public hash: string, public hashFormat: HashFormat, public url: Resource, - ) {} + ) { } } +/** + * URL provider for handling Modrinth-related URLs. + * Extends the UrlProvider with Modrinth-specific properties. + */ export class ModrinthProvider extends UrlProvider { + /** + * Creates a new ModrinthProvider instance. + * @param hash - A hash string used for identification or verification. + * @param hashFormat - The format of the provided hash. + * @param url - A Resource instance representing the URL. + * @param modId - The identifier for the Modrinth mod. + * @param versionId - The version identifier for the mod. + */ constructor( hash: string, hashFormat: HashFormat, @@ -21,7 +42,21 @@ export class ModrinthProvider extends UrlProvider { } } +/** + * URL provider for handling GitHub-related URLs. + * Extends the UrlProvider with GitHub-specific properties. + */ export class GitHubProvider extends UrlProvider { + /** + * Creates a new GitHubProvider instance. + * @param hash - A hash string used for identification or verification. + * @param hashFormat - The format of the hash. + * @param url - A Resource instance representing the URL. + * @param branch - The branch name within the GitHub repository. + * @param regex - A regular expression for matching specific patterns in the GitHub URL. + * @param slug - A URL slug used for identifying the repository. + * @param tag - The tag associated with the GitHub resource. + */ constructor( hash: string, hashFormat: HashFormat, @@ -35,7 +70,19 @@ export class GitHubProvider extends UrlProvider { } } +/** + * URL provider for handling CurseForge-related URLs. + * Extends the UrlProvider with CurseForge-specific properties. + */ export class CurseForgeProvider extends UrlProvider { + /** + * Creates a new CurseForgeProvider instance. + * @param hash - A hash string used for identification or verification. + * @param hashFormat - The format of the provided hash. + * @param mode - The mode indicating how the CurseForge file should be accessed. + * @param fileId - The identifier for the file on CurseForge. + * @param projectId - The identifier for the project on CurseForge. + */ constructor( hash: string, hashFormat: HashFormat, diff --git a/src/resource.ts b/src/resource.ts index 681ea0d..9b89079 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -2,8 +2,8 @@ import * as fs from "fs/promises"; import { URL } from "url"; import * as path from "path"; -export default class Resource { - constructor(public readonly path: string) {} +export class Resource { + constructor(public readonly path: string) { } toString(): string { return this.path;