@miadi/tide 0.5.3 → 0.5.5
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/package.json +2 -2
- package/src/annotate.ts +27 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/tide",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Typed client boundary for the ironsilk `tide` runtime. Daemon Unix-socket transport with CLI fallback.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@miadi/annotate-core": "^0.1.1",
|
|
19
|
-
"@miadi/tide-contract": "0.3.
|
|
19
|
+
"@miadi/tide-contract": "0.3.1"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"miadi",
|
package/src/annotate.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { promisify } from "node:util"
|
|
|
36
36
|
import { mkdir, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises"
|
|
37
37
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path"
|
|
38
38
|
import { homedir } from "node:os"
|
|
39
|
+
import { existsSync } from "node:fs"
|
|
39
40
|
import { randomBytes } from "node:crypto"
|
|
40
41
|
import { TideError } from "./errors"
|
|
41
42
|
import { isMarkAuthor, MARK_KINDS, resolveQuote } from "@miadi/annotate-core"
|
|
@@ -154,11 +155,34 @@ export function resolveVesselRoot(env: NodeJS.ProcessEnv = process.env, home: st
|
|
|
154
155
|
return join(xdg || join(home, ".local", "state"), "plannotator-tmux-review")
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
/** plannotator-tui's
|
|
158
|
-
export
|
|
158
|
+
/** plannotator-tui's data dir, in the binary's own order (plannotator-tui-schema `data_dir`). */
|
|
159
|
+
export const DATA_DIR_ENV = "PLANNOTATOR_DATA_DIR"
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* plannotator-tui's record root: `$PLANNOTATOR_STORE_DIR` (tide's override), else
|
|
163
|
+
* `<data dir>/clients/plannotator-tui/annotations`, where the data dir is found as
|
|
164
|
+
* the binary finds it: `$PLANNOTATOR_DATA_DIR` (a leading `~` is home) → an existing
|
|
165
|
+
* `~/.plannotator` → an absolute `$XDG_DATA_HOME/plannotator` → `~/.plannotator`.
|
|
166
|
+
* A host that shares annotations sets PLANNOTATOR_DATA_DIR, and the marks the
|
|
167
|
+
* binary writes there are the ones read here (jgwill/gaia#87).
|
|
168
|
+
*/
|
|
169
|
+
export function resolveStoreRoot(
|
|
170
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
171
|
+
home: string = homedir(),
|
|
172
|
+
exists: (p: string) => boolean = existsSync,
|
|
173
|
+
): string {
|
|
159
174
|
const fromEnv = env[STORE_ROOT_ENV]?.trim()
|
|
160
175
|
if (fromEnv) return fromEnv
|
|
161
|
-
|
|
176
|
+
const dataDir = (): string => {
|
|
177
|
+
const set = env[DATA_DIR_ENV]?.trim()
|
|
178
|
+
if (set) return set === "~" ? home : set.startsWith("~/") ? join(home, set.slice(2)) : set
|
|
179
|
+
const dot = join(home, ".plannotator")
|
|
180
|
+
if (exists(dot)) return dot
|
|
181
|
+
const xdg = env.XDG_DATA_HOME?.trim()
|
|
182
|
+
if (xdg && isAbsolute(xdg)) return join(xdg, "plannotator")
|
|
183
|
+
return dot
|
|
184
|
+
}
|
|
185
|
+
return join(dataDir(), "clients", "plannotator-tui", "annotations")
|
|
162
186
|
}
|
|
163
187
|
|
|
164
188
|
function resolveTmuxBin(env: NodeJS.ProcessEnv = process.env): string {
|