obsidian-launcher 2.1.2 → 2.1.4
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/{chunk-HMKNUWAY.js → chunk-RFPT36TQ.js} +75 -62
- package/dist/{chunk-HMKNUWAY.js.map → chunk-RFPT36TQ.js.map} +1 -1
- package/dist/{chunk-Z5EOC6TG.cjs → chunk-YJWPOCL6.cjs} +75 -62
- package/dist/chunk-YJWPOCL6.cjs.map +1 -0
- package/dist/cli.cjs +4 -4
- package/dist/cli.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-Z5EOC6TG.cjs.map +0 -1
|
@@ -360,12 +360,14 @@ var ChromeLocalStorage = class {
|
|
|
360
360
|
import fsAsync3 from "fs/promises";
|
|
361
361
|
import fs3 from "fs";
|
|
362
362
|
import path4 from "path";
|
|
363
|
+
import { promisify } from "util";
|
|
363
364
|
import child_process from "child_process";
|
|
364
365
|
import semver from "semver";
|
|
365
366
|
import _3 from "lodash";
|
|
366
367
|
import { pipeline } from "stream/promises";
|
|
367
368
|
import zlib from "zlib";
|
|
368
369
|
import { fileURLToPath } from "url";
|
|
370
|
+
var execFile = promisify(child_process.execFile);
|
|
369
371
|
function normalizeGitHubRepo(repo) {
|
|
370
372
|
return repo.match(/^(https?:\/\/)?(github.com\/)?(.*?)\/?$/)?.[3] ?? repo;
|
|
371
373
|
}
|
|
@@ -424,15 +426,82 @@ async function extractObsidianExe(exe, arch, dest) {
|
|
|
424
426
|
async function extractObsidianDmg(dmg, dest) {
|
|
425
427
|
dest = path4.resolve(dest);
|
|
426
428
|
await atomicCreate(dest, async (scratch) => {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
if (process.platform == "darwin") {
|
|
430
|
+
const proc = await execFile("hdiutil", ["attach", "-nobrowse", "-readonly", dmg]);
|
|
431
|
+
const volume = proc.stdout.match(/\/Volumes\/.*$/m)[0];
|
|
432
|
+
const files = await fsAsync3.readdir(volume);
|
|
433
|
+
let obsidianApp = files.includes("Obsidian.app") ? "Obsidian.app" : path4.join(files[0], "Obsidian.app");
|
|
434
|
+
obsidianApp = path4.join(volume, obsidianApp);
|
|
435
|
+
try {
|
|
436
|
+
await fsAsync3.cp(obsidianApp, scratch, { recursive: true, verbatimSymlinks: true, preserveTimestamps: true });
|
|
437
|
+
} finally {
|
|
438
|
+
await execFile("hdiutil", ["detach", volume]);
|
|
439
|
+
}
|
|
440
|
+
return scratch;
|
|
431
441
|
} else {
|
|
432
|
-
|
|
442
|
+
await sevenZ(["x", "-o.", path4.relative(scratch, dmg), "*/Obsidian.app", "Obsidian.app"], { cwd: scratch });
|
|
443
|
+
const files = await fsAsync3.readdir(scratch);
|
|
444
|
+
const obsidianApp = files.includes("Obsidian.app") ? "Obsidian.app" : path4.join(files[0], "Obsidian.app");
|
|
445
|
+
return path4.join(scratch, obsidianApp);
|
|
433
446
|
}
|
|
434
447
|
});
|
|
435
448
|
}
|
|
449
|
+
async function extractInstallerInfo(installerKey, url) {
|
|
450
|
+
const installerName = url.split("/").at(-1);
|
|
451
|
+
console.log(`Extrating installer info for ${installerName}...`);
|
|
452
|
+
const tmpDir = await makeTmpDir("obsidian-launcher-");
|
|
453
|
+
try {
|
|
454
|
+
const installerPath = path4.join(tmpDir, url.split("/").at(-1));
|
|
455
|
+
await downloadResponse(await fetch(url), installerPath);
|
|
456
|
+
const exractedPath = path4.join(tmpDir, "Obsidian");
|
|
457
|
+
let platforms = [];
|
|
458
|
+
if (installerKey == "appImage" || installerKey == "appImageArm") {
|
|
459
|
+
await extractObsidianAppImage(installerPath, exractedPath);
|
|
460
|
+
platforms = ["linux-" + (installerKey == "appImage" ? "x64" : "arm64")];
|
|
461
|
+
} else if (installerKey == "tar" || installerKey == "tarArm") {
|
|
462
|
+
await extractObsidianTar(installerPath, exractedPath);
|
|
463
|
+
platforms = ["linux-" + (installerKey == "tar" ? "x64" : "arm64")];
|
|
464
|
+
} else if (installerKey == "exe") {
|
|
465
|
+
await extractObsidianExe(installerPath, "x64", exractedPath);
|
|
466
|
+
const { stdout } = await sevenZ(["l", "-ba", path4.relative(tmpDir, installerPath)], { cwd: tmpDir });
|
|
467
|
+
const lines = stdout.trim().split("\n").map((l) => l.trim());
|
|
468
|
+
const files = lines.map((l) => l.split(/\s+/).at(-1).replace(/\\/g, "/"));
|
|
469
|
+
if (files.includes("$PLUGINSDIR/app-arm64.7z")) platforms.push("win32-arm64");
|
|
470
|
+
if (files.includes("$PLUGINSDIR/app-32.7z")) platforms.push("win32-ia32");
|
|
471
|
+
if (files.includes("$PLUGINSDIR/app-64.7z")) platforms.push("win32-x64");
|
|
472
|
+
} else if (installerKey == "dmg") {
|
|
473
|
+
await extractObsidianDmg(installerPath, exractedPath);
|
|
474
|
+
platforms = ["darwin-arm64", "darwin-x64"];
|
|
475
|
+
} else {
|
|
476
|
+
throw new Error(`Unknown installer key ${installerKey}`);
|
|
477
|
+
}
|
|
478
|
+
const matches = [];
|
|
479
|
+
const installerFiles = await fsAsync3.readdir(exractedPath, { recursive: true, withFileTypes: true });
|
|
480
|
+
for (const file of installerFiles) {
|
|
481
|
+
if (file.isFile() && !file.name.endsWith(".asar")) {
|
|
482
|
+
const stream = fs3.createReadStream(path4.join(file.parentPath, file.name), { encoding: "utf-8" });
|
|
483
|
+
let prev = "";
|
|
484
|
+
for await (let chunk of stream) {
|
|
485
|
+
const regex = /Chrome\/\d+\.\d+\.\d+\.\d+|Electron\/\d+\.\d+\.\d+/g;
|
|
486
|
+
chunk = prev + chunk;
|
|
487
|
+
matches.push(...[...(prev + chunk).matchAll(regex)].map((m) => m[0]));
|
|
488
|
+
prev = chunk.slice(-64);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const versionSortKey = (v) => v.split(".").map((s) => s.padStart(9, "0")).join(".");
|
|
493
|
+
const versions = _3(matches).map((m) => m.split("/")).groupBy(0).mapValues((ms) => ms.map((m) => m[1])).mapValues((ms) => _3.sortBy(ms, versionSortKey).at(-1)).value();
|
|
494
|
+
const electron = versions["Electron"];
|
|
495
|
+
const chrome = versions["Chrome"];
|
|
496
|
+
if (!electron || !chrome) {
|
|
497
|
+
throw new Error(`Failed to extract Electron and Chrome versions from binary ${installerPath}`);
|
|
498
|
+
}
|
|
499
|
+
console.log(`Extracted installer info for ${installerName}`);
|
|
500
|
+
return { electron, chrome, platforms };
|
|
501
|
+
} finally {
|
|
502
|
+
await fsAsync3.rm(tmpDir, { recursive: true, force: true });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
436
505
|
async function fetchObsidianDesktopReleases(sinceDate, sinceSha) {
|
|
437
506
|
const repo = "obsidianmd/obsidian-releases";
|
|
438
507
|
let commitHistory = await fetchGitHubAPIPaginated(`repos/${repo}/commits`, {
|
|
@@ -582,62 +651,6 @@ function updateObsidianVersionList(args) {
|
|
|
582
651
|
}
|
|
583
652
|
return Object.values(newVersions).map(normalizeObsidianVersionInfo).sort((a, b) => semver.compare(a.version, b.version));
|
|
584
653
|
}
|
|
585
|
-
async function extractInstallerInfo(installerKey, url) {
|
|
586
|
-
const installerName = url.split("/").at(-1);
|
|
587
|
-
console.log(`Extrating installer info for ${installerName}...`);
|
|
588
|
-
const tmpDir = await makeTmpDir("obsidian-launcher-");
|
|
589
|
-
try {
|
|
590
|
-
const installerPath = path4.join(tmpDir, url.split("/").at(-1));
|
|
591
|
-
await downloadResponse(await fetch(url), installerPath);
|
|
592
|
-
const exractedPath = path4.join(tmpDir, "Obsidian");
|
|
593
|
-
let platforms = [];
|
|
594
|
-
if (installerKey == "appImage" || installerKey == "appImageArm") {
|
|
595
|
-
await extractObsidianAppImage(installerPath, exractedPath);
|
|
596
|
-
platforms = ["linux-" + (installerKey == "appImage" ? "x64" : "arm64")];
|
|
597
|
-
} else if (installerKey == "tar" || installerKey == "tarArm") {
|
|
598
|
-
await extractObsidianTar(installerPath, exractedPath);
|
|
599
|
-
platforms = ["linux-" + (installerKey == "tar" ? "x64" : "arm64")];
|
|
600
|
-
} else if (installerKey == "exe") {
|
|
601
|
-
await extractObsidianExe(installerPath, "x64", exractedPath);
|
|
602
|
-
const { stdout } = await sevenZ(["l", "-ba", path4.relative(tmpDir, installerPath)], { cwd: tmpDir });
|
|
603
|
-
const lines = stdout.trim().split("\n").map((l) => l.trim());
|
|
604
|
-
const files = lines.map((l) => l.split(/\s+/).at(-1).replace(/\\/g, "/"));
|
|
605
|
-
if (files.includes("$PLUGINSDIR/app-arm64.7z")) platforms.push("win32-arm64");
|
|
606
|
-
if (files.includes("$PLUGINSDIR/app-32.7z")) platforms.push("win32-ia32");
|
|
607
|
-
if (files.includes("$PLUGINSDIR/app-64.7z")) platforms.push("win32-x64");
|
|
608
|
-
} else if (installerKey == "dmg") {
|
|
609
|
-
await extractObsidianDmg(installerPath, exractedPath);
|
|
610
|
-
platforms = ["darwin-arm64", "darwin-x64"];
|
|
611
|
-
} else {
|
|
612
|
-
throw new Error(`Unknown installer key ${installerKey}`);
|
|
613
|
-
}
|
|
614
|
-
const matches = [];
|
|
615
|
-
const installerFiles = await fsAsync3.readdir(exractedPath, { recursive: true, withFileTypes: true });
|
|
616
|
-
for (const file of installerFiles) {
|
|
617
|
-
if (file.isFile() && !file.name.endsWith(".asar")) {
|
|
618
|
-
const stream = fs3.createReadStream(path4.join(file.parentPath, file.name), { encoding: "utf-8" });
|
|
619
|
-
let prev = "";
|
|
620
|
-
for await (let chunk of stream) {
|
|
621
|
-
const regex = /Chrome\/\d+\.\d+\.\d+\.\d+|Electron\/\d+\.\d+\.\d+/g;
|
|
622
|
-
chunk = prev + chunk;
|
|
623
|
-
matches.push(...[...(prev + chunk).matchAll(regex)].map((m) => m[0]));
|
|
624
|
-
prev = chunk.slice(-64);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
const versionSortKey = (v) => v.split(".").map((s) => s.padStart(9, "0")).join(".");
|
|
629
|
-
const versions = _3(matches).map((m) => m.split("/")).groupBy(0).mapValues((ms) => ms.map((m) => m[1])).mapValues((ms) => _3.sortBy(ms, versionSortKey).at(-1)).value();
|
|
630
|
-
const electron = versions["Electron"];
|
|
631
|
-
const chrome = versions["Chrome"];
|
|
632
|
-
if (!electron || !chrome) {
|
|
633
|
-
throw new Error(`Failed to extract Electron and Chrome versions from binary ${installerPath}`);
|
|
634
|
-
}
|
|
635
|
-
console.log(`Extracted installer info for ${installerName}`);
|
|
636
|
-
return { electron, chrome, platforms };
|
|
637
|
-
} finally {
|
|
638
|
-
await fsAsync3.rm(tmpDir, { recursive: true, force: true });
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
654
|
function normalizeObsidianVersionInfo(versionInfo) {
|
|
642
655
|
versionInfo = _3.cloneDeep(versionInfo);
|
|
643
656
|
versionInfo.electronVersion = versionInfo.installers?.appImage?.electron;
|
|
@@ -1583,4 +1596,4 @@ export {
|
|
|
1583
1596
|
watchFiles,
|
|
1584
1597
|
ObsidianLauncher
|
|
1585
1598
|
};
|
|
1586
|
-
//# sourceMappingURL=chunk-
|
|
1599
|
+
//# sourceMappingURL=chunk-RFPT36TQ.js.map
|