knip 6.9.0 → 6.11.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/DependencyDeputy.d.ts +2 -1
- package/dist/DependencyDeputy.js +10 -6
- package/dist/cli.js +1 -0
- package/dist/graph/analyze.js +8 -5
- package/dist/graph/build.js +15 -1
- package/dist/manifest/helpers.js +39 -8
- package/dist/plugins/typescript/index.js +2 -1
- package/dist/reporters/symbols.js +5 -2
- package/dist/reporters/util/configuration-hints.d.ts +1 -0
- package/dist/reporters/util/configuration-hints.js +2 -0
- package/dist/types/issues.d.ts +1 -0
- package/dist/types/package-json.d.ts +1 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/get-imports-and-exports.js +4 -3
- package/dist/util/create-input-handler.js +1 -1
- package/dist/util/create-options.d.ts +1 -0
- package/dist/util/create-options.js +1 -0
- package/dist/util/input.d.ts +2 -0
- package/dist/util/load-tsconfig.d.ts +6 -2
- package/dist/util/load-tsconfig.js +31 -34
- package/dist/util/tag.d.ts +1 -0
- package/dist/util/tag.js +2 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ export declare class DependencyDeputy {
|
|
|
35
35
|
optionalPeerDependencies: DependencySet;
|
|
36
36
|
requiredPeerDependencies: DependencyArray;
|
|
37
37
|
allDependencies: DependencySet;
|
|
38
|
+
engines: Record<string, string>;
|
|
38
39
|
ignoreDependencies: (string | RegExp)[];
|
|
39
40
|
ignoreBinaries: (string | RegExp)[];
|
|
40
41
|
ignoreUnresolved: (string | RegExp)[];
|
|
@@ -57,7 +58,7 @@ export declare class DependencyDeputy {
|
|
|
57
58
|
isPeerOptional: boolean;
|
|
58
59
|
}[];
|
|
59
60
|
getOptionalPeerDependencies(workspaceName: string): DependencySet;
|
|
60
|
-
maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string, isDevOnly?: boolean): boolean;
|
|
61
|
+
maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string, isDevOnly?: boolean, isTypeOnly?: boolean): boolean;
|
|
61
62
|
maybeAddReferencedBinary(workspace: Workspace, binaryName: string): Set<string> | undefined;
|
|
62
63
|
private isInDependencies;
|
|
63
64
|
settleDependencyIssues(): {
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -73,6 +73,7 @@ export class DependencyDeputy {
|
|
|
73
73
|
optionalPeerDependencies,
|
|
74
74
|
requiredPeerDependencies,
|
|
75
75
|
allDependencies: new Set(allDependencies),
|
|
76
|
+
engines: manifest.engines ?? {},
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
getWorkspaceManifest(workspaceName) {
|
|
@@ -128,7 +129,7 @@ export class DependencyDeputy {
|
|
|
128
129
|
getOptionalPeerDependencies(workspaceName) {
|
|
129
130
|
return this._manifests.get(workspaceName)?.optionalPeerDependencies ?? new Set();
|
|
130
131
|
}
|
|
131
|
-
maybeAddReferencedExternalDependency(workspace, packageName, isDevOnly) {
|
|
132
|
+
maybeAddReferencedExternalDependency(workspace, packageName, isDevOnly, isTypeOnly) {
|
|
132
133
|
if (!this.isReportDependencies)
|
|
133
134
|
return true;
|
|
134
135
|
if (isBuiltin(packageName))
|
|
@@ -141,13 +142,16 @@ export class DependencyDeputy {
|
|
|
141
142
|
const closestWorkspaceName = workspaceNames.find(name => this.isInDependencies(name, packageName, isDevOnly));
|
|
142
143
|
const typesPackageName = !isDefinitelyTyped(packageName) && getDefinitelyTypedFor(packageName);
|
|
143
144
|
const closestWorkspaceNameForTypes = typesPackageName && workspaceNames.find(name => this.isInDependencies(name, typesPackageName, isDevOnly));
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.addReferencedDependency(closestWorkspaceNameForTypes, typesPackageName);
|
|
145
|
+
if (closestWorkspaceNameForTypes && !this.hasTypesIncluded.get(closestWorkspaceNameForTypes)?.has(packageName))
|
|
146
|
+
this.addReferencedDependency(closestWorkspaceNameForTypes, typesPackageName);
|
|
147
|
+
if (closestWorkspaceName) {
|
|
148
|
+
this.addReferencedDependency(closestWorkspaceName, packageName);
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
151
|
+
if (closestWorkspaceNameForTypes && isTypeOnly)
|
|
152
|
+
return true;
|
|
153
|
+
if (this._manifests.get(workspace.name)?.engines[packageName])
|
|
154
|
+
return true;
|
|
151
155
|
this.addReferencedDependency(workspace.name, packageName);
|
|
152
156
|
return false;
|
|
153
157
|
}
|
package/dist/cli.js
CHANGED
|
@@ -46,6 +46,7 @@ const main = async () => {
|
|
|
46
46
|
cwd: options.cwd,
|
|
47
47
|
configFilePath: options.configFilePath,
|
|
48
48
|
isDisableConfigHints: options.isDisableConfigHints,
|
|
49
|
+
isDisableTagHints: options.isDisableTagHints,
|
|
49
50
|
isProduction: options.isProduction,
|
|
50
51
|
isShowProgress: options.isShowProgress,
|
|
51
52
|
isTreatConfigHintsAsErrors: options.isTreatConfigHintsAsErrors,
|
package/dist/graph/analyze.js
CHANGED
|
@@ -5,7 +5,8 @@ import { shouldCountRefs } from '../typescript/visitors/helpers.js';
|
|
|
5
5
|
import { getPackageNameFromModuleSpecifier } from '../util/modules.js';
|
|
6
6
|
import { perfObserver } from '../util/Performance.js';
|
|
7
7
|
import { findMatch } from '../util/regex.js';
|
|
8
|
-
import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from '../util/tag.js';
|
|
8
|
+
import { getShouldIgnoreHandler, getShouldIgnoreTagHandler, isAlwaysIgnored } from '../util/tag.js';
|
|
9
|
+
import { INTERNAL_TAG } from '../constants.js';
|
|
9
10
|
export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, graph, streamer, unreferencedFiles, options, }) => {
|
|
10
11
|
const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
|
|
11
12
|
const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
|
|
@@ -54,9 +55,10 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
54
55
|
}
|
|
55
56
|
const importsForExport = file.importedBy;
|
|
56
57
|
for (const [identifier, exportedItem] of exportItems) {
|
|
57
|
-
if (
|
|
58
|
+
if (isAlwaysIgnored(exportedItem.jsDocTags))
|
|
58
59
|
continue;
|
|
59
|
-
const
|
|
60
|
+
const isInternalProd = options.isProduction && exportedItem.jsDocTags.has(INTERNAL_TAG);
|
|
61
|
+
const isIgnored = shouldIgnoreTags(exportedItem.jsDocTags) || isInternalProd;
|
|
60
62
|
if (importsForExport) {
|
|
61
63
|
const [isReferenced, reExportingEntryFile] = explorer.isReferenced(filePath, identifier, {
|
|
62
64
|
includeEntryExports: isIncludeEntryExports,
|
|
@@ -64,7 +66,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
64
66
|
if (isIgnored &&
|
|
65
67
|
(isReferenced || isReferencedInUsedExport(exportedItem, filePath, isIncludeEntryExports))) {
|
|
66
68
|
for (const tagName of exportedItem.jsDocTags) {
|
|
67
|
-
if (options.tags[1].includes(tagName)) {
|
|
69
|
+
if (options.tags[1].includes(tagName) || (isInternalProd && tagName === INTERNAL_TAG)) {
|
|
68
70
|
collector.addTagHint({ type: 'tag', filePath, identifier, tagName });
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -171,7 +173,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
171
173
|
if (file.imports?.external) {
|
|
172
174
|
for (const extImport of file.imports.external) {
|
|
173
175
|
const packageName = getPackageNameFromModuleSpecifier(extImport.specifier);
|
|
174
|
-
const isHandled = packageName &&
|
|
176
|
+
const isHandled = packageName &&
|
|
177
|
+
deputy.maybeAddReferencedExternalDependency(ws, packageName, undefined, extImport.isTypeOnly);
|
|
175
178
|
if (!isHandled)
|
|
176
179
|
collector.addIssue({
|
|
177
180
|
type: 'unlisted',
|
package/dist/graph/build.js
CHANGED
|
@@ -5,6 +5,7 @@ import { partition } from '../util/array.js';
|
|
|
5
5
|
import { createInputHandler } from '../util/create-input-handler.js';
|
|
6
6
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
8
|
+
import picomatch from 'picomatch';
|
|
8
9
|
import { tryRealpath } from '../util/fs.js';
|
|
9
10
|
import { createManifest } from '../util/package-json.js';
|
|
10
11
|
import { _glob, _syncGlob, negate, prependDirToPattern as prependDir } from '../util/glob.js';
|
|
@@ -57,7 +58,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
57
58
|
const dependencies = deputy.getDependencies(name);
|
|
58
59
|
const baseConfig = chief.getConfigForWorkspace(name);
|
|
59
60
|
const tsConfigFilePath = join(dir, options.tsConfigFile ?? 'tsconfig.json');
|
|
60
|
-
const { isFile, compilerOptions, fileNames } = await loadTSConfig(tsConfigFilePath);
|
|
61
|
+
const { isFile, compilerOptions, fileNames, include, exclude } = await loadTSConfig(tsConfigFilePath);
|
|
61
62
|
const [definitionPaths, tscSourcePaths] = partition(fileNames, filePath => IS_DTS.test(filePath));
|
|
62
63
|
const worker = new WorkspaceWorker({
|
|
63
64
|
name,
|
|
@@ -249,6 +250,19 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
249
250
|
principal.addProjectPath(filePath);
|
|
250
251
|
}
|
|
251
252
|
}
|
|
253
|
+
if (extensions.length > 0) {
|
|
254
|
+
const extPart = extensions.length === 1 ? extensions[0] : `.{${extensions.map(ext => ext.slice(1)).join(',')}}`;
|
|
255
|
+
const bases = include ? new Set(include.map(p => picomatch.scan(p).base || dir)) : new Set([dir]);
|
|
256
|
+
const patterns = [
|
|
257
|
+
...Array.from(bases, base => `${base}/**/*${extPart}`),
|
|
258
|
+
...(exclude?.map(p => `!${p}`) ?? []),
|
|
259
|
+
];
|
|
260
|
+
const compilerPaths = await _glob({ ...sharedGlobOptions, patterns, label: 'compiler extension paths' });
|
|
261
|
+
for (const compilerPath of compilerPaths) {
|
|
262
|
+
if (!isIgnoredWorkspace(compilerPath))
|
|
263
|
+
principal.addProjectPath(compilerPath);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
252
266
|
}
|
|
253
267
|
else {
|
|
254
268
|
const patterns = options.isProduction
|
package/dist/manifest/helpers.js
CHANGED
|
@@ -1,17 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from '../util/path.js';
|
|
2
3
|
import { _require } from '../util/require.js';
|
|
4
|
+
const monorepoRootCache = new Map();
|
|
5
|
+
const findMonorepoRootAbove = (startDir) => {
|
|
6
|
+
if (monorepoRootCache.has(startDir))
|
|
7
|
+
return monorepoRootCache.get(startDir);
|
|
8
|
+
let current = dirname(startDir);
|
|
9
|
+
let result;
|
|
10
|
+
while (current !== dirname(current)) {
|
|
11
|
+
if (existsSync(join(current, 'pnpm-workspace.yaml'))) {
|
|
12
|
+
result = current;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const pkg = JSON.parse(readFileSync(join(current, 'package.json'), 'utf8'));
|
|
17
|
+
if (pkg.workspaces) {
|
|
18
|
+
result = current;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch { }
|
|
23
|
+
current = dirname(current);
|
|
24
|
+
}
|
|
25
|
+
monorepoRootCache.set(startDir, result);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
3
28
|
export const loadPackageManifest = ({ dir, packageName, cwd }) => {
|
|
4
29
|
try {
|
|
5
30
|
return _require(join(dir, 'node_modules', packageName, 'package.json'));
|
|
6
31
|
}
|
|
7
|
-
catch
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
32
|
+
catch { }
|
|
33
|
+
if (dir !== cwd) {
|
|
34
|
+
try {
|
|
35
|
+
return _require(join(cwd, 'node_modules', packageName, 'package.json'));
|
|
36
|
+
}
|
|
37
|
+
catch { }
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const root = findMonorepoRootAbove(cwd);
|
|
41
|
+
if (root) {
|
|
42
|
+
try {
|
|
43
|
+
return _require(join(root, 'node_modules', packageName, 'package.json'));
|
|
14
44
|
}
|
|
45
|
+
catch { }
|
|
15
46
|
}
|
|
16
47
|
};
|
|
17
48
|
export const getFilteredScripts = (scripts) => {
|
|
@@ -32,7 +32,8 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
32
32
|
return compact([
|
|
33
33
|
...extend,
|
|
34
34
|
...references,
|
|
35
|
-
...
|
|
35
|
+
...types.map(id => toDeferResolve(id, { isTypeOnly: true })),
|
|
36
|
+
...[...plugins, ...importHelpers].map(id => toDeferResolve(id)),
|
|
36
37
|
...jsx,
|
|
37
38
|
...aliases,
|
|
38
39
|
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { printConfigurationHints } from './util/configuration-hints.js';
|
|
1
|
+
import { printConfigurationHints, printTagHints } from './util/configuration-hints.js';
|
|
2
2
|
import { dim, flattenIssues, getColoredTitle, getIssueTypeTitle, getTableForType } from './util/util.js';
|
|
3
3
|
export default (options) => {
|
|
4
|
-
const { report, issues, isDisableConfigHints, isShowProgress } = options;
|
|
4
|
+
const { report, issues, isDisableConfigHints, isDisableTagHints, isShowProgress } = options;
|
|
5
5
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
6
6
|
let totalIssues = 0;
|
|
7
7
|
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
@@ -24,6 +24,9 @@ export default (options) => {
|
|
|
24
24
|
if (!isDisableConfigHints) {
|
|
25
25
|
printConfigurationHints(options);
|
|
26
26
|
}
|
|
27
|
+
if (!isDisableTagHints) {
|
|
28
|
+
printTagHints(options);
|
|
29
|
+
}
|
|
27
30
|
if (totalIssues === 0 &&
|
|
28
31
|
isShowProgress &&
|
|
29
32
|
(!options.isTreatConfigHintsAsErrors || options.configurationHints.length === 0)) {
|
|
@@ -19,4 +19,5 @@ export declare const finalizeConfigurationHints: (results: Results, options: {
|
|
|
19
19
|
configFilePath?: string;
|
|
20
20
|
}) => ProcessedHint[];
|
|
21
21
|
export declare const printConfigurationHints: ({ cwd, counters, issues, tagHints, configurationHints, enabledPlugins, isTreatConfigHintsAsErrors, includedWorkspaceDirs, selectedWorkspaces, configFilePath, }: ReporterOptions) => void;
|
|
22
|
+
export declare const printTagHints: ({ cwd, tagHints }: ReporterOptions) => void;
|
|
22
23
|
export {};
|
|
@@ -127,6 +127,8 @@ export const printConfigurationHints = ({ cwd, counters, issues, tagHints, confi
|
|
|
127
127
|
console.log(getTitle('Configuration hints', configurationHints.length));
|
|
128
128
|
console.warn(getTableForHints(rows).toString());
|
|
129
129
|
}
|
|
130
|
+
};
|
|
131
|
+
export const printTagHints = ({ cwd, tagHints }) => {
|
|
130
132
|
if (tagHints.size > 0) {
|
|
131
133
|
console.log(getDimmedTitle('Tag hints', tagHints.size));
|
|
132
134
|
for (const hint of tagHints) {
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export type ReporterOptions = {
|
|
|
54
54
|
configurationHints: ConfigurationHint[];
|
|
55
55
|
enabledPlugins: Record<string, string[]>;
|
|
56
56
|
isDisableConfigHints: boolean;
|
|
57
|
+
isDisableTagHints: boolean;
|
|
57
58
|
isTreatConfigHintsAsErrors: boolean;
|
|
58
59
|
cwd: string;
|
|
59
60
|
isProduction: boolean;
|
|
@@ -10,6 +10,7 @@ type WorkspaceManifest = {
|
|
|
10
10
|
optionalPeerDependencies: DependencySet;
|
|
11
11
|
requiredPeerDependencies: DependencyArray;
|
|
12
12
|
allDependencies: DependencySet;
|
|
13
|
+
engines: Record<string, string>;
|
|
13
14
|
ignoreDependencies: (string | RegExp)[];
|
|
14
15
|
ignoreBinaries: (string | RegExp)[];
|
|
15
16
|
ignoreUnresolved: (string | RegExp)[];
|
|
@@ -11,6 +11,7 @@ import { buildJSDocTagLookup } from './visitors/jsdoc.js';
|
|
|
11
11
|
import { walkAST } from './visitors/walk.js';
|
|
12
12
|
const getImportsAndExports = (filePath, sourceText, resolveModule, options, ignoreExportsUsedInFile, skipExportsForFile, visitor, pluginCtx, cachedParseResult) => {
|
|
13
13
|
const skipExports = skipExportsForFile || !options.isReportExports;
|
|
14
|
+
const isDts = filePath.endsWith('.d.ts') || filePath.endsWith('.d.cts') || filePath.endsWith('.d.mts');
|
|
14
15
|
const internal = new Map();
|
|
15
16
|
const external = new Set();
|
|
16
17
|
const unresolved = new Set();
|
|
@@ -53,7 +54,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
53
54
|
pos: opts.pos,
|
|
54
55
|
line: opts.line,
|
|
55
56
|
col: opts.col,
|
|
56
|
-
isTypeOnly: !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
57
|
+
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
57
58
|
});
|
|
58
59
|
const file = internal.get(importFilePath);
|
|
59
60
|
const importMaps = file ?? createImports();
|
|
@@ -129,7 +130,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
129
130
|
pos: ePos,
|
|
130
131
|
line,
|
|
131
132
|
col,
|
|
132
|
-
isTypeOnly: !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
133
|
+
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
}
|
|
@@ -153,7 +154,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
153
154
|
pos: uPos,
|
|
154
155
|
line,
|
|
155
156
|
col,
|
|
156
|
-
isTypeOnly: !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
157
|
+
isTypeOnly: isDts || !!(modifiers & IMPORT_FLAGS.TYPE_ONLY),
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
}
|
|
@@ -53,7 +53,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
53
53
|
const isWorkspace = chief.workspacesByPkgName.has(packageName);
|
|
54
54
|
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
55
55
|
if (inputWorkspace) {
|
|
56
|
-
const isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName, isConfig(input));
|
|
56
|
+
const isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName, isConfig(input), input.isTypeOnly);
|
|
57
57
|
if (externalRefs && !isWorkspace) {
|
|
58
58
|
addExternalRef(externalRefs, containingFilePath, { specifier: packageName, identifier: undefined });
|
|
59
59
|
}
|
|
@@ -107,6 +107,7 @@ export const createOptions = async (options) => {
|
|
|
107
107
|
isCache: args.cache ?? false,
|
|
108
108
|
isDebug,
|
|
109
109
|
isDisableConfigHints: args['no-config-hints'] || isProduction || Boolean(workspace),
|
|
110
|
+
isDisableTagHints: Boolean(args['no-config-hints']),
|
|
110
111
|
isFix: args.fix ?? options.isFix ?? isFixFiles ?? fixTypes.length > 0,
|
|
111
112
|
isFixCatalog: fixTypes.length === 0 || fixTypes.includes('catalog'),
|
|
112
113
|
isFixDependencies: fixTypes.length === 0 || fixTypes.includes('dependencies'),
|
package/dist/util/input.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface Input {
|
|
|
6
6
|
specifier: string;
|
|
7
7
|
production?: boolean;
|
|
8
8
|
optional?: boolean;
|
|
9
|
+
isTypeOnly?: boolean;
|
|
9
10
|
dir?: string;
|
|
10
11
|
containingFilePath?: string;
|
|
11
12
|
allowIncludeExports?: boolean;
|
|
@@ -27,6 +28,7 @@ interface IgnoreInput extends Input {
|
|
|
27
28
|
}
|
|
28
29
|
type Options = {
|
|
29
30
|
optional?: boolean;
|
|
31
|
+
isTypeOnly?: boolean;
|
|
30
32
|
dir?: string;
|
|
31
33
|
containingFilePath?: string;
|
|
32
34
|
allowIncludeExports?: boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { CompilerOptions } from '../types/project.ts';
|
|
2
|
-
|
|
2
|
+
interface TSConfigInfo {
|
|
3
3
|
isFile: boolean;
|
|
4
4
|
compilerOptions: CompilerOptions;
|
|
5
5
|
fileNames: string[];
|
|
6
|
-
|
|
6
|
+
include: string[] | undefined;
|
|
7
|
+
exclude: string[] | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare const loadTSConfig: (tsConfigFilePath: string) => Promise<TSConfigInfo>;
|
|
10
|
+
export {};
|
|
@@ -73,42 +73,39 @@ const fillFromReferences = (target, references, dir, visited) => {
|
|
|
73
73
|
fillFromReferences(target, refConfig.references, refDir, visited);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
+
const EMPTY = {
|
|
77
|
+
compilerOptions: {},
|
|
78
|
+
fileNames: [],
|
|
79
|
+
include: undefined,
|
|
80
|
+
exclude: undefined,
|
|
81
|
+
};
|
|
76
82
|
export const loadTSConfig = async (tsConfigFilePath) => {
|
|
77
|
-
if (isFile(tsConfigFilePath))
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if ((!compilerOptions.outDir || !compilerOptions.rootDir) && config.references?.length) {
|
|
93
|
-
fillFromReferences(compilerOptions, config.references, dir, new Set([tsConfigFilePath]));
|
|
94
|
-
}
|
|
95
|
-
const include = resolvePatterns(config.include, dir, true);
|
|
96
|
-
const exclude = resolvePatterns(config.exclude, dir, true);
|
|
97
|
-
const files = resolvePatterns(config.files, dir);
|
|
98
|
-
const fileNames = expandFileNames(dir, compilerOptions, include, exclude, files);
|
|
99
|
-
return { isFile: true, compilerOptions, fileNames };
|
|
83
|
+
if (!isFile(tsConfigFilePath))
|
|
84
|
+
return { isFile: false, ...EMPTY };
|
|
85
|
+
try {
|
|
86
|
+
const config = parseTsconfig(tsConfigFilePath);
|
|
87
|
+
const dir = dirname(tsConfigFilePath);
|
|
88
|
+
const compilerOptions = (config.compilerOptions ?? {});
|
|
89
|
+
if (compilerOptions.outDir)
|
|
90
|
+
compilerOptions.outDir = toAbsolute(compilerOptions.outDir, dir).replace(/\/+$/, '');
|
|
91
|
+
if (compilerOptions.rootDir)
|
|
92
|
+
compilerOptions.rootDir = toAbsolute(compilerOptions.rootDir, dir).replace(/\/+$/, '');
|
|
93
|
+
if (compilerOptions.paths) {
|
|
94
|
+
compilerOptions.pathsBasePath ??= dir;
|
|
95
|
+
}
|
|
96
|
+
if (compilerOptions.rootDirs) {
|
|
97
|
+
compilerOptions.rootDirs = compilerOptions.rootDirs.map((d) => (isAbsolute(d) ? d : join(dir, d)));
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
isFile: true,
|
|
104
|
-
compilerOptions: {},
|
|
105
|
-
fileNames: [],
|
|
106
|
-
};
|
|
99
|
+
if ((!compilerOptions.outDir || !compilerOptions.rootDir) && config.references?.length) {
|
|
100
|
+
fillFromReferences(compilerOptions, config.references, dir, new Set([tsConfigFilePath]));
|
|
107
101
|
}
|
|
102
|
+
const include = resolvePatterns(config.include, dir, true);
|
|
103
|
+
const exclude = resolvePatterns(config.exclude, dir, true);
|
|
104
|
+
const files = resolvePatterns(config.files, dir);
|
|
105
|
+
const fileNames = expandFileNames(dir, compilerOptions, include, exclude, files);
|
|
106
|
+
return { isFile: true, compilerOptions, fileNames, include, exclude };
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return { isFile: true, ...EMPTY };
|
|
108
110
|
}
|
|
109
|
-
return {
|
|
110
|
-
isFile: false,
|
|
111
|
-
compilerOptions: {},
|
|
112
|
-
fileNames: [],
|
|
113
|
-
};
|
|
114
111
|
};
|
package/dist/util/tag.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Tags } from '../types/options.ts';
|
|
2
2
|
export declare const splitTags: (rawTags: string[]) => Tags;
|
|
3
3
|
export declare const shouldIgnore: (jsDocTags: Set<string>, tags: Tags) => boolean;
|
|
4
|
+
export declare const isAlwaysIgnored: (jsDocTags: Set<string>) => boolean;
|
|
4
5
|
export declare const getShouldIgnoreHandler: (isProduction: boolean) => (jsDocTags: Set<string>) => boolean;
|
|
5
6
|
export declare const getShouldIgnoreTagHandler: (tags: Tags) => (jsDocTags: Set<string>) => boolean;
|
package/dist/util/tag.js
CHANGED
|
@@ -17,8 +17,6 @@ export const shouldIgnore = (jsDocTags, tags) => {
|
|
|
17
17
|
return true;
|
|
18
18
|
return false;
|
|
19
19
|
};
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
jsDocTags.has(ALIAS_TAG) ||
|
|
23
|
-
(isProduction && jsDocTags.has(INTERNAL_TAG));
|
|
20
|
+
export const isAlwaysIgnored = (jsDocTags) => jsDocTags.has(PUBLIC_TAG) || jsDocTags.has(BETA_TAG) || jsDocTags.has(ALIAS_TAG);
|
|
21
|
+
export const getShouldIgnoreHandler = (isProduction) => (jsDocTags) => isAlwaysIgnored(jsDocTags) || (isProduction && jsDocTags.has(INTERNAL_TAG));
|
|
24
22
|
export const getShouldIgnoreTagHandler = (tags) => (jsDocTags) => shouldIgnore(jsDocTags, tags);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.11.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.11.0';
|