@dbx-tools/path 0.3.37 → 0.3.40

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/README.md CHANGED
@@ -22,7 +22,7 @@ Key features:
22
22
  import { find, ignore } from "@dbx-tools/path";
23
23
 
24
24
  const files = find
25
- .findFiles(["workspaces/**/src/**/*.ts"], {
25
+ .findFiles(["packages/**/src/**/*.ts"], {
26
26
  ignore: ignore.ignorePatterns(),
27
27
  })
28
28
  .toArray();
@@ -41,7 +41,7 @@ should agree with package discovery, barrel generation, or cleanup logic.
41
41
  import { match } from "@dbx-tools/path";
42
42
 
43
43
  const isTest = match.toPathMatcher("**/*.test.ts");
44
- if (isTest("workspaces/shared/model/test/classify.test.ts")) {
44
+ if (isTest("packages/shared/model/test/classify.test.ts")) {
45
45
  skip();
46
46
  }
47
47
  ```
@@ -71,7 +71,7 @@ generated files, build output, VCS metadata, and package-manager output.
71
71
  import { scan } from "@dbx-tools/path";
72
72
 
73
73
  const options: scan.FileScanOptions = {
74
- roots: ["workspaces", "example-workspaces"],
74
+ roots: ["workspaces", "example-packages"],
75
75
  followSymlinks: scan.FOLLOW_SYMLINKS_DEFAULT,
76
76
  };
77
77
  ```
@@ -85,7 +85,7 @@ like synthesis does.
85
85
  ```ts
86
86
  import { watch } from "@dbx-tools/path";
87
87
 
88
- const watcher = watch.watchFiles(["workspaces/**/src/**/*.ts"], {
88
+ const watcher = watch.watchFiles(["packages/**/src/**/*.ts"], {
89
89
  ignoreInitial: true,
90
90
  });
91
91
 
@@ -111,7 +111,7 @@ Pattern helpers keep generated glob fragments escaped and consistent.
111
111
  - `find` - glob-backed lazy file finding.
112
112
  - `match` - glob-to-predicate path matchers.
113
113
  - `ignore` - standard ignore pattern and matcher construction.
114
- - `scan` - workspace package scan option types and defaults.
114
+ - `scan` - package scan option types and defaults.
115
115
  - `watch` - chokidar wrapper for file watching.
116
116
  - `pattern` - escaped directory-name and extension glob fragments.
117
117
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/reggie-db/dbx-tools.git",
6
- "directory": "workspaces/node/path"
6
+ "directory": "packages/node/path"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@types/node": "^24.6.0",
@@ -14,21 +14,25 @@
14
14
  "chokidar": "^4.0.3",
15
15
  "glob": "^13.0.6",
16
16
  "minimatch": "^10.2.5",
17
- "@dbx-tools/core": "0.3.37",
18
- "@dbx-tools/shared-core": "0.3.37"
17
+ "@dbx-tools/core": "0.3.40",
18
+ "@dbx-tools/shared-core": "0.3.40"
19
19
  },
20
20
  "main": "index.ts",
21
21
  "license": "UNLICENSED",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "version": "0.3.37",
25
+ "version": "0.3.40",
26
26
  "types": "index.ts",
27
27
  "type": "module",
28
28
  "exports": {
29
29
  ".": "./index.ts",
30
30
  "./package.json": "./package.json"
31
31
  },
32
+ "files": [
33
+ "index.ts",
34
+ "src"
35
+ ],
32
36
  "dbxToolsConfig": {
33
37
  "tags": [
34
38
  "node"
package/src/match.ts CHANGED
@@ -61,6 +61,6 @@ if (import.meta.main) {
61
61
  const matcher = ignorePathMatcher({ test: true })
62
62
  .negate()
63
63
  .and(...pathMatchTests("**/cool.ts", "**/wow.ts"));
64
- console.log(matcher("workspaces/node/file-scan/src/cool.ts"));
65
- console.log(matcher("workspaces/node/file-scan/.src/cool.ts"));
64
+ console.log(matcher("packages/node/file-scan/src/cool.ts"));
65
+ console.log(matcher("packages/node/file-scan/.src/cool.ts"));
66
66
  }
package/.projen/deps.json DELETED
@@ -1,44 +0,0 @@
1
- {
2
- "dependencies": [
3
- {
4
- "name": "@types/node",
5
- "version": "catalog:",
6
- "type": "build"
7
- },
8
- {
9
- "name": "tsx",
10
- "version": "^4.23.0",
11
- "type": "build"
12
- },
13
- {
14
- "name": "typescript",
15
- "type": "build"
16
- },
17
- {
18
- "name": "@dbx-tools/core",
19
- "version": "workspace:*",
20
- "type": "runtime"
21
- },
22
- {
23
- "name": "@dbx-tools/shared-core",
24
- "version": "workspace:*",
25
- "type": "runtime"
26
- },
27
- {
28
- "name": "chokidar",
29
- "version": "^4.0.3",
30
- "type": "runtime"
31
- },
32
- {
33
- "name": "glob",
34
- "version": "^13.0.6",
35
- "type": "runtime"
36
- },
37
- {
38
- "name": "minimatch",
39
- "version": "^10.2.5",
40
- "type": "runtime"
41
- }
42
- ],
43
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
44
- }
@@ -1,11 +0,0 @@
1
- {
2
- "files": [
3
- ".projen/deps.json",
4
- ".projen/files.json",
5
- ".projen/tasks.json",
6
- "package.json",
7
- "test/tsconfig.json",
8
- "tsconfig.json"
9
- ],
10
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
11
- }
@@ -1,121 +0,0 @@
1
- {
2
- "manifestVersion": 3,
3
- "env": {
4
- "PATH": "$(pnpm -c exec \"node --print process.env.PATH\")"
5
- },
6
- "tasks": {
7
- "build": {
8
- "name": "build",
9
- "description": "Full release build",
10
- "steps": [
11
- {
12
- "spawn": "pre-compile"
13
- },
14
- {
15
- "spawn": "compile"
16
- },
17
- {
18
- "spawn": "post-compile"
19
- },
20
- {
21
- "spawn": "test"
22
- },
23
- {
24
- "spawn": "package"
25
- }
26
- ]
27
- },
28
- "compile": {
29
- "name": "compile",
30
- "description": "Only compile",
31
- "steps": [
32
- {
33
- "execArgs": [
34
- "tsc",
35
- "--build"
36
- ]
37
- }
38
- ]
39
- },
40
- "default": {
41
- "name": "default",
42
- "description": "Synthesize project files",
43
- "steps": [
44
- {
45
- "exec": "pnpm exec projen default",
46
- "cwd": "../../.."
47
- }
48
- ]
49
- },
50
- "install": {
51
- "name": "install",
52
- "description": "Install project dependencies and update lockfile (non-frozen)",
53
- "steps": [
54
- {
55
- "exec": "pnpm i --no-frozen-lockfile"
56
- }
57
- ]
58
- },
59
- "install:ci": {
60
- "name": "install:ci",
61
- "description": "Install project dependencies using frozen lockfile",
62
- "steps": [
63
- {
64
- "exec": "pnpm i --frozen-lockfile"
65
- }
66
- ]
67
- },
68
- "package": {
69
- "name": "package",
70
- "description": "Creates the distribution package",
71
- "steps": [
72
- {
73
- "execArgs": [
74
- "mkdir",
75
- "-p",
76
- "dist/js"
77
- ]
78
- },
79
- {
80
- "execArgs": [
81
- "pnpm",
82
- "pack",
83
- "--pack-destination",
84
- "dist/js"
85
- ]
86
- }
87
- ]
88
- },
89
- "post-compile": {
90
- "name": "post-compile",
91
- "description": "Runs after successful compilation"
92
- },
93
- "pre-compile": {
94
- "name": "pre-compile",
95
- "description": "Prepare the project for compilation"
96
- },
97
- "test": {
98
- "name": "test",
99
- "description": "Run tests",
100
- "steps": [
101
- {
102
- "exec": "tsx --test 'test/**/*.test.ts'"
103
- }
104
- ]
105
- },
106
- "watch": {
107
- "name": "watch",
108
- "description": "Watch & compile in the background",
109
- "steps": [
110
- {
111
- "execArgs": [
112
- "tsc",
113
- "--build",
114
- "-w"
115
- ]
116
- }
117
- ]
118
- }
119
- },
120
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
121
- }
@@ -1 +0,0 @@
1
- export const secret = true;
@@ -1 +0,0 @@
1
- export const skip = true;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export const keep = true;
@@ -1,99 +0,0 @@
1
- /**
2
- * Parity tests: the same ignore patterns must make {@link findFiles} and
3
- * {@link watchFiles} keep the same set of files. Both run against a temp copy of
4
- * the fixture tree (see the note below the imports for why a temp root is used)
5
- * and their results are asserted equal, then checked against a concrete list.
6
- */
7
- import assert from "node:assert/strict";
8
- import { cpSync, mkdtempSync, rmSync } from "node:fs";
9
- import { tmpdir } from "node:os";
10
- import { join, relative, sep, isAbsolute } from "node:path";
11
- import { after, before, describe, it } from "node:test";
12
- import { fileURLToPath } from "node:url";
13
- import { findFiles } from "../src/find";
14
- import { watchFiles } from "../src/watch";
15
-
16
- const FIXTURE_SOURCE = fileURLToPath(new URL("fixtures/sample-tree", import.meta.url));
17
-
18
- // glob matches ignore patterns against cwd-relative paths, while chokidar
19
- // matches them against absolute paths. The real fixture lives under a `test/`
20
- // directory, so the default `**/test/**` group would match in watch (absolute)
21
- // but not in scan (relative) - a mismatch unrelated to the shared patterns.
22
- // Copying the tree to a neutral temp root removes that ancestor so the two are
23
- // compared purely on pattern parity.
24
- let root: string;
25
-
26
- before(() => {
27
- root = mkdtempSync(join(tmpdir(), "file-scan-parity-"));
28
- cpSync(FIXTURE_SOURCE, root, { recursive: true });
29
- });
30
-
31
- after(() => {
32
- rmSync(root, { recursive: true, force: true });
33
- });
34
-
35
- const toPosix = (path: string): string => path.split(sep).join("/");
36
-
37
- /** Files fileScan keeps for the fixture (relative, posix) given `ignore`. */
38
- function scannedFiles(ignore: string | string[] | undefined): Set<string> {
39
- return new Set([...findFiles("**", { cwd: root, nodir: true, ignore })].map(toPosix));
40
- }
41
-
42
- /** Files fileWatch reports for the (static) fixture (relative, posix), then closes. */
43
- async function watchedFiles(ignore: string | string[] | undefined): Promise<Set<string>> {
44
- const files = new Set<string>();
45
- const watcher = watchFiles(root, {
46
- cwd: root,
47
- ignore,
48
- persistent: false,
49
- ignoreInitial: false,
50
- });
51
- watcher.on("add", (path) => {
52
- const rel = isAbsolute(path) ? relative(root, path) : path;
53
- files.add(toPosix(rel === "" ? "." : rel));
54
- });
55
- try {
56
- await new Promise<void>((resolve, reject) => {
57
- watcher.once("ready", () => resolve());
58
- watcher.once("error", reject);
59
- });
60
- } finally {
61
- await watcher.close();
62
- }
63
- return files;
64
- }
65
-
66
- /**
67
- * The same ignore patterns must make fileScan and fileWatch keep the same files.
68
- * Asserts parity, then returns the (shared) sorted result for concrete checks.
69
- */
70
- async function keptByBoth(patterns: string | string[] | undefined): Promise<string[]> {
71
- const scanned = [...scannedFiles(patterns)].sort();
72
- const watched = [...(await watchedFiles(patterns))].sort();
73
- assert.deepEqual(watched, scanned);
74
- return scanned;
75
- }
76
-
77
- describe("scan/watch matching parity", () => {
78
- // `.hidden` (dot group) and any node_modules/dist (default groups) are dropped
79
- // by both; only the plain source files survive the default ignore list.
80
- it("keeps the same files with only the default ignore groups", async () => {
81
- assert.deepEqual(await keptByBoth(undefined), [
82
- "example/skip.ts",
83
- "src/index.ts",
84
- "src/keep.ts",
85
- ]);
86
- });
87
-
88
- it("keeps the same files ignoring a file pattern", async () => {
89
- assert.deepEqual(await keptByBoth("**/index.ts"), ["example/skip.ts", "src/keep.ts"]);
90
- });
91
-
92
- it("keeps the same files ignoring a directory pattern", async () => {
93
- assert.deepEqual(await keptByBoth(["**/example/**"]), ["src/index.ts", "src/keep.ts"]);
94
- });
95
-
96
- it("keeps the same files ignoring multiple patterns", async () => {
97
- assert.deepEqual(await keptByBoth(["**/index.ts", "**/example/**"]), ["src/keep.ts"]);
98
- });
99
- });
@@ -1,14 +0,0 @@
1
- // ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
2
- {
3
- "extends": "../tsconfig.json",
4
- "compilerOptions": {
5
- "noEmit": true,
6
- "rootDir": ".."
7
- },
8
- "include": [
9
- "**/*.ts"
10
- ],
11
- "exclude": [
12
- "node_modules"
13
- ]
14
- }
package/tsconfig.json DELETED
@@ -1,41 +0,0 @@
1
- // ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
2
- {
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "lib",
6
- "alwaysStrict": true,
7
- "declaration": true,
8
- "esModuleInterop": true,
9
- "experimentalDecorators": true,
10
- "inlineSourceMap": true,
11
- "inlineSources": true,
12
- "lib": [
13
- "ES2022"
14
- ],
15
- "module": "ESNext",
16
- "noEmitOnError": false,
17
- "noFallthroughCasesInSwitch": true,
18
- "noImplicitAny": true,
19
- "noImplicitReturns": true,
20
- "noImplicitThis": true,
21
- "noUnusedLocals": true,
22
- "noUnusedParameters": true,
23
- "resolveJsonModule": true,
24
- "strict": true,
25
- "strictNullChecks": true,
26
- "strictPropertyInitialization": true,
27
- "stripInternal": true,
28
- "target": "ES2022",
29
- "types": [
30
- "node"
31
- ],
32
- "moduleResolution": "bundler",
33
- "skipLibCheck": true
34
- },
35
- "include": [
36
- "src/**/*.ts"
37
- ],
38
- "exclude": [
39
- "node_modules"
40
- ]
41
- }