rev-dep 1.2.0 → 1.4.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/README.md +24 -2
- package/dist/cli/createCommands.js +2 -0
- package/dist/cli/files/index.js +7 -5
- package/dist/cli/nodeModules/index.d.ts +2 -0
- package/dist/cli/nodeModules/index.js +36 -0
- package/dist/cli/nodeModules/types.d.ts +3 -0
- package/dist/cli/nodeModules/types.js +2 -0
- package/dist/cli/resolve/formatResults.d.ts +2 -2
- package/dist/cli/resolve/formatResults.js +2 -2
- package/dist/cli/resolve/index.js +8 -6
- package/dist/cli/resolve/types.d.ts +1 -0
- package/dist/lib/buildDepsGraph.d.ts +1 -1
- package/dist/lib/buildDepsGraph.js +5 -5
- package/dist/lib/cleanupDpdmDeps.d.ts +1 -1
- package/dist/lib/cleanupDpdmDeps.js +21 -6
- package/dist/lib/getDepsTree.d.ts +1 -1
- package/dist/lib/getDepsTree.js +2 -2
- package/dist/lib/getEntryPoints.d.ts +9 -1
- package/dist/lib/getEntryPoints.js +21 -10
- package/dist/lib/getFilesForEntryPoint.d.ts +8 -0
- package/dist/lib/getFilesForEntryPoint.js +12 -0
- package/dist/lib/getNodeModulesForEntryPoint.d.ts +8 -0
- package/dist/lib/getNodeModulesForEntryPoint.js +18 -0
- package/dist/lib/resolve.d.ts +4 -2
- package/dist/lib/resolve.js +7 -6
- package/dist/lib/types.d.ts +4 -2
- package/dist/module.d.ts +4 -1
- package/dist/module.js +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -378,12 +378,12 @@ Checks if a filePath is required from entryPoint(s) and prints the resolution pa
|
|
|
378
378
|
#### Usage
|
|
379
379
|
|
|
380
380
|
```sh
|
|
381
|
-
rev-dep resolve <
|
|
381
|
+
rev-dep resolve <filePathOrNodeModuleName> [entryPoints...] [options]
|
|
382
382
|
```
|
|
383
383
|
|
|
384
384
|
#### Arguments
|
|
385
385
|
|
|
386
|
-
- `
|
|
386
|
+
- `filePathOrNodeModuleName` - undefined (**required**)
|
|
387
387
|
- `entryPoints...` - List of entry points to look for file (_optional_)
|
|
388
388
|
|
|
389
389
|
#### Options
|
|
@@ -395,6 +395,7 @@ rev-dep resolve <filePath> [entryPoints...] [options]
|
|
|
395
395
|
- `-cs, --compactSummary` - print a compact summary of reverse resolution with a count of found paths (_optional_)
|
|
396
396
|
- `-a, --all` - finds all paths combination of a given dependency. Might work very slow or crash for some projects due to heavy usage of RAM (_optional_)
|
|
397
397
|
- `-ntp --notTraversePaths <paths...>` - Specify file paths relative to resolution root, that should not be traversed when finding dependency path (_optional_)
|
|
398
|
+
- `-inm --includeNodeModules` - Whether to include node modules in dependency graph. Has to be provided to resolve node module. (_optional_)
|
|
398
399
|
- `-iti --ignoreTypesImports` - Use this flag to not follow type imports when resolving modules (_optional_)
|
|
399
400
|
|
|
400
401
|
### Command `entry-points`
|
|
@@ -438,6 +439,27 @@ rev-dep files <entryPoint> [options]
|
|
|
438
439
|
- `-c, --count` - print only count of entry point dependencies (_optional_)
|
|
439
440
|
- `-iti --ignoreTypesImports` - Use this flag to not follow type imports when resolving modules (_optional_)
|
|
440
441
|
|
|
442
|
+
### Command `node-modules`
|
|
443
|
+
|
|
444
|
+
Get list of node modules required by entry point
|
|
445
|
+
|
|
446
|
+
#### Usage
|
|
447
|
+
|
|
448
|
+
```sh
|
|
449
|
+
rev-dep node-modules <entryPoint> [options]
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### Arguments
|
|
453
|
+
|
|
454
|
+
- `entryPoint` - Path to entry point (**required**)
|
|
455
|
+
|
|
456
|
+
#### Options
|
|
457
|
+
|
|
458
|
+
- `-wc, --webpackConfig <path>` - path to webpack config to enable webpack aliases support (_optional_)
|
|
459
|
+
- `--cwd <path>` - path to a directory that should be used as a resolution root (_optional_)
|
|
460
|
+
- `-c, --count` - print only count of entry point dependencies (_optional_)
|
|
461
|
+
- `-iti --ignoreTypesImports` - Use this flag to not follow type imports when resolving modules (_optional_)
|
|
462
|
+
|
|
441
463
|
### Command `docs`
|
|
442
464
|
|
|
443
465
|
Generate documentation of available commands into md file.
|
|
@@ -8,10 +8,12 @@ const resolve_1 = __importDefault(require("./resolve"));
|
|
|
8
8
|
const docs_1 = __importDefault(require("./docs"));
|
|
9
9
|
const entryPoints_1 = __importDefault(require("./entryPoints"));
|
|
10
10
|
const files_1 = __importDefault(require("./files"));
|
|
11
|
+
const nodeModules_1 = __importDefault(require("./nodeModules"));
|
|
11
12
|
function createCommands(program) {
|
|
12
13
|
(0, resolve_1.default)(program);
|
|
13
14
|
(0, entryPoints_1.default)(program);
|
|
14
15
|
(0, files_1.default)(program);
|
|
16
|
+
(0, nodeModules_1.default)(program);
|
|
15
17
|
(0, docs_1.default)(program);
|
|
16
18
|
}
|
|
17
19
|
exports.createCommands = createCommands;
|
package/dist/cli/files/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const commonOptions_1 = require("../commonOptions");
|
|
4
|
-
const
|
|
5
|
-
const getDepsTree_1 = require("../../lib/getDepsTree");
|
|
4
|
+
const getFilesForEntryPoint_1 = require("../../lib/getFilesForEntryPoint");
|
|
6
5
|
function createFiles(program) {
|
|
7
6
|
program
|
|
8
7
|
.command('files <entryPoint>')
|
|
@@ -16,9 +15,12 @@ function createFiles(program) {
|
|
|
16
15
|
.option(...commonOptions_1.ignoreTypesImports)
|
|
17
16
|
.action(async (entryPoint, data) => {
|
|
18
17
|
const { webpackConfig: webpackConfigPath, cwd, count, ignoreTypesImports } = data;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const filePaths = await (0, getFilesForEntryPoint_1.getFilesForEntryPoint)({
|
|
19
|
+
cwd,
|
|
20
|
+
entryPoint,
|
|
21
|
+
webpackConfigPath,
|
|
22
|
+
ignoreTypesImports
|
|
23
|
+
});
|
|
22
24
|
if (filePaths.length === 0) {
|
|
23
25
|
console.log('No results found');
|
|
24
26
|
return;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commonOptions_1 = require("../commonOptions");
|
|
4
|
+
const getNodeModulesForEntryPoint_1 = require("../../lib/getNodeModulesForEntryPoint");
|
|
5
|
+
function createNodeModules(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('node-modules <entryPoint>')
|
|
8
|
+
.description('Get list of node modules required by entry point', {
|
|
9
|
+
entryPoint: 'Path to entry point'
|
|
10
|
+
})
|
|
11
|
+
.option(...commonOptions_1.webpackConfigOption)
|
|
12
|
+
.option(...commonOptions_1.cwdOption)
|
|
13
|
+
// .option(...reexportRewireOption)
|
|
14
|
+
.option('-c, --count', 'print only count of entry point dependencies', false)
|
|
15
|
+
.option(...commonOptions_1.ignoreTypesImports)
|
|
16
|
+
.action(async (entryPoint, data) => {
|
|
17
|
+
const { webpackConfig: webpackConfigPath, cwd, count, ignoreTypesImports } = data;
|
|
18
|
+
const uniqueNodeModuleImports = await (0, getNodeModulesForEntryPoint_1.getNodeModulesForEntryPoint)({
|
|
19
|
+
cwd,
|
|
20
|
+
entryPoint,
|
|
21
|
+
webpackConfigPath,
|
|
22
|
+
ignoreTypesImports
|
|
23
|
+
});
|
|
24
|
+
if (uniqueNodeModuleImports.length === 0) {
|
|
25
|
+
console.log('No results found');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (count) {
|
|
29
|
+
console.log(uniqueNodeModuleImports.length);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
uniqueNodeModuleImports.forEach((nodeModuleName) => console.log(nodeModuleName));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.default = createNodeModules;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InputParams } from './types';
|
|
2
2
|
declare type Results = Array<Array<Array<string>>>;
|
|
3
|
-
export declare function formatResults({ results,
|
|
3
|
+
export declare function formatResults({ results, filePathOrNodeModuleName, entryPoints, compactSummary }: {
|
|
4
4
|
results: Results;
|
|
5
5
|
compactSummary: InputParams['compactSummary'];
|
|
6
6
|
entryPoints: string[];
|
|
7
|
-
|
|
7
|
+
filePathOrNodeModuleName: string;
|
|
8
8
|
}): string;
|
|
9
9
|
export {};
|
|
@@ -29,11 +29,11 @@ const pathToString = (str, filePath, indentation) => {
|
|
|
29
29
|
return `${str ? `${str}\n` : ''}${' '.repeat(indentation)} ➞ ${filePath}`;
|
|
30
30
|
};
|
|
31
31
|
const join = (...args) => args.join(' ') + '\n';
|
|
32
|
-
function formatResults({ results,
|
|
32
|
+
function formatResults({ results, filePathOrNodeModuleName, entryPoints, compactSummary }) {
|
|
33
33
|
let formatted = '';
|
|
34
34
|
const hasAnyResults = results.some((paths) => paths.length > 0);
|
|
35
35
|
if (!hasAnyResults) {
|
|
36
|
-
formatted = join('No results found for',
|
|
36
|
+
formatted = join('No results found for', filePathOrNodeModuleName, 'in the following entry points list:\n' + entryPoints.join('\n'));
|
|
37
37
|
return formatted;
|
|
38
38
|
}
|
|
39
39
|
if (compactSummary) {
|
|
@@ -6,7 +6,7 @@ const utils_1 = require("../../lib/utils");
|
|
|
6
6
|
const commonOptions_1 = require("../commonOptions");
|
|
7
7
|
function createResolve(program) {
|
|
8
8
|
program
|
|
9
|
-
.command('resolve <
|
|
9
|
+
.command('resolve <filePathOrNodeModuleName> [entryPoints...]')
|
|
10
10
|
.description('Checks if a filePath is required from entryPoint(s) and prints the resolution path', {
|
|
11
11
|
filePath: 'Path to a file that should be resolved in entry points',
|
|
12
12
|
'entryPoints...': 'List of entry points to look for file'
|
|
@@ -19,25 +19,27 @@ function createResolve(program) {
|
|
|
19
19
|
.option('-cs, --compactSummary', 'print a compact summary of reverse resolution with a count of found paths')
|
|
20
20
|
.option('-a, --all', 'finds all paths combination of a given dependency. Might work very slow or crash for some projects due to heavy usage of RAM', false)
|
|
21
21
|
.option('-ntp --notTraversePaths <paths...>', 'Specify file paths relative to resolution root, that should not be traversed when finding dependency path')
|
|
22
|
+
.option('-inm --includeNodeModules', 'Whether to include node modules in dependency graph. Has to be provided to resolve node module.', true)
|
|
22
23
|
.option(...commonOptions_1.ignoreTypesImports)
|
|
23
|
-
.action(async (
|
|
24
|
-
const { compactSummary, webpackConfig, all, cwd, exclude, include, notTraversePaths, ignoreTypesImports } = data;
|
|
24
|
+
.action(async (filePathOrNodeModuleName, entryPoints, data) => {
|
|
25
|
+
const { compactSummary, webpackConfig, all, cwd, exclude, include, notTraversePaths, ignoreTypesImports, includeNodeModules } = data;
|
|
25
26
|
const [results, resolveEntryPoints] = await (0, resolve_1.resolve)({
|
|
26
27
|
entryPoints,
|
|
27
|
-
|
|
28
|
+
filePathOrNodeModuleName,
|
|
28
29
|
webpackConfig,
|
|
29
30
|
all,
|
|
30
31
|
cwd: (0, utils_1.resolvePath)(cwd),
|
|
31
32
|
exclude,
|
|
32
33
|
include,
|
|
33
34
|
notTraversePaths,
|
|
34
|
-
ignoreTypesImports
|
|
35
|
+
ignoreTypesImports,
|
|
36
|
+
includeNodeModules
|
|
35
37
|
});
|
|
36
38
|
const formatted = (0, formatResults_1.formatResults)({
|
|
37
39
|
results,
|
|
38
40
|
entryPoints: resolveEntryPoints,
|
|
39
41
|
compactSummary,
|
|
40
|
-
|
|
42
|
+
filePathOrNodeModuleName
|
|
41
43
|
});
|
|
42
44
|
console.log(formatted);
|
|
43
45
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Node, MinimalDependencyTree } from './types';
|
|
2
|
-
export declare const buildDepsGraph: (deps: MinimalDependencyTree,
|
|
2
|
+
export declare const buildDepsGraph: (deps: MinimalDependencyTree, filePathOrNodeModuleName?: string | undefined, notTraversePath?: string[] | undefined) => (entryPoint: string) => [Node, Node | null, Map<string, Node>];
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildDepsGraph = void 0;
|
|
7
7
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
8
|
-
const buildDepsGraph = (deps,
|
|
8
|
+
const buildDepsGraph = (deps, filePathOrNodeModuleName, notTraversePath) => (entryPoint) => {
|
|
9
9
|
const vertices = new Map();
|
|
10
|
-
let
|
|
10
|
+
let fileOrNodeModuleNode = null;
|
|
11
11
|
const inner = (path, visited = new Set(), depth = 1, parent = null) => {
|
|
12
12
|
const vertex = vertices.get(path);
|
|
13
13
|
if (vertex) {
|
|
@@ -39,11 +39,11 @@ const buildDepsGraph = (deps, filePath, notTraversePath) => (entryPoint) => {
|
|
|
39
39
|
!(notTraversePath === null || notTraversePath === void 0 ? void 0 : notTraversePath.some((pathToNotTraverse) => (0, minimatch_1.default)(path, pathToNotTraverse))))
|
|
40
40
|
.map((path) => inner(path, localVisited, depth + 1, node));
|
|
41
41
|
vertices.set(path, node);
|
|
42
|
-
if (path ===
|
|
43
|
-
|
|
42
|
+
if (path === filePathOrNodeModuleName) {
|
|
43
|
+
fileOrNodeModuleNode = node;
|
|
44
44
|
}
|
|
45
45
|
return node;
|
|
46
46
|
};
|
|
47
|
-
return [inner(entryPoint),
|
|
47
|
+
return [inner(entryPoint), fileOrNodeModuleNode, vertices];
|
|
48
48
|
};
|
|
49
49
|
exports.buildDepsGraph = buildDepsGraph;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DependencyTree } from 'dpdm';
|
|
2
2
|
import { MinimalDependencyTree } from './types';
|
|
3
|
-
export declare const cleanupDpdmDeps: (deps: MinimalDependencyTree | DependencyTree) => MinimalDependencyTree;
|
|
3
|
+
export declare const cleanupDpdmDeps: (deps: MinimalDependencyTree | DependencyTree, includeNodeModules?: boolean) => MinimalDependencyTree;
|
|
@@ -5,18 +5,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.cleanupDpdmDeps = void 0;
|
|
7
7
|
const is_builtin_module_1 = __importDefault(require("is-builtin-module"));
|
|
8
|
-
const cleanupDpdmDeps = (deps) => {
|
|
8
|
+
const cleanupDpdmDeps = (deps, includeNodeModules = false) => {
|
|
9
9
|
const newDeps = {};
|
|
10
10
|
Object.entries(deps).forEach(([id, dependencies]) => {
|
|
11
|
+
const nodeModules = [];
|
|
11
12
|
if (!(0, is_builtin_module_1.default)(id) &&
|
|
12
13
|
!id.includes('node_modules') &&
|
|
13
14
|
dependencies !== null) {
|
|
14
15
|
newDeps[id] = dependencies
|
|
15
|
-
.filter(({ id }) => id &&
|
|
16
|
-
|
|
17
|
-
id
|
|
18
|
-
request
|
|
19
|
-
|
|
16
|
+
.filter(({ id }) => id &&
|
|
17
|
+
(includeNodeModules || !id.includes('node_modules')) &&
|
|
18
|
+
!(0, is_builtin_module_1.default)(id))
|
|
19
|
+
.map(({ id, request }) => {
|
|
20
|
+
const shouldAddNodeModule = includeNodeModules && (id === null || id === void 0 ? void 0 : id.includes('node_modules'));
|
|
21
|
+
const idToAdd = shouldAddNodeModule ? request : id;
|
|
22
|
+
if (shouldAddNodeModule && idToAdd) {
|
|
23
|
+
nodeModules.push(idToAdd);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
id: idToAdd,
|
|
27
|
+
request
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (includeNodeModules) {
|
|
32
|
+
nodeModules.forEach((nodeModuleName) => {
|
|
33
|
+
newDeps[nodeModuleName] = [];
|
|
34
|
+
});
|
|
20
35
|
}
|
|
21
36
|
});
|
|
22
37
|
return newDeps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string, ignoreTypesImports?: boolean): Promise<import("./types").MinimalDependencyTree>;
|
|
1
|
+
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string, ignoreTypesImports?: boolean, includeNodeModules?: boolean): Promise<import("./types").MinimalDependencyTree>;
|
package/dist/lib/getDepsTree.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.getDepsTree = void 0;
|
|
|
4
4
|
const getDepsSetWebpack_1 = require("./getDepsSetWebpack");
|
|
5
5
|
const dpdm_1 = require("dpdm");
|
|
6
6
|
const cleanupDpdmDeps_1 = require("./cleanupDpdmDeps");
|
|
7
|
-
async function getDepsTree(cwd, entryPoints, webpackConfigPath, ignoreTypesImports = false) {
|
|
7
|
+
async function getDepsTree(cwd, entryPoints, webpackConfigPath, ignoreTypesImports = false, includeNodeModules = false) {
|
|
8
8
|
let deps;
|
|
9
9
|
if (webpackConfigPath) {
|
|
10
10
|
deps = (0, getDepsSetWebpack_1.getDepsSetWebpack)(entryPoints, webpackConfigPath, cwd);
|
|
@@ -16,7 +16,7 @@ async function getDepsTree(cwd, entryPoints, webpackConfigPath, ignoreTypesImpor
|
|
|
16
16
|
deps = (0, cleanupDpdmDeps_1.cleanupDpdmDeps)(await (0, dpdm_1.parseDependencyTree)(entryPoints, {
|
|
17
17
|
context: cwd,
|
|
18
18
|
transform: ignoreTypesImports
|
|
19
|
-
}));
|
|
19
|
+
}), includeNodeModules);
|
|
20
20
|
process.cwd = oldProcessCwd;
|
|
21
21
|
}
|
|
22
22
|
return deps;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { MinimalDependencyTree } from './types';
|
|
2
2
|
export declare const getDirectoriesForEntryPointsSearch: (dir: string) => Promise<string[]>;
|
|
3
3
|
export declare const findEntryPointsInDepsTree: (deps: MinimalDependencyTree, exclude?: string[], include?: string[] | undefined) => string[];
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const prepareIgnoreInstance: (cwd: string) => Promise<import("ignore").Ignore>;
|
|
5
|
+
export declare const findEntryPointsInDepsTreeAndFilterOutIgnoredFiles: ({ cwd, depsTree, include, exclude }: {
|
|
6
|
+
depsTree: MinimalDependencyTree;
|
|
7
|
+
exclude: string[] | undefined;
|
|
8
|
+
include: string[] | undefined;
|
|
9
|
+
cwd: string;
|
|
10
|
+
}) => Promise<string[]>;
|
|
11
|
+
export declare const getEntryPoints: ({ cwd, exclude, include, webpackConfigPath, ignoreTypesImports, includeNodeModules }: {
|
|
5
12
|
cwd: string;
|
|
6
13
|
exclude?: string[] | undefined;
|
|
7
14
|
include?: string[] | undefined;
|
|
8
15
|
webpackConfigPath?: string | undefined;
|
|
9
16
|
ignoreTypesImports?: boolean | undefined;
|
|
17
|
+
includeNodeModules?: boolean | undefined;
|
|
10
18
|
}) => Promise<[string[], MinimalDependencyTree]>;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEntryPoints = exports.findEntryPointsInDepsTree = exports.getDirectoriesForEntryPointsSearch = void 0;
|
|
6
|
+
exports.getEntryPoints = exports.findEntryPointsInDepsTreeAndFilterOutIgnoredFiles = exports.prepareIgnoreInstance = exports.findEntryPointsInDepsTree = exports.getDirectoriesForEntryPointsSearch = void 0;
|
|
7
7
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -45,14 +45,7 @@ const findEntryPointsInDepsTree = (deps, exclude = [], include = undefined) => {
|
|
|
45
45
|
.sort();
|
|
46
46
|
};
|
|
47
47
|
exports.findEntryPointsInDepsTree = findEntryPointsInDepsTree;
|
|
48
|
-
const
|
|
49
|
-
const dirs = await (0, exports.getDirectoriesForEntryPointsSearch)(cwd);
|
|
50
|
-
const globs = dirs
|
|
51
|
-
.map((dirName) => path_1.default.relative(cwd, dirName))
|
|
52
|
-
.map((dirName) => `${(0, glob_escape_1.default)(dirName)}/*`);
|
|
53
|
-
const globsWithRoot = ['*', ...globs];
|
|
54
|
-
const depsTree = await (0, getDepsTree_1.getDepsTree)(cwd, globsWithRoot, webpackConfigPath, ignoreTypesImports);
|
|
55
|
-
const possibleEntryPoints = (0, exports.findEntryPointsInDepsTree)(depsTree, exclude, include);
|
|
48
|
+
const prepareIgnoreInstance = async (cwd) => {
|
|
56
49
|
const ignoreInstance = (0, ignore_1.default)();
|
|
57
50
|
let gitignore = '';
|
|
58
51
|
try {
|
|
@@ -67,6 +60,24 @@ const getEntryPoints = async ({ cwd, exclude, include, webpackConfigPath, ignore
|
|
|
67
60
|
e;
|
|
68
61
|
}
|
|
69
62
|
ignoreInstance.add(gitignore);
|
|
70
|
-
return
|
|
63
|
+
return ignoreInstance;
|
|
64
|
+
};
|
|
65
|
+
exports.prepareIgnoreInstance = prepareIgnoreInstance;
|
|
66
|
+
const findEntryPointsInDepsTreeAndFilterOutIgnoredFiles = async ({ cwd, depsTree, include = undefined, exclude = [] }) => {
|
|
67
|
+
const possibleEntryPoints = (0, exports.findEntryPointsInDepsTree)(depsTree, exclude, include).sort();
|
|
68
|
+
const ignoreInstance = await (0, exports.prepareIgnoreInstance)(cwd);
|
|
69
|
+
const entryPointsWithoutIgnoredFiles = ignoreInstance.filter(possibleEntryPoints);
|
|
70
|
+
return entryPointsWithoutIgnoredFiles;
|
|
71
|
+
};
|
|
72
|
+
exports.findEntryPointsInDepsTreeAndFilterOutIgnoredFiles = findEntryPointsInDepsTreeAndFilterOutIgnoredFiles;
|
|
73
|
+
const getEntryPoints = async ({ cwd, exclude, include, webpackConfigPath, ignoreTypesImports, includeNodeModules }) => {
|
|
74
|
+
const dirs = await (0, exports.getDirectoriesForEntryPointsSearch)(cwd);
|
|
75
|
+
const globs = dirs
|
|
76
|
+
.map((dirName) => path_1.default.relative(cwd, dirName))
|
|
77
|
+
.map((dirName) => `${(0, glob_escape_1.default)(dirName)}/*`);
|
|
78
|
+
const globsWithRoot = ['*', ...globs];
|
|
79
|
+
const depsTree = await (0, getDepsTree_1.getDepsTree)(cwd, globsWithRoot, webpackConfigPath, ignoreTypesImports, includeNodeModules);
|
|
80
|
+
const entryPointsWithoutIgnoredFiles = await (0, exports.findEntryPointsInDepsTreeAndFilterOutIgnoredFiles)({ cwd, include, exclude, depsTree });
|
|
81
|
+
return [entryPointsWithoutIgnoredFiles, depsTree];
|
|
71
82
|
};
|
|
72
83
|
exports.getEntryPoints = getEntryPoints;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MinimalDependencyTree } from './types';
|
|
2
|
+
export declare function getFilesForEntryPoint({ cwd, entryPoint, webpackConfigPath, ignoreTypesImports, depsTree: initDepsTree }: {
|
|
3
|
+
cwd: string;
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
ignoreTypesImports: boolean;
|
|
6
|
+
webpackConfigPath?: string;
|
|
7
|
+
depsTree?: MinimalDependencyTree;
|
|
8
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilesForEntryPoint = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const getDepsTree_1 = require("./getDepsTree");
|
|
6
|
+
async function getFilesForEntryPoint({ cwd, entryPoint, webpackConfigPath, ignoreTypesImports, depsTree: initDepsTree }) {
|
|
7
|
+
const sanitizedEntryPoints = (0, utils_1.sanitizeUserEntryPoints)([entryPoint]);
|
|
8
|
+
const depsTree = initDepsTree !== null && initDepsTree !== void 0 ? initDepsTree : (await (0, getDepsTree_1.getDepsTree)((0, utils_1.resolvePath)(cwd), sanitizedEntryPoints, webpackConfigPath, ignoreTypesImports));
|
|
9
|
+
const filePaths = Object.keys(depsTree);
|
|
10
|
+
return filePaths.sort();
|
|
11
|
+
}
|
|
12
|
+
exports.getFilesForEntryPoint = getFilesForEntryPoint;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MinimalDependencyTree } from './types';
|
|
2
|
+
export declare function getNodeModulesForEntryPoint({ cwd, entryPoint, webpackConfigPath, ignoreTypesImports, depsTree: initDepsTree }: {
|
|
3
|
+
cwd: string;
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
ignoreTypesImports: boolean;
|
|
6
|
+
webpackConfigPath?: string;
|
|
7
|
+
depsTree?: MinimalDependencyTree;
|
|
8
|
+
}): Promise<(string | undefined)[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNodeModulesForEntryPoint = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const getDepsTree_1 = require("./getDepsTree");
|
|
6
|
+
async function getNodeModulesForEntryPoint({ cwd, entryPoint, webpackConfigPath, ignoreTypesImports, depsTree: initDepsTree }) {
|
|
7
|
+
const sanitizedEntryPoints = (0, utils_1.sanitizeUserEntryPoints)([entryPoint]);
|
|
8
|
+
const depsTree = initDepsTree !== null && initDepsTree !== void 0 ? initDepsTree : (await (0, getDepsTree_1.getDepsTree)((0, utils_1.resolvePath)(cwd), sanitizedEntryPoints, webpackConfigPath, ignoreTypesImports, true));
|
|
9
|
+
const nodeModuleImports = Object.values(depsTree)
|
|
10
|
+
.filter((depsTree) => depsTree !== null)
|
|
11
|
+
.flat(2)
|
|
12
|
+
.filter((dep) => (dep === null || dep === void 0 ? void 0 : dep.id) && dep.id.includes('node_modules'))
|
|
13
|
+
.map((dep) => dep === null || dep === void 0 ? void 0 : dep.request)
|
|
14
|
+
.filter(Boolean);
|
|
15
|
+
const uniqueNodeModuleImports = [...new Set(nodeModuleImports)].sort();
|
|
16
|
+
return uniqueNodeModuleImports;
|
|
17
|
+
}
|
|
18
|
+
exports.getNodeModulesForEntryPoint = getNodeModulesForEntryPoint;
|
package/dist/lib/resolve.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MinimalDependencyTree } from './types';
|
|
1
2
|
declare type ResolveParams = {
|
|
2
3
|
entryPoints?: string[];
|
|
3
|
-
|
|
4
|
+
filePathOrNodeModuleName: string;
|
|
4
5
|
webpackConfig?: string;
|
|
5
6
|
cwd?: string;
|
|
6
7
|
all: boolean;
|
|
@@ -8,6 +9,7 @@ declare type ResolveParams = {
|
|
|
8
9
|
include?: string[];
|
|
9
10
|
notTraversePaths?: string[];
|
|
10
11
|
ignoreTypesImports?: boolean;
|
|
12
|
+
includeNodeModules?: boolean;
|
|
11
13
|
};
|
|
12
|
-
export declare const resolve: ({ entryPoints: _entryPoints,
|
|
14
|
+
export declare const resolve: ({ entryPoints: _entryPoints, filePathOrNodeModuleName, webpackConfig, cwd, all, include, exclude, notTraversePaths, ignoreTypesImports, includeNodeModules }: ResolveParams) => Promise<[string[][][], string[], MinimalDependencyTree]>;
|
|
13
15
|
export {};
|
package/dist/lib/resolve.js
CHANGED
|
@@ -27,12 +27,12 @@ const resolvePathsToRoot = (node, all = false, resolvedPaths = [[]]) => {
|
|
|
27
27
|
}
|
|
28
28
|
return resolvePathsToRoot(node.parents[0], false, newPaths);
|
|
29
29
|
};
|
|
30
|
-
const resolve = async ({ entryPoints: _entryPoints,
|
|
30
|
+
const resolve = async ({ entryPoints: _entryPoints, filePathOrNodeModuleName, webpackConfig, cwd = process.cwd(), all, include, exclude, notTraversePaths, ignoreTypesImports, includeNodeModules }) => {
|
|
31
31
|
let deps, entryPoints;
|
|
32
32
|
if (_entryPoints && (_entryPoints === null || _entryPoints === void 0 ? void 0 : _entryPoints.length) > 0) {
|
|
33
33
|
entryPoints = _entryPoints;
|
|
34
34
|
const sanitizedEntryPoints = (0, utils_1.sanitizeUserEntryPoints)(entryPoints);
|
|
35
|
-
deps = await (0, getDepsTree_1.getDepsTree)(cwd, sanitizedEntryPoints, webpackConfig, ignoreTypesImports);
|
|
35
|
+
deps = await (0, getDepsTree_1.getDepsTree)(cwd, sanitizedEntryPoints, webpackConfig, ignoreTypesImports, includeNodeModules);
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
;
|
|
@@ -41,12 +41,13 @@ const resolve = async ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd
|
|
|
41
41
|
exclude,
|
|
42
42
|
include,
|
|
43
43
|
webpackConfigPath: webpackConfig,
|
|
44
|
-
ignoreTypesImports
|
|
44
|
+
ignoreTypesImports,
|
|
45
|
+
includeNodeModules
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
const cleanedEntryPoints = entryPoints.map(utils_1.removeInitialDot);
|
|
48
|
-
const
|
|
49
|
-
const forest = cleanedEntryPoints.map((0, buildDepsGraph_1.buildDepsGraph)(deps,
|
|
49
|
+
const cleanedFilePathOrNodeModuleName = (0, utils_1.removeInitialDot)(filePathOrNodeModuleName);
|
|
50
|
+
const forest = cleanedEntryPoints.map((0, buildDepsGraph_1.buildDepsGraph)(deps, cleanedFilePathOrNodeModuleName, notTraversePaths));
|
|
50
51
|
const resolvedPaths = forest.reduce((allPaths, [_, fileNode]) => {
|
|
51
52
|
if (!fileNode) {
|
|
52
53
|
return [...allPaths, []];
|
|
@@ -54,6 +55,6 @@ const resolve = async ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd
|
|
|
54
55
|
const pathsForTree = resolvePathsToRoot(fileNode, all);
|
|
55
56
|
return [...allPaths, pathsForTree];
|
|
56
57
|
}, []);
|
|
57
|
-
return [resolvedPaths, entryPoints];
|
|
58
|
+
return [resolvedPaths, entryPoints, deps];
|
|
58
59
|
};
|
|
59
60
|
exports.resolve = resolve;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Dependency } from 'dpdm';
|
|
2
1
|
export declare type Node = {
|
|
3
2
|
path: string;
|
|
4
3
|
children: Node[];
|
|
5
4
|
parents: Node[];
|
|
6
5
|
};
|
|
7
|
-
export declare type MinimalDependency =
|
|
6
|
+
export declare type MinimalDependency = {
|
|
7
|
+
id: string | null;
|
|
8
|
+
request: string;
|
|
9
|
+
};
|
|
8
10
|
export declare type MinimalDependencyTree = {
|
|
9
11
|
[key: string]: readonly MinimalDependency[] | null;
|
|
10
12
|
};
|
package/dist/module.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { resolve } from './lib/resolve';
|
|
2
|
-
export { getEntryPoints } from './lib/getEntryPoints';
|
|
2
|
+
export { getEntryPoints, findEntryPointsInDepsTreeAndFilterOutIgnoredFiles, findEntryPointsInDepsTree } from './lib/getEntryPoints';
|
|
3
|
+
export { getFilesForEntryPoint } from './lib/getFilesForEntryPoint';
|
|
4
|
+
export { getNodeModulesForEntryPoint } from './lib/getNodeModulesForEntryPoint';
|
|
5
|
+
export * from './lib/types';
|
package/dist/module.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEntryPoints = exports.resolve = void 0;
|
|
17
|
+
exports.getNodeModulesForEntryPoint = exports.getFilesForEntryPoint = exports.findEntryPointsInDepsTree = exports.findEntryPointsInDepsTreeAndFilterOutIgnoredFiles = exports.getEntryPoints = exports.resolve = void 0;
|
|
4
18
|
var resolve_1 = require("./lib/resolve");
|
|
5
19
|
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return resolve_1.resolve; } });
|
|
6
20
|
var getEntryPoints_1 = require("./lib/getEntryPoints");
|
|
7
21
|
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return getEntryPoints_1.getEntryPoints; } });
|
|
22
|
+
Object.defineProperty(exports, "findEntryPointsInDepsTreeAndFilterOutIgnoredFiles", { enumerable: true, get: function () { return getEntryPoints_1.findEntryPointsInDepsTreeAndFilterOutIgnoredFiles; } });
|
|
23
|
+
Object.defineProperty(exports, "findEntryPointsInDepsTree", { enumerable: true, get: function () { return getEntryPoints_1.findEntryPointsInDepsTree; } });
|
|
24
|
+
var getFilesForEntryPoint_1 = require("./lib/getFilesForEntryPoint");
|
|
25
|
+
Object.defineProperty(exports, "getFilesForEntryPoint", { enumerable: true, get: function () { return getFilesForEntryPoint_1.getFilesForEntryPoint; } });
|
|
26
|
+
var getNodeModulesForEntryPoint_1 = require("./lib/getNodeModulesForEntryPoint");
|
|
27
|
+
Object.defineProperty(exports, "getNodeModulesForEntryPoint", { enumerable: true, get: function () { return getNodeModulesForEntryPoint_1.getNodeModulesForEntryPoint; } });
|
|
28
|
+
__exportStar(require("./lib/types"), exports);
|