knip 5.51.0 → 5.51.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/dist/binaries/package-manager/pnpm.js +7 -7
- package/dist/graph/build.js +5 -4
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +1 -1
- package/dist/plugins/prettier/index.js +2 -2
- package/dist/plugins/starlight/index.js +1 -1
- package/dist/util/glob.d.ts +4 -0
- package/dist/util/glob.js +2 -0
- package/dist/util/package-json.d.ts +1 -4
- package/dist/util/package-json.js +2 -3
- package/dist/util/to-source-path.d.ts +2 -1
- package/dist/util/to-source-path.js +25 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ const commands = [
|
|
|
30
30
|
'patch-commit',
|
|
31
31
|
'patch-remove',
|
|
32
32
|
'patch',
|
|
33
|
+
'prepare',
|
|
33
34
|
'prune',
|
|
34
35
|
'publish',
|
|
35
36
|
'rb',
|
|
@@ -57,20 +58,19 @@ const commands = [
|
|
|
57
58
|
export const resolve = (_binary, args, options) => {
|
|
58
59
|
const parsed = parseArgs(args, {
|
|
59
60
|
boolean: ['recursive', 'silent', 'shell-mode'],
|
|
60
|
-
alias: { recursive: 'r', silent: 's', 'shell-mode': 'c' },
|
|
61
|
+
alias: { recursive: 'r', silent: 's', 'shell-mode': 'c', filter: 'F' },
|
|
61
62
|
});
|
|
62
|
-
const [command
|
|
63
|
+
const [command] = parsed._;
|
|
63
64
|
if (command === 'dlx') {
|
|
64
65
|
const argsForDlx = args.filter(arg => arg !== 'dlx');
|
|
65
66
|
return resolveDlx(argsForDlx, options);
|
|
66
67
|
}
|
|
67
68
|
const { manifestScriptNames, fromArgs } = options;
|
|
69
|
+
if (parsed.filter)
|
|
70
|
+
return [];
|
|
68
71
|
if (manifestScriptNames.has(command) || commands.includes(command))
|
|
69
72
|
return [];
|
|
70
|
-
if (command === 'exec')
|
|
71
|
-
|
|
72
|
-
return [toBinary(binary), ...fromArgs(parsed._.slice(1))];
|
|
73
|
-
return [toBinary(binary)];
|
|
74
|
-
}
|
|
73
|
+
if (command === 'exec')
|
|
74
|
+
return fromArgs(parsed._.slice(1));
|
|
75
75
|
return command ? [toBinary(command)] : [];
|
|
76
76
|
};
|
package/dist/graph/build.js
CHANGED
|
@@ -10,12 +10,13 @@ import { getOrCreateFileNode, updateImportMap } from '../util/module-graph.js';
|
|
|
10
10
|
import { getEntryPathsFromManifest } from '../util/package-json.js';
|
|
11
11
|
import { dirname, isAbsolute, join, relative } from '../util/path.js';
|
|
12
12
|
import {} from '../util/tag.js';
|
|
13
|
-
import { augmentWorkspace, getToSourcePathHandler } from '../util/to-source-path.js';
|
|
13
|
+
import { augmentWorkspace, getToSourcePathHandler, getToSourcePathsHandler } from '../util/to-source-path.js';
|
|
14
14
|
import { loadTSConfig } from '../util/tsconfig-loader.js';
|
|
15
15
|
export async function build({ cacheLocation, chief, collector, cwd, deputy, factory, gitignore, isCache, isFixExports, isFixTypes, isGitIgnored, isIsolateWorkspaces, isProduction, isSkipLibs, isStrict, isWatch, report, streamer, tags, tsConfigFile, workspaces, }) {
|
|
16
16
|
const configFilesMap = new Map();
|
|
17
17
|
const enabledPluginsStore = new Map();
|
|
18
18
|
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
19
|
+
const toSourceFilePaths = getToSourcePathsHandler(chief);
|
|
19
20
|
const getReferencedInternalFilePath = getReferencedInputsHandler(collector, deputy, chief, isGitIgnored);
|
|
20
21
|
const isReportClassMembers = report.classMembers;
|
|
21
22
|
for (const workspace of workspaces) {
|
|
@@ -71,9 +72,9 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
71
72
|
const ignore = worker.getIgnorePatterns();
|
|
72
73
|
const sharedGlobOptions = { cwd, dir, gitignore };
|
|
73
74
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
74
|
-
const entryPathsFromManifest =
|
|
75
|
-
for (const filePath of entryPathsFromManifest) {
|
|
76
|
-
inputs.add(toProductionEntry(
|
|
75
|
+
const entryPathsFromManifest = getEntryPathsFromManifest(manifest);
|
|
76
|
+
for (const filePath of await toSourceFilePaths(entryPathsFromManifest, dir, extensionGlobStr)) {
|
|
77
|
+
inputs.add(toProductionEntry(filePath));
|
|
77
78
|
}
|
|
78
79
|
const principal = factory.createPrincipal({
|
|
79
80
|
cwd: dir,
|
|
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Astro';
|
|
4
4
|
const enablers = ['astro'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['astro.config.{js,cjs,mjs,ts}'];
|
|
6
|
+
export const config = ['astro.config.{js,cjs,mjs,ts,mts}'];
|
|
7
7
|
const entry = ['src/content/config.ts', 'src/content.config.ts'];
|
|
8
8
|
const production = [
|
|
9
9
|
'src/pages/**/*.{astro,mdx,js,ts}',
|
|
@@ -5,8 +5,8 @@ const enablers = ['prettier'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = [
|
|
7
7
|
'.prettierrc',
|
|
8
|
-
'.prettierrc.{json,js,cjs,mjs,yml,yaml,toml,json5}',
|
|
9
|
-
'prettier.config.{js,cjs,mjs}',
|
|
8
|
+
'.prettierrc.{json,js,cjs,mjs,ts,cts,mts,yml,yaml,toml,json5}',
|
|
9
|
+
'prettier.config.{js,cjs,mjs,ts,cts,mts}',
|
|
10
10
|
'package.{json,yaml}',
|
|
11
11
|
];
|
|
12
12
|
const resolveConfig = config => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { config } from '../astro/index.js';
|
|
3
4
|
import { getComponentPathsFromSourceFile } from './resolveFromAST.js';
|
|
4
5
|
const title = 'Starlight';
|
|
5
6
|
const enablers = ['@astrojs/starlight'];
|
|
6
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
-
const config = ['astro.config.{js,cjs,mjs,ts}'];
|
|
8
8
|
const resolveFromAST = (sourceFile) => {
|
|
9
9
|
const componentPaths = getComponentPathsFromSourceFile(sourceFile);
|
|
10
10
|
return Array.from(componentPaths).map(id => toProductionEntry(id));
|
package/dist/util/glob.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare const negate: (pattern: string) => string;
|
|
|
11
11
|
export declare const hasProductionSuffix: (pattern: string) => boolean;
|
|
12
12
|
export declare const hasNoProductionSuffix: (pattern: string) => boolean;
|
|
13
13
|
export declare const _glob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
|
|
14
|
+
export declare const _syncGlob: ({ cwd, patterns }: {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
patterns: string | string[];
|
|
17
|
+
}) => string[];
|
|
14
18
|
export declare const _firstGlob: ({ cwd, patterns }: GlobOptions) => Promise<string | Buffer<ArrayBufferLike> | undefined>;
|
|
15
19
|
export declare const _dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
|
|
16
20
|
export {};
|
package/dist/util/glob.js
CHANGED
|
@@ -34,6 +34,7 @@ const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }
|
|
|
34
34
|
label,
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
+
const syncGlob = ({ cwd, patterns }) => fg.sync(patterns, { cwd });
|
|
37
38
|
const firstGlob = async ({ cwd, patterns }) => {
|
|
38
39
|
const stream = fg.globStream(patterns.map(removeProductionSuffix), { cwd, ignore: GLOBAL_IGNORE_PATTERNS });
|
|
39
40
|
for await (const entry of stream) {
|
|
@@ -47,5 +48,6 @@ const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns, {
|
|
|
47
48
|
gitignore,
|
|
48
49
|
});
|
|
49
50
|
export const _glob = timerify(defaultGlob);
|
|
51
|
+
export const _syncGlob = timerify(syncGlob);
|
|
50
52
|
export const _firstGlob = timerify(firstGlob);
|
|
51
53
|
export const _dirGlob = timerify(dirGlob);
|
|
@@ -7,8 +7,5 @@ interface ExtendedPackageJson extends PackageJson {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
|
|
9
9
|
export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
|
|
10
|
-
export declare const getEntryPathsFromManifest: (manifest: PackageJson
|
|
11
|
-
cwd: string;
|
|
12
|
-
ignore: string[];
|
|
13
|
-
}) => Promise<string[]>;
|
|
10
|
+
export declare const getEntryPathsFromManifest: (manifest: PackageJson) => Set<string>;
|
|
14
11
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { _glob } from './glob.js';
|
|
3
2
|
const INDENT = Symbol.for('indent');
|
|
4
3
|
const NEWLINE = Symbol.for('newline');
|
|
5
4
|
const DEFAULT_NEWLINE = '\n';
|
|
@@ -46,7 +45,7 @@ export const save = async (filePath, content) => {
|
|
|
46
45
|
const fileContent = `${JSON.stringify(content, null, space)}\n`.replace(/\n/g, EOL);
|
|
47
46
|
await writeFile(filePath, fileContent);
|
|
48
47
|
};
|
|
49
|
-
export const getEntryPathsFromManifest = (manifest
|
|
48
|
+
export const getEntryPathsFromManifest = (manifest) => {
|
|
50
49
|
const { main, module, browser, bin, exports, types, typings } = manifest;
|
|
51
50
|
const entryPaths = new Set();
|
|
52
51
|
if (typeof main === 'string')
|
|
@@ -77,5 +76,5 @@ export const getEntryPathsFromManifest = (manifest, options) => {
|
|
|
77
76
|
entryPaths.add(types);
|
|
78
77
|
if (typeof typings === 'string')
|
|
79
78
|
entryPaths.add(typings);
|
|
80
|
-
return
|
|
79
|
+
return entryPaths;
|
|
81
80
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CompilerOptions } from 'typescript';
|
|
2
2
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
3
3
|
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
|
|
4
|
-
export declare const getToSourcePathHandler: (chief: ConfigurationChief) => (filePath: string
|
|
4
|
+
export declare const getToSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
5
|
+
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, cwd: string, extensions?: string) => Promise<string[]>;
|
|
5
6
|
export type ToSourceFilePath = ReturnType<typeof getToSourcePathHandler>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fastGlob from 'fast-glob';
|
|
2
1
|
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
3
|
-
import { debugLog } from './debug.js';
|
|
2
|
+
import { debugLog, debugLogArray } from './debug.js';
|
|
4
3
|
import { isDirectory } from './fs.js';
|
|
5
|
-
import {
|
|
4
|
+
import { _glob, _syncGlob } from './glob.js';
|
|
5
|
+
import { isAbsolute, isInternal, join, toRelative } from './path.js';
|
|
6
6
|
const defaultExtensions = `.{${DEFAULT_EXTENSIONS.map(ext => ext.slice(1)).join(',')}}`;
|
|
7
7
|
const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
|
|
8
8
|
const hasDTSExt = /.d\.(m|c)?ts$/;
|
|
@@ -14,7 +14,7 @@ export const augmentWorkspace = (workspace, dir, compilerOptions) => {
|
|
|
14
14
|
};
|
|
15
15
|
export const getToSourcePathHandler = (chief) => {
|
|
16
16
|
const toSourceMapCache = new Map();
|
|
17
|
-
return (filePath
|
|
17
|
+
return (filePath) => {
|
|
18
18
|
if (!isInternal(filePath) || hasTSExt.test(filePath))
|
|
19
19
|
return;
|
|
20
20
|
if (toSourceMapCache.has(filePath))
|
|
@@ -23,8 +23,8 @@ export const getToSourcePathHandler = (chief) => {
|
|
|
23
23
|
if (workspace?.srcDir && workspace.outDir) {
|
|
24
24
|
if ((!filePath.startsWith(workspace.srcDir) && filePath.startsWith(workspace.outDir)) ||
|
|
25
25
|
(workspace.srcDir === workspace.outDir && hasDTSExt.test(filePath))) {
|
|
26
|
-
const pattern = filePath.replace(workspace.outDir, workspace.srcDir).replace(matchExt,
|
|
27
|
-
const
|
|
26
|
+
const pattern = filePath.replace(workspace.outDir, workspace.srcDir).replace(matchExt, defaultExtensions);
|
|
27
|
+
const srcFilePath = _syncGlob({ patterns: pattern })[0];
|
|
28
28
|
toSourceMapCache.set(filePath, srcFilePath);
|
|
29
29
|
if (srcFilePath && srcFilePath !== filePath) {
|
|
30
30
|
debugLog('*', `Source mapping ${toRelative(filePath)} → ${toRelative(srcFilePath)}`);
|
|
@@ -34,3 +34,22 @@ export const getToSourcePathHandler = (chief) => {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
+
export const getToSourcePathsHandler = (chief) => {
|
|
38
|
+
return async (specifiers, cwd, extensions = defaultExtensions) => {
|
|
39
|
+
const patterns = new Set();
|
|
40
|
+
for (const specifier of specifiers) {
|
|
41
|
+
const absSpecifier = isAbsolute(specifier) ? specifier : join(cwd, specifier);
|
|
42
|
+
const ws = chief.findWorkspaceByFilePath(absSpecifier);
|
|
43
|
+
if (ws?.srcDir && ws.outDir && !absSpecifier.startsWith(ws.srcDir) && absSpecifier.startsWith(ws.outDir)) {
|
|
44
|
+
const pattern = absSpecifier.replace(ws.outDir, ws.srcDir).replace(matchExt, extensions);
|
|
45
|
+
patterns.add(pattern);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
patterns.add(absSpecifier);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const filePaths = await _glob({ patterns: Array.from(patterns), cwd });
|
|
52
|
+
debugLogArray(toRelative(cwd), 'Source mapping (package.json)', filePaths);
|
|
53
|
+
return filePaths;
|
|
54
|
+
};
|
|
55
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.51.
|
|
1
|
+
export declare const version = "5.51.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.51.
|
|
1
|
+
export const version = '5.51.1';
|