knip 6.14.1 → 6.14.2
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/DependencyDeputy.js +2 -2
- package/dist/binaries/resolvers/bun.js +9 -8
- package/dist/plugins/astro/index.js +1 -0
- package/dist/plugins/graphql-codegen/index.js +4 -0
- package/dist/plugins/serverless-framework/index.js +11 -6
- package/dist/plugins/serverless-framework/types.d.ts +7 -0
- package/dist/plugins/typescript/index.js +1 -1
- package/dist/plugins/vite/helpers.d.ts +1 -1
- package/dist/plugins/vite/helpers.js +20 -30
- package/dist/plugins/vite/index.js +2 -6
- package/dist/util/create-input-handler.js +3 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ following projects:
|
|
|
63
63
|
[14]: https://knip.dev/sponsors
|
|
64
64
|
[15]: https://knip.dev/#created-by-awesome-contributors
|
|
65
65
|
[16]: https://www.youtube.com/watch?v=PE7h7KvQoUI&t=9s
|
|
66
|
-
[17]: ./
|
|
66
|
+
[17]: ./LICENSE
|
|
67
67
|
[18]: https://github.com/npm/package-json
|
|
68
68
|
[19]: https://github.com/npm/package-json/blob/main/LICENSE
|
|
69
69
|
[20]: https://github.com/pnpm/pnpm/tree/main/deps/graph-sequencer
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -179,8 +179,6 @@ export class DependencyDeputy {
|
|
|
179
179
|
maybeAddReferencedBinary(workspace, binaryName) {
|
|
180
180
|
if (!this.isReportDependencies)
|
|
181
181
|
return new Set();
|
|
182
|
-
if (IGNORED_GLOBAL_BINARIES.has(binaryName))
|
|
183
|
-
return new Set();
|
|
184
182
|
this.addReferencedBinary(workspace.name, binaryName);
|
|
185
183
|
const workspaceNames = this.isStrict ? [workspace.name] : [workspace.name, ...[...workspace.ancestors].reverse()];
|
|
186
184
|
for (const name of workspaceNames) {
|
|
@@ -194,6 +192,8 @@ export class DependencyDeputy {
|
|
|
194
192
|
}
|
|
195
193
|
}
|
|
196
194
|
}
|
|
195
|
+
if (IGNORED_GLOBAL_BINARIES.has(binaryName))
|
|
196
|
+
return new Set();
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
isInDependencies(workspaceName, packageName, isDevOnly) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parseArgs from 'minimist';
|
|
2
|
-
import { toEntry } from '../../util/input.js';
|
|
2
|
+
import { toBinary, toEntry } from '../../util/input.js';
|
|
3
3
|
import { isAbsolute, join } from '../../util/path.js';
|
|
4
4
|
import { _resolveSync } from '../../util/resolve.js';
|
|
5
5
|
import { resolveX } from './bunx.js';
|
|
@@ -51,27 +51,28 @@ const commands = new Set([
|
|
|
51
51
|
'x',
|
|
52
52
|
]);
|
|
53
53
|
export const resolve = (_binary, args, options) => {
|
|
54
|
+
const binary = toBinary(_binary);
|
|
54
55
|
const parsed = parseArgs(args, { string: ['cwd'] });
|
|
55
56
|
const [command, script] = parsed._;
|
|
56
57
|
if (command === 'x') {
|
|
57
58
|
const argsForX = args.filter(arg => arg !== 'x');
|
|
58
|
-
return resolveX(argsForX, options);
|
|
59
|
+
return [binary, ...resolveX(argsForX, options)];
|
|
59
60
|
}
|
|
60
61
|
const { manifest, cwd, fromArgs } = options;
|
|
61
62
|
if (command === 'run' && manifest.scriptNames.has(script))
|
|
62
|
-
return [];
|
|
63
|
+
return [binary];
|
|
63
64
|
if (manifest.scriptNames.has(command))
|
|
64
|
-
return [];
|
|
65
|
+
return [binary];
|
|
65
66
|
if (command !== 'run' && commands.has(command))
|
|
66
|
-
return [];
|
|
67
|
+
return [binary];
|
|
67
68
|
const filePath = command === 'run' ? script : command;
|
|
68
69
|
if (!filePath)
|
|
69
|
-
return [];
|
|
70
|
+
return [binary];
|
|
70
71
|
const _cwd = parsed.cwd ? join(cwd, parsed.cwd) : cwd;
|
|
71
72
|
const resolved = _resolveSync(isAbsolute(filePath) ? filePath : join(_cwd, filePath), _cwd);
|
|
72
73
|
if (resolved)
|
|
73
|
-
return [toEntry(resolved)];
|
|
74
|
+
return [binary, toEntry(resolved)];
|
|
74
75
|
const dir = parsed.cwd ? join(cwd, parsed.cwd) : undefined;
|
|
75
76
|
const opts = dir ? { cwd: dir } : {};
|
|
76
|
-
return command === 'run' ? [] : fromArgs(args, opts);
|
|
77
|
+
return command === 'run' ? [binary] : [binary, ...fromArgs(args, opts)];
|
|
77
78
|
};
|
|
@@ -6,6 +6,9 @@ import { isConfigurationOutput, isGraphqlConfigTypes, isGraphqlProjectsConfigTyp
|
|
|
6
6
|
const title = 'GraphQL Codegen';
|
|
7
7
|
const enablers = [/^@graphql-codegen\//, 'graphql-config'];
|
|
8
8
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
9
|
+
const args = {
|
|
10
|
+
config: true,
|
|
11
|
+
};
|
|
9
12
|
const packageJsonPath = manifest => get(manifest, 'codegen') ?? get(manifest, 'graphql');
|
|
10
13
|
const config = [
|
|
11
14
|
'package.json',
|
|
@@ -59,6 +62,7 @@ const resolveConfig = config => {
|
|
|
59
62
|
};
|
|
60
63
|
const plugin = {
|
|
61
64
|
title,
|
|
65
|
+
args,
|
|
62
66
|
enablers,
|
|
63
67
|
isEnabled,
|
|
64
68
|
packageJsonPath,
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
1
|
+
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { isInternal, join } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
const title = 'Serverless Framework';
|
|
4
5
|
const enablers = ['serverless'];
|
|
5
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['serverless.{yml,yaml}'];
|
|
7
|
+
const config = ['serverless.{js,cjs,mjs,ts,cts,mts,yml,yaml}'];
|
|
7
8
|
const handlerToEntry = (handler) => {
|
|
8
9
|
const dot = handler.lastIndexOf('.');
|
|
9
10
|
return toProductionEntry(`${handler.slice(0, dot)}.{js,ts}`);
|
|
10
11
|
};
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const pluginToInput = (plugin, dir) => isInternal(plugin) ? toProductionEntry(join(dir, plugin)) : toDependency(plugin);
|
|
13
|
+
const resolveConfig = async (config, options) => {
|
|
14
|
+
const functions = config.functions
|
|
15
|
+
? Object.values(config.functions).flatMap(fn => (fn.handler ? [handlerToEntry(fn.handler)] : []))
|
|
16
|
+
: [];
|
|
17
|
+
const plugins = config.plugins?.filter((plugin) => typeof plugin === 'string') ?? [];
|
|
18
|
+
const esbuild = config.custom?.esbuild || config.build?.esbuild ? [toDependency('esbuild', { optional: true })] : [];
|
|
19
|
+
return [...functions, ...plugins.map(plugin => pluginToInput(plugin, options.configFileDir)), ...esbuild];
|
|
15
20
|
};
|
|
16
21
|
const plugin = {
|
|
17
22
|
title,
|
|
@@ -32,7 +32,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
32
32
|
return compact([
|
|
33
33
|
...extend,
|
|
34
34
|
...references,
|
|
35
|
-
...types.map(id => toDeferResolve(id, { isTypeOnly: true })),
|
|
35
|
+
...types.map(id => toDeferResolve(id, { isTypeOnly: true, dir: options.cwd })),
|
|
36
36
|
...[...plugins, ...importHelpers].map(id => toDeferResolve(id)),
|
|
37
37
|
...jsx,
|
|
38
38
|
...aliases,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Program } from 'oxc-parser';
|
|
2
2
|
import { type Input } from '../../util/input.ts';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getBabelInputs: (program: Program) => Input[];
|
|
4
4
|
export declare const getIndexHtmlEntries: (rootDir: string) => Promise<Input[]>;
|
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { findProperty,
|
|
2
|
+
import { findProperty, getImportMap, getStringValues } from '../../typescript/ast-helpers.js';
|
|
3
3
|
import { isFile, loadFile } from '../../util/fs.js';
|
|
4
4
|
import { toProductionEntry } from '../../util/input.js';
|
|
5
5
|
import { join } from '../../util/path.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (reactPluginNames.size === 0) {
|
|
15
|
-
const defaultImportName = getDefaultImportName(importMap, '@vitejs/plugin-react');
|
|
16
|
-
if (defaultImportName)
|
|
17
|
-
reactPluginNames.add(defaultImportName);
|
|
18
|
-
else
|
|
19
|
-
reactPluginNames.add('react');
|
|
6
|
+
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
7
|
+
const babelPluginSources = ['@rolldown/plugin-babel', '@vitejs/plugin-react', 'vite-plugin-babel'];
|
|
8
|
+
const isBabelWrappingPlugin = (path) => babelPluginSources.some(source => path === source || path.startsWith(`${source}/`));
|
|
9
|
+
export const getBabelInputs = (program) => {
|
|
10
|
+
const pluginNames = new Set();
|
|
11
|
+
for (const [name, path] of getImportMap(program)) {
|
|
12
|
+
if (isBabelWrappingPlugin(path))
|
|
13
|
+
pluginNames.add(name);
|
|
20
14
|
}
|
|
15
|
+
if (pluginNames.size === 0)
|
|
16
|
+
return [];
|
|
17
|
+
const inputs = [];
|
|
21
18
|
const visitor = new Visitor({
|
|
22
19
|
CallExpression(node) {
|
|
23
|
-
if (node.callee?.type !== 'Identifier' || node.callee.name
|
|
24
|
-
return;
|
|
25
|
-
const config = resolveObjectArg(node.arguments?.[0]);
|
|
26
|
-
const plugins = findProperty(config, 'plugins');
|
|
27
|
-
if (plugins?.type !== 'ArrayExpression')
|
|
20
|
+
if (node.callee?.type !== 'Identifier' || !pluginNames.has(node.callee.name))
|
|
28
21
|
return;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
for (const key of ['plugins', 'presets']) {
|
|
36
|
-
for (const v of getStringValues(findProperty(babel, key)))
|
|
37
|
-
inputs.push(v);
|
|
38
|
-
}
|
|
22
|
+
const options = node.arguments?.[0];
|
|
23
|
+
const plugins = [];
|
|
24
|
+
const presets = [];
|
|
25
|
+
for (const config of [options, findProperty(options, 'babel'), findProperty(options, 'babelConfig')]) {
|
|
26
|
+
plugins.push(...getStringValues(findProperty(config, 'plugins')));
|
|
27
|
+
presets.push(...getStringValues(findProperty(config, 'presets')));
|
|
39
28
|
}
|
|
29
|
+
inputs.push(...getDependenciesFromConfig({ plugins, presets }));
|
|
40
30
|
},
|
|
41
31
|
});
|
|
42
32
|
visitor.visit(program);
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { toDependency } from '../../util/input.js';
|
|
2
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
2
|
import { resolveConfig } from '../vitest/index.js';
|
|
4
|
-
import {
|
|
3
|
+
import { getBabelInputs, getIndexHtmlEntries } from './helpers.js';
|
|
5
4
|
import { createImportMetaGlobVisitor } from './visitors/importMetaGlob.js';
|
|
6
5
|
const title = 'Vite';
|
|
7
6
|
const enablers = ['vite', 'vitest'];
|
|
8
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
9
8
|
export const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
10
|
-
const resolveFromAST = program =>
|
|
11
|
-
const inputs = getReactBabelInputs(program);
|
|
12
|
-
return inputs.map(id => toDependency(id));
|
|
13
|
-
};
|
|
9
|
+
const resolveFromAST = program => getBabelInputs(program);
|
|
14
10
|
const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
15
11
|
registerVisitor(createImportMetaGlobVisitor(ctx));
|
|
16
12
|
};
|
|
@@ -18,7 +18,7 @@ const addExternalRef = (map, containingFilePath, ref) => {
|
|
|
18
18
|
};
|
|
19
19
|
export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, externalRefs, options) => (input, workspace) => {
|
|
20
20
|
const { specifier, containingFilePath } = input;
|
|
21
|
-
if (!containingFilePath
|
|
21
|
+
if (!containingFilePath)
|
|
22
22
|
return;
|
|
23
23
|
if (isBinary(input)) {
|
|
24
24
|
const binaryName = fromBinary(input);
|
|
@@ -44,6 +44,8 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
44
44
|
});
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
+
if (IGNORED_RUNTIME_DEPENDENCIES.has(specifier))
|
|
48
|
+
return;
|
|
47
49
|
const packageName = getPackageNameFromSpecifier(specifier);
|
|
48
50
|
if (packageName &&
|
|
49
51
|
(isDependency(input) ||
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.14.
|
|
1
|
+
export declare const version = "6.14.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.14.
|
|
1
|
+
export const version = '6.14.2';
|