obsidian-launcher 2.1.5 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","../src/cli.ts"],"names":[],"mappings":"AAAA;AACA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACNA,sCAAwB;AAKxB,wEAAiB;AACjB,2FAAoB;AAGpB,SAAS,YAAA,CAAa,QAAA,EAAoB,CAAC,CAAA,EAAkB;AACzD,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,EAAA,GAAc;AAC9B,IAAA,GAAA,CAAI,CAAA,CAAE,UAAA,CAAW,KAAK,CAAA,EAAG;AACrB,MAAA,MAAM,CAAC,EAAA,EAAI,OAAO,EAAA,EAAI,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,KAAA,CAAM,MAAM,CAAA;AAC7C,MAAA,OAAO,EAAC,EAAA,EAAI,QAAO,CAAA;AAAA,IACvB,EAAA,KAAA,GAAA,CAAW,CAAA,CAAE,UAAA,CAAW,OAAO,CAAA,EAAG;AAC9B,MAAA,MAAM,CAAC,IAAA,EAAM,OAAO,EAAA,EAAI,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,KAAA,CAAM,MAAM,CAAA;AAC/C,MAAA,OAAO,EAAC,IAAA,EAAM,QAAO,CAAA;AAAA,IACzB,EAAA,KAAA,GAAA,CAAW,CAAA,CAAE,UAAA,CAAW,OAAO,CAAA,EAAG;AAC9B,MAAA,OAAO,EAAC,IAAA,EAAM,CAAA,CAAE,KAAA,CAAM,CAAC,EAAC,CAAA;AAAA,IAC5B,EAAA,KAAO;AACH,MAAA,OAAO,EAAC,IAAA,EAAM,EAAC,CAAA;AAAA,IACnB;AAAA,EACJ,CAAC,CA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AA;AACJ,QAAA;AACmC,QAAA;AACvC,MAAA;AACJ,IAAA;AACJ,EAAA;AAE4B,EAAA;AACL,IAAA;AACb,IAAA;AACkC,IAAA;AAC1B,IAAA;AAClB,EAAA;AAC4B,EAAA;AACF,EAAA;AAEd,EAAA;AACN,EAAA;AACT;AAIY;AAMwB,EAAA;AACO,EAAA;AACH,EAAA;AACO,EAAA;AACF,EAAA;AAC9B,EAAA;AACf;AAIQ;AAEL,EAAA;AAQiB;AAOgB,EAAA;AACT,EAAA;AACmB,IAAA;AACnB,uBAAA;AACS,uBAAA;AAC7B,IAAA;AACqC,IAAA;AAClB,MAAA;AAAqB,MAAA;AACvC,IAAA;AACW,IAAA;AAC+B,IAAA;AACD,IAAA;AACnB,EAAA;AACoB,IAAA;AACD,IAAA;AACb,EAAA;AACQ,IAAA;AAClB,MAAA;AAAqB,MAAA;AACvC,IAAA;AACW,IAAA;AACW,EAAA;AACQ,IAAA;AACW,IAAA;AACvC,EAAA;AACsC,IAAA;AAC7C,EAAA;AACH;AAGgC;AAG7B,EAAA;AAQc;AAIV,EAAA;AACA,EAAA;AACwC,IAAA;AACpC,EAAA;AACW,IAAA;AACnB,EAAA;AAC6C,EAAA;AACpB,EAAA;AACc,IAAA;AACvC,EAAA;AAEiC,EAAA;AACH,EAAA;AACe,EAAA;AACjC,EAAA;AACf;AAIe;AAC8B,EAAA;AAC5B,EAAA;AACjB","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","sourcesContent":[null,"#!/usr/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { watchFiles } from './utils.js';\nimport { ObsidianVersionList, PluginEntry, ThemeEntry } from \"./types.js\";\nimport path from \"path\"\nimport fsAsync from \"fs/promises\";\n\n\nfunction parsePlugins(plugins: string[] = []): PluginEntry[] {\n return plugins.map((p: string) => {\n if (p.startsWith(\"id:\")) {\n const [id, version] = p.slice(3).split(/[@=]/);\n return {id, version};\n } else if (p.startsWith(\"repo:\")) {\n const [repo, version] = p.slice(5).split(/[@=]/);\n return {repo, version};\n } else if (p.startsWith(\"path:\")) {\n return {path: p.slice(5)};\n } else {\n return {path: p};\n }\n })\n}\n\nfunction parseThemes(themes: string[] = []): ThemeEntry[] {\n return themes.map((t: string, i: number) => {\n let result: ThemeEntry;\n if (t.startsWith(\"name:\")) {\n const [name, version] = t.slice(5).split(/[@=]/);\n result = {name, version};\n } else if (t.startsWith(\"repo:\")) {\n const [repo, version] = t.slice(5).split(/[@=]/);\n result = {repo, version};\n } else if (t.startsWith(\"path:\")) {\n result = {path: t.slice(5)};\n } else {\n result = {path: t};\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nfunction getLauncher(opts: {cache: string}) {\n return new ObsidianLauncher({cacheDir: opts.cache, interactive: !!process.stdin.isTTY});\n}\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian app version\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version\",\n \"earliest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download cache. (default: OBSIDIAN_CACHE env var or \".obsidian-cache\")',\n] as const\nconst pluginOptionArgs = [\n '-p, --plugin <plugin>',\n 'Plugin to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"id:<community-id>\". Can be repeated.',\n collectOpt,\n] as const\nconst themeOptionArgs = [\n '-t, --theme <plugin>',\n 'Theme to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"name:<community-name>\". Can be repeated but only last will be enabled.',\n collectOpt,\n] as const\n\nconst program = new Command(\"obsidian-launcher\");\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault.\\n\" +\n \"\\n\" +\n \"The Obsidian instance will have a sandboxed configuration directory. You can use this command to compare \" +\n \"plugin behavior on different versions of Obsidian without messing with your system installation of \" + \n \"Obsidian.\\n\" +\n \"\\n\" +\n \"You can pass arguments through to the Obsidian executable using `--`:\\n\" +\n \" npx obsidian-launcher launch ./vault -- --remote-debugging-port=9222\"\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string|undefined, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: opts.copy ?? false,\n args: obsidianArgs,\n plugins: parsePlugins(opts.plugin),\n themes: parseThemes(opts.theme),\n spawnOptions: {\n detached: true,\n stdio: 'ignore',\n }\n })\n proc.unref() // Allow node to exit and leave proc running\n console.log(`Launched obsidian ${opts.version}`)\n })\n\nprogram\n .command(\"watch\")\n .summary(\"Launch Obsidian and watch for changes to plugins and themes\")\n .description(\n \"Downloads Obsidian and opens a vault, then watches for changes to plugins and themes.\\n\" +\n \"\\n\" +\n 'Takes the same arguments as the \"launch\" command but watches for changes to any local plugins or themes and ' +\n 'updates the vault. Automatically installs \"pjeby/hot-reload\" so plugins will hot reload as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n // Normalize the plugins and themes\n const plugins = await launcher.downloadPlugins(parsePlugins(opts.plugin));\n const themes = await launcher.downloadThemes(parseThemes(opts.theme));\n const copy: boolean = opts.copy ?? false;\n const launchArgs = {\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: copy,\n args: obsidianArgs,\n plugins: plugins,\n themes: themes,\n } as const\n\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n ...launchArgs,\n plugins: [...plugins, {repo: \"pjeby/hot-reload\"}],\n spawnOptions: {\n detached: false,\n stdio: \"pipe\",\n }\n })\n if (copy) {\n console.log(`Vault copied to ${vaultCopy}`);\n }\n proc.stdout!.on('data', data => console.log(`obsidian: ${data}`));\n proc.stderr!.on('data', data => console.log(`obsidian: ${data}`));\n const procExit = new Promise<number>((resolve) => proc.on('exit', (code) => resolve(code ?? -1)));\n\n for (const plugin of plugins) {\n if (plugin.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"main.js\", \"styles.css\", \"data.json\"].map(f => path.join(plugin.path, f)),\n async () => {\n console.log(`Detected change to \"${plugin.id}\"`);\n try {\n await launcher.installPlugins(vaultCopy!, [plugin]);\n } catch (e) {\n console.error(`Failed to update plugin \"${plugin.id}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n for (const theme of themes) {\n if (theme.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"theme.css\"].map(f => path.join(theme.path, f)),\n async () => {\n console.log(`Detected change to \"${theme.name}\"`);\n try {\n await launcher.installThemes(vaultCopy!, [theme]);\n } catch (e) {\n console.error(`Failed to update theme \"${theme.name}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n\n const cleanup = async () => {\n proc.kill(\"SIGTERM\");\n await procExit;\n await fsAsync.rm(configDir, {recursive: true, force: true});\n process.exit(1);\n }\n process.on('SIGINT', cleanup);\n process.on('exit', cleanup);\n\n console.log(\"Watching for changes to plugins and themes...\")\n await procExit;\n })\n\nprogram\n .command(\"install\")\n .description(\"Install plugins and themes into an Obsidian vault\")\n .argument('<vault>', 'Vault to install into')\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option(...cacheOptionArgs)\n .action(async (vault, opts) => {\n const launcher = getLauncher(opts);\n const plugins = parsePlugins(opts.plugin);\n const themes = parseThemes(opts.theme);\n await launcher.installPlugins(vault, plugins);\n await launcher.installThemes(vault, themes);\n console.log(`Installed plugins/themes into vault.`)\n })\n\nprogram\n .command(\"download\")\n .summary(\"Download Obsidian to the cache\")\n .description(\n \"Download Obsidian to the cache.\\n\" +\n \"\\n\" + \n \"Pre-download Obsidian to the cache. Pass asset to select what variant to download, which can be one of:\\n\" +\n \" - app: Download the desktop app JS bundle\\n\" +\n \" - installer: Download the desktop installer\\n\" +\n \" - desktop: Download both the desktop app and installer (the default)\\n\" +\n \" - apk: Download the mobile app APK file\"\n )\n .argument('[asset]', 'Obsidian asset to download', \"desktop\")\n .option('-v, --version <version>', 'Obsidian version (default: \"latest\")')\n .option('-i, --installer <version>', 'Obsidian installer version (default: \"earliest\")')\n .option('--platform <platform>', \"Platform of the installer, one of linux, win32, darwin. (default: system platform)\")\n .option('--arch <arch>', \"Architecture of the installer, one of arm64, ia32, x64. (default: system arch)\")\n .option(...cacheOptionArgs)\n .action(async (asset, opts) => {\n const launcher = getLauncher(opts);\n if (asset == \"desktop\") {\n const [appVersion, installerVersion] = await launcher.resolveVersion(\n opts.version ?? \"latest\",\n opts.installerVersion ?? \"earliest\",\n );\n const installerPath = await launcher.downloadInstaller(installerVersion, {\n platform: opts.platform, arch: opts.arch,\n });\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"app\") {\n const appPath = await launcher.downloadApp(opts.version ?? \"latest\");\n console.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"installer\") {\n const installerPath = await launcher.downloadInstaller(opts.installer ?? opts.version ?? \"latest\", {\n platform: opts.platform, arch: opts.arch,\n });\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n } else if (asset == \"apk\") {\n const apkPath = await launcher.downloadAndroid(opts.version ?? \"latest\");\n console.log(`Downloaded Obsidian apk to ${apkPath}`)\n } else {\n throw Error(`Invalid asset type ${asset}`)\n }\n })\n\nprogram\n .command(\"update-version-list\", {hidden: true})\n .summary(\"Collect Obsidian version information into a single file\")\n .description(\n \"Collect Obsidian version information into a single file.\\n\" +\n \"\\n\" +\n \"This command is used to collect Obsidian version information in one place including download links, the \" +\n \"minimum installer version, and the internal Electron version for every Obsidian release and beta version. \" +\n \"This info is available and automatically kept up to date at \" +\n \"https://raw.githubusercontent.com/jesse-r-s-hines/wdio-obsidian-service/HEAD/obsidian-versions.json \" +\n \"but you can use this command to recreate the file manually if you want.\"\n )\n .argument('dest', 'Path to output. If it already exists, it will update the information instead of creating it from scratch.')\n .option(...cacheOptionArgs)\n .option('--max-instances <count>', \"Number of parallel Obsidian instances to launch when checking Electron versions\", \"1\")\n .action(async (dest, opts) => {\n let versionInfos: ObsidianVersionList|undefined;\n try {\n versionInfos = JSON.parse(await fsAsync.readFile(dest, \"utf-8\"))\n } catch {\n versionInfos = undefined;\n }\n const maxInstances = Number(opts.maxInstances)\n if (isNaN(maxInstances)) {\n throw Error(`Invalid number ${opts.maxInstances}`)\n }\n\n const launcher = getLauncher(opts);\n versionInfos = await launcher.updateVersionList(versionInfos, { maxInstances });\n await fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4) + \"\\n\");\n console.log(`Wrote updated version information to ${dest}`)\n })\n\nprogram\n .parseAsync()\n .catch((err) => {\n console.log(err?.message ?? err.toString())\n process.exit(1);\n });\n"]}
1
+ {"version":3,"sources":["/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","../src/cli.ts"],"names":[],"mappings":"AAAA;AACA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACPA,sCAAwB;AAKxB,wEAAiB;AACjB,2FAAoB;AAGpB,SAAS,YAAA,CAAa,QAAA,EAAoB,CAAC,CAAA,EAAkB;AACzD,EAAA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AA;AAC+B,IAAA;AACD,IAAA;AACnB,EAAA;AACoB,IAAA;AACD,IAAA;AACb,EAAA;AACQ,IAAA;AAClB,MAAA;AAAqB,MAAA;AACvC,IAAA;AACW,IAAA;AACW,EAAA;AACQ,IAAA;AACW,IAAA;AACvC,EAAA;AACsC,IAAA;AAC7C,EAAA;AACH;AAGgC;AAG7B,EAAA;AAQc;AAIV,EAAA;AACA,EAAA;AACwC,IAAA;AACpC,EAAA;AACW,IAAA;AACnB,EAAA;AAC6C,EAAA;AACpB,EAAA;AACc,IAAA;AACvC,EAAA;AAEiC,EAAA;AACH,EAAA;AACe,EAAA;AACjC,EAAA;AACf;AAIe;AACgC,EAAA;AAC9B,EAAA;AACjB","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","sourcesContent":[null,"#!/usr/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { consola, watchFiles } from './utils.js';\nimport { ObsidianVersionList, PluginEntry, ThemeEntry } from \"./types.js\";\nimport path from \"path\"\nimport fsAsync from \"fs/promises\";\n\n\nfunction parsePlugins(plugins: string[] = []): PluginEntry[] {\n return plugins.map((p: string) => {\n if (p.startsWith(\"id:\")) {\n const [id, version] = p.slice(3).split(/[@=]/);\n return {id, version};\n } else if (p.startsWith(\"repo:\")) {\n const [repo, version] = p.slice(5).split(/[@=]/);\n return {repo, version};\n } else if (p.startsWith(\"path:\")) {\n return {path: p.slice(5)};\n } else {\n return {path: p};\n }\n })\n}\n\nfunction parseThemes(themes: string[] = []): ThemeEntry[] {\n return themes.map((t: string, i: number) => {\n let result: ThemeEntry;\n if (t.startsWith(\"name:\")) {\n const [name, version] = t.slice(5).split(/[@=]/);\n result = {name, version};\n } else if (t.startsWith(\"repo:\")) {\n const [repo, version] = t.slice(5).split(/[@=]/);\n result = {repo, version};\n } else if (t.startsWith(\"path:\")) {\n result = {path: t.slice(5)};\n } else {\n result = {path: t};\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nfunction getLauncher(opts: {cache: string}) {\n return new ObsidianLauncher({cacheDir: opts.cache, interactive: !!process.stdin.isTTY});\n}\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian app version\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version\",\n \"earliest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download cache. (default: OBSIDIAN_CACHE env var or \".obsidian-cache\")',\n] as const\nconst pluginOptionArgs = [\n '-p, --plugin <plugin>',\n 'Plugin to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"id:<community-id>\". Can be repeated.',\n collectOpt,\n] as const\nconst themeOptionArgs = [\n '-t, --theme <plugin>',\n 'Theme to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"name:<community-name>\". Can be repeated but only last will be enabled.',\n collectOpt,\n] as const\n\nconst program = new Command(\"obsidian-launcher\");\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault.\\n\" +\n \"\\n\" +\n \"The Obsidian instance will have a sandboxed configuration directory. You can use this command to compare \" +\n \"plugin behavior on different versions of Obsidian without messing with your system installation of \" + \n \"Obsidian.\\n\" +\n \"\\n\" +\n \"You can pass arguments through to the Obsidian executable using `--`:\\n\" +\n \" npx obsidian-launcher launch ./vault -- --remote-debugging-port=9222\"\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string|undefined, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: opts.copy ?? false,\n args: obsidianArgs,\n plugins: parsePlugins(opts.plugin),\n themes: parseThemes(opts.theme),\n spawnOptions: {\n detached: true,\n stdio: 'ignore',\n }\n })\n proc.unref() // Allow node to exit and leave proc running\n consola.log(`Launched obsidian ${opts.version}`)\n })\n\nprogram\n .command(\"watch\")\n .summary(\"Launch Obsidian and watch for changes to plugins and themes\")\n .description(\n \"Downloads Obsidian and opens a vault, then watches for changes to plugins and themes.\\n\" +\n \"\\n\" +\n 'Takes the same arguments as the \"launch\" command but watches for changes to any local plugins or themes and ' +\n 'updates the vault. Automatically installs \"pjeby/hot-reload\" so plugins will hot reload as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n // Normalize the plugins and themes\n const plugins = await launcher.downloadPlugins(parsePlugins(opts.plugin));\n const themes = await launcher.downloadThemes(parseThemes(opts.theme));\n const copy: boolean = opts.copy ?? false;\n const launchArgs = {\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: copy,\n args: obsidianArgs,\n plugins: plugins,\n themes: themes,\n } as const\n\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n ...launchArgs,\n plugins: [...plugins, {repo: \"pjeby/hot-reload\"}],\n spawnOptions: {\n detached: false,\n stdio: \"pipe\",\n }\n })\n if (copy) {\n consola.log(`Vault copied to ${vaultCopy}`);\n }\n proc.stdout!.on('data', data => consola.log(`obsidian: ${data}`));\n proc.stderr!.on('data', data => consola.log(`obsidian: ${data}`));\n const procExit = new Promise<number>((resolve) => proc.on('exit', (code) => resolve(code ?? -1)));\n\n for (const plugin of plugins) {\n if (plugin.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"main.js\", \"styles.css\", \"data.json\"].map(f => path.join(plugin.path, f)),\n async () => {\n consola.log(`Detected change to \"${plugin.id}\"`);\n try {\n await launcher.installPlugins(vaultCopy!, [plugin]);\n } catch (e) {\n consola.error(`Failed to update plugin \"${plugin.id}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n for (const theme of themes) {\n if (theme.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"theme.css\"].map(f => path.join(theme.path, f)),\n async () => {\n consola.log(`Detected change to \"${theme.name}\"`);\n try {\n await launcher.installThemes(vaultCopy!, [theme]);\n } catch (e) {\n consola.error(`Failed to update theme \"${theme.name}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n\n const cleanup = async () => {\n proc.kill(\"SIGTERM\");\n await procExit;\n await fsAsync.rm(configDir, {recursive: true, force: true});\n process.exit(1);\n }\n process.on('SIGINT', cleanup);\n process.on('exit', cleanup);\n\n consola.log(\"Watching for changes to plugins and themes...\")\n await procExit;\n })\n\nprogram\n .command(\"install\")\n .description(\"Install plugins and themes into an Obsidian vault\")\n .argument('<vault>', 'Vault to install into')\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option(...cacheOptionArgs)\n .action(async (vault, opts) => {\n const launcher = getLauncher(opts);\n const plugins = parsePlugins(opts.plugin);\n const themes = parseThemes(opts.theme);\n await launcher.installPlugins(vault, plugins);\n await launcher.installThemes(vault, themes);\n consola.log(`Installed plugins/themes into vault.`)\n })\n\nprogram\n .command(\"download\")\n .summary(\"Download Obsidian to the cache\")\n .description(\n \"Download Obsidian to the cache.\\n\" +\n \"\\n\" + \n \"Pre-download Obsidian to the cache. Pass asset to select what variant to download, which can be one of:\\n\" +\n \" - app: Download the desktop app JS bundle\\n\" +\n \" - installer: Download the desktop installer\\n\" +\n \" - desktop: Download both the desktop app and installer (the default)\\n\" +\n \" - apk: Download the mobile app APK file\"\n )\n .argument('[asset]', 'Obsidian asset to download', \"desktop\")\n .option('-v, --version <version>', 'Obsidian version (default: \"latest\")')\n .option('-i, --installer <version>', 'Obsidian installer version (default: \"earliest\")')\n .option('--platform <platform>', \"Platform of the installer, one of linux, win32, darwin. (default: system platform)\")\n .option('--arch <arch>', \"Architecture of the installer, one of arm64, ia32, x64. (default: system arch)\")\n .option(...cacheOptionArgs)\n .action(async (asset, opts) => {\n const launcher = getLauncher(opts);\n if (asset == \"desktop\") {\n const [appVersion, installerVersion] = await launcher.resolveVersion(\n opts.version ?? \"latest\",\n opts.installerVersion ?? \"earliest\",\n );\n const installerPath = await launcher.downloadInstaller(installerVersion, {\n platform: opts.platform, arch: opts.arch,\n });\n consola.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n consola.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"app\") {\n const appPath = await launcher.downloadApp(opts.version ?? \"latest\");\n consola.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"installer\") {\n const installerPath = await launcher.downloadInstaller(opts.installer ?? opts.version ?? \"latest\", {\n platform: opts.platform, arch: opts.arch,\n });\n consola.log(`Downloaded Obsidian installer to ${installerPath}`)\n } else if (asset == \"apk\") {\n const apkPath = await launcher.downloadAndroid(opts.version ?? \"latest\");\n consola.log(`Downloaded Obsidian apk to ${apkPath}`)\n } else {\n throw Error(`Invalid asset type ${asset}`)\n }\n })\n\nprogram\n .command(\"update-version-list\", {hidden: true})\n .summary(\"Collect Obsidian version information into a single file\")\n .description(\n \"Collect Obsidian version information into a single file.\\n\" +\n \"\\n\" +\n \"This command is used to collect Obsidian version information in one place including download links, the \" +\n \"minimum installer version, and the internal Electron version for every Obsidian release and beta version. \" +\n \"This info is available and automatically kept up to date at \" +\n \"https://raw.githubusercontent.com/jesse-r-s-hines/wdio-obsidian-service/HEAD/obsidian-versions.json \" +\n \"but you can use this command to recreate the file manually if you want.\"\n )\n .argument('dest', 'Path to output. If it already exists, it will update the information instead of creating it from scratch.')\n .option(...cacheOptionArgs)\n .option('--max-instances <count>', \"Number of parallel Obsidian instances to launch when checking Electron versions\", \"1\")\n .action(async (dest, opts) => {\n let versionInfos: ObsidianVersionList|undefined;\n try {\n versionInfos = JSON.parse(await fsAsync.readFile(dest, \"utf-8\"))\n } catch {\n versionInfos = undefined;\n }\n const maxInstances = Number(opts.maxInstances)\n if (isNaN(maxInstances)) {\n throw Error(`Invalid number ${opts.maxInstances}`)\n }\n\n const launcher = getLauncher(opts);\n versionInfos = await launcher.updateVersionList(versionInfos, { maxInstances });\n await fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4) + \"\\n\");\n consola.log(`Wrote updated version information to ${dest}`)\n })\n\nprogram\n .parseAsync()\n .catch((err) => {\n consola.error(err?.message ?? err.toString())\n process.exit(1);\n });\n"]}
package/dist/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ObsidianLauncher,
4
+ consola,
4
5
  watchFiles
