dirsql 0.4.6 → 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/docs/reference/cli.md
CHANGED
|
@@ -69,6 +69,7 @@ Config flags are subcommand-local: pass them after `server`
|
|
|
69
69
|
| `--host <addr>` | `localhost` | Bind address. |
|
|
70
70
|
| `--port <n>` | `7117` | TCP port to bind. |
|
|
71
71
|
| `--persist [<path>]` | off | Keep the SQLite index on disk between runs so a restart only re-parses files that actually changed. Bare `--persist` caches at `<root>/.dirsql/cache.db`; `--persist <path>` caches at `<path>`. Off by default (the index is ephemeral). Also available on [`dirsql query`](#dirsql-query). See [Keep the index across restarts](../howto/persist.md). |
|
|
72
|
+
| `--no-ignore` | off | Scan files a `.gitignore` would hide. [Path-tables](./path-tables.md#skip-rules) respect `.gitignore` files by default; this flag restores the full walk. The built-in skips (`node_modules`/`.git`) and configured `ignore` patterns still apply. Also available on [`dirsql query`](#dirsql-query). |
|
|
72
73
|
| `--extension <path>` | none | Load a SQLite extension by literal path, overriding the config's `[[dirsql.extension]]` entries. Repeatable. Format: `<path>` or `<path>::<entrypoint>`. Internal plumbing for the pip/npm launchers, which resolve package-name extensions and pass the resolved paths here — not intended for direct use. When any `--extension` is present, the config file's own extension entries are not loaded. |
|
|
73
74
|
| `--version` | | Print the version and exit. |
|
|
74
75
|
| `--help` | | Print usage and exit. |
|
|
@@ -163,6 +164,8 @@ uses**, so behavior is identical to `POST /query` by construction:
|
|
|
163
164
|
on-disk cache. Because its value is optional, place a bare `--persist` after
|
|
164
165
|
the SQL (`dirsql query "SELECT …" --persist`) or use the `=` form
|
|
165
166
|
(`--persist=/path`) so it does not swallow the SQL argument.
|
|
167
|
+
- **`--no-ignore`** is honored: path-tables in the query scan files a
|
|
168
|
+
`.gitignore` would hide. See [Skip rules](./path-tables.md#skip-rules).
|
|
166
169
|
- **Hooks** ([`pre-query`](./hooks.md#pre-query) /
|
|
167
170
|
[`post-query`](./hooks.md#post-query)) and the
|
|
168
171
|
[`[dirsql].hook-timeout`](./config.md#dirsql-keys) apply identically.
|
|
@@ -179,19 +179,48 @@ A path-table scan applies the same [`ignore`](/reference/config) patterns your
|
|
|
179
179
|
declared tables use, plus two built-in defaults so a zero-config
|
|
180
180
|
`SELECT * FROM './'` does not drown in machinery:
|
|
181
181
|
|
|
182
|
-
-
|
|
183
|
-
-
|
|
182
|
+
- `**/node_modules/**`
|
|
183
|
+
- `**/.git/**`
|
|
184
|
+
|
|
185
|
+
Both apply at any depth, so a `node_modules` nested inside a subdirectory is
|
|
186
|
+
skipped just like one at the top.
|
|
187
|
+
|
|
188
|
+
### `.gitignore`
|
|
189
|
+
|
|
190
|
+
Path-table scans also respect `.gitignore` files by default, the way fd and
|
|
191
|
+
ripgrep do: a `.gitignore` anywhere in the tree applies below its own
|
|
192
|
+
directory, deeper files override shallower ones, `!pattern` re-includes, and
|
|
193
|
+
an ignored directory is pruned rather than walked. In a typical repo this
|
|
194
|
+
excludes build output, virtualenvs, and caches with zero ceremony. No `.git`
|
|
195
|
+
directory is required — a `.gitignore` in any scanned directory counts — and
|
|
196
|
+
the built-in defaults above remain as a floor for directories with no
|
|
197
|
+
`.gitignore` at all.
|
|
198
|
+
|
|
199
|
+
Pass [`--no-ignore`](./cli.md#flags) to restore the full walk — the
|
|
200
|
+
determinism switch for scripted use, since results otherwise depend on
|
|
201
|
+
`.gitignore` state. It disables only the `.gitignore` respect; the built-in
|
|
202
|
+
defaults and configured `ignore` patterns still apply.
|
|
203
|
+
|
|
204
|
+
### Naming a skipped directory
|
|
184
205
|
|
|
185
206
|
Skip rules are judged on the part of the path *below* what you named outright,
|
|
186
|
-
so pointing at a skipped directory still scans it:
|
|
207
|
+
so pointing at a skipped directory — built-in or gitignored — still scans it:
|
|
187
208
|
|
|
188
209
|
```sql
|
|
189
210
|
SELECT path FROM './'; -- no node_modules rows
|
|
190
211
|
SELECT path FROM './node_modules/*/package.json'; -- scans it anyway
|
|
212
|
+
SELECT path FROM './dist'; -- scans dist/ even when gitignored
|
|
191
213
|
```
|
|
192
214
|
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
A `.gitignore` at or below the directory you named still filters beneath it;
|
|
216
|
+
only rules inherited from above it are set aside.
|
|
217
|
+
|
|
218
|
+
### Hidden files
|
|
219
|
+
|
|
220
|
+
Dotfiles are ordinary files: `'./'` and `'./*'` include them, with or without
|
|
221
|
+
`--no-ignore`. This is a deliberate divergence from fd/ripgrep — querying
|
|
222
|
+
dotfile directories (`.claude/`, …) is a first-class `dirsql` use case. Add an
|
|
223
|
+
`ignore` pattern if you would rather not see them.
|
|
195
224
|
|
|
196
225
|
## Joining against declared tables
|
|
197
226
|
|
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
|
}
|