Skip to content

obsidian/demo-vault-helper

Bootstraps a demo vault by installing, configuring, and enabling CodeScript Toolkit.

A plugin’s demo vault showcases the plugin through notes whose code-buttons run TypeScript via CodeScript Toolkit. A demo vault that does not itself ship CodeScript Toolkit therefore needs it installed, configured, and enabled before those buttons work. bootstrapDemoVault does exactly that with no committed CodeScript Toolkit config and no manual setup, so it can be driven from a tiny committed bootstrap plugin (demo-vault-helper) that is injected into every demo vault at release time.

It writes CodeScript Toolkit’s settings BEFORE enabling it, so the plugin loads already configured — no reload. CodeScript Toolkit then runs the vault’s startup.ts (via its startupScriptPath setting), which is where each vault opens its start note and does any plugin-specific setup.

It also creates CodeScript Toolkit’s invocable-scripts folder if it is missing, so every demo vault has the same layout even when the vault ships no invocable scripts — the vaults themselves commit no empty folder for it.

InterfaceDescription
BootstrapDemoVaultParamsParameters for bootstrapDemoVault.
FunctionDescription
bootstrapDemoVaultBootstraps a demo vault so its notes’ code-buttons work with no manual setup: installs CodeScript Toolkit from the community store (if it is not already installed), writes its settings, then enables it — writing the settings BEFORE enabling so a fresh enable loads it already configured, with no reload. If CodeScript Toolkit is already enabled but the settings just changed, it is reloaded (disabled then enabled) so it re-reads data.json; when the settings were already in place, nothing is reloaded (so a routine vault re-open does not re-run CodeScript Toolkit’s startup). CodeScript Toolkit then runs the vault’s startup.ts.