obsidian-launcher 0.0.1

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.
@@ -0,0 +1,305 @@
1
+ import child_process from 'child_process';
2
+
3
+ /**
4
+ * Type of the obsidian-versions.json file.
5
+ */
6
+ type ObsidianVersionInfos = {
7
+ metadata: {
8
+ commit_date: string;
9
+ commit_sha: string;
10
+ timestamp: string;
11
+ };
12
+ versions: ObsidianVersionInfo[];
13
+ };
14
+ type ObsidianVersionInfo = {
15
+ version: string;
16
+ minInstallerVersion: string;
17
+ maxInstallerVersion: string;
18
+ isBeta: boolean;
19
+ gitHubRelease?: string;
20
+ downloads: {
21
+ appImage?: string;
22
+ appImageArm?: string;
23
+ apk?: string;
24
+ asar?: string;
25
+ dmg?: string;
26
+ exe?: string;
27
+ };
28
+ electronVersion?: string;
29
+ chromeVersion?: string;
30
+ nodeVersion?: string;
31
+ };
32
+ type ObsidianCommunityPlugin = {
33
+ id: string;
34
+ name: string;
35
+ author: string;
36
+ description: string;
37
+ repo: string;
38
+ };
39
+ type ObsidianCommunityTheme = {
40
+ name: string;
41
+ author: string;
42
+ repo: string;
43
+ screenshot: string;
44
+ modes: string[];
45
+ };
46
+ type BasePluginEntry = {
47
+ /** Set false to install the plugin but start it disabled. Default true. */
48
+ enabled?: boolean;
49
+ };
50
+ type LocalPluginEntry = BasePluginEntry & {
51
+ /** Path on disk to the plugin to install. */
52
+ path: string;
53
+ };
54
+ type LocalPluginEntryWithId = LocalPluginEntry & {
55
+ id: string;
56
+ };
57
+ type GitHubPluginEntry = BasePluginEntry & {
58
+ /** Github repo of the plugin to install, e.g. "some-user/some-plugin". */
59
+ repo: string;
60
+ /** Version of the plugin to install. Defaults to latest. */
61
+ version?: string;
62
+ };
63
+ type CommunityPluginEntry = BasePluginEntry & {
64
+ /** Plugin ID to install from Obsidian community plugins. */
65
+ id: string;
66
+ /** Version of the plugin to install. Defaults to latest. */
67
+ version?: string;
68
+ };
69
+ /**
70
+ * A plugin to install. Can be a simple string path to the local plugin to install, or an object.
71
+ * If an object set one of `path` (to install a local plugin), `repo` (to install a plugin from github), or `id` (to
72
+ * install a community plugin). You can also pass `enabled: false` to install the plugin, but start it disabled by
73
+ * default.
74
+ */
75
+ type PluginEntry = string | LocalPluginEntry | GitHubPluginEntry | CommunityPluginEntry;
76
+ type BaseThemeEntry = {
77
+ /**
78
+ * Set false to install the theme but not enable it. Defaults to true.
79
+ * Only one theme can be enabled.
80
+ */
81
+ enabled?: boolean;
82
+ };
83
+ type LocalThemeEntry = BaseThemeEntry & {
84
+ /** Path on disk to the theme to install. */
85
+ path: string;
86
+ };
87
+ type LocalThemeEntryWithName = LocalPluginEntry & {
88
+ name: string;
89
+ };
90
+ type GitHubThemeEntry = BaseThemeEntry & {
91
+ /** Github repo of the theme to install, e.g. "some-user/some-theme". */
92
+ repo: string;
93
+ };
94
+ type CommunityThemeEntry = BaseThemeEntry & {
95
+ /** Theme name to install from Obsidian community themes. */
96
+ name: string;
97
+ };
98
+ /**
99
+ * A theme to install. Can be a simple string path to the local theme to install, or an object.
100
+ * If an object, set one of `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to
101
+ * install a community theme). You can also pass `enabled: false` to install the theme, but start it disabled by
102
+ * default. You can only have one enabled theme, so if you pass multiple you'll have to disable all but one.
103
+ */
104
+ type ThemeEntry = string | LocalThemeEntry | GitHubThemeEntry | CommunityThemeEntry;
105
+
106
+ /**
107
+ * Handles downloading Obsidian versions, plugins, and themes and launching obsidian with sandboxed configuration.
108
+ */
109
+ declare class ObsidianLauncher {
110
+ readonly cacheDir: string;
111
+ readonly versionsUrl: string;
112
+ readonly communityPluginsUrl: string;
113
+ readonly communityThemesUrl: string;
114
+ /** Cached requests from cachedFetch() */
115
+ private metadataCache;
116
+ /**
117
+ * Construct an ObsidianLauncher.
118
+ * @param cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ".obsidian-cache".
119
+ * @param versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
120
+ * @param communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
121
+ * @param communityThemes Custom `community-css-themes.json` url. Can be a file URL.
122
+ */
123
+ constructor(options?: {
124
+ cacheDir?: string;
125
+ versionsUrl?: string;
126
+ communityPluginsUrl?: string;
127
+ communityThemesUrl?: string;
128
+ });
129
+ /**
130
+ * Returns file content fetched from url as JSON. Caches content to dest and uses that cache if its more recent than
131
+ * cacheDuration ms or if there are network errors.
132
+ */
133
+ private cachedFetch;
134
+ /** Get information about all available Obsidian versions. */
135
+ getVersions(): Promise<ObsidianVersionInfo[]>;
136
+ /** Get information about all available community plugins. */
137
+ getCommunityPlugins(): Promise<ObsidianCommunityPlugin[]>;
138
+ /** Get information about all available community themes. */
139
+ getCommunityThemes(): Promise<ObsidianCommunityTheme[]>;
140
+ /**
141
+ * Resolves Obsidian version strings to absolute obsidian versions.
142
+ * @param appVersion Obsidian version string or "latest" or "latest-beta"
143
+ * @param installerVersion Obsidian version string or "latest" or "earliest"
144
+ * @returns [appVersion, installerVersion] with any "latest" etc. resolved to specific versions.
145
+ */
146
+ resolveVersions(appVersion: string, installerVersion?: string): Promise<[string, string]>;
147
+ /** Gets details about an Obsidian version */
148
+ getVersionInfo(version: string): Promise<ObsidianVersionInfo>;
149
+ /**
150
+ * Downloads the Obsidian installer for the given version and platform. Returns the file path.
151
+ * @param installerVersion Version to download.
152
+ */
153
+ downloadInstaller(installerVersion: string): Promise<string>;
154
+ /**
155
+ * Helper for downloadInstaller that doesn't require the obsidian-versions.json file so it can be used in
156
+ * updateObsidianVersionInfos
157
+ */
158
+ private downloadInstallerFromVersionInfo;
159
+ /**
160
+ * Downloads the Obsidian asar for the given version and platform. Returns the file path.
161
+ * @param appVersion Version to download.
162
+ */
163
+ downloadApp(appVersion: string): Promise<string>;
164
+ /**
165
+ * Downloads chromedriver for the given Obsidian version.
166
+ *
167
+ * wdio will download chromedriver from the Chrome for Testing API automatically (see
168
+ * https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints). However, Google has only put
169
+ * chromedriver since v115.0.5763.0 in that API, so wdio can't download older versions of chromedriver. As of
170
+ * Obsidian v1.7.7, minInstallerVersion is v0.14.5 which runs on chromium v100.0.4896.75. Here we download
171
+ * chromedriver for older versions ourselves using the @electron/get package which fetches it from
172
+ * https://github.com/electron/electron/releases.
173
+ */
174
+ downloadChromedriver(installerVersion: string): Promise<string>;
175
+ /** Gets the latest version of a plugin. */
176
+ private getLatestPluginVersion;
177
+ /**
178
+ * Downloads a plugin from a GitHub repo to the cache.
179
+ * @param repo Repo
180
+ * @param version Version of the plugin to install or "latest"
181
+ * @returns path to the downloaded plugin
182
+ */
183
+ private downloadGitHubPlugin;
184
+ /**
185
+ * Downloads a community plugin to the cache.
186
+ * @param id Id of the plugin
187
+ * @param version Version of the plugin to install, or "latest"
188
+ * @returns path to the downloaded plugin
189
+ */
190
+ private downloadCommunityPlugin;
191
+ /**
192
+ * Downloads a list of plugins to the cache and returns a list of LocalPluginEntry with the downloaded paths.
193
+ * Also adds the `id` property to the plugins based on the manifest.
194
+ *
195
+ * You can download plugins from GitHub using `{repo: "org/repo"}` and community plugins using `{id: 'plugin-id'}`.
196
+ * Local plugins will just be passed through.
197
+ */
198
+ downloadPlugins(plugins: PluginEntry[]): Promise<LocalPluginEntryWithId[]>;
199
+ /** Gets the latest version of a theme. */
200
+ private getLatestThemeVersion;
201
+ /**
202
+ * Downloads a theme from a GitHub repo to the cache.
203
+ * @param repo Repo
204
+ * @returns path to the downloaded theme
205
+ */
206
+ private downloadGitHubTheme;
207
+ /**
208
+ * Downloads a community theme to the cache.
209
+ * @param name name of the theme
210
+ * @returns path to the downloaded theme
211
+ */
212
+ private downloadCommunityTheme;
213
+ /**
214
+ * Downloads a list of themes to the cache and returns a list of LocalThemeEntry with the downloaded paths.
215
+ * Also adds the `name` property to the plugins based on the manifest.
216
+ *
217
+ * You can download themes from GitHub using `{repo: "org/repo"}` and community themes using `{name: 'theme-name'}`.
218
+ * Local themes will just be passed through.
219
+ */
220
+ downloadThemes(themes: ThemeEntry[]): Promise<LocalThemeEntryWithName[]>;
221
+ /**
222
+ * Installs plugins into an Obsidian vault.
223
+ * @param vault Path to the vault to install the plugin in.
224
+ * @param plugins List plugins paths to install.
225
+ */
226
+ installPlugins(vault: string, plugins: PluginEntry[]): Promise<void>;
227
+ /**
228
+ * Installs themes into an obsidian vault.
229
+ * @param vault Path to the theme to install the plugin in.
230
+ * @param themes: List of themes to install.
231
+ */
232
+ installThemes(vault: string, themes: ThemeEntry[]): Promise<void>;
233
+ /**
234
+ * Sets up the config dir to use for the --user-data-dir in obsidian. Returns the path to the created config dir.
235
+ *
236
+ * @param appVersion Obsidian version string.
237
+ * @param installerVersion Obsidian version string.
238
+ * @param appPath Path to the asar file to install.
239
+ * @param vault Path to the vault to open in Obsidian.
240
+ * @param plugins List of plugins to install in the vault.
241
+ * @param themes List of themes to install in the vault.
242
+ * @param dest Destination path for the config dir. If omitted it will create it under `/tmp`.
243
+ */
244
+ setupConfigDir(params: {
245
+ appVersion: string;
246
+ installerVersion: string;
247
+ appPath?: string;
248
+ vault?: string;
249
+ plugins?: PluginEntry[];
250
+ themes?: ThemeEntry[];
251
+ dest?: string;
252
+ }): Promise<string>;
253
+ /**
254
+ * Copies a vault to a temporary directory.
255
+ * @returns Path to the created tmpDir.
256
+ */
257
+ copyVault(src: string): Promise<string>;
258
+ /**
259
+ * Downloads and launches Obsidian with a sandboxed config dir. Optionally open a specific vault and install plugins
260
+ * and themes first.
261
+ *
262
+ * @param appVersion Obsidian version string.
263
+ * @param installerVersion Obsidian version string.
264
+ * @param vault Path to the vault to open in Obsidian.
265
+ * @param plugins List of plugins to install in the vault.
266
+ * @param themes List of themes to install in the vault.
267
+ * @param dest Destination path for the config dir. If omitted it will create it under `/tmp`.
268
+ * @param args CLI args to pass to Obsidian
269
+ * @param spawnOptions Options to pass to `spawn`.
270
+ * @returns The launched child process and the created config dir.
271
+ */
272
+ launch(params: {
273
+ appVersion: string;
274
+ installerVersion: string;
275
+ vault?: string;
276
+ plugins?: PluginEntry[];
277
+ themes?: ThemeEntry[];
278
+ dest?: string;
279
+ args?: string[];
280
+ spawnOptions?: child_process.SpawnOptions;
281
+ }): Promise<[child_process.ChildProcess, string]>;
282
+ /**
283
+ * Extract electron and chrome versions for an Obsidian version.
284
+ */
285
+ private getDependencyVersions;
286
+ /**
287
+ * Updates the info obsidian-versions.json. The obsidian-versions.json file is used in other launcher commands
288
+ * and in wdio-obsidian-service to get metadata about Obsidian versions in one place such as minInstallerVersion and
289
+ * the internal electron version.
290
+ */
291
+ updateObsidianVersionInfos(original?: ObsidianVersionInfos, { maxInstances }?: {
292
+ maxInstances?: number | undefined;
293
+ }): Promise<ObsidianVersionInfos>;
294
+ /**
295
+ * Returns true if the Obsidian version is already in the cache.
296
+ */
297
+ isInCache(type: "app" | "installer", version: string): Promise<boolean>;
298
+ /**
299
+ * Returns true if we either have the credentails to download the version or it's already in cache.
300
+ * This is only relevant for Obsidian beta versions, as they require Obsidian insider credentials to download.
301
+ */
302
+ isAvailable(version: string): Promise<boolean>;
303
+ }
304
+
305
+ export { type CommunityPluginEntry, type CommunityThemeEntry, type GitHubPluginEntry, type GitHubThemeEntry, type LocalPluginEntry, type LocalPluginEntryWithId, type LocalThemeEntry, type LocalThemeEntryWithName, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, ObsidianLauncher, type ObsidianVersionInfo, type ObsidianVersionInfos, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
@@ -0,0 +1,305 @@
1
+ import child_process from 'child_process';
2
+
3
+ /**
4
+ * Type of the obsidian-versions.json file.
5
+ */
6
+ type ObsidianVersionInfos = {
7
+ metadata: {
8
+ commit_date: string;
9
+ commit_sha: string;
10
+ timestamp: string;
11
+ };
12
+ versions: ObsidianVersionInfo[];
13
+ };
14
+ type ObsidianVersionInfo = {
15
+ version: string;
16
+ minInstallerVersion: string;
17
+ maxInstallerVersion: string;
18
+ isBeta: boolean;
19
+ gitHubRelease?: string;
20
+ downloads: {
21
+ appImage?: string;
22
+ appImageArm?: string;
23
+ apk?: string;
24
+ asar?: string;
25
+ dmg?: string;
26
+ exe?: string;
27
+ };
28
+ electronVersion?: string;
29
+ chromeVersion?: string;
30
+ nodeVersion?: string;
31
+ };
32
+ type ObsidianCommunityPlugin = {
33
+ id: string;
34
+ name: string;
35
+ author: string;
36
+ description: string;
37
+ repo: string;
38
+ };
39
+ type ObsidianCommunityTheme = {
40
+ name: string;
41
+ author: string;
42
+ repo: string;
43
+ screenshot: string;
44
+ modes: string[];
45
+ };
46
+ type BasePluginEntry = {
47
+ /** Set false to install the plugin but start it disabled. Default true. */
48
+ enabled?: boolean;
49
+ };
50
+ type LocalPluginEntry = BasePluginEntry & {
51
+ /** Path on disk to the plugin to install. */
52
+ path: string;
53
+ };
54
+ type LocalPluginEntryWithId = LocalPluginEntry & {
55
+ id: string;
56
+ };
57
+ type GitHubPluginEntry = BasePluginEntry & {
58
+ /** Github repo of the plugin to install, e.g. "some-user/some-plugin". */
59
+ repo: string;
60
+ /** Version of the plugin to install. Defaults to latest. */
61
+ version?: string;
62
+ };
63
+ type CommunityPluginEntry = BasePluginEntry & {
64
+ /** Plugin ID to install from Obsidian community plugins. */
65
+ id: string;
66
+ /** Version of the plugin to install. Defaults to latest. */
67
+ version?: string;
68
+ };
69
+ /**
70
+ * A plugin to install. Can be a simple string path to the local plugin to install, or an object.
71
+ * If an object set one of `path` (to install a local plugin), `repo` (to install a plugin from github), or `id` (to
72
+ * install a community plugin). You can also pass `enabled: false` to install the plugin, but start it disabled by
73
+ * default.
74
+ */
75
+ type PluginEntry = string | LocalPluginEntry | GitHubPluginEntry | CommunityPluginEntry;
76
+ type BaseThemeEntry = {
77
+ /**
78
+ * Set false to install the theme but not enable it. Defaults to true.
79
+ * Only one theme can be enabled.
80
+ */
81
+ enabled?: boolean;
82
+ };
83
+ type LocalThemeEntry = BaseThemeEntry & {
84
+ /** Path on disk to the theme to install. */
85
+ path: string;
86
+ };
87
+ type LocalThemeEntryWithName = LocalPluginEntry & {
88
+ name: string;
89
+ };
90
+ type GitHubThemeEntry = BaseThemeEntry & {
91
+ /** Github repo of the theme to install, e.g. "some-user/some-theme". */
92
+ repo: string;
93
+ };
94
+ type CommunityThemeEntry = BaseThemeEntry & {
95
+ /** Theme name to install from Obsidian community themes. */
96
+ name: string;
97
+ };
98
+ /**
99
+ * A theme to install. Can be a simple string path to the local theme to install, or an object.
100
+ * If an object, set one of `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to
101
+ * install a community theme). You can also pass `enabled: false` to install the theme, but start it disabled by
102
+ * default. You can only have one enabled theme, so if you pass multiple you'll have to disable all but one.
103
+ */
104
+ type ThemeEntry = string | LocalThemeEntry | GitHubThemeEntry | CommunityThemeEntry;
105
+
106
+ /**
107
+ * Handles downloading Obsidian versions, plugins, and themes and launching obsidian with sandboxed configuration.
108
+ */
109
+ declare class ObsidianLauncher {
110
+ readonly cacheDir: string;
111
+ readonly versionsUrl: string;
112
+ readonly communityPluginsUrl: string;
113
+ readonly communityThemesUrl: string;
114
+ /** Cached requests from cachedFetch() */
115
+ private metadataCache;
116
+ /**
117
+ * Construct an ObsidianLauncher.
118
+ * @param cacheDir Path to the cache directory. Defaults to "OBSIDIAN_CACHE" env var or ".obsidian-cache".
119
+ * @param versionsUrl Custom `obsidian-versions.json` url. Can be a file URL.
120
+ * @param communityPluginsUrl Custom `community-plugins.json` url. Can be a file URL.
121
+ * @param communityThemes Custom `community-css-themes.json` url. Can be a file URL.
122
+ */
123
+ constructor(options?: {
124
+ cacheDir?: string;
125
+ versionsUrl?: string;
126
+ communityPluginsUrl?: string;
127
+ communityThemesUrl?: string;
128
+ });
129
+ /**
130
+ * Returns file content fetched from url as JSON. Caches content to dest and uses that cache if its more recent than
131
+ * cacheDuration ms or if there are network errors.
132
+ */
133
+ private cachedFetch;
134
+ /** Get information about all available Obsidian versions. */
135
+ getVersions(): Promise<ObsidianVersionInfo[]>;
136
+ /** Get information about all available community plugins. */
137
+ getCommunityPlugins(): Promise<ObsidianCommunityPlugin[]>;
138
+ /** Get information about all available community themes. */
139
+ getCommunityThemes(): Promise<ObsidianCommunityTheme[]>;
140
+ /**
141
+ * Resolves Obsidian version strings to absolute obsidian versions.
142
+ * @param appVersion Obsidian version string or "latest" or "latest-beta"
143
+ * @param installerVersion Obsidian version string or "latest" or "earliest"
144
+ * @returns [appVersion, installerVersion] with any "latest" etc. resolved to specific versions.
145
+ */
146
+ resolveVersions(appVersion: string, installerVersion?: string): Promise<[string, string]>;
147
+ /** Gets details about an Obsidian version */
148
+ getVersionInfo(version: string): Promise<ObsidianVersionInfo>;
149
+ /**
150
+ * Downloads the Obsidian installer for the given version and platform. Returns the file path.
151
+ * @param installerVersion Version to download.
152
+ */
153
+ downloadInstaller(installerVersion: string): Promise<string>;
154
+ /**
155
+ * Helper for downloadInstaller that doesn't require the obsidian-versions.json file so it can be used in
156
+ * updateObsidianVersionInfos
157
+ */
158
+ private downloadInstallerFromVersionInfo;
159
+ /**
160
+ * Downloads the Obsidian asar for the given version and platform. Returns the file path.
161
+ * @param appVersion Version to download.
162
+ */
163
+ downloadApp(appVersion: string): Promise<string>;
164
+ /**
165
+ * Downloads chromedriver for the given Obsidian version.
166
+ *
167
+ * wdio will download chromedriver from the Chrome for Testing API automatically (see
168
+ * https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints). However, Google has only put
169
+ * chromedriver since v115.0.5763.0 in that API, so wdio can't download older versions of chromedriver. As of
170
+ * Obsidian v1.7.7, minInstallerVersion is v0.14.5 which runs on chromium v100.0.4896.75. Here we download
171
+ * chromedriver for older versions ourselves using the @electron/get package which fetches it from
172
+ * https://github.com/electron/electron/releases.
173
+ */
174
+ downloadChromedriver(installerVersion: string): Promise<string>;
175
+ /** Gets the latest version of a plugin. */
176
+ private getLatestPluginVersion;
177
+ /**
178
+ * Downloads a plugin from a GitHub repo to the cache.
179
+ * @param repo Repo
180
+ * @param version Version of the plugin to install or "latest"
181
+ * @returns path to the downloaded plugin
182
+ */
183
+ private downloadGitHubPlugin;
184
+ /**
185
+ * Downloads a community plugin to the cache.
186
+ * @param id Id of the plugin
187
+ * @param version Version of the plugin to install, or "latest"
188
+ * @returns path to the downloaded plugin
189
+ */
190
+ private downloadCommunityPlugin;
191
+ /**
192
+ * Downloads a list of plugins to the cache and returns a list of LocalPluginEntry with the downloaded paths.
193
+ * Also adds the `id` property to the plugins based on the manifest.
194
+ *
195
+ * You can download plugins from GitHub using `{repo: "org/repo"}` and community plugins using `{id: 'plugin-id'}`.
196
+ * Local plugins will just be passed through.
197
+ */
198
+ downloadPlugins(plugins: PluginEntry[]): Promise<LocalPluginEntryWithId[]>;
199
+ /** Gets the latest version of a theme. */
200
+ private getLatestThemeVersion;
201
+ /**
202
+ * Downloads a theme from a GitHub repo to the cache.
203
+ * @param repo Repo
204
+ * @returns path to the downloaded theme
205
+ */
206
+ private downloadGitHubTheme;
207
+ /**
208
+ * Downloads a community theme to the cache.
209
+ * @param name name of the theme
210
+ * @returns path to the downloaded theme
211
+ */
212
+ private downloadCommunityTheme;
213
+ /**
214
+ * Downloads a list of themes to the cache and returns a list of LocalThemeEntry with the downloaded paths.
215
+ * Also adds the `name` property to the plugins based on the manifest.
216
+ *
217
+ * You can download themes from GitHub using `{repo: "org/repo"}` and community themes using `{name: 'theme-name'}`.
218
+ * Local themes will just be passed through.
219
+ */
220
+ downloadThemes(themes: ThemeEntry[]): Promise<LocalThemeEntryWithName[]>;
221
+ /**
222
+ * Installs plugins into an Obsidian vault.
223
+ * @param vault Path to the vault to install the plugin in.
224
+ * @param plugins List plugins paths to install.
225
+ */
226
+ installPlugins(vault: string, plugins: PluginEntry[]): Promise<void>;
227
+ /**
228
+ * Installs themes into an obsidian vault.
229
+ * @param vault Path to the theme to install the plugin in.
230
+ * @param themes: List of themes to install.
231
+ */
232
+ installThemes(vault: string, themes: ThemeEntry[]): Promise<void>;
233
+ /**
234
+ * Sets up the config dir to use for the --user-data-dir in obsidian. Returns the path to the created config dir.
235
+ *
236
+ * @param appVersion Obsidian version string.
237
+ * @param installerVersion Obsidian version string.
238
+ * @param appPath Path to the asar file to install.
239
+ * @param vault Path to the vault to open in Obsidian.
240
+ * @param plugins List of plugins to install in the vault.
241
+ * @param themes List of themes to install in the vault.
242
+ * @param dest Destination path for the config dir. If omitted it will create it under `/tmp`.
243
+ */
244
+ setupConfigDir(params: {
245
+ appVersion: string;
246
+ installerVersion: string;
247
+ appPath?: string;
248
+ vault?: string;
249
+ plugins?: PluginEntry[];
250
+ themes?: ThemeEntry[];
251
+ dest?: string;
252
+ }): Promise<string>;
253
+ /**
254
+ * Copies a vault to a temporary directory.
255
+ * @returns Path to the created tmpDir.
256
+ */
257
+ copyVault(src: string): Promise<string>;
258
+ /**
259
+ * Downloads and launches Obsidian with a sandboxed config dir. Optionally open a specific vault and install plugins
260
+ * and themes first.
261
+ *
262
+ * @param appVersion Obsidian version string.
263
+ * @param installerVersion Obsidian version string.
264
+ * @param vault Path to the vault to open in Obsidian.
265
+ * @param plugins List of plugins to install in the vault.
266
+ * @param themes List of themes to install in the vault.
267
+ * @param dest Destination path for the config dir. If omitted it will create it under `/tmp`.
268
+ * @param args CLI args to pass to Obsidian
269
+ * @param spawnOptions Options to pass to `spawn`.
270
+ * @returns The launched child process and the created config dir.
271
+ */
272
+ launch(params: {
273
+ appVersion: string;
274
+ installerVersion: string;
275
+ vault?: string;
276
+ plugins?: PluginEntry[];
277
+ themes?: ThemeEntry[];
278
+ dest?: string;
279
+ args?: string[];
280
+ spawnOptions?: child_process.SpawnOptions;
281
+ }): Promise<[child_process.ChildProcess, string]>;
282
+ /**
283
+ * Extract electron and chrome versions for an Obsidian version.
284
+ */
285
+ private getDependencyVersions;
286
+ /**
287
+ * Updates the info obsidian-versions.json. The obsidian-versions.json file is used in other launcher commands
288
+ * and in wdio-obsidian-service to get metadata about Obsidian versions in one place such as minInstallerVersion and
289
+ * the internal electron version.
290
+ */
291
+ updateObsidianVersionInfos(original?: ObsidianVersionInfos, { maxInstances }?: {
292
+ maxInstances?: number | undefined;
293
+ }): Promise<ObsidianVersionInfos>;
294
+ /**
295
+ * Returns true if the Obsidian version is already in the cache.
296
+ */
297
+ isInCache(type: "app" | "installer", version: string): Promise<boolean>;
298
+ /**
299
+ * Returns true if we either have the credentails to download the version or it's already in cache.
300
+ * This is only relevant for Obsidian beta versions, as they require Obsidian insider credentials to download.
301
+ */
302
+ isAvailable(version: string): Promise<boolean>;
303
+ }
304
+
305
+ export { type CommunityPluginEntry, type CommunityThemeEntry, type GitHubPluginEntry, type GitHubThemeEntry, type LocalPluginEntry, type LocalPluginEntryWithId, type LocalThemeEntry, type LocalThemeEntryWithName, type ObsidianCommunityPlugin, type ObsidianCommunityTheme, ObsidianLauncher, type ObsidianVersionInfo, type ObsidianVersionInfos, type PluginEntry, type ThemeEntry, ObsidianLauncher as default };
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import {
2
+ ObsidianLauncher
3
+ } from "./chunk-QKHJKZ5P.js";
4
+
5
+ // src/index.ts
6
+ var index_default = ObsidianLauncher;
7
+ export {
8
+ ObsidianLauncher,
9
+ index_default as default
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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, LocalPluginEntryWithId, GitHubPluginEntry, CommunityPluginEntry, PluginEntry,\n LocalThemeEntry, LocalThemeEntryWithName, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry,\n} from \"./types.js\";\n"],"mappings":";;;;;AAGA,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "obsidian-launcher",
3
+ "version": "0.0.1",
4
+ "description": "TODO",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "bin": {
12
+ "obsidian-launcher": "dist/cli.js"
13
+ },
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "lint": "eslint src test",
17
+ "test": "run-s test:*",
18
+ "test:unit": "tsc --noEmit && mocha"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/jesse-r-s-hines/wdio-obsidian-service.git"
23
+ },
24
+ "author": "jesse-r-s-hines",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/jesse-r-s-hines/wdio-obsidian-service/issues"
28
+ },
29
+ "homepage": "https://github.com/jesse-r-s-hines/wdio-obsidian-service#readme",
30
+ "devDependencies": {
31
+ "@eslint/js": "^9.17.0",
32
+ "@types/chai": "^5.0.1",
33
+ "@types/chrome-remote-interface": "^0.31.14",
34
+ "@types/lodash": "^4.17.14",
35
+ "@types/mocha": "^10.0.10",
36
+ "@types/node": "^18.11.9",
37
+ "@types/semver": "^7.5.8",
38
+ "chai": "^5.1.2",
39
+ "eslint": "^9.17.0",
40
+ "mocha": "^11.0.1",
41
+ "npm-run-all": "^4.1.5",
42
+ "ts-node": "^10.9.2",
43
+ "tsup": "^8.3.5",
44
+ "tsx": "^4.19.2",
45
+ "typescript": "^5.7.2",
46
+ "typescript-eslint": "^8.19.0"
47
+ },
48
+ "dependencies": {
49
+ "@electron/get": "^3.1.0",
50
+ "@supercharge/promise-pool": "^3.2.0",
51
+ "chrome-remote-interface": "^0.33.2",
52
+ "classic-level": "^2.0.0",
53
+ "commander": "^13.0.0",
54
+ "extract-zip": "^2.0.1",
55
+ "lodash": "^4.17.21",
56
+ "node-fetch": "^3.3.2",
57
+ "semver": "^7.6.3",
58
+ "which": "^5.0.0"
59
+ },
60
+ "engines": {
61
+ "node": ">=18"
62
+ }
63
+ }