@life-os/obsidian-web 0.1.0 → 0.1.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.
- package/README.md +2 -2
- package/download-archive.mjs +33 -0
- package/package.json +2 -1
- package/prepare.sh +2 -7
package/README.md
CHANGED
|
@@ -19,13 +19,13 @@ obsidian-web setup
|
|
|
19
19
|
obsidian-web --help
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
For local testing, install a tarball with `npm install -g ./life-os-obsidian-web-0.1.
|
|
22
|
+
For local testing, install a tarball with `npm install -g ./life-os-obsidian-web-0.1.1.tgz`. Build the tarball with `npm pack` from the repository root. The package uses the same `@life-os` scope as the LifeOS CLI. For checkout-based installation, run the following command from the repository root.
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
25
|
./install.mjs
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
The installer uses a local Obsidian 1.14.4 ASAR if available.
|
|
28
|
+
The installer uses a local Obsidian 1.14.4 ASAR if available. If the pinned archive is missing from the cache, setup downloads it concurrently from the [official GitHub release](https://github.com/obsidianmd/obsidian-releases/releases/tag/v1.14.4) and the third-party relays ghfast.top and gh-proxy.com. The first complete download matching the pinned SHA-256 wins. Setup cancels outstanding transfers and caches the verified archive under `~/.local/share/vault-ui/archives/`. The archive is about 8.8 MiB. Later installs can reuse the cache. To supply the runtime yourself, pass a local `.asar` or the official `.asar.gz` to `./install.mjs`.
|
|
29
29
|
|
|
30
30
|
The installer links the CLI and WorkBuddy skill at `~/.local/bin/obsidian-web` and `~/.workbuddy/skills/obsidian-web`. The first setup also downloads build dependencies from npm. With the runtime archive and npm dependencies already cached, use `npm_config_offline=true ./install.mjs` to install without npm network requests. Keep this repository directory in place after installation, then start a new chat in WorkBuddy.
|
|
31
31
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { readFile, rename } from 'node:fs/promises';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
|
|
6
|
+
const [official, destination, expectedHash] = process.argv.slice(2);
|
|
7
|
+
const urls = [official, 'https://ghfast.top/' + official, 'https://gh-proxy.com/' + official];
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
const curl = promisify(execFile);
|
|
10
|
+
|
|
11
|
+
async function download(url, index) {
|
|
12
|
+
const file = destination + '.' + index;
|
|
13
|
+
const host = new URL(url).host;
|
|
14
|
+
await curl('curl', [
|
|
15
|
+
'--fail', '--location', '--silent', '--show-error', '--proto', '=https', '--proto-redir', '=https',
|
|
16
|
+
'--connect-timeout', '15', '--max-time', '600', '--speed-limit', '1024', '--speed-time', '45',
|
|
17
|
+
'--max-filesize', '16777216', '--output', file, url,
|
|
18
|
+
], { signal: controller.signal });
|
|
19
|
+
if (createHash('sha256').update(await readFile(file)).digest('hex') !== expectedHash) {
|
|
20
|
+
throw Error(host + ': SHA-256 mismatch');
|
|
21
|
+
}
|
|
22
|
+
return { file, host };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const winner = await Promise.any(urls.map(download));
|
|
27
|
+
controller.abort();
|
|
28
|
+
await rename(winner.file, destination);
|
|
29
|
+
console.error('Verified runtime downloaded from ' + winner.host);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error((error.errors ?? [error]).map(cause => cause.message).join('\n'));
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@life-os/obsidian-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Open and edit local Obsidian vaults in your browser or AI client. An unofficial CLI by LifeOS.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"obsidian-web": "./vault-ui.mjs",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"vault-ui.mjs",
|
|
14
14
|
"install.mjs",
|
|
15
15
|
"prepare.sh",
|
|
16
|
+
"download-archive.mjs",
|
|
16
17
|
"browser.cjs",
|
|
17
18
|
"fs-queue.cjs",
|
|
18
19
|
"vault-switch.cjs",
|
package/prepare.sh
CHANGED
|
@@ -36,13 +36,8 @@ elif [ -f "$local_archive" ] && [ -r "$local_archive" ]; then
|
|
|
36
36
|
else
|
|
37
37
|
if [ ! -f "$cached_archive" ] || ! verify_archive "$cached_archive"; then
|
|
38
38
|
echo "Downloading the official Obsidian $version runtime" >&2
|
|
39
|
-
if !
|
|
40
|
-
|
|
41
|
-
echo "Could not download the Obsidian runtime. Pass the path to a local .asar or official .asar.gz file." >&2
|
|
42
|
-
exit 1
|
|
43
|
-
fi
|
|
44
|
-
if ! verify_archive "$tmp/$archive_name"; then
|
|
45
|
-
echo "The downloaded Obsidian archive failed SHA-256 verification" >&2
|
|
39
|
+
if ! node "$source_dir/download-archive.mjs" "$archive_url" "$tmp/$archive_name" "$archive_sha256"; then
|
|
40
|
+
echo "Could not download a verified runtime. Pass the path to a local .asar or official .asar.gz file." >&2
|
|
46
41
|
exit 1
|
|
47
42
|
fi
|
|
48
43
|
mkdir -p "$root/archives"
|