From 832e357cf884302ba60105ca9ab6c2c11626ab21 Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Tue, 6 Aug 2024 16:20:35 -0500 Subject: [PATCH 1/7] Compile Classic Level - Transform Entry First When compiling a classic level database transform the entry before attempting to access the contents. This allows you to not have to put a _key in the files and instead can be generated using transformEntry. --- lib/package.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/package.mjs b/lib/package.mjs index 260a324..7b41ba3 100644 --- a/lib/package.mjs +++ b/lib/package.mjs @@ -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 ) { From 7b40a0bb083a65691d18d9543105d5e130380469 Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 18:53:04 -0500 Subject: [PATCH 2/7] Export Types --- index.d.ts | 2 ++ package.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..b9657c1 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,2 @@ +import type * as Types from "./lib/package.mjs"; +export { Types }; \ No newline at end of file diff --git a/package.json b/package.json index 0901e55..27675e6 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,13 @@ "name": "@foundryvtt/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" From b71142a92ffb98da94bbdcd1a8c02473ca8e4064 Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 18:56:43 -0500 Subject: [PATCH 3/7] Update Package Name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27675e6..86a961c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@foundryvtt/foundryvtt-cli", + "name": "foundryvtt-cli", "productName": "Foundry VTT CLI", "description": "The Official CLI for Foundry VTT", "version": "1.0.4", From 704c793e00d26214f4cb0bfdf841e7baa3cd8ae9 Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 19:02:40 -0500 Subject: [PATCH 4/7] Update Exports --- index.d.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index b9657c1..2b81fd4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,2 +1,17 @@ -import type * as Types from "./lib/package.mjs"; -export { Types }; \ No newline at end of file +import { CompileOptions } from "./lib/package.mjs"; + +declare module "foundryvtt-cli" { + /** + * 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} + */ + export function compilePack( + src: string, + dest: string, + options: CompileOptions + ): Promise; +} From debfb107ebddcadcd4210158921002b0daad7ddc Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 19:08:09 -0500 Subject: [PATCH 5/7] Fix Exports --- index.d.ts | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 2b81fd4..1ed3908 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,28 @@ -import { CompileOptions } from "./lib/package.mjs"; +import { CompileOptions, ExtractOptions } from "./lib/package.mjs"; declare module "foundryvtt-cli" { + /** + * A mapping of primary document types to collection names. + * @type {Record} + */ + export const TYPE_COLLECTION_MAP = { + 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. @@ -14,4 +36,18 @@ declare module "foundryvtt-cli" { dest: string, options: CompileOptions ): Promise; + + /** + * 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} + */ + export async function extractPack( + src: string, + dest: string, + options: ExtractOptions + ): Promise; } From 4acb57c77c9360be71deeb6d8c04991501a61dae Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 19:12:42 -0500 Subject: [PATCH 6/7] Update Types --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 1ed3908..c533a54 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,7 +5,7 @@ declare module "foundryvtt-cli" { * A mapping of primary document types to collection names. * @type {Record} */ - export const TYPE_COLLECTION_MAP = { + export const TYPE_COLLECTION_MAP: Record = { Actor: "actors", Adventure: "adventures", Cards: "cards", From f683c77323fb4c08bc3e9fc4ff4a4e01ee56c600 Mon Sep 17 00:00:00 2001 From: 7H3LaughingMan <7H3LaughingMan@proton.me> Date: Sun, 20 Oct 2024 19:13:45 -0500 Subject: [PATCH 7/7] Update Exports --- index.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.mjs b/index.mjs index 372d936..566c85b 100644 --- a/index.mjs +++ b/index.mjs @@ -1 +1,5 @@ -export { compilePack, extractPack } from "./lib/package.mjs"; +export { + compilePack, + extractPack, + TYPE_COLLECTION_MAP, +} from "./lib/package.mjs"; \ No newline at end of file