knip 6.36.0 → 6.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.d.ts +8 -2
- package/dist/ConfigurationChief.js +15 -1
- package/dist/DependencyDeputy.d.ts +0 -2
- package/dist/DependencyDeputy.js +1 -17
- package/dist/WorkspaceWorker.js +1 -2
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/binaries/command.js +20 -9
- package/dist/binaries/fallback.js +5 -4
- package/dist/binaries/plugins.js +4 -4
- package/dist/binaries/resolvers/bun.js +2 -2
- package/dist/binaries/resolvers/find.js +5 -4
- package/dist/binaries/resolvers/index.d.ts +2 -1
- package/dist/binaries/resolvers/index.js +3 -2
- package/dist/binaries/resolvers/npm.js +46 -4
- package/dist/binaries/resolvers/npx.js +8 -4
- package/dist/binaries/resolvers/nub.js +3 -2
- package/dist/binaries/resolvers/pnpm.js +17 -10
- package/dist/binaries/resolvers/yarn.js +1 -1
- package/dist/binaries/util.d.ts +4 -1
- package/dist/binaries/util.js +2 -0
- package/dist/manifest/index.js +1 -3
- package/dist/plugins/ava/index.js +1 -1
- package/dist/plugins/eslint/helpers.d.ts +2 -1
- package/dist/plugins/eslint/helpers.js +28 -8
- package/dist/plugins/eslint/index.js +2 -2
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/graphql-codegen/index.js +15 -4
- package/dist/plugins/graphql-codegen/types.d.ts +11 -1
- package/dist/plugins/graphql-codegen/types.js +6 -0
- package/dist/plugins/husky/index.js +1 -1
- package/dist/plugins/lefthook/index.js +1 -1
- package/dist/plugins/mise/scripts.js +5 -5
- package/dist/plugins/taskfile/index.js +1 -1
- package/dist/plugins/tauri/index.js +1 -1
- package/dist/plugins/travis/index.js +1 -1
- package/dist/plugins/vite-plus/resolveFromAST.js +1 -1
- package/dist/schema/configuration.d.ts +3 -0
- package/dist/schema/configuration.js +2 -0
- package/dist/types/config.d.ts +4 -1
- package/dist/types/package-json.d.ts +1 -1
- package/dist/util/create-input-handler.js +3 -3
- package/dist/util/create-options.d.ts +8 -2
- package/dist/util/jiti.js +1 -0
- package/dist/util/modules.d.ts +2 -0
- package/dist/util/modules.js +3 -1
- package/dist/util/package-json.d.ts +185 -185
- package/dist/util/parse-args.d.ts +2 -0
- package/dist/util/parse-args.js +6 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/schema.json +12 -0
|
@@ -107,15 +107,35 @@ const getDependenciesFromSettings = (settings = {}) => {
|
|
|
107
107
|
};
|
|
108
108
|
export const getInputsFromSettings = (settings) => compact(getDependenciesFromSettings(settings)).map(id => toDeferResolve(id, { optional: true }));
|
|
109
109
|
const builtinFormatters = new Set(['html', 'json-with-metadata', 'json', 'stylish']);
|
|
110
|
-
|
|
110
|
+
const builtinFormattersUntilV8 = new Set([
|
|
111
|
+
'checkstyle',
|
|
112
|
+
'compact',
|
|
113
|
+
'jslint-xml',
|
|
114
|
+
'junit',
|
|
115
|
+
'tap',
|
|
116
|
+
'unix',
|
|
117
|
+
'visualstudio',
|
|
118
|
+
]);
|
|
119
|
+
const normalizeFormatterName = (name) => {
|
|
120
|
+
if (!name.startsWith('@'))
|
|
121
|
+
return name.startsWith('eslint-formatter-') ? name : `eslint-formatter-${name}`;
|
|
122
|
+
const [scope, id] = name.split('/');
|
|
123
|
+
if (!id)
|
|
124
|
+
return `${scope}/eslint-formatter`;
|
|
125
|
+
return /^eslint-formatter(-|$)/.test(id) ? name : name.replace('/', '/eslint-formatter-');
|
|
126
|
+
};
|
|
127
|
+
export const resolveFormatters = (formatters, manifest) => {
|
|
111
128
|
const inputs = new Set();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
inputs.add(toDeferResolve(formatter));
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
const isBeforeV9 = (manifest.getMajor('eslint') ?? 9) < 9;
|
|
130
|
+
for (const rawFormatter of [formatters].flat()) {
|
|
131
|
+
const formatter = rawFormatter.replace(/\\/g, '/');
|
|
132
|
+
if (!formatter.startsWith('@') && formatter.includes('/')) {
|
|
133
|
+
inputs.add(toDeferResolve(isInternal(formatter) ? formatter : `./${formatter}`));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const isBuiltin = builtinFormatters.has(formatter) || (isBeforeV9 && builtinFormattersUntilV8.has(formatter));
|
|
137
|
+
inputs.add(toDependency(normalizeFormatterName(formatter), isBuiltin ? { optional: true } : {}));
|
|
138
|
+
}
|
|
119
139
|
}
|
|
120
140
|
return inputs;
|
|
121
141
|
};
|
|
@@ -49,12 +49,12 @@ const args = {
|
|
|
49
49
|
config: true,
|
|
50
50
|
alias: { format: ['f'] },
|
|
51
51
|
boolean: ['inspect-config'],
|
|
52
|
-
resolveInputs: (parsed) => {
|
|
52
|
+
resolveInputs: (parsed, { manifest }) => {
|
|
53
53
|
const inputs = [];
|
|
54
54
|
if (parsed['inspect-config'])
|
|
55
55
|
inputs.push(toDependency('@eslint/config-inspector', { optional: true }));
|
|
56
56
|
if (parsed['format'])
|
|
57
|
-
for (const input of resolveFormatters(parsed['format']))
|
|
57
|
+
for (const input of resolveFormatters(parsed['format'], manifest))
|
|
58
58
|
inputs.push(input);
|
|
59
59
|
return inputs;
|
|
60
60
|
},
|
|
@@ -34,7 +34,7 @@ const resolveConfig = async (config, options) => {
|
|
|
34
34
|
const manifest = getManifest(dir) ?? options.manifest;
|
|
35
35
|
const actionPath = relative(dir, configFileDir);
|
|
36
36
|
const run = step.run.replace(ACTION_PATH_VAR, actionPath ? `./${actionPath}` : '.');
|
|
37
|
-
for (const input of getInputsFromScripts([run], {
|
|
37
|
+
for (const input of getInputsFromScripts([run], { optionalBinaries: true, manifest })) {
|
|
38
38
|
if (isDeferResolveEntry(input) && path && !workingDir) {
|
|
39
39
|
input.specifier = relative(join(dir, path), join(rootCwd, input.specifier));
|
|
40
40
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { get } from '../../util/object.js';
|
|
3
|
-
import { isInternal, join } from '../../util/path.js';
|
|
3
|
+
import { isInternal, join, normalize } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
|
-
import { isConfigurationOutput, isGraphqlConfigTypes, isGraphqlProjectsConfigTypes } from './types.js';
|
|
5
|
+
import { isConfigurationOutput, isGraphqlConfigTypes, isGraphqlProjectsConfigTypes, isNearOperationFilePreset, } from './types.js';
|
|
6
6
|
const title = 'GraphQL Codegen';
|
|
7
7
|
const enablers = [/^@graphql-codegen\//, 'graphql-config'];
|
|
8
8
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -24,6 +24,17 @@ const getPluginPackageName = (name) => {
|
|
|
24
24
|
return name;
|
|
25
25
|
return `@graphql-codegen/${name}`;
|
|
26
26
|
};
|
|
27
|
+
const getOutputPattern = (output, outputConfig) => {
|
|
28
|
+
if (isConfigurationOutput(outputConfig) && isNearOperationFilePreset(outputConfig.preset)) {
|
|
29
|
+
const presetConfig = outputConfig.presetConfig ?? {};
|
|
30
|
+
const { folder = '', extension = '.generated.ts', fileName = '*', filePerOperation = false } = presetConfig;
|
|
31
|
+
const subfolder = normalize(folder)
|
|
32
|
+
.split('/')
|
|
33
|
+
.filter(segment => segment !== '' && segment !== '.' && segment !== '..');
|
|
34
|
+
return join(output, '**', ...subfolder, `${filePerOperation ? '*' : fileName}${extension}`);
|
|
35
|
+
}
|
|
36
|
+
return output.endsWith('/') ? `${output}**` : output;
|
|
37
|
+
};
|
|
27
38
|
const resolveConfig = (config, options) => {
|
|
28
39
|
const codegenConfigs = isGraphqlProjectsConfigTypes(config)
|
|
29
40
|
? Object.values(config.projects).flatMap(project => project.extensions?.codegen ?? [])
|
|
@@ -33,8 +44,8 @@ const resolveConfig = (config, options) => {
|
|
|
33
44
|
const generateConfigs = codegenConfigs.filter((config) => Boolean(config?.generates));
|
|
34
45
|
const generateSet = generateConfigs.flatMap(config => Object.values(config.generates));
|
|
35
46
|
const outputs = generateConfigs
|
|
36
|
-
.flatMap(config => Object.
|
|
37
|
-
.map(output => toProductionEntry(join(options.configFileDir,
|
|
47
|
+
.flatMap(config => Object.entries(config.generates))
|
|
48
|
+
.map(([output, outputConfig]) => toProductionEntry(join(options.configFileDir, getOutputPattern(output, outputConfig))));
|
|
38
49
|
const configurationOutput = generateSet.filter(isConfigurationOutput);
|
|
39
50
|
const presets = configurationOutput
|
|
40
51
|
.map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
|
|
@@ -12,10 +12,20 @@ type OutputPreset = {
|
|
|
12
12
|
buildGeneratesSection: (options: unknown) => Promise<unknown>;
|
|
13
13
|
prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: unknown) => Promise<unknown>;
|
|
14
14
|
};
|
|
15
|
+
export interface NearOperationFilePresetConfig {
|
|
16
|
+
baseTypesPath?: string;
|
|
17
|
+
extension?: string;
|
|
18
|
+
fileName?: string;
|
|
19
|
+
filePerOperation?: boolean;
|
|
20
|
+
folder?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export declare const isNearOperationFilePreset: (preset: ConfiguredOutput['preset']) => preset is PresetNames;
|
|
15
24
|
export declare function isConfigurationOutput(config: ConfiguredOutput | ConfiguredPlugin[]): config is ConfiguredOutput;
|
|
16
|
-
interface ConfiguredOutput {
|
|
25
|
+
export interface ConfiguredOutput {
|
|
17
26
|
plugins?: OutputConfig[];
|
|
18
27
|
preset?: PresetNames | OutputPreset;
|
|
28
|
+
presetConfig?: NearOperationFilePresetConfig;
|
|
19
29
|
}
|
|
20
30
|
export interface GraphqlCodegenTypes {
|
|
21
31
|
generates: {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
const nearOperationFilePresetNames = new Set([
|
|
2
|
+
'near-operation-file',
|
|
3
|
+
'near-operation-file-preset',
|
|
4
|
+
'@graphql-codegen/near-operation-file-preset',
|
|
5
|
+
]);
|
|
6
|
+
export const isNearOperationFilePreset = (preset) => typeof preset === 'string' && nearOperationFilePresetNames.has(preset);
|
|
1
7
|
export function isConfigurationOutput(config) {
|
|
2
8
|
return 'preset' in config || 'plugins' in config;
|
|
3
9
|
}
|
|
@@ -17,7 +17,7 @@ const resolveConfig = (script, options) => {
|
|
|
17
17
|
return [toDependency('husky'), ...options.getInputsFromScripts(scripts, { ...options })];
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
return options.getInputsFromScripts(String(script), {
|
|
20
|
+
return options.getInputsFromScripts(String(script), { optionalBinaries: true });
|
|
21
21
|
};
|
|
22
22
|
const plugin = {
|
|
23
23
|
title,
|
|
@@ -21,7 +21,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
21
21
|
const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(id => toDependency(id)) : [];
|
|
22
22
|
if (extname(configFileName) !== '') {
|
|
23
23
|
const scripts = findByKeyDeep(localConfig, 'run').flatMap(command => {
|
|
24
|
-
const deps = getInputsFromScripts([command.run], { ...options,
|
|
24
|
+
const deps = getInputsFromScripts([command.run], { ...options, optionalBinaries: true });
|
|
25
25
|
const dir = command.root ?? cwd;
|
|
26
26
|
return deps.flatMap(dependency => ({ ...dependency, dir }));
|
|
27
27
|
});
|
|
@@ -2,11 +2,11 @@ import { parse } from 'unbash';
|
|
|
2
2
|
import { getDependenciesFromCommand, getInputsFromNodeOptions } from '../../binaries/command.js';
|
|
3
3
|
import { spawningBinaries } from '../../binaries/fallback.js';
|
|
4
4
|
import { isWrapper } from '../../binaries/plugins.js';
|
|
5
|
-
import
|
|
5
|
+
import { isPackageManager } from '../../binaries/resolvers/index.js';
|
|
6
6
|
import { toScript } from '../../binaries/util.js';
|
|
7
7
|
import { SCRIPT_INTERPOLATION } from '../../constants.js';
|
|
8
8
|
import { isBinary } from '../../util/input.js';
|
|
9
|
-
import { extractBinary } from '../../util/modules.js';
|
|
9
|
+
import { extractBinary, isRelativeNodeModulesBin } from '../../util/modules.js';
|
|
10
10
|
import { walkCommands } from '../../util/scripts.js';
|
|
11
11
|
export const getInputsFromMiseScript = (script, options, hasLocalBinPath) => {
|
|
12
12
|
const inputs = [];
|
|
@@ -62,10 +62,10 @@ export const getInputsFromMiseScript = (script, options, hasLocalBinPath) => {
|
|
|
62
62
|
if (!name || !word || definedFunctions.has(name))
|
|
63
63
|
continue;
|
|
64
64
|
const binary = extractBinary(name);
|
|
65
|
-
const
|
|
66
|
-
const isExplicit =
|
|
65
|
+
const isPackageCommand = isPackageManager(binary);
|
|
66
|
+
const isExplicit = isPackageCommand || name.startsWith('./') || isRelativeNodeModulesBin(name);
|
|
67
67
|
const isLocal = hasLocalBinPath && !command.prefix.some(assignment => assignment.name === 'PATH');
|
|
68
|
-
const isWrapperCommand = !
|
|
68
|
+
const isWrapperCommand = !isPackageCommand && isWrapper(binary);
|
|
69
69
|
if (!isExplicit && !isLocal && !isWrapperCommand && binary !== 'node' && binary !== 'find')
|
|
70
70
|
continue;
|
|
71
71
|
let commandInputs;
|
|
@@ -97,7 +97,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
97
97
|
for (const task of Object.values(localConfig.tasks)) {
|
|
98
98
|
for (const script of extractScriptsFromTask(task)) {
|
|
99
99
|
for (const input of getInputsFromScripts([script], {
|
|
100
|
-
|
|
100
|
+
optionalBinaries: true,
|
|
101
101
|
containingFilePath: configFilePath,
|
|
102
102
|
})) {
|
|
103
103
|
if (isProduction)
|
|
@@ -26,7 +26,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
26
26
|
continue;
|
|
27
27
|
const dir = typeof command === 'string' || !command.cwd ? options.cwd : join(options.cwd, command.cwd);
|
|
28
28
|
const manifest = options.getManifest(dir) ?? options.manifest;
|
|
29
|
-
for (const input of options.getInputsFromScripts(script, {
|
|
29
|
+
for (const input of options.getInputsFromScripts(script, { optionalBinaries: true, cwd: dir, manifest })) {
|
|
30
30
|
inputs.push({ ...input, dir });
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -11,7 +11,7 @@ const resolveConfig = async (config, options) => {
|
|
|
11
11
|
const beforeInstall = config.before_install ?? [];
|
|
12
12
|
const beforeScript = config.before_script ?? [];
|
|
13
13
|
const scripts = [beforeDeploy, beforeInstall, beforeScript].flat();
|
|
14
|
-
return options.getInputsFromScripts(scripts, {
|
|
14
|
+
return options.getInputsFromScripts(scripts, { optionalBinaries: true });
|
|
15
15
|
};
|
|
16
16
|
const plugin = {
|
|
17
17
|
title,
|
|
@@ -30,7 +30,7 @@ export const resolveFromAST = (program, options) => {
|
|
|
30
30
|
visitor.visit(program);
|
|
31
31
|
const inputs = [];
|
|
32
32
|
for (const command of commands) {
|
|
33
|
-
for (const input of options.getInputsFromScripts(command, {
|
|
33
|
+
for (const input of options.getInputsFromScripts(command, { optionalBinaries: true }))
|
|
34
34
|
inputs.push(input);
|
|
35
35
|
}
|
|
36
36
|
return inputs;
|
|
@@ -932,6 +932,7 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
|
|
|
932
932
|
ignore: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
933
933
|
ignoreFiles: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
934
934
|
ignoreBinaries: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
935
|
+
ignoreGlobalBinaries: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
935
936
|
ignoreDependencies: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
936
937
|
ignoreMembers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
937
938
|
ignoreUnresolved: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
@@ -1879,6 +1880,7 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1879
1880
|
ignore: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1880
1881
|
ignoreFiles: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1881
1882
|
ignoreBinaries: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
1883
|
+
ignoreGlobalBinaries: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
1882
1884
|
ignoreDependencies: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
1883
1885
|
ignoreMembers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
1884
1886
|
ignoreUnresolved: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
@@ -2833,6 +2835,7 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
2833
2835
|
ignore: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2834
2836
|
ignoreFiles: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2835
2837
|
ignoreBinaries: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
2838
|
+
ignoreGlobalBinaries: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
2836
2839
|
ignoreDependencies: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
2837
2840
|
ignoreMembers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
2838
2841
|
ignoreUnresolved: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniCustom<RegExp, RegExp>]>>>;
|
|
@@ -42,6 +42,7 @@ const rootConfigurationSchema = z.object({
|
|
|
42
42
|
ignore: z.optional(globSchema),
|
|
43
43
|
ignoreFiles: z.optional(globSchema),
|
|
44
44
|
ignoreBinaries: z.optional(stringOrRegexSchema),
|
|
45
|
+
ignoreGlobalBinaries: z.optional(z.boolean()),
|
|
45
46
|
ignoreDependencies: z.optional(stringOrRegexSchema),
|
|
46
47
|
ignoreMembers: z.optional(stringOrRegexSchema),
|
|
47
48
|
ignoreUnresolved: z.optional(stringOrRegexSchema),
|
|
@@ -69,6 +70,7 @@ const baseWorkspaceConfigurationSchema = z.object({
|
|
|
69
70
|
ignore: z.optional(globSchema),
|
|
70
71
|
ignoreFiles: z.optional(globSchema),
|
|
71
72
|
ignoreBinaries: z.optional(stringOrRegexSchema),
|
|
73
|
+
ignoreGlobalBinaries: z.optional(z.boolean()),
|
|
72
74
|
ignoreDependencies: z.optional(stringOrRegexSchema),
|
|
73
75
|
ignoreMembers: z.optional(stringOrRegexSchema),
|
|
74
76
|
ignoreUnresolved: z.optional(stringOrRegexSchema),
|
package/dist/types/config.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type { Tags } from './options.ts';
|
|
|
13
13
|
import type { PluginName } from './PluginNames.ts';
|
|
14
14
|
import type { PackageJson } from './package-json.ts';
|
|
15
15
|
export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
16
|
-
|
|
16
|
+
isForwardedArgs?: boolean;
|
|
17
|
+
optionalBinaries?: boolean;
|
|
17
18
|
containingFilePath: string;
|
|
18
19
|
expandedScripts?: Set<string>;
|
|
19
20
|
}
|
|
@@ -47,6 +48,7 @@ export type GetImportsAndExportsOptions = {
|
|
|
47
48
|
export interface Configuration {
|
|
48
49
|
ignore: NormalizedGlob;
|
|
49
50
|
ignoreBinaries: IgnorePatterns;
|
|
51
|
+
ignoreGlobalBinaries: boolean;
|
|
50
52
|
ignoreDependencies: IgnorePatterns;
|
|
51
53
|
ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
|
|
52
54
|
ignoreFiles: NormalizedGlob;
|
|
@@ -71,6 +73,7 @@ interface BaseWorkspaceConfiguration {
|
|
|
71
73
|
paths: Record<string, string[]>;
|
|
72
74
|
ignore: NormalizedGlob;
|
|
73
75
|
ignoreFiles: NormalizedGlob;
|
|
76
|
+
ignoreGlobalBinaries: boolean;
|
|
74
77
|
ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
|
|
75
78
|
isIncludeEntryExports: boolean;
|
|
76
79
|
}
|
|
@@ -18,7 +18,7 @@ type WithPackageJsonPathAsKey<T> = {
|
|
|
18
18
|
[K in keyof T]: PackageJsonPath<T[K]> extends never ? K : PackageJsonPath<T[K]>;
|
|
19
19
|
};
|
|
20
20
|
type PluginConfig<P> = {
|
|
21
|
-
[K in keyof P as WithPackageJsonPathAsKey<P>[K]]
|
|
21
|
+
[K in keyof P as WithPackageJsonPathAsKey<P>[K]]?: unknown;
|
|
22
22
|
};
|
|
23
23
|
type Plugins = PluginConfig<PluginMap>;
|
|
24
24
|
export type Scripts = Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGNORED_RUNTIME_DEPENDENCIES } from '../constants.js';
|
|
1
|
+
import { IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES } from '../constants.js';
|
|
2
2
|
import { debugLog } from './debug.js';
|
|
3
3
|
import { fromBinary, isBinary, isConfig, isDeferResolve, isDeferResolveEntry, isDependency, toDebugString, } from './input.js';
|
|
4
4
|
import { getPackageNameFromSpecifier } from './modules.js';
|
|
@@ -32,12 +32,12 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
32
32
|
}
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
35
|
+
if (input.optional || (inputWorkspace.config.ignoreGlobalBinaries && IGNORED_GLOBAL_BINARIES.has(binaryName)))
|
|
36
36
|
return;
|
|
37
37
|
addIssue({
|
|
38
38
|
type: 'binaries',
|
|
39
39
|
filePath: containingFilePath,
|
|
40
|
-
workspace:
|
|
40
|
+
workspace: inputWorkspace.name,
|
|
41
41
|
symbol: binaryName,
|
|
42
42
|
specifier,
|
|
43
43
|
fixes: [],
|
|
@@ -979,10 +979,13 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
979
979
|
ignore?: string | string[] | undefined;
|
|
980
980
|
ignoreFiles?: string | string[] | undefined;
|
|
981
981
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
982
|
+
ignoreGlobalBinaries?: boolean | undefined;
|
|
982
983
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
983
984
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
984
985
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
985
|
-
ignoreExportsUsedInFile?: boolean |
|
|
986
|
+
ignoreExportsUsedInFile?: boolean | {
|
|
987
|
+
[x: string]: boolean | undefined;
|
|
988
|
+
} | undefined;
|
|
986
989
|
ignoreIssues?: Record<string, ("binaries" | "catalog" | "catalogReferences" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
987
990
|
cycles?: {
|
|
988
991
|
allow?: string[][] | undefined;
|
|
@@ -1931,10 +1934,13 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1931
1934
|
ignore?: string | string[] | undefined;
|
|
1932
1935
|
ignoreFiles?: string | string[] | undefined;
|
|
1933
1936
|
ignoreBinaries?: (string | RegExp)[] | undefined;
|
|
1937
|
+
ignoreGlobalBinaries?: boolean | undefined;
|
|
1934
1938
|
ignoreDependencies?: (string | RegExp)[] | undefined;
|
|
1935
1939
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
1936
1940
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
1937
|
-
ignoreExportsUsedInFile?: boolean |
|
|
1941
|
+
ignoreExportsUsedInFile?: boolean | {
|
|
1942
|
+
[x: string]: boolean | undefined;
|
|
1943
|
+
} | undefined;
|
|
1938
1944
|
ignoreIssues?: Record<string, ("binaries" | "catalog" | "catalogReferences" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
1939
1945
|
includeEntryExports?: boolean | undefined;
|
|
1940
1946
|
}> | undefined;
|
package/dist/util/jiti.js
CHANGED
package/dist/util/modules.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const getPackageNameFromFilePath: (value: string) => string;
|
|
|
3
3
|
export declare const getPackageNameFromSpecifier: (specifier: string) => string | undefined;
|
|
4
4
|
export declare const isStartsLikePackageName: (specifier: string) => boolean;
|
|
5
5
|
export declare const stripVersionFromSpecifier: (specifier: string) => string;
|
|
6
|
+
export declare const isInNodeModulesBin: (value: string) => boolean;
|
|
7
|
+
export declare const isRelativeNodeModulesBin: (value: string) => boolean;
|
|
6
8
|
export declare const extractBinary: (command: string) => string;
|
|
7
9
|
export declare const isValidBinary: (str: string) => boolean;
|
|
8
10
|
export declare const isDefinitelyTyped: (packageName: string) => boolean;
|
package/dist/util/modules.js
CHANGED
|
@@ -38,7 +38,7 @@ const getPackageNameFromYarnPnpmStore = (posixPath) => {
|
|
|
38
38
|
};
|
|
39
39
|
export const getPackageNameFromFilePath = (value) => {
|
|
40
40
|
const name = value.startsWith('file://') ? value.slice(7) : value;
|
|
41
|
-
if (name
|
|
41
|
+
if (isInNodeModulesBin(name))
|
|
42
42
|
return extractBinary(name);
|
|
43
43
|
const posixPath = toPosix(name);
|
|
44
44
|
const match = posixPath.match(lastPackageNameMatch);
|
|
@@ -56,6 +56,8 @@ export const isStartsLikePackageName = (specifier) => {
|
|
|
56
56
|
return ch === 64 ? isPackageScopeStart(specifier.charCodeAt(1)) : isPackageNameStart(ch);
|
|
57
57
|
};
|
|
58
58
|
export const stripVersionFromSpecifier = (specifier) => specifier.replace(/(\S+)@.*/, '$1');
|
|
59
|
+
export const isInNodeModulesBin = (value) => value.includes('node_modules/.bin/');
|
|
60
|
+
export const isRelativeNodeModulesBin = (value) => /^(?:\.\.?\/)*node_modules\/\.bin\//.test(value);
|
|
59
61
|
const stripNodeModulesFromPath = (command) => command.replace(/(?:\.{0,2}\/)*node_modules\//, '');
|
|
60
62
|
export const extractBinary = (command) => stripVersionFromSpecifier(stripNodeModulesFromPath(command)
|
|
61
63
|
.replace(/^(\.bin\/)/, '')
|