knip 0.7.3 → 0.8.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 +6 -1
- package/dist/cli.js +3 -1
- package/dist/help.js +1 -0
- package/dist/index.js +65 -50
- package/dist/runner.js +25 -20
- package/dist/types.d.ts +2 -0
- package/dist/util/config.js +2 -0
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/fs.js +6 -4
- package/dist/util/project.d.ts +1 -4
- package/dist/util/project.js +2 -6
- package/license +12 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -209,6 +209,11 @@ Using the `--dev` flag will now switch to the non-production analysis.
|
|
|
209
209
|
|
|
210
210
|
Depending on the complexity of the project, be aware that it might require some fine-tuning on your end.
|
|
211
211
|
|
|
212
|
+
## Zero-config
|
|
213
|
+
|
|
214
|
+
Knip can work without any configuration. Then an existing `tsconfig.json` file is required. Since `entryFiles` and
|
|
215
|
+
`projectFiles` are now the same, Knip is unable to report unused files.
|
|
216
|
+
|
|
212
217
|
## More configuration examples
|
|
213
218
|
|
|
214
219
|
### Monorepos
|
|
@@ -434,7 +439,7 @@ for the job. I'm motivated to make knip perfectly suited for the job of cutting
|
|
|
434
439
|
|
|
435
440
|
[1]: #reporters
|
|
436
441
|
[2]: #custom-reporters
|
|
437
|
-
[3]: #
|
|
442
|
+
[3]: #really-another-unused-filedependencyexport-finder
|
|
438
443
|
[4]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
|
|
439
444
|
[5]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
|
|
440
445
|
[6]: ./assets/how-it-works.drawio.svg
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ const _1 = require(".");
|
|
|
10
10
|
const help_1 = require("./help");
|
|
11
11
|
const reporters_1 = __importDefault(require("./reporters"));
|
|
12
12
|
const errors_1 = require("./util/errors");
|
|
13
|
-
const { values: { help, dir, config: configFilePath
|
|
13
|
+
const { values: { help, dir, config: configFilePath, tsConfig: tsConfigFilePath, include = [], exclude = [], ignore = [], 'no-gitignore': isNoGitIgnore = false, dev: isDev = false, 'include-entry-files': isIncludeEntryFiles = false, 'no-progress': noProgress = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', 'max-issues': maxIssues = '0', jsdoc: jsDoc = [], debug: isDebug = false, 'debug-level': debugLevel = '1', }, } = (0, node_util_1.parseArgs)({
|
|
14
14
|
options: {
|
|
15
15
|
help: { type: 'boolean' },
|
|
16
16
|
config: { type: 'string', short: 'c' },
|
|
@@ -21,6 +21,7 @@ const { values: { help, dir, config: configFilePath = 'knip.json', tsConfig: tsC
|
|
|
21
21
|
ignore: { type: 'string', multiple: true },
|
|
22
22
|
'no-gitignore': { type: 'boolean' },
|
|
23
23
|
dev: { type: 'boolean' },
|
|
24
|
+
'include-entry-files': { type: 'boolean' },
|
|
24
25
|
'no-progress': { type: 'boolean' },
|
|
25
26
|
'max-issues': { type: 'string' },
|
|
26
27
|
reporter: { type: 'string' },
|
|
@@ -49,6 +50,7 @@ const run = async () => {
|
|
|
49
50
|
exclude,
|
|
50
51
|
ignore,
|
|
51
52
|
gitignore: !isNoGitIgnore,
|
|
53
|
+
isIncludeEntryFiles,
|
|
52
54
|
isDev,
|
|
53
55
|
isShowProgress,
|
|
54
56
|
jsDoc,
|
package/dist/help.js
CHANGED
|
@@ -13,6 +13,7 @@ Options:
|
|
|
13
13
|
--ignore Ignore files matching this glob pattern (can be set multiple times)
|
|
14
14
|
--no-gitignore Don't use .gitignore
|
|
15
15
|
--dev Include \`devDependencies\` in report(s)
|
|
16
|
+
--include-entry-files Report unused exports and types for entry files
|
|
16
17
|
--no-progress Don't show dynamic progress updates
|
|
17
18
|
--max-issues Maximum number of issues before non-zero exit code (default: 0)
|
|
18
19
|
--reporter Select reporter: symbols, compact, codeowners (default: symbols)
|
package/dist/index.js
CHANGED
|
@@ -14,74 +14,89 @@ const runner_1 = require("./runner");
|
|
|
14
14
|
const errors_1 = require("./util/errors");
|
|
15
15
|
const debug_1 = require("./util/debug");
|
|
16
16
|
const main = async (options) => {
|
|
17
|
-
const { cwd, workingDir, configFilePath
|
|
17
|
+
const { cwd, workingDir, configFilePath: configFilePathArg, tsConfigFilePath: tsConfigFilePathArg, include, exclude, ignore, gitignore, isIncludeEntryFiles, isDev, isShowProgress, jsDoc, debug, } = options;
|
|
18
18
|
(0, debug_1.debugLogObject)(options, 1, 'Unresolved onfiguration', options);
|
|
19
|
-
const
|
|
20
|
-
const manifestPath = await (0, fs_1.findFile)(workingDir, 'package.json');
|
|
21
|
-
const localConfiguration = localConfigurationPath && require(localConfigurationPath);
|
|
19
|
+
const manifestPath = await (0, fs_1.findFile)(cwd, workingDir, 'package.json');
|
|
22
20
|
const manifest = manifestPath && require(manifestPath);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const configFilePath = configFilePathArg ?? 'knip.json';
|
|
22
|
+
const resolvedConfigFilePath = await (0, fs_1.findFile)(cwd, workingDir, configFilePath);
|
|
23
|
+
const localConfig = resolvedConfigFilePath && require(resolvedConfigFilePath);
|
|
24
|
+
if (configFilePathArg && !resolvedConfigFilePath) {
|
|
25
|
+
throw new errors_1.ConfigurationError(`Unable to find ${configFilePathArg}`);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new errors_1.ConfigurationError('Unable to find `entryFiles` and/or `projectFiles` in configuration.');
|
|
27
|
+
const tsConfigFilePath = tsConfigFilePathArg ?? 'tsconfig.json';
|
|
28
|
+
const resolvedTsConfigFilePath = await (0, fs_1.findFile)(cwd, workingDir, tsConfigFilePath);
|
|
29
|
+
if (tsConfigFilePathArg && !resolvedTsConfigFilePath) {
|
|
30
|
+
throw new errors_1.ConfigurationError(`Unable to find ${tsConfigFilePathArg}`);
|
|
32
31
|
}
|
|
33
|
-
const report = (0, config_1.resolveIncludedIssueGroups)(include, exclude, resolvedConfig);
|
|
34
32
|
let tsConfigPaths = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (tsConfigPath) {
|
|
40
|
-
const tsConfig = typescript_1.default.readConfigFile(tsConfigPath, typescript_1.default.sys.readFile);
|
|
41
|
-
tsConfigPaths = tsConfig.config.compilerOptions?.paths
|
|
42
|
-
? Object.keys(tsConfig.config.compilerOptions.paths).map(p => p.replace(/\*/g, '**'))
|
|
33
|
+
if (resolvedTsConfigFilePath) {
|
|
34
|
+
const config = typescript_1.default.readConfigFile(resolvedTsConfigFilePath, typescript_1.default.sys.readFile);
|
|
35
|
+
tsConfigPaths = config.config.compilerOptions?.paths
|
|
36
|
+
? Object.keys(config.config.compilerOptions.paths).map(p => p.replace(/\*/g, '**'))
|
|
43
37
|
: [];
|
|
44
|
-
if (
|
|
45
|
-
throw new errors_1.ConfigurationError(`
|
|
38
|
+
if (config.error) {
|
|
39
|
+
throw new errors_1.ConfigurationError(`Unable to read ${node_path_1.default.relative(cwd, resolvedTsConfigFilePath)}`);
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
42
|
+
const dir = node_path_1.default.relative(cwd, workingDir);
|
|
43
|
+
const resolvedConfig = (0, config_1.resolveConfig)(manifest.knip ?? localConfig, { workingDir: dir, isDev });
|
|
44
|
+
(0, debug_1.debugLogObject)(options, 1, 'Resolved onfiguration', resolvedConfig);
|
|
45
|
+
if (!resolvedConfigFilePath && !manifest.knip && !resolvedTsConfigFilePath) {
|
|
46
|
+
throw new errors_1.ConfigurationError(`Unable to find ${configFilePath} or package.json#knip or ${tsConfigFilePath}`);
|
|
47
|
+
}
|
|
48
|
+
const { entryFiles, productionFiles, projectFiles } = await (async () => {
|
|
49
|
+
if (resolvedConfig) {
|
|
50
|
+
const skipAddFiles = { skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: true };
|
|
51
|
+
const projectOptions = resolvedTsConfigFilePath
|
|
52
|
+
? { tsConfigFilePath: resolvedTsConfigFilePath }
|
|
53
|
+
: { compilerOptions: { allowJs: true } };
|
|
54
|
+
const entryPaths = await (0, path_1.resolvePaths)({
|
|
55
|
+
cwd,
|
|
56
|
+
workingDir,
|
|
57
|
+
patterns: resolvedConfig.entryFiles,
|
|
58
|
+
ignore,
|
|
59
|
+
gitignore,
|
|
60
|
+
});
|
|
61
|
+
(0, debug_1.debugLogFiles)(options, 1, 'Globbed entry paths', entryPaths);
|
|
62
|
+
const production = (0, project_1.createProject)({ ...projectOptions, ...skipAddFiles }, entryPaths);
|
|
63
|
+
const entryFiles = production.getSourceFiles();
|
|
64
|
+
(0, debug_1.debugLogSourceFiles)(options, 1, 'Included entry source files', entryFiles);
|
|
65
|
+
production.resolveSourceFileDependencies();
|
|
66
|
+
const productionFiles = production.getSourceFiles();
|
|
67
|
+
(0, debug_1.debugLogSourceFiles)(options, 1, 'Included production source files', productionFiles);
|
|
68
|
+
const projectPaths = await (0, path_1.resolvePaths)({
|
|
69
|
+
cwd,
|
|
70
|
+
workingDir,
|
|
71
|
+
patterns: resolvedConfig.projectFiles,
|
|
72
|
+
ignore,
|
|
73
|
+
gitignore,
|
|
74
|
+
});
|
|
75
|
+
(0, debug_1.debugLogFiles)(options, 1, 'Globbed project paths', projectPaths);
|
|
76
|
+
const project = (0, project_1.createProject)({ ...projectOptions, ...skipAddFiles }, projectPaths);
|
|
77
|
+
const projectFiles = project.getSourceFiles();
|
|
78
|
+
(0, debug_1.debugLogSourceFiles)(options, 1, 'Included project source files', projectFiles);
|
|
79
|
+
return { entryFiles, productionFiles, projectFiles };
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const project = (0, project_1.createProject)({ tsConfigFilePath: resolvedTsConfigFilePath });
|
|
83
|
+
const files = project.getSourceFiles();
|
|
84
|
+
return { entryFiles: files, productionFiles: files, projectFiles: files };
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
const report = (0, config_1.resolveIncludedIssueGroups)(include, resolvedConfig ? exclude : ['files'], resolvedConfig);
|
|
74
88
|
const config = {
|
|
75
89
|
workingDir,
|
|
76
90
|
report,
|
|
77
91
|
entryFiles,
|
|
78
92
|
productionFiles,
|
|
79
93
|
projectFiles,
|
|
94
|
+
isIncludeEntryFiles: !resolvedConfig || isIncludeEntryFiles,
|
|
80
95
|
dependencies: Object.keys(manifest.dependencies ?? {}),
|
|
81
96
|
peerDependencies: Object.keys(manifest.peerDependencies ?? {}),
|
|
82
97
|
optionalDependencies: Object.keys(manifest.optionalDependencies ?? {}),
|
|
83
98
|
devDependencies: Object.keys(manifest.devDependencies ?? {}),
|
|
84
|
-
isDev: typeof resolvedConfig
|
|
99
|
+
isDev: typeof resolvedConfig?.dev === 'boolean' ? resolvedConfig.dev : isDev,
|
|
85
100
|
tsConfigPaths,
|
|
86
101
|
isShowProgress,
|
|
87
102
|
jsDocOptions: {
|
package/dist/runner.js
CHANGED
|
@@ -15,14 +15,14 @@ const debug_1 = require("./util/debug");
|
|
|
15
15
|
const lineRewriter = new log_1.LineRewriter();
|
|
16
16
|
async function findIssues(configuration) {
|
|
17
17
|
const { workingDir, isShowProgress, report, isDev, jsDocOptions } = configuration;
|
|
18
|
-
const { entryFiles, productionFiles, projectFiles } = configuration;
|
|
18
|
+
const { entryFiles, productionFiles, projectFiles, isIncludeEntryFiles } = configuration;
|
|
19
19
|
const { getUnresolvedDependencies, getUnusedDependencies, getUnusedDevDependencies } = (0, dependencies_1.getDependencyAnalyzer)(configuration);
|
|
20
20
|
const [usedProductionFiles, unreferencedProductionFiles] = (0, project_1.partitionSourceFiles)(projectFiles, productionFiles);
|
|
21
21
|
const [usedEntryFiles, usedNonEntryFiles] = (0, project_1.partitionSourceFiles)(usedProductionFiles, entryFiles);
|
|
22
|
-
(0, debug_1.debugLogSourceFiles)(configuration, 1, '
|
|
23
|
-
(0, debug_1.debugLogSourceFiles)(configuration, 1, '
|
|
24
|
-
(0, debug_1.debugLogSourceFiles)(configuration, 1, '
|
|
25
|
-
(0, debug_1.debugLogSourceFiles)(configuration, 1, '
|
|
22
|
+
(0, debug_1.debugLogSourceFiles)(configuration, 1, 'Used production files', usedProductionFiles);
|
|
23
|
+
(0, debug_1.debugLogSourceFiles)(configuration, 1, 'Unreferenced production files', unreferencedProductionFiles);
|
|
24
|
+
(0, debug_1.debugLogSourceFiles)(configuration, 1, 'Used entry files', usedEntryFiles);
|
|
25
|
+
(0, debug_1.debugLogSourceFiles)(configuration, 1, 'Used non-entry files', usedNonEntryFiles);
|
|
26
26
|
const issues = {
|
|
27
27
|
files: new Set(unreferencedProductionFiles.map(file => file.getFilePath())),
|
|
28
28
|
dependencies: new Set(),
|
|
@@ -81,13 +81,6 @@ async function findIssues(configuration) {
|
|
|
81
81
|
}
|
|
82
82
|
updateProcessingOutput(issue);
|
|
83
83
|
};
|
|
84
|
-
if (report.dependencies || report.unlisted) {
|
|
85
|
-
usedEntryFiles.forEach(sourceFile => {
|
|
86
|
-
counters.processed++;
|
|
87
|
-
const unresolvedDependencies = getUnresolvedDependencies(sourceFile);
|
|
88
|
-
unresolvedDependencies.forEach(issue => addSymbolIssue('unresolved', issue));
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
84
|
if (report.dependencies ||
|
|
92
85
|
report.unlisted ||
|
|
93
86
|
report.exports ||
|
|
@@ -95,7 +88,7 @@ async function findIssues(configuration) {
|
|
|
95
88
|
report.nsExports ||
|
|
96
89
|
report.nsTypes ||
|
|
97
90
|
report.duplicates) {
|
|
98
|
-
|
|
91
|
+
usedProductionFiles.forEach(sourceFile => {
|
|
99
92
|
counters.processed++;
|
|
100
93
|
const filePath = sourceFile.getFilePath();
|
|
101
94
|
if (report.dependencies || report.unlisted) {
|
|
@@ -110,10 +103,14 @@ async function findIssues(configuration) {
|
|
|
110
103
|
addSymbolIssue('duplicates', { filePath, symbol, symbols });
|
|
111
104
|
});
|
|
112
105
|
}
|
|
106
|
+
if (!isIncludeEntryFiles && usedEntryFiles.includes(sourceFile))
|
|
107
|
+
return;
|
|
113
108
|
if (report.exports || report.types || report.nsExports || report.nsTypes) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
if (!isIncludeEntryFiles) {
|
|
110
|
+
const uniqueExportedSymbols = new Set([...exportDeclarations.values()].flat());
|
|
111
|
+
if (uniqueExportedSymbols.size === 1)
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
117
114
|
exportDeclarations.forEach(declarations => {
|
|
118
115
|
declarations.forEach(declaration => {
|
|
119
116
|
const type = (0, type_1.getType)(declaration);
|
|
@@ -126,10 +123,18 @@ async function findIssues(configuration) {
|
|
|
126
123
|
if (jsDocOptions.isReadPublicTag && ts_morph_1.ts.getJSDocPublicTag(declaration.compilerNode))
|
|
127
124
|
return;
|
|
128
125
|
let identifier;
|
|
126
|
+
let fakeIdentifier;
|
|
129
127
|
if (declaration.isKind(ts_morph_1.ts.SyntaxKind.Identifier)) {
|
|
130
128
|
identifier = declaration;
|
|
131
129
|
}
|
|
132
|
-
else if (declaration.isKind(ts_morph_1.ts.SyntaxKind.ArrowFunction)
|
|
130
|
+
else if (declaration.isKind(ts_morph_1.ts.SyntaxKind.ArrowFunction) ||
|
|
131
|
+
declaration.isKind(ts_morph_1.ts.SyntaxKind.ObjectLiteralExpression) ||
|
|
132
|
+
declaration.isKind(ts_morph_1.ts.SyntaxKind.ArrayLiteralExpression) ||
|
|
133
|
+
declaration.isKind(ts_morph_1.ts.SyntaxKind.StringLiteral) ||
|
|
134
|
+
declaration.isKind(ts_morph_1.ts.SyntaxKind.NumericLiteral)) {
|
|
135
|
+
if (!(0, ts_morph_helpers_1.hasReferencingDefaultImport)(sourceFile)) {
|
|
136
|
+
fakeIdentifier = 'default';
|
|
137
|
+
}
|
|
133
138
|
}
|
|
134
139
|
else if (declaration.isKind(ts_morph_1.ts.SyntaxKind.FunctionDeclaration) ||
|
|
135
140
|
declaration.isKind(ts_morph_1.ts.SyntaxKind.ClassDeclaration) ||
|
|
@@ -144,8 +149,8 @@ async function findIssues(configuration) {
|
|
|
144
149
|
else {
|
|
145
150
|
identifier = declaration.getFirstDescendantByKind(ts_morph_1.ts.SyntaxKind.Identifier);
|
|
146
151
|
}
|
|
147
|
-
if (identifier) {
|
|
148
|
-
const identifierText = identifier
|
|
152
|
+
if (identifier || fakeIdentifier) {
|
|
153
|
+
const identifierText = fakeIdentifier ?? identifier?.getText() ?? '*';
|
|
149
154
|
if (report.exports && issues.exports[filePath]?.[identifierText])
|
|
150
155
|
return;
|
|
151
156
|
if (report.types && issues.types[filePath]?.[identifierText])
|
|
@@ -154,7 +159,7 @@ async function findIssues(configuration) {
|
|
|
154
159
|
return;
|
|
155
160
|
if (report.nsTypes && issues.nsTypes[filePath]?.[identifierText])
|
|
156
161
|
return;
|
|
157
|
-
const refs = identifier
|
|
162
|
+
const refs = identifier?.findReferences() ?? [];
|
|
158
163
|
if (refs.length === 0) {
|
|
159
164
|
addSymbolIssue('exports', { filePath, symbol: identifierText });
|
|
160
165
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare type UnresolvedConfiguration = {
|
|
|
44
44
|
exclude: string[];
|
|
45
45
|
ignore: string[];
|
|
46
46
|
gitignore: boolean;
|
|
47
|
+
isIncludeEntryFiles: boolean;
|
|
47
48
|
isDev: boolean;
|
|
48
49
|
isShowProgress: boolean;
|
|
49
50
|
jsDoc: string[];
|
|
@@ -61,6 +62,7 @@ export declare type Configuration = {
|
|
|
61
62
|
projectFiles: SourceFile[];
|
|
62
63
|
productionFiles: SourceFile[];
|
|
63
64
|
entryFiles: SourceFile[];
|
|
65
|
+
isIncludeEntryFiles: boolean;
|
|
64
66
|
dependencies: string[];
|
|
65
67
|
peerDependencies: string[];
|
|
66
68
|
optionalDependencies: string[];
|
package/dist/util/config.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveIncludedIssueGroups = exports.resolveConfig = void 0;
|
|
7
7
|
const micromatch_1 = __importDefault(require("micromatch"));
|
|
8
8
|
const resolveConfig = (importedConfiguration, options) => {
|
|
9
|
+
if (!importedConfiguration)
|
|
10
|
+
return;
|
|
9
11
|
let resolvedConfig = importedConfiguration;
|
|
10
12
|
const { workingDir, isDev } = options ?? {};
|
|
11
13
|
const configKeys = Object.keys(importedConfiguration);
|
package/dist/util/fs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const findFile: (cwd: string, fileName: string) => Promise<string | undefined>;
|
|
1
|
+
export declare const findFile: (cwd: string, workingDir: string, fileName: string) => Promise<string | undefined>;
|
package/dist/util/fs.js
CHANGED
|
@@ -15,14 +15,16 @@ const isFile = async (filePath) => {
|
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
const findFile = async (cwd, fileName) => {
|
|
19
|
-
const filePath = node_path_1.default.join(
|
|
18
|
+
const findFile = async (cwd, workingDir, fileName) => {
|
|
19
|
+
const filePath = node_path_1.default.join(workingDir, fileName);
|
|
20
20
|
if (await isFile(filePath)) {
|
|
21
21
|
return filePath;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (cwd === workingDir)
|
|
25
|
+
return;
|
|
26
|
+
const parentDir = node_path_1.default.resolve(workingDir, '..');
|
|
27
|
+
return (0, exports.findFile)(cwd, parentDir, fileName);
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
30
|
exports.findFile = findFile;
|
package/dist/util/project.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { Project } from 'ts-morph';
|
|
2
2
|
import type { ProjectOptions, SourceFile } from 'ts-morph';
|
|
3
|
-
export declare const createProject: (
|
|
4
|
-
projectOptions: ProjectOptions;
|
|
5
|
-
paths?: string[] | undefined;
|
|
6
|
-
}) => Project;
|
|
3
|
+
export declare const createProject: (projectOptions: ProjectOptions, paths?: string[]) => Project;
|
|
7
4
|
export declare const partitionSourceFiles: (projectFiles: SourceFile[], productionFiles: SourceFile[]) => SourceFile[][];
|
package/dist/util/project.js
CHANGED
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.partitionSourceFiles = exports.createProject = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
|
-
const createProject = (
|
|
6
|
-
const workspace = new ts_morph_1.Project(
|
|
7
|
-
...projectOptions,
|
|
8
|
-
skipAddingFilesFromTsConfig: true,
|
|
9
|
-
skipFileDependencyResolution: true,
|
|
10
|
-
});
|
|
5
|
+
const createProject = (projectOptions, paths) => {
|
|
6
|
+
const workspace = new ts_morph_1.Project(projectOptions);
|
|
11
7
|
if (paths)
|
|
12
8
|
workspace.addSourceFilesAtPaths(paths);
|
|
13
9
|
return workspace;
|
package/license
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
ISC License (ISC)
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Lars Kappert
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
|
|
6
|
+
provided that the above copyright notice and this permission notice appear in all copies.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
9
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
11
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
12
|
+
THIS SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"find",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"is-builtin-module": "3.2.0",
|
|
46
46
|
"micromatch": "4.0.5",
|
|
47
47
|
"ts-morph": "16.0.0",
|
|
48
|
-
"ts-morph-helpers": "0.
|
|
48
|
+
"ts-morph-helpers": "0.6.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/micromatch": "4.0.2",
|