obsidian-launcher 0.3.0 → 0.4.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/index.d.ts CHANGED
@@ -11,6 +11,10 @@ type ObsidianVersionInfos = {
11
11
  };
12
12
  versions: ObsidianVersionInfo[];
13
13
  };
14
+ /**
15
+ * Metadata about a specific Obsidian version, including the min/max compatible installer versions, download urls, and
16
+ * the internal electron version.
17
+ */
14
18
  type ObsidianVersionInfo = {
15
19
  version: string;
16
20
  minInstallerVersion?: string;
@@ -29,6 +33,9 @@ type ObsidianVersionInfo = {
29
33
  chromeVersion?: string;
30
34
  nodeVersion?: string;
31
35
  };
36
+ /**
37
+ * Schema of entries in https://github.com/obsidianmd/obsidian-releases/HEAD/community-plugins.json
38
+ */
32
39
  type ObsidianCommunityPlugin = {
33
40
  id: string;
34
41
  name: string;
@@ -36,6 +43,9 @@ type ObsidianCommunityPlugin = {
36
43
  description: string;
37
44
  repo: string;
38
45
  };
46
+ /**
47
+ * Schema of entries in https://github.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json
48
+ */
39
49
  type ObsidianCommunityTheme = {
40
50
  name: string;
41
51
  author: string;
@@ -43,25 +53,34 @@ type ObsidianCommunityTheme = {
43
53
  screenshot: string;
44
54
  modes: string[];
45
55
  };
56
+ /** @inline */
46
57
  type BasePluginEntry = {
47
58
  /** Set false to install the plugin but start it disabled. Default true. */
48
59
  enabled?: boolean;
49
60
  };
61
+ /** @inline */
50
62
  type LocalPluginEntry = BasePluginEntry & {
51
63
  /** Path on disk to the plugin to install. */
52
64
  path: string;
53
65
  };
54
- type DownloadedPluginEntry = LocalPluginEntry & {
66
+ type DownloadedPluginEntry = {
67
+ /** If the plugin is enabled */
68
+ enabled: boolean;
69
+ /** Path on disk to the downloaded plugin. */
70
+ path: string;
71
+ /** Id of the plugin */
55
72
  id: string;
56
73
  /** Type of the plugin entry before downloading */
57
74
  originalType: "local" | "github" | "community";
58
75
  };
76
+ /** @inline */
59
77
  type GitHubPluginEntry = BasePluginEntry & {
60
78
  /** Github repo of the plugin to install, e.g. "some-user/some-plugin". */
61
79
  repo: string;
62
80
  /** Version of the plugin to install. Defaults to latest. */
63
81
  version?: string;
64
82
  };
83
+ /** @inline */
65
84
  type CommunityPluginEntry = BasePluginEntry & {
66
85
  /** Plugin ID to install from Obsidian community plugins. */
67
86
  id: string;
@@ -70,11 +89,15 @@ type CommunityPluginEntry = BasePluginEntry & {
70
89
  };
71
90
  /**
72
91
  * A plugin to install. Can be a simple string path to the local plugin to install, or an object.
73
- * If an object set one of `path` (to install a local plugin), `repo` (to install a plugin from github), or `id` (to
74
- * install a community plugin). You can also pass `enabled: false` to install the plugin, but start it disabled by
75
- * default.
92
+ * If an object set one of:
93
+ * - `path` to install a local plugin
94
+ * - `repo` to install a plugin from github
95
+ * - `id` to install a community plugin
96
+ *
97
+ * You can also pass `enabled: false` to install the plugin, but start it disabled by default.
76
98
  */
77
99
  type PluginEntry = string | LocalPluginEntry | GitHubPluginEntry | CommunityPluginEntry;
100
+ /** @inline */
78
101
  type BaseThemeEntry = {
79
102
  /**
80
103
  * Set false to install the theme but not enable it. Defaults to true.
@@ -82,84 +105,111 @@ type BaseThemeEntry = {
82
105
  */
83
106
  enabled?: boolean;
84
107
  };
108
+ /** @inline */
85
109
  type LocalThemeEntry = BaseThemeEntry & {
86
110
  /** Path on disk to the theme to install. */
87
111
  path: string;
88
112
  };
89
- type DownloadedThemeEntry = LocalPluginEntry & {
113
+ type DownloadedThemeEntry = {
114
+ /** If the theme is enabled */
115
+ enabled: boolean;
116
+ /** Path on disk to the downloaded theme. */
117
+ path: string;
118
+ /** Name of the theme */
90
119
  name: string;
91
- /** Type of the plugin entry before downloading */
120
+ /** Type of the theme entry before downloading */
92
121
  originalType: "local" | "github" | "community";
93
122
  };
123
+ /** @inline */
94
124
  type GitHubThemeEntry = BaseThemeEntry & {
95
125
  /** Github repo of the theme to install, e.g. "some-user/some-theme". */
96
126
  repo: string;
97
127
  };
128
+ /** @inline */
98
129
  type CommunityThemeEntry = BaseThemeEntry & {
99
130
  /** Theme name to install from Obsidian community themes. */
100
131
  name: string;
101
132
  };
102
133
  /**
103
134
  * A theme to install. Can be a simple string path to the local theme to install, or an object.
104
- * If an object, set one of `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to
105
- * install a community theme). You can also pass `enabled: false` to install the theme, but start it disabled by
106
- * default. You can only have one enabled theme, so if you pass multiple you'll have to disable all but one.
135
+ * If an object, set one of:
136
+ * - `path` to install a local theme
137
+ * - `repo` to install a theme from github
138
+ * - `name` to install a community theme
139
+ *
140
+ * You can also pass `enabled: false` to install the theme, but start it disabled by default. You can only have one
141
+ * enabled theme, so if you pass multiple you need to disable all but one.
107
142
  */
108
143
  type ThemeEntry = string | LocalThemeEntry | GitHubThemeEntry | CommunityThemeEntry;
109
144
 
110
145
  /**
111
- * Handles downloading Obsidian versions, plugins, and themes and launching obsidian with sandboxed configuration.
146
+ * Helper class that handles downloading and installing Obsidian versions, plugins, and themes and launching Obsidian
147
+ * with sandboxed configuration directories.
112
148
  */
113
149
  declare class ObsidianLauncher {
114
150
  readonly cacheDir: string;
115
151
  readonly versionsUrl: string;
116
152
  readonly communityPluginsUrl: string;
117
153
  readonly communityThemesUrl: string;
154
+ readonly cacheDuration: number;
118
155
  /** Cached metadata files and requests */
119
156
  private metadataCache;
120
157
  /**
121
158
  * Construct an ObsidianLauncher.
122
- * @param cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ".obsidian-cache".
123
- * @param versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
124
- * @param communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
125
- * @param communityThemes Custom `community-css-themes.json` url. Can be a file URL.
159
+ * @param options.cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ".obsidian-cache".
160
+ * @param options.versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
161
+ * @param options.communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
162
+ * @param options.communityThemesUrl Custom `community-css-themes.json` url. Can be a file URL.
163
+ * @param options.cacheDuration If the cached version list is older than this (in ms), refetch it. Defaults to 30 minutes.
126
164
  */
127
165
  constructor(options?: {
128
166
  cacheDir?: string;
129
167
  versionsUrl?: string;
130
168
  communityPluginsUrl?: string;
131
169
  communityThemesUrl?: string;
170
+ cacheDuration?: number;
132
171
  });
133
172
  /**
134
173
  * Returns file content fetched from url as JSON. Caches content to dest and uses that cache if its more recent than
135
174
  * cacheDuration ms or if there are network errors.
136
175
  */
137
176
  private cachedFetch;
177
+ /**
178
+ * Get parsed content of the current project's manifest.json
179
+ */
138
180
  private getRootManifest;
139
- /** Get information about all available Obsidian versions. */
181
+ /**
182
+ * Get information about all available Obsidian versions.
183
+ */
140
184
  getVersions(): Promise<ObsidianVersionInfo[]>;
141
- /** Get information about all available community plugins. */
185
+ /**
186
+ * Get information about all available community plugins.
187
+ */
142
188
  getCommunityPlugins(): Promise<ObsidianCommunityPlugin[]>;
143
- /** Get information about all available community themes. */
189
+ /**
190
+ * Get information about all available community themes.
191
+ */
144
192
  getCommunityThemes(): Promise<ObsidianCommunityTheme[]>;
145
193
  /**
146
194
  * Resolves Obsidian app and installer version strings to absolute versions.
147
- * @param appVersion Obsidian version string or "latest", "latest-beta" or "earliest". "earliest" will use the
148
- * minAppVersion set in your manifest.json.
149
- * @param installerVersion Obsidian version string or "latest" or "earliest". "earliest" will use the minimum
150
- * installer version compatible with the appVersion.
195
+ * @param appVersion Obsidian version string or one of
196
+ * - "latest": Get the current latest non-beta Obsidian version
197
+ * - "latest-beta": Get the current latest beta Obsidian version (or latest is there is no current beta)
198
+ * - "earliest": Get the `minAppVersion` set in set in your `manifest.json`
199
+ * @param installerVersion Obsidian version string or one of
200
+ * - "latest": Get the latest Obsidian installer
201
+ * - "earliest": Get the oldest Obsidian installer compatible with the specified Obsidian app version
151
202
  * @returns [appVersion, installerVersion] with any "latest" etc. resolved to specific versions.
152
203
  */
153
204
  resolveVersions(appVersion: string, installerVersion?: string): Promise<[string, string]>;
154
205
  /**
155
206
  * Gets details about an Obsidian version.
156
- * @param version Obsidian version string or "latest", "earliest", or "latest-beta". "earliest" will use the
157
- * minAppVersion set in your manifest.json.
207
+ * @param appVersion Obsidian app version (see {@link resolveVersions} for format)
158
208
  */
159
- getVersionInfo(version: string): Promise<ObsidianVersionInfo>;
209
+ getVersionInfo(appVersion: string): Promise<ObsidianVersionInfo>;
160
210
  /**
161
211
  * Downloads the Obsidian installer for the given version and platform. Returns the file path.
162
- * @param installerVersion Version to download.
212
+ * @param installerVersion Obsidian installer version to download. (see {@link resolveVersions} for format)
163
213
  */
164
214
  downloadInstaller(installerVersion: string): Promise<string>;
165
215
  /**
@@ -169,7 +219,11 @@ declare class ObsidianLauncher {
169
219
  private downloadInstallerFromVersionInfo;
170
220
  /**
171
221
  * Downloads the Obsidian asar for the given version and platform. Returns the file path.
172
- * @param appVersion Version to download.
222
+ *
223
+ * To download beta versions you'll need to have an Obsidian account with Catalyst and set the `OBSIDIAN_USERNAME`
224
+ * and `OBSIDIAN_PASSWORD` environment variables. 2FA needs to be disabled.
225
+ *
226
+ * @param appVersion Obsidian version to download (see {@link resolveVersions} for format)
173
227
  */
174
228
  downloadApp(appVersion: string): Promise<string>;
175
229
  /**
@@ -177,10 +231,11 @@ declare class ObsidianLauncher {
177
231
  *
178
232
  * wdio will download chromedriver from the Chrome for Testing API automatically (see
179
233
  * https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints). However, Google has only put
180
- * chromedriver since v115.0.5763.0 in that API, so wdio can't download older versions of chromedriver. As of
181
- * Obsidian v1.7.7, minInstallerVersion is v0.14.5 which runs on chromium v100.0.4896.75. Here we download
182
- * chromedriver for older versions ourselves using the @electron/get package which fetches it from
183
- * https://github.com/electron/electron/releases.
234
+ * chromedriver since v115.0.5763.0 in that API, so wdio can't automatically download older versions of chromedriver
235
+ * for old Electron versions. Here we download chromedriver for older versions ourselves using the @electron/get
236
+ * package which fetches chromedriver from https://github.com/electron/electron/releases.
237
+ *
238
+ * @param installerVersion Obsidian installer version (see {@link resolveVersions} for format)
184
239
  */
185
240
  downloadChromedriver(installerVersion: string): Promise<string>;
186
241
  /** Gets the latest version of a plugin. */
@@ -200,11 +255,13 @@ declare class ObsidianLauncher {
200
255
  */
201
256
  private downloadCommunityPlugin;
202
257
  /**
203
- * Downloads a list of plugins to the cache and returns a list of LocalPluginEntry with the downloaded paths.
258
+ * Downloads a list of plugins to the cache and returns a list of `DownloadedPluginEntry` with the downloaded paths.
204
259
  * Also adds the `id` property to the plugins based on the manifest.
205
260
  *
206
261
  * You can download plugins from GitHub using `{repo: "org/repo"}` and community plugins using `{id: 'plugin-id'}`.
207
262
  * Local plugins will just be passed through.
263
+ *
264
+ * @param plugins List of plugins to download.
208
265
  */
209
266
  downloadPlugins(plugins: PluginEntry[]): Promise<DownloadedPluginEntry[]>;
210
267
  /** Gets the latest version of a theme. */
@@ -222,33 +279,35 @@ declare class ObsidianLauncher {
222
279
  */
223
280
  private downloadCommunityTheme;
224
281
  /**
225
- * Downloads a list of themes to the cache and returns a list of LocalThemeEntry with the downloaded paths.
282
+ * Downloads a list of themes to the cache and returns a list of `DownloadedThemeEntry` with the downloaded paths.
226
283
  * Also adds the `name` property to the plugins based on the manifest.
227
284
  *
228
285
  * You can download themes from GitHub using `{repo: "org/repo"}` and community themes using `{name: 'theme-name'}`.
229
286
  * Local themes will just be passed through.
287
+ *
288
+ * @param themes List of themes to download
230
289
  */
231
290
  downloadThemes(themes: ThemeEntry[]): Promise<DownloadedThemeEntry[]>;
232
291
  /**
233
- * Installs plugins into an Obsidian vault.
234
- * @param vault Path to the vault to install the plugin in.
235
- * @param plugins List plugins paths to install.
292
+ * Installs plugins into an Obsidian vault
293
+ * @param vault Path to the vault to install the plugins in
294
+ * @param plugins List plugins to install
236
295
  */
237
296
  installPlugins(vault: string, plugins: PluginEntry[]): Promise<void>;
238
297
  /**
239
- * Installs themes into an obsidian vault.
240
- * @param vault Path to the theme to install the plugin in.
241
- * @param themes: List of themes to install.
298
+ * Installs themes into an Obsidian vault
299
+ * @param vault Path to the theme to install the themes in
300
+ * @param themes List of themes to install
242
301
  */
243
302
  installThemes(vault: string, themes: ThemeEntry[]): Promise<void>;
244
303
  /**
245
- * Sets up the config dir to use for the --user-data-dir in obsidian. Returns the path to the created config dir.
304
+ * Sets up the config dir to use for the `--user-data-dir` in obsidian. Returns the path to the created config dir.
246
305
  *
247
- * @param appVersion Obsidian version string.
248
- * @param installerVersion Obsidian version string.
249
- * @param appPath Path to the asar file to install. Will download if omitted.
250
- * @param vault Path to the vault to open in Obsidian.
251
- * @param dest Destination path for the config dir. If omitted it will create it under `/tmp`.
306
+ * @param params.appVersion Obsidian app version (see {@link resolveVersions} for format)
307
+ * @param params.installerVersion Obsidian version string.
308
+ * @param params.appPath Path to the asar file to install. Will download if omitted.
309
+ * @param params.vault Path to the vault to open in Obsidian.
310
+ * @param params.dest Destination path for the config dir. If omitted it will create a temporary directory.
252
311
  */
253
312
  setupConfigDir(params: {
254
313
  appVersion: string;
@@ -260,10 +319,10 @@ declare class ObsidianLauncher {
260
319
  /**
261
320
  * Sets up a vault for Obsidian, installing plugins and themes and optionally copying the vault to a temporary
262
321
  * directory first.
263
- * @param vault Path to the vault to open in Obsidian.
264
- * @param copy Whether to copy the vault to a tmpdir first. Default false.
265
- * @param plugins List of plugins to install in the vault.
266
- * @param themes List of themes to install in the vault.
322
+ * @param params.vault Path to the vault to open in Obsidian
323
+ * @param params.copy Whether to copy the vault to a tmpdir first. Default false
324
+ * @param params.plugins List of plugins to install in the vault
325
+ * @param params.themes List of themes to install in the vault
267
326
  * @returns Path to the copied vault (or just the path to the vault if copy is false)
268
327
  */
269
328
  setupVault(params: {
@@ -276,21 +335,22 @@ declare class ObsidianLauncher {
276
335
  * Downloads and launches Obsidian with a sandboxed config dir and a specifc vault open. Optionally install plugins
277
336
  * and themes first.
278
337
  *
279
- * This is just a shortcut for calling downloadApp, downloadInstaller, setupVault and setupConfDir.
338
+ * This is just a shortcut for calling `downloadApp`, `downloadInstaller`, `setupVault` and `setupConfDir`.
280
339
  *
281
- * @param appVersion Obsidian version string.
282
- * @param installerVersion Obsidian version string.
283
- * @param vault Path to the vault to open in Obsidian.
284
- * @param copy Whether to copy the vault to a tmpdir first. Default false.
285
- * @param plugins List of plugins to install in the vault.
286
- * @param themes List of themes to install in the vault.
287
- * @param args CLI args to pass to Obsidian
288
- * @param spawnOptions Options to pass to `spawn`.
289
- * @returns The launched child process and the created tmpdirs.
340
+ * @param params.appVersion Obsidian app version (see {@link resolveVersions} for format). Default "latest"
341
+ * @param params.installerVersion Obsidian installer version (see {@link resolveVersions} for format).
342
+ * Default "latest"
343
+ * @param params.vault Path to the vault to open in Obsidian
344
+ * @param params.copy Whether to copy the vault to a tmpdir first. Default false
345
+ * @param params.plugins List of plugins to install in the vault
346
+ * @param params.themes List of themes to install in the vault
347
+ * @param params.args CLI args to pass to Obsidian
348
+ * @param params.spawnOptions Options to pass to `spawn`
349
+ * @returns The launched child process and the created tmpdirs
290
350
  */
291
351
  launch(params: {
292
- appVersion: string;
293
- installerVersion: string;
352
+ appVersion?: string;
353
+ installerVersion?: string;
294
354
  copy?: boolean;
295
355
  vault?: string;
296
356
  plugins?: PluginEntry[];
@@ -312,13 +372,16 @@ declare class ObsidianLauncher {
312
372
  }): Promise<ObsidianVersionInfos>;
313
373
  /**
314
374
  * Returns true if the Obsidian version is already in the cache.
375
+ * @param type on of "app" or "installer"
376
+ * @param version Obsidian app/installer version (see {@link resolveVersions} for format)
315
377
  */
316
378
  isInCache(type: "app" | "installer", version: string): Promise<boolean>;
317
379
  /**
318
- * Returns true if we either have the credentails to download the version or it's already in cache.
380
+ * Returns true if we either have the credentials to download the version or it's already in cache.
319
381
  * This is only relevant for Obsidian beta versions, as they require Obsidian insider credentials to download.
382
+ * @param version Obsidian version (see {@link resolveVersions} for format)
320
383
  */
321
384
  isAvailable(version: string): Promise<boolean>;
322
385
  }
323
386
 
324
- export { type CommunityPluginEntry, type CommunityThemeEntry, type DownloadedPluginEntry, type DownloadedThemeEntry, type GitHubPluginEntry, type GitHubThemeEntry, type LocalPluginEntry, type LocalThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, ObsidianLauncher, type ObsidianVersionInfo, type ObsidianVersionInfos, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
387
+ export { type DownloadedPluginEntry, type DownloadedThemeEntry, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, ObsidianLauncher, type ObsidianVersionInfo, type ObsidianVersionInfos, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ObsidianLauncher
3
- } from "./chunk-DAXQJZ7Z.js";
3
+ } from "./chunk-K7DNIKI5.js";
4
4
 
5
5
  // src/index.ts
6
6
  var index_default = ObsidianLauncher;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ObsidianLauncher } from \"./launcher.js\"\n\nexport { ObsidianLauncher };\nexport default ObsidianLauncher;\nexport type {\n ObsidianVersionInfos, ObsidianVersionInfo, ObsidianCommunityPlugin, ObsidianCommunityTheme,\n LocalPluginEntry, GitHubPluginEntry, CommunityPluginEntry, PluginEntry, DownloadedPluginEntry,\n LocalThemeEntry, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry, DownloadedThemeEntry,\n} from \"./types.js\";\n"],"mappings":";;;;;AAGA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ObsidianLauncher } from \"./launcher.js\"\n\nexport { ObsidianLauncher };\nexport default ObsidianLauncher;\nexport type {\n ObsidianVersionInfos, ObsidianVersionInfo, ObsidianCommunityPlugin, ObsidianCommunityTheme,\n PluginEntry, DownloadedPluginEntry, ThemeEntry, DownloadedThemeEntry,\n} from \"./types.js\";\n"],"mappings":";;;;;AAGA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "obsidian-launcher",
3
- "version": "0.3.0",
4
- "description": "TODO",
3
+ "version": "0.4.0",
4
+ "description": "Download and launch sandboxed Obsidian instances",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "bin": {
22
- "obsidian-launcher": "dist/cli.js"
22
+ "obsidian-launcher": "./dist/cli.js"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup",
@@ -35,7 +35,7 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/jesse-r-s-hines/wdio-obsidian-service/issues"
37
37
  },
38
- "homepage": "https://github.com/jesse-r-s-hines/wdio-obsidian-service#readme",
38
+ "homepage": "https://jesse-r-s-hines.github.io/wdio-obsidian-service/modules/obsidian-launcher.html",
39
39
  "devDependencies": {
40
40
  "@types/chai": "^5.0.1",
41
41
  "@types/chrome-remote-interface": "^0.31.14",