macros icon indicating copy to clipboard operation
macros copied to clipboard

Look into Github Actions that can automatically create the .db files after a merge

Open AnthonyVadala opened this issue 4 years ago • 8 comments

Originally posted by @shawndibble in https://github.com/foundry-vtt-community/macros/issues/16#issuecomment-632374382

AnthonyVadala avatar Jun 29 '20 19:06 AnthonyVadala

may want to look into github actions that can automatically create the .db files after a merge.

It is something on my radar and would make management of the packs WAY easier, but as of right now directly entering data into a .db file causes a bunch of data corruption errors in the debug log of Foundry.

So once a better method of editing .db files becomes available I'll be all over it!

Originally posted by @AnthonyVadala in https://github.com/foundry-vtt-community/macros/issues/16#issuecomment-633085631

AnthonyVadala avatar Jun 29 '20 19:06 AnthonyVadala

I created a strawpoll for the community to vote on a temporary sorting solution for this module while folder organization within Compendium Packs is being added to Foundry VTT : https://www.strawpoll.me/20468759

AnthonyVadala avatar Jun 29 '20 22:06 AnthonyVadala

What is your current method of manually creating the .db files? Knowing each step you take to create the .db files may help with the automation.

shawndibble avatar Jul 06 '20 16:07 shawndibble

Right now I load up the community macros modules on a test Foundry instance and pretty just copy and paste any changes into the specific module in the compendium. If it is a new macro I create it from the macro bar and drag it to the compendium pack.

When I last tried to automate the process, after my bash script failed, I tried to manually create a macro entry in a blank .db file then when I placed it in my test instance I would get database corruption errors from the console. Even copying and pasting an entry from a working .db file to my test file would cause the .db corruption errors when I attempted to load it.

I am probably just doing something wrong creating the .db files from outside of Foundry.

AnthonyVadala avatar Jul 07 '20 13:07 AnthonyVadala

From my understanding, the .db files is using the following library https://github.com/louischatriot/nedb

So you may need to utilize nedb to create the .db files from the js files in this git library

shawndibble avatar Jul 07 '20 14:07 shawndibble

You could keep all macros in one big JSON file, or even have separate JSON files for every macro. then, when Foundry initializes, you could fetch the JSON file and import macro into compendium using API.

Could also utilize hidden settings to fire this import once per version.

I absolutely advise against any attempts to modify db files. Only sorrow comes from that ;)

Forien avatar Jul 07 '20 20:07 Forien

That maybe the best option. Have a github action that creates a few json files for you. Then utilize the api to import macros from json with the importFromJSON. After that is done, you can utilize toCompendium.

If you have a dedicated foundry installation, you could use the http api module so that github actions can make those remote api calls and imports to foundry for you.

shawndibble avatar Jul 07 '20 22:07 shawndibble

The db file is not a json file. It is a newline separated file that uses json chunks on each line.

@AnthonyVadala when you save the file out, please ensure you're using the correct encoding. Opening the ones I use in vscode shows the encoding to be UTF-8. If you're not saving into the correct encoding that FoundryVTT expects, it may cause corruption like you're experiencing.

damccull avatar Oct 18 '20 07:10 damccull