obsidian-launcher 2.2.1 → 2.3.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/README.md +4 -4
- package/dist/{chunk-LBBOWJGG.js → chunk-4A3EFE5K.js} +155 -23
- package/dist/chunk-4A3EFE5K.js.map +1 -0
- package/dist/{chunk-KNNPLZ3O.cjs → chunk-KA32F3Y5.cjs} +191 -59
- package/dist/chunk-KA32F3Y5.cjs.map +1 -0
- package/dist/cli.cjs +35 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +15 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KNNPLZ3O.cjs.map +0 -1
- package/dist/chunk-LBBOWJGG.js.map +0 -1
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;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACPA,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,CA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AA;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"]}
|
|
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,4GAA0B;AAC1B,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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AAA;AACvB,QAAA;AAC2B,UAAA;AAC/B,UAAA;AAC6B,YAAA;AACrB,UAAA;AACM,YAAA;AAClB,UAAA;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;AACE,uBAAA;AACtB,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;AAIQ;AAEL,EAAA;AAe4B;AAEG,EAAA;AACW,EAAA;AAC/B,IAAA;AACV,EAAA;AAC0B,EAAA;AACD,IAAA;AACzB,EAAA;AACJ;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 child_process from \"child_process\";\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.installer ?? \"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(\"cli\")\n .summary(\"Run an Obsidian CLI command\")\n .description(\n \"Run an Obsidian CLI command.\\n\" +\n \"\\n\" +\n \"As obsidian-launcher sandboxes the config dir for each obsidian instance, the Obsidian CLI won't connect to \" +\n \"the launched instances by default. This command handles connecting the CLI to the sandboxed Obsidian \" +\n \"instances.\\n\" +\n \"\\n\" +\n \"Like the the regular Obsidian CLI, it will connect to the instance matching the `vault=` argument if \" +\n \"present, or the cwd.\\n\" +\n \"\\n\" +\n \"The Obsidian CLI only works on Obsidian >=1.12.0 with installer >=1.11.7\\n\" +\n \"See https://help.obsidian.md/cli\\n\" +\n \"\\n\" +\n \"Example:\\n\" +\n \" npx obsidian-launcher cli file file=Dashboard\"\n )\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .action(async (args: string[]) => {\n const launcher = getLauncher({});\n const proc = child_process.spawn(...await launcher.getObsidianCli(args), {\n stdio: \"inherit\",\n })\n proc.on('close', (code) => {\n process.exit(code ?? 1);\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
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
ObsidianLauncher,
|
|
4
4
|
consola,
|
|
5
5
|
watchFiles
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4A3EFE5K.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
|
+
import child_process from "child_process";
|
|
9
10
|
import { Command } from "commander";
|
|
10
11
|
import path from "path";
|
|
11
12
|
import fsAsync from "fs/promises";
|
|
@@ -57,7 +58,7 @@ var installerOptionArgs = [
|
|
|
57
58
|
];
|
|
58
59
|
var cacheOptionArgs = [
|
|
59
60
|
"-c, --cache <cache>",
|
|
60
|
-
|
|
61
|
+
"Directory to use as the download cache. (default: OBSIDIAN_CACHE env var or ~/.obsidian-cache)"
|
|
61
62
|
];
|
|
62
63
|
var pluginOptionArgs = [
|
|
63
64
|
"-p, --plugin <plugin>",
|
|
@@ -178,7 +179,7 @@ program.command("download").summary("Download Obsidian to the cache").descriptio
|
|
|
178
179
|
if (asset == "desktop") {
|
|
179
180
|
const [appVersion, installerVersion] = await launcher.resolveVersion(
|
|
180
181
|
opts.version ?? "latest",
|
|
181
|
-
opts.
|
|
182
|
+
opts.installer ?? "earliest"
|
|
182
183
|
);
|
|
183
184
|
const installerPath = await launcher.downloadInstaller(installerVersion, {
|
|
184
185
|
platform: opts.platform,
|
|
@@ -203,6 +204,17 @@ program.command("download").summary("Download Obsidian to the cache").descriptio
|
|
|
203
204
|
throw Error(`Invalid asset type ${asset}`);
|
|
204
205
|
}
|
|
205
206
|
});
|
|
207
|
+
program.command("cli").summary("Run an Obsidian CLI command").description(
|
|
208
|
+
"Run an Obsidian CLI command.\n\nAs obsidian-launcher sandboxes the config dir for each obsidian instance, the Obsidian CLI won't connect to the launched instances by default. This command handles connecting the CLI to the sandboxed Obsidian instances.\n\nLike the the regular Obsidian CLI, it will connect to the instance matching the `vault=` argument if present, or the cwd.\n\nThe Obsidian CLI only works on Obsidian >=1.12.0 with installer >=1.11.7\nSee https://help.obsidian.md/cli\n\nExample:\n npx obsidian-launcher cli file file=Dashboard"
|
|
209
|
+
).argument("[obsidian-args...]", "Arguments to pass to Obsidian").action(async (args) => {
|
|
210
|
+
const launcher = getLauncher({});
|
|
211
|
+
const proc = child_process.spawn(...await launcher.getObsidianCli(args), {
|
|
212
|
+
stdio: "inherit"
|
|
213
|
+
});
|
|
214
|
+
proc.on("close", (code) => {
|
|
215
|
+
process.exit(code ?? 1);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
206
218
|
program.command("update-version-list", { hidden: true }).summary("Collect Obsidian version information into a single file").description(
|
|
207
219
|
"Collect Obsidian version information into a single file.\n\nThis command is used to collect Obsidian version information in one place including download links, the minimum installer version, and the internal Electron version for every Obsidian release and beta version. This info is available and automatically kept up to date at https://raw.githubusercontent.com/jesse-r-s-hines/wdio-obsidian-service/HEAD/obsidian-versions.json but you can use this command to recreate the file manually if you want."
|
|
208
220
|
).argument("dest", "Path to output. If it already exists, it will update the information instead of creating it from scratch.").option(...cacheOptionArgs).option("--max-instances <count>", "Number of parallel Obsidian instances to launch when checking Electron versions", "1").action(async (dest, opts) => {
|
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 { 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,GAAG;AACvB,YAAM,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/C,eAAS,EAAC,MAAM,QAAO;AAAA,IAC3B,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,YAAM,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM;AAC/C,eAAS,EAAC,MAAM,QAAO;AAAA,IAC3B,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,eAAS,EAAC,M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AC9D,CAAC;AAEL,QACK,WAAW,EACX,MAAM,CAAC,QAAQ;AACZ,UAAQ,MAAM,KAAK,WAAW,IAAI,SAAS,CAAC;AAC5C,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport child_process from \"child_process\";\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.installer ?? \"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(\"cli\")\n .summary(\"Run an Obsidian CLI command\")\n .description(\n \"Run an Obsidian CLI command.\\n\" +\n \"\\n\" +\n \"As obsidian-launcher sandboxes the config dir for each obsidian instance, the Obsidian CLI won't connect to \" +\n \"the launched instances by default. This command handles connecting the CLI to the sandboxed Obsidian \" +\n \"instances.\\n\" +\n \"\\n\" +\n \"Like the the regular Obsidian CLI, it will connect to the instance matching the `vault=` argument if \" +\n \"present, or the cwd.\\n\" +\n \"\\n\" +\n \"The Obsidian CLI only works on Obsidian >=1.12.0 with installer >=1.11.7\\n\" +\n \"See https://help.obsidian.md/cli\\n\" +\n \"\\n\" +\n \"Example:\\n\" +\n \" npx obsidian-launcher cli file file=Dashboard\"\n )\n .argument('[obsidian-args...]', 'Arguments to pass to Obsidian')\n .action(async (args: string[]) => {\n const launcher = getLauncher({});\n const proc = child_process.spawn(...await launcher.getObsidianCli(args), {\n stdio: \"inherit\",\n })\n proc.on('close', (code) => {\n process.exit(code ?? 1);\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,OAAO,mBAAmB;AAC1B,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,MAA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@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkKA32F3Y5cjs = require('./chunk-KA32F3Y5.cjs');
|
|
5
5
|
require('./chunk-UMVJ7W6K.cjs');
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
-
var index_default =
|
|
8
|
+
var index_default = _chunkKA32F3Y5cjs.ObsidianLauncher;
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.default = index_default; exports.minSupportedObsidianVersion =
|
|
12
|
+
exports.default = index_default; exports.minSupportedObsidianVersion = _chunkKA32F3Y5cjs.minSupportedObsidianVersion;
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -215,7 +215,7 @@ declare class ObsidianLauncher {
|
|
|
215
215
|
private obsidianApiToken;
|
|
216
216
|
/**
|
|
217
217
|
* Construct an ObsidianLauncher.
|
|
218
|
-
* @param opts.cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or
|
|
218
|
+
* @param opts.cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ~/.obsidian-cache.
|
|
219
219
|
* @param opts.versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
|
|
220
220
|
* @param opts.communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
|
|
221
221
|
* @param opts.communityThemesUrl Custom `community-css-themes.json` url. Can be a file URL.
|
|
@@ -493,6 +493,33 @@ declare class ObsidianLauncher {
|
|
|
493
493
|
* @param appVersion Obsidian app version
|
|
494
494
|
*/
|
|
495
495
|
isAvailable(appVersion: string): Promise<boolean>;
|
|
496
|
+
/**
|
|
497
|
+
* Return the command needed to run the Obsidian CLI.
|
|
498
|
+
*
|
|
499
|
+
* As obsidian-launcher sandboxes the config dir for each Obsidian instance, the Obsidian CLI won't connect to the
|
|
500
|
+
* launched instances by default. This method takes Obsidian CLI args, and then returns an [executable, args] tuple
|
|
501
|
+
* that can be used to launch the Obsidian CLI against the sandboxed instances.
|
|
502
|
+
*
|
|
503
|
+
* Like the the regular Obsidian CLI, it will connect to the instance matching the `vault=` argument if present, or
|
|
504
|
+
* the cwd.
|
|
505
|
+
*
|
|
506
|
+
* Just pass the result to child_process.spawn or child_process.execFile to run the command.
|
|
507
|
+
*
|
|
508
|
+
* Example:
|
|
509
|
+
* ```js
|
|
510
|
+
* import child_process from "child_process";
|
|
511
|
+
* import util from "util";
|
|
512
|
+
* const execFile = util.promisify(child_process.execFile);
|
|
513
|
+
* const [executable, args] = await launcher.getObsidianCli(["file", "file=Dashboard"]);
|
|
514
|
+
* const {stdout, stderr} = await execFile(executable, args);
|
|
515
|
+
* ```
|
|
516
|
+
*
|
|
517
|
+
* The Obsidian CLI only works on Obsidian >=1.12.0 with installer >=1.11.7.
|
|
518
|
+
* See https://help.obsidian.md/cli
|
|
519
|
+
*
|
|
520
|
+
* @returns [executable, args] tuple
|
|
521
|
+
*/
|
|
522
|
+
getObsidianCli(args: string[]): Promise<[string, string[]]>;
|
|
496
523
|
}
|
|
497
524
|
|
|
498
525
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ declare class ObsidianLauncher {
|
|
|
215
215
|
private obsidianApiToken;
|
|
216
216
|
/**
|
|
217
217
|
* Construct an ObsidianLauncher.
|
|
218
|
-
* @param opts.cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or
|
|
218
|
+
* @param opts.cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ~/.obsidian-cache.
|
|
219
219
|
* @param opts.versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
|
|
220
220
|
* @param opts.communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
|
|
221
221
|
* @param opts.communityThemesUrl Custom `community-css-themes.json` url. Can be a file URL.
|
|
@@ -493,6 +493,33 @@ declare class ObsidianLauncher {
|
|
|
493
493
|
* @param appVersion Obsidian app version
|
|
494
494
|
*/
|
|
495
495
|
isAvailable(appVersion: string): Promise<boolean>;
|
|
496
|
+
/**
|
|
497
|
+
* Return the command needed to run the Obsidian CLI.
|
|
498
|
+
*
|
|
499
|
+
* As obsidian-launcher sandboxes the config dir for each Obsidian instance, the Obsidian CLI won't connect to the
|
|
500
|
+
* launched instances by default. This method takes Obsidian CLI args, and then returns an [executable, args] tuple
|
|
501
|
+
* that can be used to launch the Obsidian CLI against the sandboxed instances.
|
|
502
|
+
*
|
|
503
|
+
* Like the the regular Obsidian CLI, it will connect to the instance matching the `vault=` argument if present, or
|
|
504
|
+
* the cwd.
|
|
505
|
+
*
|
|
506
|
+
* Just pass the result to child_process.spawn or child_process.execFile to run the command.
|
|
507
|
+
*
|
|
508
|
+
* Example:
|
|
509
|
+
* ```js
|
|
510
|
+
* import child_process from "child_process";
|
|
511
|
+
* import util from "util";
|
|
512
|
+
* const execFile = util.promisify(child_process.execFile);
|
|
513
|
+
* const [executable, args] = await launcher.getObsidianCli(["file", "file=Dashboard"]);
|
|
514
|
+
* const {stdout, stderr} = await execFile(executable, args);
|
|
515
|
+
* ```
|
|
516
|
+
*
|
|
517
|
+
* The Obsidian CLI only works on Obsidian >=1.12.0 with installer >=1.11.7.
|
|
518
|
+
* See https://help.obsidian.md/cli
|
|
519
|
+
*
|
|
520
|
+
* @returns [executable, args] tuple
|
|
521
|
+
*/
|
|
522
|
+
getObsidianCli(args: string[]): Promise<[string, string[]]>;
|
|
496
523
|
}
|
|
497
524
|
|
|
498
525
|
/**
|
package/dist/index.js
CHANGED