5
- } from "./chunk-O3OTELNK.js";
6
+ } from "./chunk-LBBOWJGG.js";
6
7
 
7
8
  // src/cli.ts
8
9
  import { Command } from "commander";
@@ -87,7 +88,7 @@ program.command("launch").summary("Download and launch Obsidian").description(
87
88
  }
88
89
  });
89
90
  proc.unref();
90
- console.log(`Launched obsidian ${opts.version}`);
91
+ consola.log(`Launched obsidian ${opts.version}`);
91
92
  });
92
93
  program.command("watch").summary("Launch Obsidian and watch for changes to plugins and themes").description(
93
94
  'Downloads Obsidian and opens a vault, then watches for changes to plugins and themes.\n\nTakes the same arguments as the "launch" command but watches for changes to any local plugins or themes and updates the vault. Automatically installs "pjeby/hot-reload" so plugins will hot reload as they are updated.'
@@ -114,21 +115,21 @@ program.command("watch").summary("Launch Obsidian and watch for changes to plugi
114
115
  }
115
116
  });
116
117
  if (copy) {
117
- console.log(`Vault copied to ${vaultCopy}`);
118
+ consola.log(`Vault copied to ${vaultCopy}`);
118
119
  }
119
- proc.stdout.on("data", (data) => console.log(`obsidian: ${data}`));
120
- proc.stderr.on("data", (data) => console.log(`obsidian: ${data}`));
120
+ proc.stdout.on("data", (data) => consola.log(`obsidian: ${data}`));
121
+ proc.stderr.on("data", (data) => consola.log(`obsidian: ${data}`));
121
122
  const procExit = new Promise((resolve) => proc.on("exit", (code) => resolve(code ?? -1)));
