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.

The plugin the vault demonstrates is read from the helper’s own data.json, written by the packaging step (DemoVaultHelperSettings); a vault without that marker is refused as not a demo vault.

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.

It then installs the Folder Notes plugin, configured to treat README.md as a folder’s own note. A demo vault that has outgrown a flat note list groups its notes into folders (G95), and a group folder only says what it is for if it has a note of its own — README.md, because that is also the file GitHub renders under the file list when the same vault is browsed as a repository, so one file serves both readers.

Finally it raises the sandbox notice explaining that the opened vault is a throwaway copy, so a user who writes their own notes in it is never surprised by them being absent from the next copy. Settings is closed first, so the notice lands in the vault’s main window rather than in the settings popout.

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. Folder Notes is installed next, configured to treat README.md as a folder’s own note, so a vault whose notes are grouped into folders describes each group in the file explorer. Finally it closes Settings (so the notice cannot be raised inside the settings popout) and raises the sandbox notice describing the opened vault as a throwaway copy.