obsidian-launcher 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/{chunk-5744ELNA.cjs → chunk-DBOVVHWF.cjs} +44 -48
- package/dist/chunk-DBOVVHWF.cjs.map +1 -0
- package/dist/{chunk-CGVVDO5H.js → chunk-IHBVELTU.js} +74 -78
- package/dist/chunk-IHBVELTU.js.map +1 -0
- package/dist/cli.cjs +6 -6
- package/dist/cli.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +25 -25
- package/dist/index.d.ts +25 -25
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5744ELNA.cjs.map +0 -1
- package/dist/chunk-CGVVDO5H.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/launcher.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import fsAsync3 from "fs/promises";
|
|
3
|
+
import fs2 from "fs";
|
|
4
4
|
import zlib from "zlib";
|
|
5
5
|
import path4 from "path";
|
|
6
6
|
import crypto from "crypto";
|
|
@@ -9,6 +9,7 @@ import { pipeline } from "stream/promises";
|
|
|
9
9
|
import { downloadArtifact } from "@electron/get";
|
|
10
10
|
import child_process2 from "child_process";
|
|
11
11
|
import semver2 from "semver";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
12
13
|
|
|
13
14
|
// src/utils.ts
|
|
14
15
|
import fsAsync from "fs/promises";
|
|
@@ -87,8 +88,9 @@ function mergeKeepUndefined(object, ...sources) {
|
|
|
87
88
|
|
|
88
89
|
// src/apis.ts
|
|
89
90
|
import _2 from "lodash";
|
|
90
|
-
import
|
|
91
|
-
import {
|
|
91
|
+
import fs from "fs";
|
|
92
|
+
import { finished } from "stream/promises";
|
|
93
|
+
import { Readable } from "stream";
|
|
92
94
|
function parseLinkHeader(linkHeader) {
|
|
93
95
|
function parseLinkData(linkData) {
|
|
94
96
|
return Object.fromEntries(
|
|
@@ -157,17 +159,10 @@ async function fetchObsidianAPI(url) {
|
|
|
157
159
|
});
|
|
158
160
|
return response;
|
|
159
161
|
}
|
|
160
|
-
async function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const response = await fetch(url);
|
|
165
|
-
if (response.ok) {
|
|
166
|
-
return response.text();
|
|
167
|
-
} else {
|
|
168
|
-
throw Error(`Request failed with ${response.status}: ${response.text()}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
162
|
+
async function downloadResponse(response, dest) {
|
|
163
|
+
const fileStream = fs.createWriteStream(dest, { flags: "w" });
|
|
164
|
+
const fetchStream = Readable.fromWeb(response.body);
|
|
165
|
+
await finished(fetchStream.pipe(fileStream));
|
|
171
166
|
}
|
|
172
167
|
|
|
173
168
|
// src/chromeLocalStorage.ts
|
|
@@ -244,7 +239,7 @@ var ChromeLocalStorage = class {
|
|
|
244
239
|
};
|
|
245
240
|
|
|
246
241
|
// src/launcherUtils.ts
|
|
247
|
-
import
|
|
242
|
+
import fsAsync2 from "fs/promises";
|
|
248
243
|
import path3 from "path";
|
|
249
244
|
import { promisify } from "util";
|
|
250
245
|
import child_process from "child_process";
|
|
@@ -258,7 +253,7 @@ function normalizeGitHubRepo(repo) {
|
|
|
258
253
|
}
|
|
259
254
|
async function extractObsidianAppImage(appImage, dest) {
|
|
260
255
|
await withTmpDir(dest, async (tmpDir) => {
|
|
261
|
-
await
|
|
256
|
+
await fsAsync2.chmod(appImage, 493);
|
|
262
257
|
await execFile(appImage, ["--appimage-extract"], { cwd: tmpDir });
|
|
263
258
|
return path3.join(tmpDir, "squashfs-root");
|
|
264
259
|
});
|
|
@@ -288,7 +283,7 @@ async function extractObsidianDmg(dmg, dest) {
|
|
|
288
283
|
const volume = proc.stdout.match(/\/Volumes\/.*$/m)[0];
|
|
289
284
|
const obsidianApp = path3.join(volume, "Obsidian.app");
|
|
290
285
|
try {
|
|
291
|
-
await
|
|
286
|
+
await fsAsync2.cp(obsidianApp, tmpDir, { recursive: true, verbatimSymlinks: true });
|
|
292
287
|
} finally {
|
|
293
288
|
await execFile("hdiutil", ["detach", volume]);
|
|
294
289
|
}
|
|
@@ -362,7 +357,7 @@ async function getElectronVersionInfo(version, binaryPath) {
|
|
|
362
357
|
}
|
|
363
358
|
await procExit;
|
|
364
359
|
await sleep(1e3);
|
|
365
|
-
await
|
|
360
|
+
await fsAsync2.rm(configDir, { recursive: true, force: true });
|
|
366
361
|
}
|
|
367
362
|
if (!dependencyVersions?.electron || !dependencyVersions?.chrome) {
|
|
368
363
|
throw Error(`Failed to extract electron and chrome versions for ${version}`);
|
|
@@ -443,27 +438,31 @@ var ObsidianLauncher = class {
|
|
|
443
438
|
* cacheDuration ms or if there are network errors.
|
|
444
439
|
*/
|
|
445
440
|
async cachedFetch(url, dest) {
|
|
446
|
-
dest = path4.
|
|
441
|
+
dest = path4.join(this.cacheDir, dest);
|
|
447
442
|
if (!(dest in this.metadataCache)) {
|
|
448
443
|
let fileContent;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
fileContent = await fsAsync4.readFile(dest, "utf-8");
|
|
444
|
+
if (url.startsWith("file:")) {
|
|
445
|
+
fileContent = await fsAsync3.readFile(fileURLToPath(url), "utf-8");
|
|
452
446
|
} else {
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
await
|
|
456
|
-
await withTmpDir(dest, async (tmpDir) => {
|
|
457
|
-
await fsAsync4.writeFile(path4.join(tmpDir, "download.json"), request.result);
|
|
458
|
-
return path4.join(tmpDir, "download.json");
|
|
459
|
-
});
|
|
460
|
-
fileContent = request.result;
|
|
461
|
-
} else if (await fileExists(dest)) {
|
|
462
|
-
console.warn(request.error);
|
|
463
|
-
console.warn(`Unable to download ${dest}, using cached file.`);
|
|
464
|
-
fileContent = await fsAsync4.readFile(dest, "utf-8");
|
|
447
|
+
const mtime = await fileExists(dest) ? (await fsAsync3.stat(dest)).mtime : void 0;
|
|
448
|
+
if (mtime && (/* @__PURE__ */ new Date()).getTime() - mtime.getTime() < this.cacheDuration) {
|
|
449
|
+
fileContent = await fsAsync3.readFile(dest, "utf-8");
|
|
465
450
|
} else {
|
|
466
|
-
|
|
451
|
+
const request = await maybe(fetch(url).then((r) => r.text()));
|
|
452
|
+
if (request.success) {
|
|
453
|
+
await fsAsync3.mkdir(path4.dirname(dest), { recursive: true });
|
|
454
|
+
await withTmpDir(dest, async (tmpDir) => {
|
|
455
|
+
await fsAsync3.writeFile(path4.join(tmpDir, "download.json"), request.result);
|
|
456
|
+
return path4.join(tmpDir, "download.json");
|
|
457
|
+
});
|
|
458
|
+
fileContent = request.result;
|
|
459
|
+
} else if (await fileExists(dest)) {
|
|
460
|
+
console.warn(request.error);
|
|
461
|
+
console.warn(`Unable to download ${dest}, using cached file.`);
|
|
462
|
+
fileContent = await fsAsync3.readFile(dest, "utf-8");
|
|
463
|
+
} else {
|
|
464
|
+
throw request.error;
|
|
465
|
+
}
|
|
467
466
|
}
|
|
468
467
|
}
|
|
469
468
|
this.metadataCache[dest] = JSON.parse(fileContent);
|
|
@@ -482,7 +481,7 @@ var ObsidianLauncher = class {
|
|
|
482
481
|
}
|
|
483
482
|
const manifestPath = path4.join(dir, "manifest.json");
|
|
484
483
|
if (await fileExists(manifestPath)) {
|
|
485
|
-
this.metadataCache["manifest.json"] = JSON.parse(await
|
|
484
|
+
this.metadataCache["manifest.json"] = JSON.parse(await fsAsync3.readFile(manifestPath, "utf-8"));
|
|
486
485
|
} else {
|
|
487
486
|
this.metadataCache["manifest.json"] = null;
|
|
488
487
|
}
|
|
@@ -493,29 +492,26 @@ var ObsidianLauncher = class {
|
|
|
493
492
|
* Get information about all available Obsidian versions.
|
|
494
493
|
*/
|
|
495
494
|
async getVersions() {
|
|
496
|
-
|
|
497
|
-
return (await this.cachedFetch(this.versionsUrl, dest)).versions;
|
|
495
|
+
return (await this.cachedFetch(this.versionsUrl, "obsidian-versions.json")).versions;
|
|
498
496
|
}
|
|
499
497
|
/**
|
|
500
498
|
* Get information about all available community plugins.
|
|
501
499
|
*/
|
|
502
500
|
async getCommunityPlugins() {
|
|
503
|
-
|
|
504
|
-
return await this.cachedFetch(this.communityPluginsUrl, dest);
|
|
501
|
+
return await this.cachedFetch(this.communityPluginsUrl, "obsidian-community-plugins.json");
|
|
505
502
|
}
|
|
506
503
|
/**
|
|
507
504
|
* Get information about all available community themes.
|
|
508
505
|
*/
|
|
509
506
|
async getCommunityThemes() {
|
|
510
|
-
|
|
511
|
-
return await this.cachedFetch(this.communityThemesUrl, dest);
|
|
507
|
+
return await this.cachedFetch(this.communityThemesUrl, "obsidian-community-css-themes.json");
|
|
512
508
|
}
|
|
513
509
|
/**
|
|
514
510
|
* Resolves Obsidian app and installer version strings to absolute versions.
|
|
515
511
|
* @param appVersion Obsidian version string or one of
|
|
516
512
|
* - "latest": Get the current latest non-beta Obsidian version
|
|
517
513
|
* - "latest-beta": Get the current latest beta Obsidian version (or latest is there is no current beta)
|
|
518
|
-
* - "earliest": Get the `minAppVersion` set in
|
|
514
|
+
* - "earliest": Get the `minAppVersion` set in your `manifest.json`
|
|
519
515
|
* @param installerVersion Obsidian version string or one of
|
|
520
516
|
* - "latest": Get the latest Obsidian installer compatible with `appVersion`
|
|
521
517
|
* - "earliest": Get the oldest Obsidian installer compatible with `appVersion`
|
|
@@ -601,7 +597,7 @@ var ObsidianLauncher = class {
|
|
|
601
597
|
if (installerUrl) {
|
|
602
598
|
downloader = async (tmpDir) => {
|
|
603
599
|
const appImage = path4.join(tmpDir, "Obsidian.AppImage");
|
|
604
|
-
await
|
|
600
|
+
await downloadResponse(await fetch(installerUrl), appImage);
|
|
605
601
|
const obsidianFolder = path4.join(tmpDir, "Obsidian");
|
|
606
602
|
await extractObsidianAppImage(appImage, obsidianFolder);
|
|
607
603
|
return obsidianFolder;
|
|
@@ -621,7 +617,7 @@ var ObsidianLauncher = class {
|
|
|
621
617
|
if (installerUrl && appArch) {
|
|
622
618
|
downloader = async (tmpDir) => {
|
|
623
619
|
const installerExecutable = path4.join(tmpDir, "Obsidian.exe");
|
|
624
|
-
await
|
|
620
|
+
await downloadResponse(await fetch(installerUrl), installerExecutable);
|
|
625
621
|
const obsidianFolder = path4.join(tmpDir, "Obsidian");
|
|
626
622
|
await extractObsidianExe(installerExecutable, appArch, obsidianFolder);
|
|
627
623
|
return obsidianFolder;
|
|
@@ -633,7 +629,7 @@ var ObsidianLauncher = class {
|
|
|
633
629
|
if (installerUrl) {
|
|
634
630
|
downloader = async (tmpDir) => {
|
|
635
631
|
const dmg = path4.join(tmpDir, "Obsidian.dmg");
|
|
636
|
-
await
|
|
632
|
+
await downloadResponse(await fetch(installerUrl), dmg);
|
|
637
633
|
const obsidianFolder = path4.join(tmpDir, "Obsidian");
|
|
638
634
|
await extractObsidianDmg(dmg, obsidianFolder);
|
|
639
635
|
return obsidianFolder;
|
|
@@ -647,7 +643,7 @@ var ObsidianLauncher = class {
|
|
|
647
643
|
}
|
|
648
644
|
if (!await fileExists(installerPath)) {
|
|
649
645
|
console.log(`Downloading Obsidian installer v${installerVersion}...`);
|
|
650
|
-
await
|
|
646
|
+
await fsAsync3.mkdir(path4.dirname(cacheDir), { recursive: true });
|
|
651
647
|
await withTmpDir(cacheDir, downloader);
|
|
652
648
|
}
|
|
653
649
|
return installerPath;
|
|
@@ -669,14 +665,14 @@ var ObsidianLauncher = class {
|
|
|
669
665
|
const appPath = path4.join(this.cacheDir, "obsidian-app", `obsidian-${appVersionInfo.version}.asar`);
|
|
670
666
|
if (!await fileExists(appPath)) {
|
|
671
667
|
console.log(`Downloading Obsidian app v${appVersion} ...`);
|
|
672
|
-
await
|
|
668
|
+
await fsAsync3.mkdir(path4.dirname(appPath), { recursive: true });
|
|
673
669
|
await withTmpDir(appPath, async (tmpDir) => {
|
|
674
670
|
const isInsidersBuild = new URL(appUrl).hostname.endsWith(".obsidian.md");
|
|
675
671
|
const response = isInsidersBuild ? await fetchObsidianAPI(appUrl) : await fetch(appUrl);
|
|
676
672
|
const archive = path4.join(tmpDir, "app.asar.gz");
|
|
677
673
|
const asar = path4.join(tmpDir, "app.asar");
|
|
678
|
-
await
|
|
679
|
-
await pipeline(
|
|
674
|
+
await downloadResponse(response, archive);
|
|
675
|
+
await pipeline(fs2.createReadStream(archive), zlib.createGunzip(), fs2.createWriteStream(asar));
|
|
680
676
|
return asar;
|
|
681
677
|
});
|
|
682
678
|
}
|
|
@@ -725,7 +721,7 @@ var ObsidianLauncher = class {
|
|
|
725
721
|
async getLatestPluginVersion(repo) {
|
|
726
722
|
repo = normalizeGitHubRepo(repo);
|
|
727
723
|
const manifestUrl = `https://raw.githubusercontent.com/${repo}/HEAD/manifest.json`;
|
|
728
|
-
const cacheDest = path4.join(
|
|
724
|
+
const cacheDest = path4.join("obsidian-plugins", repo, "latest.json");
|
|
729
725
|
const manifest = await this.cachedFetch(manifestUrl, cacheDest);
|
|
730
726
|
return manifest.version;
|
|
731
727
|
}
|
|
@@ -746,7 +742,7 @@ var ObsidianLauncher = class {
|
|
|
746
742
|
version = semver2.valid(version);
|
|
747
743
|
const pluginDir = path4.join(this.cacheDir, "obsidian-plugins", repo, version);
|
|
748
744
|
if (!await fileExists(pluginDir)) {
|
|
749
|
-
await
|
|
745
|
+
await fsAsync3.mkdir(path4.dirname(pluginDir), { recursive: true });
|
|
750
746
|
await withTmpDir(pluginDir, async (tmpDir) => {
|
|
751
747
|
const assetsToDownload = { "manifest.json": true, "main.js": true, "styles.css": false };
|
|
752
748
|
await Promise.all(
|
|
@@ -754,7 +750,7 @@ var ObsidianLauncher = class {
|
|
|
754
750
|
const url = `https://github.com/${repo}/releases/download/${version}/${file}`;
|
|
755
751
|
const response = await fetch(url);
|
|
756
752
|
if (response.ok) {
|
|
757
|
-
await
|
|
753
|
+
await downloadResponse(response, path4.join(tmpDir, file));
|
|
758
754
|
} else if (required) {
|
|
759
755
|
throw Error(`No ${file} found for ${repo} version ${version}`);
|
|
760
756
|
}
|
|
@@ -818,7 +814,7 @@ var ObsidianLauncher = class {
|
|
|
818
814
|
}
|
|
819
815
|
let pluginId = typeof plugin == "object" && "id" in plugin ? plugin.id : void 0;
|
|
820
816
|
if (!pluginId) {
|
|
821
|
-
pluginId = JSON.parse(await
|
|
817
|
+
pluginId = JSON.parse(await fsAsync3.readFile(manifestPath, "utf8").catch(() => "{}")).id;
|
|
822
818
|
if (!pluginId) {
|
|
823
819
|
throw Error(`${manifestPath} malformed.`);
|
|
824
820
|
}
|
|
@@ -840,7 +836,7 @@ var ObsidianLauncher = class {
|
|
|
840
836
|
async getLatestThemeVersion(repo) {
|
|
841
837
|
repo = normalizeGitHubRepo(repo);
|
|
842
838
|
const manifestUrl = `https://raw.githubusercontent.com/${repo}/HEAD/manifest.json`;
|
|
843
|
-
const cacheDest = path4.join(
|
|
839
|
+
const cacheDest = path4.join("obsidian-themes", repo, "latest.json");
|
|
844
840
|
const manifest = await this.cachedFetch(manifestUrl, cacheDest);
|
|
845
841
|
return manifest.version;
|
|
846
842
|
}
|
|
@@ -854,7 +850,7 @@ var ObsidianLauncher = class {
|
|
|
854
850
|
const version = await this.getLatestThemeVersion(repo);
|
|
855
851
|
const themeDir = path4.join(this.cacheDir, "obsidian-themes", repo, version);
|
|
856
852
|
if (!await fileExists(themeDir)) {
|
|
857
|
-
await
|
|
853
|
+
await fsAsync3.mkdir(path4.dirname(themeDir), { recursive: true });
|
|
858
854
|
await withTmpDir(themeDir, async (tmpDir) => {
|
|
859
855
|
const assetsToDownload = ["manifest.json", "theme.css"];
|
|
860
856
|
await Promise.all(
|
|
@@ -862,7 +858,7 @@ var ObsidianLauncher = class {
|
|
|
862
858
|
const url = `https://raw.githubusercontent.com/${repo}/HEAD/${file}`;
|
|
863
859
|
const response = await fetch(url);
|
|
864
860
|
if (response.ok) {
|
|
865
|
-
await
|
|
861
|
+
await downloadResponse(response, path4.join(tmpDir, file));
|
|
866
862
|
} else {
|
|
867
863
|
throw Error(`No ${file} found for ${repo}`);
|
|
868
864
|
}
|
|
@@ -926,7 +922,7 @@ var ObsidianLauncher = class {
|
|
|
926
922
|
let themeName = typeof theme == "object" && "name" in theme ? theme.name : void 0;
|
|
927
923
|
if (!themeName) {
|
|
928
924
|
const manifestPath2 = path4.join(themePath, "manifest.json");
|
|
929
|
-
themeName = JSON.parse(await
|
|
925
|
+
themeName = JSON.parse(await fsAsync3.readFile(manifestPath2, "utf8").catch(() => "{}")).name;
|
|
930
926
|
if (!themeName) {
|
|
931
927
|
throw Error(`${themePath}/manifest.json malformed.`);
|
|
932
928
|
}
|
|
@@ -952,21 +948,21 @@ var ObsidianLauncher = class {
|
|
|
952
948
|
async installPlugins(vault, plugins) {
|
|
953
949
|
const downloadedPlugins = await this.downloadPlugins(plugins);
|
|
954
950
|
const obsidianDir = path4.join(vault, ".obsidian");
|
|
955
|
-
await
|
|
951
|
+
await fsAsync3.mkdir(obsidianDir, { recursive: true });
|
|
956
952
|
const enabledPluginsPath = path4.join(obsidianDir, "community-plugins.json");
|
|
957
953
|
let originalEnabledPlugins = [];
|
|
958
954
|
if (await fileExists(enabledPluginsPath)) {
|
|
959
|
-
originalEnabledPlugins = JSON.parse(await
|
|
955
|
+
originalEnabledPlugins = JSON.parse(await fsAsync3.readFile(enabledPluginsPath, "utf-8"));
|
|
960
956
|
}
|
|
961
957
|
let enabledPlugins = [...originalEnabledPlugins];
|
|
962
958
|
for (const { path: pluginPath, enabled = true, originalType } of downloadedPlugins) {
|
|
963
959
|
const manifestPath = path4.join(pluginPath, "manifest.json");
|
|
964
|
-
const pluginId = JSON.parse(await
|
|
960
|
+
const pluginId = JSON.parse(await fsAsync3.readFile(manifestPath, "utf8").catch(() => "{}")).id;
|
|
965
961
|
if (!pluginId) {
|
|
966
962
|
throw Error(`${manifestPath} missing or malformed.`);
|
|
967
963
|
}
|
|
968
964
|
const pluginDest = path4.join(obsidianDir, "plugins", pluginId);
|
|
969
|
-
await
|
|
965
|
+
await fsAsync3.mkdir(pluginDest, { recursive: true });
|
|
970
966
|
const files = {
|
|
971
967
|
"manifest.json": [true, true],
|
|
972
968
|
"main.js": [true, true],
|
|
@@ -979,7 +975,7 @@ var ObsidianLauncher = class {
|
|
|
979
975
|
} else if (required) {
|
|
980
976
|
throw Error(`${pluginPath}/${file} missing.`);
|
|
981
977
|
} else if (deleteIfMissing) {
|
|
982
|
-
await
|
|
978
|
+
await fsAsync3.rm(path4.join(pluginDest, file), { force: true });
|
|
983
979
|
}
|
|
984
980
|
}
|
|
985
981
|
const pluginAlreadyListed = enabledPlugins.includes(pluginId);
|
|
@@ -989,11 +985,11 @@ var ObsidianLauncher = class {
|
|
|
989
985
|
enabledPlugins = enabledPlugins.filter((p) => p != pluginId);
|
|
990
986
|
}
|
|
991
987
|
if (originalType == "local") {
|
|
992
|
-
await
|
|
988
|
+
await fsAsync3.writeFile(path4.join(pluginDest, ".hotreload"), "");
|
|
993
989
|
}
|
|
994
990
|
}
|
|
995
991
|
if (!_4.isEqual(enabledPlugins, originalEnabledPlugins)) {
|
|
996
|
-
await
|
|
992
|
+
await fsAsync3.writeFile(enabledPluginsPath, JSON.stringify(enabledPlugins, void 0, 2));
|
|
997
993
|
}
|
|
998
994
|
}
|
|
999
995
|
/**
|
|
@@ -1004,12 +1000,12 @@ var ObsidianLauncher = class {
|
|
|
1004
1000
|
async installThemes(vault, themes) {
|
|
1005
1001
|
const downloadedThemes = await this.downloadThemes(themes);
|
|
1006
1002
|
const obsidianDir = path4.join(vault, ".obsidian");
|
|
1007
|
-
await
|
|
1003
|
+
await fsAsync3.mkdir(obsidianDir, { recursive: true });
|
|
1008
1004
|
let enabledTheme = void 0;
|
|
1009
1005
|
for (const { path: themePath, enabled = true } of downloadedThemes) {
|
|
1010
1006
|
const manifestPath = path4.join(themePath, "manifest.json");
|
|
1011
1007
|
const cssPath = path4.join(themePath, "theme.css");
|
|
1012
|
-
const themeName = JSON.parse(await
|
|
1008
|
+
const themeName = JSON.parse(await fsAsync3.readFile(manifestPath, "utf8").catch(() => "{}")).name;
|
|
1013
1009
|
if (!themeName) {
|
|
1014
1010
|
throw Error(`${manifestPath} missing or malformed.`);
|
|
1015
1011
|
}
|
|
@@ -1017,7 +1013,7 @@ var ObsidianLauncher = class {
|
|
|
1017
1013
|
throw Error(`${cssPath} missing.`);
|
|
1018
1014
|
}
|
|
1019
1015
|
const themeDest = path4.join(obsidianDir, "themes", themeName);
|
|
1020
|
-
await
|
|
1016
|
+
await fsAsync3.mkdir(themeDest, { recursive: true });
|
|
1021
1017
|
await linkOrCp(manifestPath, path4.join(themeDest, "manifest.json"));
|
|
1022
1018
|
await linkOrCp(cssPath, path4.join(themeDest, "theme.css"));
|
|
1023
1019
|
if (enabledTheme && enabled) {
|
|
@@ -1030,10 +1026,10 @@ var ObsidianLauncher = class {
|
|
|
1030
1026
|
const appearancePath = path4.join(obsidianDir, "appearance.json");
|
|
1031
1027
|
let appearance = {};
|
|
1032
1028
|
if (await fileExists(appearancePath)) {
|
|
1033
|
-
appearance = JSON.parse(await
|
|
1029
|
+
appearance = JSON.parse(await fsAsync3.readFile(appearancePath, "utf-8"));
|
|
1034
1030
|
}
|
|
1035
1031
|
appearance.cssTheme = enabledTheme ?? "";
|
|
1036
|
-
await
|
|
1032
|
+
await fsAsync3.writeFile(appearancePath, JSON.stringify(appearance, void 0, 2));
|
|
1037
1033
|
}
|
|
1038
1034
|
}
|
|
1039
1035
|
/**
|
|
@@ -1077,7 +1073,7 @@ var ObsidianLauncher = class {
|
|
|
1077
1073
|
// Disable "safe mode" and enable plugins
|
|
1078
1074
|
};
|
|
1079
1075
|
}
|
|
1080
|
-
await
|
|
1076
|
+
await fsAsync3.writeFile(path4.join(configDir, "obsidian.json"), JSON.stringify(obsidianJson));
|
|
1081
1077
|
let appPath = params.appPath;
|
|
1082
1078
|
if (!appPath) {
|
|
1083
1079
|
appPath = await this.downloadApp(appVersion);
|
|
@@ -1101,7 +1097,7 @@ var ObsidianLauncher = class {
|
|
|
1101
1097
|
let vault = params.vault;
|
|
1102
1098
|
if (params.copy) {
|
|
1103
1099
|
const dest = await makeTmpDir(`${path4.basename(vault)}-`);
|
|
1104
|
-
await
|
|
1100
|
+
await fsAsync3.cp(vault, dest, { recursive: true, preserveTimestamps: true });
|
|
1105
1101
|
vault = dest;
|
|
1106
1102
|
}
|
|
1107
1103
|
await this.installPlugins(vault, params.plugins ?? []);
|
|
@@ -1158,11 +1154,11 @@ var ObsidianLauncher = class {
|
|
|
1158
1154
|
const repo = "obsidianmd/obsidian-releases";
|
|
1159
1155
|
let commitHistory = await fetchGitHubAPIPaginated(`repos/${repo}/commits`, {
|
|
1160
1156
|
path: "desktop-releases.json",
|
|
1161
|
-
since: original?.metadata.
|
|
1157
|
+
since: original?.metadata.commitDate
|
|
1162
1158
|
});
|
|
1163
1159
|
commitHistory.reverse();
|
|
1164
1160
|
if (original) {
|
|
1165
|
-
commitHistory = _4.takeRightWhile(commitHistory, (c) => c.sha != original.metadata.
|
|
1161
|
+
commitHistory = _4.takeRightWhile(commitHistory, (c) => c.sha != original.metadata.commitSha);
|
|
1166
1162
|
}
|
|
1167
1163
|
const fileHistory = await pool(
|
|
1168
1164
|
8,
|
|
@@ -1226,8 +1222,8 @@ var ObsidianLauncher = class {
|
|
|
1226
1222
|
}
|
|
1227
1223
|
const result = {
|
|
1228
1224
|
metadata: {
|
|
1229
|
-
|
|
1230
|
-
|
|
1225
|
+
commitDate: commitHistory.at(-1)?.commit.committer.date ?? original?.metadata.commitDate,
|
|
1226
|
+
commitSha: commitHistory.at(-1)?.sha ?? original?.metadata.commitSha,
|
|
1231
1227
|
timestamp: original?.metadata.timestamp ?? ""
|
|
1232
1228
|
// set down below
|
|
1233
1229
|
},
|
|
@@ -1277,4 +1273,4 @@ var ObsidianLauncher = class {
|
|
|
1277
1273
|
export {
|
|
1278
1274
|
ObsidianLauncher
|
|
1279
1275
|
};
|
|
1280
|
-
//# sourceMappingURL=chunk-
|
|
1276
|
+
//# sourceMappingURL=chunk-IHBVELTU.js.map
|