dirsql 0.4.38 → 0.4.39
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/cli/keep-signals-fatal.d.ts +18 -0
- package/dist/cli/keep-signals-fatal.js +24 -0
- package/dist/cli/main.js +2 -43
- package/dist/cli/resolve-run-cli.d.ts +13 -0
- package/dist/cli/resolve-run-cli.js +19 -0
- package/dist/library-slug.d.ts +8 -0
- package/dist/library-slug.js +13 -0
- package/dist/platform-suffixes.d.ts +2 -0
- package/dist/platform-suffixes.js +10 -0
- package/dist/platforms.d.ts +0 -7
- package/dist/platforms.js +0 -13
- package/dist/resolve-package.js +1 -10
- package/package.json +6 -6
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep Ctrl-C fatal while the CLI runs in-process.
|
|
3
|
+
*
|
|
4
|
+
* The core installs tokio signal handlers for `dirsql server`, and
|
|
5
|
+
* signal-hook (which tokio uses) *chains*: it runs its own actions and then
|
|
6
|
+
* the handler installed before it. CPython installs `default_int_handler` at
|
|
7
|
+
* startup, so the pip launcher gets a terminating disposition for free —
|
|
8
|
+
* bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
|
|
9
|
+
* signal is swallowed and the process becomes SIGKILL-only (measured: a
|
|
10
|
+
* probe ignored SIGTERM for 143 seconds).
|
|
11
|
+
*
|
|
12
|
+
* Registering a JS listener first gives signal-hook a real prior handler to
|
|
13
|
+
* chain to. This cannot be fixed after the fact: `removeAllListeners` only
|
|
14
|
+
* drops JS listeners and cannot touch a disposition installed by native
|
|
15
|
+
* code, and `unregister_signal` leaves the OS handler in place. One listener
|
|
16
|
+
* is the whole remedy — no `unsafe`, no `sigaction`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function keepSignalsFatal(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep Ctrl-C fatal while the CLI runs in-process.
|
|
3
|
+
*
|
|
4
|
+
* The core installs tokio signal handlers for `dirsql server`, and
|
|
5
|
+
* signal-hook (which tokio uses) *chains*: it runs its own actions and then
|
|
6
|
+
* the handler installed before it. CPython installs `default_int_handler` at
|
|
7
|
+
* startup, so the pip launcher gets a terminating disposition for free —
|
|
8
|
+
* bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
|
|
9
|
+
* signal is swallowed and the process becomes SIGKILL-only (measured: a
|
|
10
|
+
* probe ignored SIGTERM for 143 seconds).
|
|
11
|
+
*
|
|
12
|
+
* Registering a JS listener first gives signal-hook a real prior handler to
|
|
13
|
+
* chain to. This cannot be fixed after the fact: `removeAllListeners` only
|
|
14
|
+
* drops JS listeners and cannot touch a disposition installed by native
|
|
15
|
+
* code, and `unregister_signal` leaves the OS handler in place. One listener
|
|
16
|
+
* is the whole remedy — no `unsafe`, no `sigaction`.
|
|
17
|
+
*/
|
|
18
|
+
export function keepSignalsFatal() {
|
|
19
|
+
// While the core is running, its own handler drives shutdown and this
|
|
20
|
+
// listener is the tail of the chain; it matters for signals arriving
|
|
21
|
+
// outside that window, where exiting is exactly right.
|
|
22
|
+
process.on("SIGINT", () => process.exit(130));
|
|
23
|
+
process.on("SIGTERM", () => process.exit(143));
|
|
24
|
+
}
|
package/dist/cli/main.js
CHANGED
|
@@ -6,51 +6,10 @@
|
|
|
6
6
|
// `@dirsql/lib-*` addon the SDK loads carries the CLI, so a package ships one
|
|
7
7
|
// copy of the core instead of two (#739).
|
|
8
8
|
import { mainInProcess } from "bin-shim";
|
|
9
|
-
import { loadNativeCore } from "../load-native-core.js";
|
|
10
9
|
import { die } from "./die.js";
|
|
10
|
+
import { keepSignalsFatal } from "./keep-signals-fatal.js";
|
|
11
11
|
import { withResolvedExtensions } from "./resolve-config-extensions.js";
|
|
12
|
-
|
|
13
|
-
* Resolve `runCli` off the same addon the SDK loads.
|
|
14
|
-
*
|
|
15
|
-
* bin-shim can resolve an addon itself, but its default naming is
|
|
16
|
-
* `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
|
|
17
|
-
* dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
|
|
18
|
-
* `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
|
|
19
|
-
* including its dev fallback to a locally built `dirsql.node` — so a
|
|
20
|
-
* monorepo checkout and a published install take the same path.
|
|
21
|
-
*/
|
|
22
|
-
function resolveRunCli() {
|
|
23
|
-
const core = loadNativeCore();
|
|
24
|
-
if (typeof core.runCli !== "function") {
|
|
25
|
-
throw new Error("dirsql: the native addon has no callable `runCli` export; " +
|
|
26
|
-
"it was built without the `cli` feature.");
|
|
27
|
-
}
|
|
28
|
-
return core.runCli;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Keep Ctrl-C fatal while the CLI runs in-process.
|
|
32
|
-
*
|
|
33
|
-
* The core installs tokio signal handlers for `dirsql server`, and
|
|
34
|
-
* signal-hook (which tokio uses) *chains*: it runs its own actions and then
|
|
35
|
-
* the handler installed before it. CPython installs `default_int_handler` at
|
|
36
|
-
* startup, so the pip launcher gets a terminating disposition for free —
|
|
37
|
-
* bare Node leaves `SIG_DFL`, which signal-hook does not emulate, so the
|
|
38
|
-
* signal is swallowed and the process becomes SIGKILL-only (measured: a
|
|
39
|
-
* probe ignored SIGTERM for 143 seconds).
|
|
40
|
-
*
|
|
41
|
-
* Registering a JS listener first gives signal-hook a real prior handler to
|
|
42
|
-
* chain to. This cannot be fixed after the fact: `removeAllListeners` only
|
|
43
|
-
* drops JS listeners and cannot touch a disposition installed by native
|
|
44
|
-
* code, and `unregister_signal` leaves the OS handler in place. One listener
|
|
45
|
-
* is the whole remedy — no `unsafe`, no `sigaction`.
|
|
46
|
-
*/
|
|
47
|
-
function keepSignalsFatal() {
|
|
48
|
-
// While the core is running, its own handler drives shutdown and this
|
|
49
|
-
// listener is the tail of the chain; it matters for signals arriving
|
|
50
|
-
// outside that window, where exiting is exactly right.
|
|
51
|
-
process.on("SIGINT", () => process.exit(130));
|
|
52
|
-
process.on("SIGTERM", () => process.exit(143));
|
|
53
|
-
}
|
|
12
|
+
import { resolveRunCli } from "./resolve-run-cli.js";
|
|
54
13
|
export async function main(argv = process.argv.slice(2)) {
|
|
55
14
|
keepSignalsFatal();
|
|
56
15
|
// Resolve any package-name extensions in a TOML config here (the core
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The addon's CLI entry point, as napi exports it. */
|
|
2
|
+
export type RunCli = (argv: readonly string[]) => number;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve `runCli` off the same addon the SDK loads.
|
|
5
|
+
*
|
|
6
|
+
* bin-shim can resolve an addon itself, but its default naming is
|
|
7
|
+
* `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
|
|
8
|
+
* dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
|
|
9
|
+
* `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
|
|
10
|
+
* including its dev fallback to a locally built `dirsql.node` — so a
|
|
11
|
+
* monorepo checkout and a published install take the same path.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveRunCli(): RunCli;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { loadNativeCore } from "../load-native-core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `runCli` off the same addon the SDK loads.
|
|
4
|
+
*
|
|
5
|
+
* bin-shim can resolve an addon itself, but its default naming is
|
|
6
|
+
* `@{scope}/lib-{platform}-{arch}`, which cannot express the ABI suffix
|
|
7
|
+
* dirsql's packages carry (`@dirsql/lib-linux-x64-gnu`). Reusing
|
|
8
|
+
* `loadNativeCore` keeps one resolution rule for the SDK and the CLI —
|
|
9
|
+
* including its dev fallback to a locally built `dirsql.node` — so a
|
|
10
|
+
* monorepo checkout and a published install take the same path.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveRunCli() {
|
|
13
|
+
const core = loadNativeCore();
|
|
14
|
+
if (typeof core.runCli !== "function") {
|
|
15
|
+
throw new Error("dirsql: the native addon has no callable `runCli` export; " +
|
|
16
|
+
"it was built without the `cli` feature.");
|
|
17
|
+
}
|
|
18
|
+
return core.runCli;
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Platform } from "./platforms.js";
|
|
2
|
+
/**
|
|
3
|
+
* Suffix used in the napi `.node` filename for a given triple. Follows the
|
|
4
|
+
* `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
|
|
5
|
+
* `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
|
|
6
|
+
* on-disk artifact name and the npm package name can't drift.
|
|
7
|
+
*/
|
|
8
|
+
export declare function librarySlug(p: Platform): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suffix used in the napi `.node` filename for a given triple. Follows the
|
|
3
|
+
* `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
|
|
4
|
+
* `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
|
|
5
|
+
* on-disk artifact name and the npm package name can't drift.
|
|
6
|
+
*/
|
|
7
|
+
export function librarySlug(p) {
|
|
8
|
+
const prefix = "@dirsql/lib-";
|
|
9
|
+
if (!p.libName.startsWith(prefix)) {
|
|
10
|
+
throw new Error(`libName ${p.libName} missing ${prefix} prefix`);
|
|
11
|
+
}
|
|
12
|
+
return p.libName.slice(prefix.length);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Loadable-file glob suffix(es) for the current platform. */
|
|
2
|
+
export function platformSuffixes() {
|
|
3
|
+
if (process.platform === "darwin") {
|
|
4
|
+
return [".dylib", ".node"];
|
|
5
|
+
}
|
|
6
|
+
if (process.platform === "win32") {
|
|
7
|
+
return [".dll", ".node"];
|
|
8
|
+
}
|
|
9
|
+
return [".so", ".node"];
|
|
10
|
+
}
|
package/dist/platforms.d.ts
CHANGED
|
@@ -17,10 +17,3 @@ export interface Platform {
|
|
|
17
17
|
export declare const PLATFORMS: readonly Platform[];
|
|
18
18
|
/** Node `${platform}-${arch}` → `@dirsql/lib-*` napi sub-package name. */
|
|
19
19
|
export declare function libTriples(): Record<string, string>;
|
|
20
|
-
/**
|
|
21
|
-
* Suffix used in the napi `.node` filename for a given triple. Follows the
|
|
22
|
-
* `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
|
|
23
|
-
* `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
|
|
24
|
-
* on-disk artifact name and the npm package name can't drift.
|
|
25
|
-
*/
|
|
26
|
-
export declare function librarySlug(p: Platform): string;
|
package/dist/platforms.js
CHANGED
|
@@ -64,16 +64,3 @@ export function libTriples() {
|
|
|
64
64
|
}
|
|
65
65
|
return out;
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Suffix used in the napi `.node` filename for a given triple. Follows the
|
|
69
|
-
* `@napi-rs/cli` convention: `dirsql.<platform>-<arch>[-<abi>].node`, e.g.
|
|
70
|
-
* `dirsql.linux-x64-gnu.node`. Derived from the sub-package name so the
|
|
71
|
-
* on-disk artifact name and the npm package name can't drift.
|
|
72
|
-
*/
|
|
73
|
-
export function librarySlug(p) {
|
|
74
|
-
const prefix = "@dirsql/lib-";
|
|
75
|
-
if (!p.libName.startsWith(prefix)) {
|
|
76
|
-
throw new Error(`libName ${p.libName} missing ${prefix} prefix`);
|
|
77
|
-
}
|
|
78
|
-
return p.libName.slice(prefix.length);
|
|
79
|
-
}
|
package/dist/resolve-package.js
CHANGED
|
@@ -2,16 +2,7 @@
|
|
|
2
2
|
import { readdirSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { packageDir } from "./package-dir.js";
|
|
5
|
-
|
|
6
|
-
function platformSuffixes() {
|
|
7
|
-
if (process.platform === "darwin") {
|
|
8
|
-
return [".dylib", ".node"];
|
|
9
|
-
}
|
|
10
|
-
if (process.platform === "win32") {
|
|
11
|
-
return [".dll", ".node"];
|
|
12
|
-
}
|
|
13
|
-
return [".so", ".node"];
|
|
14
|
-
}
|
|
5
|
+
import { platformSuffixes } from "./platform-suffixes.js";
|
|
15
6
|
/** Glob the platform loadable inside a bare name's package dir. */
|
|
16
7
|
export function resolvePackage(name, resolver) {
|
|
17
8
|
const dir = packageDir(name, resolver);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.39",
|
|
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.39",
|
|
217
|
+
"@dirsql/lib-linux-arm64-gnu": "0.4.39",
|
|
218
|
+
"@dirsql/lib-darwin-x64": "0.4.39",
|
|
219
|
+
"@dirsql/lib-darwin-arm64": "0.4.39",
|
|
220
|
+
"@dirsql/lib-win32-x64-msvc": "0.4.39"
|
|
221
221
|
}
|
|
222
222
|
}
|