Skip to content

Commit dfda17c

Browse files
misterpottsMatt Potts
andauthored
Feat: Data download for debugging (#198)
Co-authored-by: Matt Potts <matt@@mrpotts.uk>
1 parent dcf344d commit dfda17c

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
title: Fabricate 0.10.4
1+
title: Fabricate 0.10.5
22
33
description: >-
44
End user documentation for the Foundry Virtual Tabletop (VTT) Module, "Fabricate".

docs/api/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ interface FabricateAPI {
144144
*/
145145
export(craftingSystemId: string): Promise<FabricateExportModel>;
146146

147+
/**
148+
* Downloads a copy of all Fabricate data as a JSON file. This function is used for debugging and troubleshooting.
149+
* If you want to export data from Fabricate for use in another Foundry VTT world, use {@link FabricateAPI#export}
150+
*/
151+
downloadData(): void;
152+
147153
}
148154
```
149155

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fabricate",
3-
"version": "0.10.4",
3+
"version": "0.10.5",
44
"description": "A system-agnostic, flexible crafting module for FoundryVT",
55
"main": "index.js",
66
"type": "module",

src/scripts/api/FabricateAPI.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ interface FabricateAPI {
211211
*/
212212
export(craftingSystemId: string): Promise<FabricateExportModel>;
213213

214+
/**
215+
* Downloads a copy of all Fabricate data as a JSON file. This function is used for debugging and troubleshooting.
216+
* If you want to export data from Fabricate for use in another Foundry VTT world, use {@link FabricateAPI#export}
217+
*/
218+
downloadData(): void;
219+
214220
}
215221

216222
export { FabricateAPI }
@@ -259,6 +265,18 @@ class DefaultFabricateAPI implements FabricateAPI {
259265
this.settingMigrationAPI = settingMigrationAPI;
260266
}
261267

268+
downloadData(): void {
269+
const allFabricateSettingValues = Array.from(game.settings.storage.get("world").values())
270+
.filter((setting: any) => setting.key.search(new RegExp("fabricate", "i")) >= 0);
271+
const fileContents = JSON.stringify(allFabricateSettingValues, null, 2);
272+
const dateTime = new Date();
273+
const postfix = dateTime.toISOString()
274+
.replace(/:\s*/g, "-")
275+
.replace(".", "-");
276+
const fileName = `fabricate-data-extract-${postfix}.json`;
277+
saveDataToFile(fileContents, "application/json", fileName);
278+
}
279+
262280
get documentManager(): DocumentManager {
263281
return this._documentManager;
264282
}
@@ -448,7 +466,6 @@ class DefaultFabricateAPI implements FabricateAPI {
448466

449467
async import(importData: FabricateExportModel): Promise<CraftingSystemData> {
450468

451-
452469
importData = this.upgradeV1ImportData(importData);
453470
await this.validateImportData(importData);
454471

0 commit comments

Comments
 (0)