knip 6.41.0 → 6.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 +18 -0
- package/dist/WorkspaceWorker.js +1 -0
- package/dist/binaries/bash-parser.js +16 -39
- package/dist/binaries/resolvers/bun.js +1 -0
- package/dist/compilers/scss.js +2 -22
- package/dist/compilers/shared.d.ts +1 -1
- package/dist/compilers/shared.js +24 -1
- package/dist/constants.js +1 -0
- package/dist/graph-explorer/operations/is-referenced.js +8 -2
- package/dist/manifest/index.js +2 -3
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.d.ts +2 -0
- package/dist/plugins/_component-style-urls/component-style-urls-visitor.js +40 -0
- package/dist/plugins/angular/index.js +7 -1
- package/dist/plugins/biome/index.js +2 -2
- package/dist/plugins/bun/index.js +13 -0
- package/dist/plugins/commitlint/index.js +2 -2
- package/dist/plugins/eslint/helpers.js +1 -1
- package/dist/plugins/filesystem-routing/index.d.ts +3 -0
- package/dist/plugins/filesystem-routing/index.js +57 -0
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/jest/index.js +16 -7
- package/dist/plugins/jest/visitors/mock.d.ts +2 -0
- package/dist/plugins/jest/visitors/mock.js +91 -0
- package/dist/plugins/mise/scripts.js +55 -97
- package/dist/plugins/next/index.js +33 -1
- package/dist/plugins/nx/index.js +46 -8
- package/dist/plugins/nx/types.d.ts +8 -0
- package/dist/plugins/oxlint/index.js +1 -1
- package/dist/plugins/react-router/index.d.ts +3 -0
- package/dist/plugins/react-router/index.js +3 -0
- package/dist/plugins/rstest/index.js +1 -1
- package/dist/plugins/semantic-release/index.js +32 -3
- package/dist/plugins/semantic-release/types.d.ts +1 -0
- package/dist/plugins/solidjs-vite-plugin/index.d.ts +6 -0
- package/dist/plugins/solidjs-vite-plugin/index.js +17 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.d.ts +3 -0
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +76 -0
- package/dist/plugins/sst/resolveFromAST.js +1 -1
- package/dist/plugins/stencil/index.js +2 -39
- package/dist/plugins/storybook/index.js +2 -4
- package/dist/plugins/sveltejs-package/helpers.js +2 -2
- package/dist/plugins/tailwind/compiler.js +10 -2
- package/dist/plugins/taskfile/index.js +3 -6
- package/dist/plugins/tsrs/index.d.ts +3 -0
- package/dist/plugins/tsrs/index.js +15 -0
- package/dist/plugins/typescript/index.d.ts +12 -1
- package/dist/plugins/typescript/index.js +5 -7
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +15 -1
- package/dist/plugins/vitest/index.js +4 -4
- package/dist/schema/configuration.d.ts +45 -0
- package/dist/schema/plugins.d.ts +15 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/visitors/imports.js +11 -0
- package/dist/typescript/visitors/jsdoc.js +27 -22
- package/dist/util/create-options.d.ts +30 -0
- package/dist/util/create-options.js +2 -3
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/scripts.d.ts +3 -2
- package/dist/util/scripts.js +32 -72
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/schema.json +12 -0
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ following projects:
|
|
|
48
48
|
|
|
49
49
|
[1]: https://www.npmx.dev/package/knip
|
|
50
50
|
[2]: https://img.shields.io/npm/v/knip?color=f56e0f
|
|
51
|
-
[3]: https://img.shields.io/npm/
|
|
51
|
+
[3]: https://img.shields.io/badge/dynamic/json?url=https://npm-gapless.webpro.nl/downloads/range/last-month/knip&query=$.totalCompact&label=downloads&suffix=/month&color=f56e0f
|
|
52
52
|
[4]: https://github.com/webpro-nl/knip
|
|
53
53
|
[5]:
|
|
54
54
|
https://img.shields.io/github/stars/webpro-nl/knip?style=flat&color=f56e0f
|
|
@@ -252,6 +252,11 @@ export declare class ConfigurationChief {
|
|
|
252
252
|
entry?: string | string[] | undefined;
|
|
253
253
|
project?: string | string[] | undefined;
|
|
254
254
|
} | undefined;
|
|
255
|
+
'filesystem-routing'?: string | boolean | string[] | {
|
|
256
|
+
config?: string | string[] | undefined;
|
|
257
|
+
entry?: string | string[] | undefined;
|
|
258
|
+
project?: string | string[] | undefined;
|
|
259
|
+
} | undefined;
|
|
255
260
|
flue?: string | boolean | string[] | {
|
|
256
261
|
config?: string | string[] | undefined;
|
|
257
262
|
entry?: string | string[] | undefined;
|
|
@@ -722,6 +727,11 @@ export declare class ConfigurationChief {
|
|
|
722
727
|
entry?: string | string[] | undefined;
|
|
723
728
|
project?: string | string[] | undefined;
|
|
724
729
|
} | undefined;
|
|
730
|
+
'solidjs-vite-plugin'?: string | boolean | string[] | {
|
|
731
|
+
config?: string | string[] | undefined;
|
|
732
|
+
entry?: string | string[] | undefined;
|
|
733
|
+
project?: string | string[] | undefined;
|
|
734
|
+
} | undefined;
|
|
725
735
|
sst?: string | boolean | string[] | {
|
|
726
736
|
config?: string | string[] | undefined;
|
|
727
737
|
entry?: string | string[] | undefined;
|
|
@@ -837,6 +847,11 @@ export declare class ConfigurationChief {
|
|
|
837
847
|
entry?: string | string[] | undefined;
|
|
838
848
|
project?: string | string[] | undefined;
|
|
839
849
|
} | undefined;
|
|
850
|
+
tsrs?: string | boolean | string[] | {
|
|
851
|
+
config?: string | string[] | undefined;
|
|
852
|
+
entry?: string | string[] | undefined;
|
|
853
|
+
project?: string | string[] | undefined;
|
|
854
|
+
} | undefined;
|
|
840
855
|
tsup?: string | boolean | string[] | {
|
|
841
856
|
config?: string | string[] | undefined;
|
|
842
857
|
entry?: string | string[] | undefined;
|
|
@@ -1089,6 +1104,7 @@ export declare class ConfigurationChief {
|
|
|
1089
1104
|
"expo-router"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1090
1105
|
"expressive-code"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1091
1106
|
fast?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1107
|
+
"filesystem-routing"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1092
1108
|
flue?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1093
1109
|
fumadocs?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1094
1110
|
gatsby?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
@@ -1183,6 +1199,7 @@ export declare class ConfigurationChief {
|
|
|
1183
1199
|
"serverless-framework"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1184
1200
|
"simple-git-hooks"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1185
1201
|
"size-limit"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1202
|
+
"solidjs-vite-plugin"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1186
1203
|
sst?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1187
1204
|
starlight?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1188
1205
|
stencil?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
@@ -1206,6 +1223,7 @@ export declare class ConfigurationChief {
|
|
|
1206
1223
|
"ts-node"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1207
1224
|
tsd?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1208
1225
|
tsdown?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1226
|
+
tsrs?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1209
1227
|
tsup?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1210
1228
|
tsx?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
1211
1229
|
turbo?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import { parse } from 'unbash';
|
|
1
|
+
import { forEachChild, parse } from 'unbash';
|
|
2
2
|
import { debugLogObject } from '../util/debug.js';
|
|
3
3
|
import { extractBinary, isValidBinary } from '../util/modules.js';
|
|
4
4
|
import { relative } from '../util/path.js';
|
|
5
5
|
import { substringBefore, truncate } from '../util/string.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isScriptExpansion } from '../util/scripts.js';
|
|
7
7
|
import { getDependenciesFromCommand } from './command.js';
|
|
8
8
|
import { toScript } from './util.js';
|
|
9
|
-
const collectExpansionScripts = (word, out) => {
|
|
10
|
-
if (word.type === 'ArrayValue') {
|
|
11
|
-
for (const element of word.elements)
|
|
12
|
-
collectExpansionScripts(element, out);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (!word.parts)
|
|
16
|
-
return;
|
|
17
|
-
for (const part of word.parts) {
|
|
18
|
-
if ((part.type === 'CommandExpansion' || part.type === 'ProcessSubstitution') && part.script) {
|
|
19
|
-
out.push(part.script);
|
|
20
|
-
}
|
|
21
|
-
else if (part.type === 'DoubleQuoted' || part.type === 'LocaleString') {
|
|
22
|
-
for (const child of part.parts) {
|
|
23
|
-
if (child.type === 'CommandExpansion' && child.script)
|
|
24
|
-
out.push(child.script);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
9
|
export const getDependenciesFromScript = (script, options) => {
|
|
30
10
|
if (!script)
|
|
31
11
|
return [];
|
|
@@ -56,24 +36,21 @@ export const getDependenciesFromScript = (script, options) => {
|
|
|
56
36
|
};
|
|
57
37
|
const processScript = (s) => {
|
|
58
38
|
collectFunctionNames(s.commands);
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
const inputs = [];
|
|
40
|
+
const visit = (node) => {
|
|
41
|
+
if (node.type === 'Command')
|
|
42
|
+
inputs.push(...processCommand(node));
|
|
43
|
+
if (isScriptExpansion(node)) {
|
|
44
|
+
if (node.script)
|
|
45
|
+
inputs.push(...processScript(node.script));
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
forEachChild(node, visit);
|
|
49
|
+
};
|
|
50
|
+
visit(s);
|
|
51
|
+
return inputs;
|
|
67
52
|
};
|
|
68
|
-
const processCommand = (node
|
|
69
|
-
if (node.name)
|
|
70
|
-
collectExpansionScripts(node.name, pending);
|
|
71
|
-
for (const prefix of node.prefix) {
|
|
72
|
-
if (prefix.type === 'Assignment')
|
|
73
|
-
collectExpansionScripts(prefix.value, pending);
|
|
74
|
-
}
|
|
75
|
-
for (const arg of node.args)
|
|
76
|
-
collectExpansionScripts(arg.type === 'Assignment' ? arg.value : arg, pending);
|
|
53
|
+
const processCommand = (node) => {
|
|
77
54
|
if (definedFunctions.size && node.name && definedFunctions.has(extractBinary(node.name.value)))
|
|
78
55
|
return [];
|
|
79
56
|
return getDependenciesFromCommand(node, { ...options, fromArgs }, fromWords);
|
package/dist/compilers/scss.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { hasUrlScheme } from '../util/url.js';
|
|
1
|
+
import { getUrlSpecifier, isScopedPackage, isTildePackage, splitSpec } from './shared.js';
|
|
3
2
|
const dependencies = ['sass', 'sass-embedded', 'node-sass'];
|
|
4
|
-
const dependencyMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|\/\/[^\r\n]*(?:[\r\n]|$)|@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]|url\(\s*(?:["']([^"']*)["']|([^'")\s]+))\s*\)/g;
|
|
5
|
-
const getUrlSpecifier = (url) => {
|
|
6
|
-
if (!url ||
|
|
7
|
-
url.startsWith('//') ||
|
|
8
|
-
url.startsWith('/') ||
|
|
9
|
-
url.startsWith('#') ||
|
|
10
|
-
hasUrlScheme(url) ||
|
|
11
|
-
url.includes('$') ||
|
|
12
|
-
url.includes('#{'))
|
|
13
|
-
return;
|
|
14
|
-
let end = url.length;
|
|
15
|
-
const queryIndex = url.indexOf('?');
|
|
16
|
-
if (queryIndex !== -1)
|
|
17
|
-
end = queryIndex;
|
|
18
|
-
const fragmentIndex = url.indexOf('#');
|
|
19
|
-
if (fragmentIndex !== -1 && fragmentIndex < end)
|
|
20
|
-
end = fragmentIndex;
|
|
21
|
-
const path = url.slice(0, end);
|
|
22
|
-
return path ? ensureRelative(path) : undefined;
|
|
23
|
-
};
|
|
3
|
+
const dependencyMatcher = /"(?:\\(?:\r\n|[\s\S]|$)|[^"\\\r\n\f])*(?:"|[\r\n\f]|$)|'(?:\\(?:\r\n|[\s\S]|$)|[^'\\\r\n\f])*(?:'|[\r\n\f]|$)|\/\*[\s\S]*?(?:\*\/|$)|\/\/[^\r\n]*(?:[\r\n]|$)|@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]|url\(\s*(?:["']([^"'\r\n]*)["']|([^'")\s]+))\s*\)/g;
|
|
24
4
|
const candidates = (specifier) => {
|
|
25
5
|
const { dir, name } = splitSpec(specifier);
|
|
26
6
|
const hasExt = name.endsWith('.scss') || name.endsWith('.sass');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const isScopedPackage: (s: string) => boolean;
|
|
2
2
|
export declare const isTildePackage: (s: string) => boolean;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getUrlSpecifier: (url: string) => string | undefined;
|
|
4
4
|
export declare const splitSpec: (specifier: string) => {
|
|
5
5
|
dir: string;
|
|
6
6
|
name: string;
|
package/dist/compilers/shared.js
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { basename, dirname } from '../util/path.js';
|
|
2
|
+
import { hasUrlScheme } from '../util/url.js';
|
|
2
3
|
const isAlias = (s) => (s.charCodeAt(0) === 64 && s.charCodeAt(1) === 47) || s.charCodeAt(0) === 126 || s.charCodeAt(0) === 35;
|
|
3
4
|
export const isScopedPackage = (s) => s.charCodeAt(0) === 64 && s.charCodeAt(1) !== 47;
|
|
4
5
|
export const isTildePackage = (s) => s.charCodeAt(0) === 126 && s.charCodeAt(1) !== 47;
|
|
5
|
-
export const
|
|
6
|
+
export const getUrlSpecifier = (url) => {
|
|
7
|
+
if (!url ||
|
|
8
|
+
url.startsWith('//') ||
|
|
9
|
+
url.startsWith('/') ||
|
|
10
|
+
url.startsWith('#') ||
|
|
11
|
+
hasUrlScheme(url) ||
|
|
12
|
+
url.includes('$') ||
|
|
13
|
+
url.includes('#{') ||
|
|
14
|
+
url.includes('('))
|
|
15
|
+
return;
|
|
16
|
+
let end = url.length;
|
|
17
|
+
const queryIndex = url.indexOf('?');
|
|
18
|
+
if (queryIndex !== -1)
|
|
19
|
+
end = queryIndex;
|
|
20
|
+
const fragmentIndex = url.indexOf('#');
|
|
21
|
+
if (fragmentIndex !== -1 && fragmentIndex < end)
|
|
22
|
+
end = fragmentIndex;
|
|
23
|
+
const path = url.slice(0, end);
|
|
24
|
+
if (!path)
|
|
25
|
+
return;
|
|
26
|
+
return isScopedPackage(path) ? path : ensureRelative(path);
|
|
27
|
+
};
|
|
28
|
+
const ensureRelative = (spec) => (spec.startsWith('.') || isAlias(spec) ? spec : `./${spec}`);
|
|
6
29
|
export const splitSpec = (specifier) => {
|
|
7
30
|
const spec = ensureRelative(specifier);
|
|
8
31
|
return { dir: dirname(spec), name: basename(spec) };
|
package/dist/constants.js
CHANGED
|
@@ -38,10 +38,16 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
|
|
|
38
38
|
return hasCompleteResult();
|
|
39
39
|
}
|
|
40
40
|
const node = graph.get(path);
|
|
41
|
-
|
|
42
|
-
if (!identifier || !node || !file) {
|
|
41
|
+
if (!identifier || !node) {
|
|
43
42
|
return false;
|
|
44
43
|
}
|
|
44
|
+
if (isEntryFile && node.skipExports) {
|
|
45
|
+
isReferenced = true;
|
|
46
|
+
return hasCompleteResult();
|
|
47
|
+
}
|
|
48
|
+
const file = node.importedBy;
|
|
49
|
+
if (!file)
|
|
50
|
+
return false;
|
|
45
51
|
const follow = (sources, nextId, nextViaStar = viaStar) => {
|
|
46
52
|
for (const byFilePath of sources) {
|
|
47
53
|
if (walkDown(byFilePath, nextId, nextViaStar))
|
package/dist/manifest/index.js
CHANGED
|
@@ -16,10 +16,9 @@ const getMetaDataFromPackageJson = ({ dir, packageNames }) => {
|
|
|
16
16
|
for (const packageName of packageNames) {
|
|
17
17
|
const manifest = loadPackageManifest({ dir, packageName });
|
|
18
18
|
if (manifest) {
|
|
19
|
-
const
|
|
20
|
-
const binaries = typeof manifest.bin === 'string' ? [defaultBinaryName] : Object.keys(manifest.bin ?? {});
|
|
19
|
+
const binaries = typeof manifest.bin === 'string' ? [packageName] : Object.keys(manifest.bin ?? {});
|
|
21
20
|
for (const binaryName of binaries)
|
|
22
|
-
addBinary(binaryName, packageName);
|
|
21
|
+
addBinary(binaryName.replace(/^@[^/]+\//, ''), packageName);
|
|
23
22
|
const packagePeerDependencies = Object.keys(manifest.peerDependencies ?? {});
|
|
24
23
|
for (const packagePeerDependency of packagePeerDependencies) {
|
|
25
24
|
const hostDependency = {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IMPORT_FLAGS } from '../../constants.js';
|
|
2
|
+
import { getPropertyValues } from '../../typescript/ast-helpers.js';
|
|
3
|
+
import { dirname, join } from '../../util/path.js';
|
|
4
|
+
export function createComponentStyleUrlsVisitor(ctx, isSpecifier) {
|
|
5
|
+
const componentNames = new Set();
|
|
6
|
+
return {
|
|
7
|
+
Program() {
|
|
8
|
+
componentNames.clear();
|
|
9
|
+
},
|
|
10
|
+
ImportDeclaration(node) {
|
|
11
|
+
if (!isSpecifier(node.source?.value))
|
|
12
|
+
return;
|
|
13
|
+
for (const spec of node.specifiers ?? []) {
|
|
14
|
+
if (spec.type === 'ImportSpecifier' &&
|
|
15
|
+
spec.imported.type === 'Identifier' &&
|
|
16
|
+
spec.imported.name === 'Component')
|
|
17
|
+
componentNames.add(spec.local.name);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
ClassDeclaration(node) {
|
|
21
|
+
if (componentNames.size === 0)
|
|
22
|
+
return;
|
|
23
|
+
const dir = dirname(ctx.filePath);
|
|
24
|
+
for (const decorator of node.decorators ?? []) {
|
|
25
|
+
const expr = decorator.expression;
|
|
26
|
+
if (expr?.type !== 'CallExpression')
|
|
27
|
+
continue;
|
|
28
|
+
if (expr.callee?.type !== 'Identifier' || !componentNames.has(expr.callee.name))
|
|
29
|
+
continue;
|
|
30
|
+
const arg = expr.arguments?.[0];
|
|
31
|
+
if (arg?.type !== 'ObjectExpression')
|
|
32
|
+
continue;
|
|
33
|
+
for (const url of getPropertyValues(arg, 'styleUrl'))
|
|
34
|
+
ctx.addImport(join(dir, url), arg.start, IMPORT_FLAGS.NONE);
|
|
35
|
+
for (const url of getPropertyValues(arg, 'styleUrls'))
|
|
36
|
+
ctx.addImport(join(dir, url), arg.start, IMPORT_FLAGS.NONE);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { toConfig, toDeferResolve, toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
3
3
|
import { isInternal, join } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
|
+
import { createComponentStyleUrlsVisitor } from '../_component-style-urls/component-style-urls-visitor.js';
|
|
5
6
|
import * as karma from '../karma/helpers.js';
|
|
6
7
|
const title = 'Angular';
|
|
7
8
|
const enablers = ['@angular/cli'];
|
|
@@ -72,7 +73,7 @@ const resolveConfig = async (config, options) => {
|
|
|
72
73
|
karma.inputsFromFrameworks(['jasmine']).forEach(inputs.add, inputs);
|
|
73
74
|
}
|
|
74
75
|
if (karmaConfig && !karma.configFiles.includes(karmaConfig)) {
|
|
75
|
-
inputs.add(toConfig('karma', karmaConfig
|
|
76
|
+
inputs.add(toConfig('karma', karmaConfig));
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -111,11 +112,16 @@ const isAngularBuilderRefWithName = ({ builderRef, name }) => {
|
|
|
111
112
|
};
|
|
112
113
|
const PRODUCTION_CONFIG_NAME = 'production';
|
|
113
114
|
const BUILD_TARGET_NAME = 'build';
|
|
115
|
+
const isAngularSpecifier = (specifier) => specifier === '@angular/core';
|
|
116
|
+
const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
117
|
+
registerVisitor(createComponentStyleUrlsVisitor(ctx, isAngularSpecifier));
|
|
118
|
+
};
|
|
114
119
|
const plugin = {
|
|
115
120
|
title,
|
|
116
121
|
enablers,
|
|
117
122
|
isEnabled,
|
|
118
123
|
config,
|
|
119
124
|
resolveConfig,
|
|
125
|
+
registerVisitors,
|
|
120
126
|
};
|
|
121
127
|
export default plugin;
|
|
@@ -10,9 +10,9 @@ const isRootConfigReference = (specifier) => specifier === '//';
|
|
|
10
10
|
const resolveExtends = (extendsArray, options) => {
|
|
11
11
|
return extendsArray.map(specifier => {
|
|
12
12
|
if (isRootConfigReference(specifier)) {
|
|
13
|
-
return toConfig('biome', join(options.rootCwd, 'biome')
|
|
13
|
+
return toConfig('biome', join(options.rootCwd, 'biome'));
|
|
14
14
|
}
|
|
15
|
-
return toConfig('biome', specifier
|
|
15
|
+
return toConfig('biome', specifier);
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
const resolveConfig = (config, options) => {
|
|
@@ -21,9 +21,22 @@ const resolveConfig = localConfig => {
|
|
|
21
21
|
const preload = localConfig.test?.preload ?? [];
|
|
22
22
|
return preload.map(specifier => toDeferResolve(specifier));
|
|
23
23
|
};
|
|
24
|
+
const isPath = (arg) => /^\.{0,2}\//.test(arg);
|
|
25
|
+
const toFilterPatterns = (filter) => {
|
|
26
|
+
if (filter === '.')
|
|
27
|
+
return patterns;
|
|
28
|
+
if (/\.[cm]?[jt]sx?$/.test(filter))
|
|
29
|
+
return [`**/*${filter}`];
|
|
30
|
+
return [
|
|
31
|
+
...patterns.map(pattern => `**/*${filter}*/${pattern}`),
|
|
32
|
+
...patterns.map(pattern => pattern.replace('**/*', `**/*${filter}*`)),
|
|
33
|
+
];
|
|
34
|
+
};
|
|
24
35
|
const toPatterns = (arg) => {
|
|
25
36
|
if (/[*{?]/.test(arg))
|
|
26
37
|
return [arg];
|
|
38
|
+
if (!isPath(arg))
|
|
39
|
+
return toFilterPatterns(arg);
|
|
27
40
|
if (/\.\w+$/.test(arg))
|
|
28
41
|
return [arg];
|
|
29
42
|
const dir = arg.replace(/\/+$/, '');
|
|
@@ -25,12 +25,12 @@ const toPluginSpecifier = (id) => {
|
|
|
25
25
|
return id;
|
|
26
26
|
return id.replace('/', '/commitlint-plugin-');
|
|
27
27
|
};
|
|
28
|
-
const resolveConfig = async (config
|
|
28
|
+
const resolveConfig = async (config) => {
|
|
29
29
|
const inputs = [];
|
|
30
30
|
const extendsConfigs = [];
|
|
31
31
|
for (const id of config.extends ? [config.extends].flat() : []) {
|
|
32
32
|
if (isInternal(id))
|
|
33
|
-
inputs.push(toConfig('commitlint', id
|
|
33
|
+
inputs.push(toConfig('commitlint', id));
|
|
34
34
|
else
|
|
35
35
|
extendsConfigs.push(toExtendsSpecifier(id));
|
|
36
36
|
}
|
|
@@ -20,7 +20,7 @@ const getInputsDeprecated = (config, options) => {
|
|
|
20
20
|
const extendsSpecifiers = compact(extendsList.map(resolveExtendSpecifier));
|
|
21
21
|
if (extendsSpecifiers.some(specifier => specifier?.startsWith('eslint-plugin-prettier')))
|
|
22
22
|
extendsSpecifiers.push('eslint-config-prettier');
|
|
23
|
-
const extendConfigs = [...extendsList.filter(isInternal), ...extendsSpecifiers].map(specifier => toConfig('eslint', specifier
|
|
23
|
+
const extendConfigs = [...extendsList.filter(isInternal), ...extendsSpecifiers].map(specifier => toConfig('eslint', specifier));
|
|
24
24
|
const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
|
|
25
25
|
const parsers = getParsers(config);
|
|
26
26
|
const babelDependencies = config.parserOptions?.babelOptions
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { escapePath } from 'tinyglobby';
|
|
2
|
+
import { findImportedCalls, findProperty } from '../../typescript/ast-helpers.js';
|
|
3
|
+
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
5
|
+
import { join, relative, toAbsolute } from '../../util/path.js';
|
|
6
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
7
|
+
import { getViteRoot } from '../vite/helpers.js';
|
|
8
|
+
const title = 'filesystem-routing';
|
|
9
|
+
const enablers = ['filesystem-routing'];
|
|
10
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
11
|
+
const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
12
|
+
const defaultDir = 'src/routes';
|
|
13
|
+
const defaultExtensions = ['js', 'jsx', 'ts', 'tsx', 'tsrx'];
|
|
14
|
+
const production = [`${defaultDir}/**/*.{${defaultExtensions.join(',')}}`];
|
|
15
|
+
const resolveFromAST = (program, { config, cwd }) => {
|
|
16
|
+
if (config.entry)
|
|
17
|
+
return [];
|
|
18
|
+
const root = getViteRoot(program, cwd);
|
|
19
|
+
const toEntry = (dir, pattern) => toProductionEntry(join(cwd, escapePath(relative(cwd, dir)), pattern));
|
|
20
|
+
const calls = findImportedCalls(program, 'filesystem-routing/vite');
|
|
21
|
+
if (calls.length === 0)
|
|
22
|
+
return production.map(pattern => toEntry(root, pattern));
|
|
23
|
+
const inputs = [];
|
|
24
|
+
for (const call of calls) {
|
|
25
|
+
const options = call.arguments[0];
|
|
26
|
+
const dir = getStringValue(findProperty(options, 'dir')) ?? defaultDir;
|
|
27
|
+
const value = findProperty(options, 'extensions');
|
|
28
|
+
const extensions = new Set();
|
|
29
|
+
let useDefaults = value?.type !== 'ArrayExpression';
|
|
30
|
+
if (value?.type === 'ArrayExpression') {
|
|
31
|
+
for (const element of value.elements) {
|
|
32
|
+
const extension = getStringValue(element);
|
|
33
|
+
if (extension === undefined)
|
|
34
|
+
useDefaults = true;
|
|
35
|
+
else
|
|
36
|
+
extensions.add(extension);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (useDefaults)
|
|
40
|
+
for (const extension of defaultExtensions)
|
|
41
|
+
extensions.add(extension);
|
|
42
|
+
if (extensions.size === 0)
|
|
43
|
+
continue;
|
|
44
|
+
const suffix = extensions.size === 1 ? [...extensions][0] : `{${[...extensions].join(',')}}`;
|
|
45
|
+
inputs.push(toEntry(toAbsolute(dir, root), `**/*.${suffix}`));
|
|
46
|
+
}
|
|
47
|
+
return inputs;
|
|
48
|
+
};
|
|
49
|
+
const plugin = {
|
|
50
|
+
title,
|
|
51
|
+
enablers,
|
|
52
|
+
isEnabled,
|
|
53
|
+
config,
|
|
54
|
+
production,
|
|
55
|
+
resolveFromAST,
|
|
56
|
+
};
|
|
57
|
+
export default plugin;
|
|
@@ -29,7 +29,7 @@ const resolveConfig = async (config, options) => {
|
|
|
29
29
|
const path = action?.with?.path;
|
|
30
30
|
for (const step of steps.steps) {
|
|
31
31
|
const workingDir = step['working-directory'];
|
|
32
|
-
const dir = join(rootCwd, path && workingDir ? relative(
|
|
32
|
+
const dir = join(rootCwd, path && workingDir ? relative(path, workingDir) : workingDir ? workingDir : '.');
|
|
33
33
|
if (step.run) {
|
|
34
34
|
const manifest = getManifest(dir) ?? options.manifest;
|
|
35
35
|
const actionPath = relative(dir, configFileDir);
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const Plugins: {
|
|
|
43
43
|
config: string[];
|
|
44
44
|
};
|
|
45
45
|
fast: import("../types/config.ts").Plugin;
|
|
46
|
+
'filesystem-routing': import("../types/config.ts").Plugin;
|
|
46
47
|
flue: import("../types/config.ts").Plugin;
|
|
47
48
|
fumadocs: import("../types/config.ts").Plugin;
|
|
48
49
|
gatsby: import("../types/config.ts").Plugin;
|
|
@@ -137,6 +138,7 @@ export declare const Plugins: {
|
|
|
137
138
|
'serverless-framework': import("../types/config.ts").Plugin;
|
|
138
139
|
'simple-git-hooks': import("../types/config.ts").Plugin;
|
|
139
140
|
'size-limit': import("../types/config.ts").Plugin;
|
|
141
|
+
'solidjs-vite-plugin': import("../types/config.ts").Plugin;
|
|
140
142
|
sst: import("../types/config.ts").Plugin;
|
|
141
143
|
starlight: import("../types/config.ts").Plugin;
|
|
142
144
|
stencil: import("../types/config.ts").Plugin;
|
|
@@ -160,6 +162,7 @@ export declare const Plugins: {
|
|
|
160
162
|
'ts-node': import("../types/config.ts").Plugin;
|
|
161
163
|
tsd: import("../types/config.ts").Plugin;
|
|
162
164
|
tsdown: import("../types/config.ts").Plugin;
|
|
165
|
+
tsrs: import("../types/config.ts").Plugin;
|
|
163
166
|
tsup: import("../types/config.ts").Plugin;
|
|
164
167
|
tsx: import("../types/config.ts").Plugin;
|
|
165
168
|
turbo: import("../types/config.ts").Plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import { default as expo } from './expo/index.js';
|
|
|
37
37
|
import { default as expoRouter } from './expo-router/index.js';
|
|
38
38
|
import { default as expressiveCode } from './expressive-code/index.js';
|
|
39
39
|
import { default as fast } from './fast/index.js';
|
|
40
|
+
import { default as filesystemRouting } from './filesystem-routing/index.js';
|
|
40
41
|
import { default as flue } from './flue/index.js';
|
|
41
42
|
import { default as fumadocs } from './fumadocs/index.js';
|
|
42
43
|
import { default as gatsby } from './gatsby/index.js';
|
|
@@ -131,6 +132,7 @@ import { default as sentry } from './sentry/index.js';
|
|
|
131
132
|
import { default as serverlessFramework } from './serverless-framework/index.js';
|
|
132
133
|
import { default as simpleGitHooks } from './simple-git-hooks/index.js';
|
|
133
134
|
import { default as sizeLimit } from './size-limit/index.js';
|
|
135
|
+
import { default as solidjsVitePlugin } from './solidjs-vite-plugin/index.js';
|
|
134
136
|
import { default as sst } from './sst/index.js';
|
|
135
137
|
import { default as starlight } from './starlight/index.js';
|
|
136
138
|
import { default as stencil } from './stencil/index.js';
|
|
@@ -154,6 +156,7 @@ import { default as travis } from './travis/index.js';
|
|
|
154
156
|
import { default as tsNode } from './ts-node/index.js';
|
|
155
157
|
import { default as tsd } from './tsd/index.js';
|
|
156
158
|
import { default as tsdown } from './tsdown/index.js';
|
|
159
|
+
import { default as tsrs } from './tsrs/index.js';
|
|
157
160
|
import { default as tsup } from './tsup/index.js';
|
|
158
161
|
import { default as tsx } from './tsx/index.js';
|
|
159
162
|
import { default as turbo } from './turbo/index.js';
|
|
@@ -230,6 +233,7 @@ export const Plugins = {
|
|
|
230
233
|
'expo-router': expoRouter,
|
|
231
234
|
'expressive-code': expressiveCode,
|
|
232
235
|
fast,
|
|
236
|
+
'filesystem-routing': filesystemRouting,
|
|
233
237
|
flue,
|
|
234
238
|
fumadocs,
|
|
235
239
|
gatsby,
|
|
@@ -324,6 +328,7 @@ export const Plugins = {
|
|
|
324
328
|
'serverless-framework': serverlessFramework,
|
|
325
329
|
'simple-git-hooks': simpleGitHooks,
|
|
326
330
|
'size-limit': sizeLimit,
|
|
331
|
+
'solidjs-vite-plugin': solidjsVitePlugin,
|
|
327
332
|
sst,
|
|
328
333
|
starlight,
|
|
329
334
|
stencil,
|
|
@@ -347,6 +352,7 @@ export const Plugins = {
|
|
|
347
352
|
'ts-node': tsNode,
|
|
348
353
|
tsd,
|
|
349
354
|
tsdown,
|
|
355
|
+
tsrs,
|
|
350
356
|
tsup,
|
|
351
357
|
tsx,
|
|
352
358
|
turbo,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { arrayify } from '../../util/array.js';
|
|
2
|
-
import { _glob
|
|
2
|
+
import { _glob } from '../../util/glob.js';
|
|
3
3
|
import { toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
|
|
4
|
-
import { isInternal, join, normalize, toAbsolute } from '../../util/path.js';
|
|
4
|
+
import { extname, isInternal, join, normalize, toAbsolute } from '../../util/path.js';
|
|
5
5
|
import { hasDependency } from '../../util/plugin.js';
|
|
6
6
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
7
7
|
import { getReportersDependencies, resolveExtensibleConfig, resolveWithPrefix } from './helpers.js';
|
|
8
|
+
import { createJestMockVisitor } from './visitors/mock.js';
|
|
8
9
|
const title = 'Jest';
|
|
9
10
|
const enablers = ['jest'];
|
|
10
11
|
const isEnabled = ({ dependencies, manifest }) => hasDependency(dependencies, enablers) || Boolean(manifest.name?.startsWith('jest-presets'));
|
|
11
|
-
const
|
|
12
|
+
const configExtensions = ['js', 'ts', 'mjs', 'mts', 'cjs', 'cts', 'json'];
|
|
13
|
+
const configPattern = `jest.config.{${configExtensions.join(',')}}`;
|
|
14
|
+
const config = [configPattern, 'package.json'];
|
|
12
15
|
const mocks = ['**/__mocks__/**/*.[jt]s?(x)'];
|
|
13
16
|
const entry = ['**/__tests__/**/*.?(c|m)[jt]s?(x)', '**/?(*.)+(spec|test).?(c|m)[jt]s?(x)', ...mocks];
|
|
14
17
|
const rootDirRe = /<rootDir>/;
|
|
@@ -27,10 +30,12 @@ const resolveDependencies = async (config, rootDir, options) => {
|
|
|
27
30
|
const projects = [];
|
|
28
31
|
for (const project of config.projects ?? []) {
|
|
29
32
|
if (typeof project === 'string') {
|
|
30
|
-
const
|
|
31
|
-
const files = await _glob({ patterns, cwd: options.cwd });
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
const pattern = project.replace(rootDirRe, rootDir);
|
|
34
|
+
const files = await _glob({ patterns: [pattern, join(pattern, configPattern)], cwd: options.cwd });
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
if (configExtensions.includes(extname(file).slice(1)))
|
|
37
|
+
projects.push(toConfig('jest', file));
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
else {
|
|
36
41
|
const dependencies = await resolveDependencies(project, rootDir, options);
|
|
@@ -127,6 +132,9 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
127
132
|
const args = {
|
|
128
133
|
config: true,
|
|
129
134
|
};
|
|
135
|
+
const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
136
|
+
registerVisitor(createJestMockVisitor(ctx));
|
|
137
|
+
};
|
|
130
138
|
const plugin = {
|
|
131
139
|
title,
|
|
132
140
|
enablers,
|
|
@@ -135,5 +143,6 @@ const plugin = {
|
|
|
135
143
|
entry,
|
|
136
144
|
resolveConfig,
|
|
137
145
|
args,
|
|
146
|
+
registerVisitors,
|
|
138
147
|
};
|
|
139
148
|
export default plugin;
|