Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ async function getMods(modQueryService: ModQueryService, options: CliOptions): P
const modsMap = new Map<string, ModMetadata>();

if (options.modId) {
for (const id of options.modId) {
let [repoName, modId] = id.split('/');
for (const repoAndId of options.modId) {
let [repoName, modId] = repoAndId.split('/');
if (!modId) {
logger.error(`Invalid mod ID format: ${id}. Expected format is 'repository/modId'.`);
logger.error(`Invalid mod ID format: ${repoAndId}. Expected format is 'repository/modId'.`);
continue;
}

Expand All @@ -94,12 +94,13 @@ async function getMods(modQueryService: ModQueryService, options: CliOptions): P

// Add mod to map
if (modsMap.has(fullId)) {
logger.warn(`Duplicate mod ID from --mod-id: ${id}`);
logger.warn(`Duplicate mod ID from --mod-id: ${repoAndId}`);
} else {
modsMap.set(fullId, [{
id: modId,
repository: repo.getRepositoryName(),
name: id,
id: modId,
slug: repoAndId,
name: repoAndId,
homepageURL: "",
imageURL: "",
downloadCount: 0
Expand Down Expand Up @@ -243,7 +244,7 @@ program

logger.info(` Unsupported mods (${unsupportedModsMeta.length}):`);
for (const modMeta of unsupportedModsMeta) {
logger.info(` - ${modMeta[0].id} (${modMeta[0].name})`);
logger.info(` - ${modMeta[0].slug} (${modMeta[0].name})`);
}

}
Expand Down
3 changes: 2 additions & 1 deletion mclib/src/finder/LocalSolutionFinder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ function releaseMatchConstraints(
// Helper to create test ModRepoMetadata
function newTestMetadata(id: string, repository: ModRepositoryName): ModRepoMetadata {
return {
id,
repository,
id,
slug: id,
name: id,
homepageURL: '',
imageURL: '',
Expand Down
8 changes: 6 additions & 2 deletions mclib/src/repos/CurseForgeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class CurseForgeRepository implements IRepository {
type Data = {
data: {
id: number;
slug: string;
name: string;
links: {
websiteUrl: string;
Expand All @@ -80,8 +81,9 @@ export class CurseForgeRepository implements IRepository {
const jsonResp: Data = (await resp.json());

return jsonResp.data.map(mod => ({
id: mod.id.toString(),
repository: ModRepositoryName.CURSEFORGE,
id: mod.id.toString(),
slug: mod.slug,
name: mod.name,
homepageURL: mod.links.websiteUrl,
imageURL: mod.logo.url,
Expand Down Expand Up @@ -128,8 +130,9 @@ export class CurseForgeRepository implements IRepository {
if (!modInfo) return null;

return {
id: modId.toString(),
repository: ModRepositoryName.CURSEFORGE,
id: modId.toString(),
slug: modInfo.slug,
name: modInfo.name,
homepageURL: modInfo.links.websiteUrl,
imageURL: modInfo.logo?.url || "",
Expand All @@ -144,6 +147,7 @@ export class CurseForgeRepository implements IRepository {

type ModInfoData = {
id: number;
slug: string;
name: string;
links: {
websiteUrl: string;
Expand Down
6 changes: 4 additions & 2 deletions mclib/src/repos/ModrinthRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export class ModrinthRepository implements IRepository {
const jsonResp: Data = await resp.json();

return jsonResp.hits.map(hit => ({
id: hit.slug,
repository: ModRepositoryName.MODRINTH,
id: hit.slug,
slug: hit.slug,
name: hit.title,
homepageURL: "https://modrinth.com/mod/" + hit.slug,
imageURL: hit.icon_url || "",
Expand All @@ -85,8 +86,9 @@ export class ModrinthRepository implements IRepository {
const projectData = await projectResp.json();

return {
id: projectData.slug,
repository: ModRepositoryName.MODRINTH,
id: projectData.slug,
slug: projectData.slug,
name: projectData.title,
homepageURL: "https://modrinth.com/mod/" + projectData.slug,
imageURL: projectData.icon_url || "",
Expand Down
3 changes: 2 additions & 1 deletion mclib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export class ModMetadataUtil {

/** Represents metadata for a mod search result, for a given repository */
export type ModRepoMetadata = {
id: string;
repository: ModRepositoryName;
id: string;
slug: string;
name: string; // user-facing name
homepageURL: string;
imageURL: string;
Expand Down