@gmickel/gno 1.3.0 → 1.3.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/package.json +1 -1
- package/src/core/user-dirs.ts +21 -12
- package/src/store/sqlite/adapter.ts +5 -5
package/package.json
CHANGED
package/src/core/user-dirs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// node:os homedir: no Bun equivalent.
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
// node:path
|
|
4
|
-
import {
|
|
3
|
+
// node:path posix/win32: no Bun path utilities.
|
|
4
|
+
import { posix, win32 } from "node:path";
|
|
5
5
|
|
|
6
6
|
interface ResolveDownloadsDirDeps {
|
|
7
7
|
env?: Record<string, string | undefined>;
|
|
@@ -12,12 +12,17 @@ interface ResolveDownloadsDirDeps {
|
|
|
12
12
|
|
|
13
13
|
const XDG_DOWNLOAD_DIR_REGEX = /^XDG_DOWNLOAD_DIR=(?:"([^"]+)"|([^\r\n#]+))$/mu;
|
|
14
14
|
|
|
15
|
+
function pathOpsForPlatform(platform: NodeJS.Platform) {
|
|
16
|
+
return platform === "win32" ? win32 : posix;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
function expandEnvPath(
|
|
16
20
|
value: string,
|
|
17
21
|
env: Record<string, string | undefined>,
|
|
18
|
-
homeDir: string
|
|
22
|
+
homeDir: string,
|
|
23
|
+
platform: NodeJS.Platform
|
|
19
24
|
): string {
|
|
20
|
-
return normalize(
|
|
25
|
+
return pathOpsForPlatform(platform).normalize(
|
|
21
26
|
value
|
|
22
27
|
.trim()
|
|
23
28
|
.replaceAll(/\$HOME|\$\{HOME\}/gu, homeDir)
|
|
@@ -32,14 +37,15 @@ function expandEnvPath(
|
|
|
32
37
|
function parseXdgDownloadsDir(
|
|
33
38
|
fileContents: string,
|
|
34
39
|
env: Record<string, string | undefined>,
|
|
35
|
-
homeDir: string
|
|
40
|
+
homeDir: string,
|
|
41
|
+
platform: NodeJS.Platform
|
|
36
42
|
): string | null {
|
|
37
43
|
const match = fileContents.match(XDG_DOWNLOAD_DIR_REGEX);
|
|
38
44
|
const rawValue = match?.[1] ?? match?.[2];
|
|
39
45
|
if (!rawValue) {
|
|
40
46
|
return null;
|
|
41
47
|
}
|
|
42
|
-
return expandEnvPath(rawValue, env, homeDir);
|
|
48
|
+
return expandEnvPath(rawValue, env, homeDir, platform);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
async function defaultReadTextFile(path: string): Promise<string | null> {
|
|
@@ -57,18 +63,21 @@ export async function resolveDownloadsDir(
|
|
|
57
63
|
const platform = deps.platform ?? process.platform;
|
|
58
64
|
const homeDir = deps.homeDir ?? homedir();
|
|
59
65
|
const readTextFile = deps.readTextFile ?? defaultReadTextFile;
|
|
66
|
+
const pathOps = pathOpsForPlatform(platform);
|
|
60
67
|
|
|
61
68
|
if (platform === "linux") {
|
|
62
69
|
const explicit = env.XDG_DOWNLOAD_DIR?.trim();
|
|
63
70
|
if (explicit) {
|
|
64
|
-
return expandEnvPath(explicit, env, homeDir);
|
|
71
|
+
return expandEnvPath(explicit, env, homeDir, platform);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
const xdgConfigHome =
|
|
68
|
-
env.XDG_CONFIG_HOME?.trim() || join(homeDir, ".config");
|
|
69
|
-
const userDirs = await readTextFile(
|
|
75
|
+
env.XDG_CONFIG_HOME?.trim() || pathOps.join(homeDir, ".config");
|
|
76
|
+
const userDirs = await readTextFile(
|
|
77
|
+
pathOps.join(xdgConfigHome, "user-dirs.dirs")
|
|
78
|
+
);
|
|
70
79
|
if (userDirs) {
|
|
71
|
-
const parsed = parseXdgDownloadsDir(userDirs, env, homeDir);
|
|
80
|
+
const parsed = parseXdgDownloadsDir(userDirs, env, homeDir, platform);
|
|
72
81
|
if (parsed) {
|
|
73
82
|
return parsed;
|
|
74
83
|
}
|
|
@@ -78,9 +87,9 @@ export async function resolveDownloadsDir(
|
|
|
78
87
|
if (platform === "win32") {
|
|
79
88
|
const userProfile = env.USERPROFILE?.trim();
|
|
80
89
|
if (userProfile) {
|
|
81
|
-
return join(userProfile, "Downloads");
|
|
90
|
+
return pathOps.join(userProfile, "Downloads");
|
|
82
91
|
}
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
return join(homeDir, "Downloads");
|
|
94
|
+
return pathOps.join(homeDir, "Downloads");
|
|
86
95
|
}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// CRITICAL: Import setup FIRST to configure custom SQLite before any Database use
|
|
11
11
|
import "./setup";
|
|
12
12
|
import { Database } from "bun:sqlite";
|
|
13
|
+
// node:path basename: no Bun path utilities.
|
|
14
|
+
import { basename } from "node:path";
|
|
13
15
|
|
|
14
16
|
import type { Collection, Context, FtsTokenizer } from "../../config/types";
|
|
15
17
|
import type {
|
|
@@ -2751,11 +2753,9 @@ export class SqliteAdapter implements StorePort, SqliteDbProvider {
|
|
|
2751
2753
|
|
|
2752
2754
|
// Derive indexName from dbPath (basename without extension)
|
|
2753
2755
|
const indexName =
|
|
2754
|
-
this.dbPath
|
|
2755
|
-
.
|
|
2756
|
-
.
|
|
2757
|
-
?.replace(SQLITE_EXT_REGEX, "")
|
|
2758
|
-
?.replace(INDEX_PREFIX_REGEX, "") || "default";
|
|
2756
|
+
basename(this.dbPath)
|
|
2757
|
+
.replace(SQLITE_EXT_REGEX, "")
|
|
2758
|
+
.replace(INDEX_PREFIX_REGEX, "") || "default";
|
|
2759
2759
|
|
|
2760
2760
|
// Get collection stats with chunk counts
|
|
2761
2761
|
interface CollectionStat {
|