knip 5.26.0 → 5.27.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/CacheConsultant.d.ts +8 -2
- package/dist/CacheConsultant.js +9 -16
- package/dist/ConfigurationChief.d.ts +11 -4
- package/dist/ConfigurationChief.js +22 -21
- package/dist/ConfigurationValidator.d.ts +224 -0
- package/dist/ConfigurationValidator.js +4 -0
- package/dist/DependencyDeputy.d.ts +3 -2
- package/dist/DependencyDeputy.js +4 -4
- package/dist/PrincipalFactory.d.ts +4 -0
- package/dist/ProjectPrincipal.d.ts +5 -4
- package/dist/ProjectPrincipal.js +8 -6
- package/dist/WorkspaceWorker.d.ts +5 -3
- package/dist/WorkspaceWorker.js +2 -2
- package/dist/binaries/resolvers/bun.js +1 -1
- package/dist/cli.js +23 -12
- package/dist/compilers/index.d.ts +40 -0
- package/dist/index.js +55 -134
- package/dist/plugins/babel/index.js +2 -1
- package/dist/plugins/babel/types.d.ts +1 -0
- package/dist/plugins/cypress/helpers.d.ts +3 -0
- package/dist/plugins/cypress/helpers.js +23 -0
- package/dist/plugins/cypress/index.d.ts +3 -1
- package/dist/plugins/cypress/index.js +5 -0
- package/dist/plugins/cypress/types.d.ts +6 -0
- package/dist/plugins/cypress/types.js +1 -0
- package/dist/plugins/husky/index.d.ts +1 -1
- package/dist/plugins/husky/index.js +9 -2
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/ladle/index.d.ts +13 -0
- package/dist/plugins/ladle/index.js +36 -0
- package/dist/plugins/ladle/types.d.ts +4 -0
- package/dist/plugins/ladle/types.js +1 -0
- package/dist/plugins/react-cosmos/index.d.ts +12 -0
- package/dist/plugins/react-cosmos/index.js +33 -0
- package/dist/plugins/react-cosmos/types.d.ts +5 -0
- package/dist/plugins/react-cosmos/types.js +1 -0
- package/dist/plugins/rsbuild/index.d.ts +10 -0
- package/dist/plugins/rsbuild/index.js +15 -0
- package/dist/plugins/rsbuild/types.d.ts +3 -0
- package/dist/plugins/rsbuild/types.js +1 -0
- package/dist/plugins/rspack/index.d.ts +10 -0
- package/dist/plugins/rspack/index.js +22 -0
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/types/cli.d.ts +16 -9
- package/dist/typescript/{createHosts.js → create-hosts.js} +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importCall.js +13 -15
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/create-workspace-graph.d.ts +8 -0
- package/dist/util/{pkgs-graph.js → create-workspace-graph.js} +3 -3
- package/dist/util/dependency-graph.d.ts +3 -4
- package/dist/util/dependency-graph.js +35 -3
- package/dist/util/get-included-issue-types.d.ts +6 -6
- package/dist/util/get-included-issue-types.js +5 -5
- package/dist/util/globby.js +2 -2
- package/dist/util/handle-dependency.d.ts +1 -1
- package/dist/util/handle-dependency.js +1 -1
- package/dist/util/reporter.d.ts +2 -2
- package/dist/util/reporter.js +12 -10
- package/dist/util/to-source-path.d.ts +2 -2
- package/dist/util/watch.d.ts +25 -0
- package/dist/util/watch.js +85 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +16 -0
- package/dist/util/pkgs-graph.d.ts +0 -8
- /package/dist/typescript/{createHosts.d.ts → create-hosts.d.ts} +0 -0
- /package/dist/typescript/{getImportsAndExports.d.ts → get-imports-and-exports.d.ts} +0 -0
- /package/dist/typescript/{getImportsAndExports.js → get-imports-and-exports.js} +0 -0
- /package/dist/typescript/{resolveModuleNames.d.ts → resolve-module-names.d.ts} +0 -0
- /package/dist/typescript/{resolveModuleNames.js → resolve-module-names.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { watch } from 'node:fs';
|
|
2
|
-
import { CacheConsultant } from './CacheConsultant.js';
|
|
3
2
|
import { ConfigurationChief } from './ConfigurationChief.js';
|
|
4
3
|
import { ConsoleStreamer } from './ConsoleStreamer.js';
|
|
5
4
|
import { DependencyDeputy } from './DependencyDeputy.js';
|
|
@@ -10,35 +9,38 @@ import { WorkspaceWorker } from './WorkspaceWorker.js';
|
|
|
10
9
|
import { _getDependenciesFromScripts } from './binaries/index.js';
|
|
11
10
|
import { getCompilerExtensions, getIncludedCompilers } from './compilers/index.js';
|
|
12
11
|
import { getFilteredScripts } from './manifest/helpers.js';
|
|
13
|
-
import watchReporter from './reporters/watch.js';
|
|
14
12
|
import { debugLog, debugLogArray, debugLogObject } from './util/debug.js';
|
|
15
|
-
import {
|
|
16
|
-
import { isFile } from './util/fs.js';
|
|
13
|
+
import { getOrCreateFileNode, updateImportMap } from './util/dependency-graph.js';
|
|
17
14
|
import { _glob, negate } from './util/glob.js';
|
|
18
15
|
import { getGitIgnoredHandler } from './util/globby.js';
|
|
19
|
-
import {
|
|
16
|
+
import { getReferencedDependencyHandler } from './util/handle-dependency.js';
|
|
20
17
|
import { getHasStrictlyNsReferences, getType } from './util/has-strictly-ns-references.js';
|
|
21
18
|
import { getIsIdentifierReferencedHandler } from './util/is-identifier-referenced.js';
|
|
22
19
|
import { getEntryPathFromManifest, getPackageNameFromModuleSpecifier } from './util/modules.js';
|
|
23
|
-
import { dirname, join
|
|
20
|
+
import { dirname, join } from './util/path.js';
|
|
24
21
|
import { findMatch } from './util/regex.js';
|
|
25
22
|
import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from './util/tag.js';
|
|
26
23
|
import { augmentWorkspace, getToSourcePathHandler } from './util/to-source-path.js';
|
|
27
24
|
import { createAndPrintTrace, printTrace } from './util/trace.js';
|
|
28
25
|
import { loadTSConfig } from './util/tsconfig-loader.js';
|
|
26
|
+
import { getWatchHandler } from './util/watch.js';
|
|
29
27
|
export const main = async (unresolvedConfiguration) => {
|
|
30
|
-
const { cwd,
|
|
28
|
+
const { cacheLocation, cwd, excludedIssueTypes, fixTypes, gitignore, includedIssueTypes, isCache, isDebug, isDependenciesShorthand, isExportsShorthand, isFilesShorthand, isFix, isHideConfigHints, isIncludeEntryExports, isIncludeLibs, isIsolateWorkspaces, isProduction, isRemoveFiles, isShowProgress, isStrict, isWatch, tags, tsConfigFile, workspace, } = unresolvedConfiguration;
|
|
31
29
|
debugLogObject('*', 'Unresolved configuration (from CLI arguments)', unresolvedConfiguration);
|
|
32
|
-
const chief = new ConfigurationChief({ cwd, isProduction, isStrict, isIncludeEntryExports });
|
|
30
|
+
const chief = new ConfigurationChief({ cwd, isProduction, isStrict, isIncludeEntryExports, workspace });
|
|
33
31
|
const deputy = new DependencyDeputy({ isProduction, isStrict });
|
|
34
32
|
const factory = new PrincipalFactory();
|
|
35
33
|
const streamer = new ConsoleStreamer({ isEnabled: isShowProgress });
|
|
36
|
-
const isGitIgnored = await getGitIgnoredHandler({ cwd, gitignore });
|
|
37
|
-
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
38
34
|
streamer.cast('Reading workspace configuration(s)...');
|
|
39
35
|
await chief.init();
|
|
40
36
|
const workspaces = chief.getIncludedWorkspaces();
|
|
41
|
-
const report = chief.getIncludedIssueTypes(
|
|
37
|
+
const report = chief.getIncludedIssueTypes({
|
|
38
|
+
includedIssueTypes,
|
|
39
|
+
excludedIssueTypes,
|
|
40
|
+
isDependenciesShorthand,
|
|
41
|
+
isExportsShorthand,
|
|
42
|
+
isFilesShorthand,
|
|
43
|
+
});
|
|
42
44
|
const rules = chief.getRules();
|
|
43
45
|
const filters = chief.getFilters();
|
|
44
46
|
const fixer = new IssueFixer({ isEnabled: isFix, cwd, fixTypes, isRemoveFiles });
|
|
@@ -53,6 +55,11 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
53
55
|
const o = () => workspaces.map(w => ({ pkgName: w.pkgName, name: w.name, config: w.config, ancestors: w.ancestors }));
|
|
54
56
|
debugLogObject('*', 'Included workspaces', () => workspaces.map(w => w.pkgName));
|
|
55
57
|
debugLogObject('*', 'Included workspace configs', o);
|
|
58
|
+
const isGitIgnored = await getGitIgnoredHandler({ cwd, gitignore });
|
|
59
|
+
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
60
|
+
const handleReferencedDependency = getReferencedDependencyHandler(collector, deputy, chief);
|
|
61
|
+
const shouldIgnore = getShouldIgnoreHandler(isProduction);
|
|
62
|
+
const shouldIgnoreTags = getShouldIgnoreTagHandler(tags);
|
|
56
63
|
for (const workspace of workspaces) {
|
|
57
64
|
const { name, dir, ancestors, pkgName, manifestPath } = workspace;
|
|
58
65
|
streamer.cast(`Analyzing workspace ${name}...`);
|
|
@@ -81,6 +88,9 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
81
88
|
isIsolateWorkspaces,
|
|
82
89
|
isSkipLibs,
|
|
83
90
|
isWatch,
|
|
91
|
+
toSourceFilePath,
|
|
92
|
+
isCache,
|
|
93
|
+
cacheLocation,
|
|
84
94
|
});
|
|
85
95
|
const worker = new WorkspaceWorker({
|
|
86
96
|
name,
|
|
@@ -94,6 +104,8 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
94
104
|
rootIgnore: chief.config.ignore,
|
|
95
105
|
negatedWorkspacePatterns: chief.getNegatedWorkspacePatterns(name),
|
|
96
106
|
enabledPluginsInAncestors: ancestors.flatMap(ancestor => enabledPluginsStore.get(ancestor) ?? []),
|
|
107
|
+
isCache,
|
|
108
|
+
cacheLocation,
|
|
97
109
|
});
|
|
98
110
|
await worker.init();
|
|
99
111
|
principal.addEntryPaths(definitionPaths);
|
|
@@ -177,39 +189,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
177
189
|
const analyzedFiles = new Set();
|
|
178
190
|
const unreferencedFiles = new Set();
|
|
179
191
|
const entryPaths = new Set();
|
|
180
|
-
const
|
|
181
|
-
const handleReferencedDependency = getHandler(collector, deputy, chief);
|
|
182
|
-
const updateImportDetails = (importedModule, importItems) => {
|
|
183
|
-
for (const id of importItems.refs)
|
|
184
|
-
importedModule.refs.add(id);
|
|
185
|
-
for (const [id, v] of importItems.imported.entries())
|
|
186
|
-
addValues(importedModule.imported, id, v);
|
|
187
|
-
for (const [id, v] of importItems.importedAs.entries())
|
|
188
|
-
addNsValues(importedModule.importedAs, id, v);
|
|
189
|
-
for (const [id, v] of importItems.importedNs.entries())
|
|
190
|
-
addValues(importedModule.importedNs, id, v);
|
|
191
|
-
for (const [id, v] of importItems.reExported.entries())
|
|
192
|
-
addValues(importedModule.reExported, id, v);
|
|
193
|
-
for (const [id, v] of importItems.reExportedAs.entries())
|
|
194
|
-
addNsValues(importedModule.reExportedAs, id, v);
|
|
195
|
-
for (const [id, v] of importItems.reExportedNs.entries())
|
|
196
|
-
addValues(importedModule.reExportedNs, id, v);
|
|
197
|
-
};
|
|
198
|
-
const updateImportMap = (file, importMap) => {
|
|
199
|
-
for (const [importedFilePath, importDetails] of importMap.entries()) {
|
|
200
|
-
const importedFileImports = file.imports.internal.get(importedFilePath);
|
|
201
|
-
if (!importedFileImports)
|
|
202
|
-
file.imports.internal.set(importedFilePath, importDetails);
|
|
203
|
-
else
|
|
204
|
-
updateImportDetails(importedFileImports, importDetails);
|
|
205
|
-
const importedFile = getFileNode(importedFilePath);
|
|
206
|
-
if (!importedFile.imported)
|
|
207
|
-
importedFile.imported = importDetails;
|
|
208
|
-
else
|
|
209
|
-
updateImportDetails(importedFile.imported, importDetails);
|
|
210
|
-
graph.set(importedFilePath, importedFile);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
192
|
+
const isIdentifierReferenced = getIsIdentifierReferencedHandler(graph, entryPaths);
|
|
213
193
|
const isPackageNameInternalWorkspace = (packageName) => chief.availableWorkspacePkgNames.has(packageName);
|
|
214
194
|
const getPrincipalByFilePath = (filePath) => {
|
|
215
195
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
@@ -230,12 +210,12 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
230
210
|
isReportClassMembers,
|
|
231
211
|
tags,
|
|
232
212
|
}, isGitIgnored, isPackageNameInternalWorkspace, getPrincipalByFilePath);
|
|
233
|
-
const file =
|
|
213
|
+
const file = getOrCreateFileNode(graph, filePath);
|
|
234
214
|
file.imports = imports;
|
|
235
215
|
file.exports = exports;
|
|
236
216
|
file.scripts = scripts;
|
|
237
217
|
file.traceRefs = traceRefs;
|
|
238
|
-
updateImportMap(file, imports.internal);
|
|
218
|
+
updateImportMap(file, imports.internal, graph);
|
|
239
219
|
file.internalImportCache = imports.internal;
|
|
240
220
|
graph.set(filePath, file);
|
|
241
221
|
if (scripts && scripts.size > 0) {
|
|
@@ -252,12 +232,12 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
252
232
|
}
|
|
253
233
|
};
|
|
254
234
|
for (const principal of principals) {
|
|
255
|
-
principal.init(
|
|
235
|
+
principal.init();
|
|
256
236
|
for (const [containingFilePath, specifier, workspaceName] of principal.referencedDependencies) {
|
|
257
237
|
const workspace = chief.findWorkspaceByName(workspaceName);
|
|
258
238
|
if (workspace) {
|
|
259
239
|
const specifierFilePath = handleReferencedDependency(specifier, containingFilePath, workspace);
|
|
260
|
-
if (specifierFilePath)
|
|
240
|
+
if (specifierFilePath && !isGitIgnored(specifierFilePath))
|
|
261
241
|
principal.addEntryPath(specifierFilePath);
|
|
262
242
|
}
|
|
263
243
|
}
|
|
@@ -285,16 +265,13 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
285
265
|
if (isIsolateWorkspaces)
|
|
286
266
|
for (const principal of principals)
|
|
287
267
|
factory.deletePrincipal(principal);
|
|
288
|
-
const shouldIgnore = getShouldIgnoreHandler(isProduction);
|
|
289
|
-
const shouldIgnoreTags = getShouldIgnoreTagHandler(tags);
|
|
290
|
-
const isIdentifierReferenced = getIsIdentifierReferencedHandler(graph, entryPaths);
|
|
291
268
|
const ignoreExportsUsedInFile = chief.config.ignoreExportsUsedInFile;
|
|
292
269
|
const isExportedItemReferenced = (exportedItem) => exportedItem.refs[1] ||
|
|
293
270
|
(exportedItem.refs[0] > 0 &&
|
|
294
271
|
(typeof ignoreExportsUsedInFile === 'object'
|
|
295
272
|
? exportedItem.type !== 'unknown' && !!ignoreExportsUsedInFile[exportedItem.type]
|
|
296
273
|
: ignoreExportsUsedInFile));
|
|
297
|
-
const
|
|
274
|
+
const collectUnusedExports = async () => {
|
|
298
275
|
if (isReportValues || isReportTypes) {
|
|
299
276
|
streamer.cast('Connecting the dots...');
|
|
300
277
|
for (const [filePath, file] of graph.entries()) {
|
|
@@ -472,98 +449,42 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
472
449
|
collector.addIssue(issue);
|
|
473
450
|
for (const issue of optionalPeerDependencyIssues)
|
|
474
451
|
collector.addIssue(issue);
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
452
|
+
deputy.removeIgnoredIssues(collector.getIssues());
|
|
453
|
+
if (!workspace && !isProduction && !isHideConfigHints) {
|
|
454
|
+
const configurationHints = deputy.getConfigurationHints();
|
|
455
|
+
for (const hint of configurationHints)
|
|
456
|
+
collector.addConfigurationHint(hint);
|
|
457
|
+
}
|
|
478
458
|
}
|
|
479
459
|
const unusedIgnoredWorkspaces = chief.getUnusedIgnoredWorkspaces();
|
|
480
460
|
for (const identifier of unusedIgnoredWorkspaces) {
|
|
481
461
|
collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
|
|
482
462
|
}
|
|
483
463
|
};
|
|
464
|
+
await collectUnusedExports();
|
|
465
|
+
const { issues, counters, tagHints, configurationHints } = collector.getIssues();
|
|
484
466
|
if (isWatch) {
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
principal.invalidateFile(filePath);
|
|
501
|
-
unreferencedFiles.clear();
|
|
502
|
-
const cachedUnusedFiles = collector.purge();
|
|
503
|
-
switch (event) {
|
|
504
|
-
case 'added':
|
|
505
|
-
principal.addProjectPath(filePath);
|
|
506
|
-
principal.deletedFiles.delete(filePath);
|
|
507
|
-
cachedUnusedFiles.add(filePath);
|
|
508
|
-
debugLog(workspace.name, `Watcher: + ${filename}`);
|
|
509
|
-
break;
|
|
510
|
-
case 'deleted':
|
|
511
|
-
analyzedFiles.delete(filePath);
|
|
512
|
-
principal.removeProjectPath(filePath);
|
|
513
|
-
cachedUnusedFiles.delete(filePath);
|
|
514
|
-
debugLog(workspace.name, `Watcher: - ${filename}`);
|
|
515
|
-
break;
|
|
516
|
-
case 'modified':
|
|
517
|
-
debugLog(workspace.name, `Watcher: ± ${filename}`);
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
const filePaths = principal.getUsedResolvedFiles();
|
|
521
|
-
if (event === 'added' || event === 'deleted') {
|
|
522
|
-
graph.clear();
|
|
523
|
-
for (const filePath of filePaths)
|
|
524
|
-
analyzeSourceFile(filePath, principal);
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
for (const [filePath, file] of graph) {
|
|
528
|
-
if (filePaths.includes(filePath)) {
|
|
529
|
-
file.imported = undefined;
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
graph.delete(filePath);
|
|
533
|
-
analyzedFiles.delete(filePath);
|
|
534
|
-
cachedUnusedFiles.add(filePath);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
for (const filePath of filePaths)
|
|
538
|
-
if (!graph.has(filePath))
|
|
539
|
-
analyzeSourceFile(filePath, principal);
|
|
540
|
-
if (!cachedUnusedFiles.has(filePath))
|
|
541
|
-
analyzeSourceFile(filePath, principal);
|
|
542
|
-
for (const filePath of filePaths) {
|
|
543
|
-
const file = graph.get(filePath);
|
|
544
|
-
if (file?.internalImportCache)
|
|
545
|
-
updateImportMap(file, file.internalImportCache);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
await findUnusedExports();
|
|
549
|
-
const unusedFiles = [...cachedUnusedFiles].filter(filePath => !analyzedFiles.has(filePath));
|
|
550
|
-
collector.addFilesIssues(unusedFiles);
|
|
551
|
-
collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
|
|
552
|
-
const { issues } = collector.getIssues();
|
|
553
|
-
watchReporter({ report, issues, streamer, startTime, size: analyzedFiles.size, isDebug });
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
467
|
+
const isIgnored = (filePath) => filePath.startsWith(cacheLocation) || filePath.includes('/.git/') || isGitIgnored(filePath);
|
|
468
|
+
const watchHandler = await getWatchHandler({
|
|
469
|
+
analyzedFiles,
|
|
470
|
+
analyzeSourceFile,
|
|
471
|
+
chief,
|
|
472
|
+
collector,
|
|
473
|
+
collectUnusedExports,
|
|
474
|
+
cwd,
|
|
475
|
+
factory,
|
|
476
|
+
graph,
|
|
477
|
+
isDebug,
|
|
478
|
+
isIgnored,
|
|
479
|
+
report,
|
|
480
|
+
streamer,
|
|
481
|
+
unreferencedFiles,
|
|
557
482
|
});
|
|
483
|
+
watch('.', { recursive: true }, watchHandler);
|
|
558
484
|
}
|
|
559
|
-
|
|
560
|
-
const { issues, counters, tagHints, configurationHints } = collector.getIssues();
|
|
561
|
-
if (isFix) {
|
|
485
|
+
if (isFix)
|
|
562
486
|
await fixer.fixIssues(issues);
|
|
563
|
-
|
|
564
|
-
if (isWatch)
|
|
565
|
-
watchReporter({ report, issues, streamer, size: analyzedFiles.size, isDebug });
|
|
566
|
-
else
|
|
487
|
+
if (!isWatch)
|
|
567
488
|
streamer.clear();
|
|
568
489
|
return { report, issues, counters, rules, tagHints, configurationHints };
|
|
569
490
|
};
|
|
@@ -10,7 +10,8 @@ export const getDependenciesFromConfig = (config) => {
|
|
|
10
10
|
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
|
|
11
11
|
const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
|
|
12
12
|
const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
|
|
13
|
-
|
|
13
|
+
const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependenciesFromConfig) : [];
|
|
14
|
+
return compact([...presets, ...plugins, ...nested, ...overrides]);
|
|
14
15
|
};
|
|
15
16
|
const resolveConfig = async (config) => {
|
|
16
17
|
if (typeof config === 'function')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isInternal, toAbsolute } from '#p/util/path.js';
|
|
2
|
+
import { load, resolveEntry } from '#p/util/plugin.js';
|
|
3
|
+
export const resolveDependencies = async (config, options) => {
|
|
4
|
+
const { reporter } = config;
|
|
5
|
+
const { configFileDir } = options;
|
|
6
|
+
const resolve = (specifier) => resolveEntry(options, specifier);
|
|
7
|
+
const reporters = reporter ? new Set([reporter]) : new Set();
|
|
8
|
+
if (reporter === 'cypress-multi-reporters' && config.reporterOptions?.configFile) {
|
|
9
|
+
const { configFile } = config.reporterOptions;
|
|
10
|
+
const configFilePath = toAbsolute(configFile, configFileDir);
|
|
11
|
+
if (isInternal(configFilePath)) {
|
|
12
|
+
const reporterConfig = await load(configFilePath);
|
|
13
|
+
if (typeof reporterConfig === 'object' && reporterConfig.reporterEnabled) {
|
|
14
|
+
const { reporterEnabled: reporterConcatenatedNames } = reporterConfig;
|
|
15
|
+
const reporterNames = reporterConcatenatedNames.split(',');
|
|
16
|
+
for (const reporterName of reporterNames) {
|
|
17
|
+
reporters.add(resolve(reporterName.trim()));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...reporters];
|
|
23
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
2
|
+
import type { CypressConfig } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
4
5
|
enablers: string[];
|
|
@@ -6,5 +7,6 @@ declare const _default: {
|
|
|
6
7
|
config: string[];
|
|
7
8
|
entry: string[];
|
|
8
9
|
resolveEntryPaths: ResolveEntryPaths;
|
|
10
|
+
resolveConfig: ResolveConfig<CypressConfig>;
|
|
9
11
|
};
|
|
10
12
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hasDependency } from '#p/util/plugin.js';
|
|
2
2
|
import { toEntryPattern } from '../../util/protocols.js';
|
|
3
|
+
import { resolveDependencies } from './helpers.js';
|
|
3
4
|
const title = 'Cypress';
|
|
4
5
|
const enablers = ['cypress'];
|
|
5
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -19,6 +20,9 @@ const resolveEntryPaths = async (localConfig) => {
|
|
|
19
20
|
...(supportFiles.length > 0 ? supportFiles : SUPPORT_FILE_PATTERNS),
|
|
20
21
|
].map(toEntryPattern);
|
|
21
22
|
};
|
|
23
|
+
const resolveConfig = (config, options) => {
|
|
24
|
+
return resolveDependencies(config, options);
|
|
25
|
+
};
|
|
22
26
|
export default {
|
|
23
27
|
title,
|
|
24
28
|
enablers,
|
|
@@ -26,4 +30,5 @@ export default {
|
|
|
26
30
|
config,
|
|
27
31
|
entry,
|
|
28
32
|
resolveEntryPaths,
|
|
33
|
+
resolveConfig,
|
|
29
34
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,10 +4,17 @@ const title = 'husky';
|
|
|
4
4
|
const enablers = ['husky'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const gitHookPaths = getGitHookPaths('.husky', false);
|
|
7
|
-
const config = [...gitHookPaths];
|
|
8
|
-
const resolveConfig =
|
|
7
|
+
const config = [...gitHookPaths, 'package.json'];
|
|
8
|
+
const resolveConfig = (script, options) => {
|
|
9
9
|
if (!script)
|
|
10
10
|
return [];
|
|
11
|
+
if (options.configFileName === 'package.json') {
|
|
12
|
+
const hooks = script.hooks;
|
|
13
|
+
if (hooks) {
|
|
14
|
+
const scripts = Object.values(hooks);
|
|
15
|
+
return ['husky', ...getDependenciesFromScripts(scripts, { ...options })];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
return getDependenciesFromScripts(String(script), { ...options, knownGlobalsOnly: true });
|
|
12
19
|
};
|
|
13
20
|
export default {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { default as githubActions } from './github-actions/index.js';
|
|
|
17
17
|
export { default as graphqlCodegen } from './graphql-codegen/index.js';
|
|
18
18
|
export { default as husky } from './husky/index.js';
|
|
19
19
|
export { default as jest } from './jest/index.js';
|
|
20
|
+
export { default as ladle } from './ladle/index.js';
|
|
20
21
|
export { default as lefthook } from './lefthook/index.js';
|
|
21
22
|
export { default as linthtml } from './linthtml/index.js';
|
|
22
23
|
export { default as lintStaged } from './lint-staged/index.js';
|
|
@@ -37,10 +38,13 @@ export { default as playwright } from './playwright/index.js';
|
|
|
37
38
|
export { default as playwrightCt } from './playwright-ct/index.js';
|
|
38
39
|
export { default as postcss } from './postcss/index.js';
|
|
39
40
|
export { default as prettier } from './prettier/index.js';
|
|
41
|
+
export { default as reactCosmos } from './react-cosmos/index.js';
|
|
40
42
|
export { default as releaseIt } from './release-it/index.js';
|
|
41
43
|
export { default as remark } from './remark/index.js';
|
|
42
44
|
export { default as remix } from './remix/index.js';
|
|
43
45
|
export { default as rollup } from './rollup/index.js';
|
|
46
|
+
export { default as rsbuild } from './rsbuild/index.js';
|
|
47
|
+
export { default as rspack } from './rspack/index.js';
|
|
44
48
|
export { default as semanticRelease } from './semantic-release/index.js';
|
|
45
49
|
export { default as sentry } from './sentry/index.js';
|
|
46
50
|
export { default as simpleGitHooks } from './simple-git-hooks/index.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { default as githubActions } from './github-actions/index.js';
|
|
|
17
17
|
export { default as graphqlCodegen } from './graphql-codegen/index.js';
|
|
18
18
|
export { default as husky } from './husky/index.js';
|
|
19
19
|
export { default as jest } from './jest/index.js';
|
|
20
|
+
export { default as ladle } from './ladle/index.js';
|
|
20
21
|
export { default as lefthook } from './lefthook/index.js';
|
|
21
22
|
export { default as linthtml } from './linthtml/index.js';
|
|
22
23
|
export { default as lintStaged } from './lint-staged/index.js';
|
|
@@ -37,10 +38,13 @@ export { default as playwright } from './playwright/index.js';
|
|
|
37
38
|
export { default as playwrightCt } from './playwright-ct/index.js';
|
|
38
39
|
export { default as postcss } from './postcss/index.js';
|
|
39
40
|
export { default as prettier } from './prettier/index.js';
|
|
41
|
+
export { default as reactCosmos } from './react-cosmos/index.js';
|
|
40
42
|
export { default as releaseIt } from './release-it/index.js';
|
|
41
43
|
export { default as remark } from './remark/index.js';
|
|
42
44
|
export { default as remix } from './remix/index.js';
|
|
43
45
|
export { default as rollup } from './rollup/index.js';
|
|
46
|
+
export { default as rsbuild } from './rsbuild/index.js';
|
|
47
|
+
export { default as rspack } from './rspack/index.js';
|
|
44
48
|
export { default as semanticRelease } from './semantic-release/index.js';
|
|
45
49
|
export { default as sentry } from './sentry/index.js';
|
|
46
50
|
export { default as simpleGitHooks } from './simple-git-hooks/index.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
2
|
+
import type { LadleConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: import("#p/types/config.js").IgnorePatterns;
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
entry: string[];
|
|
9
|
+
project: string[];
|
|
10
|
+
resolveEntryPaths: ResolveEntryPaths<LadleConfig>;
|
|
11
|
+
resolveConfig: ResolveConfig<LadleConfig>;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toAbsolute } from '#p/util/path.js';
|
|
2
|
+
import { hasDependency, load } from '#p/util/plugin.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
|
+
import { resolveConfig as resolveVitestConfig } from '../vitest/index.js';
|
|
5
|
+
const title = 'Ladle';
|
|
6
|
+
const enablers = ['@ladle/react'];
|
|
7
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
+
const config = ['.ladle/config.{mjs,js,ts}'];
|
|
9
|
+
const stories = ['src/**/*.stories.{js,jsx,ts,tsx,mdx}'];
|
|
10
|
+
const restEntry = ['.ladle/components.{js,jsx,ts,tsx}'];
|
|
11
|
+
const entry = [...restEntry, ...stories];
|
|
12
|
+
const project = ['.ladle/**/*.{js,jsx,ts,tsx}'];
|
|
13
|
+
const resolveEntryPaths = (localConfig, options) => {
|
|
14
|
+
const localStories = typeof localConfig.stories === 'string' ? [localConfig.stories] : localConfig.stories;
|
|
15
|
+
const viteConfig = localConfig.viteConfig ? [toAbsolute(localConfig.viteConfig, options.cwd)] : [];
|
|
16
|
+
const patterns = [...restEntry, ...(localStories ?? stories), ...viteConfig];
|
|
17
|
+
return patterns.map(toEntryPattern);
|
|
18
|
+
};
|
|
19
|
+
const resolveConfig = async (localConfig, options) => {
|
|
20
|
+
if (localConfig.viteConfig) {
|
|
21
|
+
const viteConfigPath = toAbsolute(localConfig.viteConfig, options.cwd);
|
|
22
|
+
const viteConfig = await load(viteConfigPath);
|
|
23
|
+
return resolveVitestConfig(viteConfig, options);
|
|
24
|
+
}
|
|
25
|
+
return [];
|
|
26
|
+
};
|
|
27
|
+
export default {
|
|
28
|
+
title,
|
|
29
|
+
enablers,
|
|
30
|
+
isEnabled,
|
|
31
|
+
config,
|
|
32
|
+
entry,
|
|
33
|
+
project,
|
|
34
|
+
resolveEntryPaths,
|
|
35
|
+
resolveConfig,
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
|
|
2
|
+
import type { ReactCosmosConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: import("#p/types/config.js").IgnorePatterns;
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
entry: string[];
|
|
9
|
+
resolveConfig: ResolveConfig<ReactCosmosConfig>;
|
|
10
|
+
resolveEntryPaths: ResolveEntryPaths<ReactCosmosConfig>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { hasDependency, resolveEntry } from '#p/util/plugin.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
3
|
+
import { toEntryPattern } from '../../util/protocols.js';
|
|
4
|
+
const title = 'React Cosmos';
|
|
5
|
+
const enablers = ['react-cosmos'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['cosmos.config.json'];
|
|
8
|
+
const ext = '{js,jsx,ts,tsx,md,mdx}';
|
|
9
|
+
const fixtureEntry = [`**/*.fixture.${ext}`, `__fixtures__/**/*.${ext}`, `**/fixture.${ext}`];
|
|
10
|
+
const decoratorEntry = ['**/cosmos.decorator.{jsx,tsx}'];
|
|
11
|
+
const entry = [...fixtureEntry, ...decoratorEntry];
|
|
12
|
+
const resolveEntryPaths = async (localConfig) => {
|
|
13
|
+
const { fixturesDir, fixtureFileSuffix } = localConfig;
|
|
14
|
+
const entries = [
|
|
15
|
+
join(fixturesDir ?? '__fixtures__', `**/*.${ext}`),
|
|
16
|
+
join(fixturesDir ?? '', `**/*.${fixtureFileSuffix ?? 'fixture'}.${ext}`),
|
|
17
|
+
join(fixturesDir ?? '', `**/${fixtureFileSuffix ?? 'fixture'}.${ext}`),
|
|
18
|
+
];
|
|
19
|
+
return [...entries, ...decoratorEntry].map(toEntryPattern);
|
|
20
|
+
};
|
|
21
|
+
const resolveConfig = async (localConfig, options) => {
|
|
22
|
+
const dependencies = (localConfig?.plugins ?? []).map(specifier => resolveEntry(options, specifier));
|
|
23
|
+
return [...dependencies];
|
|
24
|
+
};
|
|
25
|
+
export default {
|
|
26
|
+
title,
|
|
27
|
+
enablers,
|
|
28
|
+
isEnabled,
|
|
29
|
+
config,
|
|
30
|
+
entry,
|
|
31
|
+
resolveConfig,
|
|
32
|
+
resolveEntryPaths,
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
|
|
2
|
+
import type { RsbuildConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: import("#p/types/config.js").IgnorePatterns;
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<RsbuildConfig>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hasDependency } from '#p/util/plugin.js';
|
|
2
|
+
const title = 'Rsbuild';
|
|
3
|
+
const enablers = ['@rsbuild/core'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
6
|
+
const resolveConfig = async () => {
|
|
7
|
+
return [];
|
|
8
|
+
};
|
|
9
|
+
export default {
|
|
10
|
+
title,
|
|
11
|
+
enablers,
|
|
12
|
+
isEnabled,
|
|
13
|
+
config,
|
|
14
|
+
resolveConfig,
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
|
|
2
|
+
import type { WebpackConfig } from '../webpack/types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: import("#p/types/config.js").IgnorePatterns;
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<WebpackConfig>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|