@rsdk/yarn.constraints 6.0.0-next.40 → 6.0.0-next.41
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/DEPENDENCY_MODEL.md +12 -4
- package/README.MD +70 -30
- package/__tests__/config-validation.test.ts +42 -0
- package/__tests__/engine.test.ts +105 -0
- package/__tests__/fixtures/imports/lib/lib-entry.js +3 -0
- package/__tests__/fixtures/imports/root-entry.js +1 -0
- package/__tests__/fixtures/imports/rules/transitive.js +3 -0
- package/__tests__/fixtures/imports/test/outside.ts +3 -0
- package/__tests__/imports.test.ts +12 -0
- package/dist/collectors/config.js +4 -1
- package/dist/collectors/config.js.map +1 -1
- package/dist/collectors/workspaces.js +3 -1
- package/dist/collectors/workspaces.js.map +1 -1
- package/dist/lib/imports.d.ts +2 -0
- package/dist/lib/imports.js +124 -31
- package/dist/lib/imports.js.map +1 -1
- package/dist/model/config-validation.d.ts +6 -0
- package/dist/model/config-validation.js +31 -0
- package/dist/model/config-validation.js.map +1 -0
- package/dist/model/diagnostics.js +22 -0
- package/dist/model/diagnostics.js.map +1 -1
- package/dist/model/placement.js +12 -7
- package/dist/model/placement.js.map +1 -1
- package/dist/model/rules.d.ts +1 -0
- package/dist/model/rules.js +6 -0
- package/dist/model/rules.js.map +1 -1
- package/dist/model/types.d.ts +2 -1
- package/dist/model/types.js.map +1 -1
- package/dist/model/versions.js +5 -1
- package/dist/model/versions.js.map +1 -1
- package/package.json +2 -2
- package/src/collectors/config.ts +8 -1
- package/src/collectors/workspaces.ts +10 -2
- package/src/lib/imports.ts +173 -31
- package/src/model/config-validation.ts +49 -0
- package/src/model/diagnostics.ts +30 -0
- package/src/model/placement.ts +13 -7
- package/src/model/rules.ts +12 -0
- package/src/model/types.ts +2 -1
- package/src/model/versions.ts +7 -2
package/DEPENDENCY_MODEL.md
CHANGED
|
@@ -85,7 +85,7 @@ autofixable.
|
|
|
85
85
|
| V2 | Wildcard rules count as version rules. | For example `@nestjs/*`. |
|
|
86
86
|
| V3 | The constraints config does not describe the whole model. | It contains versions, overrides, root-only rules, manual required dependencies, and workspace-specific exceptions. |
|
|
87
87
|
| V4 | The last matching rule wins. | Enables broad rules plus specific overrides. |
|
|
88
|
-
| V5 | `rootOnly` means the dependency belongs only to the root dev environment. | Workspace usage
|
|
88
|
+
| V5 | `rootOnly` means the dependency belongs only to the root dev environment. | Workspace declarations and source usage are forbidden unless a more specific override exists. `required` + `rootOnly` means required for the selected workspace but physically owned by root `devDependencies`. |
|
|
89
89
|
|
|
90
90
|
## Placement Formula
|
|
91
91
|
|
|
@@ -133,7 +133,9 @@ guess something that an earlier phase can derive.
|
|
|
133
133
|
|
|
134
134
|
### Phase 3. Collect Usage
|
|
135
135
|
|
|
136
|
-
1. Scan source imports for every workspace
|
|
136
|
+
1. Scan source imports for every workspace from `src/`, `test/`, `tests/`,
|
|
137
|
+
`__tests__/`, concrete package entry-points, and relative imports reachable
|
|
138
|
+
from those entry-points.
|
|
137
139
|
2. Classify each import as local or external.
|
|
138
140
|
3. Classify each import as runtime, type-only, test-only, or tooling-only.
|
|
139
141
|
4. Scan emitted `dist/**/*.d.ts` imports when `dist/` exists.
|
|
@@ -141,8 +143,10 @@ guess something that an earlier phase can derive.
|
|
|
141
143
|
`--with-dts`, missing `dist/` is allowed so local source-only checks remain
|
|
142
144
|
usable before build.
|
|
143
145
|
6. Mark all dependencies found in emitted `.d.ts` as public type surface.
|
|
144
|
-
7.
|
|
145
|
-
|
|
146
|
+
7. Skip generated entry-point roots such as `dist/`, `build/`, `coverage/`, and
|
|
147
|
+
`node_modules/`.
|
|
148
|
+
8. Warn when a workspace has scanned source files but zero collected external
|
|
149
|
+
source or `.d.ts` usage.
|
|
146
150
|
|
|
147
151
|
### Phase 4. Derive Required Public/Runtime Deps
|
|
148
152
|
|
|
@@ -160,6 +164,8 @@ For each workspace:
|
|
|
160
164
|
7. Dependencies matched by a concrete `required: true` rule are treated as
|
|
161
165
|
required public/runtime dependencies even when source scanning cannot see a
|
|
162
166
|
direct import.
|
|
167
|
+
8. Dependencies matched by `required: true` and `rootOnly: true` are added to
|
|
168
|
+
root `devDependencies` instead of the workspace manifest.
|
|
163
169
|
|
|
164
170
|
### Phase 5. Propagate Peers
|
|
165
171
|
|
|
@@ -196,6 +202,8 @@ For each `library`:
|
|
|
196
202
|
4. Apply the last matching rule.
|
|
197
203
|
5. Mirror ranges must stay identical.
|
|
198
204
|
6. Local workspace deps use `workspace:*`.
|
|
205
|
+
7. Workspace-scoped version rules do not satisfy V1; the required V1 rule must
|
|
206
|
+
be global.
|
|
199
207
|
|
|
200
208
|
### Phase 8. Compare Expected vs Actual Manifests
|
|
201
209
|
|
package/README.MD
CHANGED
|
@@ -1,59 +1,99 @@
|
|
|
1
1
|
# @rsdk/yarn.constraints
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```yaml
|
|
8
|
-
some-package: 1.0.0
|
|
9
|
-
"@scope":
|
|
10
|
-
scope-package: ~1.0.0
|
|
11
|
-
```
|
|
3
|
+
`depdoc` derives and checks workspace dependency manifests from package roles,
|
|
4
|
+
source imports, emitted `.d.ts` imports, dependency rules, peer propagation, and
|
|
5
|
+
library peer/dev mirrors.
|
|
12
6
|
|
|
13
7
|
## Usage
|
|
14
8
|
|
|
15
|
-
Dependency model CLI:
|
|
16
|
-
|
|
17
9
|
```sh
|
|
18
10
|
depdoc check
|
|
11
|
+
depdoc check --with-dts
|
|
19
12
|
depdoc fix
|
|
13
|
+
depdoc fix --with-dts
|
|
20
14
|
depdoc explain <workspace> <dependency>
|
|
21
15
|
depdoc doctor
|
|
22
16
|
```
|
|
23
17
|
|
|
24
|
-
`
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
`check` reports dependency-model violations. `fix` rewrites `package.json`
|
|
19
|
+
dependency sections from the derived model. `explain` shows why a dependency is
|
|
20
|
+
or is not expected for a workspace.
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
`--with-dts` requires `dist/` for workspaces that have `src/`. Without the flag,
|
|
23
|
+
existing `dist/**/*.d.ts` files are still read when present, but missing `dist/`
|
|
24
|
+
does not fail the check.
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
By default `depdoc` reads `.rsdk/.constraints.yml`. Override the path with
|
|
29
|
+
`RSDK_YARN_CONSTRAINTS_CFG`.
|
|
29
30
|
|
|
30
31
|
```yaml
|
|
32
|
+
version: 1
|
|
33
|
+
|
|
34
|
+
doctor:
|
|
35
|
+
buildCmd: yarn build
|
|
36
|
+
lintCmd: yarn lint
|
|
37
|
+
typecheckCmd: yarn lerna run typecheck
|
|
38
|
+
|
|
31
39
|
rules:
|
|
40
|
+
- match: '@nestjs/*'
|
|
41
|
+
version: '<=10.4.8'
|
|
42
|
+
|
|
32
43
|
- match: '@fastify/static'
|
|
33
44
|
workspace: '@rsdk/http.server.fastify'
|
|
34
45
|
section: dependencies
|
|
35
46
|
version: '^6.12.0'
|
|
36
47
|
required: true
|
|
48
|
+
|
|
49
|
+
- match: '@types/*'
|
|
50
|
+
rootOnly: true
|
|
37
51
|
```
|
|
38
52
|
|
|
39
|
-
|
|
53
|
+
## Source Scanning
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
// yarn.config.js
|
|
43
|
-
module.exports = require('@rsdk/yarn.constraints').config
|
|
44
|
-
```
|
|
55
|
+
For each workspace, `depdoc` scans:
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
- `src/`
|
|
58
|
+
- `test/`
|
|
59
|
+
- `tests/`
|
|
60
|
+
- `__tests__/`
|
|
61
|
+
- concrete `main`, `bin`, and `exports` entry-points
|
|
62
|
+
- relative imports reachable from those entry-points
|
|
47
63
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
Entry-point traversal stays inside the workspace and skips generated roots such
|
|
65
|
+
as `dist/`, `build/`, `coverage/`, and `node_modules/`.
|
|
66
|
+
|
|
67
|
+
If a workspace has scanned source files but no external source or `.d.ts` usage
|
|
68
|
+
was collected, `depdoc` emits a warning. This is meant to catch packages whose
|
|
69
|
+
real source roots or entry-point graph were missed before `fix` removes declared
|
|
70
|
+
dependencies as stale.
|
|
71
|
+
|
|
72
|
+
## Rule Semantics
|
|
73
|
+
|
|
74
|
+
`match` and `workspace` accept a string or string array. `*` is supported for
|
|
75
|
+
matching, and later matching rules override earlier ones.
|
|
76
|
+
|
|
77
|
+
`version` pins the range used by the derived model. A dependency that appears in
|
|
78
|
+
more than one location must have a global version rule. Workspace-scoped version
|
|
79
|
+
rules are useful overrides, but they do not satisfy that global V1 invariant.
|
|
80
|
+
|
|
81
|
+
`section: dependencies` marks a library dependency as an implementation
|
|
82
|
+
dependency instead of the default peer dependency. `section: devDependencies` is
|
|
83
|
+
only valid with `rootOnly: true`; workspace dev dependencies are derived by the
|
|
84
|
+
model and library dev dependencies are rebuilt as peer mirrors.
|
|
85
|
+
|
|
86
|
+
`required: true` adds a concrete dependency even when source scanning cannot see
|
|
87
|
+
it. Wildcard `required` rules are rejected because they cannot expand to concrete
|
|
88
|
+
dependency names.
|
|
89
|
+
|
|
90
|
+
`rootOnly: true` keeps the dependency in root `devDependencies` and forbids
|
|
91
|
+
workspace declarations or source usage. When combined with `required: true`, the
|
|
92
|
+
dependency is required for the selected workspace but physically owned by root
|
|
93
|
+
`devDependencies`.
|
|
54
94
|
|
|
55
95
|
## Variables
|
|
56
96
|
|
|
57
|
-
| Name
|
|
58
|
-
|
|
59
|
-
| RSDK_YARN_CONSTRAINTS_CFG |
|
|
97
|
+
| Name | Description | Default |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `RSDK_YARN_CONSTRAINTS_CFG` | Path to constraints yaml | `.rsdk/.constraints.yml` |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { validateDependencyRules } from '../src/model/config-validation';
|
|
2
|
+
|
|
3
|
+
describe('validateDependencyRules', () => {
|
|
4
|
+
it('rejects required wildcard rules because they cannot expand to concrete deps', () => {
|
|
5
|
+
expect(
|
|
6
|
+
validateDependencyRules([
|
|
7
|
+
{ match: '@scope/*', version: '^1.0.0', required: true },
|
|
8
|
+
]),
|
|
9
|
+
).toEqual([
|
|
10
|
+
expect.stringContaining('required: true requires concrete match patterns'),
|
|
11
|
+
]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('allows section devDependencies for rootOnly rules', () => {
|
|
15
|
+
expect(
|
|
16
|
+
validateDependencyRules([
|
|
17
|
+
{
|
|
18
|
+
match: 'typescript',
|
|
19
|
+
section: 'devDependencies',
|
|
20
|
+
version: '5.7.3',
|
|
21
|
+
rootOnly: true,
|
|
22
|
+
},
|
|
23
|
+
]),
|
|
24
|
+
).toEqual([]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('rejects section devDependencies when the dependency is not rootOnly', () => {
|
|
28
|
+
expect(
|
|
29
|
+
validateDependencyRules([
|
|
30
|
+
{
|
|
31
|
+
match: 'some-lib',
|
|
32
|
+
section: 'devDependencies',
|
|
33
|
+
version: '^1.0.0',
|
|
34
|
+
},
|
|
35
|
+
]),
|
|
36
|
+
).toEqual([
|
|
37
|
+
expect.stringContaining(
|
|
38
|
+
'section: devDependencies is only supported together with rootOnly: true',
|
|
39
|
+
),
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
});
|
package/__tests__/engine.test.ts
CHANGED
|
@@ -35,6 +35,7 @@ function makeWorkspace(
|
|
|
35
35
|
dtsImports: Set<string> = new Set(),
|
|
36
36
|
hasSrc = false,
|
|
37
37
|
hasDist = false,
|
|
38
|
+
sourceFileCount?: number,
|
|
38
39
|
): WorkspaceFacts {
|
|
39
40
|
const basePkg: WorkspaceFacts['pkg'] = { name };
|
|
40
41
|
if (role !== undefined) basePkg.role = role;
|
|
@@ -48,6 +49,7 @@ function makeWorkspace(
|
|
|
48
49
|
dtsImports,
|
|
49
50
|
hasSrc,
|
|
50
51
|
hasDist,
|
|
52
|
+
...(sourceFileCount === undefined ? {} : { sourceFileCount }),
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -465,6 +467,41 @@ describe('deriveDependencyModel engine', () => {
|
|
|
465
467
|
),
|
|
466
468
|
).toBe(true);
|
|
467
469
|
});
|
|
470
|
+
|
|
471
|
+
it('keeps required rootOnly dependencies in root devDependencies without root-only-usage', () => {
|
|
472
|
+
const root = makeRoot({
|
|
473
|
+
name: '@test/root',
|
|
474
|
+
private: true,
|
|
475
|
+
devDependencies: { 'test-harness': '^1.0.0' },
|
|
476
|
+
});
|
|
477
|
+
const ws = makeWorkspace(
|
|
478
|
+
'@test/svc',
|
|
479
|
+
'packages/svc',
|
|
480
|
+
'service',
|
|
481
|
+
{ name: '@test/svc', role: 'service' },
|
|
482
|
+
);
|
|
483
|
+
const result = deriveDependencyModel(emptyFacts([root, ws], [
|
|
484
|
+
{
|
|
485
|
+
match: 'test-harness',
|
|
486
|
+
workspace: '@test/svc',
|
|
487
|
+
version: '^1.0.0',
|
|
488
|
+
required: true,
|
|
489
|
+
rootOnly: true,
|
|
490
|
+
},
|
|
491
|
+
]));
|
|
492
|
+
const rootExp = result.expected.get('.')!;
|
|
493
|
+
const wsExp = result.expected.get('packages/svc')!;
|
|
494
|
+
|
|
495
|
+
expect(rootExp.sections.devDependencies.get('test-harness')).toBe('^1.0.0');
|
|
496
|
+
expect(wsExp.sections.dependencies.has('test-harness')).toBe(false);
|
|
497
|
+
expect(
|
|
498
|
+
result.violations.some(
|
|
499
|
+
(v) =>
|
|
500
|
+
v.code === 'root-only-usage' &&
|
|
501
|
+
v.dependency === 'test-harness',
|
|
502
|
+
),
|
|
503
|
+
).toBe(false);
|
|
504
|
+
});
|
|
468
505
|
});
|
|
469
506
|
|
|
470
507
|
// 9. library-dev-mirror-exact
|
|
@@ -999,4 +1036,72 @@ describe('deriveDependencyModel engine', () => {
|
|
|
999
1036
|
).toBe(false);
|
|
1000
1037
|
});
|
|
1001
1038
|
});
|
|
1039
|
+
|
|
1040
|
+
describe('source-usage-safety', () => {
|
|
1041
|
+
it('warns when source files were scanned but no external usage was found', () => {
|
|
1042
|
+
const root = makeRoot();
|
|
1043
|
+
const ws = makeWorkspace(
|
|
1044
|
+
'@test/svc',
|
|
1045
|
+
'packages/svc',
|
|
1046
|
+
'service',
|
|
1047
|
+
{ name: '@test/svc', role: 'service' },
|
|
1048
|
+
new Map(),
|
|
1049
|
+
new Set(),
|
|
1050
|
+
false,
|
|
1051
|
+
false,
|
|
1052
|
+
2,
|
|
1053
|
+
);
|
|
1054
|
+
const result = deriveDependencyModel(emptyFacts([root, ws]));
|
|
1055
|
+
|
|
1056
|
+
expect(
|
|
1057
|
+
result.warnings.some(
|
|
1058
|
+
(warning) =>
|
|
1059
|
+
warning.code === 'zero-external-dependencies' &&
|
|
1060
|
+
warning.workspace === '@test/svc',
|
|
1061
|
+
),
|
|
1062
|
+
).toBe(true);
|
|
1063
|
+
});
|
|
1064
|
+
|
|
1065
|
+
it('treats imports from external test roots as private dev dependencies', () => {
|
|
1066
|
+
const root = makeRoot();
|
|
1067
|
+
const ws = makeWorkspace(
|
|
1068
|
+
'@test/svc',
|
|
1069
|
+
'packages/svc',
|
|
1070
|
+
'service',
|
|
1071
|
+
{ name: '@test/svc', role: 'service' },
|
|
1072
|
+
new Map([['test-harness', runtimeUsage(['test/main.spec.ts'])]]),
|
|
1073
|
+
);
|
|
1074
|
+
const result = deriveDependencyModel(emptyFacts([root, ws], [
|
|
1075
|
+
{ match: 'test-harness', version: '^1.0.0' },
|
|
1076
|
+
]));
|
|
1077
|
+
const rootExp = result.expected.get('.')!;
|
|
1078
|
+
const wsExp = result.expected.get('packages/svc')!;
|
|
1079
|
+
|
|
1080
|
+
expect(rootExp.sections.devDependencies.get('test-harness')).toBe('^1.0.0');
|
|
1081
|
+
expect(wsExp.sections.dependencies.has('test-harness')).toBe(false);
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
it('lists repeated dependency occurrences and explains workspace-scoped version rules', () => {
|
|
1085
|
+
const root = makeRoot();
|
|
1086
|
+
const ws1 = makeWorkspace(
|
|
1087
|
+
'@test/a', 'packages/a', 'service',
|
|
1088
|
+
{ name: '@test/a', role: 'service' },
|
|
1089
|
+
new Map([['lodash', runtimeUsage(['src/a.ts'])]]),
|
|
1090
|
+
);
|
|
1091
|
+
const ws2 = makeWorkspace(
|
|
1092
|
+
'@test/b', 'packages/b', 'service',
|
|
1093
|
+
{ name: '@test/b', role: 'service' },
|
|
1094
|
+
new Map([['lodash', runtimeUsage(['src/b.ts'])]]),
|
|
1095
|
+
);
|
|
1096
|
+
const result = deriveDependencyModel(emptyFacts([root, ws1, ws2], [
|
|
1097
|
+
{ match: 'lodash', workspace: '@test/a', version: '^4.17.21' },
|
|
1098
|
+
]));
|
|
1099
|
+
const violation = result.violations.find(
|
|
1100
|
+
(v) => v.code === 'unconstrained-version' && v.dependency === 'lodash',
|
|
1101
|
+
);
|
|
1102
|
+
|
|
1103
|
+
expect(violation?.message).toContain('occurrences: packages/a:dependencies, packages/b:dependencies');
|
|
1104
|
+
expect(violation?.message).toContain('workspace-scoped version rules do not satisfy V1');
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1002
1107
|
});
|
|
@@ -149,6 +149,7 @@ describe('collectSourceImports', () => {
|
|
|
149
149
|
},
|
|
150
150
|
exports: {
|
|
151
151
|
'.': './export-entry.mjs',
|
|
152
|
+
'./lib': './lib/lib-entry.js',
|
|
152
153
|
'./dist': './dist/index.js',
|
|
153
154
|
},
|
|
154
155
|
});
|
|
@@ -157,6 +158,17 @@ describe('collectSourceImports', () => {
|
|
|
157
158
|
expect(pkgs.has('root-entry-dep')).toBe(true);
|
|
158
159
|
expect(pkgs.has('bin-entry-dep')).toBe(true);
|
|
159
160
|
expect(pkgs.has('exports-entry-dep')).toBe(true);
|
|
161
|
+
expect(pkgs.has('lib-entry-dep')).toBe(true);
|
|
162
|
+
expect(pkgs.has('transitive-entry-dep')).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('collects workspace-level test directories as dev-only source surface', () => {
|
|
166
|
+
const workspaceEntries = collectSourceImports(FIXTURES, {
|
|
167
|
+
name: '@test/imports',
|
|
168
|
+
});
|
|
169
|
+
const pkgs = new Set(workspaceEntries.map((e) => e.packageName));
|
|
170
|
+
|
|
171
|
+
expect(pkgs.has('external-test-dep')).toBe(true);
|
|
160
172
|
});
|
|
161
173
|
|
|
162
174
|
it('does not collect .d.ts files (only .ts source files)', () => {
|
|
@@ -14,12 +14,15 @@ exports.loadConfig = loadConfig;
|
|
|
14
14
|
const node_fs_1 = require("node:fs");
|
|
15
15
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
16
|
const yaml_1 = __importDefault(require("yaml"));
|
|
17
|
+
const config_validation_1 = require("../model/config-validation");
|
|
17
18
|
function loadConfig(rootDir, constraintsPath) {
|
|
18
19
|
const filepath = constraintsPath ??
|
|
19
20
|
process.env.RSDK_YARN_CONSTRAINTS_CFG ??
|
|
20
21
|
node_path_1.default.join(rootDir, '.rsdk/.constraints.yml');
|
|
21
22
|
if (!(0, node_fs_1.existsSync)(filepath))
|
|
22
23
|
return { rules: [] };
|
|
23
|
-
|
|
24
|
+
const config = yaml_1.default.parse((0, node_fs_1.readFileSync)(filepath, 'utf8'));
|
|
25
|
+
(0, config_validation_1.assertValidDependencyModelConfig)(config);
|
|
26
|
+
return config;
|
|
24
27
|
}
|
|
25
28
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/collectors/config.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/collectors/config.ts"],"names":[],"mappings":";;;;;AAcA,gCAkBC;AAhCD;;;;;;GAMG;AACH,qCAAmD;AACnD,0DAA6B;AAC7B,gDAAwB;AAExB,kEAA8E;AAG9E,SAAgB,UAAU,CACxB,OAAe,EACf,eAAwB;IAExB,MAAM,QAAQ,GACZ,eAAe;QACf,OAAO,CAAC,GAAG,CAAC,yBAAyB;QACrC,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAE/C,IAAI,CAAC,IAAA,oBAAU,EAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAEhD,MAAM,MAAM,GAAG,cAAI,CAAC,KAAK,CACvB,IAAA,sBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CACN,CAAC;IAE3B,IAAA,oDAAgC,EAAC,MAAM,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -18,7 +18,9 @@ const imports_1 = require("../lib/imports");
|
|
|
18
18
|
const package_json_1 = require("../lib/package-json");
|
|
19
19
|
const rules_1 = require("../model/rules");
|
|
20
20
|
function collectUsage(workspace, withDts) {
|
|
21
|
-
|
|
21
|
+
const sourceFiles = (0, imports_1.collectSourceFiles)(workspace.dir, workspace.pkg);
|
|
22
|
+
workspace.sourceFileCount = sourceFiles.length;
|
|
23
|
+
for (const entry of (0, imports_1.collectSourceImportsFromFiles)(sourceFiles)) {
|
|
22
24
|
if (!workspace.sourceUsage.has(entry.packageName)) {
|
|
23
25
|
workspace.sourceUsage.set(entry.packageName, {
|
|
24
26
|
files: new Set(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/collectors/workspaces.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/collectors/workspaces.ts"],"names":[],"mappings":";;;;;AAsDA,wCAoDC;AA1GD;;;;;;GAMG;AACH,2DAA8C;AAC9C,qCAAqC;AACrC,0DAA6B;AAE7B,4CAIwB;AACxB,sDAAsD;AACtD,0CAAiD;AAQjD,SAAS,YAAY,CAAC,SAA2B,EAAE,OAAgB;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,IAAI;YACzB,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,GAAG;YACH,GAAG;YACH,IAAI;YACJ,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI,GAAG,EAAE;YACtB,UAAU,EAAE,IAAI,GAAG,EAAE;YACrB,MAAM,EAAE,IAAA,oBAAU,EAAC,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,OAAO,EAAE,IAAA,oBAAU,EAAC,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;SAC5C,CAAC;QAEF,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3B,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/lib/imports.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ export interface ImportEntry {
|
|
|
5
5
|
file: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function getPackageName(specifier: string): string | null;
|
|
8
|
+
export declare function collectSourceFiles(srcDirOrWorkspaceDir: string, pkg?: PackageJson): string[];
|
|
9
|
+
export declare function collectSourceImportsFromFiles(files: string[]): ImportEntry[];
|
|
8
10
|
export declare function collectSourceImports(srcDirOrWorkspaceDir: string, pkg?: PackageJson): ImportEntry[];
|
|
9
11
|
export declare function collectDtsImports(distDir: string): Set<string>;
|