API reference / @jsprismarine/addon-tools / build
build
Interfaces
BuildAddonsOptions
Defined in: build.ts:66
Options for buildAddons.
Properties
addonsDirectory
readonlyaddonsDirectory:string
Defined in: build.ts:68
The folder that holds one folder per addon.
baseUrl
readonlybaseUrl:string
Defined in: build.ts:72
Where the release serves its files from, an https: URL.
outDirectory
readonlyoutDirectory:string
Defined in: build.ts:70
Where the packs and index.json are written.
published?
readonlyoptionalpublished?:AddonIndex
Defined in: build.ts:74
The index already published, merged with the build's entries; none before a first release.
BuildAddonsResult
Defined in: build.ts:78
What buildAddons wrote.
Properties
added
readonlyadded: readonlyAddonIndexEntry[]
Defined in: build.ts:84
The built entries the published index lacks: the packs a release has to upload.
addedListingFiles
readonlyaddedListingFiles: readonlystring[]
Defined in: build.ts:86
The listing files of the added entries, in index order: what a release uploads beside their packs.
built
readonlybuilt: readonlyAddonIndexEntry[]
Defined in: build.ts:82
One entry for each addon built, in name order.
index
readonlyindex:AddonIndex
Defined in: build.ts:80
The index written to index.json: the published one plus every addon built.
warnings
readonlywarnings: readonlystring[]
Defined in: build.ts:88
Each addon whose commands could not be read, and why. Its listing goes without them.
Functions
buildAddons()
buildAddons(
options):Promise<BuildAddonsResult>
Defined in: build.ts:135
Builds every addon in a folder: compiles the TypeScript ones with compileAddons, reads them with readAddons, merges their entries into the published index, then writes each pack into the output folder as <name>-<version>.mcpack, its listing files beside it, and index.json. Each listing records the commands the addon's scripts register, read with readAddonCommands; an addon whose commands cannot be read is built without them, and the result's warnings say why. A build it refuses writes nothing to the output folder, so it keeps the last good build.
Parameters
options
Returns
Promise<BuildAddonsResult>
Throws
When an addon is invalid or does not compile, or a built version is published with other contents.
Throws
InvalidBaseUrl when the base URL is not an https: URL.
compileAddons()
compileAddons(
addonsDirectory):Promise<void>
Defined in: build.ts:110
Compiles every TypeScript addon in a folder with compileAddon, in name order, so that readAddons reads scripts built from the current sources.
Parameters
addonsDirectory
string
Returns
Promise<void>
Throws
AddonCompileFailed when an addon's scripts do not compile.
fetchPublishedIndex()
fetchPublishedIndex(
baseUrl,fetcher?):Promise<AddonIndex|undefined>
Defined in: build.ts:58
Downloads the index a release publishes. When the release has no index.json but has the ADDON_INDEX_BACKUP_FILE a failed upload left, it reads that instead, so a build after the failure keeps every published version.
Parameters
baseUrl
string
Where the release's files download from, as releaseDownloadUrl gives.
fetcher?
(input, init?) => Promise<Response>
What downloads it; the global fetch unless a caller routes requests itself.
Returns
Promise<AddonIndex | undefined>
The index, or undefined when the release has neither file yet.
Throws
When the index does not follow the schema.
readAddons()
readAddons(
addonsDirectory):Promise<Addon[]>
Defined in: build.ts:98
Reads and checks every addon in a folder with readAddon, in name order. Every folder directly under addonsDirectory is an addon, except those whose names start with a dot; files there, such as a README, are skipped.
Parameters
addonsDirectory
string
Returns
Promise<Addon[]>
Throws
When an addon is invalid.
releaseDownloadUrl()
releaseDownloadUrl(
repository):string
Defined in: build.ts:25
Where a GitHub repository's addon release serves its files from.
Parameters
repository
string
<owner>/<repo>.
Returns
string