@mark1russell7/boundaries 0.1.0 → 0.2.0
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 +40 -4
- package/build/index.cjs +85 -9
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +47 -6
- package/build/index.d.cts.map +1 -1
- package/build/index.d.ts +47 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +83 -10
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,10 +9,15 @@ This package gives the import boundaries of a pnpm workspace as a [dependency-cr
|
|
|
9
9
|
| `relative-import-out-of-<package>` | A relative import (`../../b/src/x.js`) goes into the folder of a different package. |
|
|
10
10
|
| `deep-import-into-<package>` | An import gets to a file of a package that is not an entry of its `package.json` (`exports`, `main`, `module`, `types` or `bin`). |
|
|
11
11
|
| `not-a-declared-export` | An import of a workspace package does not resolve. The path is not in its `exports`, or the package is not built. |
|
|
12
|
+
| `unknown-workspace-package` | An import in a scope of the workspace (for example `@x/typo`) does not resolve, and the name is not a workspace package or a declared dependency. |
|
|
12
13
|
| `import-of-the-app-<package>` | A package imports an app. An app is a leaf of the graph. This rule is only on with the option `apps`. |
|
|
13
14
|
|
|
14
15
|
A type-only import is a boundary too. Tests, fixtures and declaration files are not part of a boundary.
|
|
15
16
|
|
|
17
|
+
The rule `import-of-the-app-<package>` examines only the path of an import that resolves. When the name of an app does not resolve, `not-a-declared-export` finds the import.
|
|
18
|
+
|
|
19
|
+
The scopes of `unknown-workspace-package` are the scopes of the workspace package names. For example, the packages `@x/a` and `@x/b` give the scope `@x`. A declared dependency is a name in a dependency field (`dependencies`, `devDependencies`, `peerDependencies` or `optionalDependencies`) of the root `package.json` or of a workspace package.
|
|
20
|
+
|
|
16
21
|
## Use
|
|
17
22
|
|
|
18
23
|
Install the package, `dependency-cruiser` and, for TypeScript 7 or for source with no TypeScript compiler, `@swc/core`:
|
|
@@ -21,6 +26,15 @@ Install the package, `dependency-cruiser` and, for TypeScript 7 or for source wi
|
|
|
21
26
|
pnpm add -D @mark1russell7/boundaries dependency-cruiser @swc/core
|
|
22
27
|
```
|
|
23
28
|
|
|
29
|
+
Since pnpm 11, the install fails with `ERR_PNPM_IGNORED_BUILDS` when a package has an install script that `allowBuilds` does not name. `@swc/core` has an install script. That script only examines the native package, and pnpm installs the native package as an optional dependency. Thus disallow the script in `pnpm-workspace.yaml` before the install:
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
allowBuilds:
|
|
33
|
+
"@swc/core": false
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The option `--allow-build='!@swc/core'` of `pnpm add` writes the same setting.
|
|
37
|
+
|
|
24
38
|
Write `.dependency-cruiser.mjs` at the root of the repository:
|
|
25
39
|
|
|
26
40
|
```js
|
|
@@ -39,7 +53,9 @@ Add the script `"check:boundaries": "depcruise --config .dependency-cruiser.mjs
|
|
|
39
53
|
|---|---|---|
|
|
40
54
|
| `packages` | the `packages` list of `pnpm-workspace.yaml` | The globs of the package folders. |
|
|
41
55
|
| `apps` | none | The apps. `"private"` makes each private package an app. |
|
|
42
|
-
| `reference` | none | A text before each comment, for example the name of the decision record. |
|
|
56
|
+
| `reference` | none | A text before each comment, for example the name of the decision record. The rules of `forbidden` get it too, when their comment does not start with it. |
|
|
57
|
+
| `scopes` | the scopes of the workspace package names | The scopes of `unknown-workspace-package`. A list replaces the scopes. `{ add: ["@y"], remove: ["@x"] }` changes them. `[]` turns off the rule. |
|
|
58
|
+
| `buildFolders` | `["dist", "build"]` | The build folders of each package. The analysis does not follow them. `[]` follows them. |
|
|
43
59
|
| `forbidden` | none | More rules of the repository, after the rules of the boundaries. |
|
|
44
60
|
| `options` | the default options | More options of dependency-cruiser. They replace the default options that have the same key. |
|
|
45
61
|
|
|
@@ -55,6 +71,7 @@ module.exports = boundaries(__dirname, {
|
|
|
55
71
|
{
|
|
56
72
|
name: "transport-imports-server",
|
|
57
73
|
severity: "error",
|
|
74
|
+
comment: "A transport does not import the server.",
|
|
58
75
|
from: { path: "^packages/client/src/adapters/" },
|
|
59
76
|
to: { path: "^packages/server/" },
|
|
60
77
|
},
|
|
@@ -62,12 +79,31 @@ module.exports = boundaries(__dirname, {
|
|
|
62
79
|
});
|
|
63
80
|
```
|
|
64
81
|
|
|
82
|
+
## The default options
|
|
83
|
+
|
|
84
|
+
- `doNotFollow`: `node_modules` and the build folders of each package (`buildFolders`). An import of a different package stops at its entry, for example `packages/b/dist/index.js`. The analysis does not go into the imports of that built file. It also does not start from the files of a build folder.
|
|
85
|
+
- `enhancedResolveOptions.conditionNames`: `["import", "node", "default"]`, as Node resolves an ESM import. An entry that is only for `require` does not resolve.
|
|
86
|
+
- `exclude`: tests, fixtures, declaration files and `node_modules`.
|
|
87
|
+
|
|
88
|
+
To change a default option, give the option in `options`. For example, `options: { enhancedResolveOptions: { exportsFields: ["exports"], conditionNames: ["import", "require", "node", "default"], mainFields: ["module", "main"] } }` also resolves the entries for `require`.
|
|
89
|
+
|
|
65
90
|
## The parser
|
|
66
91
|
|
|
67
|
-
dependency-cruiser reads TypeScript with the TypeScript compiler of the repository only for TypeScript 2 to 6. With TypeScript 7, or with no TypeScript, `boundaries()` sets the parser `swc` when `@swc/core` is installed. Without `@swc/core`, dependency-cruiser reads only JavaScript.
|
|
92
|
+
dependency-cruiser reads TypeScript with the TypeScript compiler of the repository only for TypeScript 2 to 6. With TypeScript 7, or with no TypeScript, `boundaries()` sets the parser `swc` when `@swc/core` is installed. Without `@swc/core`, dependency-cruiser reads only JavaScript. For a check of built JavaScript, set `buildFolders: []`.
|
|
93
|
+
|
|
94
|
+
## Changes in 0.2.0
|
|
95
|
+
|
|
96
|
+
These changes can give different results than 0.1.0:
|
|
97
|
+
|
|
98
|
+
- The analysis does not follow the build folders (`dist/` and `build/`) of the packages.
|
|
99
|
+
- The resolution does not use the condition `require`.
|
|
100
|
+
- The new rule `unknown-workspace-package` finds an import of an unknown name in a scope of the workspace.
|
|
101
|
+
- The rules of `forbidden` get the text of `reference`.
|
|
68
102
|
|
|
69
103
|
## Other exports
|
|
70
104
|
|
|
71
105
|
- `boundaryRules(packages, options)` gives only the rules, for a list of packages.
|
|
72
|
-
- `workspacePackages(root, globs)` gives the packages of the workspace and their
|
|
73
|
-
- `
|
|
106
|
+
- `workspacePackages(root, globs)` gives the packages of the workspace, their entries and their declared dependencies.
|
|
107
|
+
- `workspaceScopes(packages, scopes)` gives the scopes of `unknown-workspace-package`.
|
|
108
|
+
- `declaredDependencies(manifest)` gives the names in the dependency fields of a `package.json`.
|
|
109
|
+
- `defaultOptions(root, { packages, buildFolders })`, `doNotFollowPaths(packages, buildFolders)` and `parserOptions(root)` give the default options.
|
package/build/index.cjs
CHANGED
|
@@ -16,6 +16,32 @@ let node_path = require("node:path");
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
19
|
+
/** The default build folders of a package. */
|
|
20
|
+
const BUILD_FOLDERS = ["dist", "build"];
|
|
21
|
+
const DEPENDENCY_FIELDS = [
|
|
22
|
+
"dependencies",
|
|
23
|
+
"devDependencies",
|
|
24
|
+
"peerDependencies",
|
|
25
|
+
"optionalDependencies"
|
|
26
|
+
];
|
|
27
|
+
/** The names of the dependencies of a package.json, from each dependency field. */
|
|
28
|
+
function declaredDependencies(manifest) {
|
|
29
|
+
const names = /* @__PURE__ */ new Set();
|
|
30
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
31
|
+
const value = manifest[field];
|
|
32
|
+
if (value && typeof value === "object" && !Array.isArray(value)) for (const name of Object.keys(value)) names.add(name);
|
|
33
|
+
}
|
|
34
|
+
return [...names].sort();
|
|
35
|
+
}
|
|
36
|
+
/** The scopes of the package names, for example "@x" for "@x/a", changed by the option `scopes`. A name with no scope gives no scope. */
|
|
37
|
+
function workspaceScopes(packages, opts = {}) {
|
|
38
|
+
const normal = (scope) => (scope.startsWith("@") ? scope : `@${scope}`).replace(/\/$/, "");
|
|
39
|
+
if (Array.isArray(opts)) return [...new Set(opts.map(normal))].sort();
|
|
40
|
+
const scopes = new Set(packages.filter((p) => p.name.startsWith("@") && p.name.includes("/")).map((p) => p.name.slice(0, p.name.indexOf("/"))));
|
|
41
|
+
for (const scope of opts.add ?? []) scopes.add(normal(scope));
|
|
42
|
+
for (const scope of opts.remove ?? []) scopes.delete(normal(scope));
|
|
43
|
+
return [...scopes].sort();
|
|
44
|
+
}
|
|
19
45
|
/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */
|
|
20
46
|
function workspaceGlobs(yaml) {
|
|
21
47
|
const globs = [];
|
|
@@ -140,7 +166,8 @@ function workspacePackages(root, globs) {
|
|
|
140
166
|
name: manifest["name"],
|
|
141
167
|
dir,
|
|
142
168
|
private: manifest["private"] === true,
|
|
143
|
-
entries: packageEntries(dir, manifest)
|
|
169
|
+
entries: packageEntries(dir, manifest),
|
|
170
|
+
dependencies: declaredDependencies(manifest)
|
|
144
171
|
});
|
|
145
172
|
}
|
|
146
173
|
return found;
|
|
@@ -186,6 +213,23 @@ function boundaryRules(packages, opts = {}) {
|
|
|
186
213
|
couldNotResolve: true
|
|
187
214
|
}
|
|
188
215
|
});
|
|
216
|
+
const scopes = workspaceScopes(packages, opts.scopes);
|
|
217
|
+
if (scopes.length > 0) {
|
|
218
|
+
const inScope = (name) => scopes.some((scope) => name.startsWith(`${scope}/`));
|
|
219
|
+
const declared = [...packages.flatMap((p) => p.dependencies ?? []), ...opts.dependencies ?? []];
|
|
220
|
+
const known = [...new Set([...packages.map((p) => p.name), ...declared].filter(inScope))].sort().map(escape);
|
|
221
|
+
rules.push({
|
|
222
|
+
name: "unknown-workspace-package",
|
|
223
|
+
severity: "error",
|
|
224
|
+
comment: why(`An import names a package of the scope ${scopes.join(", ")}, but the import does not resolve. The name is not a package of this workspace and not a declared dependency. Correct the name, or add the package.`),
|
|
225
|
+
from: {},
|
|
226
|
+
to: {
|
|
227
|
+
path: `^(${scopes.map(escape).join("|")})/`,
|
|
228
|
+
...known.length > 0 ? { pathNot: `^(${known.join("|")})(/|$)` } : {},
|
|
229
|
+
couldNotResolve: true
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
189
233
|
const apps = opts.apps === "private" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));
|
|
190
234
|
for (const app of apps) rules.push({
|
|
191
235
|
name: `import-of-the-app-${slug(app.name)}`,
|
|
@@ -216,13 +260,25 @@ function parserOptions(root) {
|
|
|
216
260
|
} catch {}
|
|
217
261
|
return {};
|
|
218
262
|
}
|
|
263
|
+
/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */
|
|
264
|
+
function doNotFollowPaths(packages, buildFolders = BUILD_FOLDERS) {
|
|
265
|
+
const paths = ["(^|/)node_modules/"];
|
|
266
|
+
const dirs = packages.map((p) => p.dir).filter((dir) => dir !== "" && dir !== ".");
|
|
267
|
+
const folders = buildFolders.map((folder) => folder.replace(/^\.\//, "").replace(/\/$/, "")).filter((folder) => folder !== "");
|
|
268
|
+
if (dirs.length > 0 && folders.length > 0) paths.push(`^(${dirs.map(escape).join("|")})/(${folders.map(escape).join("|")})/`);
|
|
269
|
+
return paths;
|
|
270
|
+
}
|
|
219
271
|
/**
|
|
220
272
|
* The default options: the source of the packages, with type-only imports, resolved as Node resolves
|
|
221
|
-
*
|
|
222
|
-
* rule not-a-declared-export needs them. The
|
|
223
|
-
*
|
|
273
|
+
* an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,
|
|
274
|
+
* and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the
|
|
275
|
+
* build folders of the packages: an import of a package stops at its entry. The "types" condition is
|
|
276
|
+
* not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep
|
|
277
|
+
* import does not show. The `require` condition is not used: an ESM import does not resolve to an
|
|
278
|
+
* entry that is only for `require`.
|
|
224
279
|
*/
|
|
225
|
-
function defaultOptions(root) {
|
|
280
|
+
function defaultOptions(root, input = {}) {
|
|
281
|
+
const packages = input.packages ?? (root ? workspacePackages(root) : []);
|
|
226
282
|
return {
|
|
227
283
|
...parserOptions(root),
|
|
228
284
|
exclude: { path: [
|
|
@@ -231,12 +287,11 @@ function defaultOptions(root) {
|
|
|
231
287
|
"\\.d\\.[cm]?ts$",
|
|
232
288
|
"/(test|tests|e2e|__tests__|fixtures)/"
|
|
233
289
|
] },
|
|
234
|
-
doNotFollow: { path:
|
|
290
|
+
doNotFollow: { path: doNotFollowPaths(packages, input.buildFolders) },
|
|
235
291
|
enhancedResolveOptions: {
|
|
236
292
|
exportsFields: ["exports"],
|
|
237
293
|
conditionNames: [
|
|
238
294
|
"import",
|
|
239
|
-
"require",
|
|
240
295
|
"node",
|
|
241
296
|
"default"
|
|
242
297
|
],
|
|
@@ -245,25 +300,46 @@ function defaultOptions(root) {
|
|
|
245
300
|
skipAnalysisNotInRules: true
|
|
246
301
|
};
|
|
247
302
|
}
|
|
303
|
+
/** A rule with the reference before its comment, when the comment does not start with it. */
|
|
304
|
+
function withReference(rule, reference) {
|
|
305
|
+
if (!reference || rule.comment?.startsWith(reference)) return rule;
|
|
306
|
+
return {
|
|
307
|
+
...rule,
|
|
308
|
+
comment: rule.comment ? `${reference} ${rule.comment}` : reference
|
|
309
|
+
};
|
|
310
|
+
}
|
|
248
311
|
/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */
|
|
249
312
|
function boundaries(root, opts = {}) {
|
|
250
313
|
const packages = workspacePackages(root, opts.packages);
|
|
314
|
+
let rootManifest = {};
|
|
315
|
+
try {
|
|
316
|
+
rootManifest = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(root, "package.json"), "utf8"));
|
|
317
|
+
} catch {}
|
|
251
318
|
const options = {
|
|
252
|
-
...defaultOptions(root
|
|
319
|
+
...defaultOptions(root, {
|
|
320
|
+
packages,
|
|
321
|
+
...opts.buildFolders ? { buildFolders: opts.buildFolders } : {}
|
|
322
|
+
}),
|
|
253
323
|
...opts.options
|
|
254
324
|
};
|
|
255
325
|
return {
|
|
256
|
-
forbidden: [...boundaryRules(packages,
|
|
326
|
+
forbidden: [...boundaryRules(packages, {
|
|
327
|
+
...opts,
|
|
328
|
+
dependencies: declaredDependencies(rootManifest)
|
|
329
|
+
}), ...(opts.forbidden ?? []).map((rule) => withReference(rule, opts.reference))],
|
|
257
330
|
options
|
|
258
331
|
};
|
|
259
332
|
}
|
|
260
333
|
exports.boundaries = boundaries;
|
|
261
334
|
exports.boundaryRules = boundaryRules;
|
|
335
|
+
exports.declaredDependencies = declaredDependencies;
|
|
262
336
|
exports.defaultOptions = defaultOptions;
|
|
337
|
+
exports.doNotFollowPaths = doNotFollowPaths;
|
|
263
338
|
exports.entryPattern = entryPattern;
|
|
264
339
|
exports.packageEntries = packageEntries;
|
|
265
340
|
exports.parserOptions = parserOptions;
|
|
266
341
|
exports.workspaceGlobs = workspaceGlobs;
|
|
267
342
|
exports.workspacePackages = workspacePackages;
|
|
343
|
+
exports.workspaceScopes = workspaceScopes;
|
|
268
344
|
|
|
269
345
|
//# sourceMappingURL=index.cjs.map
|
package/build/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["statSync","join","readdirSync","posix","readFileSync","require","createRequire"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * The import boundaries of a workspace, as a dependency-cruiser configuration. Each package is a\n * unit. Another package imports it only through an entry of its package.json (`exports`, `main`,\n * `module`, `types`, `bin`). A relative path or a deep path into its folder is not an entry.\n *\n * A repository uses it from its `.dependency-cruiser.cjs`:\n *\n * ```js\n * const { boundaries } = require(\"@mark1russell7/boundaries\");\n * module.exports = boundaries(__dirname, { apps: \"private\" });\n * ```\n */\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join, posix } from \"node:path\";\n\n/** A rule of dependency-cruiser (the `forbidden` list). The package does not depend on the types of dependency-cruiser. */\nexport interface Rule {\n name: string;\n severity: \"error\" | \"warn\" | \"info\" | \"ignore\";\n comment?: string;\n from: Record<string, unknown>;\n to: Record<string, unknown>;\n}\n\n/** A dependency-cruiser configuration. */\nexport interface Config {\n forbidden: Rule[];\n options: Record<string, unknown>;\n}\n\n/** A package of the workspace. */\nexport interface WorkspacePackage {\n /** The name in package.json. */\n name: string;\n /** The folder, relative to the root, with \"/\". */\n dir: string;\n private: boolean;\n /** RegExp sources of the files that other packages can import. */\n entries: string[];\n}\n\nexport interface BoundaryOptions {\n /**\n * Globs of the package folders, for example `[\"packages/*\"]`. The default is the `packages` list of\n * pnpm-workspace.yaml, or `[\"packages/*\"]` when the file does not exist.\n */\n packages?: string[];\n /** The apps: the leaves of the graph, which no other package imports. \"private\" means each private package. */\n apps?: \"private\" | string[];\n /** A text before each comment, for example the decision record of the rules. */\n reference?: string;\n /** More rules, after the rules of the boundaries. */\n forbidden?: Rule[];\n /** More options of dependency-cruiser. They replace the default options with the same key. */\n options?: Record<string, unknown>;\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */\nexport function workspaceGlobs(yaml: string): string[] {\n const globs: string[] = [];\n let inList = false;\n // String operations, not one large RegExp: a RegExp with nested whitespace groups can be slow on some input.\n for (const raw of yaml.split(/\\r?\\n/)) {\n const hash = raw.indexOf(\" #\");\n const line = (hash === -1 ? raw : raw.slice(0, hash)).trimEnd();\n const trimmed = line.trimStart();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) continue;\n if (/^packages\\s*:/.test(line)) {\n inList = true;\n continue;\n }\n if (!inList) continue;\n if (trimmed === line) break;\n if (!trimmed.startsWith(\"-\")) continue;\n const item = trimmed.slice(1).trim().replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n if (item) globs.push(item);\n }\n return globs;\n}\n\nfunction isDir(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\n/** The folders that a glob of pnpm-workspace.yaml gives: \"a/b\", \"a/*\" and \"a/**\". */\nfunction expand(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\");\n const star = clean.indexOf(\"*\");\n if (star === -1) return isDir(join(root, clean)) ? [clean] : [];\n const base = clean.slice(0, star).replace(/\\/$/, \"\");\n const recursive = clean.slice(star).startsWith(\"**\");\n const found: string[] = [];\n const walk = (dir: string, depth: number): void => {\n let entries;\n try {\n entries = readdirSync(join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const child = dir === \"\" ? entry.name : `${dir}/${entry.name}`;\n found.push(child);\n if (recursive && depth < 6) walk(child, depth + 1);\n }\n };\n walk(base, 0);\n return found;\n}\n\n/** The leaf strings of an `exports` value, with their subpath keys. */\nfunction exportTargets(value: unknown, out: string[] = []): string[] {\n if (typeof value === \"string\") out.push(value);\n else if (Array.isArray(value)) for (const item of value) exportTargets(item, out);\n else if (value && typeof value === \"object\") for (const item of Object.values(value)) exportTargets(item, out);\n return out;\n}\n\n/**\n * The RegExp source of an entry target of a package. The extension can change, because\n * dependency-cruiser resolves \"./x.js\" to the source file x.ts, and \"*\" of a subpath pattern matches\n * each path.\n */\nexport function entryPattern(dir: string, target: string): string {\n const path = posix.normalize(posix.join(dir, target.replace(/^\\.\\//, \"\")));\n const stem = path.replace(/\\.d\\.[cm]?ts$|\\.[cm]?[jt]sx?$/, \"\");\n const source = stem.split(\"*\").map(escape).join(\".*\");\n // A flat list, because dependency-cruiser refuses a RegExp with nested quantifiers (safe-regex).\n return `^${source}(${EXTENSIONS})?$`;\n}\n\nconst EXTENSIONS = [\".js\", \".mjs\", \".cjs\", \".jsx\", \".ts\", \".mts\", \".cts\", \".tsx\", \".d.ts\", \".d.mts\", \".d.cts\"].map(escape).join(\"|\");\n\n/** The entries of a package.json: the files that other packages can import. */\nexport function packageEntries(dir: string, manifest: Record<string, unknown>): string[] {\n const targets = exportTargets(manifest[\"exports\"]);\n for (const field of [\"main\", \"module\", \"types\", \"typings\"]) {\n const value = manifest[field];\n if (typeof value === \"string\") targets.push(value);\n }\n if (typeof manifest[\"bin\"] === \"string\") targets.push(manifest[\"bin\"]);\n else if (manifest[\"bin\"] && typeof manifest[\"bin\"] === \"object\") targets.push(...exportTargets(manifest[\"bin\"]));\n // With no entry field, Node resolves the package to index.js.\n if (targets.length === 0 && manifest[\"exports\"] === undefined) targets.push(\"./index.js\");\n return [...new Set(targets.filter((t) => !t.endsWith(\".json\") || t === \"./package.json\").map((t) => entryPattern(dir, t)))];\n}\n\n/** The packages of the workspace in the folder `root`. */\nexport function workspacePackages(root: string, globs?: string[]): WorkspacePackage[] {\n let list = globs;\n if (!list) {\n try {\n list = workspaceGlobs(readFileSync(join(root, \"pnpm-workspace.yaml\"), \"utf8\"));\n } catch {\n list = [];\n }\n if (list.length === 0) list = [\"packages/*\"];\n }\n const excluded = list.filter((g) => g.startsWith(\"!\")).flatMap((g) => expand(root, g.slice(1)));\n const dirs = [...new Set(list.filter((g) => !g.startsWith(\"!\")).flatMap((g) => expand(root, g)))].filter((d) => !excluded.includes(d));\n const found: WorkspacePackage[] = [];\n for (const dir of dirs.sort()) {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(readFileSync(join(root, dir, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n continue;\n }\n if (typeof manifest[\"name\"] !== \"string\") continue;\n found.push({ name: manifest[\"name\"], dir, private: manifest[\"private\"] === true, entries: packageEntries(dir, manifest) });\n }\n return found;\n}\n\n/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */\nexport function boundaryRules(packages: WorkspacePackage[], opts: Pick<BoundaryOptions, \"apps\" | \"reference\"> = {}): Rule[] {\n const why = (text: string): string => (opts.reference ? `${opts.reference} ${text}` : text);\n const anyPackage = packages.map((p) => `^${escape(p.dir)}/`);\n const rules: Rule[] = [];\n for (const pkg of packages) {\n const own = `^${escape(pkg.dir)}/`;\n const others = anyPackage.filter((path) => path !== own);\n if (others.length > 0) {\n rules.push({\n name: `relative-import-out-of-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(`A relative import leaves the package ${pkg.name}. Import the other package by its name, through an entry of its package.json.`),\n from: { path: own },\n to: { path: others, pathNot: own, dependencyTypes: [\"local\"] },\n });\n }\n rules.push({\n name: `deep-import-into-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(\n `An import reaches into the folder of ${pkg.name} at a file that is not an entry of its package.json (exports, main, module, types or bin). Import an entry, or add the file to the exports of ${pkg.name}.`,\n ),\n from: { pathNot: own },\n to: pkg.entries.length > 0 ? { path: own, pathNot: pkg.entries } : { path: own },\n });\n }\n const names = packages.map((p) => escape(p.name));\n if (names.length > 0) {\n rules.push({\n name: \"not-a-declared-export\",\n severity: \"error\",\n comment: why(\"An import of a package of this workspace does not resolve. The path is not an entry of its exports, or the package is not built.\"),\n from: {},\n to: { path: `^(${names.join(\"|\")})(/|$)`, couldNotResolve: true },\n });\n }\n const apps =\n opts.apps === \"private\" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));\n for (const app of apps) {\n rules.push({\n name: `import-of-the-app-${slug(app.name)}`,\n severity: \"error\",\n comment: why(`A package imports the app ${app.name}. An app is a leaf: no other package imports it. Move the shared code to a library package.`),\n from: { pathNot: `^${escape(app.dir)}/` },\n to: { path: `^${escape(app.dir)}/` },\n });\n }\n return rules;\n}\n\nconst slug = (name: string): string => name.replace(/^@/, \"\").replace(/[^A-Za-z0-9]+/g, \"-\");\n\n/**\n * The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript\n * compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads\n * TypeScript with swc when @swc/core is installed. Else it reads only JavaScript (acorn): that is\n * enough for a check of built JavaScript.\n */\nexport function parserOptions(root?: string): Record<string, unknown> {\n if (!root) return {};\n const require = createRequire(join(root, \"package.json\"));\n try {\n const { version } = require(\"typescript/package.json\") as { version: string };\n // A type-only import is a boundary too. This option needs the TypeScript compiler.\n if (Number(version.split(\".\")[0]) < 7) return { tsPreCompilationDeps: true };\n } catch {\n // No TypeScript in the repository\n }\n // @swc/core from the repository, or next to this package (a peer dependency)\n for (const from of [require, createRequire(import.meta.url)]) {\n try {\n from.resolve(\"@swc/core\");\n return { parser: \"swc\" };\n } catch {\n // Not there\n }\n }\n return {};\n}\n\n/**\n * The default options: the source of the packages, with type-only imports, resolved as Node resolves\n * them. There is no `includeOnly`, because it also removes the imports that do not resolve, and the\n * rule not-a-declared-export needs them. The \"types\" condition is not used: it resolves to a\n * declaration file, and the analysis excludes declaration files, so a deep import does not show.\n */\nexport function defaultOptions(root?: string): Record<string, unknown> {\n return {\n ...parserOptions(root),\n exclude: {\n path: [\"(^|/)node_modules/\", \"\\\\.(test|spec|e2e)\\\\.[cm]?[jt]sx?$\", \"\\\\.d\\\\.[cm]?ts$\", \"/(test|tests|e2e|__tests__|fixtures)/\"],\n },\n doNotFollow: { path: [\"(^|/)node_modules/\"] },\n enhancedResolveOptions: {\n exportsFields: [\"exports\"],\n conditionNames: [\"import\", \"require\", \"node\", \"default\"],\n mainFields: [\"module\", \"main\"],\n },\n skipAnalysisNotInRules: true,\n };\n}\n\n/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */\nexport function boundaries(root: string, opts: BoundaryOptions = {}): Config {\n const packages = workspacePackages(root, opts.packages);\n const options = { ...defaultOptions(root), ...opts.options };\n return {\n forbidden: [...boundaryRules(packages, opts), ...(opts.forbidden ?? [])],\n options,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0DA,MAAM,UAAU,SAAyB,KAAK,QAAQ,uBAAuB,MAAM;;AAGnF,SAAgB,eAAe,MAAwB;CACrD,MAAM,QAAkB,CAAC;CACzB,IAAI,SAAS;CA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CACzB,QAAQ,CAER;CAEF,OAAO,CAAC;AACV;;;;;;;AAQA,SAAgB,eAAe,MAAwC;CACrE,OAAO;EACL,GAAG,cAAc,IAAI;EACrB,SAAS,EACP,MAAM;GAAC;GAAsB;GAAsC;GAAmB;EAAuC,EAC/H;EACA,aAAa,EAAE,MAAM,CAAC,oBAAoB,EAAE;EAC5C,wBAAwB;GACtB,eAAe,CAAC,SAAS;GACzB,gBAAgB;IAAC;IAAU;IAAW;IAAQ;GAAS;GACvD,YAAY,CAAC,UAAU,MAAM;EAC/B;EACA,wBAAwB;CAC1B;AACF;;AAGA,SAAgB,WAAW,MAAc,OAAwB,CAAC,GAAW;CAC3E,MAAM,WAAW,kBAAkB,MAAM,KAAK,QAAQ;CACtD,MAAM,UAAU;EAAE,GAAG,eAAe,IAAI;EAAG,GAAG,KAAK;CAAQ;CAC3D,OAAO;EACL,WAAW,CAAC,GAAG,cAAc,UAAU,IAAI,GAAG,GAAI,KAAK,aAAa,CAAC,CAAE;EACvE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["statSync","join","readdirSync","posix","readFileSync","require","createRequire"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * The import boundaries of a workspace, as a dependency-cruiser configuration. Each package is a\n * unit. Another package imports it only through an entry of its package.json (`exports`, `main`,\n * `module`, `types`, `bin`). A relative path or a deep path into its folder is not an entry.\n *\n * A repository uses it from its `.dependency-cruiser.cjs`:\n *\n * ```js\n * const { boundaries } = require(\"@mark1russell7/boundaries\");\n * module.exports = boundaries(__dirname, { apps: \"private\" });\n * ```\n */\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join, posix } from \"node:path\";\n\n/** A rule of dependency-cruiser (the `forbidden` list). The package does not depend on the types of dependency-cruiser. */\nexport interface Rule {\n name: string;\n severity: \"error\" | \"warn\" | \"info\" | \"ignore\";\n comment?: string;\n from: Record<string, unknown>;\n to: Record<string, unknown>;\n}\n\n/** A dependency-cruiser configuration. */\nexport interface Config {\n forbidden: Rule[];\n options: Record<string, unknown>;\n}\n\n/** A package of the workspace. */\nexport interface WorkspacePackage {\n /** The name in package.json. */\n name: string;\n /** The folder, relative to the root, with \"/\". */\n dir: string;\n private: boolean;\n /** RegExp sources of the files that other packages can import. */\n entries: string[];\n /** The names of the dependencies in package.json: dependencies, devDependencies, peerDependencies and optionalDependencies. */\n dependencies?: string[];\n}\n\n/**\n * The scopes of the rule unknown-workspace-package. A list replaces the scopes of the workspace\n * packages. `add` and `remove` change that list. An empty list turns off the rule.\n */\nexport type ScopeOptions = string[] | { add?: string[]; remove?: string[] };\n\nexport interface BoundaryOptions {\n /**\n * Globs of the package folders, for example `[\"packages/*\"]`. The default is the `packages` list of\n * pnpm-workspace.yaml, or `[\"packages/*\"]` when the file does not exist.\n */\n packages?: string[];\n /** The apps: the leaves of the graph, which no other package imports. \"private\" means each private package. */\n apps?: \"private\" | string[];\n /** A text before each comment, for example the decision record of the rules. The comments of `forbidden` get it too. */\n reference?: string;\n /**\n * The scopes (for example \"@x\") in which an import that does not resolve must name a workspace\n * package or a declared dependency. The default is the scopes of the workspace package names.\n */\n scopes?: ScopeOptions;\n /**\n * The build folders of each package, for example `[\"dist\", \"build\"]` (the default). The analysis\n * does not follow the imports of their files, and it does not start from them.\n */\n buildFolders?: string[];\n /** More rules, after the rules of the boundaries. */\n forbidden?: Rule[];\n /** More options of dependency-cruiser. They replace the default options with the same key. */\n options?: Record<string, unknown>;\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The default build folders of a package. */\nconst BUILD_FOLDERS = [\"dist\", \"build\"];\n\nconst DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"];\n\n/** The names of the dependencies of a package.json, from each dependency field. */\nexport function declaredDependencies(manifest: Record<string, unknown>): string[] {\n const names = new Set<string>();\n for (const field of DEPENDENCY_FIELDS) {\n const value = manifest[field];\n if (value && typeof value === \"object\" && !Array.isArray(value)) for (const name of Object.keys(value)) names.add(name);\n }\n return [...names].sort();\n}\n\n/** The scopes of the package names, for example \"@x\" for \"@x/a\", changed by the option `scopes`. A name with no scope gives no scope. */\nexport function workspaceScopes(packages: Pick<WorkspacePackage, \"name\">[], opts: ScopeOptions = {}): string[] {\n const normal = (scope: string): string => (scope.startsWith(\"@\") ? scope : `@${scope}`).replace(/\\/$/, \"\");\n if (Array.isArray(opts)) return [...new Set(opts.map(normal))].sort();\n const scopes = new Set(packages.filter((p) => p.name.startsWith(\"@\") && p.name.includes(\"/\")).map((p) => p.name.slice(0, p.name.indexOf(\"/\"))));\n for (const scope of opts.add ?? []) scopes.add(normal(scope));\n for (const scope of opts.remove ?? []) scopes.delete(normal(scope));\n return [...scopes].sort();\n}\n\n/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */\nexport function workspaceGlobs(yaml: string): string[] {\n const globs: string[] = [];\n let inList = false;\n // String operations, not one large RegExp: a RegExp with nested whitespace groups can be slow on some input.\n for (const raw of yaml.split(/\\r?\\n/)) {\n const hash = raw.indexOf(\" #\");\n const line = (hash === -1 ? raw : raw.slice(0, hash)).trimEnd();\n const trimmed = line.trimStart();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) continue;\n if (/^packages\\s*:/.test(line)) {\n inList = true;\n continue;\n }\n if (!inList) continue;\n if (trimmed === line) break;\n if (!trimmed.startsWith(\"-\")) continue;\n const item = trimmed.slice(1).trim().replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n if (item) globs.push(item);\n }\n return globs;\n}\n\nfunction isDir(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\n/** The folders that a glob of pnpm-workspace.yaml gives: \"a/b\", \"a/*\" and \"a/**\". */\nfunction expand(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\");\n const star = clean.indexOf(\"*\");\n if (star === -1) return isDir(join(root, clean)) ? [clean] : [];\n const base = clean.slice(0, star).replace(/\\/$/, \"\");\n const recursive = clean.slice(star).startsWith(\"**\");\n const found: string[] = [];\n const walk = (dir: string, depth: number): void => {\n let entries;\n try {\n entries = readdirSync(join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const child = dir === \"\" ? entry.name : `${dir}/${entry.name}`;\n found.push(child);\n if (recursive && depth < 6) walk(child, depth + 1);\n }\n };\n walk(base, 0);\n return found;\n}\n\n/** The leaf strings of an `exports` value, with their subpath keys. */\nfunction exportTargets(value: unknown, out: string[] = []): string[] {\n if (typeof value === \"string\") out.push(value);\n else if (Array.isArray(value)) for (const item of value) exportTargets(item, out);\n else if (value && typeof value === \"object\") for (const item of Object.values(value)) exportTargets(item, out);\n return out;\n}\n\n/**\n * The RegExp source of an entry target of a package. The extension can change, because\n * dependency-cruiser resolves \"./x.js\" to the source file x.ts, and \"*\" of a subpath pattern matches\n * each path.\n */\nexport function entryPattern(dir: string, target: string): string {\n const path = posix.normalize(posix.join(dir, target.replace(/^\\.\\//, \"\")));\n const stem = path.replace(/\\.d\\.[cm]?ts$|\\.[cm]?[jt]sx?$/, \"\");\n const source = stem.split(\"*\").map(escape).join(\".*\");\n // A flat list, because dependency-cruiser refuses a RegExp with nested quantifiers (safe-regex).\n return `^${source}(${EXTENSIONS})?$`;\n}\n\nconst EXTENSIONS = [\".js\", \".mjs\", \".cjs\", \".jsx\", \".ts\", \".mts\", \".cts\", \".tsx\", \".d.ts\", \".d.mts\", \".d.cts\"].map(escape).join(\"|\");\n\n/** The entries of a package.json: the files that other packages can import. */\nexport function packageEntries(dir: string, manifest: Record<string, unknown>): string[] {\n const targets = exportTargets(manifest[\"exports\"]);\n for (const field of [\"main\", \"module\", \"types\", \"typings\"]) {\n const value = manifest[field];\n if (typeof value === \"string\") targets.push(value);\n }\n if (typeof manifest[\"bin\"] === \"string\") targets.push(manifest[\"bin\"]);\n else if (manifest[\"bin\"] && typeof manifest[\"bin\"] === \"object\") targets.push(...exportTargets(manifest[\"bin\"]));\n // With no entry field, Node resolves the package to index.js.\n if (targets.length === 0 && manifest[\"exports\"] === undefined) targets.push(\"./index.js\");\n return [...new Set(targets.filter((t) => !t.endsWith(\".json\") || t === \"./package.json\").map((t) => entryPattern(dir, t)))];\n}\n\n/** The packages of the workspace in the folder `root`. */\nexport function workspacePackages(root: string, globs?: string[]): WorkspacePackage[] {\n let list = globs;\n if (!list) {\n try {\n list = workspaceGlobs(readFileSync(join(root, \"pnpm-workspace.yaml\"), \"utf8\"));\n } catch {\n list = [];\n }\n if (list.length === 0) list = [\"packages/*\"];\n }\n const excluded = list.filter((g) => g.startsWith(\"!\")).flatMap((g) => expand(root, g.slice(1)));\n const dirs = [...new Set(list.filter((g) => !g.startsWith(\"!\")).flatMap((g) => expand(root, g)))].filter((d) => !excluded.includes(d));\n const found: WorkspacePackage[] = [];\n for (const dir of dirs.sort()) {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(readFileSync(join(root, dir, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n continue;\n }\n if (typeof manifest[\"name\"] !== \"string\") continue;\n found.push({\n name: manifest[\"name\"],\n dir,\n private: manifest[\"private\"] === true,\n entries: packageEntries(dir, manifest),\n dependencies: declaredDependencies(manifest),\n });\n }\n return found;\n}\n\n/** The options of `boundaryRules()`. */\nexport interface RuleOptions extends Pick<BoundaryOptions, \"apps\" | \"reference\" | \"scopes\"> {\n /** More declared dependencies, for example the dependencies of the root package.json. */\n dependencies?: string[];\n}\n\n/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */\nexport function boundaryRules(packages: WorkspacePackage[], opts: RuleOptions = {}): Rule[] {\n const why = (text: string): string => (opts.reference ? `${opts.reference} ${text}` : text);\n const anyPackage = packages.map((p) => `^${escape(p.dir)}/`);\n const rules: Rule[] = [];\n for (const pkg of packages) {\n const own = `^${escape(pkg.dir)}/`;\n const others = anyPackage.filter((path) => path !== own);\n if (others.length > 0) {\n rules.push({\n name: `relative-import-out-of-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(`A relative import leaves the package ${pkg.name}. Import the other package by its name, through an entry of its package.json.`),\n from: { path: own },\n to: { path: others, pathNot: own, dependencyTypes: [\"local\"] },\n });\n }\n rules.push({\n name: `deep-import-into-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(\n `An import reaches into the folder of ${pkg.name} at a file that is not an entry of its package.json (exports, main, module, types or bin). Import an entry, or add the file to the exports of ${pkg.name}.`,\n ),\n from: { pathNot: own },\n to: pkg.entries.length > 0 ? { path: own, pathNot: pkg.entries } : { path: own },\n });\n }\n const names = packages.map((p) => escape(p.name));\n if (names.length > 0) {\n rules.push({\n name: \"not-a-declared-export\",\n severity: \"error\",\n comment: why(\"An import of a package of this workspace does not resolve. The path is not an entry of its exports, or the package is not built.\"),\n from: {},\n to: { path: `^(${names.join(\"|\")})(/|$)`, couldNotResolve: true },\n });\n }\n const scopes = workspaceScopes(packages, opts.scopes);\n if (scopes.length > 0) {\n const inScope = (name: string): boolean => scopes.some((scope) => name.startsWith(`${scope}/`));\n const declared = [...packages.flatMap((p) => p.dependencies ?? []), ...(opts.dependencies ?? [])];\n const known = [...new Set([...packages.map((p) => p.name), ...declared].filter(inScope))].sort().map(escape);\n rules.push({\n name: \"unknown-workspace-package\",\n severity: \"error\",\n comment: why(\n `An import names a package of the scope ${scopes.join(\", \")}, but the import does not resolve. The name is not a package of this workspace and not a declared dependency. Correct the name, or add the package.`,\n ),\n from: {},\n to: { path: `^(${scopes.map(escape).join(\"|\")})/`, ...(known.length > 0 ? { pathNot: `^(${known.join(\"|\")})(/|$)` } : {}), couldNotResolve: true },\n });\n }\n const apps =\n opts.apps === \"private\" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));\n for (const app of apps) {\n rules.push({\n name: `import-of-the-app-${slug(app.name)}`,\n severity: \"error\",\n comment: why(`A package imports the app ${app.name}. An app is a leaf: no other package imports it. Move the shared code to a library package.`),\n from: { pathNot: `^${escape(app.dir)}/` },\n to: { path: `^${escape(app.dir)}/` },\n });\n }\n return rules;\n}\n\nconst slug = (name: string): string => name.replace(/^@/, \"\").replace(/[^A-Za-z0-9]+/g, \"-\");\n\n/**\n * The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript\n * compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads\n * TypeScript with swc when @swc/core is installed. Else it reads only JavaScript (acorn): that is\n * enough for a check of built JavaScript.\n */\nexport function parserOptions(root?: string): Record<string, unknown> {\n if (!root) return {};\n const require = createRequire(join(root, \"package.json\"));\n try {\n const { version } = require(\"typescript/package.json\") as { version: string };\n // A type-only import is a boundary too. This option needs the TypeScript compiler.\n if (Number(version.split(\".\")[0]) < 7) return { tsPreCompilationDeps: true };\n } catch {\n // No TypeScript in the repository\n }\n // @swc/core from the repository, or next to this package (a peer dependency)\n for (const from of [require, createRequire(import.meta.url)]) {\n try {\n from.resolve(\"@swc/core\");\n return { parser: \"swc\" };\n } catch {\n // Not there\n }\n }\n return {};\n}\n\n/** The options of `defaultOptions()`. */\nexport interface DefaultOptionsInput {\n /** The packages of the workspace. The default is `workspacePackages(root)`. */\n packages?: WorkspacePackage[];\n /** The build folders of each package. The default is `[\"dist\", \"build\"]`. */\n buildFolders?: string[];\n}\n\n/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */\nexport function doNotFollowPaths(packages: Pick<WorkspacePackage, \"dir\">[], buildFolders: string[] = BUILD_FOLDERS): string[] {\n const paths = [\"(^|/)node_modules/\"];\n const dirs = packages.map((p) => p.dir).filter((dir) => dir !== \"\" && dir !== \".\");\n const folders = buildFolders.map((folder) => folder.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\")).filter((folder) => folder !== \"\");\n if (dirs.length > 0 && folders.length > 0) paths.push(`^(${dirs.map(escape).join(\"|\")})/(${folders.map(escape).join(\"|\")})/`);\n return paths;\n}\n\n/**\n * The default options: the source of the packages, with type-only imports, resolved as Node resolves\n * an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,\n * and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the\n * build folders of the packages: an import of a package stops at its entry. The \"types\" condition is\n * not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep\n * import does not show. The `require` condition is not used: an ESM import does not resolve to an\n * entry that is only for `require`.\n */\nexport function defaultOptions(root?: string, input: DefaultOptionsInput = {}): Record<string, unknown> {\n const packages = input.packages ?? (root ? workspacePackages(root) : []);\n return {\n ...parserOptions(root),\n exclude: {\n path: [\"(^|/)node_modules/\", \"\\\\.(test|spec|e2e)\\\\.[cm]?[jt]sx?$\", \"\\\\.d\\\\.[cm]?ts$\", \"/(test|tests|e2e|__tests__|fixtures)/\"],\n },\n doNotFollow: { path: doNotFollowPaths(packages, input.buildFolders) },\n enhancedResolveOptions: {\n exportsFields: [\"exports\"],\n conditionNames: [\"import\", \"node\", \"default\"],\n mainFields: [\"module\", \"main\"],\n },\n skipAnalysisNotInRules: true,\n };\n}\n\n/** A rule with the reference before its comment, when the comment does not start with it. */\nfunction withReference(rule: Rule, reference?: string): Rule {\n if (!reference || rule.comment?.startsWith(reference)) return rule;\n return { ...rule, comment: rule.comment ? `${reference} ${rule.comment}` : reference };\n}\n\n/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */\nexport function boundaries(root: string, opts: BoundaryOptions = {}): Config {\n const packages = workspacePackages(root, opts.packages);\n let rootManifest: Record<string, unknown> = {};\n try {\n rootManifest = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n // No package.json at the root\n }\n const options = { ...defaultOptions(root, { packages, ...(opts.buildFolders ? { buildFolders: opts.buildFolders } : {}) }), ...opts.options };\n const rules = boundaryRules(packages, { ...opts, dependencies: declaredDependencies(rootManifest) });\n return {\n forbidden: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,UAAU;GAAE,GAAG;GAAM,cAAc,qBAAqB,YAAY;EAAE,CAE7E,GAAG,IAAI,KAAK,aAAa,CAAC,EAAA,CAAG,KAAK,SAAS,cAAc,MAAM,KAAK,SAAS,CAAC,CAAC;EAClG;CACF;AACF"}
|
package/build/index.d.cts
CHANGED
|
@@ -20,7 +20,17 @@ export interface WorkspacePackage {
|
|
|
20
20
|
private: boolean;
|
|
21
21
|
/** RegExp sources of the files that other packages can import. */
|
|
22
22
|
entries: string[];
|
|
23
|
+
/** The names of the dependencies in package.json: dependencies, devDependencies, peerDependencies and optionalDependencies. */
|
|
24
|
+
dependencies?: string[];
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The scopes of the rule unknown-workspace-package. A list replaces the scopes of the workspace
|
|
28
|
+
* packages. `add` and `remove` change that list. An empty list turns off the rule.
|
|
29
|
+
*/
|
|
30
|
+
export type ScopeOptions = string[] | {
|
|
31
|
+
add?: string[];
|
|
32
|
+
remove?: string[];
|
|
33
|
+
};
|
|
24
34
|
export interface BoundaryOptions {
|
|
25
35
|
/**
|
|
26
36
|
* Globs of the package folders, for example `["packages/*"]`. The default is the `packages` list of
|
|
@@ -29,13 +39,27 @@ export interface BoundaryOptions {
|
|
|
29
39
|
packages?: string[];
|
|
30
40
|
/** The apps: the leaves of the graph, which no other package imports. "private" means each private package. */
|
|
31
41
|
apps?: "private" | string[];
|
|
32
|
-
/** A text before each comment, for example the decision record of the rules. */
|
|
42
|
+
/** A text before each comment, for example the decision record of the rules. The comments of `forbidden` get it too. */
|
|
33
43
|
reference?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The scopes (for example "@x") in which an import that does not resolve must name a workspace
|
|
46
|
+
* package or a declared dependency. The default is the scopes of the workspace package names.
|
|
47
|
+
*/
|
|
48
|
+
scopes?: ScopeOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The build folders of each package, for example `["dist", "build"]` (the default). The analysis
|
|
51
|
+
* does not follow the imports of their files, and it does not start from them.
|
|
52
|
+
*/
|
|
53
|
+
buildFolders?: string[];
|
|
34
54
|
/** More rules, after the rules of the boundaries. */
|
|
35
55
|
forbidden?: Rule[];
|
|
36
56
|
/** More options of dependency-cruiser. They replace the default options with the same key. */
|
|
37
57
|
options?: Record<string, unknown>;
|
|
38
58
|
}
|
|
59
|
+
/** The names of the dependencies of a package.json, from each dependency field. */
|
|
60
|
+
export declare function declaredDependencies(manifest: Record<string, unknown>): string[];
|
|
61
|
+
/** The scopes of the package names, for example "@x" for "@x/a", changed by the option `scopes`. A name with no scope gives no scope. */
|
|
62
|
+
export declare function workspaceScopes(packages: Pick<WorkspacePackage, "name">[], opts?: ScopeOptions): string[];
|
|
39
63
|
/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */
|
|
40
64
|
export declare function workspaceGlobs(yaml: string): string[];
|
|
41
65
|
/**
|
|
@@ -48,8 +72,13 @@ export declare function entryPattern(dir: string, target: string): string;
|
|
|
48
72
|
export declare function packageEntries(dir: string, manifest: Record<string, unknown>): string[];
|
|
49
73
|
/** The packages of the workspace in the folder `root`. */
|
|
50
74
|
export declare function workspacePackages(root: string, globs?: string[]): WorkspacePackage[];
|
|
75
|
+
/** The options of `boundaryRules()`. */
|
|
76
|
+
export interface RuleOptions extends Pick<BoundaryOptions, "apps" | "reference" | "scopes"> {
|
|
77
|
+
/** More declared dependencies, for example the dependencies of the root package.json. */
|
|
78
|
+
dependencies?: string[];
|
|
79
|
+
}
|
|
51
80
|
/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */
|
|
52
|
-
export declare function boundaryRules(packages: WorkspacePackage[], opts?:
|
|
81
|
+
export declare function boundaryRules(packages: WorkspacePackage[], opts?: RuleOptions): Rule[];
|
|
53
82
|
/**
|
|
54
83
|
* The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript
|
|
55
84
|
* compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads
|
|
@@ -57,13 +86,25 @@ export declare function boundaryRules(packages: WorkspacePackage[], opts?: Pick<
|
|
|
57
86
|
* enough for a check of built JavaScript.
|
|
58
87
|
*/
|
|
59
88
|
export declare function parserOptions(root?: string): Record<string, unknown>;
|
|
89
|
+
/** The options of `defaultOptions()`. */
|
|
90
|
+
export interface DefaultOptionsInput {
|
|
91
|
+
/** The packages of the workspace. The default is `workspacePackages(root)`. */
|
|
92
|
+
packages?: WorkspacePackage[];
|
|
93
|
+
/** The build folders of each package. The default is `["dist", "build"]`. */
|
|
94
|
+
buildFolders?: string[];
|
|
95
|
+
}
|
|
96
|
+
/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */
|
|
97
|
+
export declare function doNotFollowPaths(packages: Pick<WorkspacePackage, "dir">[], buildFolders?: string[]): string[];
|
|
60
98
|
/**
|
|
61
99
|
* The default options: the source of the packages, with type-only imports, resolved as Node resolves
|
|
62
|
-
*
|
|
63
|
-
* rule not-a-declared-export needs them. The
|
|
64
|
-
*
|
|
100
|
+
* an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,
|
|
101
|
+
* and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the
|
|
102
|
+
* build folders of the packages: an import of a package stops at its entry. The "types" condition is
|
|
103
|
+
* not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep
|
|
104
|
+
* import does not show. The `require` condition is not used: an ESM import does not resolve to an
|
|
105
|
+
* entry that is only for `require`.
|
|
65
106
|
*/
|
|
66
|
-
export declare function defaultOptions(root?: string): Record<string, unknown>;
|
|
107
|
+
export declare function defaultOptions(root?: string, input?: DefaultOptionsInput): Record<string, unknown>;
|
|
67
108
|
/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */
|
|
68
109
|
export declare function boundaries(root: string, opts?: BoundaryOptions): Config;
|
|
69
110
|
//# sourceMappingURL=index.d.cts.map
|
package/build/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";iBAiBiB;EACf;EACA;EACA;EACA,MAAM;EACN,IAAI;;;iBAIW;EACf,WAAW;EACX,SAAS;;;iBAIM;;EAEf;;EAEA;EACA;;EAEA;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";iBAiBiB;EACf;EACA;EACA;EACA,MAAM;EACN,IAAI;;;iBAIW;EACf,WAAW;EACX,SAAS;;;iBAIM;;EAEf;;EAEA;EACA;;EAEA;;EAEA;;;;;;YAOU;EAA4B;EAAgB;;iBAEvC;;;;;EAKf;;EAEA;;EAEA;;;;;EAKA,SAAS;;;;;EAKT;;EAEA,YAAY;;EAEZ,UAAU;;;wBAWI,qBAAqB,UAAU;;wBAU/B,gBAAgB,UAAU,KAAK,6BAA6B,OAAM;;wBAUlE,eAAe;;;;;;wBAqEf,aAAa,aAAa;;wBAW1B,eAAe,aAAa,UAAU;;wBActC,kBAAkB,cAAc,mBAAmB;;iBAiClD,oBAAoB,KAAK;;EAExC;;;wBAIc,cAAc,UAAU,oBAAoB,OAAM,cAAmB;;;;;;;wBAyErE,cAAc,gBAAgB;;iBAuB7B;;EAEf,WAAW;;EAEX;;;wBAIc,iBAAiB,UAAU,KAAK,4BAA4B;;;;;;;;;;wBAiB5D,eAAe,eAAe,QAAO,sBAA2B;;wBAwBhE,WAAW,cAAc,OAAM,kBAAuB"}
|
package/build/index.d.ts
CHANGED
|
@@ -20,7 +20,17 @@ export interface WorkspacePackage {
|
|
|
20
20
|
private: boolean;
|
|
21
21
|
/** RegExp sources of the files that other packages can import. */
|
|
22
22
|
entries: string[];
|
|
23
|
+
/** The names of the dependencies in package.json: dependencies, devDependencies, peerDependencies and optionalDependencies. */
|
|
24
|
+
dependencies?: string[];
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The scopes of the rule unknown-workspace-package. A list replaces the scopes of the workspace
|
|
28
|
+
* packages. `add` and `remove` change that list. An empty list turns off the rule.
|
|
29
|
+
*/
|
|
30
|
+
export type ScopeOptions = string[] | {
|
|
31
|
+
add?: string[];
|
|
32
|
+
remove?: string[];
|
|
33
|
+
};
|
|
24
34
|
export interface BoundaryOptions {
|
|
25
35
|
/**
|
|
26
36
|
* Globs of the package folders, for example `["packages/*"]`. The default is the `packages` list of
|
|
@@ -29,13 +39,27 @@ export interface BoundaryOptions {
|
|
|
29
39
|
packages?: string[];
|
|
30
40
|
/** The apps: the leaves of the graph, which no other package imports. "private" means each private package. */
|
|
31
41
|
apps?: "private" | string[];
|
|
32
|
-
/** A text before each comment, for example the decision record of the rules. */
|
|
42
|
+
/** A text before each comment, for example the decision record of the rules. The comments of `forbidden` get it too. */
|
|
33
43
|
reference?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The scopes (for example "@x") in which an import that does not resolve must name a workspace
|
|
46
|
+
* package or a declared dependency. The default is the scopes of the workspace package names.
|
|
47
|
+
*/
|
|
48
|
+
scopes?: ScopeOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The build folders of each package, for example `["dist", "build"]` (the default). The analysis
|
|
51
|
+
* does not follow the imports of their files, and it does not start from them.
|
|
52
|
+
*/
|
|
53
|
+
buildFolders?: string[];
|
|
34
54
|
/** More rules, after the rules of the boundaries. */
|
|
35
55
|
forbidden?: Rule[];
|
|
36
56
|
/** More options of dependency-cruiser. They replace the default options with the same key. */
|
|
37
57
|
options?: Record<string, unknown>;
|
|
38
58
|
}
|
|
59
|
+
/** The names of the dependencies of a package.json, from each dependency field. */
|
|
60
|
+
export declare function declaredDependencies(manifest: Record<string, unknown>): string[];
|
|
61
|
+
/** The scopes of the package names, for example "@x" for "@x/a", changed by the option `scopes`. A name with no scope gives no scope. */
|
|
62
|
+
export declare function workspaceScopes(packages: Pick<WorkspacePackage, "name">[], opts?: ScopeOptions): string[];
|
|
39
63
|
/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */
|
|
40
64
|
export declare function workspaceGlobs(yaml: string): string[];
|
|
41
65
|
/**
|
|
@@ -48,8 +72,13 @@ export declare function entryPattern(dir: string, target: string): string;
|
|
|
48
72
|
export declare function packageEntries(dir: string, manifest: Record<string, unknown>): string[];
|
|
49
73
|
/** The packages of the workspace in the folder `root`. */
|
|
50
74
|
export declare function workspacePackages(root: string, globs?: string[]): WorkspacePackage[];
|
|
75
|
+
/** The options of `boundaryRules()`. */
|
|
76
|
+
export interface RuleOptions extends Pick<BoundaryOptions, "apps" | "reference" | "scopes"> {
|
|
77
|
+
/** More declared dependencies, for example the dependencies of the root package.json. */
|
|
78
|
+
dependencies?: string[];
|
|
79
|
+
}
|
|
51
80
|
/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */
|
|
52
|
-
export declare function boundaryRules(packages: WorkspacePackage[], opts?:
|
|
81
|
+
export declare function boundaryRules(packages: WorkspacePackage[], opts?: RuleOptions): Rule[];
|
|
53
82
|
/**
|
|
54
83
|
* The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript
|
|
55
84
|
* compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads
|
|
@@ -57,13 +86,25 @@ export declare function boundaryRules(packages: WorkspacePackage[], opts?: Pick<
|
|
|
57
86
|
* enough for a check of built JavaScript.
|
|
58
87
|
*/
|
|
59
88
|
export declare function parserOptions(root?: string): Record<string, unknown>;
|
|
89
|
+
/** The options of `defaultOptions()`. */
|
|
90
|
+
export interface DefaultOptionsInput {
|
|
91
|
+
/** The packages of the workspace. The default is `workspacePackages(root)`. */
|
|
92
|
+
packages?: WorkspacePackage[];
|
|
93
|
+
/** The build folders of each package. The default is `["dist", "build"]`. */
|
|
94
|
+
buildFolders?: string[];
|
|
95
|
+
}
|
|
96
|
+
/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */
|
|
97
|
+
export declare function doNotFollowPaths(packages: Pick<WorkspacePackage, "dir">[], buildFolders?: string[]): string[];
|
|
60
98
|
/**
|
|
61
99
|
* The default options: the source of the packages, with type-only imports, resolved as Node resolves
|
|
62
|
-
*
|
|
63
|
-
* rule not-a-declared-export needs them. The
|
|
64
|
-
*
|
|
100
|
+
* an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,
|
|
101
|
+
* and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the
|
|
102
|
+
* build folders of the packages: an import of a package stops at its entry. The "types" condition is
|
|
103
|
+
* not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep
|
|
104
|
+
* import does not show. The `require` condition is not used: an ESM import does not resolve to an
|
|
105
|
+
* entry that is only for `require`.
|
|
65
106
|
*/
|
|
66
|
-
export declare function defaultOptions(root?: string): Record<string, unknown>;
|
|
107
|
+
export declare function defaultOptions(root?: string, input?: DefaultOptionsInput): Record<string, unknown>;
|
|
67
108
|
/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */
|
|
68
109
|
export declare function boundaries(root: string, opts?: BoundaryOptions): Config;
|
|
69
110
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";iBAiBiB;EACf;EACA;EACA;EACA,MAAM;EACN,IAAI;;;iBAIW;EACf,WAAW;EACX,SAAS;;;iBAIM;;EAEf;;EAEA;EACA;;EAEA;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";iBAiBiB;EACf;EACA;EACA;EACA,MAAM;EACN,IAAI;;;iBAIW;EACf,WAAW;EACX,SAAS;;;iBAIM;;EAEf;;EAEA;EACA;;EAEA;;EAEA;;;;;;YAOU;EAA4B;EAAgB;;iBAEvC;;;;;EAKf;;EAEA;;EAEA;;;;;EAKA,SAAS;;;;;EAKT;;EAEA,YAAY;;EAEZ,UAAU;;;wBAWI,qBAAqB,UAAU;;wBAU/B,gBAAgB,UAAU,KAAK,6BAA6B,OAAM;;wBAUlE,eAAe;;;;;;wBAqEf,aAAa,aAAa;;wBAW1B,eAAe,aAAa,UAAU;;wBActC,kBAAkB,cAAc,mBAAmB;;iBAiClD,oBAAoB,KAAK;;EAExC;;;wBAIc,cAAc,UAAU,oBAAoB,OAAM,cAAmB;;;;;;;wBAyErE,cAAc,gBAAgB;;iBAuB7B;;EAEf,WAAW;;EAEX;;;wBAIc,iBAAiB,UAAU,KAAK,4BAA4B;;;;;;;;;;wBAiB5D,eAAe,eAAe,QAAO,sBAA2B;;wBAwBhE,WAAW,cAAc,OAAM,kBAAuB"}
|
package/build/index.js
CHANGED
|
@@ -15,6 +15,32 @@ import { join, posix } from "node:path";
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
18
|
+
/** The default build folders of a package. */
|
|
19
|
+
const BUILD_FOLDERS = ["dist", "build"];
|
|
20
|
+
const DEPENDENCY_FIELDS = [
|
|
21
|
+
"dependencies",
|
|
22
|
+
"devDependencies",
|
|
23
|
+
"peerDependencies",
|
|
24
|
+
"optionalDependencies"
|
|
25
|
+
];
|
|
26
|
+
/** The names of the dependencies of a package.json, from each dependency field. */
|
|
27
|
+
function declaredDependencies(manifest) {
|
|
28
|
+
const names = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
30
|
+
const value = manifest[field];
|
|
31
|
+
if (value && typeof value === "object" && !Array.isArray(value)) for (const name of Object.keys(value)) names.add(name);
|
|
32
|
+
}
|
|
33
|
+
return [...names].sort();
|
|
34
|
+
}
|
|
35
|
+
/** The scopes of the package names, for example "@x" for "@x/a", changed by the option `scopes`. A name with no scope gives no scope. */
|
|
36
|
+
function workspaceScopes(packages, opts = {}) {
|
|
37
|
+
const normal = (scope) => (scope.startsWith("@") ? scope : `@${scope}`).replace(/\/$/, "");
|
|
38
|
+
if (Array.isArray(opts)) return [...new Set(opts.map(normal))].sort();
|
|
39
|
+
const scopes = new Set(packages.filter((p) => p.name.startsWith("@") && p.name.includes("/")).map((p) => p.name.slice(0, p.name.indexOf("/"))));
|
|
40
|
+
for (const scope of opts.add ?? []) scopes.add(normal(scope));
|
|
41
|
+
for (const scope of opts.remove ?? []) scopes.delete(normal(scope));
|
|
42
|
+
return [...scopes].sort();
|
|
43
|
+
}
|
|
18
44
|
/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */
|
|
19
45
|
function workspaceGlobs(yaml) {
|
|
20
46
|
const globs = [];
|
|
@@ -139,7 +165,8 @@ function workspacePackages(root, globs) {
|
|
|
139
165
|
name: manifest["name"],
|
|
140
166
|
dir,
|
|
141
167
|
private: manifest["private"] === true,
|
|
142
|
-
entries: packageEntries(dir, manifest)
|
|
168
|
+
entries: packageEntries(dir, manifest),
|
|
169
|
+
dependencies: declaredDependencies(manifest)
|
|
143
170
|
});
|
|
144
171
|
}
|
|
145
172
|
return found;
|
|
@@ -185,6 +212,23 @@ function boundaryRules(packages, opts = {}) {
|
|
|
185
212
|
couldNotResolve: true
|
|
186
213
|
}
|
|
187
214
|
});
|
|
215
|
+
const scopes = workspaceScopes(packages, opts.scopes);
|
|
216
|
+
if (scopes.length > 0) {
|
|
217
|
+
const inScope = (name) => scopes.some((scope) => name.startsWith(`${scope}/`));
|
|
218
|
+
const declared = [...packages.flatMap((p) => p.dependencies ?? []), ...opts.dependencies ?? []];
|
|
219
|
+
const known = [...new Set([...packages.map((p) => p.name), ...declared].filter(inScope))].sort().map(escape);
|
|
220
|
+
rules.push({
|
|
221
|
+
name: "unknown-workspace-package",
|
|
222
|
+
severity: "error",
|
|
223
|
+
comment: why(`An import names a package of the scope ${scopes.join(", ")}, but the import does not resolve. The name is not a package of this workspace and not a declared dependency. Correct the name, or add the package.`),
|
|
224
|
+
from: {},
|
|
225
|
+
to: {
|
|
226
|
+
path: `^(${scopes.map(escape).join("|")})/`,
|
|
227
|
+
...known.length > 0 ? { pathNot: `^(${known.join("|")})(/|$)` } : {},
|
|
228
|
+
couldNotResolve: true
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
188
232
|
const apps = opts.apps === "private" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));
|
|
189
233
|
for (const app of apps) rules.push({
|
|
190
234
|
name: `import-of-the-app-${slug(app.name)}`,
|
|
@@ -215,13 +259,25 @@ function parserOptions(root) {
|
|
|
215
259
|
} catch {}
|
|
216
260
|
return {};
|
|
217
261
|
}
|
|
262
|
+
/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */
|
|
263
|
+
function doNotFollowPaths(packages, buildFolders = BUILD_FOLDERS) {
|
|
264
|
+
const paths = ["(^|/)node_modules/"];
|
|
265
|
+
const dirs = packages.map((p) => p.dir).filter((dir) => dir !== "" && dir !== ".");
|
|
266
|
+
const folders = buildFolders.map((folder) => folder.replace(/^\.\//, "").replace(/\/$/, "")).filter((folder) => folder !== "");
|
|
267
|
+
if (dirs.length > 0 && folders.length > 0) paths.push(`^(${dirs.map(escape).join("|")})/(${folders.map(escape).join("|")})/`);
|
|
268
|
+
return paths;
|
|
269
|
+
}
|
|
218
270
|
/**
|
|
219
271
|
* The default options: the source of the packages, with type-only imports, resolved as Node resolves
|
|
220
|
-
*
|
|
221
|
-
* rule not-a-declared-export needs them. The
|
|
222
|
-
*
|
|
272
|
+
* an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,
|
|
273
|
+
* and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the
|
|
274
|
+
* build folders of the packages: an import of a package stops at its entry. The "types" condition is
|
|
275
|
+
* not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep
|
|
276
|
+
* import does not show. The `require` condition is not used: an ESM import does not resolve to an
|
|
277
|
+
* entry that is only for `require`.
|
|
223
278
|
*/
|
|
224
|
-
function defaultOptions(root) {
|
|
279
|
+
function defaultOptions(root, input = {}) {
|
|
280
|
+
const packages = input.packages ?? (root ? workspacePackages(root) : []);
|
|
225
281
|
return {
|
|
226
282
|
...parserOptions(root),
|
|
227
283
|
exclude: { path: [
|
|
@@ -230,12 +286,11 @@ function defaultOptions(root) {
|
|
|
230
286
|
"\\.d\\.[cm]?ts$",
|
|
231
287
|
"/(test|tests|e2e|__tests__|fixtures)/"
|
|
232
288
|
] },
|
|
233
|
-
doNotFollow: { path:
|
|
289
|
+
doNotFollow: { path: doNotFollowPaths(packages, input.buildFolders) },
|
|
234
290
|
enhancedResolveOptions: {
|
|
235
291
|
exportsFields: ["exports"],
|
|
236
292
|
conditionNames: [
|
|
237
293
|
"import",
|
|
238
|
-
"require",
|
|
239
294
|
"node",
|
|
240
295
|
"default"
|
|
241
296
|
],
|
|
@@ -244,18 +299,36 @@ function defaultOptions(root) {
|
|
|
244
299
|
skipAnalysisNotInRules: true
|
|
245
300
|
};
|
|
246
301
|
}
|
|
302
|
+
/** A rule with the reference before its comment, when the comment does not start with it. */
|
|
303
|
+
function withReference(rule, reference) {
|
|
304
|
+
if (!reference || rule.comment?.startsWith(reference)) return rule;
|
|
305
|
+
return {
|
|
306
|
+
...rule,
|
|
307
|
+
comment: rule.comment ? `${reference} ${rule.comment}` : reference
|
|
308
|
+
};
|
|
309
|
+
}
|
|
247
310
|
/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */
|
|
248
311
|
function boundaries(root, opts = {}) {
|
|
249
312
|
const packages = workspacePackages(root, opts.packages);
|
|
313
|
+
let rootManifest = {};
|
|
314
|
+
try {
|
|
315
|
+
rootManifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
316
|
+
} catch {}
|
|
250
317
|
const options = {
|
|
251
|
-
...defaultOptions(root
|
|
318
|
+
...defaultOptions(root, {
|
|
319
|
+
packages,
|
|
320
|
+
...opts.buildFolders ? { buildFolders: opts.buildFolders } : {}
|
|
321
|
+
}),
|
|
252
322
|
...opts.options
|
|
253
323
|
};
|
|
254
324
|
return {
|
|
255
|
-
forbidden: [...boundaryRules(packages,
|
|
325
|
+
forbidden: [...boundaryRules(packages, {
|
|
326
|
+
...opts,
|
|
327
|
+
dependencies: declaredDependencies(rootManifest)
|
|
328
|
+
}), ...(opts.forbidden ?? []).map((rule) => withReference(rule, opts.reference))],
|
|
256
329
|
options
|
|
257
330
|
};
|
|
258
331
|
}
|
|
259
|
-
export { boundaries, boundaryRules, defaultOptions, entryPattern, packageEntries, parserOptions, workspaceGlobs, workspacePackages };
|
|
332
|
+
export { boundaries, boundaryRules, declaredDependencies, defaultOptions, doNotFollowPaths, entryPattern, packageEntries, parserOptions, workspaceGlobs, workspacePackages, workspaceScopes };
|
|
260
333
|
|
|
261
334
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * The import boundaries of a workspace, as a dependency-cruiser configuration. Each package is a\n * unit. Another package imports it only through an entry of its package.json (`exports`, `main`,\n * `module`, `types`, `bin`). A relative path or a deep path into its folder is not an entry.\n *\n * A repository uses it from its `.dependency-cruiser.cjs`:\n *\n * ```js\n * const { boundaries } = require(\"@mark1russell7/boundaries\");\n * module.exports = boundaries(__dirname, { apps: \"private\" });\n * ```\n */\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join, posix } from \"node:path\";\n\n/** A rule of dependency-cruiser (the `forbidden` list). The package does not depend on the types of dependency-cruiser. */\nexport interface Rule {\n name: string;\n severity: \"error\" | \"warn\" | \"info\" | \"ignore\";\n comment?: string;\n from: Record<string, unknown>;\n to: Record<string, unknown>;\n}\n\n/** A dependency-cruiser configuration. */\nexport interface Config {\n forbidden: Rule[];\n options: Record<string, unknown>;\n}\n\n/** A package of the workspace. */\nexport interface WorkspacePackage {\n /** The name in package.json. */\n name: string;\n /** The folder, relative to the root, with \"/\". */\n dir: string;\n private: boolean;\n /** RegExp sources of the files that other packages can import. */\n entries: string[];\n}\n\nexport interface BoundaryOptions {\n /**\n * Globs of the package folders, for example `[\"packages/*\"]`. The default is the `packages` list of\n * pnpm-workspace.yaml, or `[\"packages/*\"]` when the file does not exist.\n */\n packages?: string[];\n /** The apps: the leaves of the graph, which no other package imports. \"private\" means each private package. */\n apps?: \"private\" | string[];\n /** A text before each comment, for example the decision record of the rules. */\n reference?: string;\n /** More rules, after the rules of the boundaries. */\n forbidden?: Rule[];\n /** More options of dependency-cruiser. They replace the default options with the same key. */\n options?: Record<string, unknown>;\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */\nexport function workspaceGlobs(yaml: string): string[] {\n const globs: string[] = [];\n let inList = false;\n // String operations, not one large RegExp: a RegExp with nested whitespace groups can be slow on some input.\n for (const raw of yaml.split(/\\r?\\n/)) {\n const hash = raw.indexOf(\" #\");\n const line = (hash === -1 ? raw : raw.slice(0, hash)).trimEnd();\n const trimmed = line.trimStart();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) continue;\n if (/^packages\\s*:/.test(line)) {\n inList = true;\n continue;\n }\n if (!inList) continue;\n if (trimmed === line) break;\n if (!trimmed.startsWith(\"-\")) continue;\n const item = trimmed.slice(1).trim().replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n if (item) globs.push(item);\n }\n return globs;\n}\n\nfunction isDir(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\n/** The folders that a glob of pnpm-workspace.yaml gives: \"a/b\", \"a/*\" and \"a/**\". */\nfunction expand(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\");\n const star = clean.indexOf(\"*\");\n if (star === -1) return isDir(join(root, clean)) ? [clean] : [];\n const base = clean.slice(0, star).replace(/\\/$/, \"\");\n const recursive = clean.slice(star).startsWith(\"**\");\n const found: string[] = [];\n const walk = (dir: string, depth: number): void => {\n let entries;\n try {\n entries = readdirSync(join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const child = dir === \"\" ? entry.name : `${dir}/${entry.name}`;\n found.push(child);\n if (recursive && depth < 6) walk(child, depth + 1);\n }\n };\n walk(base, 0);\n return found;\n}\n\n/** The leaf strings of an `exports` value, with their subpath keys. */\nfunction exportTargets(value: unknown, out: string[] = []): string[] {\n if (typeof value === \"string\") out.push(value);\n else if (Array.isArray(value)) for (const item of value) exportTargets(item, out);\n else if (value && typeof value === \"object\") for (const item of Object.values(value)) exportTargets(item, out);\n return out;\n}\n\n/**\n * The RegExp source of an entry target of a package. The extension can change, because\n * dependency-cruiser resolves \"./x.js\" to the source file x.ts, and \"*\" of a subpath pattern matches\n * each path.\n */\nexport function entryPattern(dir: string, target: string): string {\n const path = posix.normalize(posix.join(dir, target.replace(/^\\.\\//, \"\")));\n const stem = path.replace(/\\.d\\.[cm]?ts$|\\.[cm]?[jt]sx?$/, \"\");\n const source = stem.split(\"*\").map(escape).join(\".*\");\n // A flat list, because dependency-cruiser refuses a RegExp with nested quantifiers (safe-regex).\n return `^${source}(${EXTENSIONS})?$`;\n}\n\nconst EXTENSIONS = [\".js\", \".mjs\", \".cjs\", \".jsx\", \".ts\", \".mts\", \".cts\", \".tsx\", \".d.ts\", \".d.mts\", \".d.cts\"].map(escape).join(\"|\");\n\n/** The entries of a package.json: the files that other packages can import. */\nexport function packageEntries(dir: string, manifest: Record<string, unknown>): string[] {\n const targets = exportTargets(manifest[\"exports\"]);\n for (const field of [\"main\", \"module\", \"types\", \"typings\"]) {\n const value = manifest[field];\n if (typeof value === \"string\") targets.push(value);\n }\n if (typeof manifest[\"bin\"] === \"string\") targets.push(manifest[\"bin\"]);\n else if (manifest[\"bin\"] && typeof manifest[\"bin\"] === \"object\") targets.push(...exportTargets(manifest[\"bin\"]));\n // With no entry field, Node resolves the package to index.js.\n if (targets.length === 0 && manifest[\"exports\"] === undefined) targets.push(\"./index.js\");\n return [...new Set(targets.filter((t) => !t.endsWith(\".json\") || t === \"./package.json\").map((t) => entryPattern(dir, t)))];\n}\n\n/** The packages of the workspace in the folder `root`. */\nexport function workspacePackages(root: string, globs?: string[]): WorkspacePackage[] {\n let list = globs;\n if (!list) {\n try {\n list = workspaceGlobs(readFileSync(join(root, \"pnpm-workspace.yaml\"), \"utf8\"));\n } catch {\n list = [];\n }\n if (list.length === 0) list = [\"packages/*\"];\n }\n const excluded = list.filter((g) => g.startsWith(\"!\")).flatMap((g) => expand(root, g.slice(1)));\n const dirs = [...new Set(list.filter((g) => !g.startsWith(\"!\")).flatMap((g) => expand(root, g)))].filter((d) => !excluded.includes(d));\n const found: WorkspacePackage[] = [];\n for (const dir of dirs.sort()) {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(readFileSync(join(root, dir, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n continue;\n }\n if (typeof manifest[\"name\"] !== \"string\") continue;\n found.push({ name: manifest[\"name\"], dir, private: manifest[\"private\"] === true, entries: packageEntries(dir, manifest) });\n }\n return found;\n}\n\n/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */\nexport function boundaryRules(packages: WorkspacePackage[], opts: Pick<BoundaryOptions, \"apps\" | \"reference\"> = {}): Rule[] {\n const why = (text: string): string => (opts.reference ? `${opts.reference} ${text}` : text);\n const anyPackage = packages.map((p) => `^${escape(p.dir)}/`);\n const rules: Rule[] = [];\n for (const pkg of packages) {\n const own = `^${escape(pkg.dir)}/`;\n const others = anyPackage.filter((path) => path !== own);\n if (others.length > 0) {\n rules.push({\n name: `relative-import-out-of-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(`A relative import leaves the package ${pkg.name}. Import the other package by its name, through an entry of its package.json.`),\n from: { path: own },\n to: { path: others, pathNot: own, dependencyTypes: [\"local\"] },\n });\n }\n rules.push({\n name: `deep-import-into-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(\n `An import reaches into the folder of ${pkg.name} at a file that is not an entry of its package.json (exports, main, module, types or bin). Import an entry, or add the file to the exports of ${pkg.name}.`,\n ),\n from: { pathNot: own },\n to: pkg.entries.length > 0 ? { path: own, pathNot: pkg.entries } : { path: own },\n });\n }\n const names = packages.map((p) => escape(p.name));\n if (names.length > 0) {\n rules.push({\n name: \"not-a-declared-export\",\n severity: \"error\",\n comment: why(\"An import of a package of this workspace does not resolve. The path is not an entry of its exports, or the package is not built.\"),\n from: {},\n to: { path: `^(${names.join(\"|\")})(/|$)`, couldNotResolve: true },\n });\n }\n const apps =\n opts.apps === \"private\" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));\n for (const app of apps) {\n rules.push({\n name: `import-of-the-app-${slug(app.name)}`,\n severity: \"error\",\n comment: why(`A package imports the app ${app.name}. An app is a leaf: no other package imports it. Move the shared code to a library package.`),\n from: { pathNot: `^${escape(app.dir)}/` },\n to: { path: `^${escape(app.dir)}/` },\n });\n }\n return rules;\n}\n\nconst slug = (name: string): string => name.replace(/^@/, \"\").replace(/[^A-Za-z0-9]+/g, \"-\");\n\n/**\n * The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript\n * compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads\n * TypeScript with swc when @swc/core is installed. Else it reads only JavaScript (acorn): that is\n * enough for a check of built JavaScript.\n */\nexport function parserOptions(root?: string): Record<string, unknown> {\n if (!root) return {};\n const require = createRequire(join(root, \"package.json\"));\n try {\n const { version } = require(\"typescript/package.json\") as { version: string };\n // A type-only import is a boundary too. This option needs the TypeScript compiler.\n if (Number(version.split(\".\")[0]) < 7) return { tsPreCompilationDeps: true };\n } catch {\n // No TypeScript in the repository\n }\n // @swc/core from the repository, or next to this package (a peer dependency)\n for (const from of [require, createRequire(import.meta.url)]) {\n try {\n from.resolve(\"@swc/core\");\n return { parser: \"swc\" };\n } catch {\n // Not there\n }\n }\n return {};\n}\n\n/**\n * The default options: the source of the packages, with type-only imports, resolved as Node resolves\n * them. There is no `includeOnly`, because it also removes the imports that do not resolve, and the\n * rule not-a-declared-export needs them. The \"types\" condition is not used: it resolves to a\n * declaration file, and the analysis excludes declaration files, so a deep import does not show.\n */\nexport function defaultOptions(root?: string): Record<string, unknown> {\n return {\n ...parserOptions(root),\n exclude: {\n path: [\"(^|/)node_modules/\", \"\\\\.(test|spec|e2e)\\\\.[cm]?[jt]sx?$\", \"\\\\.d\\\\.[cm]?ts$\", \"/(test|tests|e2e|__tests__|fixtures)/\"],\n },\n doNotFollow: { path: [\"(^|/)node_modules/\"] },\n enhancedResolveOptions: {\n exportsFields: [\"exports\"],\n conditionNames: [\"import\", \"require\", \"node\", \"default\"],\n mainFields: [\"module\", \"main\"],\n },\n skipAnalysisNotInRules: true,\n };\n}\n\n/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */\nexport function boundaries(root: string, opts: BoundaryOptions = {}): Config {\n const packages = workspacePackages(root, opts.packages);\n const options = { ...defaultOptions(root), ...opts.options };\n return {\n forbidden: [...boundaryRules(packages, opts), ...(opts.forbidden ?? [])],\n options,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0DA,MAAM,UAAU,SAAyB,KAAK,QAAQ,uBAAuB,MAAM;;AAGnF,SAAgB,eAAe,MAAwB;CACrD,MAAM,QAAkB,CAAC;CACzB,IAAI,SAAS;CAEb,KAAK,MAAM,OAAO,KAAK,MAAM,OAAO,GAAG;EACrC,MAAM,OAAO,IAAI,QAAQ,IAAI;EAC7B,MAAM,QAAQ,SAAS,KAAK,MAAM,IAAI,MAAM,GAAG,IAAI,EAAA,CAAG,QAAQ;EAC9D,MAAM,UAAU,KAAK,UAAU;EAC/B,IAAI,YAAY,MAAM,QAAQ,WAAW,GAAG,GAAG;EAC/C,IAAI,gBAAgB,KAAK,IAAI,GAAG;GAC9B,SAAS;GACT;EACF;EACA,IAAI,CAAC,QAAQ;EACb,IAAI,YAAY,MAAM;EACtB,IAAI,CAA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esContent":["/**\n * The import boundaries of a workspace, as a dependency-cruiser configuration. Each package is a\n * unit. Another package imports it only through an entry of its package.json (`exports`, `main`,\n * `module`, `types`, `bin`). A relative path or a deep path into its folder is not an entry.\n *\n * A repository uses it from its `.dependency-cruiser.cjs`:\n *\n * ```js\n * const { boundaries } = require(\"@mark1russell7/boundaries\");\n * module.exports = boundaries(__dirname, { apps: \"private\" });\n * ```\n */\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join, posix } from \"node:path\";\n\n/** A rule of dependency-cruiser (the `forbidden` list). The package does not depend on the types of dependency-cruiser. */\nexport interface Rule {\n name: string;\n severity: \"error\" | \"warn\" | \"info\" | \"ignore\";\n comment?: string;\n from: Record<string, unknown>;\n to: Record<string, unknown>;\n}\n\n/** A dependency-cruiser configuration. */\nexport interface Config {\n forbidden: Rule[];\n options: Record<string, unknown>;\n}\n\n/** A package of the workspace. */\nexport interface WorkspacePackage {\n /** The name in package.json. */\n name: string;\n /** The folder, relative to the root, with \"/\". */\n dir: string;\n private: boolean;\n /** RegExp sources of the files that other packages can import. */\n entries: string[];\n /** The names of the dependencies in package.json: dependencies, devDependencies, peerDependencies and optionalDependencies. */\n dependencies?: string[];\n}\n\n/**\n * The scopes of the rule unknown-workspace-package. A list replaces the scopes of the workspace\n * packages. `add` and `remove` change that list. An empty list turns off the rule.\n */\nexport type ScopeOptions = string[] | { add?: string[]; remove?: string[] };\n\nexport interface BoundaryOptions {\n /**\n * Globs of the package folders, for example `[\"packages/*\"]`. The default is the `packages` list of\n * pnpm-workspace.yaml, or `[\"packages/*\"]` when the file does not exist.\n */\n packages?: string[];\n /** The apps: the leaves of the graph, which no other package imports. \"private\" means each private package. */\n apps?: \"private\" | string[];\n /** A text before each comment, for example the decision record of the rules. The comments of `forbidden` get it too. */\n reference?: string;\n /**\n * The scopes (for example \"@x\") in which an import that does not resolve must name a workspace\n * package or a declared dependency. The default is the scopes of the workspace package names.\n */\n scopes?: ScopeOptions;\n /**\n * The build folders of each package, for example `[\"dist\", \"build\"]` (the default). The analysis\n * does not follow the imports of their files, and it does not start from them.\n */\n buildFolders?: string[];\n /** More rules, after the rules of the boundaries. */\n forbidden?: Rule[];\n /** More options of dependency-cruiser. They replace the default options with the same key. */\n options?: Record<string, unknown>;\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** The default build folders of a package. */\nconst BUILD_FOLDERS = [\"dist\", \"build\"];\n\nconst DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"];\n\n/** The names of the dependencies of a package.json, from each dependency field. */\nexport function declaredDependencies(manifest: Record<string, unknown>): string[] {\n const names = new Set<string>();\n for (const field of DEPENDENCY_FIELDS) {\n const value = manifest[field];\n if (value && typeof value === \"object\" && !Array.isArray(value)) for (const name of Object.keys(value)) names.add(name);\n }\n return [...names].sort();\n}\n\n/** The scopes of the package names, for example \"@x\" for \"@x/a\", changed by the option `scopes`. A name with no scope gives no scope. */\nexport function workspaceScopes(packages: Pick<WorkspacePackage, \"name\">[], opts: ScopeOptions = {}): string[] {\n const normal = (scope: string): string => (scope.startsWith(\"@\") ? scope : `@${scope}`).replace(/\\/$/, \"\");\n if (Array.isArray(opts)) return [...new Set(opts.map(normal))].sort();\n const scopes = new Set(packages.filter((p) => p.name.startsWith(\"@\") && p.name.includes(\"/\")).map((p) => p.name.slice(0, p.name.indexOf(\"/\"))));\n for (const scope of opts.add ?? []) scopes.add(normal(scope));\n for (const scope of opts.remove ?? []) scopes.delete(normal(scope));\n return [...scopes].sort();\n}\n\n/** The `packages` list of a pnpm-workspace.yaml file. It reads only that list, with no YAML library. */\nexport function workspaceGlobs(yaml: string): string[] {\n const globs: string[] = [];\n let inList = false;\n // String operations, not one large RegExp: a RegExp with nested whitespace groups can be slow on some input.\n for (const raw of yaml.split(/\\r?\\n/)) {\n const hash = raw.indexOf(\" #\");\n const line = (hash === -1 ? raw : raw.slice(0, hash)).trimEnd();\n const trimmed = line.trimStart();\n if (trimmed === \"\" || trimmed.startsWith(\"#\")) continue;\n if (/^packages\\s*:/.test(line)) {\n inList = true;\n continue;\n }\n if (!inList) continue;\n if (trimmed === line) break;\n if (!trimmed.startsWith(\"-\")) continue;\n const item = trimmed.slice(1).trim().replace(/^[\"']/, \"\").replace(/[\"']$/, \"\");\n if (item) globs.push(item);\n }\n return globs;\n}\n\nfunction isDir(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\n/** The folders that a glob of pnpm-workspace.yaml gives: \"a/b\", \"a/*\" and \"a/**\". */\nfunction expand(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\");\n const star = clean.indexOf(\"*\");\n if (star === -1) return isDir(join(root, clean)) ? [clean] : [];\n const base = clean.slice(0, star).replace(/\\/$/, \"\");\n const recursive = clean.slice(star).startsWith(\"**\");\n const found: string[] = [];\n const walk = (dir: string, depth: number): void => {\n let entries;\n try {\n entries = readdirSync(join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const child = dir === \"\" ? entry.name : `${dir}/${entry.name}`;\n found.push(child);\n if (recursive && depth < 6) walk(child, depth + 1);\n }\n };\n walk(base, 0);\n return found;\n}\n\n/** The leaf strings of an `exports` value, with their subpath keys. */\nfunction exportTargets(value: unknown, out: string[] = []): string[] {\n if (typeof value === \"string\") out.push(value);\n else if (Array.isArray(value)) for (const item of value) exportTargets(item, out);\n else if (value && typeof value === \"object\") for (const item of Object.values(value)) exportTargets(item, out);\n return out;\n}\n\n/**\n * The RegExp source of an entry target of a package. The extension can change, because\n * dependency-cruiser resolves \"./x.js\" to the source file x.ts, and \"*\" of a subpath pattern matches\n * each path.\n */\nexport function entryPattern(dir: string, target: string): string {\n const path = posix.normalize(posix.join(dir, target.replace(/^\\.\\//, \"\")));\n const stem = path.replace(/\\.d\\.[cm]?ts$|\\.[cm]?[jt]sx?$/, \"\");\n const source = stem.split(\"*\").map(escape).join(\".*\");\n // A flat list, because dependency-cruiser refuses a RegExp with nested quantifiers (safe-regex).\n return `^${source}(${EXTENSIONS})?$`;\n}\n\nconst EXTENSIONS = [\".js\", \".mjs\", \".cjs\", \".jsx\", \".ts\", \".mts\", \".cts\", \".tsx\", \".d.ts\", \".d.mts\", \".d.cts\"].map(escape).join(\"|\");\n\n/** The entries of a package.json: the files that other packages can import. */\nexport function packageEntries(dir: string, manifest: Record<string, unknown>): string[] {\n const targets = exportTargets(manifest[\"exports\"]);\n for (const field of [\"main\", \"module\", \"types\", \"typings\"]) {\n const value = manifest[field];\n if (typeof value === \"string\") targets.push(value);\n }\n if (typeof manifest[\"bin\"] === \"string\") targets.push(manifest[\"bin\"]);\n else if (manifest[\"bin\"] && typeof manifest[\"bin\"] === \"object\") targets.push(...exportTargets(manifest[\"bin\"]));\n // With no entry field, Node resolves the package to index.js.\n if (targets.length === 0 && manifest[\"exports\"] === undefined) targets.push(\"./index.js\");\n return [...new Set(targets.filter((t) => !t.endsWith(\".json\") || t === \"./package.json\").map((t) => entryPattern(dir, t)))];\n}\n\n/** The packages of the workspace in the folder `root`. */\nexport function workspacePackages(root: string, globs?: string[]): WorkspacePackage[] {\n let list = globs;\n if (!list) {\n try {\n list = workspaceGlobs(readFileSync(join(root, \"pnpm-workspace.yaml\"), \"utf8\"));\n } catch {\n list = [];\n }\n if (list.length === 0) list = [\"packages/*\"];\n }\n const excluded = list.filter((g) => g.startsWith(\"!\")).flatMap((g) => expand(root, g.slice(1)));\n const dirs = [...new Set(list.filter((g) => !g.startsWith(\"!\")).flatMap((g) => expand(root, g)))].filter((d) => !excluded.includes(d));\n const found: WorkspacePackage[] = [];\n for (const dir of dirs.sort()) {\n let manifest: Record<string, unknown>;\n try {\n manifest = JSON.parse(readFileSync(join(root, dir, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n continue;\n }\n if (typeof manifest[\"name\"] !== \"string\") continue;\n found.push({\n name: manifest[\"name\"],\n dir,\n private: manifest[\"private\"] === true,\n entries: packageEntries(dir, manifest),\n dependencies: declaredDependencies(manifest),\n });\n }\n return found;\n}\n\n/** The options of `boundaryRules()`. */\nexport interface RuleOptions extends Pick<BoundaryOptions, \"apps\" | \"reference\" | \"scopes\"> {\n /** More declared dependencies, for example the dependencies of the root package.json. */\n dependencies?: string[];\n}\n\n/** The rules of the boundaries for a list of packages. `boundaries()` reads the list from the workspace. */\nexport function boundaryRules(packages: WorkspacePackage[], opts: RuleOptions = {}): Rule[] {\n const why = (text: string): string => (opts.reference ? `${opts.reference} ${text}` : text);\n const anyPackage = packages.map((p) => `^${escape(p.dir)}/`);\n const rules: Rule[] = [];\n for (const pkg of packages) {\n const own = `^${escape(pkg.dir)}/`;\n const others = anyPackage.filter((path) => path !== own);\n if (others.length > 0) {\n rules.push({\n name: `relative-import-out-of-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(`A relative import leaves the package ${pkg.name}. Import the other package by its name, through an entry of its package.json.`),\n from: { path: own },\n to: { path: others, pathNot: own, dependencyTypes: [\"local\"] },\n });\n }\n rules.push({\n name: `deep-import-into-${slug(pkg.name)}`,\n severity: \"error\",\n comment: why(\n `An import reaches into the folder of ${pkg.name} at a file that is not an entry of its package.json (exports, main, module, types or bin). Import an entry, or add the file to the exports of ${pkg.name}.`,\n ),\n from: { pathNot: own },\n to: pkg.entries.length > 0 ? { path: own, pathNot: pkg.entries } : { path: own },\n });\n }\n const names = packages.map((p) => escape(p.name));\n if (names.length > 0) {\n rules.push({\n name: \"not-a-declared-export\",\n severity: \"error\",\n comment: why(\"An import of a package of this workspace does not resolve. The path is not an entry of its exports, or the package is not built.\"),\n from: {},\n to: { path: `^(${names.join(\"|\")})(/|$)`, couldNotResolve: true },\n });\n }\n const scopes = workspaceScopes(packages, opts.scopes);\n if (scopes.length > 0) {\n const inScope = (name: string): boolean => scopes.some((scope) => name.startsWith(`${scope}/`));\n const declared = [...packages.flatMap((p) => p.dependencies ?? []), ...(opts.dependencies ?? [])];\n const known = [...new Set([...packages.map((p) => p.name), ...declared].filter(inScope))].sort().map(escape);\n rules.push({\n name: \"unknown-workspace-package\",\n severity: \"error\",\n comment: why(\n `An import names a package of the scope ${scopes.join(\", \")}, but the import does not resolve. The name is not a package of this workspace and not a declared dependency. Correct the name, or add the package.`,\n ),\n from: {},\n to: { path: `^(${scopes.map(escape).join(\"|\")})/`, ...(known.length > 0 ? { pathNot: `^(${known.join(\"|\")})(/|$)` } : {}), couldNotResolve: true },\n });\n }\n const apps =\n opts.apps === \"private\" ? packages.filter((p) => p.private) : packages.filter((p) => (opts.apps ?? []).includes(p.name));\n for (const app of apps) {\n rules.push({\n name: `import-of-the-app-${slug(app.name)}`,\n severity: \"error\",\n comment: why(`A package imports the app ${app.name}. An app is a leaf: no other package imports it. Move the shared code to a library package.`),\n from: { pathNot: `^${escape(app.dir)}/` },\n to: { path: `^${escape(app.dir)}/` },\n });\n }\n return rules;\n}\n\nconst slug = (name: string): string => name.replace(/^@/, \"\").replace(/[^A-Za-z0-9]+/g, \"-\");\n\n/**\n * The parser of the TypeScript source. dependency-cruiser reads TypeScript with the TypeScript\n * compiler of the repository only for TypeScript 2 to 6. With TypeScript 7 or no TypeScript, it reads\n * TypeScript with swc when @swc/core is installed. Else it reads only JavaScript (acorn): that is\n * enough for a check of built JavaScript.\n */\nexport function parserOptions(root?: string): Record<string, unknown> {\n if (!root) return {};\n const require = createRequire(join(root, \"package.json\"));\n try {\n const { version } = require(\"typescript/package.json\") as { version: string };\n // A type-only import is a boundary too. This option needs the TypeScript compiler.\n if (Number(version.split(\".\")[0]) < 7) return { tsPreCompilationDeps: true };\n } catch {\n // No TypeScript in the repository\n }\n // @swc/core from the repository, or next to this package (a peer dependency)\n for (const from of [require, createRequire(import.meta.url)]) {\n try {\n from.resolve(\"@swc/core\");\n return { parser: \"swc\" };\n } catch {\n // Not there\n }\n }\n return {};\n}\n\n/** The options of `defaultOptions()`. */\nexport interface DefaultOptionsInput {\n /** The packages of the workspace. The default is `workspacePackages(root)`. */\n packages?: WorkspacePackage[];\n /** The build folders of each package. The default is `[\"dist\", \"build\"]`. */\n buildFolders?: string[];\n}\n\n/** The RegExp sources of the paths that the analysis does not follow: node_modules and the build folders of each package. */\nexport function doNotFollowPaths(packages: Pick<WorkspacePackage, \"dir\">[], buildFolders: string[] = BUILD_FOLDERS): string[] {\n const paths = [\"(^|/)node_modules/\"];\n const dirs = packages.map((p) => p.dir).filter((dir) => dir !== \"\" && dir !== \".\");\n const folders = buildFolders.map((folder) => folder.replace(/^\\.\\//, \"\").replace(/\\/$/, \"\")).filter((folder) => folder !== \"\");\n if (dirs.length > 0 && folders.length > 0) paths.push(`^(${dirs.map(escape).join(\"|\")})/(${folders.map(escape).join(\"|\")})/`);\n return paths;\n}\n\n/**\n * The default options: the source of the packages, with type-only imports, resolved as Node resolves\n * an ESM import. There is no `includeOnly`, because it also removes the imports that do not resolve,\n * and the rule not-a-declared-export needs them. The analysis does not follow node_modules and the\n * build folders of the packages: an import of a package stops at its entry. The \"types\" condition is\n * not used: it resolves to a declaration file, and the analysis excludes declaration files, so a deep\n * import does not show. The `require` condition is not used: an ESM import does not resolve to an\n * entry that is only for `require`.\n */\nexport function defaultOptions(root?: string, input: DefaultOptionsInput = {}): Record<string, unknown> {\n const packages = input.packages ?? (root ? workspacePackages(root) : []);\n return {\n ...parserOptions(root),\n exclude: {\n path: [\"(^|/)node_modules/\", \"\\\\.(test|spec|e2e)\\\\.[cm]?[jt]sx?$\", \"\\\\.d\\\\.[cm]?ts$\", \"/(test|tests|e2e|__tests__|fixtures)/\"],\n },\n doNotFollow: { path: doNotFollowPaths(packages, input.buildFolders) },\n enhancedResolveOptions: {\n exportsFields: [\"exports\"],\n conditionNames: [\"import\", \"node\", \"default\"],\n mainFields: [\"module\", \"main\"],\n },\n skipAnalysisNotInRules: true,\n };\n}\n\n/** A rule with the reference before its comment, when the comment does not start with it. */\nfunction withReference(rule: Rule, reference?: string): Rule {\n if (!reference || rule.comment?.startsWith(reference)) return rule;\n return { ...rule, comment: rule.comment ? `${reference} ${rule.comment}` : reference };\n}\n\n/** The dependency-cruiser configuration of the boundaries for the workspace in the folder `root`. */\nexport function boundaries(root: string, opts: BoundaryOptions = {}): Config {\n const packages = workspacePackages(root, opts.packages);\n let rootManifest: Record<string, unknown> = {};\n try {\n rootManifest = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n } catch {\n // No package.json at the root\n }\n const options = { ...defaultOptions(root, { packages, ...(opts.buildFolders ? { buildFolders: opts.buildFolders } : {}) }), ...opts.options };\n const rules = boundaryRules(packages, { ...opts, dependencies: declaredDependencies(rootManifest) });\n return {\n forbidden: [...rules, ...(opts.forbidden ?? []).map((rule) => withReference(rule, opts.reference))],\n options,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4EA,MAAM,UAAU,SAAyB,KAAK,QAAQ,uBAAuB,MAAM;;AAGnF,MAAM,gBAAgB,CAAC,QAAQ,OAAO;AAEtC,MAAM,oBAAoB;CAAC;CAAgB;CAAmB;CAAoB;AAAsB;;AAGxG,SAAgB,qBAAqB,UAA6C;CAChF,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,SAAS,mBAAmB;EACrC,MAAM,QAAQ,SAAS;EACvB,IAAI,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,GAAG,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,GAAG,MAAM,IAAI,IAAI;CACxH;CACA,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACzB;;AAGA,SAAgB,gBAAgB,UAA4C,OAAqB,CAAC,GAAa;CAC7G,MAAM,UAAU,WAA2B,MAAM,WAAW,GAAG,IAAI,QAAQ,IAAI,QAAA,CAAS,QAAQ,OAAO,EAAE;CACzG,IAAI,MAAM,QAAQ,IA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AAE;GAAU,GAAI,KAAK,eAAe,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;EAAG,CAAC;EAAG,GAAG,KAAK;CAAQ;CAE5I,OAAO;EACL,WAAW,CAAC,GAFA,cAAc,UAAU;GAAE,GAAG;GAAM,cAAc,qBAAqB,YAAY;EAAE,CAE7E,GAAG,IAAI,KAAK,aAAa,CAAC,EAAA,CAAG,KAAK,SAAS,cAAc,MAAM,KAAK,SAAS,CAAC,CAAC;EAClG;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/boundaries",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "The import boundaries of a pnpm workspace as a dependency-cruiser configuration: each package is imported only through the entries of its package.json.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dependency-cruiser",
|