Skip to content
Open
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
53 changes: 53 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { CompileOptions, ExtractOptions } from "./lib/package.mjs";

declare module "foundryvtt-cli" {
/**
* A mapping of primary document types to collection names.
* @type {Record<DocumentType, DocumentCollection>}
*/
export const TYPE_COLLECTION_MAP: Record<string, string> = {
Actor: "actors",
Adventure: "adventures",
Cards: "cards",
ChatMessage: "messages",
Combat: "combats",
FogExploration: "fog",
Folder: "folders",
Item: "items",
JournalEntry: "journal",
Macro: "macros",
Playlist: "playlists",
RollTable: "tables",
Scene: "scenes",
Setting: "settings",
User: "users",
};

/**
* Compile source files into a compendium pack.
* @param {string} src The directory containing the source files.
* @param {string} dest The target compendium pack. This should be a directory for LevelDB packs, or a .db file for
* NeDB packs.
* @param {CompileOptions} [options]
* @returns {Promise<void>}
*/
export function compilePack(
src: string,
dest: string,
options: CompileOptions
): Promise<void>;

/**
* Extract the contents of a compendium pack into individual source files for each primary Document.
* @param {string} src The source compendium pack. This should be a directory for LevelDB pack, or a .db file for
* NeDB packs.
* @param {string} dest The directory to write the extracted files into.
* @param {ExtractOptions} [options]
* @returns {Promise<void>}
*/
export async function extractPack(
src: string,
dest: string,
options: ExtractOptions
): Promise<void>;
}
6 changes: 5 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { compilePack, extractPack } from "./lib/package.mjs";
export {
compilePack,
extractPack,
TYPE_COLLECTION_MAP,
} from "./lib/package.mjs";
2 changes: 1 addition & 1 deletion lib/package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ async function compileClassicLevel(pack, files, { log, transformEntry }={}) {
const ext = path.extname(file);
const isYaml = ext === ".yml" || ext === ".yaml";
const doc = isYaml ? YAML.load(contents) : JSON.parse(contents);
const [, collection] = doc._key.split("!");
if ( await transformEntry?.(doc) === false ) continue;
const [, collection] = doc._key.split("!");
await packDoc(doc, collection);
if ( log ) console.log(`Packed ${chalk.blue(doc._id)}${chalk.blue(doc.name ? ` (${doc.name})` : "")}`);
} catch ( err ) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@foundryvtt/foundryvtt-cli",
"name": "foundryvtt-cli",
"productName": "Foundry VTT CLI",
"description": "The Official CLI for Foundry VTT",
"version": "0.0.5",
"version": "1.0.4",
"author": {
"name": "Foundry Gaming LLC",
"email": "admin@foundryvtt.com",
"url": "https://foundryvtt.com"
},
"types": "index.d.ts",
"main": "index.mjs",
"bin": {
"fvtt": "fvtt.mjs"
Expand Down