obsidian-launcher 0.2.6 → 0.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/dist/cli.cjs CHANGED
@@ -87,7 +87,7 @@ program.command("launch").summary("Download and launch Obsidian").description(
87
87
  "Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed configuration directory."
88
88
  ).argument("[vault]", "Vault to open").option(...cacheOptionArgs).option(...versionOptionArgs).option(...installerOptionArgs).option(...pluginOptionArgs).option(...themeOptionArgs).option("--copy", "Copy the vault first").action(async (vault, opts) => {
89
89
  const launcher = new (0, _chunkTEADGVGKcjs.ObsidianLauncher)({ cacheDir: opts.cache });
90
- const { proc, configDir, vault: vaultCopy } = await launcher.launch({
90
+ const { proc } = await launcher.launch({
91
91
  appVersion: opts.version,
92
92
  installerVersion: opts.installerVersion,
93
93
  vault,
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;AACF,wDAA6B;AAC7B;AACA;ACJA,sCAAwB;AACxB,gFAAc;AAGd,gEAAe;AACf,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,OAAO,EAAC,EAAA,EAAI,CAAA,CAAE,KAAA,CAAM,CAAC,EAAC,CAAA;AAAA,IAC1B,EAAA,KAAA,GAAA,CAAW,CAAA,CAAE,UAAA,CAAW,OAAO,CAAA,EAAG;AAC9B,MAAA,OAAO,EAAC,IAAA,EAAM,CAAA,CAAE,KAAA,CAAM,CAAC,EAAC,CAA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AAA;AAE4B,EAAA;AACL,IAAA;AACb,IAAA;AACoD,IAAA;AAC5C,IAAA;AAClB,EAAA;AAC4B,EAAA;AACF,EAAA;AAEiC,EAAA;AACrD,EAAA;AACT;AAIQ;AAEL,EAAA;AAQc;AAIV,EAAA;AACA,EAAA;AACuD,IAAA;AACnD,EAAA;AACW,IAAA;AACnB,EAAA;AAC6C,EAAA;AACpB,EAAA;AAC4B,IAAA;AACrD,EAAA;AAE4D,EAAA;AACH,EAAA;AACQ,EAAA;AACP,EAAA;AAC7D;AAIe;AAC8B,EAAA;AAC5B,EAAA;AACjB","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","sourcesContent":[null,"#!/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { PluginEntry, ThemeEntry } from \"./types.js\";\nimport fs from \"fs\";\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 return {id: p.slice(3)}\n } else if (p.startsWith(\"repo:\")) {\n return {repo: 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 result = {name: t.slice(5)}\n } else if (t.startsWith(\"repo:\")) {\n result = {repo: t.slice(5)}\n } else {\n result = {path: t}\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\n/**\n * Watch a list of files, calls func whenever there's an update. Debounced files changes.\n */\nfunction watchFiles(\n files: string[],\n func: (curr: fs.Stats, prev: fs.Stats) => void,\n options: { interval: number, persistent: boolean, debounce: number },\n) {\n const debouncedFunc = _.debounce((curr: fs.Stats, prev: fs.Stats) => {\n if (curr.mtimeMs > prev.mtimeMs || (curr.mtimeMs == 0 && prev.mtimeMs != 0)) {\n func(curr, prev)\n }\n }, options.debounce);\n for (const file of files) {\n fs.watchFile(file, {interval: options.interval, persistent: options.persistent}, debouncedFunc);\n }\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian version to run\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version to run\",\n \"latest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download 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(\"download\")\n .description(\"Download Obsidian to the cache\")\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .action(async (opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const [appVersion, installerVersion] = await launcher.resolveVersions(opts.version, opts.installerVersion);\n const installerPath = await launcher.downloadInstaller(installerVersion);\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\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(...cacheOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .action(async (vault, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n await launcher.installPlugins(vault, parsePlugins(opts.plugin));\n await launcher.installThemes(vault, parseThemes(opts.theme));\n console.log(`Installed plugins and themes into ${vault}`)\n })\n\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed \" +\n \"configuration directory.\"\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string|undefined, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installerVersion,\n vault: vault,\n copy: opts.copy ?? false,\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 copies in the vault. Automatically installs the \"pjeby/hot-reload\" so plugins will hot reload ' +\n 'as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\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.installerVersion,\n vault: vault,\n copy: copy,\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(data.toString()));\n proc.stderr!.on('data', data => console.log(data.toString()));\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(\"create-versions-list\")\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: any;\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 = new ObsidianLauncher({cacheDir: opts.cache});\n versionInfos = await launcher.updateObsidianVersionInfos(versionInfos, { maxInstances });\n fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4));\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;AACF,wDAA6B;AAC7B;AACA;ACJA,sCAAwB;AACxB,gFAAc;AAGd,gEAAe;AACf,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,OAAO,EAAC,EAAA,EAAI,CAAA,CAAE,KAAA,CAAM,CAAC,EAAC,CAAA;AAAA,IAC1B,EAAA,KAAA,GAAA,CAAW,CAAA,CAAE,UAAA,CAAW,OAAO,CAAA,EAAG;AAC9B,MAAA,OAAO,EAAC,IAAA,EAAM,CAAA,CAAE,KAAA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AAA;AACJ,IAAA;AACJ,EAAA;AAE4B,EAAA;AACL,IAAA;AACb,IAAA;AACoD,IAAA;AAC5C,IAAA;AAClB,EAAA;AAC4B,EAAA;AACF,EAAA;AAEiC,EAAA;AACrD,EAAA;AACT;AAIQ;AAEL,EAAA;AAQc;AAIV,EAAA;AACA,EAAA;AACuD,IAAA;AACnD,EAAA;AACW,IAAA;AACnB,EAAA;AAC6C,EAAA;AACpB,EAAA;AAC4B,IAAA;AACrD,EAAA;AAE4D,EAAA;AACH,EAAA;AACQ,EAAA;AACP,EAAA;AAC7D;AAIe;AAC8B,EAAA;AAC5B,EAAA;AACjB","file":"/home/runner/work/wdio-obsidian-service/wdio-obsidian-service/packages/obsidian-launcher/dist/cli.cjs","sourcesContent":[null,"#!/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { PluginEntry, ThemeEntry } from \"./types.js\";\nimport fs from \"fs\";\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 return {id: p.slice(3)}\n } else if (p.startsWith(\"repo:\")) {\n return {repo: 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 result = {name: t.slice(5)}\n } else if (t.startsWith(\"repo:\")) {\n result = {repo: t.slice(5)}\n } else {\n result = {path: t}\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\n/**\n * Watch a list of files, calls func whenever there's an update. Debounced files changes.\n */\nfunction watchFiles(\n files: string[],\n func: (curr: fs.Stats, prev: fs.Stats) => void,\n options: { interval: number, persistent: boolean, debounce: number },\n) {\n const debouncedFunc = _.debounce((curr: fs.Stats, prev: fs.Stats) => {\n if (curr.mtimeMs > prev.mtimeMs || (curr.mtimeMs == 0 && prev.mtimeMs != 0)) {\n func(curr, prev)\n }\n }, options.debounce);\n for (const file of files) {\n fs.watchFile(file, {interval: options.interval, persistent: options.persistent}, debouncedFunc);\n }\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian version to run\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version to run\",\n \"latest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download 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(\"download\")\n .description(\"Download Obsidian to the cache\")\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .action(async (opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const [appVersion, installerVersion] = await launcher.resolveVersions(opts.version, opts.installerVersion);\n const installerPath = await launcher.downloadInstaller(installerVersion);\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\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(...cacheOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .action(async (vault, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n await launcher.installPlugins(vault, parsePlugins(opts.plugin));\n await launcher.installThemes(vault, parseThemes(opts.theme));\n console.log(`Installed plugins and themes into ${vault}`)\n })\n\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed \" +\n \"configuration directory.\"\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string|undefined, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installerVersion,\n vault: vault,\n copy: opts.copy ?? false,\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 copies in the vault. Automatically installs the \"pjeby/hot-reload\" so plugins will hot reload ' +\n 'as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\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.installerVersion,\n vault: vault,\n copy: copy,\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(data.toString()));\n proc.stderr!.on('data', data => console.log(data.toString()));\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(\"create-versions-list\")\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: any;\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 = new ObsidianLauncher({cacheDir: opts.cache});\n versionInfos = await launcher.updateObsidianVersionInfos(versionInfos, { maxInstances });\n fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4));\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"]}
package/dist/cli.js CHANGED
@@ -87,7 +87,7 @@ program.command("launch").summary("Download and launch Obsidian").description(
87
87
  "Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed configuration directory."
88
88
  ).argument("[vault]", "Vault to open").option(...cacheOptionArgs).option(...versionOptionArgs).option(...installerOptionArgs).option(...pluginOptionArgs).option(...themeOptionArgs).option("--copy", "Copy the vault first").action(async (vault, opts) => {
89
89
  const launcher = new ObsidianLauncher({ cacheDir: opts.cache });
90
- const { proc, configDir, vault: vaultCopy } = await launcher.launch({
90
+ const { proc } = await launcher.launch({
91
91
  appVersion: opts.version,
92
92
  installerVersion: opts.installerVersion,
93
93
  vault,
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { PluginEntry, ThemeEntry } from \"./types.js\";\nimport fs from \"fs\";\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 return {id: p.slice(3)}\n } else if (p.startsWith(\"repo:\")) {\n return {repo: 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 result = {name: t.slice(5)}\n } else if (t.startsWith(\"repo:\")) {\n result = {repo: t.slice(5)}\n } else {\n result = {path: t}\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\n/**\n * Watch a list of files, calls func whenever there's an update. Debounced files changes.\n */\nfunction watchFiles(\n files: string[],\n func: (curr: fs.Stats, prev: fs.Stats) => void,\n options: { interval: number, persistent: boolean, debounce: number },\n) {\n const debouncedFunc = _.debounce((curr: fs.Stats, prev: fs.Stats) => {\n if (curr.mtimeMs > prev.mtimeMs || (curr.mtimeMs == 0 && prev.mtimeMs != 0)) {\n func(curr, prev)\n }\n }, options.debounce);\n for (const file of files) {\n fs.watchFile(file, {interval: options.interval, persistent: options.persistent}, debouncedFunc);\n }\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian version to run\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version to run\",\n \"latest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download 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(\"download\")\n .description(\"Download Obsidian to the cache\")\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .action(async (opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const [appVersion, installerVersion] = await launcher.resolveVersions(opts.version, opts.installerVersion);\n const installerPath = await launcher.downloadInstaller(installerVersion);\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\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(...cacheOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .action(async (vault, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n await launcher.installPlugins(vault, parsePlugins(opts.plugin));\n await launcher.installThemes(vault, parseThemes(opts.theme));\n console.log(`Installed plugins and themes into ${vault}`)\n })\n\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed \" +\n \"configuration directory.\"\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string|undefined, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const {proc, configDir, vault: vaultCopy} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installerVersion,\n vault: vault,\n copy: opts.copy ?? false,\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 copies in the vault. Automatically installs the \"pjeby/hot-reload\" so plugins will hot reload ' +\n 'as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\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.installerVersion,\n vault: vault,\n copy: copy,\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(data.toString()));\n proc.stderr!.on('data', data => console.log(data.toString()));\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(\"create-versions-list\")\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: any;\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 = new ObsidianLauncher({cacheDir: opts.cache});\n versionInfos = await launcher.updateObsidianVersionInfos(versionInfos, { maxInstances });\n fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4));\n console.log(`Wrote updated version information to ${dest}`)\n })\n\nprogram\n .parseAsync()\n .catch((err) => {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EAAC,UAAU,KAAK,MAAK,CAAC;AAC5D,iBAAe,MAAM,SAAS,2BAA2B,cAAc,EAAE,aAAa,CAAC;AACvF,UAAQ,UAAU,MAAM,KAAK,UAAU,cAAc,QAAW,CAAC,CAAC;AAClE,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":["#!/bin/env node\nimport { Command } from 'commander';\nimport _ from \"lodash\";\nimport { ObsidianLauncher } from \"./launcher.js\"\nimport { PluginEntry, ThemeEntry } from \"./types.js\";\nimport fs from \"fs\";\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 return {id: p.slice(3)}\n } else if (p.startsWith(\"repo:\")) {\n return {repo: 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 result = {name: t.slice(5)}\n } else if (t.startsWith(\"repo:\")) {\n result = {repo: t.slice(5)}\n } else {\n result = {path: t}\n }\n return {...result, enabled: i == themes.length - 1}\n })\n}\n\n/**\n * Watch a list of files, calls func whenever there's an update. Debounced files changes.\n */\nfunction watchFiles(\n files: string[],\n func: (curr: fs.Stats, prev: fs.Stats) => void,\n options: { interval: number, persistent: boolean, debounce: number },\n) {\n const debouncedFunc = _.debounce((curr: fs.Stats, prev: fs.Stats) => {\n if (curr.mtimeMs > prev.mtimeMs || (curr.mtimeMs == 0 && prev.mtimeMs != 0)) {\n func(curr, prev)\n }\n }, options.debounce);\n for (const file of files) {\n fs.watchFile(file, {interval: options.interval, persistent: options.persistent}, debouncedFunc);\n }\n}\n\nconst collectOpt = (curr: string, prev?: string[]) => [...(prev ?? []), curr];\n\nconst versionOptionArgs = [\n '-v, --version <version>',\n \"Obsidian version to run\",\n \"latest\",\n] as const\nconst installerOptionArgs = [\n '-i, --installer <version>',\n \"Obsidian installer version to run\",\n \"latest\",\n] as const\nconst cacheOptionArgs = [\n '-c, --cache <cache>',\n 'Directory to use as the download 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(\"download\")\n .description(\"Download Obsidian to the cache\")\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .action(async (opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const [appVersion, installerVersion] = await launcher.resolveVersions(opts.version, opts.installerVersion);\n const installerPath = await launcher.downloadInstaller(installerVersion);\n console.log(`Downloaded Obsidian installer to ${installerPath}`)\n const appPath = await launcher.downloadApp(appVersion);\n console.log(`Downloaded Obsidian app to ${appPath}`)\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(...cacheOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .action(async (vault, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n await launcher.installPlugins(vault, parsePlugins(opts.plugin));\n await launcher.installThemes(vault, parseThemes(opts.theme));\n console.log(`Installed plugins and themes into ${vault}`)\n })\n\n\nprogram\n .command(\"launch\")\n .summary(\"Download and launch Obsidian\")\n .description(\n \"Download and launch Obsidian, opening the specified vault. The Obsidian instance will have a sandboxed \" +\n \"configuration directory.\"\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string|undefined, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\n const {proc} = await launcher.launch({\n appVersion: opts.version, installerVersion: opts.installerVersion,\n vault: vault,\n copy: opts.copy ?? false,\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 copies in the vault. Automatically installs the \"pjeby/hot-reload\" so plugins will hot reload ' +\n 'as they are updated.'\n )\n .argument('[vault]', 'Vault to open')\n .option(...cacheOptionArgs)\n .option(...versionOptionArgs)\n .option(...installerOptionArgs)\n .option(...pluginOptionArgs)\n .option(...themeOptionArgs)\n .option('--copy', \"Copy the vault first\")\n .action(async (vault: string, opts) => {\n const launcher = new ObsidianLauncher({cacheDir: opts.cache});\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.installerVersion,\n vault: vault,\n copy: copy,\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(data.toString()));\n proc.stderr!.on('data', data => console.log(data.toString()));\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(\"create-versions-list\")\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: any;\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 = new ObsidianLauncher({cacheDir: opts.cache});\n versionInfos = await launcher.updateObsidianVersionInfos(versionInfos, { maxInstances });\n fsAsync.writeFile(dest, JSON.stringify(versionInfos, undefined, 4));\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;AACxB,OAAO,OAAO;AAGd,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,aAAa;AAGpB,SAAS,aAAa,UAAoB,CAAC,GAAkB;AACzD,SAAO,QAAQ,IAAI,CAAC,MAAc;AAC9B,QAAI,EAAE,WAAW,KAAK,GAAG;AACrB,aAAO,EAAC,IAAI,EAAE,MAAM,CAAC,EAAC;AAAA,IAC1B,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,eAAS,EAAC,MAAM,EAAE,MAAM,CAAC,EAAC;AAAA,IAC9B,WAAW,EAAE,WAAW,OAAO,GAAG;AAC9B,eAAS,EAAC,MAAM,EAAE,MAAM,CAAC,EA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QAAQ,sBAAsB,EAC9B,QAAQ,yDAAyD,EACjE;AAAA,EACG;AAOJ,EACC,SAAS,QAAQ,2GAA2G,EAC5H,OAAO,GAAG,eAAe,EACzB,OAAO,2BAA2B,mFAAmF,GAAG,EACxH,OAAO,OAAO,MAAM,SAAS;AAC1B,MAAI;AACJ,MAAI;AACA,mBAAe,KAAK,MAAM,MAAM,QAAQ,SAAS,MAAM,OAAO,CAAC;AAAA,EACnE,QAAQ;AACJ,mBAAe;AAAA,EACnB;AACA,QAAM,eAAe,OAAO,KAAK,YAAY;AAC7C,MAAI,MAAM,YAAY,GAAG;AACrB,UAAM,MAAM,kBAAkB,KAAK,YAAY,EAAE;AAAA,EACrD;AAEA,QAAM,WAAW,IAAI,iBAAiB,EAAC,UAAU,KAAK,MAAK,CAAC;AAC5D,iBAAe,MAAM,SAAS,2BAA2B,cAAc,EAAE,aAAa,CAAC;AACvF,UAAQ,UAAU,MAAM,KAAK,UAAU,cAAc,QAAW,CAAC,CAAC;AAClE,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":[]}
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "obsidian-launcher",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "TODO",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "require": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.cjs"
12
+ },
13
+ "import": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
8
18
  "files": [
9
19
  "dist"
10
20
  ],
@@ -13,7 +23,6 @@
13
23
  },
14
24
  "scripts": {
15
25
  "build": "tsup",
16
- "lint": "eslint src test",
17
26
  "test": "run-s test:*",
18
27
  "test:unit": "tsc --noEmit && mocha"
19
28
  },
@@ -28,7 +37,6 @@
28
37
  },
29
38
  "homepage": "https://github.com/jesse-r-s-hines/wdio-obsidian-service#readme",
30
39
  "devDependencies": {
31
- "@eslint/js": "^9.17.0",
32
40
  "@types/chai": "^5.0.1",
33
41
  "@types/chrome-remote-interface": "^0.31.14",
34
42
  "@types/lodash": "^4.17.14",
@@ -36,14 +44,12 @@
36
44
  "@types/node": "^18.11.9",
37
45
  "@types/semver": "^7.5.8",
38
46
  "chai": "^5.1.2",
39
- "eslint": "^9.17.0",
40
47
  "mocha": "^11.0.1",
41
48
  "npm-run-all": "^4.1.5",
42
49
  "ts-node": "^10.9.2",
43
50
  "tsup": "^8.3.5",
44
51
  "tsx": "^4.19.2",
45
- "typescript": "^5.7.2",
46
- "typescript-eslint": "^8.19.0"
52
+ "typescript": "^5.8.2"
47
53
  },
48
54
  "dependencies": {
49
55
  "@electron/get": "^3.1.0",