knip 5.80.1 → 5.81.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/dist/ConfigurationChief.d.ts +18 -3
- package/dist/ConfigurationChief.js +57 -42
- package/dist/DependencyDeputy.d.ts +3 -2
- package/dist/DependencyDeputy.js +14 -11
- package/dist/IssueCollector.d.ts +3 -1
- package/dist/IssueCollector.js +9 -5
- package/dist/binaries/package-manager/bun.js +3 -3
- package/dist/cli.js +2 -1
- package/dist/compilers/index.d.ts +21 -1
- package/dist/compilers/index.js +3 -0
- package/dist/graph/analyze.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/plugins/astro-og-canvas/index.d.ts +3 -0
- package/dist/plugins/astro-og-canvas/index.js +15 -0
- package/dist/plugins/capacitor/index.js +2 -4
- package/dist/plugins/eleventy/index.js +1 -1
- package/dist/plugins/github-actions/index.js +4 -2
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/nitro/index.d.ts +6 -0
- package/dist/plugins/nitro/index.js +58 -0
- package/dist/plugins/nitro/types.d.ts +7 -0
- package/dist/plugins/nitro/types.js +1 -0
- package/dist/plugins/pnpm/index.js +2 -3
- package/dist/plugins/prisma/index.js +2 -2
- package/dist/plugins/svelte/index.js +7 -1
- package/dist/plugins/taskfile/index.js +13 -4
- package/dist/plugins/yarn/index.js +2 -2
- package/dist/reporters/trace.d.ts +3 -1
- package/dist/reporters/trace.js +3 -4
- package/dist/reporters/util/configuration-hints.d.ts +1 -1
- package/dist/reporters/util/configuration-hints.js +2 -2
- package/dist/run.d.ts +1 -0
- package/dist/run.js +3 -1
- package/dist/schema/configuration.d.ts +30 -0
- package/dist/schema/plugins.d.ts +10 -0
- package/dist/schema/plugins.js +2 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/issues.d.ts +1 -0
- package/dist/types/options.d.ts +1 -1
- package/dist/types/workspace.d.ts +2 -1
- package/dist/typescript/ast-helpers.d.ts +1 -0
- package/dist/typescript/ast-helpers.js +3 -0
- package/dist/typescript/get-imports-and-exports.js +6 -3
- package/dist/typescript/has-refs-in-file.js +71 -0
- package/dist/typescript/visitors/exports/exportAssignment.js +1 -1
- package/dist/util/catalog.js +1 -1
- package/dist/util/cli-arguments.d.ts +2 -3
- package/dist/util/cli-arguments.js +33 -22
- package/dist/util/create-options.d.ts +21 -1
- package/dist/util/create-options.js +3 -2
- package/dist/util/create-workspace-graph.js +5 -2
- package/dist/util/fs.d.ts +4 -3
- package/dist/util/fs.js +23 -9
- package/dist/util/glob-core.js +1 -1
- package/dist/util/glob.d.ts +0 -1
- package/dist/util/glob.js +0 -8
- package/dist/util/to-source-path.js +1 -1
- package/dist/util/watch.js +2 -2
- package/dist/util/workspace-file-filter.d.ts +2 -0
- package/dist/util/workspace-file-filter.js +17 -0
- package/dist/util/workspace-selectors.d.ts +12 -0
- package/dist/util/workspace-selectors.js +104 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
- package/dist/typescript/find-internal-references.js +0 -50
- /package/dist/typescript/{find-internal-references.d.ts → has-refs-in-file.d.ts} +0 -0
|
@@ -3,6 +3,7 @@ import type { ConfigurationHint } from './types/issues.js';
|
|
|
3
3
|
import type { WorkspacePackage } from './types/package-json.js';
|
|
4
4
|
import type { MainOptions } from './util/create-options.js';
|
|
5
5
|
import { type WorkspaceGraph } from './util/create-workspace-graph.js';
|
|
6
|
+
import { type WorkspaceFilePathFilter } from './util/workspace-file-filter.js';
|
|
6
7
|
export declare const isDefaultPattern: (type: "entry" | "project", id: string) => boolean;
|
|
7
8
|
export type Workspace = {
|
|
8
9
|
name: string;
|
|
@@ -23,18 +24,19 @@ export declare class ConfigurationChief {
|
|
|
23
24
|
isStrict: boolean;
|
|
24
25
|
isIncludeEntryExports: boolean;
|
|
25
26
|
config: Configuration;
|
|
26
|
-
workspace: string | undefined;
|
|
27
|
+
workspace: string | string[] | undefined;
|
|
28
|
+
selectedWorkspaces: Set<string> | undefined;
|
|
29
|
+
workspaceFilePathFilter: WorkspaceFilePathFilter;
|
|
27
30
|
workspaces: string[];
|
|
28
31
|
ignoredWorkspacePatterns: string[];
|
|
29
32
|
workspacePackages: Map<string, WorkspacePackage>;
|
|
30
33
|
workspacesByPkgName: Map<string, Workspace>;
|
|
31
|
-
|
|
34
|
+
workspacesByDir: Map<string, Workspace>;
|
|
32
35
|
additionalWorkspaceNames: Set<string>;
|
|
33
36
|
availableWorkspaceNames: string[];
|
|
34
37
|
availableWorkspacePkgNames: Set<string>;
|
|
35
38
|
availableWorkspaceDirs: string[];
|
|
36
39
|
workspaceGraph: WorkspaceGraph;
|
|
37
|
-
includedWorkspaces: Workspace[];
|
|
38
40
|
constructor(options: MainOptions);
|
|
39
41
|
getConfigurationHints(): ConfigurationHint[];
|
|
40
42
|
private normalize;
|
|
@@ -52,6 +54,7 @@ export declare class ConfigurationChief {
|
|
|
52
54
|
createIgnoredWorkspaceMatcher(name: string, dir: string): (filePath: string) => boolean;
|
|
53
55
|
getNegatedWorkspacePatterns(name: string): string[];
|
|
54
56
|
private getConfigKeyForWorkspace;
|
|
57
|
+
private getSelectedWorkspaces;
|
|
55
58
|
getWorkspaceConfig(workspaceName: string): {
|
|
56
59
|
angular?: string | boolean | string[] | {
|
|
57
60
|
config?: string | string[] | undefined;
|
|
@@ -68,6 +71,11 @@ export declare class ConfigurationChief {
|
|
|
68
71
|
entry?: string | string[] | undefined;
|
|
69
72
|
project?: string | string[] | undefined;
|
|
70
73
|
} | undefined;
|
|
74
|
+
'astro-og-canvas'?: string | boolean | string[] | {
|
|
75
|
+
config?: string | string[] | undefined;
|
|
76
|
+
entry?: string | string[] | undefined;
|
|
77
|
+
project?: string | string[] | undefined;
|
|
78
|
+
} | undefined;
|
|
71
79
|
ava?: string | boolean | string[] | {
|
|
72
80
|
config?: string | string[] | undefined;
|
|
73
81
|
entry?: string | string[] | undefined;
|
|
@@ -343,6 +351,11 @@ export declare class ConfigurationChief {
|
|
|
343
351
|
entry?: string | string[] | undefined;
|
|
344
352
|
project?: string | string[] | undefined;
|
|
345
353
|
} | undefined;
|
|
354
|
+
nitro?: string | boolean | string[] | {
|
|
355
|
+
config?: string | string[] | undefined;
|
|
356
|
+
entry?: string | string[] | undefined;
|
|
357
|
+
project?: string | string[] | undefined;
|
|
358
|
+
} | undefined;
|
|
346
359
|
node?: string | boolean | string[] | {
|
|
347
360
|
config?: string | string[] | undefined;
|
|
348
361
|
entry?: string | string[] | undefined;
|
|
@@ -714,6 +727,7 @@ export declare class ConfigurationChief {
|
|
|
714
727
|
angular?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
715
728
|
astro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
716
729
|
"astro-db"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
730
|
+
"astro-og-canvas"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
717
731
|
ava?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
718
732
|
babel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
719
733
|
biome?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -767,6 +781,7 @@ export declare class ConfigurationChief {
|
|
|
767
781
|
next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
768
782
|
"next-intl"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
769
783
|
"next-mdx"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
784
|
+
nitro?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
770
785
|
"node-modules-inspector"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
771
786
|
nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
772
787
|
"npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -4,7 +4,6 @@ import { DEFAULT_EXTENSIONS, ROOT_WORKSPACE_NAME } from './constants.js';
|
|
|
4
4
|
import { pluginNames } from './types/PluginNames.js';
|
|
5
5
|
import { arrayify, compact, partition } from './util/array.js';
|
|
6
6
|
import { createWorkspaceGraph } from './util/create-workspace-graph.js';
|
|
7
|
-
import { ConfigurationError } from './util/errors.js';
|
|
8
7
|
import { isDirectory, isFile } from './util/fs.js';
|
|
9
8
|
import { _dirGlob, removeProductionSuffix } from './util/glob.js';
|
|
10
9
|
import { graphSequencer } from './util/graph-sequencer.js';
|
|
@@ -14,6 +13,8 @@ import { normalizePluginConfig } from './util/plugin.js';
|
|
|
14
13
|
import { toRegexOrString } from './util/regex.js';
|
|
15
14
|
import { ELLIPSIS } from './util/string.js';
|
|
16
15
|
import { byPathDepth } from './util/workspace.js';
|
|
16
|
+
import { createWorkspaceFilePathFilter } from './util/workspace-file-filter.js';
|
|
17
|
+
import { selectWorkspaces } from './util/workspace-selectors.js';
|
|
17
18
|
const defaultBaseFilenamePattern = '{index,cli,main}';
|
|
18
19
|
export const isDefaultPattern = (type, id) => {
|
|
19
20
|
if (type === 'project')
|
|
@@ -31,9 +32,10 @@ const getDefaultWorkspaceConfig = (extensions = []) => {
|
|
|
31
32
|
const isPluginName = (name) => pluginNames.includes(name);
|
|
32
33
|
const defaultConfig = {
|
|
33
34
|
ignore: [],
|
|
34
|
-
ignoreFiles: [],
|
|
35
35
|
ignoreBinaries: [],
|
|
36
36
|
ignoreDependencies: [],
|
|
37
|
+
ignoreFiles: [],
|
|
38
|
+
ignoreIssues: {},
|
|
37
39
|
ignoreMembers: [],
|
|
38
40
|
ignoreUnresolved: [],
|
|
39
41
|
ignoreWorkspaces: [],
|
|
@@ -51,17 +53,18 @@ export class ConfigurationChief {
|
|
|
51
53
|
isIncludeEntryExports;
|
|
52
54
|
config;
|
|
53
55
|
workspace;
|
|
56
|
+
selectedWorkspaces;
|
|
57
|
+
workspaceFilePathFilter = () => true;
|
|
54
58
|
workspaces;
|
|
55
59
|
ignoredWorkspacePatterns = [];
|
|
56
60
|
workspacePackages = new Map();
|
|
57
61
|
workspacesByPkgName = new Map();
|
|
58
|
-
|
|
62
|
+
workspacesByDir = new Map();
|
|
59
63
|
additionalWorkspaceNames = new Set();
|
|
60
64
|
availableWorkspaceNames = [];
|
|
61
65
|
availableWorkspacePkgNames = new Set();
|
|
62
66
|
availableWorkspaceDirs = [];
|
|
63
67
|
workspaceGraph = new Map();
|
|
64
|
-
includedWorkspaces = [];
|
|
65
68
|
constructor(options) {
|
|
66
69
|
this.cwd = options.cwd;
|
|
67
70
|
this.isProduction = options.isProduction;
|
|
@@ -98,7 +101,7 @@ export class ConfigurationChief {
|
|
|
98
101
|
const ignoreMembers = rawConfig.ignoreMembers ?? [];
|
|
99
102
|
const ignoreUnresolved = rawConfig.ignoreUnresolved ?? [];
|
|
100
103
|
const ignoreExportsUsedInFile = rawConfig.ignoreExportsUsedInFile ?? false;
|
|
101
|
-
const ignoreIssues = rawConfig.ignoreIssues;
|
|
104
|
+
const ignoreIssues = rawConfig.ignoreIssues ?? {};
|
|
102
105
|
const ignoreWorkspaces = rawConfig.ignoreWorkspaces ?? defaultConfig.ignoreWorkspaces;
|
|
103
106
|
const isIncludeEntryExports = rawConfig.includeEntryExports ?? this.isIncludeEntryExports;
|
|
104
107
|
const { syncCompilers, asyncCompilers } = rawConfig;
|
|
@@ -137,14 +140,16 @@ export class ConfigurationChief {
|
|
|
137
140
|
.reverse()
|
|
138
141
|
.map(dir => join(this.cwd, dir));
|
|
139
142
|
this.workspaceGraph = createWorkspaceGraph(this.cwd, this.availableWorkspaceNames, wsPkgNames, packages);
|
|
140
|
-
this.
|
|
141
|
-
|
|
143
|
+
this.selectedWorkspaces = this.getSelectedWorkspaces();
|
|
144
|
+
this.workspaceFilePathFilter = createWorkspaceFilePathFilter(this.cwd, this.selectedWorkspaces, this.availableWorkspaceNames);
|
|
145
|
+
const includedWorkspaces = this.getIncludedWorkspaces();
|
|
146
|
+
for (const workspace of includedWorkspaces) {
|
|
142
147
|
this.workspacesByPkgName.set(workspace.pkgName, workspace);
|
|
143
|
-
this.
|
|
148
|
+
this.workspacesByDir.set(workspace.dir, workspace);
|
|
144
149
|
}
|
|
145
|
-
const sorted = graphSequencer(this.workspaceGraph, this.
|
|
150
|
+
const sorted = graphSequencer(this.workspaceGraph, Array.from(this.workspacesByDir.keys()).filter(dir => this.workspaceGraph.has(dir)));
|
|
146
151
|
const [root, rest] = partition(sorted.chunks.flat(), dir => dir === this.cwd);
|
|
147
|
-
return [...root, ...rest.reverse()].map(dir => this.
|
|
152
|
+
return [...root, ...rest.reverse()].map(dir => this.workspacesByDir.get(dir));
|
|
148
153
|
}
|
|
149
154
|
getListedWorkspaces() {
|
|
150
155
|
return this.workspaces.map(pattern => pattern.replace(/(?<=!?)\.\//, ''));
|
|
@@ -180,53 +185,48 @@ export class ConfigurationChief {
|
|
|
180
185
|
getAvailableWorkspaceNames(names) {
|
|
181
186
|
const availableWorkspaceNames = [];
|
|
182
187
|
const [ignore, patterns] = partition(this.ignoredWorkspacePatterns, pattern => pattern.startsWith('!'));
|
|
188
|
+
const ignoreSliced = ignore.map(pattern => pattern.slice(1));
|
|
183
189
|
for (const name of names) {
|
|
184
|
-
if (!picomatch.isMatch(name, patterns, { ignore:
|
|
190
|
+
if (!picomatch.isMatch(name, patterns, { ignore: ignoreSliced })) {
|
|
185
191
|
availableWorkspaceNames.push(name);
|
|
186
192
|
}
|
|
187
193
|
}
|
|
188
194
|
return availableWorkspaceNames;
|
|
189
195
|
}
|
|
190
196
|
getIncludedWorkspaces() {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
throw new ConfigurationError('Unable to find package.json in workspace');
|
|
197
|
-
}
|
|
198
|
-
const getAncestors = (name) => (ancestors, ancestorName) => {
|
|
199
|
-
if (name === ancestorName)
|
|
200
|
-
return ancestors;
|
|
201
|
-
if (ancestorName === ROOT_WORKSPACE_NAME || name.startsWith(`${ancestorName}/`))
|
|
202
|
-
ancestors.push(ancestorName);
|
|
203
|
-
return ancestors;
|
|
204
|
-
};
|
|
205
|
-
const workspaceNames = this.workspace
|
|
206
|
-
? [...this.availableWorkspaceNames.reduce(getAncestors(this.workspace), []), this.workspace]
|
|
197
|
+
const selectedWorkspaces = this.selectedWorkspaces;
|
|
198
|
+
const isAncestor = (name, ancestor) => ancestor !== name && (ancestor === ROOT_WORKSPACE_NAME || name.startsWith(`${ancestor}/`));
|
|
199
|
+
const getAncestors = (name) => this.availableWorkspaceNames.filter(a => isAncestor(name, a));
|
|
200
|
+
const workspaceNames = selectedWorkspaces
|
|
201
|
+
? Array.from(selectedWorkspaces).flatMap(name => [...getAncestors(name), name])
|
|
207
202
|
: this.availableWorkspaceNames;
|
|
208
203
|
const ws = new Set();
|
|
209
|
-
if (
|
|
210
|
-
|
|
204
|
+
if (selectedWorkspaces && this.isStrict) {
|
|
205
|
+
for (const name of selectedWorkspaces)
|
|
206
|
+
ws.add(name);
|
|
211
207
|
}
|
|
212
|
-
else if (
|
|
208
|
+
else if (selectedWorkspaces) {
|
|
213
209
|
const graph = this.workspaceGraph;
|
|
214
210
|
if (graph) {
|
|
215
211
|
const seen = new Set();
|
|
216
|
-
const initialWorkspaces = workspaceNames.map(name => join(this.cwd, name));
|
|
212
|
+
const initialWorkspaces = new Set(workspaceNames.map(name => join(this.cwd, name)));
|
|
217
213
|
const workspaceDirsWithDependents = new Set(initialWorkspaces);
|
|
218
214
|
const addDependents = (dir) => {
|
|
219
215
|
seen.add(dir);
|
|
220
216
|
const dirs = graph.get(dir);
|
|
221
217
|
if (!dirs || dirs.size === 0)
|
|
222
218
|
return;
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
for (const d of dirs)
|
|
220
|
+
if (initialWorkspaces.has(d)) {
|
|
221
|
+
workspaceDirsWithDependents.add(dir);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
225
224
|
for (const dir of dirs)
|
|
226
225
|
if (!seen.has(dir))
|
|
227
226
|
addDependents(dir);
|
|
228
227
|
};
|
|
229
|
-
this.availableWorkspaceDirs
|
|
228
|
+
for (const dir of this.availableWorkspaceDirs)
|
|
229
|
+
addDependents(dir);
|
|
230
230
|
for (const dir of workspaceDirsWithDependents)
|
|
231
231
|
ws.add(relative(this.cwd, dir) || ROOT_WORKSPACE_NAME);
|
|
232
232
|
}
|
|
@@ -250,7 +250,7 @@ export class ConfigurationChief {
|
|
|
250
250
|
pkgName,
|
|
251
251
|
dir,
|
|
252
252
|
config: this.getConfigForWorkspace(name),
|
|
253
|
-
ancestors:
|
|
253
|
+
ancestors: getAncestors(name),
|
|
254
254
|
manifestPath,
|
|
255
255
|
manifestStr,
|
|
256
256
|
ignoreMembers,
|
|
@@ -261,9 +261,8 @@ export class ConfigurationChief {
|
|
|
261
261
|
return this.workspacePackages.get(name)?.manifest;
|
|
262
262
|
}
|
|
263
263
|
getDescendentWorkspaces(name) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
.filter(workspaceName => name === ROOT_WORKSPACE_NAME || workspaceName.startsWith(`${name}/`));
|
|
264
|
+
const prefix = `${name}/`;
|
|
265
|
+
return this.availableWorkspaceNames.filter(workspaceName => workspaceName !== name && (name === ROOT_WORKSPACE_NAME || workspaceName.startsWith(prefix)));
|
|
267
266
|
}
|
|
268
267
|
getIgnoredWorkspacesFor(name) {
|
|
269
268
|
return this.ignoredWorkspacePatterns
|
|
@@ -294,6 +293,12 @@ export class ConfigurationChief {
|
|
|
294
293
|
.reverse()
|
|
295
294
|
.find(pattern => picomatch.isMatch(workspaceName, pattern));
|
|
296
295
|
}
|
|
296
|
+
getSelectedWorkspaces() {
|
|
297
|
+
if (!this.workspace)
|
|
298
|
+
return;
|
|
299
|
+
const workspaceSelectors = Array.isArray(this.workspace) ? this.workspace : [this.workspace];
|
|
300
|
+
return selectWorkspaces(workspaceSelectors, this.cwd, this.workspacePackages, this.availableWorkspaceNames);
|
|
301
|
+
}
|
|
297
302
|
getWorkspaceConfig(workspaceName) {
|
|
298
303
|
const key = this.getConfigKeyForWorkspace(workspaceName);
|
|
299
304
|
const workspaces = this.rawConfig?.workspaces ?? {};
|
|
@@ -341,16 +346,26 @@ export class ConfigurationChief {
|
|
|
341
346
|
}
|
|
342
347
|
findWorkspaceByFilePath(filePath) {
|
|
343
348
|
const workspaceDir = this.availableWorkspaceDirs.find(workspaceDir => filePath.startsWith(`${workspaceDir}/`));
|
|
344
|
-
|
|
349
|
+
if (!workspaceDir)
|
|
350
|
+
return undefined;
|
|
351
|
+
return this.workspacesByDir.get(workspaceDir);
|
|
345
352
|
}
|
|
346
353
|
getUnusedIgnoredWorkspaces() {
|
|
347
354
|
const ignoredWorkspaceNames = this.config.ignoreWorkspaces.map(removeProductionSuffix);
|
|
348
|
-
const
|
|
355
|
+
const matchesWorkspace = (pattern) => {
|
|
356
|
+
for (const name of this.workspacePackages.keys())
|
|
357
|
+
if (picomatch.isMatch(name, pattern))
|
|
358
|
+
return true;
|
|
359
|
+
for (const name of this.additionalWorkspaceNames)
|
|
360
|
+
if (picomatch.isMatch(name, pattern))
|
|
361
|
+
return true;
|
|
362
|
+
return false;
|
|
363
|
+
};
|
|
349
364
|
return ignoredWorkspaceNames
|
|
350
|
-
.filter(ignoredWorkspaceName => !
|
|
365
|
+
.filter(ignoredWorkspaceName => !matchesWorkspace(ignoredWorkspaceName))
|
|
351
366
|
.filter(ignoredWorkspaceName => {
|
|
352
367
|
const dir = join(this.cwd, ignoredWorkspaceName);
|
|
353
|
-
return !isDirectory(dir) || isFile(
|
|
368
|
+
return !isDirectory(dir) || isFile(dir, 'package.json');
|
|
354
369
|
});
|
|
355
370
|
}
|
|
356
371
|
}
|
|
@@ -32,7 +32,8 @@ export declare class DependencyDeputy {
|
|
|
32
32
|
dependencies: DependencyArray;
|
|
33
33
|
devDependencies: DependencyArray;
|
|
34
34
|
peerDependencies: DependencySet;
|
|
35
|
-
optionalPeerDependencies:
|
|
35
|
+
optionalPeerDependencies: DependencySet;
|
|
36
|
+
requiredPeerDependencies: DependencyArray;
|
|
36
37
|
allDependencies: DependencySet;
|
|
37
38
|
ignoreDependencies: (string | RegExp)[];
|
|
38
39
|
ignoreBinaries: (string | RegExp)[];
|
|
@@ -55,7 +56,7 @@ export declare class DependencyDeputy {
|
|
|
55
56
|
name: string;
|
|
56
57
|
isPeerOptional: boolean;
|
|
57
58
|
}[];
|
|
58
|
-
getOptionalPeerDependencies(workspaceName: string):
|
|
59
|
+
getOptionalPeerDependencies(workspaceName: string): DependencySet;
|
|
59
60
|
maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string): boolean;
|
|
60
61
|
maybeAddReferencedBinary(workspace: Workspace, binaryName: string): Set<string> | undefined;
|
|
61
62
|
private isInDependencies;
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -29,11 +29,14 @@ export class DependencyDeputy {
|
|
|
29
29
|
const dependencies = Object.keys(manifest.dependencies ?? {});
|
|
30
30
|
const peerDependencies = Object.keys(manifest.peerDependencies ?? {});
|
|
31
31
|
const optionalDependencies = Object.keys(manifest.optionalDependencies ?? {});
|
|
32
|
-
const optionalPeerDependencies =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
manifest.peerDependenciesMeta[
|
|
36
|
-
|
|
32
|
+
const optionalPeerDependencies = new Set();
|
|
33
|
+
if (manifest.peerDependenciesMeta) {
|
|
34
|
+
for (const dep of peerDependencies) {
|
|
35
|
+
if (manifest.peerDependenciesMeta[dep]?.optional)
|
|
36
|
+
optionalPeerDependencies.add(dep);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const requiredPeerDependencies = peerDependencies.filter(dep => !optionalPeerDependencies.has(dep));
|
|
37
40
|
const devDependencies = Object.keys(manifest.devDependencies ?? {});
|
|
38
41
|
const allDependencies = [...dependencies, ...devDependencies, ...peerDependencies, ...optionalDependencies];
|
|
39
42
|
const packageNames = [
|
|
@@ -68,6 +71,7 @@ export class DependencyDeputy {
|
|
|
68
71
|
devDependencies,
|
|
69
72
|
peerDependencies: new Set(peerDependencies),
|
|
70
73
|
optionalPeerDependencies,
|
|
74
|
+
requiredPeerDependencies,
|
|
71
75
|
allDependencies: new Set(allDependencies),
|
|
72
76
|
});
|
|
73
77
|
}
|
|
@@ -79,7 +83,7 @@ export class DependencyDeputy {
|
|
|
79
83
|
if (!manifest)
|
|
80
84
|
return [];
|
|
81
85
|
if (this.isStrict)
|
|
82
|
-
return [...manifest.dependencies, ...manifest.
|
|
86
|
+
return [...manifest.dependencies, ...manifest.requiredPeerDependencies];
|
|
83
87
|
return manifest.dependencies;
|
|
84
88
|
}
|
|
85
89
|
getDevDependencies(workspaceName) {
|
|
@@ -122,10 +126,7 @@ export class DependencyDeputy {
|
|
|
122
126
|
return this.hostDependencies.get(workspaceName)?.get(dependency) ?? [];
|
|
123
127
|
}
|
|
124
128
|
getOptionalPeerDependencies(workspaceName) {
|
|
125
|
-
|
|
126
|
-
if (!manifest)
|
|
127
|
-
return [];
|
|
128
|
-
return manifest.optionalPeerDependencies;
|
|
129
|
+
return this._manifests.get(workspaceName)?.optionalPeerDependencies ?? new Set();
|
|
129
130
|
}
|
|
130
131
|
maybeAddReferencedExternalDependency(workspace, packageName) {
|
|
131
132
|
if (!this.isReportDependencies)
|
|
@@ -227,7 +228,9 @@ export class DependencyDeputy {
|
|
|
227
228
|
const position = peeker.getLocation('devDependencies', symbol);
|
|
228
229
|
devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, fixes: [], ...position });
|
|
229
230
|
}
|
|
230
|
-
for (const symbol of this.getOptionalPeerDependencies(workspace)
|
|
231
|
+
for (const symbol of this.getOptionalPeerDependencies(workspace)) {
|
|
232
|
+
if (!isReferencedDependency(symbol))
|
|
233
|
+
continue;
|
|
231
234
|
const pos = peeker.getLocation('optionalPeerDependencies', symbol);
|
|
232
235
|
optionalPeerDependencyIssues.push({
|
|
233
236
|
type: 'optionalPeerDependencies',
|
package/dist/IssueCollector.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { IgnoreIssues } from './types/config.js';
|
|
2
2
|
import type { ConfigurationHint, Issue, TagHint } from './types/issues.js';
|
|
3
3
|
import type { MainOptions } from './util/create-options.js';
|
|
4
|
+
import type { WorkspaceFilePathFilter } from './util/workspace-file-filter.js';
|
|
4
5
|
export type CollectorIssues = ReturnType<IssueCollector['getIssues']>;
|
|
5
6
|
export declare class IssueCollector {
|
|
6
7
|
private cwd;
|
|
7
8
|
private rules;
|
|
8
|
-
private
|
|
9
|
+
private workspaceFilter;
|
|
9
10
|
private issues;
|
|
10
11
|
private counters;
|
|
11
12
|
private referencedFiles;
|
|
@@ -17,6 +18,7 @@ export declare class IssueCollector {
|
|
|
17
18
|
private isFileMatch;
|
|
18
19
|
private issueMatchers;
|
|
19
20
|
constructor(options: MainOptions);
|
|
21
|
+
setWorkspaceFilter(workspaceFilePathFilter: WorkspaceFilePathFilter | undefined): void;
|
|
20
22
|
addIgnorePatterns(patterns: string[]): void;
|
|
21
23
|
addIgnoreFilesPatterns(patterns: string[]): void;
|
|
22
24
|
setIgnoreIssues(ignoreIssues?: IgnoreIssues): void;
|
package/dist/IssueCollector.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import picomatch from 'picomatch';
|
|
2
2
|
import { partition } from './util/array.js';
|
|
3
3
|
import { initCounters, initIssues } from './util/issue-initializers.js';
|
|
4
|
-
import {
|
|
4
|
+
import { relative } from './util/path.js';
|
|
5
5
|
const createMatcher = (patterns) => {
|
|
6
6
|
const [negated, positive] = partition(patterns, p => p[0] === '!');
|
|
7
7
|
if (positive.length === 0) {
|
|
@@ -14,7 +14,7 @@ const createMatcher = (patterns) => {
|
|
|
14
14
|
export class IssueCollector {
|
|
15
15
|
cwd;
|
|
16
16
|
rules;
|
|
17
|
-
|
|
17
|
+
workspaceFilter;
|
|
18
18
|
issues = initIssues();
|
|
19
19
|
counters = initCounters();
|
|
20
20
|
referencedFiles = new Set();
|
|
@@ -28,10 +28,14 @@ export class IssueCollector {
|
|
|
28
28
|
constructor(options) {
|
|
29
29
|
this.cwd = options.cwd;
|
|
30
30
|
this.rules = options.rules;
|
|
31
|
-
this.
|
|
31
|
+
this.workspaceFilter = () => true;
|
|
32
32
|
this.isMatch = () => false;
|
|
33
33
|
this.isFileMatch = () => false;
|
|
34
34
|
}
|
|
35
|
+
setWorkspaceFilter(workspaceFilePathFilter) {
|
|
36
|
+
if (workspaceFilePathFilter)
|
|
37
|
+
this.workspaceFilter = workspaceFilePathFilter;
|
|
38
|
+
}
|
|
35
39
|
addIgnorePatterns(patterns) {
|
|
36
40
|
for (const pattern of patterns)
|
|
37
41
|
this.ignorePatterns.add(pattern);
|
|
@@ -71,7 +75,7 @@ export class IssueCollector {
|
|
|
71
75
|
}
|
|
72
76
|
addFilesIssues(filePaths) {
|
|
73
77
|
for (const filePath of filePaths) {
|
|
74
|
-
if (this.
|
|
78
|
+
if (!this.workspaceFilter(filePath))
|
|
75
79
|
continue;
|
|
76
80
|
if (this.referencedFiles.has(filePath))
|
|
77
81
|
continue;
|
|
@@ -89,7 +93,7 @@ export class IssueCollector {
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
addIssue(issue) {
|
|
92
|
-
if (this.
|
|
96
|
+
if (!this.workspaceFilter(issue.filePath))
|
|
93
97
|
return;
|
|
94
98
|
if (this.isMatch(issue.filePath))
|
|
95
99
|
return;
|
|
@@ -3,7 +3,7 @@ import { toEntry } from '../../util/input.js';
|
|
|
3
3
|
import { isAbsolute, join } from '../../util/path.js';
|
|
4
4
|
import { _resolveSync } from '../../util/resolve.js';
|
|
5
5
|
import { resolveX } from './bunx.js';
|
|
6
|
-
const commands = [
|
|
6
|
+
const commands = new Set([
|
|
7
7
|
'add',
|
|
8
8
|
'audit',
|
|
9
9
|
'auth',
|
|
@@ -49,7 +49,7 @@ const commands = [
|
|
|
49
49
|
'whoami',
|
|
50
50
|
'why',
|
|
51
51
|
'x',
|
|
52
|
-
];
|
|
52
|
+
]);
|
|
53
53
|
export const resolve = (_binary, args, options) => {
|
|
54
54
|
const parsed = parseArgs(args, { string: ['cwd'] });
|
|
55
55
|
const [command, script] = parsed._;
|
|
@@ -64,7 +64,7 @@ export const resolve = (_binary, args, options) => {
|
|
|
64
64
|
return [];
|
|
65
65
|
if (command === 'test')
|
|
66
66
|
return parsed._.filter(id => id !== command).map(toEntry);
|
|
67
|
-
if (command !== 'run' && commands.
|
|
67
|
+
if (command !== 'run' && commands.has(command))
|
|
68
68
|
return [];
|
|
69
69
|
const filePath = command === 'run' ? script : command;
|
|
70
70
|
if (!filePath)
|
package/dist/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const main = async () => {
|
|
|
32
32
|
}
|
|
33
33
|
const options = await createOptions({ args });
|
|
34
34
|
const { results } = await run(options);
|
|
35
|
-
const { issues, counters, tagHints, configurationHints, includedWorkspaceDirs, enabledPlugins } = results;
|
|
35
|
+
const { issues, counters, tagHints, configurationHints, includedWorkspaceDirs, enabledPlugins, selectedWorkspaces, } = results;
|
|
36
36
|
if (options.isWatch || options.isTrace)
|
|
37
37
|
return;
|
|
38
38
|
const initialData = {
|
|
@@ -52,6 +52,7 @@ const main = async () => {
|
|
|
52
52
|
maxShowIssues: args['max-show-issues'] ? Number(args['max-show-issues']) : undefined,
|
|
53
53
|
options: args['reporter-options'] ?? '',
|
|
54
54
|
preprocessorOptions: args['preprocessor-options'] ?? '',
|
|
55
|
+
selectedWorkspaces,
|
|
55
56
|
};
|
|
56
57
|
const finalData = await runPreprocessors(args.preprocessor ?? [], initialData);
|
|
57
58
|
if (options.isFix)
|
|
@@ -2,7 +2,7 @@ import type { RawConfiguration } from '../types/config.js';
|
|
|
2
2
|
import type { DependencySet } from '../types/workspace.js';
|
|
3
3
|
import type { AsyncCompilerFn, AsyncCompilers, RawSyncCompilers, SyncCompilerFn, SyncCompilers } from './types.js';
|
|
4
4
|
export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
5
|
-
syncCompilers: Record<string, SyncCompilerFn>;
|
|
5
|
+
syncCompilers: Record<string, true | SyncCompilerFn>;
|
|
6
6
|
asyncCompilers: Record<string, AsyncCompilerFn>;
|
|
7
7
|
angular?: string | boolean | string[] | {
|
|
8
8
|
config?: string | string[] | undefined;
|
|
@@ -19,6 +19,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
19
19
|
entry?: string | string[] | undefined;
|
|
20
20
|
project?: string | string[] | undefined;
|
|
21
21
|
} | undefined;
|
|
22
|
+
'astro-og-canvas'?: string | boolean | string[] | {
|
|
23
|
+
config?: string | string[] | undefined;
|
|
24
|
+
entry?: string | string[] | undefined;
|
|
25
|
+
project?: string | string[] | undefined;
|
|
26
|
+
} | undefined;
|
|
22
27
|
ava?: string | boolean | string[] | {
|
|
23
28
|
config?: string | string[] | undefined;
|
|
24
29
|
entry?: string | string[] | undefined;
|
|
@@ -294,6 +299,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
294
299
|
entry?: string | string[] | undefined;
|
|
295
300
|
project?: string | string[] | undefined;
|
|
296
301
|
} | undefined;
|
|
302
|
+
nitro?: string | boolean | string[] | {
|
|
303
|
+
config?: string | string[] | undefined;
|
|
304
|
+
entry?: string | string[] | undefined;
|
|
305
|
+
project?: string | string[] | undefined;
|
|
306
|
+
} | undefined;
|
|
297
307
|
node?: string | boolean | string[] | {
|
|
298
308
|
config?: string | string[] | undefined;
|
|
299
309
|
entry?: string | string[] | undefined;
|
|
@@ -655,6 +665,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
655
665
|
entry?: string | string[] | undefined;
|
|
656
666
|
project?: string | string[] | undefined;
|
|
657
667
|
} | undefined;
|
|
668
|
+
'astro-og-canvas'?: string | boolean | string[] | {
|
|
669
|
+
config?: string | string[] | undefined;
|
|
670
|
+
entry?: string | string[] | undefined;
|
|
671
|
+
project?: string | string[] | undefined;
|
|
672
|
+
} | undefined;
|
|
658
673
|
ava?: string | boolean | string[] | {
|
|
659
674
|
config?: string | string[] | undefined;
|
|
660
675
|
entry?: string | string[] | undefined;
|
|
@@ -930,6 +945,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
930
945
|
entry?: string | string[] | undefined;
|
|
931
946
|
project?: string | string[] | undefined;
|
|
932
947
|
} | undefined;
|
|
948
|
+
nitro?: string | boolean | string[] | {
|
|
949
|
+
config?: string | string[] | undefined;
|
|
950
|
+
entry?: string | string[] | undefined;
|
|
951
|
+
project?: string | string[] | undefined;
|
|
952
|
+
} | undefined;
|
|
933
953
|
node?: string | boolean | string[] | {
|
|
934
954
|
config?: string | string[] | undefined;
|
|
935
955
|
entry?: string | string[] | undefined;
|
package/dist/compilers/index.js
CHANGED
|
@@ -22,6 +22,9 @@ export const partitionCompilers = (rawLocalConfig) => {
|
|
|
22
22
|
syncCompilers[ext] = compilerFn;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
else if (compilerFn === true) {
|
|
26
|
+
syncCompilers[ext] = true;
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
for (const extension in rawLocalConfig.asyncCompilers) {
|
|
27
30
|
const ext = normalizeExt(extension);
|
package/dist/graph/analyze.js
CHANGED
|
@@ -234,7 +234,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
234
234
|
collector.addConfigurationHint(hint);
|
|
235
235
|
};
|
|
236
236
|
await analyzeGraph();
|
|
237
|
-
if (options.isTrace)
|
|
238
|
-
traceReporter({ graph, explorer, options });
|
|
237
|
+
if (options.isTrace) {
|
|
238
|
+
traceReporter({ graph, explorer, options, workspaceFilePathFilter: chief.workspaceFilePathFilter });
|
|
239
|
+
}
|
|
239
240
|
return analyzeGraph;
|
|
240
241
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const main: (options: MainOptions) => Promise<{
|
|
|
4
4
|
counters: import("./types/issues.js").Counters;
|
|
5
5
|
tagHints: Set<import("./types/issues.js").TagHint>;
|
|
6
6
|
configurationHints: import("./types/issues.js").ConfigurationHint[];
|
|
7
|
+
selectedWorkspaces: string[] | undefined;
|
|
7
8
|
includedWorkspaceDirs: string[];
|
|
8
9
|
enabledPlugins: {
|
|
9
10
|
[k: string]: string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toDependency } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
const title = 'astro-og-canvas';
|
|
4
|
+
const enablers = ['astro-og-canvas'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const resolve = async () => {
|
|
7
|
+
return [toDependency('canvaskit-wasm', { optional: true })];
|
|
8
|
+
};
|
|
9
|
+
const plugin = {
|
|
10
|
+
title,
|
|
11
|
+
enablers,
|
|
12
|
+
isEnabled,
|
|
13
|
+
resolve,
|
|
14
|
+
};
|
|
15
|
+
export default plugin;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { isFile } from '../../util/fs.js';
|
|
2
2
|
import { toDependency } from '../../util/input.js';
|
|
3
|
-
import { join } from '../../util/path.js';
|
|
4
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
4
|
const title = 'Capacitor';
|
|
6
5
|
const enablers = [/^@capacitor\//];
|
|
7
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
7
|
const config = ['capacitor.config.{json,ts}'];
|
|
9
8
|
const resolveConfig = async (config, { configFileDir }) => {
|
|
10
|
-
const exists = (filePath) => isFile(join(configFileDir, filePath));
|
|
11
9
|
const plugins = config.includePlugins ?? [];
|
|
12
|
-
const android = (
|
|
13
|
-
const ios = (
|
|
10
|
+
const android = isFile(configFileDir, 'android/capacitor.settings.gradle') ? ['@capacitor/android'] : [];
|
|
11
|
+
const ios = isFile(configFileDir, 'ios/App/Podfile') ? ['@capacitor/ios'] : [];
|
|
14
12
|
return [...plugins, ...android, ...ios].map(id => toDependency(id));
|
|
15
13
|
};
|
|
16
14
|
const plugin = {
|
|
@@ -21,7 +21,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
21
21
|
const copiedEntries = new Set();
|
|
22
22
|
const copiedPackages = new Set();
|
|
23
23
|
for (const path of Object.keys(dummyUserConfig.passthroughCopies)) {
|
|
24
|
-
const isDir = !path.includes('*') && isDirectory(
|
|
24
|
+
const isDir = !path.includes('*') && isDirectory(configFileDir, path);
|
|
25
25
|
if (isDir) {
|
|
26
26
|
copiedEntries.add(join(path, `**/*.{${exts}}`));
|
|
27
27
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasFilesWithExtensions } from '../../util/fs.js';
|
|
2
2
|
import { isDeferResolveEntry, toEntry } from '../../util/input.js';
|
|
3
3
|
import { findByKeyDeep } from '../../util/object.js';
|
|
4
4
|
import { join, relative } from '../../util/path.js';
|
|
5
5
|
const title = 'GitHub Actions';
|
|
6
6
|
const enablers = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
|
|
7
|
-
const isEnabled =
|
|
7
|
+
const isEnabled = ({ cwd }) => {
|
|
8
|
+
return hasFilesWithExtensions(cwd, '.github/workflows', ['yml', 'yaml']);
|
|
9
|
+
};
|
|
8
10
|
const isRootOnly = true;
|
|
9
11
|
const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
|
|
10
12
|
const isString = (value) => typeof value === 'string';
|