knip 5.41.1 → 5.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ConfigurationChief.d.ts +2 -0
- package/dist/ConfigurationValidator.d.ts +112 -0
- package/dist/IssueCollector.js +6 -4
- package/dist/ProjectPrincipal.js +2 -14
- package/dist/WorkspaceWorker.js +2 -3
- package/dist/binaries/package-manager/bun.js +8 -2
- package/dist/binaries/package-manager/bunx.d.ts +3 -0
- package/dist/binaries/package-manager/bunx.js +18 -0
- package/dist/binaries/package-manager/index.d.ts +2 -0
- package/dist/binaries/package-manager/index.js +4 -0
- package/dist/binaries/package-manager/npm.js +1 -2
- package/dist/binaries/package-manager/npx.js +7 -2
- package/dist/binaries/package-manager/pnpm.js +7 -1
- package/dist/binaries/package-manager/pnpx.d.ts +3 -0
- package/dist/binaries/package-manager/pnpx.js +18 -0
- package/dist/binaries/package-manager/yarn.js +4 -3
- package/dist/binaries/plugins.js +7 -2
- package/dist/compilers/index.d.ts +20 -0
- package/dist/constants.js +2 -0
- package/dist/index.js +27 -17
- package/dist/plugins/_template/index.js +1 -1
- package/dist/plugins/angular/index.js +59 -27
- package/dist/plugins/angular/types.d.ts +2 -2
- package/dist/plugins/capacitor/index.js +1 -1
- package/dist/plugins/changesets/index.js +1 -1
- package/dist/plugins/commitlint/index.js +1 -1
- package/dist/plugins/dependency-cruiser/index.d.ts +12 -0
- package/dist/plugins/dependency-cruiser/index.js +16 -0
- package/dist/plugins/expo/helpers.js +1 -1
- package/dist/plugins/expo/index.d.ts +3 -0
- package/dist/plugins/expo/index.js +6 -4
- package/dist/plugins/gatsby/index.js +1 -1
- package/dist/plugins/graphql-codegen/index.js +1 -1
- package/dist/plugins/index.d.ts +29 -11
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/jest/index.d.ts +3 -0
- package/dist/plugins/jest/index.js +4 -0
- package/dist/plugins/karma/helpers.d.ts +7 -0
- package/dist/plugins/karma/helpers.js +32 -0
- package/dist/plugins/karma/index.d.ts +1 -2
- package/dist/plugins/karma/index.js +10 -36
- package/dist/plugins/lefthook/index.js +2 -2
- package/dist/plugins/linthtml/index.d.ts +2 -2
- package/dist/plugins/linthtml/types.d.ts +1 -1
- package/dist/plugins/markdownlint/index.js +1 -1
- package/dist/plugins/metro/index.d.ts +15 -0
- package/dist/plugins/metro/index.js +47 -0
- package/dist/plugins/metro/types.d.ts +13 -0
- package/dist/plugins/metro/types.js +1 -0
- package/dist/plugins/nest/index.js +1 -1
- package/dist/plugins/netlify/index.js +2 -2
- package/dist/plugins/npm-package-json-lint/index.js +1 -1
- package/dist/plugins/nuxt/index.d.ts +3 -1
- package/dist/plugins/nuxt/index.js +3 -3
- package/dist/plugins/nx/index.js +11 -3
- package/dist/plugins/nx/types.d.ts +1 -0
- package/dist/plugins/oclif/index.js +1 -1
- package/dist/plugins/prettier/index.js +1 -1
- package/dist/plugins/release-it/index.d.ts +0 -1
- package/dist/plugins/release-it/index.js +1 -3
- package/dist/plugins/semantic-release/index.js +7 -1
- package/dist/plugins/simple-git-hooks/index.d.ts +2 -3
- package/dist/plugins/simple-git-hooks/index.js +1 -9
- package/dist/plugins/simple-git-hooks/types.d.ts +1 -1
- package/dist/plugins/storybook/index.js +5 -1
- package/dist/plugins/typescript/index.d.ts +3 -1
- package/dist/plugins/typescript/index.js +2 -2
- package/dist/plugins/vite/index.d.ts +0 -1
- package/dist/plugins/vite/index.js +0 -2
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/plugins/webdriver-io/index.js +1 -1
- package/dist/plugins/webpack/index.d.ts +4 -1
- package/dist/plugins/webpack/index.js +5 -2
- package/dist/plugins/wireit/index.d.ts +0 -1
- package/dist/plugins/wireit/index.js +0 -2
- package/dist/reporters/symbols.js +12 -3
- package/dist/schema/plugins.d.ts +46 -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 +1 -2
- package/dist/types/dependency-graph.d.ts +2 -4
- package/dist/typescript/ast-helpers.d.ts +1 -0
- package/dist/typescript/ast-helpers.js +1 -0
- package/dist/typescript/get-imports-and-exports.d.ts +2 -4
- package/dist/typescript/get-imports-and-exports.js +18 -23
- package/dist/typescript/visitors/exports/exportAssignment.js +2 -1
- package/dist/typescript/visitors/exports/exportDeclaration.js +2 -1
- package/dist/typescript/visitors/exports/exportKeyword.js +3 -4
- package/dist/typescript/visitors/helpers.d.ts +2 -1
- package/dist/typescript/visitors/helpers.js +3 -2
- package/dist/typescript/visitors/scripts/bun.js +1 -1
- package/dist/typescript/visitors/scripts/execa.js +24 -1
- package/dist/util/dependency-graph.js +2 -4
- package/dist/util/file-entry-cache.js +2 -6
- package/dist/util/get-referenced-inputs.js +4 -2
- package/dist/util/input.d.ts +3 -1
- package/dist/util/input.js +5 -1
- package/dist/util/modules.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -12
- package/schema.json +8 -0
package/dist/index.js
CHANGED
|
@@ -232,7 +232,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
232
232
|
analyzedFiles.add(filePath);
|
|
233
233
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
234
234
|
if (workspace) {
|
|
235
|
-
const { imports, exports, scripts, traceRefs } = principal.analyzeSourceFile(filePath, {
|
|
235
|
+
const { imports, exports, duplicates, scripts, traceRefs } = principal.analyzeSourceFile(filePath, {
|
|
236
236
|
skipTypeOnly: isStrict,
|
|
237
237
|
isFixExports: fixer.isEnabled && fixer.isFixUnusedExports,
|
|
238
238
|
isFixTypes: fixer.isEnabled && fixer.isFixUnusedTypes,
|
|
@@ -243,6 +243,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
243
243
|
const file = getOrCreateFileNode(graph, filePath);
|
|
244
244
|
file.imports = imports;
|
|
245
245
|
file.exports = exports;
|
|
246
|
+
file.duplicates = duplicates;
|
|
246
247
|
file.scripts = scripts;
|
|
247
248
|
file.traceRefs = traceRefs;
|
|
248
249
|
updateImportMap(file, imports.internal, graph);
|
|
@@ -250,7 +251,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
250
251
|
graph.set(filePath, file);
|
|
251
252
|
if (scripts && scripts.size > 0) {
|
|
252
253
|
const dependencies = deputy.getDependencies(workspace.name);
|
|
253
|
-
const manifestScriptNames = new Set();
|
|
254
|
+
const manifestScriptNames = new Set(Object.keys(chief.getManifestForWorkspace(workspace.name)?.scripts ?? {}));
|
|
254
255
|
const rootCwd = cwd;
|
|
255
256
|
const options = {
|
|
256
257
|
cwd: dirname(filePath),
|
|
@@ -259,18 +260,21 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
259
260
|
dependencies,
|
|
260
261
|
manifestScriptNames,
|
|
261
262
|
};
|
|
262
|
-
const
|
|
263
|
-
for (const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const specifierFilePath = getReferencedInternalFilePath(
|
|
263
|
+
const inputs = _getInputsFromScripts(scripts, options);
|
|
264
|
+
for (const input of inputs) {
|
|
265
|
+
input.containingFilePath = filePath;
|
|
266
|
+
input.dir = cwd;
|
|
267
|
+
const specifierFilePath = getReferencedInternalFilePath(input, workspace);
|
|
267
268
|
if (specifierFilePath)
|
|
268
269
|
analyzeSourceFile(specifierFilePath, principal);
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
};
|
|
273
|
-
for (
|
|
274
|
+
for (let i = 0; i < principals.length; ++i) {
|
|
275
|
+
const principal = principals[i];
|
|
276
|
+
if (!principal)
|
|
277
|
+
continue;
|
|
274
278
|
principal.init();
|
|
275
279
|
streamer.cast('Running async compilers...');
|
|
276
280
|
await principal.runAsyncCompilers();
|
|
@@ -281,7 +285,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
281
285
|
size = principal.entryPaths.size;
|
|
282
286
|
const resolvedFiles = principal.getUsedResolvedFiles();
|
|
283
287
|
const files = resolvedFiles.filter(filePath => !analyzedFiles.has(filePath));
|
|
284
|
-
debugLogArray('*', `Analyzing used resolved files [P${
|
|
288
|
+
debugLogArray('*', `Analyzing used resolved files [P${i + 1}/${++round}]`, files);
|
|
285
289
|
for (const filePath of files)
|
|
286
290
|
analyzeSourceFile(filePath, principal);
|
|
287
291
|
} while (size !== principal.entryPaths.size);
|
|
@@ -290,12 +294,18 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
290
294
|
for (const filePath of principal.entryPaths)
|
|
291
295
|
entryPaths.add(filePath);
|
|
292
296
|
principal.reconcileCache(graph);
|
|
293
|
-
if (!isIsolateWorkspaces && isSkipLibs && !isWatch)
|
|
297
|
+
if (!isIsolateWorkspaces && isSkipLibs && !isWatch) {
|
|
294
298
|
factory.deletePrincipal(principal);
|
|
299
|
+
principals[i] = undefined;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (isIsolateWorkspaces) {
|
|
303
|
+
for (const principal of principals) {
|
|
304
|
+
if (principal)
|
|
305
|
+
factory.deletePrincipal(principal);
|
|
306
|
+
}
|
|
307
|
+
principals.length = 0;
|
|
295
308
|
}
|
|
296
|
-
if (isIsolateWorkspaces)
|
|
297
|
-
for (const principal of principals)
|
|
298
|
-
factory.deletePrincipal(principal);
|
|
299
309
|
const ignoreExportsUsedInFile = chief.config.ignoreExportsUsedInFile;
|
|
300
310
|
const isExportedItemReferenced = (exportedItem) => exportedItem.refs[1] ||
|
|
301
311
|
(exportedItem.refs[0] > 0 &&
|
|
@@ -306,7 +316,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
306
316
|
if (isReportValues || isReportTypes) {
|
|
307
317
|
streamer.cast('Connecting the dots...');
|
|
308
318
|
for (const [filePath, file] of graph.entries()) {
|
|
309
|
-
const exportItems = file.exports
|
|
319
|
+
const exportItems = file.exports;
|
|
310
320
|
if (!exportItems || exportItems.size === 0)
|
|
311
321
|
continue;
|
|
312
322
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
@@ -341,7 +351,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
341
351
|
createAndPrintTrace(filePath, { identifier, isEntry, hasRef: isReferenced });
|
|
342
352
|
continue;
|
|
343
353
|
}
|
|
344
|
-
const reExportedItem = graph.get(reExportingEntryFile)?.exports.
|
|
354
|
+
const reExportedItem = graph.get(reExportingEntryFile)?.exports.get(identifier);
|
|
345
355
|
if (reExportedItem && shouldIgnore(reExportedItem.jsDocTags))
|
|
346
356
|
continue;
|
|
347
357
|
}
|
|
@@ -450,8 +460,8 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
450
460
|
for (const [filePath, file] of graph.entries()) {
|
|
451
461
|
const ws = chief.findWorkspaceByFilePath(filePath);
|
|
452
462
|
if (ws) {
|
|
453
|
-
if (file.
|
|
454
|
-
for (const symbols of file.
|
|
463
|
+
if (file.duplicates) {
|
|
464
|
+
for (const symbols of file.duplicates) {
|
|
455
465
|
if (symbols.length > 1) {
|
|
456
466
|
const symbol = symbols.map(s => s.symbol).join('|');
|
|
457
467
|
collector.addIssue({ type: 'duplicates', filePath, workspace: ws.name, symbol, symbols });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toDeferResolve } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
-
const title = '
|
|
3
|
+
const title = '__PLUGIN_NAME__';
|
|
4
4
|
const enablers = ['__PLUGIN_NAME__'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toConfig, toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
import * as karma from '../karma/helpers.js';
|
|
4
5
|
const title = 'Angular';
|
|
5
6
|
const enablers = ['@angular/cli'];
|
|
6
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -13,50 +14,81 @@ const resolveConfig = async (config, options) => {
|
|
|
13
14
|
for (const project of Object.values(config.projects)) {
|
|
14
15
|
if (!project.architect)
|
|
15
16
|
return [];
|
|
16
|
-
for (const target of Object.
|
|
17
|
+
for (const [targetName, target] of Object.entries(project.architect)) {
|
|
17
18
|
const { options: opts, configurations: configs } = target;
|
|
18
19
|
const [packageName] = typeof target.builder === 'string' ? target.builder.split(':') : [];
|
|
19
20
|
if (typeof packageName === 'string')
|
|
20
21
|
inputs.add(toDependency(packageName));
|
|
21
22
|
if (opts) {
|
|
22
|
-
if ('main' in opts && typeof opts.main === 'string') {
|
|
23
|
-
inputs.add(toProductionEntry(join(cwd, opts.main)));
|
|
24
|
-
}
|
|
25
|
-
if ('browser' in opts && typeof opts.browser === 'string') {
|
|
26
|
-
inputs.add(toProductionEntry(join(cwd, opts.browser)));
|
|
27
|
-
}
|
|
28
|
-
if ('ssr' in opts && opts.ssr && typeof opts.ssr === 'object') {
|
|
29
|
-
if ('entry' in opts.ssr && typeof opts.ssr.entry === 'string') {
|
|
30
|
-
inputs.add(toProductionEntry(join(cwd, opts.ssr.entry)));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
23
|
if ('tsConfig' in opts && typeof opts.tsConfig === 'string') {
|
|
34
24
|
inputs.add(toConfig('typescript', opts.tsConfig, configFilePath));
|
|
35
25
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
}
|
|
27
|
+
const defaultEntriesByOption = opts ? entriesByOption(opts) : new Map();
|
|
28
|
+
const entriesByOptionByConfig = new Map(configs ? Object.entries(configs).map(([name, opts]) => [name, entriesByOption(opts)]) : []);
|
|
29
|
+
const productionEntriesByOption = entriesByOptionByConfig.get(PRODUCTION_CONFIG_NAME) ?? new Map();
|
|
30
|
+
const normalizePath = (path) => join(cwd, path);
|
|
31
|
+
for (const [configName, entriesByOption] of entriesByOptionByConfig.entries()) {
|
|
32
|
+
for (const entries of entriesByOption.values()) {
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
inputs.add(targetName === BUILD_TARGET_NAME && configName === PRODUCTION_CONFIG_NAME
|
|
35
|
+
? toProductionEntry(normalizePath(entry))
|
|
36
|
+
: toEntry(normalizePath(entry)));
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
|
|
46
|
-
for (const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
for (const [option, entries] of defaultEntriesByOption.entries()) {
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
inputs.add(targetName === BUILD_TARGET_NAME && !productionEntriesByOption.get(option)?.length
|
|
43
|
+
? toProductionEntry(normalizePath(entry))
|
|
44
|
+
: toEntry(normalizePath(entry)));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (target.builder === '@angular-devkit/build-angular:karma' && opts) {
|
|
48
|
+
const karmaBuilderOptions = opts;
|
|
49
|
+
const testFilePatterns = karmaBuilderOptions.include ?? ['**/*.spec.ts'];
|
|
50
|
+
for (const testFilePattern of testFilePatterns) {
|
|
51
|
+
inputs.add(toEntry(testFilePattern));
|
|
52
|
+
}
|
|
53
|
+
const excludedTestFilePatterns = karmaBuilderOptions.exclude ?? [];
|
|
54
|
+
for (const excludedTestFilePattern of excludedTestFilePatterns) {
|
|
55
|
+
inputs.add(toEntry(`!${excludedTestFilePattern}`));
|
|
56
|
+
}
|
|
57
|
+
const karmaConfig = karmaBuilderOptions.karmaConfig;
|
|
58
|
+
if (!karmaConfig) {
|
|
59
|
+
karma
|
|
60
|
+
.inputsFromPlugins(['karma-jasmine', 'karma-chrome-launcher', 'karma-jasmine-html-reporter', 'karma-coverage'], options.manifest.devDependencies)
|
|
61
|
+
.forEach(inputs.add, inputs);
|
|
62
|
+
karma.inputsFromFrameworks(['jasmine']).forEach(inputs.add, inputs);
|
|
63
|
+
}
|
|
64
|
+
if (karmaConfig && !karma.configFiles.includes(karmaConfig)) {
|
|
65
|
+
inputs.add(toConfig('karma', karmaConfig, options.configFilePath));
|
|
53
66
|
}
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
70
|
return Array.from(inputs);
|
|
58
71
|
};
|
|
59
|
-
const
|
|
72
|
+
const entriesByOption = (opts) => new Map(Object.entries({
|
|
73
|
+
main: 'main' in opts && opts.main && typeof opts.main === 'string' ? [opts.main] : [],
|
|
74
|
+
scripts: 'scripts' in opts && opts.scripts && Array.isArray(opts.scripts)
|
|
75
|
+
? opts.scripts.map(scriptStringOrObject => typeof scriptStringOrObject === 'string' ? scriptStringOrObject : scriptStringOrObject.input)
|
|
76
|
+
: [],
|
|
77
|
+
fileReplacements: 'fileReplacements' in opts && opts.fileReplacements && Array.isArray(opts.fileReplacements)
|
|
78
|
+
? opts.fileReplacements.map(fileReplacement => 'with' in fileReplacement ? fileReplacement.with : fileReplacement.replaceWith)
|
|
79
|
+
: [],
|
|
80
|
+
browser: 'browser' in opts && opts.browser && typeof opts.browser === 'string' ? [opts.browser] : [],
|
|
81
|
+
server: 'server' in opts && opts.server && typeof opts.server === 'string' ? [opts.server] : [],
|
|
82
|
+
ssrEntry: 'ssr' in opts &&
|
|
83
|
+
opts.ssr &&
|
|
84
|
+
typeof opts.ssr === 'object' &&
|
|
85
|
+
'entry' in opts.ssr &&
|
|
86
|
+
typeof opts.ssr.entry === 'string'
|
|
87
|
+
? [opts.ssr.entry]
|
|
88
|
+
: [],
|
|
89
|
+
}));
|
|
90
|
+
const PRODUCTION_CONFIG_NAME = 'production';
|
|
91
|
+
const BUILD_TARGET_NAME = 'build';
|
|
60
92
|
export default {
|
|
61
93
|
title,
|
|
62
94
|
enablers,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type FileVersion = number;
|
|
2
|
-
type Project = Project1 & {
|
|
2
|
+
export type Project = Project1 & {
|
|
3
3
|
cli?: {
|
|
4
4
|
[k: string]: unknown;
|
|
5
5
|
};
|
|
@@ -869,7 +869,7 @@ interface ExtractI18NTarget1 {
|
|
|
869
869
|
outputPath?: string;
|
|
870
870
|
outFile?: string;
|
|
871
871
|
}
|
|
872
|
-
interface KarmaTarget {
|
|
872
|
+
export interface KarmaTarget {
|
|
873
873
|
main?: string;
|
|
874
874
|
tsConfig: string;
|
|
875
875
|
karmaConfig?: string;
|
|
@@ -11,7 +11,7 @@ const resolveConfig = async (config, { configFileDir }) => {
|
|
|
11
11
|
const plugins = config.includePlugins ?? [];
|
|
12
12
|
const android = (await exists('android/capacitor.settings.gradle')) ? ['@capacitor/android'] : [];
|
|
13
13
|
const ios = (await exists('ios/App/Podfile')) ? ['@capacitor/ios'] : [];
|
|
14
|
-
return [...plugins, ...android, ...ios].map(toDependency);
|
|
14
|
+
return [...plugins, ...android, ...ios].map(id => toDependency(id));
|
|
15
15
|
};
|
|
16
16
|
export default {
|
|
17
17
|
title,
|
|
@@ -21,7 +21,7 @@ const resolveConfig = async (config) => {
|
|
|
21
21
|
? [parserPreset.path ?? parserPreset]
|
|
22
22
|
: []
|
|
23
23
|
: [];
|
|
24
|
-
return [...extendsConfigs, ...plugins, ...formatter, ...parserPresetPaths].map(toDependency);
|
|
24
|
+
return [...extendsConfigs, ...plugins, ...formatter, ...parserPresetPaths].map(id => toDependency(id));
|
|
25
25
|
};
|
|
26
26
|
export default {
|
|
27
27
|
title,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IsPluginEnabled } from '../../types/config.js';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
enablers: string[];
|
|
5
|
+
isEnabled: IsPluginEnabled;
|
|
6
|
+
config: string[];
|
|
7
|
+
args: {
|
|
8
|
+
binaries: string[];
|
|
9
|
+
config: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = 'dependency-cruiser';
|
|
3
|
+
const enablers = ['dependency-cruiser'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const config = ['.dependency-cruiser.{js,cjs,mjs,json}'];
|
|
6
|
+
const args = {
|
|
7
|
+
binaries: ['depcruise', 'dependency-cruise', 'dependency-cruiser', 'depcruise-baseline'],
|
|
8
|
+
config: true,
|
|
9
|
+
};
|
|
10
|
+
export default {
|
|
11
|
+
title,
|
|
12
|
+
enablers,
|
|
13
|
+
isEnabled,
|
|
14
|
+
config,
|
|
15
|
+
args,
|
|
16
|
+
};
|
|
@@ -9,7 +9,7 @@ export const getDependencies = async (expoConfig, { manifest }) => {
|
|
|
9
9
|
return getPackageNameFromModuleSpecifier(pluginName);
|
|
10
10
|
})
|
|
11
11
|
.filter(Boolean) ?? [];
|
|
12
|
-
const inputs = new Set(pluginPackages.map(toDependency));
|
|
12
|
+
const inputs = new Set(pluginPackages.map(id => toDependency(id)));
|
|
13
13
|
const allowedPackages = ['expo-atlas', 'expo-dev-client'];
|
|
14
14
|
const allowedProductionPackages = ['expo-insights'];
|
|
15
15
|
const manifestDependencies = Object.keys(manifest.dependencies ?? {});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
|
|
2
2
|
import type { ExpoConfig } from './types.js';
|
|
3
|
+
export declare const docs: {
|
|
4
|
+
production: string[];
|
|
5
|
+
};
|
|
3
6
|
declare const _default: {
|
|
4
7
|
title: string;
|
|
5
8
|
enablers: string[];
|
|
@@ -6,21 +6,23 @@ const title = 'Expo';
|
|
|
6
6
|
const enablers = ['expo'];
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
8
|
const config = ['app.json', 'app.config.{ts,js}'];
|
|
9
|
+
const production = ['app/**/*.{js,jsx,ts,tsx}', 'src/app/**/*.{js,jsx,ts,tsx}'];
|
|
10
|
+
export const docs = { production };
|
|
9
11
|
const resolveEntryPaths = async (expoConfig, { manifest }) => {
|
|
10
12
|
const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
|
|
11
|
-
let
|
|
13
|
+
let patterns = [];
|
|
12
14
|
if (manifest.main === 'expo-router/entry') {
|
|
13
|
-
|
|
15
|
+
patterns = [...production];
|
|
14
16
|
const normalizedPlugins = config.plugins?.map(plugin => (Array.isArray(plugin) ? plugin : [plugin])) ?? [];
|
|
15
17
|
const expoRouterPlugin = normalizedPlugins.find(([plugin]) => plugin === 'expo-router');
|
|
16
18
|
if (expoRouterPlugin) {
|
|
17
19
|
const [, options] = expoRouterPlugin;
|
|
18
20
|
if (typeof options?.root === 'string') {
|
|
19
|
-
|
|
21
|
+
patterns = [join(options.root, '**/*.{js,jsx,ts,tsx}')];
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
return
|
|
25
|
+
return patterns.map(entry => toProductionEntry(entry));
|
|
24
26
|
};
|
|
25
27
|
const resolveConfig = async (expoConfig, options) => getDependencies(expoConfig, options);
|
|
26
28
|
export default {
|
|
@@ -26,7 +26,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
26
26
|
if (typeof _config.onCreateBabelConfig === 'function') {
|
|
27
27
|
_config.onCreateBabelConfig({ actions });
|
|
28
28
|
}
|
|
29
|
-
return Array.from(plugins).map(toDependency);
|
|
29
|
+
return Array.from(plugins).map(id => toDependency(id));
|
|
30
30
|
}
|
|
31
31
|
return [];
|
|
32
32
|
};
|
|
@@ -48,7 +48,7 @@ const resolveConfig = config => {
|
|
|
48
48
|
return [];
|
|
49
49
|
if (isInternal(plugin))
|
|
50
50
|
return [toEntry(plugin)];
|
|
51
|
-
return [plugin.includes('codegen-') ? plugin : `@graphql-codegen/${plugin}`].map(toDependency);
|
|
51
|
+
return [plugin.includes('codegen-') ? plugin : `@graphql-codegen/${plugin}`].map(id => toDependency(id));
|
|
52
52
|
});
|
|
53
53
|
return [...presets, ...flatPlugins, ...nestedPlugins].map(id => (typeof id === 'string' ? toDependency(id) : id));
|
|
54
54
|
};
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -94,6 +94,16 @@ export declare const Plugins: {
|
|
|
94
94
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths;
|
|
95
95
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./cypress/types.js").CypressConfig>;
|
|
96
96
|
};
|
|
97
|
+
'dependency-cruiser': {
|
|
98
|
+
title: string;
|
|
99
|
+
enablers: string[];
|
|
100
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
101
|
+
config: string[];
|
|
102
|
+
args: {
|
|
103
|
+
binaries: string[];
|
|
104
|
+
config: boolean;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
97
107
|
dotenv: {
|
|
98
108
|
title: string;
|
|
99
109
|
args: {
|
|
@@ -184,6 +194,9 @@ export declare const Plugins: {
|
|
|
184
194
|
entry: string[];
|
|
185
195
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./jest/types.js").JestConfig>;
|
|
186
196
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./jest/types.js").JestConfig>;
|
|
197
|
+
args: {
|
|
198
|
+
config: boolean;
|
|
199
|
+
};
|
|
187
200
|
};
|
|
188
201
|
karma: {
|
|
189
202
|
title: string;
|
|
@@ -191,8 +204,8 @@ export declare const Plugins: {
|
|
|
191
204
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
192
205
|
config: string[];
|
|
193
206
|
entry: string[];
|
|
194
|
-
resolveConfig: import("../types/config.js").ResolveConfig<
|
|
195
|
-
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<
|
|
207
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./karma/helpers.js").ConfigFile>;
|
|
208
|
+
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./karma/helpers.js").ConfigFile>;
|
|
196
209
|
};
|
|
197
210
|
ladle: {
|
|
198
211
|
title: string;
|
|
@@ -225,7 +238,7 @@ export declare const Plugins: {
|
|
|
225
238
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
226
239
|
packageJsonPath: string;
|
|
227
240
|
config: string[];
|
|
228
|
-
resolveConfig: import("../types/config.js").ResolveConfig<import("./linthtml/types.js").
|
|
241
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./linthtml/types.js").LintHTMLConfig>;
|
|
229
242
|
};
|
|
230
243
|
'lockfile-lint': {
|
|
231
244
|
title: string;
|
|
@@ -246,6 +259,14 @@ export declare const Plugins: {
|
|
|
246
259
|
config: string[];
|
|
247
260
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./markdownlint/types.js").MarkdownlintConfig>;
|
|
248
261
|
};
|
|
262
|
+
metro: {
|
|
263
|
+
title: string;
|
|
264
|
+
enablers: string[];
|
|
265
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
266
|
+
config: string[];
|
|
267
|
+
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./metro/types.js").MetroConfig>;
|
|
268
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./metro/types.js").MetroConfig>;
|
|
269
|
+
};
|
|
249
270
|
mocha: {
|
|
250
271
|
title: string;
|
|
251
272
|
enablers: string[];
|
|
@@ -329,7 +350,6 @@ export declare const Plugins: {
|
|
|
329
350
|
};
|
|
330
351
|
nuxt: {
|
|
331
352
|
title: string;
|
|
332
|
-
note: string;
|
|
333
353
|
enablers: string[];
|
|
334
354
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
335
355
|
entry: string[];
|
|
@@ -441,7 +461,6 @@ export declare const Plugins: {
|
|
|
441
461
|
title: string;
|
|
442
462
|
enablers: string[];
|
|
443
463
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
444
|
-
packageJsonPath: string;
|
|
445
464
|
config: string[];
|
|
446
465
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./release-it/types.js").ReleaseItConfig>;
|
|
447
466
|
};
|
|
@@ -500,9 +519,8 @@ export declare const Plugins: {
|
|
|
500
519
|
title: string;
|
|
501
520
|
enablers: string[];
|
|
502
521
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
503
|
-
packageJsonPath: string;
|
|
504
522
|
config: string[];
|
|
505
|
-
resolveConfig: import("../types/config.js").ResolveConfig<import("./simple-git-hooks/types.js").
|
|
523
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./simple-git-hooks/types.js").SimpleGitHooksConfig>;
|
|
506
524
|
};
|
|
507
525
|
'size-limit': {
|
|
508
526
|
title: string;
|
|
@@ -611,7 +629,6 @@ export declare const Plugins: {
|
|
|
611
629
|
enablers: string[];
|
|
612
630
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
613
631
|
config: string[];
|
|
614
|
-
production: string[];
|
|
615
632
|
resolveConfig: import("../types/config.js").ResolveConfig<import("type-fest").TsConfigJson>;
|
|
616
633
|
args: {
|
|
617
634
|
binaries: string[];
|
|
@@ -652,7 +669,6 @@ export declare const Plugins: {
|
|
|
652
669
|
enablers: string[];
|
|
653
670
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
654
671
|
config: string[];
|
|
655
|
-
production: string[];
|
|
656
672
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./vitest/types.js").ViteConfigOrFn | import("./vitest/types.js").VitestWorkspaceConfig>;
|
|
657
673
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./vitest/types.js").ViteConfigOrFn | import("./vitest/types.js").VitestWorkspaceConfig>;
|
|
658
674
|
};
|
|
@@ -687,14 +703,16 @@ export declare const Plugins: {
|
|
|
687
703
|
enablers: string[];
|
|
688
704
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
689
705
|
config: string[];
|
|
690
|
-
production: string[];
|
|
691
706
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./webpack/types.js").WebpackConfig>;
|
|
707
|
+
args: {
|
|
708
|
+
binaries: string[];
|
|
709
|
+
config: boolean;
|
|
710
|
+
};
|
|
692
711
|
};
|
|
693
712
|
wireit: {
|
|
694
713
|
title: string;
|
|
695
714
|
enablers: string[];
|
|
696
715
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
697
|
-
packageJsonPath: string;
|
|
698
716
|
config: string[];
|
|
699
717
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./wireit/types.js").WireitConfig>;
|
|
700
718
|
};
|
package/dist/plugins/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { default as commitlint } from './commitlint/index.js';
|
|
|
10
10
|
import { default as cspell } from './cspell/index.js';
|
|
11
11
|
import { default as cucumber } from './cucumber/index.js';
|
|
12
12
|
import { default as cypress } from './cypress/index.js';
|
|
13
|
+
import { default as dependencyCruiser } from './dependency-cruiser/index.js';
|
|
13
14
|
import { default as dotenv } from './dotenv/index.js';
|
|
14
15
|
import { default as drizzle } from './drizzle/index.js';
|
|
15
16
|
import { default as eleventy } from './eleventy/index.js';
|
|
@@ -29,6 +30,7 @@ import { default as linthtml } from './linthtml/index.js';
|
|
|
29
30
|
import { default as lockfileLint } from './lockfile-lint/index.js';
|
|
30
31
|
import { default as lostPixel } from './lost-pixel/index.js';
|
|
31
32
|
import { default as markdownlint } from './markdownlint/index.js';
|
|
33
|
+
import { default as metro } from './metro/index.js';
|
|
32
34
|
import { default as mocha } from './mocha/index.js';
|
|
33
35
|
import { default as moonrepo } from './moonrepo/index.js';
|
|
34
36
|
import { default as msw } from './msw/index.js';
|
|
@@ -100,6 +102,7 @@ export const Plugins = {
|
|
|
100
102
|
cspell,
|
|
101
103
|
cucumber,
|
|
102
104
|
cypress,
|
|
105
|
+
'dependency-cruiser': dependencyCruiser,
|
|
103
106
|
dotenv,
|
|
104
107
|
drizzle,
|
|
105
108
|
eleventy,
|
|
@@ -119,6 +122,7 @@ export const Plugins = {
|
|
|
119
122
|
'lockfile-lint': lockfileLint,
|
|
120
123
|
'lost-pixel': lostPixel,
|
|
121
124
|
markdownlint,
|
|
125
|
+
metro,
|
|
122
126
|
mocha,
|
|
123
127
|
moonrepo,
|
|
124
128
|
msw,
|
|
@@ -95,6 +95,9 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
95
95
|
});
|
|
96
96
|
return result;
|
|
97
97
|
};
|
|
98
|
+
const args = {
|
|
99
|
+
config: true,
|
|
100
|
+
};
|
|
98
101
|
export default {
|
|
99
102
|
title,
|
|
100
103
|
enablers,
|
|
@@ -103,4 +106,5 @@ export default {
|
|
|
103
106
|
entry,
|
|
104
107
|
resolveEntryPaths,
|
|
105
108
|
resolveConfig,
|
|
109
|
+
args,
|
|
106
110
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Input } from '../../util/input.js';
|
|
2
|
+
import type { Config, ConfigOptions } from './types.js';
|
|
3
|
+
export declare const configFiles: string[];
|
|
4
|
+
export declare const inputsFromFrameworks: (frameworks: readonly string[]) => readonly Input[];
|
|
5
|
+
export declare const inputsFromPlugins: (plugins: ConfigOptions["plugins"], devDependencies: Record<string, string> | undefined) => readonly Input[];
|
|
6
|
+
export type ConfigFile = (config: Config) => void;
|
|
7
|
+
export declare const loadConfig: (configFile: ConfigFile) => ConfigOptions | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { toDeferResolveEntry, toDevDependency } from '../../util/input.js';
|
|
2
|
+
import { isInternal } from '../../util/path.js';
|
|
3
|
+
export const configFiles = ['karma.conf.js', 'karma.conf.ts', '.config/karma.conf.js', '.config/karma.conf.ts'];
|
|
4
|
+
export const inputsFromFrameworks = (frameworks) => frameworks.map(framework => {
|
|
5
|
+
return toDevDependency(framework === 'jasmine' ? 'jasmine-core' : framework);
|
|
6
|
+
});
|
|
7
|
+
export const inputsFromPlugins = (plugins, devDependencies) => {
|
|
8
|
+
if (!plugins) {
|
|
9
|
+
const karmaPluginDevDeps = Object.keys(devDependencies ?? {}).filter(name => name.startsWith('karma-'));
|
|
10
|
+
return karmaPluginDevDeps.map(karmaPluginDevDep => toDevDependency(karmaPluginDevDep));
|
|
11
|
+
}
|
|
12
|
+
return plugins
|
|
13
|
+
.map(plugin => {
|
|
14
|
+
if (typeof plugin !== 'string')
|
|
15
|
+
return;
|
|
16
|
+
return isInternal(plugin) ? toDeferResolveEntry(plugin) : toDevDependency(plugin);
|
|
17
|
+
})
|
|
18
|
+
.filter(input => !!input);
|
|
19
|
+
};
|
|
20
|
+
export const loadConfig = (configFile) => {
|
|
21
|
+
if (typeof configFile !== 'function')
|
|
22
|
+
return;
|
|
23
|
+
const inMemoryConfig = new InMemoryConfig();
|
|
24
|
+
configFile(inMemoryConfig);
|
|
25
|
+
return inMemoryConfig.config ?? {};
|
|
26
|
+
};
|
|
27
|
+
class InMemoryConfig {
|
|
28
|
+
config;
|
|
29
|
+
set(config) {
|
|
30
|
+
this.config = config;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
|
|
2
|
-
import type
|
|
3
|
-
type ConfigFile = (config: Config) => void;
|
|
2
|
+
import { type ConfigFile } from './helpers.js';
|
|
4
3
|
declare const _default: {
|
|
5
4
|
title: string;
|
|
6
5
|
enablers: string[];
|