WDIO Obsidian Service
    Preparing search index...

    The ObsidianLauncher class.

    Helper class that handles downloading and installing Obsidian versions, plugins, and themes and launching Obsidian with sandboxed configuration directories.

    Index

    Constructors

    • Construct an ObsidianLauncher.

      Parameters

      • opts: {
            cacheDir?: string;
            versionsUrl?: string;
            communityPluginsUrl?: string;
            communityThemesUrl?: string;
            cacheDuration?: number;
            interactive?: boolean;
        } = {}
        • OptionalcacheDir?: string

          Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ".obsidian-cache".

        • OptionalversionsUrl?: string

          Custom obsidian-versions.json url. Can be a file URL.

        • OptionalcommunityPluginsUrl?: string

          Custom community-plugins.json url. Can be a file URL.

        • OptionalcommunityThemesUrl?: string

          Custom community-css-themes.json url. Can be a file URL.

        • OptionalcacheDuration?: number

          If the cached version list is older than this (in ms), refetch it. Defaults to 30 minutes.

        • Optionalinteractive?: boolean

          If it can prompt the user for input (e.g. for Obsidian credentials). Default false.

      Returns default

    Properties

    cacheDir: string
    versionsUrl: string
    communityPluginsUrl: string
    communityThemesUrl: string
    cacheDuration: number
    interactive: boolean = false

    Methods

    • Resolves Obsidian app and installer version strings to absolute versions.

      Parameters

      • appVersion: string

        specific version or one of

        • "latest": Get the current latest non-beta Obsidian version
        • "latest-beta": Get the current latest beta Obsidian version (or latest is there is no current beta)
        • "earliest": Get the minAppVersion set in your manifest.json
      • installerVersion: string = "latest"

        specific version or one of

        • "latest": Get the latest Obsidian installer compatible with appVersion
        • "earliest": Get the oldest Obsidian installer compatible with appVersion

        See also: Obsidian App vs Installer Versions

      Returns Promise<[string, string]>

      [appVersion, installerVersion] with any "latest" etc. resolved to specific versions.

    • Parses a string of Obsidian versions into [appVersion, installerVersion] tuples.

      versions should be a space separated list of Obsidian app versions. You can optionally specify the installer version by using "appVersion/installerVersion" e.g. "1.7.7/1.8.10".

      Example:

      launcher.parseVersions("1.8.10/1.7.7 latest latest-beta/earliest")
      

      See also: Obsidian App vs Installer Versions

      Parameters

      • versions: string

        string to parse

      Returns Promise<[string, string][]>

      [appVersion, installerVersion][] resolved to specific versions.

    • Gets details about the Obsidian installer for the given platform.

      Parameters

      • installerVersion: string

        Obsidian installer version

      • opts: { platform?: Platform; arch?: Architecture } = {}
        • Optionalplatform?: Platform

          Platform/os (defaults to host platform)

        • Optionalarch?: Architecture

          Architecture (defaults to host architecture)

      Returns Promise<ObsidianInstallerInfo & { url: string }>

    • Downloads the Obsidian installer for the given version and platform/arch (defaults to host platform/arch). Returns the file path.

      Parameters

      • installerVersion: string

        Obsidian installer version to download

      • opts: { platform?: Platform; arch?: Architecture } = {}
        • Optionalplatform?: Platform

          Platform/os of the installer to download (defaults to host platform)

        • Optionalarch?: Architecture

          Architecture of the installer to download (defaults to host architecture)

      Returns Promise<string>

    • Downloads the Obsidian asar for the given version. Returns the file path.

      To download Obsidian beta versions you'll need to have an Obsidian Insiders account and either set the OBSIDIAN_EMAIL and OBSIDIAN_PASSWORD env vars (.env file is supported) or pre-download the Obsidian beta with npx obsidian-launcher download app -v latest-beta

      Parameters

      • appVersion: string

        Obsidian version to download

      Returns Promise<string>

    • Downloads chromedriver for the given Obsidian version.

      wdio will download chromedriver from the Chrome for Testing API automatically (see https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints). However, Google has only put chromedriver since v115.0.5763.0 in that API, so wdio can't automatically download older versions of chromedriver for old Electron versions. Here we download chromedriver for older versions ourselves using the @electron/get package which fetches chromedriver from https://github.com/electron/electron/releases.

      Parameters

      • installerVersion: string

        Obsidian installer version

      • opts: { platform?: Platform; arch?: Architecture } = {}

      Returns Promise<string>

    • Downloads the Obsidian apk.

      Parameters

      • version: string

      Returns Promise<string>

    • Downloads a list of plugins to the cache and returns a list of DownloadedPluginEntry with the downloaded paths. Also adds the id property to the plugins based on the manifest.

      You can download plugins from GitHub using {repo: "org/repo"} and community plugins using {id: 'plugin-id'}. Local plugins will just be passed through.

      Parameters

      Returns Promise<DownloadedPluginEntry[]>

    • Installs plugins into an Obsidian vault

      Parameters

      • vault: string

        Path to the vault to install the plugins in

      • plugins: PluginEntry[]

        List plugins to install

      Returns Promise<void>

    • Downloads a list of themes to the cache and returns a list of DownloadedThemeEntry with the downloaded paths. Also adds the name property to the plugins based on the manifest.

      You can download themes from GitHub using {repo: "org/repo"} and community themes using {name: 'theme-name'}. Local themes will just be passed through.

      Parameters

      Returns Promise<DownloadedThemeEntry[]>

    • Installs themes into an Obsidian vault

      Parameters

      • vault: string

        Path to the theme to install the themes in

      • themes: ThemeEntry[]

        List of themes to install

      Returns Promise<void>

    • Sets up the config dir to use for the --user-data-dir in obsidian. Returns the path to the created config dir.

      Parameters

      • params: {
            appVersion: string;
            installerVersion: string;
            appPath?: string;
            vault?: string;
            localStorage?: Record<string, string>;
            chromePreferences?: Record<string, any>;
        }
        • appVersion: string

          Obsidian app version

        • installerVersion: string

          Obsidian version string.

        • OptionalappPath?: string

          Path to the asar file to install. Will download if omitted.

        • Optionalvault?: string

          Path to the vault to open in Obsidian

        • OptionallocalStorage?: Record<string, string>

          items to add to localStorage. $vaultId in the keys will be replaced with the vaultId

        • OptionalchromePreferences?: Record<string, any>

          Chrome preferences to add to the Preferences file

      Returns Promise<string>

    • Sets up a vault for Obsidian, installing plugins and themes and optionally copying the vault to a temporary directory first.

      Parameters

      • params: {
            vault: string;
            copy?: boolean;
            plugins?: PluginEntry[];
            themes?: ThemeEntry[];
        }
        • vault: string

          Path to the vault to open in Obsidian

        • Optionalcopy?: boolean

          Whether to copy the vault to a tmpdir first. Default false

        • Optionalplugins?: PluginEntry[]

          List of plugins to install in the vault

        • Optionalthemes?: ThemeEntry[]

          List of themes to install in the vault

      Returns Promise<string>

      Path to the copied vault (or just the path to the vault if copy is false)

    • Downloads and launches Obsidian with a sandboxed config dir and a specifc vault open. Optionally install plugins and themes first.

      Parameters

      • params: {
            appVersion?: string;
            installerVersion?: string;
            copy?: boolean;
            vault?: string;
            plugins?: PluginEntry[];
            themes?: ThemeEntry[];
            args?: string[];
            localStorage?: Record<string, string>;
            spawnOptions?: SpawnOptions;
        }
        • OptionalappVersion?: string

          Obsidian app version. Default "latest"

        • OptionalinstallerVersion?: string

          Obsidian installer version. Default "latest"

        • Optionalcopy?: boolean

          Whether to copy the vault to a tmpdir first. Default false

        • Optionalvault?: string

          Path to the vault to open in Obsidian

        • Optionalplugins?: PluginEntry[]

          List of plugins to install in the vault

        • Optionalthemes?: ThemeEntry[]

          List of themes to install in the vault

        • Optionalargs?: string[]

          CLI args to pass to Obsidian

        • OptionallocalStorage?: Record<string, string>

          items to add to localStorage. $vaultId in the keys will be replaced with the vaultId

        • OptionalspawnOptions?: SpawnOptions

          Options to pass to spawn

      Returns Promise<{ proc: ChildProcess; configDir: string; vault?: string }>

      The launched child process and the created tmpdirs

    • Updates the info in obsidian-versions.json. The obsidian-versions.json file is used in other launcher commands and in wdio-obsidian-service to get metadata about Obsidian versions in one place such as minInstallerVersion and the internal Electron version.

      Parameters

      Returns Promise<ObsidianVersionList>

    • Returns true if the Obsidian version is already in the cache.

      Parameters

      • type: "installer" | "app"

        on of "app" or "installer"

      • version: string

        Obsidian app/installer version

      Returns Promise<boolean>

    • Returns true if we either have the credentials to download the version or it's already in cache. This is only relevant for Obsidian beta versions, as they require Obsidian insider credentials to download.

      Parameters

      • appVersion: string

        Obsidian app version

      Returns Promise<boolean>