dirsql 0.4.37 → 0.4.38
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/default-resolver.d.ts +3 -0
- package/dist/default-resolver.js +9 -0
- package/dist/has-bare-name.d.ts +3 -0
- package/dist/has-bare-name.js +5 -0
- package/dist/is-bare-name.d.ts +2 -0
- package/dist/is-bare-name.js +10 -0
- package/dist/resolve-config-extension-specs.d.ts +13 -0
- package/dist/resolve-config-extension-specs.js +21 -0
- package/dist/resolve-config-extensions.d.ts +0 -12
- package/dist/resolve-config-extensions.js +2 -28
- package/dist/resolve-entries.d.ts +4 -0
- package/dist/resolve-entries.js +8 -0
- package/dist/resolve-extension.d.ts +0 -2
- package/dist/resolve-extension.js +2 -18
- package/package.json +6 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
/** `require.resolve`-backed resolver used when a caller injects none. */
|
|
3
|
+
export function defaultResolver() {
|
|
4
|
+
const req = createRequire(import.meta.url);
|
|
5
|
+
return {
|
|
6
|
+
resolve: (s) => req.resolve(s),
|
|
7
|
+
paths: (s) => req.resolve.paths(s),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** True when `path` is a bare package name rather than a file path. */
|
|
2
|
+
export function isBareName(path) {
|
|
3
|
+
// Suffixes that mark a value as "already a file path" (so package resolution is
|
|
4
|
+
// never attempted).
|
|
5
|
+
const loadableSuffixes = [".so", ".dylib", ".dll", ".node"];
|
|
6
|
+
if (path.includes("/") || path.includes("\\")) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return !loadableSuffixes.some((s) => path.endsWith(s));
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExtensionSpec } from "./dirsql.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
4
|
+
*
|
|
5
|
+
* Returns the resolved specs — every entry resolved via
|
|
6
|
+
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
7
|
+
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
8
|
+
* caller should not intervene: the config is missing, malformed, declares no
|
|
9
|
+
* extensions, or uses only literal paths — leaving the core's own loading
|
|
10
|
+
* (and error reporting) untouched. Throws if a package name cannot be
|
|
11
|
+
* resolved.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveConfigExtensionSpecs(configPath: string): ExtensionSpec[] | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { hasBareName } from "./has-bare-name.js";
|
|
2
|
+
import { loadExtensionEntries } from "./load-extension-entries.js";
|
|
3
|
+
import { resolveEntries } from "./resolve-entries.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
6
|
+
*
|
|
7
|
+
* Returns the resolved specs — every entry resolved via
|
|
8
|
+
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
9
|
+
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
10
|
+
* caller should not intervene: the config is missing, malformed, declares no
|
|
11
|
+
* extensions, or uses only literal paths — leaving the core's own loading
|
|
12
|
+
* (and error reporting) untouched. Throws if a package name cannot be
|
|
13
|
+
* resolved.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveConfigExtensionSpecs(configPath) {
|
|
16
|
+
const loaded = loadExtensionEntries(configPath);
|
|
17
|
+
if (loaded === null || !hasBareName(loaded.entries)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return resolveEntries(loaded.entries, loaded.base);
|
|
21
|
+
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import type { ExtensionSpec } from "./dirsql.js";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
4
|
-
*
|
|
5
|
-
* Returns the resolved specs — every entry resolved via
|
|
6
|
-
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
7
|
-
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
8
|
-
* caller should not intervene: the config is missing, malformed, declares no
|
|
9
|
-
* extensions, or uses only literal paths — leaving the core's own loading
|
|
10
|
-
* (and error reporting) untouched. Throws if a package name cannot be
|
|
11
|
-
* resolved.
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveConfigExtensionSpecs(configPath: string): ExtensionSpec[] | null;
|
|
14
2
|
/**
|
|
15
3
|
* Resolve the `[[dirsql.extension]]` entries of several configs, in order.
|
|
16
4
|
*
|
|
@@ -7,35 +7,9 @@
|
|
|
7
7
|
// own config-extension loading so the entries are not loaded twice.
|
|
8
8
|
//
|
|
9
9
|
// Shared by the `DirSQL` constructor (`config` option) and the CLI launcher.
|
|
10
|
+
import { hasBareName } from "./has-bare-name.js";
|
|
10
11
|
import { loadExtensionEntries } from "./load-extension-entries.js";
|
|
11
|
-
import {
|
|
12
|
-
function hasBareName(entries) {
|
|
13
|
-
return entries.some((e) => typeof e.path === "string" && isBareName(e.path));
|
|
14
|
-
}
|
|
15
|
-
function resolveEntries(entries, base) {
|
|
16
|
-
return entries.map((e) => ({
|
|
17
|
-
path: resolveExtensionPath(e.path, base, true),
|
|
18
|
-
entrypoint: typeof e.entrypoint === "string" ? e.entrypoint : undefined,
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
23
|
-
*
|
|
24
|
-
* Returns the resolved specs — every entry resolved via
|
|
25
|
-
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
26
|
-
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
27
|
-
* caller should not intervene: the config is missing, malformed, declares no
|
|
28
|
-
* extensions, or uses only literal paths — leaving the core's own loading
|
|
29
|
-
* (and error reporting) untouched. Throws if a package name cannot be
|
|
30
|
-
* resolved.
|
|
31
|
-
*/
|
|
32
|
-
export function resolveConfigExtensionSpecs(configPath) {
|
|
33
|
-
const loaded = loadExtensionEntries(configPath);
|
|
34
|
-
if (loaded === null || !hasBareName(loaded.entries)) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return resolveEntries(loaded.entries, loaded.base);
|
|
38
|
-
}
|
|
12
|
+
import { resolveEntries } from "./resolve-entries.js";
|
|
39
13
|
/**
|
|
40
14
|
* Resolve the `[[dirsql.extension]]` entries of several configs, in order.
|
|
41
15
|
*
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtensionSpec } from "./dirsql.js";
|
|
2
|
+
import type { Toml } from "./load-extension-entries.js";
|
|
3
|
+
/** Resolve a config's entries to specs, against that config's own directory. */
|
|
4
|
+
export declare function resolveEntries(entries: Toml[], base: string): ExtensionSpec[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { resolveExtensionPath } from "./resolve-extension.js";
|
|
2
|
+
/** Resolve a config's entries to specs, against that config's own directory. */
|
|
3
|
+
export function resolveEntries(entries, base) {
|
|
4
|
+
return entries.map((e) => ({
|
|
5
|
+
path: resolveExtensionPath(e.path, base, true),
|
|
6
|
+
entrypoint: typeof e.entrypoint === "string" ? e.entrypoint : undefined,
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { PackageResolver } from "./package-dir.js";
|
|
2
|
-
/** True when `path` is a bare package name rather than a file path. */
|
|
3
|
-
export declare function isBareName(path: string): boolean;
|
|
4
2
|
/**
|
|
5
3
|
* Resolve an extension `path` to a concrete file. `base` is the directory a
|
|
6
4
|
* relative path and the bare-name shadow probe resolve against (a config file's
|
|
@@ -12,26 +12,10 @@
|
|
|
12
12
|
// matches and multiple matches are both hard errors -- disambiguate
|
|
13
13
|
// with a literal path.
|
|
14
14
|
import { existsSync, statSync } from "node:fs";
|
|
15
|
-
import { createRequire } from "node:module";
|
|
16
15
|
import { isAbsolute, resolve as resolvePath } from "node:path";
|
|
16
|
+
import { defaultResolver } from "./default-resolver.js";
|
|
17
|
+
import { isBareName } from "./is-bare-name.js";
|
|
17
18
|
import { resolvePackage } from "./resolve-package.js";
|
|
18
|
-
// Suffixes that mark a value as "already a file path" (so package resolution is
|
|
19
|
-
// never attempted).
|
|
20
|
-
const LOADABLE_SUFFIXES = [".so", ".dylib", ".dll", ".node"];
|
|
21
|
-
function defaultResolver() {
|
|
22
|
-
const req = createRequire(import.meta.url);
|
|
23
|
-
return {
|
|
24
|
-
resolve: (s) => req.resolve(s),
|
|
25
|
-
paths: (s) => req.resolve.paths(s),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** True when `path` is a bare package name rather than a file path. */
|
|
29
|
-
export function isBareName(path) {
|
|
30
|
-
if (path.includes("/") || path.includes("\\")) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return !LOADABLE_SUFFIXES.some((s) => path.endsWith(s));
|
|
34
|
-
}
|
|
35
19
|
/**
|
|
36
20
|
* Resolve an extension `path` to a concrete file. `base` is the directory a
|
|
37
21
|
* relative path and the bare-name shadow probe resolve against (a config file's
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.38",
|
|
4
4
|
"description": "Ephemeral SQL index over a local directory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/thekevinscott/dirsql",
|
|
@@ -213,10 +213,10 @@
|
|
|
213
213
|
]
|
|
214
214
|
},
|
|
215
215
|
"optionalDependencies": {
|
|
216
|
-
"@dirsql/lib-linux-x64-gnu": "0.4.
|
|
217
|
-
"@dirsql/lib-linux-arm64-gnu": "0.4.
|
|
218
|
-
"@dirsql/lib-darwin-x64": "0.4.
|
|
219
|
-
"@dirsql/lib-darwin-arm64": "0.4.
|
|
220
|
-
"@dirsql/lib-win32-x64-msvc": "0.4.
|
|
216
|
+
"@dirsql/lib-linux-x64-gnu": "0.4.38",
|
|
217
|
+
"@dirsql/lib-linux-arm64-gnu": "0.4.38",
|
|
218
|
+
"@dirsql/lib-darwin-x64": "0.4.38",
|
|
219
|
+
"@dirsql/lib-darwin-arm64": "0.4.38",
|
|
220
|
+
"@dirsql/lib-win32-x64-msvc": "0.4.38"
|
|
221
221
|
}
|
|
222
222
|
}
|