knip 5.52.0 → 5.54.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 +1 -0
- package/dist/IssueFixer.d.ts +1 -1
- package/dist/IssueFixer.js +13 -3
- package/dist/PrincipalFactory.js +3 -17
- package/dist/ProjectPrincipal.d.ts +2 -2
- package/dist/ProjectPrincipal.js +14 -3
- package/dist/WorkspaceWorker.d.ts +0 -1
- package/dist/WorkspaceWorker.js +4 -19
- package/dist/cli.js +10 -6
- package/dist/compilers/index.d.ts +10 -0
- package/dist/graph/build.js +12 -7
- package/dist/index.js +15 -4
- package/dist/plugins/ava/index.d.ts +1 -2
- package/dist/plugins/ava/index.js +2 -7
- package/dist/plugins/bun/index.d.ts +2 -2
- package/dist/plugins/bun/index.js +2 -2
- package/dist/plugins/cucumber/index.d.ts +1 -2
- package/dist/plugins/cucumber/index.js +2 -5
- package/dist/plugins/cypress/index.d.ts +1 -2
- package/dist/plugins/cypress/index.js +6 -9
- package/dist/plugins/cypress/types.d.ts +8 -0
- package/dist/plugins/eleventy/helpers.d.ts +10 -2
- package/dist/plugins/eleventy/index.d.ts +3 -6
- package/dist/plugins/eleventy/index.js +11 -16
- package/dist/plugins/eleventy/types.d.ts +9 -7
- package/dist/plugins/expo/index.d.ts +2 -5
- package/dist/plugins/expo/index.js +4 -6
- package/dist/plugins/github-action/index.d.ts +2 -2
- package/dist/plugins/github-action/index.js +2 -2
- package/dist/plugins/index.d.ts +20 -28
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/jest/index.d.ts +1 -2
- package/dist/plugins/jest/index.js +4 -12
- package/dist/plugins/karma/index.d.ts +1 -3
- package/dist/plugins/karma/index.js +0 -10
- package/dist/plugins/ladle/index.d.ts +1 -2
- package/dist/plugins/ladle/index.js +4 -7
- package/dist/plugins/metro/index.d.ts +2 -3
- package/dist/plugins/metro/index.js +17 -14
- package/dist/plugins/mocha/index.d.ts +1 -2
- package/dist/plugins/mocha/index.js +2 -6
- package/dist/plugins/msw/index.d.ts +2 -2
- package/dist/plugins/msw/index.js +2 -2
- package/dist/plugins/netlify/index.d.ts +1 -2
- package/dist/plugins/netlify/index.js +4 -7
- package/dist/plugins/node/index.d.ts +2 -2
- package/dist/plugins/node/index.js +2 -2
- package/dist/plugins/nuxt/index.d.ts +2 -2
- package/dist/plugins/nuxt/index.js +2 -2
- package/dist/plugins/playwright/index.d.ts +1 -3
- package/dist/plugins/playwright/index.js +5 -7
- package/dist/plugins/playwright-ct/index.d.ts +0 -1
- package/dist/plugins/playwright-ct/index.js +1 -2
- package/dist/plugins/postcss/index.js +3 -1
- package/dist/plugins/preconstruct/index.d.ts +1 -1
- package/dist/plugins/preconstruct/index.js +2 -2
- package/dist/plugins/react-cosmos/index.d.ts +1 -2
- package/dist/plugins/react-cosmos/index.js +4 -6
- package/dist/plugins/react-router/index.d.ts +2 -2
- package/dist/plugins/react-router/index.js +2 -2
- package/dist/plugins/relay/index.d.ts +2 -2
- package/dist/plugins/relay/index.js +2 -2
- package/dist/plugins/rspack/index.js +2 -3
- package/dist/plugins/size-limit/index.d.ts +2 -1
- package/dist/plugins/size-limit/index.js +10 -0
- package/dist/plugins/storybook/index.d.ts +1 -2
- package/dist/plugins/storybook/index.js +2 -5
- package/dist/plugins/svelte/index.d.ts +2 -1
- package/dist/plugins/svelte/index.js +7 -0
- package/dist/plugins/svgo/index.d.ts +8 -0
- package/dist/plugins/svgo/index.js +11 -0
- package/dist/plugins/vite/index.d.ts +0 -1
- package/dist/plugins/vite/index.js +1 -2
- package/dist/plugins/vitest/index.d.ts +1 -3
- package/dist/plugins/vitest/index.js +35 -24
- package/dist/plugins/vitest/types.d.ts +12 -0
- package/dist/plugins/vue/index.js +2 -5
- package/dist/plugins/webpack/index.d.ts +1 -5
- package/dist/plugins/webpack/index.js +36 -17
- package/dist/plugins/wrangler/index.d.ts +2 -2
- package/dist/plugins/wrangler/index.js +2 -2
- package/dist/plugins.js +1 -1
- package/dist/reporters/watch.js +1 -1
- package/dist/schema/configuration.d.ts +56 -0
- package/dist/schema/plugins.d.ts +23 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/config.d.ts +0 -2
- package/dist/types/project.d.ts +0 -1
- package/dist/util/Performance.d.ts +25 -7
- package/dist/util/Performance.js +70 -34
- package/dist/util/cli-arguments.d.ts +4 -1
- package/dist/util/cli-arguments.js +7 -1
- package/dist/util/glob-core.d.ts +5 -6
- package/dist/util/glob-core.js +30 -29
- package/dist/util/input.d.ts +7 -1
- package/dist/util/input.js +7 -0
- package/dist/util/string.d.ts +1 -0
- package/dist/util/string.js +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/schema.json +4 -0
|
@@ -150,6 +150,7 @@ export declare class ConfigurationChief {
|
|
|
150
150
|
stryker?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
151
151
|
stylelint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
152
152
|
svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
153
|
+
svgo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
153
154
|
syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
154
155
|
tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
155
156
|
travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
package/dist/IssueFixer.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class IssueFixer {
|
|
|
18
18
|
constructor({ isEnabled, cwd, fixTypes, isRemoveFiles }: Fixer);
|
|
19
19
|
addUnusedTypeNode(filePath: string, fixes: Fixes | undefined): void;
|
|
20
20
|
addUnusedExportNode(filePath: string, fixes: Fixes | undefined): void;
|
|
21
|
-
fixIssues(issues: Issues): Promise<
|
|
21
|
+
fixIssues(issues: Issues): Promise<Set<string>>;
|
|
22
22
|
private markExportFixed;
|
|
23
23
|
private removeUnusedFiles;
|
|
24
24
|
private removeUnusedExports;
|
package/dist/IssueFixer.js
CHANGED
|
@@ -38,9 +38,13 @@ export class IssueFixer {
|
|
|
38
38
|
this.unusedExportNodes.set(filePath, new Set(fixes));
|
|
39
39
|
}
|
|
40
40
|
async fixIssues(issues) {
|
|
41
|
+
const touchedFiles = new Set();
|
|
41
42
|
await this.removeUnusedFiles(issues);
|
|
42
|
-
await this.removeUnusedExports(issues)
|
|
43
|
-
|
|
43
|
+
for (const filePath of await this.removeUnusedExports(issues))
|
|
44
|
+
touchedFiles.add(filePath);
|
|
45
|
+
for (const filePath of await this.removeUnusedDependencies(issues))
|
|
46
|
+
touchedFiles.add(filePath);
|
|
47
|
+
return touchedFiles;
|
|
44
48
|
}
|
|
45
49
|
markExportFixed(issues, filePath) {
|
|
46
50
|
const relPath = relative(filePath);
|
|
@@ -63,6 +67,7 @@ export class IssueFixer {
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
async removeUnusedExports(issues) {
|
|
70
|
+
const touchedFiles = new Set();
|
|
66
71
|
const filePaths = new Set([...this.unusedTypeNodes.keys(), ...this.unusedExportNodes.keys()]);
|
|
67
72
|
for (const filePath of filePaths) {
|
|
68
73
|
const types = (this.isFixUnusedTypes && this.unusedTypeNodes.get(filePath)) || [];
|
|
@@ -71,13 +76,16 @@ export class IssueFixer {
|
|
|
71
76
|
if (exportPositions.length > 0) {
|
|
72
77
|
const sourceFileText = exportPositions.reduce((text, [start, end, flags]) => removeExport({ text, start, end, flags }), await readFile(filePath, 'utf-8'));
|
|
73
78
|
await writeFile(filePath, sourceFileText);
|
|
79
|
+
touchedFiles.add(filePath);
|
|
74
80
|
this.markExportFixed(issues, filePath);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
83
|
+
return touchedFiles;
|
|
77
84
|
}
|
|
78
85
|
async removeUnusedDependencies(issues) {
|
|
86
|
+
const touchedFiles = new Set();
|
|
79
87
|
if (!this.isFixDependencies)
|
|
80
|
-
return;
|
|
88
|
+
return touchedFiles;
|
|
81
89
|
const filePaths = new Set([...Object.keys(issues.dependencies), ...Object.keys(issues.devDependencies)]);
|
|
82
90
|
for (const filePath of filePaths) {
|
|
83
91
|
const absFilePath = join(this.cwd, filePath);
|
|
@@ -99,6 +107,8 @@ export class IssueFixer {
|
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
109
|
await save(absFilePath, pkg);
|
|
110
|
+
touchedFiles.add(filePath);
|
|
102
111
|
}
|
|
112
|
+
return touchedFiles;
|
|
103
113
|
}
|
|
104
114
|
}
|
package/dist/PrincipalFactory.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { ProjectPrincipal } from './ProjectPrincipal.js';
|
|
3
3
|
import { debugLog } from './util/debug.js';
|
|
4
|
-
import {
|
|
5
|
-
const mapToAbsolutePaths = (paths, cwd) => Object.keys(paths).reduce((result, key) => {
|
|
6
|
-
result[key] = paths[key].map(entry => toAbsolute(entry, cwd));
|
|
7
|
-
return result;
|
|
8
|
-
}, {});
|
|
9
|
-
const mergePaths = (cwd, compilerOptions, paths = {}) => {
|
|
10
|
-
const basePath = typeof compilerOptions.pathsBasePath === 'string' ? compilerOptions.pathsBasePath : cwd;
|
|
11
|
-
const compilerPaths = !compilerOptions.baseUrl && compilerOptions.paths
|
|
12
|
-
? mapToAbsolutePaths(compilerOptions.paths, basePath)
|
|
13
|
-
: compilerOptions.paths;
|
|
14
|
-
const extraPaths = mapToAbsolutePaths(paths, cwd);
|
|
15
|
-
compilerOptions.paths = { ...compilerPaths, ...extraPaths };
|
|
16
|
-
return compilerOptions;
|
|
17
|
-
};
|
|
4
|
+
import { toRelative } from './util/path.js';
|
|
18
5
|
export class PrincipalFactory {
|
|
19
6
|
principals = new Set();
|
|
20
7
|
createPrincipal(options) {
|
|
21
|
-
const { cwd, compilerOptions, isFile,
|
|
22
|
-
options.compilerOptions = mergePaths(cwd, compilerOptions, paths);
|
|
8
|
+
const { cwd, compilerOptions, isFile, pkgName, isIsolateWorkspaces, compilers } = options;
|
|
23
9
|
if (isFile && compilerOptions.module !== ts.ModuleKind.CommonJS)
|
|
24
10
|
compilerOptions.moduleResolution ??= ts.ModuleResolutionKind.Bundler;
|
|
25
11
|
const principal = this.findReusablePrincipal(compilerOptions);
|
|
@@ -48,7 +34,7 @@ export class PrincipalFactory {
|
|
|
48
34
|
principal.principal.compilerOptions.moduleResolution ??= compilerOptions.moduleResolution;
|
|
49
35
|
for (const p of Object.keys(paths ?? {}))
|
|
50
36
|
principal.pathKeys.add(p);
|
|
51
|
-
principal.principal.addPaths(paths);
|
|
37
|
+
principal.principal.addPaths(paths, cwd);
|
|
52
38
|
principal.principal.addCompilers(compilers);
|
|
53
39
|
principal.wsDirs.add(cwd);
|
|
54
40
|
principal.pkgNames.add(pkgName);
|
|
@@ -3,7 +3,7 @@ import { CacheConsultant } from './CacheConsultant.js';
|
|
|
3
3
|
import type { AsyncCompilers, SyncCompilers } from './compilers/types.js';
|
|
4
4
|
import type { GetImportsAndExportsOptions } from './types/config.js';
|
|
5
5
|
import type { Export, ExportMember, FileNode, ModuleGraph } from './types/module-graph.js';
|
|
6
|
-
import type { PrincipalOptions } from './types/project.js';
|
|
6
|
+
import type { Paths, PrincipalOptions } from './types/project.js';
|
|
7
7
|
import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
8
8
|
import type { ResolveModuleNames } from './typescript/resolve-module-names.js';
|
|
9
9
|
import type { ToSourceFilePath } from './util/to-source-path.js';
|
|
@@ -32,7 +32,7 @@ export declare class ProjectPrincipal {
|
|
|
32
32
|
findReferences?: ts.LanguageService['findReferences'];
|
|
33
33
|
constructor({ compilerOptions, cwd, compilers, isSkipLibs, isWatch, pkgName, toSourceFilePath, isCache, cacheLocation, }: PrincipalOptions);
|
|
34
34
|
init(): void;
|
|
35
|
-
addPaths(paths:
|
|
35
|
+
addPaths(paths: Paths, basePath: string): void;
|
|
36
36
|
addCompilers(compilers: [SyncCompilers, AsyncCompilers]): void;
|
|
37
37
|
private createProgram;
|
|
38
38
|
private hasAcceptedExtension;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -8,7 +8,7 @@ import { _getImportsAndExports } from './typescript/get-imports-and-exports.js';
|
|
|
8
8
|
import { timerify } from './util/Performance.js';
|
|
9
9
|
import { compact } from './util/array.js';
|
|
10
10
|
import { getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier } from './util/modules.js';
|
|
11
|
-
import { dirname, extname, isInNodeModules, join } from './util/path.js';
|
|
11
|
+
import { dirname, extname, isInNodeModules, join, toAbsolute } from './util/path.js';
|
|
12
12
|
const baseCompilerOptions = {
|
|
13
13
|
allowJs: true,
|
|
14
14
|
allowSyntheticDefaultImports: true,
|
|
@@ -78,8 +78,19 @@ export class ProjectPrincipal {
|
|
|
78
78
|
this.backend.resolveModuleNames = resolveModuleNames;
|
|
79
79
|
this.backend.languageServiceHost = languageServiceHost;
|
|
80
80
|
}
|
|
81
|
-
addPaths(paths) {
|
|
82
|
-
|
|
81
|
+
addPaths(paths, basePath) {
|
|
82
|
+
if (!paths)
|
|
83
|
+
return;
|
|
84
|
+
this.compilerOptions.paths ??= {};
|
|
85
|
+
for (const key in paths) {
|
|
86
|
+
const prefixes = paths[key].map(prefix => toAbsolute(prefix, basePath));
|
|
87
|
+
if (key in this.compilerOptions.paths) {
|
|
88
|
+
this.compilerOptions.paths[key] = compact([...this.compilerOptions.paths[key], ...prefixes]);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.compilerOptions.paths[key] = prefixes;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
83
94
|
}
|
|
84
95
|
addCompilers(compilers) {
|
|
85
96
|
this.syncCompilers = new Map([...this.syncCompilers, ...compilers[0]]);
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -235,7 +235,7 @@ export class WorkspaceWorker {
|
|
|
235
235
|
for (const id of config.entry)
|
|
236
236
|
addInput(toInput(id));
|
|
237
237
|
}
|
|
238
|
-
else if ((!plugin.
|
|
238
|
+
else if ((!plugin.resolveConfig && !plugin.resolveFromAST) ||
|
|
239
239
|
(configFilePaths.filter(path => basename(path) !== 'package.json').length === 0 &&
|
|
240
240
|
(!this.configFilesMap.get(wsName)?.get(pluginName) ||
|
|
241
241
|
this.configFilesMap.get(wsName)?.get(pluginName)?.size === 0))) {
|
|
@@ -251,9 +251,6 @@ export class WorkspaceWorker {
|
|
|
251
251
|
const fd = isManifest ? undefined : this.cache.getFileDescriptor(configFilePath);
|
|
252
252
|
if (fd?.meta?.data && !fd.changed) {
|
|
253
253
|
const data = fd.meta.data;
|
|
254
|
-
if (data.resolveEntryPaths)
|
|
255
|
-
for (const id of data.resolveEntryPaths)
|
|
256
|
-
addInput(id, configFilePath);
|
|
257
254
|
if (data.resolveConfig)
|
|
258
255
|
for (const id of data.resolveConfig)
|
|
259
256
|
addInput(id, configFilePath);
|
|
@@ -270,22 +267,10 @@ export class WorkspaceWorker {
|
|
|
270
267
|
configFileName: basename(configFilePath),
|
|
271
268
|
};
|
|
272
269
|
const cache = {};
|
|
273
|
-
let loadedConfig;
|
|
274
|
-
if (plugin.resolveEntryPaths && !seen.get(wsName)?.has(configFilePath)) {
|
|
275
|
-
if (!loadedConfig)
|
|
276
|
-
loadedConfig = await loadConfigForPlugin(configFilePath, plugin, resolveOpts, pluginName);
|
|
277
|
-
if (loadedConfig) {
|
|
278
|
-
const inputs = await plugin.resolveEntryPaths(loadedConfig, resolveOpts);
|
|
279
|
-
for (const input of inputs)
|
|
280
|
-
addInput(input, configFilePath);
|
|
281
|
-
cache.resolveEntryPaths = inputs;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
270
|
if (plugin.resolveConfig && !seen.get(wsName)?.has(configFilePath)) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const inputs = await plugin.resolveConfig(loadedConfig, resolveOpts);
|
|
271
|
+
const localConfig = await loadConfigForPlugin(configFilePath, plugin, resolveOpts, pluginName);
|
|
272
|
+
if (localConfig) {
|
|
273
|
+
const inputs = await plugin.resolveConfig(localConfig, resolveOpts);
|
|
289
274
|
for (const input of inputs)
|
|
290
275
|
addInput(input, configFilePath);
|
|
291
276
|
cache.resolveConfig = inputs;
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import prettyMilliseconds from 'pretty-ms';
|
|
2
1
|
import { main } from './index.js';
|
|
3
2
|
import { perfObserver } from './util/Performance.js';
|
|
4
3
|
import parsedArgValues, { helpText } from './util/cli-arguments.js';
|
|
@@ -6,11 +5,12 @@ import { getKnownError, isConfigurationError, isDisplayReason, isKnownError } fr
|
|
|
6
5
|
import { logError, logWarning } from './util/log.js';
|
|
7
6
|
import { cwd, join, toPosix } from './util/path.js';
|
|
8
7
|
import { runPreprocessors, runReporters } from './util/reporter.js';
|
|
8
|
+
import { prettyMilliseconds } from './util/string.js';
|
|
9
9
|
import { splitTags } from './util/tag.js';
|
|
10
10
|
import { isTrace } from './util/trace.js';
|
|
11
11
|
import { version } from './version.js';
|
|
12
12
|
const defaultCacheLocation = join(cwd, 'node_modules', '.cache', 'knip');
|
|
13
|
-
const { 'allow-remove-files': isRemoveFiles = false, cache: isCache = false, 'cache-location': cacheLocation = defaultCacheLocation, debug: isDebug = false, dependencies: isDependenciesShorthand = false, exclude: excludedIssueTypes = [], 'experimental-tags': experimentalTags = [], exports: isExportsShorthand = false, files: isFilesShorthand = false, fix: isFix = false, 'fix-type': fixTypes = [], help: isHelp, include: includedIssueTypes = [], 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, 'max-issues': maxIssues = '0', 'no-config-hints': isDisableConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace, preprocessor = [], 'preprocessor-options': preprocessorOptions = '', production: isProduction = false, reporter = ['symbols'], 'reporter-options': reporterOptions = '', strict: isStrict = false, tags = [], 'treat-config-hints-as-errors': treatConfigHintsAsErrors = false, tsConfig, version: isVersion, watch: isWatch = false, workspace: rawWorkspaceArg, } = parsedArgValues;
|
|
13
|
+
const { 'allow-remove-files': isRemoveFiles = false, cache: isCache = false, 'cache-location': cacheLocation = defaultCacheLocation, debug: isDebug = false, dependencies: isDependenciesShorthand = false, exclude: excludedIssueTypes = [], 'experimental-tags': experimentalTags = [], exports: isExportsShorthand = false, files: isFilesShorthand = false, fix: isFix = false, format: isFormat = false, 'fix-type': fixTypes = [], help: isHelp, include: includedIssueTypes = [], 'include-entry-exports': isIncludeEntryExports = false, 'include-libs': isIncludeLibs = false, 'isolate-workspaces': isIsolateWorkspaces = false, 'max-issues': maxIssues = '0', 'no-config-hints': isDisableConfigHints = false, 'no-exit-code': noExitCode = false, 'no-gitignore': isNoGitIgnore = false, 'no-progress': isNoProgress = isDebug || isTrace, preprocessor = [], 'preprocessor-options': preprocessorOptions = '', production: isProduction = false, reporter = ['symbols'], 'reporter-options': reporterOptions = '', strict: isStrict = false, tags = [], 'treat-config-hints-as-errors': treatConfigHintsAsErrors = false, tsConfig, version: isVersion, watch: isWatch = false, workspace: rawWorkspaceArg, } = parsedArgValues;
|
|
14
14
|
if (isHelp) {
|
|
15
15
|
console.log(helpText);
|
|
16
16
|
process.exit(0);
|
|
@@ -36,6 +36,7 @@ const run = async () => {
|
|
|
36
36
|
isExportsShorthand,
|
|
37
37
|
isFilesShorthand,
|
|
38
38
|
isFix: isFix || fixTypes.length > 0,
|
|
39
|
+
isFormat,
|
|
39
40
|
isDisableConfigHints,
|
|
40
41
|
isIncludeEntryExports,
|
|
41
42
|
isIncludeLibs,
|
|
@@ -70,12 +71,15 @@ const run = async () => {
|
|
|
70
71
|
const totalErrorCount = Object.keys(finalData.report)
|
|
71
72
|
.filter(reportGroup => finalData.report[reportGroup] && rules[reportGroup] === 'error')
|
|
72
73
|
.reduce((errorCount, reportGroup) => errorCount + finalData.counters[reportGroup], 0);
|
|
73
|
-
if (perfObserver.isEnabled)
|
|
74
|
+
if (perfObserver.isEnabled)
|
|
74
75
|
await perfObserver.finalize();
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (perfObserver.isPerformanceEnabled)
|
|
77
|
+
console.log(`\n${perfObserver.getPerformanceTable()}`);
|
|
78
|
+
if (perfObserver.isMemoryEnabled)
|
|
79
|
+
console.log(`\n${perfObserver.getMemoryTable()}`);
|
|
80
|
+
if (perfObserver.isEnabled) {
|
|
77
81
|
const duration = perfObserver.getCurrentDurationInMs();
|
|
78
|
-
console.log('\nTotal running time:', prettyMilliseconds(duration)
|
|
82
|
+
console.log('\nTotal running time:', prettyMilliseconds(duration));
|
|
79
83
|
perfObserver.reset();
|
|
80
84
|
}
|
|
81
85
|
if (experimentalTags.length > 0) {
|
|
@@ -399,6 +399,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
399
399
|
entry?: string | string[] | undefined;
|
|
400
400
|
project?: string | string[] | undefined;
|
|
401
401
|
} | undefined;
|
|
402
|
+
svgo?: string | boolean | string[] | {
|
|
403
|
+
config?: string | string[] | undefined;
|
|
404
|
+
entry?: string | string[] | undefined;
|
|
405
|
+
project?: string | string[] | undefined;
|
|
406
|
+
} | undefined;
|
|
402
407
|
syncpack?: string | boolean | string[] | {
|
|
403
408
|
config?: string | string[] | undefined;
|
|
404
409
|
entry?: string | string[] | undefined;
|
|
@@ -915,6 +920,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
915
920
|
entry?: string | string[] | undefined;
|
|
916
921
|
project?: string | string[] | undefined;
|
|
917
922
|
} | undefined;
|
|
923
|
+
svgo?: string | boolean | string[] | {
|
|
924
|
+
config?: string | string[] | undefined;
|
|
925
|
+
entry?: string | string[] | undefined;
|
|
926
|
+
project?: string | string[] | undefined;
|
|
927
|
+
} | undefined;
|
|
918
928
|
syncpack?: string | boolean | string[] | {
|
|
919
929
|
config?: string | string[] | undefined;
|
|
920
930
|
entry?: string | string[] | undefined;
|
package/dist/graph/build.js
CHANGED
|
@@ -2,13 +2,14 @@ import { WorkspaceWorker } from '../WorkspaceWorker.js';
|
|
|
2
2
|
import { _getInputsFromScripts } from '../binaries/index.js';
|
|
3
3
|
import { getCompilerExtensions, getIncludedCompilers } from '../compilers/index.js';
|
|
4
4
|
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
5
|
+
import { perfObserver } from '../util/Performance.js';
|
|
5
6
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
6
7
|
import { getReferencedInputsHandler } from '../util/get-referenced-inputs.js';
|
|
7
8
|
import { _glob, negate } from '../util/glob.js';
|
|
8
|
-
import { isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isProductionEntry, isProject, toProductionEntry, } from '../util/input.js';
|
|
9
|
+
import { isAlias, isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isProductionEntry, isProject, toProductionEntry, } from '../util/input.js';
|
|
9
10
|
import { getOrCreateFileNode, updateImportMap } from '../util/module-graph.js';
|
|
10
11
|
import { getEntryPathsFromManifest } from '../util/package-json.js';
|
|
11
|
-
import { dirname, isAbsolute, join, relative } from '../util/path.js';
|
|
12
|
+
import { dirname, isAbsolute, join, relative, toRelative } from '../util/path.js';
|
|
12
13
|
import {} from '../util/tag.js';
|
|
13
14
|
import { augmentWorkspace, getToSourcePathHandler, getToSourcePathsHandler } from '../util/to-source-path.js';
|
|
14
15
|
import { loadTSConfig } from '../util/tsconfig-loader.js';
|
|
@@ -28,7 +29,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
28
29
|
}
|
|
29
30
|
for (const workspace of workspaces) {
|
|
30
31
|
const { name, dir, ancestors, pkgName } = workspace;
|
|
31
|
-
streamer.cast(`Analyzing workspace ${name}...`);
|
|
32
|
+
streamer.cast(`Analyzing workspace (${name})...`);
|
|
32
33
|
const manifest = chief.getManifestForWorkspace(name);
|
|
33
34
|
if (!manifest) {
|
|
34
35
|
continue;
|
|
@@ -78,7 +79,6 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
78
79
|
}
|
|
79
80
|
const principal = factory.createPrincipal({
|
|
80
81
|
cwd: dir,
|
|
81
|
-
paths: config.paths,
|
|
82
82
|
isFile,
|
|
83
83
|
compilerOptions,
|
|
84
84
|
compilers,
|
|
@@ -90,6 +90,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
90
90
|
isCache,
|
|
91
91
|
cacheLocation,
|
|
92
92
|
});
|
|
93
|
+
principal.addPaths(config.paths, dir);
|
|
93
94
|
const inputsFromPlugins = await worker.runPlugins();
|
|
94
95
|
for (const id of inputsFromPlugins)
|
|
95
96
|
inputs.add(Object.assign(id, { skipExportsAnalysis: !id.allowIncludeExports }));
|
|
@@ -122,6 +123,9 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
122
123
|
else if (isProject(input)) {
|
|
123
124
|
projectFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
|
|
124
125
|
}
|
|
126
|
+
else if (isAlias(input)) {
|
|
127
|
+
principal.addPaths({ [input.specifier]: input.prefixes }, input.dir ?? dir);
|
|
128
|
+
}
|
|
125
129
|
else if (!isConfig(input)) {
|
|
126
130
|
const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
|
|
127
131
|
const resolvedFilePath = getReferencedInternalFilePath(input, ws);
|
|
@@ -275,7 +279,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
275
279
|
streamer.cast('Running async compilers...');
|
|
276
280
|
await principal.runAsyncCompilers();
|
|
277
281
|
}
|
|
278
|
-
streamer.cast(
|
|
282
|
+
streamer.cast(`Analyzing source files (${toRelative(principal.cwd) || '.'})...`);
|
|
279
283
|
let size = principal.entryPaths.size;
|
|
280
284
|
let round = 0;
|
|
281
285
|
do {
|
|
@@ -291,12 +295,13 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
291
295
|
for (const filePath of principal.entryPaths)
|
|
292
296
|
entryPaths.add(filePath);
|
|
293
297
|
principal.reconcileCache(graph);
|
|
294
|
-
if (
|
|
298
|
+
if (isIsolateWorkspaces || (isSkipLibs && !isWatch)) {
|
|
295
299
|
factory.deletePrincipal(principal);
|
|
296
300
|
principals[i] = undefined;
|
|
297
301
|
}
|
|
302
|
+
perfObserver.addMemoryMark(factory.principals.size);
|
|
298
303
|
}
|
|
299
|
-
if (isIsolateWorkspaces) {
|
|
304
|
+
if (!isWatch && isSkipLibs && !isIsolateWorkspaces) {
|
|
300
305
|
for (const principal of principals) {
|
|
301
306
|
if (principal)
|
|
302
307
|
factory.deletePrincipal(principal);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watch } from 'node:fs';
|
|
2
|
+
import { formatly } from 'formatly';
|
|
2
3
|
import { ConfigurationChief } from './ConfigurationChief.js';
|
|
3
4
|
import { ConsoleStreamer } from './ConsoleStreamer.js';
|
|
4
5
|
import { DependencyDeputy } from './DependencyDeputy.js';
|
|
@@ -7,11 +8,11 @@ import { IssueFixer } from './IssueFixer.js';
|
|
|
7
8
|
import { PrincipalFactory } from './PrincipalFactory.js';
|
|
8
9
|
import { analyze } from './graph/analyze.js';
|
|
9
10
|
import { build } from './graph/build.js';
|
|
10
|
-
import { debugLogObject } from './util/debug.js';
|
|
11
|
+
import { debugLogArray, debugLogObject } from './util/debug.js';
|
|
11
12
|
import { getGitIgnoredHandler } from './util/glob-core.js';
|
|
12
13
|
import { getWatchHandler } from './util/watch.js';
|
|
13
14
|
export const main = async (unresolvedConfiguration) => {
|
|
14
|
-
const { cacheLocation, cwd, excludedIssueTypes, fixTypes, gitignore, includedIssueTypes, isCache, isDebug, isDependenciesShorthand, isExportsShorthand, isFilesShorthand, isFix, isDisableConfigHints, isIncludeEntryExports, isIncludeLibs, isIsolateWorkspaces, isProduction, isRemoveFiles, isShowProgress, isStrict, isWatch, tags, tsConfigFile, workspace, } = unresolvedConfiguration;
|
|
15
|
+
const { cacheLocation, cwd, excludedIssueTypes, fixTypes, gitignore, includedIssueTypes, isCache, isDebug, isDependenciesShorthand, isExportsShorthand, isFilesShorthand, isFix, isFormat, isDisableConfigHints, isIncludeEntryExports, isIncludeLibs, isIsolateWorkspaces, isProduction, isRemoveFiles, isShowProgress, isStrict, isWatch, tags, tsConfigFile, workspace, } = unresolvedConfiguration;
|
|
15
16
|
debugLogObject('*', 'Unresolved configuration (from CLI arguments)', unresolvedConfiguration);
|
|
16
17
|
const chief = new ConfigurationChief({ cwd, isProduction, isStrict, isIncludeEntryExports, workspace });
|
|
17
18
|
const deputy = new DependencyDeputy({ isProduction, isStrict });
|
|
@@ -101,8 +102,18 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
101
102
|
});
|
|
102
103
|
watch('.', { recursive: true }, watchHandler);
|
|
103
104
|
}
|
|
104
|
-
if (isFix)
|
|
105
|
-
await fixer.fixIssues(issues);
|
|
105
|
+
if (isFix) {
|
|
106
|
+
const touchedFiles = await fixer.fixIssues(issues);
|
|
107
|
+
if (isFormat) {
|
|
108
|
+
const report = await formatly(Array.from(touchedFiles), { cwd });
|
|
109
|
+
if (report.ran && report.result.code === 0) {
|
|
110
|
+
debugLogArray('*', `Formatted files using ${report.formatter.name} (${report.formatter.runner})`, touchedFiles);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
debugLogObject('*', 'Formatting files failed', report);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
106
117
|
if (!isWatch)
|
|
107
118
|
streamer.clear();
|
|
108
119
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveConfig
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
2
|
import type { AvaConfig } from './types.js';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
@@ -6,7 +6,6 @@ declare const _default: {
|
|
|
6
6
|
isEnabled: IsPluginEnabled;
|
|
7
7
|
config: string[];
|
|
8
8
|
entry: string[];
|
|
9
|
-
resolveEntryPaths: ResolveEntryPaths<AvaConfig>;
|
|
10
9
|
resolveConfig: ResolveConfig<AvaConfig>;
|
|
11
10
|
};
|
|
12
11
|
export default _default;
|
|
@@ -16,18 +16,14 @@ const entry = [
|
|
|
16
16
|
'!**/__tests__/**/__{helper,fixture}?(s)__/**/*',
|
|
17
17
|
'!**/test?(s)/**/{helper,fixture}?(s)/**/*',
|
|
18
18
|
];
|
|
19
|
-
const resolveEntryPaths = localConfig => {
|
|
20
|
-
if (typeof localConfig === 'function')
|
|
21
|
-
localConfig = localConfig();
|
|
22
|
-
return (localConfig?.files ?? entry).map(id => toEntry(id));
|
|
23
|
-
};
|
|
24
19
|
const resolveConfig = async (localConfig, options) => {
|
|
25
20
|
if (typeof localConfig === 'function')
|
|
26
21
|
localConfig = localConfig();
|
|
22
|
+
const files = (localConfig?.files ?? entry).map(id => toEntry(id));
|
|
27
23
|
const nodeArgs = localConfig.nodeArguments ?? [];
|
|
28
24
|
const requireArgs = (localConfig.require ?? []).map(require => `--require ${require}`);
|
|
29
25
|
const fakeCommand = `node ${nodeArgs.join(' ')} ${requireArgs.join(' ')}`;
|
|
30
|
-
return options.getInputsFromScripts(fakeCommand, { knownBinsOnly: true });
|
|
26
|
+
return files.concat(options.getInputsFromScripts(fakeCommand, { knownBinsOnly: true }));
|
|
31
27
|
};
|
|
32
28
|
export default {
|
|
33
29
|
title,
|
|
@@ -35,6 +31,5 @@ export default {
|
|
|
35
31
|
isEnabled,
|
|
36
32
|
config,
|
|
37
33
|
entry,
|
|
38
|
-
resolveEntryPaths,
|
|
39
34
|
resolveConfig,
|
|
40
35
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResolveConfig } from '../../types/config.js';
|
|
2
2
|
import type { PackageJson } from '../../types/package-json.js';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
@@ -6,6 +6,6 @@ declare const _default: {
|
|
|
6
6
|
isEnabled: () => boolean;
|
|
7
7
|
config: string[];
|
|
8
8
|
packageJsonPath: (id: PackageJson) => PackageJson;
|
|
9
|
-
|
|
9
|
+
resolveConfig: ResolveConfig<PackageJson>;
|
|
10
10
|
};
|
|
11
11
|
export default _default;
|
|
@@ -5,7 +5,7 @@ const enablers = ['bun'];
|
|
|
5
5
|
const isEnabled = () => true;
|
|
6
6
|
const config = ['package.json'];
|
|
7
7
|
const packageJsonPath = (id) => id;
|
|
8
|
-
const
|
|
8
|
+
const resolveConfig = localConfig => {
|
|
9
9
|
const scripts = localConfig.scripts;
|
|
10
10
|
if (scripts) {
|
|
11
11
|
const testScripts = Object.keys(scripts).filter(script => /(?<=^|\s)bun test/.test(scripts[script]));
|
|
@@ -24,5 +24,5 @@ export default {
|
|
|
24
24
|
isEnabled,
|
|
25
25
|
config,
|
|
26
26
|
packageJsonPath,
|
|
27
|
-
|
|
27
|
+
resolveConfig,
|
|
28
28
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveConfig
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
2
|
import type { CucumberConfig } from './types.js';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
@@ -6,7 +6,6 @@ declare const _default: {
|
|
|
6
6
|
isEnabled: IsPluginEnabled;
|
|
7
7
|
config: string[];
|
|
8
8
|
entry: string[];
|
|
9
|
-
resolveEntryPaths: ResolveEntryPaths<CucumberConfig>;
|
|
10
9
|
resolveConfig: ResolveConfig<CucumberConfig>;
|
|
11
10
|
};
|
|
12
11
|
export default _default;
|
|
@@ -5,13 +5,11 @@ const enablers = ['@cucumber/cucumber'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = ['cucumber.{json,yaml,yml,js,cjs,mjs}'];
|
|
7
7
|
const entry = ['features/**/*.@(js|cjs|mjs)'];
|
|
8
|
-
const resolveEntryPaths = config => {
|
|
9
|
-
return (config?.import ? config.import : []).map(id => toEntry(id));
|
|
10
|
-
};
|
|
11
8
|
const resolveConfig = config => {
|
|
9
|
+
const imports = (config?.import ? config.import : entry).map(id => toEntry(id));
|
|
12
10
|
const formatters = config?.format ? config.format : [];
|
|
13
11
|
const requires = config?.require ? config.require : [];
|
|
14
|
-
return [...formatters, ...requires].map(toDeferResolve);
|
|
12
|
+
return imports.concat([...formatters, ...requires].map(toDeferResolve));
|
|
15
13
|
};
|
|
16
14
|
export default {
|
|
17
15
|
title,
|
|
@@ -19,6 +17,5 @@ export default {
|
|
|
19
17
|
isEnabled,
|
|
20
18
|
config,
|
|
21
19
|
entry,
|
|
22
|
-
resolveEntryPaths,
|
|
23
20
|
resolveConfig,
|
|
24
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveConfig
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
2
|
import type { CypressConfig } from './types.js';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
@@ -6,7 +6,6 @@ declare const _default: {
|
|
|
6
6
|
isEnabled: IsPluginEnabled;
|
|
7
7
|
config: string[];
|
|
8
8
|
entry: string[];
|
|
9
|
-
resolveEntryPaths: ResolveEntryPaths;
|
|
10
9
|
resolveConfig: ResolveConfig<CypressConfig>;
|
|
11
10
|
};
|
|
12
11
|
export default _default;
|
|
@@ -13,17 +13,15 @@ const SUPPORT_FILE_PATTERNS = [
|
|
|
13
13
|
'cypress/plugins/index.js',
|
|
14
14
|
];
|
|
15
15
|
const entry = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
|
|
16
|
-
const
|
|
16
|
+
const resolveConfig = async (localConfig, options) => {
|
|
17
17
|
const specPatterns = [localConfig.e2e?.specPattern ?? [], localConfig.component?.specPattern ?? []].flat();
|
|
18
18
|
const supportFiles = [localConfig.e2e?.supportFile || [], localConfig.component?.supportFile || []].flat();
|
|
19
|
+
const inputs = await resolveDependencies(localConfig, options);
|
|
19
20
|
return [
|
|
20
|
-
...(
|
|
21
|
-
...(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const resolveConfig = async (config, options) => {
|
|
25
|
-
const inputs = await resolveDependencies(config, options);
|
|
26
|
-
return inputs.map(toDeferResolve);
|
|
21
|
+
...inputs.map(toDeferResolve),
|
|
22
|
+
...(specPatterns.length > 0 ? specPatterns : TEST_FILE_PATTERNS).map(id => toEntry(id)),
|
|
23
|
+
...(supportFiles.length > 0 ? supportFiles : SUPPORT_FILE_PATTERNS).map(id => toEntry(id)),
|
|
24
|
+
];
|
|
27
25
|
};
|
|
28
26
|
export default {
|
|
29
27
|
title,
|
|
@@ -31,6 +29,5 @@ export default {
|
|
|
31
29
|
isEnabled,
|
|
32
30
|
config,
|
|
33
31
|
entry,
|
|
34
|
-
resolveEntryPaths,
|
|
35
32
|
resolveConfig,
|
|
36
33
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { EleventyConfig } from './types.js';
|
|
2
1
|
export declare class DummyEleventyConfig {
|
|
3
2
|
_getUniqueId(): void;
|
|
4
3
|
reset(): void;
|
|
@@ -135,4 +134,13 @@ export declare class DummyEleventyConfig {
|
|
|
135
134
|
};
|
|
136
135
|
templateFormatsAdded: {};
|
|
137
136
|
}
|
|
138
|
-
export declare const defaultEleventyConfig:
|
|
137
|
+
export declare const defaultEleventyConfig: {
|
|
138
|
+
dir: {
|
|
139
|
+
input: string;
|
|
140
|
+
output: string;
|
|
141
|
+
includes: string;
|
|
142
|
+
layouts: string;
|
|
143
|
+
data: string;
|
|
144
|
+
};
|
|
145
|
+
templateFormats: string;
|
|
146
|
+
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type { IsPluginEnabled, ResolveConfig
|
|
2
|
-
import {
|
|
3
|
-
import type { EleventyConfig } from './types.js';
|
|
4
|
-
type T = Partial<EleventyConfig> | ((arg: DummyEleventyConfig) => Promise<Partial<EleventyConfig>>);
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
+
import type { EleventyConfigOrFn } from './types.js';
|
|
5
3
|
declare const _default: {
|
|
6
4
|
title: string;
|
|
7
5
|
enablers: string[];
|
|
8
6
|
isEnabled: IsPluginEnabled;
|
|
9
7
|
config: string[];
|
|
10
8
|
production: string[];
|
|
11
|
-
|
|
12
|
-
resolveConfig: ResolveConfig<T>;
|
|
9
|
+
resolveConfig: ResolveConfig<EleventyConfigOrFn>;
|
|
13
10
|
};
|
|
14
11
|
export default _default;
|