@mctools/curseforge
v1.1.3
Published
Lib for working with CurseForge using minecraftinstance.json
Maintainers
Readme
Lib for working with CurseForge using minecraftinstance.json
Bunch of functions, used for other @mctools/ packages, such as fetching info for several mods at once.
Usage
API
- Install package
npm i @mctools/curseforge
- Import functions from package.
import fnc from '@mctools/curseforge'
functions
asAddonID
asAddonID(
n):AddonID
Assert-cast a plain number into a branded AddonID.
nnumber
Returns: AddonID
asFileID
asFileID(
n):FileID
Assert-cast a plain number into a branded FileID.
nnumber
Returns: FileID
fetchChangelog
fetchChangelog(
entry,cfApiKey):Promise<string>
Fetch a single file changelog from CurseForge.
entryChangelogEntry— Object with modId and fileIdcfApiKeystring— CurseForge API key
Returns: Promise<string> — Changelog HTML string, or empty string if not found
fetchChangelogs
fetchChangelogs(
entries,cfApiKey,doLogging?,concurrency?):Promise<Map<number,string>>
Fetch changelogs for specific mod files from CurseForge. Requests are executed in parallel with a concurrency limit.
entriesChangelogEntry[] — Array of { modId, fileId } objectscfApiKeystring— CurseForge API keydoLogging?boolean=false— Log progress into stdoutconcurrency?number=15— Maximum number of concurrent requests (default: 10)
Returns: Promise<Map<number, string>> — Map of fileId → changelog HTML string
fetchFile
fetchFile(
modId,fileId,cfApiKey):Promise<CF2File|undefined>
Fetch metadata for a single file.
modIdnumber— Mod ID the file belongs tofileIdnumber— File IDcfApiKeystring— CurseForge API key
Returns: Promise<CF2File | undefined> — File metadata
fetchFiles
fetchFiles(
fileIds,cfApiKey):Promise<CF2File[]>
Fetch metadata for multiple files at once using the batch endpoint.
fileIdsnumber[] — Array of file IDscfApiKeystring— CurseForge API key
Returns: Promise<CF2File[]> — Array of file metadata
fetchIntermediateFileChangelogs
fetchIntermediateFileChangelogs(
modId,oldFileId,newFileId,cfApiKey,doLogging?,gameVersion?,maxFiles?,concurrency?,includeExtraBefore?):Promise<{changelogs:FileChangelog[];extraBefore?:FileChangelog; }>
Fetch all file changelogs between two file versions of a mod. Files are ordered by upload date and filtered to include only those strictly after oldFileId and up to newFileId. Changelog requests are executed in parallel with a concurrency limit.
modIdnumberoldFileIdnumbernewFileIdnumbercfApiKeystringdoLogging?boolean=falsegameVersion?stringmaxFiles?number=15concurrency?number=15includeExtraBefore?boolean
Returns: Promise<{ changelogs: FileChangelog[]; extraBefore?: FileChangelog; }>
fetchMod
fetchMod(
modId,cfApiKey,timeout?,doLogging?):Promise<CF2Addon>
Fetch a single mod from CurseForge.
modIdnumber— ID of the mod to fetchcfApiKeystring— CurseForge API keytimeout?number=96— Cache timeout in hoursdoLogging?boolean=false— Log into stdout
Returns: Promise<CF2Addon>
fetchMods
fetchMods(
modIds,cfApiKey,timeout?,doLogging?):Promise<CF2Addon[]>
Get mod information from CurseForge, such as name, summary, download count, etc.
modIdsnumber[] — IDs of mods you want to fetch.[32274, 59751, 59816]cfApiKeystring— CurseForge API key. Get one at https://console.curseforge.com/?#/api-keystimeout?number=96— If file was already fetched lasttimeouthours, it would be loaded from cache filedoLogging?boolean=false— Log into stdout
Returns: Promise<CF2Addon[]> — Object with information about mods
loadFromCF
loadFromCF(
modIds,cfApiKey):Promise<CF2Addon[]>
modIdsnumber[]cfApiKeystring
Returns: Promise<CF2Addon[]>
loadMCInstanceFiltered
loadMCInstanceFiltered(
mci,ignore?):Minecraftinstance
Load a filtered view of a minecraftinstance.json object.
Returns a shallow-cloned instance with installedAddons narrowed to
on-CF, non-ignored mods. The original mci is not mutated.
mciMinecraftinstance— Parsedminecraftinstance.json.ignore?string|Ignore| readonly (string|Ignore)[] — .gitignore-like content — mods matching these patterns (bymods/<file>) are excluded.
Returns: Minecraftinstance
modListDiff
modListDiff(
fresh,old,ignore?):ModsComparison
Compare two minecraftinstance.json snapshots and return a full breakdown
(added, removed, both, updated, plus the total union).
Use this when you have the previous version to diff against, typically for generating a changelog.
freshMinecraftinstanceoldMinecraftinstanceignore?string|Ignore| readonly (string|Ignore)[]
Returns: ModsComparison
modListUnion
modListUnion(
fresh,ignore?):ModsUnion
Collect the full set of addons from a single minecraftinstance, after
applying the same .gitignore-style filter as modListDiff.
Use this when you don't have a previous instance to compare against.
freshMinecraftinstanceignore?string|Ignore| readonly (string|Ignore)[]
Returns: ModsUnion
setCachePath
setCachePath(
path):void
Override the file the CF mod cache reads/writes. Defaults to ~/.cache/mctools/curseforge-mods.json.
pathstring
Returns: void
Author
- https://github.com/Krutoy242
Other tools
- @mctools/errors - Scan debug.log file to find unknown errors
- @mctools/format - Format .zs files by using ESLint for typescript
- @mctools/manifest -
manifest.jsongeneration tool - @mctools/modlist - Generate .md file with all mods listed
- @mctools/reducer - Partially disable minecraft mods
- @mctools/source - Locate, clone or decompile Minecraft mod source code
- @mctools/tcon - Tweaks Tinker Constructs' materials with csv tables
