dirsql 0.4.7 → 0.4.8
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Return `argv` augmented with `--extension <path>[::entrypoint]` flags when
|
|
2
|
+
* Return `argv` augmented with `--extension <path>[::entrypoint]` flags when a
|
|
3
3
|
* TOML config names an extension by package name; otherwise return `argv`
|
|
4
4
|
* unchanged. Throws if a package name cannot be resolved (surfaced by the
|
|
5
5
|
* launcher as a clean error).
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
// Launcher-side resolution of
|
|
1
|
+
// Launcher-side resolution of the TOML configs' `[[dirsql.extension]]` entries.
|
|
2
2
|
//
|
|
3
3
|
// The compiled `dirsql` binary loads config extensions literally — it has no
|
|
4
|
-
// `require.resolve`, so it cannot resolve a bare **package name**. When
|
|
5
|
-
// TOML config names an extension by package name, the shared SDK
|
|
6
|
-
// resolves every
|
|
7
|
-
// to the binary via repeatable `--extension` flags;
|
|
8
|
-
// those and ignores the
|
|
4
|
+
// `require.resolve`, so it cannot resolve a bare **package name**. When any
|
|
5
|
+
// TOML config in argv names an extension by package name, the shared SDK
|
|
6
|
+
// resolver resolves every config's entries and this launcher passes the
|
|
7
|
+
// resolved literal paths to the binary via repeatable `--extension` flags;
|
|
8
|
+
// the binary then loads those and ignores the configs' own extension entries.
|
|
9
|
+
//
|
|
10
|
+
// The `-c`/`--config` flag is repeatable, so the scan collects every
|
|
11
|
+
// occurrence, in argv order.
|
|
9
12
|
//
|
|
10
13
|
// Native-language configs (`.py`/`.js`/`.mjs`/`.cjs`) are untouched: the binary
|
|
11
14
|
// dispatches those to `dirsql interpret`, whose handshake already carries
|
|
@@ -14,21 +17,37 @@ import { existsSync } from "node:fs";
|
|
|
14
17
|
// Config extensions the binary dispatches to `dirsql interpret`; never
|
|
15
18
|
// pre-resolved here (that path resolves via the handshake).
|
|
16
19
|
const NATIVE_CONFIG_SUFFIXES = [".py", ".js", ".mjs", ".cjs"];
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Every config value in argv, in order (`--config X`, `--config=X`, `-c X`,
|
|
22
|
+
* `-c=X`, `-cX`), or the default when none are given.
|
|
23
|
+
*/
|
|
24
|
+
function configPathsFromArgv(argv) {
|
|
25
|
+
const paths = [];
|
|
26
|
+
let expectValue = false;
|
|
27
|
+
for (const a of argv) {
|
|
28
|
+
if (expectValue) {
|
|
29
|
+
paths.push(a);
|
|
30
|
+
expectValue = false;
|
|
31
|
+
}
|
|
32
|
+
else if (a === "--config" || a === "-c") {
|
|
33
|
+
expectValue = true;
|
|
23
34
|
}
|
|
24
|
-
if (a
|
|
25
|
-
|
|
35
|
+
else if (a.startsWith("--config=")) {
|
|
36
|
+
paths.push(a.slice("--config=".length));
|
|
26
37
|
}
|
|
38
|
+
else if (a.startsWith("-c")) {
|
|
39
|
+
const value = a.slice("-c".length);
|
|
40
|
+
paths.push(value.startsWith("=") ? value.slice("=".length) : value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (expectValue) {
|
|
44
|
+
// A bare trailing flag (no following value) yields "".
|
|
45
|
+
paths.push("");
|
|
27
46
|
}
|
|
28
|
-
return "./.dirsql.toml";
|
|
47
|
+
return paths.length > 0 ? paths : ["./.dirsql.toml"];
|
|
29
48
|
}
|
|
30
49
|
/**
|
|
31
|
-
* Return `argv` augmented with `--extension <path>[::entrypoint]` flags when
|
|
50
|
+
* Return `argv` augmented with `--extension <path>[::entrypoint]` flags when a
|
|
32
51
|
* TOML config names an extension by package name; otherwise return `argv`
|
|
33
52
|
* unchanged. Throws if a package name cannot be resolved (surfaced by the
|
|
34
53
|
* launcher as a clean error).
|
|
@@ -37,18 +56,16 @@ export async function withResolvedExtensions(argv) {
|
|
|
37
56
|
if (argv[0] === "init") {
|
|
38
57
|
return argv;
|
|
39
58
|
}
|
|
40
|
-
const
|
|
41
|
-
if (NATIVE_CONFIG_SUFFIXES.some((s) => configPath.endsWith(s))) {
|
|
42
|
-
return argv;
|
|
43
|
-
}
|
|
59
|
+
const configPaths = configPathsFromArgv(argv).filter((p) => !NATIVE_CONFIG_SUFFIXES.some((s) => p.endsWith(s)));
|
|
44
60
|
// The shared resolver pulls in smol-toml, which only a TOML config on disk
|
|
45
61
|
// can need. Guarding on the same `existsSync` the resolver itself starts
|
|
46
|
-
// with keeps the parser off the common launch path entirely (#720)
|
|
47
|
-
|
|
62
|
+
// with keeps the parser off the common launch path entirely (#720); the
|
|
63
|
+
// resolver skips any individually-missing config on its own.
|
|
64
|
+
if (!configPaths.some((p) => existsSync(p))) {
|
|
48
65
|
return argv;
|
|
49
66
|
}
|
|
50
|
-
const {
|
|
51
|
-
const specs =
|
|
67
|
+
const { resolveConfigsExtensionSpecs } = await import("../resolve-config-extensions.js");
|
|
68
|
+
const specs = resolveConfigsExtensionSpecs(configPaths);
|
|
52
69
|
if (specs === null) {
|
|
53
70
|
return argv;
|
|
54
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Ephemeral SQL index over a local directory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/thekevinscott/dirsql",
|
|
@@ -212,15 +212,15 @@
|
|
|
212
212
|
]
|
|
213
213
|
},
|
|
214
214
|
"optionalDependencies": {
|
|
215
|
-
"@dirsql/lib-linux-x64-gnu": "0.4.
|
|
216
|
-
"@dirsql/lib-linux-arm64-gnu": "0.4.
|
|
217
|
-
"@dirsql/lib-darwin-x64": "0.4.
|
|
218
|
-
"@dirsql/lib-darwin-arm64": "0.4.
|
|
219
|
-
"@dirsql/lib-win32-x64-msvc": "0.4.
|
|
220
|
-
"@dirsql/cli-linux-x64-gnu": "0.4.
|
|
221
|
-
"@dirsql/cli-linux-arm64-gnu": "0.4.
|
|
222
|
-
"@dirsql/cli-darwin-x64": "0.4.
|
|
223
|
-
"@dirsql/cli-darwin-arm64": "0.4.
|
|
224
|
-
"@dirsql/cli-win32-x64-msvc": "0.4.
|
|
215
|
+
"@dirsql/lib-linux-x64-gnu": "0.4.8",
|
|
216
|
+
"@dirsql/lib-linux-arm64-gnu": "0.4.8",
|
|
217
|
+
"@dirsql/lib-darwin-x64": "0.4.8",
|
|
218
|
+
"@dirsql/lib-darwin-arm64": "0.4.8",
|
|
219
|
+
"@dirsql/lib-win32-x64-msvc": "0.4.8",
|
|
220
|
+
"@dirsql/cli-linux-x64-gnu": "0.4.8",
|
|
221
|
+
"@dirsql/cli-linux-arm64-gnu": "0.4.8",
|
|
222
|
+
"@dirsql/cli-darwin-x64": "0.4.8",
|
|
223
|
+
"@dirsql/cli-darwin-arm64": "0.4.8",
|
|
224
|
+
"@dirsql/cli-win32-x64-msvc": "0.4.8"
|
|
225
225
|
}
|
|
226
226
|
}
|