122
123
  for (const plugin of plugins) {
123
124
  if (plugin.originalType == "local") {
124
125
  watchFiles(
125
126
  ["manifest.json", "main.js", "styles.css", "data.json"].map((f) => path.join(plugin.path, f)),
126
127
  async () => {
127
- console.log(`Detected change to "${plugin.id}"`);
128
+ consola.log(`Detected change to "${plugin.id}"`);
128
129
  try {
129
130
  await launcher.installPlugins(vaultCopy, [plugin]);
130
131
  } catch (e) {
131
- console.error(`Failed to update plugin "${plugin.id}": ${e}`);
132
+ consola.error(`Failed to update plugin "${plugin.id}": ${e}`);
132
133
  }
133
134
  },
134
135
  { interval: 500, persistent: false, debounce: 1e3 }
@@ -140,11 +141,11 @@ program.command("watch").summary("Launch Obsidian and watch for changes to plugi
140
141
  watchFiles(
141
142
  ["manifest.json", "theme.css"].map((f) => path.join(theme.path, f)),
142
143
  async () => {
143
- console.log(`Detected change to "${theme.name}"`);
144
+ consola.log(`Detected change to "${theme.name}"`);
144
145
  try {
145
146
  await launcher.installThemes(vaultCopy, [theme]);
146
147
  } catch (e) {
147
- console.error(`Failed to update theme "${theme.name}": ${e}`);
148
+ consola.error(`Failed to update theme "${theme.name}": ${e}`);
148
149
  }
149
150
  },
150
151
  { interval: 500, persistent: false, debounce: 1e3 }
@@ -159,7 +160,7 @@ program.command("watch").summary("Launch Obsidian and watch for changes to plugi
159
160
  };
160
161
  process.on("SIGINT", cleanup);
161
162
  process.on("exit", cleanup);
162
- console.log("Watching for changes to plugins and themes...");
163
+ consola.log("Watching for changes to plugins and themes...");
163
164
  await procExit;
164
165
  });
165
166
  program.command("install").description("Install plugins and themes into an Obsidian vault").argument("<vault>", "Vault to install into").option(...pluginOptionArgs).option(...themeOptionArgs).option(...cacheOptionArgs).action(async (vault, opts) => {
@@ -168,7 +169,7 @@ program.command("install").description("Install plugins and themes into an Obsid
168
169
  const themes = parseThemes(opts.theme);
169
170
  await launcher.installPlugins(vault, plugins);
170
171
  await launcher.installThemes(vault, themes);
171
- console.log(`Installed plugins/themes into vault.`);
172
+ consola.log(`Installed plugins/themes into vault.`);
172
173
  });
173
174
  program.command("download").summary("Download Obsidian to the cache").description(
174
175
  "Download Obsidian to the cache.\n\nPre-download Obsidian to the cache. Pass asset to select what variant to download, which can be one of:\n - app: Download the desktop app JS bundle\n - installer: Download the desktop installer\n - desktop: Download both the desktop app and installer (the default)\n - apk: Download the mobile app APK file"
@@ -183,21 +184,21 @@ program.command("download").summary("Download Obsidian to the cache").descriptio
183
184
  platform: opts.platform,
184
185
  arch: opts.arch
185
186
  });
186
- console.log(`Downloaded Obsidian installer to ${installerPath}`);
187
+ consola.log(`Downloaded Obsidian installer to ${installerPath}`);
187
188
  const appPath = await launcher.downloadApp(appVersion);
188
- console.log(`Downloaded Obsidian app to ${appPath}`);
189
+ consola.log(`Downloaded Obsidian app to ${appPath}`);
189
190
  } else if (asset == "app") {
190
191
  const appPath = await launcher.downloadApp(opts.version ?? "latest");
191
- console.log(`Downloaded Obsidian app to ${appPath}`);
192
+ consola.log(`Downloaded Obsidian app to ${appPath}`);
192
193
  } else if (asset == "installer") {
193
194
  const installerPath = await launcher.downloadInstaller(opts.installer ?? opts.version ?? "latest", {
194
195
  platform: opts.platform,
195
196
  arch: opts.arch
196
197
  });
197
- console.log(`Downloaded Obsidian installer to ${installerPath}`);
198
+ consola.log(`Downloaded Obsidian installer to ${installerPath}`);
198
199
  } else if (asset == "apk") {
199
200
  const apkPath = await launcher.downloadAndroid(opts.version ?? "latest");
200
- console.log(`Downloaded Obsidian apk to ${apkPath}`);
201
+ consola.log(`Downloaded Obsidian apk to ${apkPath}`);
201
202
  } else {
202
203
  throw Error(`Invalid asset type ${asset}`);
203
204
  }
@@ -218,10 +219,10 @@ program.command("update-version-list", { hidden: true }).summary("Collect Obsidi
218
219
  const launcher = getLauncher(opts);
219
220
  versionInfos = await launcher.updateVersionList(versionInfos, { maxInstances });
220
221
  await fsAsync.writeFile(dest, JSON.stringify(versionInfos, void 0, 4) + "\n");
221
- console.log(`Wrote updated version information to ${dest}`);
222
+ consola.log(`Wrote updated version information to ${dest}`);
222
223
  });
223
224
  program.parseAsync().catch((err) => {
224
- console.log(err?.message ?? err.toString());
225
+ consola.error(err?.message ?? err.toString());
225
226
  process.exit(1);
226
227
  });
227
228
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { watchFiles } from './utils.js';\nimport { ObsidianVersionList, PluginEntry, ThemeEntry } from \"./types.js\";\nimport path from \"path\"\nimport fsAsync from \"fs/promises\";\n\n\nfunction parsePlugins(plugins: string[] = []): PluginEntry[] {\n return plugins.map((p: string) => {\n if (p.startsWith(\"id:\")) {\n const [id, version] = p.slice(3).split(/[@=]/);\n return {id, version};\n } else if (p.startsWith(\"repo:\")) {\n const [repo, version] = p.slice(5).split(/[@=]/);\n return {repo, version};\n } else if (p.startsWith(\"path:\")) {\n return {path: p.slice(5)};\n } else {\n return {path: p};\n }\n })\n}\n\nfunction parseThemes(themes: string[] = []): ThemeEntry[] {\n return themes.map((t: string, i: number) => {\n let result: ThemeEntry;\n if (t.startsWith(\"name:\")) {\n const [name, version] = t.slice(5).split(/[@=]/);\n result = {name, version};\n } else if (t.startsWith(\"repo:\")) {\n const [repo, version] = t.slice(5).split(/[@=]/);\n result = {repo, version};\n } else if (t.startsWith(\"path:\")) {\n result = {path: t.slice(5)};\n } else {\n result = {path: t};\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nfunction getLauncher(opts: {cache: string}) {\n return new ObsidianLauncher({cacheDir: opts.cache, interactive: !!process.stdin.isTTY});\n}\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian app version\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version\",\n \"earliest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download cache. (default: OBSIDIAN_CACHE env var or \".obsidian-cache\")',\n] as const\nconst pluginOptionArgs = [\n '-p, --plugin <plugin>',\n 'Plugin to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"id:<community-id>\". Can be repeated.',\n collectOpt,\n] as const\nconst themeOptionArgs = [\n '-t, --theme <plugin>',\n 'Theme to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"name:<community-name>\". Can be repeated but only last will be enabled.',\n collectOpt,\n] as const\n\nconst program = new Command(\"obsidian-launcher\");\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault.\\n\" +\n \"\\n\" +\n \"The Obsidian instance will have a sandboxed configuration directory. You can use this command to compare \" +\n \"plugin behavior on different versions of Obsidian without messing with your system installation of \" + \n \"Obsidian.\\n\" +\n \"\\n\" +\n \"You can pass arguments through to the Obsidian executable using `--`:\\n\" +\n \" npx obsidian-launcher launch ./vault -- --remote-debugging-port=9222\"\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string|undefined, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: opts.copy ?? false,\n args: obsidianArgs,\n plugins: parsePlugins(opts.plugin),\n themes: parseThemes(opts.theme),\n spawnOptions: {\n detached: true,\n stdio: 'ignore',\n }\n })\n proc.unref() // Allow node to exit and leave proc running\n console.log(`Launched obsidian ${opts.version}`)\n })\n\nprogram\n .command(\"watch\")\n .summary(\"Launch Obsidian and watch for changes to plugins and themes\")\n .description(\n \"Downloads Obsidian and opens a vault, then watches for changes to plugins and themes.\\n\" +\n \"\\n\" +\n 'Takes the same arguments as the \"launch\" command but watches for changes to any local plugins or themes and ' +\n 'updates the vault. Automatically installs \"pjeby/hot-reload\" so plugins will hot reload as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n // Normalize the plugins and themes\n const plugins = await launcher.downloadPlugins(parsePlugins(opts.plugin));\n const themes = await launcher.downloadThemes(parseThemes(opts.theme));\n const copy: boolean = opts.copy ?? false;\n const launchArgs = {\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: copy,\n args: obsidianArgs,\n plugins: plugins,\n themes: themes,\n } as const\n\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n ...launchArgs,\n plugins: [...plugins, {repo: \"pjeby/hot-reload\"}],\n spawnOptions: {\n detached: false,\n stdio: \"pipe\",\n }\n })\n if (copy) {\n console.log(`Vault copied to ${vaultCopy}`);\n }\n proc.stdout!.on('data', data => console.log(`obsidian: ${data}`));\n proc.stderr!.on('data', data => console.log(`obsidian: ${data}`));\n const procExit = new Promise<number>((resolve) => proc.on('exit', (code) => resolve(code ?? -1)));\n\n for (const plugin of plugins) {\n if (plugin.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"main.js\", \"styles.css\", \"data.json\"].map(f => path.join(plugin.path, f)),\n async () => {\n console.log(`Detected change to \"${plugin.id}\"`);\n try {\n await launcher.installPlugins(vaultCopy!, [plugin]);\n } catch (e) {\n console.error(`Failed to update plugin \"${plugin.id}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n for (const theme of themes) {\n if (theme.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"theme.css\"].map(f => path.join(theme.path, f)),\n async () => {\n console.log(`Detected change to \"${theme.name}\"`);\n try {\n await launcher.installThemes(vaultCopy!, [theme]);\n } catch (e) {\n console.error(`Failed to update theme \"${theme.name}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n\n const cleanup = async () => {\n proc.kill(\"SIGTERM\");\n await procExit;\n await fsAsync.rm(configDir, {recursive: true, force: true});\n process.exit(1);\n }\n process.on('SIGINT', cleanup);\n process.on('exit', cleanup);\n\n console.log(\"Watching for changes to plugins and themes...\")\n await procExit;\n })\n\nprogram\n .command(\"install\")\n .description(\"Install plugins and themes into an Obsidian vault\")\n .argument('<vault>', 'Vault to install into')\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option(...cacheOptionArgs)\n .action(async (vault, opts) => {\n const launcher = getLauncher(opts);\n const plugins = parsePlugins(opts.plugin);\n const themes = parseThemes(opts.theme);\n await launcher.installPlugins(vault, plugins);\n await launcher.installThemes(vault, themes);\n console.log(`Installed plugins/themes into vault.`)\n })\n\nprogram\n .command(\"download\")\n .summary(\"Download Obsidian to the cache\")\n .description(\n \"Download Obsidian to the cache.\\n\" +\n \"\\n\" + \n \"Pre-download Obsidian to the cache. Pass asset to select what variant to download, which can be one of:\\n\" +\n \" - app: Download the desktop app JS bundle\\n\" +\n \" - installer: Download the desktop installer\\n\" +\n \" - desktop: Download both the desktop app and installer (the default)\\n\" +\n \" - apk: Download the mobile app APK file\"\n )\n .argument('[asset]', 'Obsidian asset to download', \"desktop\")\n .option('-v, --version <version>', 'Obsidian version (default: \"latest\")')\n .option('-i, --installer <version>', 'Obsidian installer version (default: \"earliest\")')\n .option('--platform <platform>', \"Platform of the installer, one of linux, win32, darwin. (default: system platform)\")\n .option('--arch <arch>', \"Architecture of the installer, one of arm64, ia32, x64. (default: system arch)\")\n .option(...cacheOptionArgs)\n .action(async (asset, opts) => {\n const launcher = getLauncher(opts);\n if (asset == \"desktop\") {\n const [appVersion, installerVersion] = await launcher.resolveVersion(\n opts.version ?? \"latest\",\n opts.installerVersion ?? \"earliest\",\n );\n const installerPath = await launcher.downloadInstaller(installerVersion, {\n platform: opts.platform, arch: opts.arch,\n });\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"app\") {\n const appPath = await launcher.downloadApp(opts.version ?? \"latest\");\n console.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"installer\") {\n const installerPath = await launcher.downloadInstaller(opts.installer ?? opts.version ?? \"latest\", {\n platform: opts.platform, arch: opts.arch,\n });\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n } else if (asset == \"apk\") {\n const apkPath = await launcher.downloadAndroid(opts.version ?? \"latest\");\n console.log(`Downloaded Obsidian apk to ${apkPath}`)\n } else {\n throw Error(`Invalid asset type ${asset}`)\n }\n })\n\nprogram\n .command(\"update-version-list\", {hidden: true})\n .summary(\"Collect Obsidian version information into a single file\")\n .description(\n \"Collect Obsidian version information into a single file.\\n\" +\n \"\\n\" +\n \"This command is used to collect Obsidian version information in one place including download links, the \" +\n \"minimum installer version, and the internal Electron version for every Obsidian release and beta version. \" +\n \"This info is available and automatically kept up to date at \" +\n \"https://raw.githubusercontent.com/jesse-r-s-hines/wdio-obsidian-service/HEAD/obsidian-versions.json \" +\n \"but you can use this command to recreate the file manually if you want.\"\n )\n .argument('dest', 'Path to output. If it already exists, it will update the information instead of creating it from scratch.')\n .option(...cacheOptionArgs)\n .option('--max-instances <count>', \"Number of parallel Obsidian instances to launch when checking Electron versions\", \"1\")\n .action(async (dest, opts) => {\n let versionInfos: ObsidianVersionList|undefined;\n try {\n versionInfos = JSON.parse(await fsAsync.readFile(dest, \"utf-8\"))\n } catch {\n versionInfos = undefined;\n }\n const maxInstances = Number(opts.maxInstances)\n if (isNaN(maxInstances)) {\n throw Error(`Invalid number ${opts.maxInstances}`)\n }\n\n const launcher = getLauncher(opts);\n versionInfos = await launcher.updateVersionList(versionInfos, { maxInstances });\n await fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4) + \"\\n\");\n console.log(`Wrote updated version information to ${dest}`)\n })\n\nprogram\n .parseAsync()\n .catch((err) => {\n console.log(err?.message ?? err.toString())\n process.exit(1);\n });\n"],"mappings":";;;;;;;AACA,SAAS,eAAe;AAKxB,OAAO,UAAU;AACjB,OAAO,aAAa;AAGpB,SAAS,aAAa,UAAoB,CAAC,GAAkB;AACzD,SAAO,QAAQ,IAAI,CAAC,MAAc;AAC9B,QAAI,EAAE,WAAW,KAAK,GAAG;AACrB,YAAM,CAAC,IAAI,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC7C,aAAO,EAAC,IAAI,QAAO;AAAA,IACvB,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,YAAM,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/C,aAAO,EAAC,MAAM,QAAO;AAAA,IACzB,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,aAAO,EAAC,MAAM,EAAE,MAAM,CAAC,EAAC;AAAA,IAC5B,OAAO;AACH,aAAO,EAAC,MAAM,EAAC;AAAA,IACnB;AAAA,EACJ,CAAC;AACL;AAEA,SAAS,YAAY,SAAmB,CAAC,GAAiB;AACtD,SAAO,OAAO,IAAI,CAAC,GAAW,MAAc;AACxC,QAAI;AACJ,QAAI,EAAE,WAAW,OAAO,GAAG;AACvB,YAAM,CAAC,MAAM,OA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7C,MAAI,MAAM,YAAY,GAAG;AACrB,UAAM,MAAM,kBAAkB,KAAK,YAAY,EAAE;AAAA,EACrD;AAEA,QAAM,WAAW,YAAY,IAAI;AACjC,iBAAe,MAAM,SAAS,kBAAkB,cAAc,EAAE,aAAa,CAAC;AAC9E,QAAM,QAAQ,UAAU,MAAM,KAAK,UAAU,cAAc,QAAW,CAAC,IAAI,IAAI;AAC/E,UAAQ,IAAI,wCAAwC,IAAI,EAAE;AAC9D,CAAC;AAEL,QACK,WAAW,EACX,MAAM,CAAC,QAAQ;AACZ,UAAQ,IAAI,KAAK,WAAW,IAAI,SAAS,CAAC;AAC1C,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { consola, watchFiles } from './utils.js';\nimport { ObsidianVersionList, PluginEntry, ThemeEntry } from \"./types.js\";\nimport path from \"path\"\nimport fsAsync from \"fs/promises\";\n\n\nfunction parsePlugins(plugins: string[] = []): PluginEntry[] {\n return plugins.map((p: string) => {\n if (p.startsWith(\"id:\")) {\n const [id, version] = p.slice(3).split(/[@=]/);\n return {id, version};\n } else if (p.startsWith(\"repo:\")) {\n const [repo, version] = p.slice(5).split(/[@=]/);\n return {repo, version};\n } else if (p.startsWith(\"path:\")) {\n return {path: p.slice(5)};\n } else {\n return {path: p};\n }\n })\n}\n\nfunction parseThemes(themes: string[] = []): ThemeEntry[] {\n return themes.map((t: string, i: number) => {\n let result: ThemeEntry;\n if (t.startsWith(\"name:\")) {\n const [name, version] = t.slice(5).split(/[@=]/);\n result = {name, version};\n } else if (t.startsWith(\"repo:\")) {\n const [repo, version] = t.slice(5).split(/[@=]/);\n result = {repo, version};\n } else if (t.startsWith(\"path:\")) {\n result = {path: t.slice(5)};\n } else {\n result = {path: t};\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nfunction getLauncher(opts: {cache: string}) {\n return new ObsidianLauncher({cacheDir: opts.cache, interactive: !!process.stdin.isTTY});\n}\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian app version\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version\",\n \"earliest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download cache. (default: OBSIDIAN_CACHE env var or \".obsidian-cache\")',\n] as const\nconst pluginOptionArgs = [\n '-p, --plugin <plugin>',\n 'Plugin to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"id:<community-id>\". Can be repeated.',\n collectOpt,\n] as const\nconst themeOptionArgs = [\n '-t, --theme <plugin>',\n 'Theme to install. Format: \"<path>\" or \"repo:<github-repo>\" or \"name:<community-name>\". Can be repeated but only last will be enabled.',\n collectOpt,\n] as const\n\nconst program = new Command(\"obsidian-launcher\");\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault.\\n\" +\n \"\\n\" +\n \"The Obsidian instance will have a sandboxed configuration directory. You can use this command to compare \" +\n \"plugin behavior on different versions of Obsidian without messing with your system installation of \" + \n \"Obsidian.\\n\" +\n \"\\n\" +\n \"You can pass arguments through to the Obsidian executable using `--`:\\n\" +\n \" npx obsidian-launcher launch ./vault -- --remote-debugging-port=9222\"\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string|undefined, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: opts.copy ?? false,\n args: obsidianArgs,\n plugins: parsePlugins(opts.plugin),\n themes: parseThemes(opts.theme),\n spawnOptions: {\n detached: true,\n stdio: 'ignore',\n }\n })\n proc.unref() // Allow node to exit and leave proc running\n consola.log(`Launched obsidian ${opts.version}`)\n })\n\nprogram\n .command(\"watch\")\n .summary(\"Launch Obsidian and watch for changes to plugins and themes\")\n .description(\n \"Downloads Obsidian and opens a vault, then watches for changes to plugins and themes.\\n\" +\n \"\\n\" +\n 'Takes the same arguments as the \"launch\" command but watches for changes to any local plugins or themes and ' +\n 'updates the vault. Automatically installs \"pjeby/hot-reload\" so plugins will hot reload as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .option(...cacheOptionArgs)\n .action(async (vault: string, obsidianArgs: string[], opts) => {\n const launcher = getLauncher(opts);\n // Normalize the plugins and themes\n const plugins = await launcher.downloadPlugins(parsePlugins(opts.plugin));\n const themes = await launcher.downloadThemes(parseThemes(opts.theme));\n const copy: boolean = opts.copy ?? false;\n const launchArgs = {\n appVersion: opts.version, installerVersion: opts.installer,\n vault: vault,\n copy: copy,\n args: obsidianArgs,\n plugins: plugins,\n themes: themes,\n } as const\n\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n ...launchArgs,\n plugins: [...plugins, {repo: \"pjeby/hot-reload\"}],\n spawnOptions: {\n detached: false,\n stdio: \"pipe\",\n }\n })\n if (copy) {\n consola.log(`Vault copied to ${vaultCopy}`);\n }\n proc.stdout!.on('data', data => consola.log(`obsidian: ${data}`));\n proc.stderr!.on('data', data => consola.log(`obsidian: ${data}`));\n const procExit = new Promise<number>((resolve) => proc.on('exit', (code) => resolve(code ?? -1)));\n\n for (const plugin of plugins) {\n if (plugin.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"main.js\", \"styles.css\", \"data.json\"].map(f => path.join(plugin.path, f)),\n async () => {\n consola.log(`Detected change to \"${plugin.id}\"`);\n try {\n await launcher.installPlugins(vaultCopy!, [plugin]);\n } catch (e) {\n consola.error(`Failed to update plugin \"${plugin.id}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n for (const theme of themes) {\n if (theme.originalType == \"local\") {\n watchFiles(\n [\"manifest.json\", \"theme.css\"].map(f => path.join(theme.path, f)),\n async () => {\n consola.log(`Detected change to \"${theme.name}\"`);\n try {\n await launcher.installThemes(vaultCopy!, [theme]);\n } catch (e) {\n consola.error(`Failed to update theme \"${theme.name}\": ${e}`)\n }\n },\n {interval: 500, persistent: false, debounce: 1000},\n )\n }\n }\n\n const cleanup = async () => {\n proc.kill(\"SIGTERM\");\n await procExit;\n await fsAsync.rm(configDir, {recursive: true, force: true});\n process.exit(1);\n }\n process.on('SIGINT', cleanup);\n process.on('exit', cleanup);\n\n consola.log(\"Watching for changes to plugins and themes...\")\n await procExit;\n })\n\nprogram\n .command(\"install\")\n .description(\"Install plugins and themes into an Obsidian vault\")\n .argument('<vault>', 'Vault to install into')\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option(...cacheOptionArgs)\n .action(async (vault, opts) => {\n const launcher = getLauncher(opts);\n const plugins = parsePlugins(opts.plugin);\n const themes = parseThemes(opts.theme);\n await launcher.installPlugins(vault, plugins);\n await launcher.installThemes(vault, themes);\n consola.log(`Installed plugins/themes into vault.`)\n })\n\nprogram\n .command(\"download\")\n .summary(\"Download Obsidian to the cache\")\n .description(\n \"Download Obsidian to the cache.\\n\" +\n \"\\n\" + \n \"Pre-download Obsidian to the cache. Pass asset to select what variant to download, which can be one of:\\n\" +\n \" - app: Download the desktop app JS bundle\\n\" +\n \" - installer: Download the desktop installer\\n\" +\n \" - desktop: Download both the desktop app and installer (the default)\\n\" +\n \" - apk: Download the mobile app APK file\"\n )\n .argument('[asset]', 'Obsidian asset to download', \"desktop\")\n .option('-v, --version <version>', 'Obsidian version (default: \"latest\")')\n .option('-i, --installer <version>', 'Obsidian installer version (default: \"earliest\")')\n .option('--platform <platform>', \"Platform of the installer, one of linux, win32, darwin. (default: system platform)\")\n .option('--arch <arch>', \"Architecture of the installer, one of arm64, ia32, x64. (default: system arch)\")\n .option(...cacheOptionArgs)\n .action(async (asset, opts) => {\n const launcher = getLauncher(opts);\n if (asset == \"desktop\") {\n const [appVersion, installerVersion] = await launcher.resolveVersion(\n opts.version ?? \"latest\",\n opts.installerVersion ?? \"earliest\",\n );\n const installerPath = await launcher.downloadInstaller(installerVersion, {\n platform: opts.platform, arch: opts.arch,\n });\n consola.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n consola.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"app\") {\n const appPath = await launcher.downloadApp(opts.version ?? \"latest\");\n consola.log(`Downloaded Obsidian app to ${appPath}`)\n } else if (asset == \"installer\") {\n const installerPath = await launcher.downloadInstaller(opts.installer ?? opts.version ?? \"latest\", {\n platform: opts.platform, arch: opts.arch,\n });\n consola.log(`Downloaded Obsidian installer to ${installerPath}`)\n } else if (asset == \"apk\") {\n const apkPath = await launcher.downloadAndroid(opts.version ?? \"latest\");\n consola.log(`Downloaded Obsidian apk to ${apkPath}`)\n } else {\n throw Error(`Invalid asset type ${asset}`)\n }\n })\n\nprogram\n .command(\"update-version-list\", {hidden: true})\n .summary(\"Collect Obsidian version information into a single file\")\n .description(\n \"Collect Obsidian version information into a single file.\\n\" +\n \"\\n\" +\n \"This command is used to collect Obsidian version information in one place including download links, the \" +\n \"minimum installer version, and the internal Electron version for every Obsidian release and beta version. \" +\n \"This info is available and automatically kept up to date at \" +\n \"https://raw.githubusercontent.com/jesse-r-s-hines/wdio-obsidian-service/HEAD/obsidian-versions.json \" +\n \"but you can use this command to recreate the file manually if you want.\"\n )\n .argument('dest', 'Path to output. If it already exists, it will update the information instead of creating it from scratch.')\n .option(...cacheOptionArgs)\n .option('--max-instances <count>', \"Number of parallel Obsidian instances to launch when checking Electron versions\", \"1\")\n .action(async (dest, opts) => {\n let versionInfos: ObsidianVersionList|undefined;\n try {\n versionInfos = JSON.parse(await fsAsync.readFile(dest, \"utf-8\"))\n } catch {\n versionInfos = undefined;\n }\n const maxInstances = Number(opts.maxInstances)\n if (isNaN(maxInstances)) {\n throw Error(`Invalid number ${opts.maxInstances}`)\n }\n\n const launcher = getLauncher(opts);\n versionInfos = await launcher.updateVersionList(versionInfos, { maxInstances });\n await fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4) + \"\\n\");\n consola.log(`Wrote updated version information to ${dest}`)\n })\n\nprogram\n .parseAsync()\n .catch((err) => {\n consola.error(err?.message ?? err.toString())\n process.exit(1);\n });\n"],"mappings":";;;;;;;;AACA,SAAS,eAAe;AAKxB,OAAO,UAAU;AACjB,OAAO,aAAa;AAGpB,SAAS,aAAa,UAAoB,CAAC,GAAkB;AACzD,SAAO,QAAQ,IAAI,CAAC,MAAc;AAC9B,QAAI,EAAE,WAAW,KAAK,GAAG;AACrB,YAAM,CAAC,IAAI,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC7C,aAAO,EAAC,IAAI,QAAO;AAAA,IACvB,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,YAAM,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/C,aAAO,EAAC,MAAM,QAAO;AAAA,IACzB,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,aAAO,EAAC,MAAM,EAAE,MAAM,CAAC,EAAC;AAAA,IAC5B,OAAO;AACH,aAAO,EAAC,MAAM,EAAC;AAAA,IACnB;AAAA,EACJ,CAAC;AACL;AAEA,SAAS,YAAY,SAAmB,CAAC,GAAiB;AACtD,SAAO,OAAO,IAAI,CAAC,GAAW,MAAc;AACxC,QAAI;AACJ,QAAI,EAAE,WAAW,OAAO,GA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M,eAAe,OAAO,KAAK,YAAY;AAC7C,MAAI,MAAM,YAAY,GAAG;AACrB,UAAM,MAAM,kBAAkB,KAAK,YAAY,EAAE;AAAA,EACrD;AAEA,QAAM,WAAW,YAAY,IAAI;AACjC,iBAAe,MAAM,SAAS,kBAAkB,cAAc,EAAE,aAAa,CAAC;AAC9E,QAAM,QAAQ,UAAU,MAAM,KAAK,UAAU,cAAc,QAAW,CAAC,IAAI,IAAI;AAC/E,UAAQ,IAAI,wCAAwC,IAAI,EAAE;AAC9D,CAAC;AAEL,QACK,WAAW,EACX,MAAM,CAAC,QAAQ;AACZ,UAAQ,MAAM,KAAK,WAAW,IAAI,SAAS,CAAC;AAC5C,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
package/dist/index.cjs CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEPJSKILHcjs = require('./chunk-EPJSKILH.cjs');
3
+
4
+ var _chunkGVT27UTKcjs = require('./chunk-GVT27UTK.cjs');
4
5
  require('./chunk-MNS2C2HB.cjs');
