@samuel_malcolm ,
This is not my experience, but probably because I haven't done anything specifically related to themes with JSDom. I wasn't thinking of using the API to get the page data, though.
What I was thinking is that you might be able to do this:
- Use Node / JSDom to log into the Canvas web ui as a headless browser. There are other ways to do this -- I think puppeteer is one way, but I don't know how to use it, so I'm sharing what I have experimented with.
- Get a list of subaccounts from the API
- For each subAccount, visit the theme page within Canvas that Canvas subaccount: example /accounts/123/brand_configs
- Obtain the ENV variable. This is where I would use JSDom to extract information from the window variable or you could parse the HTML delivered and bypass it -- probably quicker, but possibly harder to use. There is an ENV.brandConfigStuff object. It's pretty big, but it has a lot of information in it, including everything that I think you're after.
- Grab what you need and do something useful with it.
- Loop back to step 3 for the next subaccount.
Here is some of what is inside ENV.brandConfigStuff:
- baseBrandableVariables contains the colors and log / header locations.
- brandableVariableDefaults is probably not what you're after here, but you may need to use it in conjunction with something else.
- accountID but you already knew this to get the information
- sharedBrandConfigs is an array of all the configs that you might be able to use for this subaccount themes. It includes the name and brand_config_md5, parent_md5, variables, js_overrides, css_overrides, mobile_js_overrides, and mobile_css_overrides. Those last four are null when there are no overrides. When there is an override, it has the URL to the override. Those files are wide open, so you can fetch them without having to be logged into Canvas. The variables contains only the overrides from the defaults.
- activeBrandConfig is the one you probably want. It has the same information as sharedBrandConfigs, especially the JS and CSS overrides, except that if your brand config is shared, there are no variables here. Strangely, my name here is null. You can, however, use the md5 property and then search the sharedBrandConfigs to get additional information from there, including the name.
This doesn't help you upload CSS and JS, but it may help you track what's already out there.
I'm not sure that anyone will be able to run your SQL unless you're self-hosting Canvas.