knip 0.0.0-graph.0 → 0.0.0-graph.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.js +22 -15
- package/package.json +2 -1
|
@@ -239,23 +239,30 @@ export class ConfigurationChief {
|
|
|
239
239
|
return ancestors;
|
|
240
240
|
};
|
|
241
241
|
const workspaceNames = workspaceArg
|
|
242
|
-
? [
|
|
243
|
-
...this.availableWorkspaceNames.reduce(getAncestors(workspaceArg), []),
|
|
244
|
-
...this.availableWorkspaceNames.filter(name => name === workspaceArg),
|
|
245
|
-
]
|
|
242
|
+
? [...this.availableWorkspaceNames.reduce(getAncestors(workspaceArg), []), workspaceArg]
|
|
246
243
|
: this.availableWorkspaceNames;
|
|
247
|
-
const graph = this.workspacesGraph;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
244
|
+
const graph = this.workspacesGraph?.graph;
|
|
245
|
+
const ws = new Set();
|
|
246
|
+
if (graph && workspaceArg) {
|
|
247
|
+
const seen = new Set();
|
|
248
|
+
const workspaceDirsWithDependants = new Set(workspaceNames.map(name => join(this.cwd, name)));
|
|
249
|
+
const addDependents = (dir) => {
|
|
250
|
+
seen.add(dir);
|
|
251
|
+
const deps = graph[dir]?.dependencies ?? [];
|
|
252
|
+
if (deps.length > 0 && Array.from(workspaceDirsWithDependants).some(dir => deps.includes(dir))) {
|
|
253
|
+
workspaceDirsWithDependants.add(dir);
|
|
254
|
+
deps.filter(dir => !seen.has(dir)).forEach(addDependents);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
this.availableWorkspaceNames.map(name => join(this.cwd, name)).forEach(addDependents);
|
|
258
|
+
workspaceDirsWithDependants.forEach(dir => ws.add(relative(this.cwd, dir) || ROOT_WORKSPACE_NAME));
|
|
251
259
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return workspaceNamesWithDependencies.sort(byPathDepth).map((name) => {
|
|
260
|
+
else {
|
|
261
|
+
workspaceNames.forEach(name => ws.add(name));
|
|
262
|
+
}
|
|
263
|
+
return Array.from(ws)
|
|
264
|
+
.sort(byPathDepth)
|
|
265
|
+
.map((name) => {
|
|
259
266
|
const dir = join(this.cwd, name);
|
|
260
267
|
return {
|
|
261
268
|
name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "0.0.0-graph.
|
|
3
|
+
"version": "0.0.0-graph.1",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ericcornelissen/bash-parser": "^0.5.2",
|
|
46
46
|
"@npmcli/map-workspaces": "^3.0.4",
|
|
47
|
+
"@pnpm/logger": "5.0.0",
|
|
47
48
|
"@pnpm/workspace.pkgs-graph": "2.0.6",
|
|
48
49
|
"@snyk/github-codeowners": "^1.1.0",
|
|
49
50
|
"chalk": "^5.2.0",
|