5
6
 
6
7
  // src/index.ts
7
- var index_default = _chunkEPJSKILHcjs.ObsidianLauncher;
8
+ var index_default = _chunkGVT27UTKcjs.ObsidianLauncher;
9
+
8
10
 
9
11
 
10
- exports.default = index_default;
12
+ exports.default = index_default; exports.minSupportedObsidianVersion = _chunkGVT27UTKcjs.minSupportedObsidianVersion;
11
13
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACCA,IAAO,cAAA,EAAQ,kCAAA;ADCf;AACE;AACF,gCAAC","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/index.cjs","sourcesContent":[null,"/**\n * @module\n * @document ../README.md\n */\nimport { ObsidianLauncher } from \"./launcher.js\"\n\nexport default ObsidianLauncher;\nexport type {\n ObsidianVersionList, ObsidianVersionInfo, ObsidianInstallerInfo, PluginEntry, DownloadedPluginEntry, ThemeEntry,\n DownloadedThemeEntry,\n} from \"./types.js\";\nexport type { ObsidianCommunityPlugin, ObsidianCommunityTheme } from \"./obsidianTypes.js\";\n"]}
1
+ {"version":3,"sources":["/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACAA,IAAO,cAAA,EAAQ,kCAAA;ADEf;AACE;AACA;AACF,qHAAC","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/index.cjs","sourcesContent":[null,"/**\n * @module\n * @document ../README.md\n */\nimport { ObsidianLauncher } from \"./launcher.js\"\n\nexport default ObsidianLauncher;\nexport { minSupportedObsidianVersion } from \"./launcher.js\"\nexport type {\n ObsidianVersionList, ObsidianVersionInfo, ObsidianInstallerInfo, PluginEntry, DownloadedPluginEntry, ThemeEntry,\n DownloadedThemeEntry,\n} from \"./types.js\";\nexport type { ObsidianCommunityPlugin, ObsidianCommunityTheme } from \"./obsidianTypes.js\";\n"]}
package/dist/index.d.cts CHANGED
@@ -196,6 +196,7 @@ type ObsidianCommunityTheme = {
196
196
  modes: string[];
197
197
  };
198
198
 
199
+ declare const minSupportedObsidianVersion = "0.12.8";
199
200
  /**
200
201
  * The `ObsidianLauncher` class.
201
202
  *
@@ -300,6 +301,13 @@ declare class ObsidianLauncher {
300
301
  }): Promise<ObsidianInstallerInfo & {
301
302
  url: string;
302
303
  }>;
304
+ /**
305
+ * Log into the Obsidian api using your Insider's account so you can download beta versions.
306
+ *
307
+ * login will be called automatically when using downloadApp on an Obsidian beta version so you usually won't need
308
+ * to call this directly.
309
+ */
310
+ login(): Promise<void>;
303
311
  /**
304
312
  * Downloads the Obsidian installer for the given version and platform/arch (defaults to host platform/arch).
305
313
  * Returns the file path.
@@ -315,8 +323,8 @@ declare class ObsidianLauncher {
315
323
  * Downloads the Obsidian asar for the given version. Returns the file path.
316
324
  *
317
325
  * To download Obsidian beta versions you'll need to have an Obsidian Insiders account and either set the
318
- * `OBSIDIAN_EMAIL` and `OBSIDIAN_PASSWORD` env vars (`.env` file is supported) or pre-download the Obsidian beta
319
- * with `npx obsidian-launcher download app -v latest-beta`
326
+ * `OBSIDIAN_EMAIL` and `OBSIDIAN_PASSWORD` environment variables (`.env` file is supported) or pre-download the
327
+ * Obsidian beta with `npx obsidian-launcher download app -v latest-beta`
320
328
  *
321
329
  * @param appVersion Obsidian version to download
322
330
  */
@@ -492,4 +500,4 @@ declare class ObsidianLauncher {
492
500
  * @document ../README.md
493
501
  */
494
502
 
495
- export { type DownloadedPluginEntry, type DownloadedThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, type ObsidianInstallerInfo, type ObsidianVersionInfo, type ObsidianVersionList, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
503
+ export { type DownloadedPluginEntry, type DownloadedThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, type ObsidianInstallerInfo, type ObsidianVersionInfo, type ObsidianVersionList, type PluginEntry, type ThemeEntry, ObsidianLauncher as default, minSupportedObsidianVersion };
package/dist/index.d.ts CHANGED
@@ -196,6 +196,7 @@ type ObsidianCommunityTheme = {
196
196
  modes: string[];
197
197
  };
198
198
 
199
+ declare const minSupportedObsidianVersion = "0.12.8";
199
200
  /**
200
201
  * The `ObsidianLauncher` class.
201
202
  *
@@ -300,6 +301,13 @@ declare class ObsidianLauncher {
300
301
  }): Promise<ObsidianInstallerInfo & {
301
302
  url: string;
302
303
  }>;
304
+ /**
305
+ * Log into the Obsidian api using your Insider's account so you can download beta versions.
306
+ *
307
+ * login will be called automatically when using downloadApp on an Obsidian beta version so you usually won't need
308
+ * to call this directly.
309
+ */
310
+ login(): Promise<void>;
303
311
  /**
304
312
  * Downloads the Obsidian installer for the given version and platform/arch (defaults to host platform/arch).
305
313
  * Returns the file path.
@@ -315,8 +323,8 @@ declare class ObsidianLauncher {
315
323
  * Downloads the Obsidian asar for the given version. Returns the file path.
316
324
  *
317
325
  * To download Obsidian beta versions you'll need to have an Obsidian Insiders account and either set the
318
- * `OBSIDIAN_EMAIL` and `OBSIDIAN_PASSWORD` env vars (`.env` file is supported) or pre-download the Obsidian beta
319
- * with `npx obsidian-launcher download app -v latest-beta`
326
+ * `OBSIDIAN_EMAIL` and `OBSIDIAN_PASSWORD` environment variables (`.env` file is supported) or pre-download the
327
+ * Obsidian beta with `npx obsidian-launcher download app -v latest-beta`
320
328
  *
321
329
  * @param appVersion Obsidian version to download
322
330
  */
@@ -492,4 +500,4 @@ declare class ObsidianLauncher {
492
500
  * @document ../README.md
493
501
  */
494
502
 
495
- export { type DownloadedPluginEntry, type DownloadedThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, type ObsidianInstallerInfo, type ObsidianVersionInfo, type ObsidianVersionList, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
503
+ export { type DownloadedPluginEntry, type DownloadedThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, type ObsidianInstallerInfo, type ObsidianVersionInfo, type ObsidianVersionList, type PluginEntry, type ThemeEntry, ObsidianLauncher as default, minSupportedObsidianVersion };
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
- ObsidianLauncher
3
- } from "./chunk-O3OTELNK.js";
2
+ ObsidianLauncher,
3
+ minSupportedObsidianVersion
4
+ } from "./chunk-LBBOWJGG.js";
4
5
 
5
6
  // src/index.ts
6
7
  var index_default = ObsidianLauncher;
7
8
  export {
8
- index_default as default
9
+ index_default as default,
10
+ minSupportedObsidianVersion
9
11
  };
10
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @module\n * @document ../README.md\n */\nimport { ObsidianLauncher } from \"./launcher.js\"\n\nexport default ObsidianLauncher;\nexport type {\n ObsidianVersionList, ObsidianVersionInfo, ObsidianInstallerInfo, PluginEntry, DownloadedPluginEntry, ThemeEntry,\n DownloadedThemeEntry,\n} from \"./types.js\";\nexport type { ObsidianCommunityPlugin, ObsidianCommunityTheme } from \"./obsidianTypes.js\";\n"],"mappings":";;;;;AAMA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @module\n * @document ../README.md\n */\nimport { ObsidianLauncher } from \"./launcher.js\"\n\nexport default ObsidianLauncher;\nexport { minSupportedObsidianVersion } from \"./launcher.js\"\nexport type {\n ObsidianVersionList, ObsidianVersionInfo, ObsidianInstallerInfo, PluginEntry, DownloadedPluginEntry, ThemeEntry,\n DownloadedThemeEntry,\n} from \"./types.js\";\nexport type { ObsidianCommunityPlugin, ObsidianCommunityTheme } from \"./obsidianTypes.js\";\n"],"mappings":";;;;;;AAMA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-launcher",
3
- "version": "2.1.5",
3
+ "version": "2.2.0",
4
4
  "description": "Download and launch sandboxed Obsidian instances",
5
5
  "keywords": [
6
6
  "obsidian"
@@ -67,6 +67,7 @@
67
67
  "chrome-remote-interface": "^0.33.3",
68
68
  "classic-level": "^3.0.0",
69
69
  "commander": "^13.1.0",
70
+ "consola": "^3.4.2",
70
71
  "dotenv": "^17.2.1",
71
72
  "extract-zip": "^2.0.1",
72
73
  "lodash": "^4.17.21",