@mctools/curseforge
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@mctools/curseforge

Lib for working with CurseForge using minecraftinstance.json

Usage

API

  1. Install package
npm i @mctools/curseforge
  1. Import functions from package.
import fnc from "@mctools/curseforge"

Functions

fetchMods

fetchMods(modIds, cfApiKey, timeout?, doLogging?): Promise<CFV2.CF2Addon[]>

Get mod information from CurseForge, such as name, summary, download count, etc.

Parameters
Name Type Default value Description
modIds number[] undefined IDs of mods you want to fetch. [32274, 59751, 59816]
cfApiKey string undefined CurseForge API key. Get one at https://console.curseforge.com/?#/api-keys
timeout number 96 If file was already fetched last timeout hours, it would be loaded from cache file
doLogging boolean false Log into stdout
Returns

Promise<CFV2.CF2Addon[]>

Object with information about mods

Example

const cfMods = await fetchMods([32274, 59751, 59816], key)
console.log(cfMods.map(m => m.name)) // ["JourneyMap", "Forestry", "Random Things"]

loadMCInstanceFiltered

loadMCInstanceFiltered(mci, ignore?): Minecraftinstance

Load minecraftinstance.json file from disk, filtering unavailable or ignored mods

Parameters
Name Type Description
mci Minecraftinstance Json object of minecraftinstance.json
ignore? string | Ignore | readonly (string | Ignore)[] .gitignore-like file content with mods to ignore. For example, ignore contains 3 lines: ts const mci = loadMCInstanceFiltered(mciPath, ` scripts/debug config/FBP/* mods/tellme-* `) Since it have line mods/tellme-* in it, mod tellme-1.12.2-0.7.0.jar would be removed from result.
Returns

Minecraftinstance

Same minecraftinstance object but without unavailable on CF mods like Optifine or Nutrition.


modList

modList(fresh, old?, ignore?): ModsUnion

Compare two minecraftinstance.json files and output differences between them

Parameters
Name Type Description
fresh Minecraftinstance Json object from minecraftinstance.json of current version
old? undefined Json object from minecraftinstance.json of previous version.
ignore? string | Ignore | readonly (string | Ignore)[] .gitignore-like file content with mods to ignore. Useful for dev-only mods that should not be included in result.
Returns

ModsUnion

Result of comparsion. if old is omited, returns only union field.

modList(fresh, old?, ignore?): ModsComparsion

Parameters
Name Type
fresh Minecraftinstance
old? Minecraftinstance
ignore? string | Ignore | readonly (string | Ignore)[]
Returns

ModsComparsion

Author

Other tools

Package Sidebar

Install

npm i @mctools/curseforge

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

31.5 kB

Total Files

9

Last publish

Collaborators

  • krutoy242