rev-dep 1.0.6 → 1.1.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/bin.js +0 -0
- package/dist/cli/docs/template.d.ts +1 -1
- package/dist/cli/entryPoints/index.js +1 -1
- package/dist/cli/resolve/formatResults.js +1 -1
- package/dist/lib/buildDepsGraph.d.ts +1 -1
- package/dist/lib/buildDepsGraph.js +10 -4
- package/dist/lib/getDepsTree.d.ts +1 -1
- package/dist/lib/getDepsTree.js +3 -2
- package/dist/lib/getEntryPoints.d.ts +2 -1
- package/dist/lib/getEntryPoints.js +3 -3
- package/dist/lib/resolve.d.ts +4 -2
- package/dist/lib/resolve.js +18 -5
- package/dist/supersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersupersuperLongPath.ts +1 -0
- package/package.json +1 -1
package/bin.js
CHANGED
|
File without changes
|
|
@@ -26,7 +26,7 @@ function createEntryPoints(program) {
|
|
|
26
26
|
let depsCount = null;
|
|
27
27
|
if (printDependenciesCount) {
|
|
28
28
|
depsCount = entryPoints
|
|
29
|
-
.map((0, buildDepsGraph_1.
|
|
29
|
+
.map((0, buildDepsGraph_1.buildDepsGraph)(depsTree))
|
|
30
30
|
.map(([_, __, vertices]) => vertices.size);
|
|
31
31
|
}
|
|
32
32
|
if (count) {
|
|
@@ -33,7 +33,7 @@ function formatResults({ results, filePath, 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', filePath, 'in'
|
|
36
|
+
formatted = join('No results found for', filePath, 'in the following entry points list:\n' + entryPoints.join('\n'));
|
|
37
37
|
return formatted;
|
|
38
38
|
}
|
|
39
39
|
if (compactSummary) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Node, MinimalDependencyTree } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const buildDepsGraph: (deps: MinimalDependencyTree, filePath?: string | undefined, notTraversePath?: string[] | undefined) => (entryPoint: string) => [Node, Node | null, Map<string, Node>];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
6
|
+
exports.buildDepsGraph = void 0;
|
|
7
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
8
|
+
const buildDepsGraph = (deps, filePath, notTraversePath) => (entryPoint) => {
|
|
5
9
|
const vertices = new Map();
|
|
6
10
|
let fileNode = null;
|
|
7
11
|
const inner = (path, visited = new Set(), depth = 1, parent = null) => {
|
|
@@ -30,7 +34,9 @@ const buildGraphDpdm = (deps, filePath) => (entryPoint) => {
|
|
|
30
34
|
};
|
|
31
35
|
node.children = (dep || [])
|
|
32
36
|
.map((d) => d.id)
|
|
33
|
-
.filter((path) => path !== null &&
|
|
37
|
+
.filter((path) => path !== null &&
|
|
38
|
+
!path.includes('node_modules') &&
|
|
39
|
+
!(notTraversePath === null || notTraversePath === void 0 ? void 0 : notTraversePath.some((pathToNotTraverse) => (0, minimatch_1.default)(path, pathToNotTraverse))))
|
|
34
40
|
.map((path) => inner(path, localVisited, depth + 1, node));
|
|
35
41
|
vertices.set(path, node);
|
|
36
42
|
if (path === filePath) {
|
|
@@ -40,4 +46,4 @@ const buildGraphDpdm = (deps, filePath) => (entryPoint) => {
|
|
|
40
46
|
};
|
|
41
47
|
return [inner(entryPoint), fileNode, vertices];
|
|
42
48
|
};
|
|
43
|
-
exports.
|
|
49
|
+
exports.buildDepsGraph = buildDepsGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string): Promise<import("./types").MinimalDependencyTree>;
|
|
1
|
+
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string, ignoreTypesImports?: 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) {
|
|
7
|
+
async function getDepsTree(cwd, entryPoints, webpackConfigPath, ignoreTypesImports = false) {
|
|
8
8
|
let deps;
|
|
9
9
|
if (webpackConfigPath) {
|
|
10
10
|
deps = (0, getDepsSetWebpack_1.getDepsSetWebpack)(entryPoints, webpackConfigPath, cwd);
|
|
@@ -14,7 +14,8 @@ async function getDepsTree(cwd, entryPoints, webpackConfigPath) {
|
|
|
14
14
|
const oldProcessCwd = process.cwd;
|
|
15
15
|
process.cwd = () => cwd;
|
|
16
16
|
deps = (0, cleanupDpdmDeps_1.cleanupDpdmDeps)(await (0, dpdm_1.parseDependencyTree)(entryPoints, {
|
|
17
|
-
context: cwd
|
|
17
|
+
context: cwd,
|
|
18
|
+
transform: ignoreTypesImports
|
|
18
19
|
}));
|
|
19
20
|
process.cwd = oldProcessCwd;
|
|
20
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
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 getEntryPoints: ({ cwd, exclude, include, webpackConfigPath }: {
|
|
4
|
+
export declare const getEntryPoints: ({ cwd, exclude, include, webpackConfigPath, ignoreTypesImports }: {
|
|
5
5
|
cwd: string;
|
|
6
6
|
exclude?: string[] | undefined;
|
|
7
7
|
include?: string[] | undefined;
|
|
8
8
|
webpackConfigPath?: string | undefined;
|
|
9
|
+
ignoreTypesImports?: boolean | undefined;
|
|
9
10
|
}) => Promise<[string[], MinimalDependencyTree]>;
|
|
@@ -35,7 +35,7 @@ const findEntryPointsInDepsTree = (deps, exclude = [], include = undefined) => {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
return Object.keys(deps)
|
|
38
|
-
.filter((id) => /\.(ts|tsx|mjs|js|jsx)$/.test(id) &&
|
|
38
|
+
.filter((id) => /\.(ts|tsx|mjs|cjs|js|jsx)$/.test(id) &&
|
|
39
39
|
!/node_modules/.test(id) &&
|
|
40
40
|
!referencedIds.has(id))
|
|
41
41
|
.filter((id) => exclude.reduce((result, pattern) => result && !(0, minimatch_1.default)(id, pattern), true))
|
|
@@ -45,13 +45,13 @@ const findEntryPointsInDepsTree = (deps, exclude = [], include = undefined) => {
|
|
|
45
45
|
.sort();
|
|
46
46
|
};
|
|
47
47
|
exports.findEntryPointsInDepsTree = findEntryPointsInDepsTree;
|
|
48
|
-
const getEntryPoints = async ({ cwd, exclude, include, webpackConfigPath }) => {
|
|
48
|
+
const getEntryPoints = async ({ cwd, exclude, include, webpackConfigPath, ignoreTypesImports }) => {
|
|
49
49
|
const dirs = await (0, exports.getDirectoriesForEntryPointsSearch)(cwd);
|
|
50
50
|
const globs = dirs
|
|
51
51
|
.map((dirName) => path_1.default.relative(cwd, dirName))
|
|
52
52
|
.map((dirName) => `${(0, glob_escape_1.default)(dirName)}/*`);
|
|
53
53
|
const globsWithRoot = ['*', ...globs];
|
|
54
|
-
const depsTree = await (0, getDepsTree_1.getDepsTree)(cwd, globsWithRoot, webpackConfigPath);
|
|
54
|
+
const depsTree = await (0, getDepsTree_1.getDepsTree)(cwd, globsWithRoot, webpackConfigPath, ignoreTypesImports);
|
|
55
55
|
const possibleEntryPoints = (0, exports.findEntryPointsInDepsTree)(depsTree, exclude, include);
|
|
56
56
|
const ignoreInstance = (0, ignore_1.default)();
|
|
57
57
|
let gitignore = '';
|
package/dist/lib/resolve.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
declare type ResolveParams = {
|
|
2
|
-
entryPoints
|
|
2
|
+
entryPoints?: string[];
|
|
3
3
|
filePath: string;
|
|
4
4
|
webpackConfig?: string;
|
|
5
5
|
cwd?: string;
|
|
6
6
|
all: boolean;
|
|
7
7
|
exclude?: string[];
|
|
8
8
|
include?: string[];
|
|
9
|
+
notTraversePaths?: string[];
|
|
10
|
+
ignoreTypesImports?: boolean;
|
|
9
11
|
};
|
|
10
|
-
export declare const resolve: ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd, all, include, exclude }: ResolveParams) => Promise<[string[][][], string[]]>;
|
|
12
|
+
export declare const resolve: ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd, all, include, exclude, notTraversePaths, ignoreTypesImports }: ResolveParams) => Promise<[string[][][], string[]]>;
|
|
11
13
|
export {};
|
package/dist/lib/resolve.js
CHANGED
|
@@ -11,6 +11,13 @@ const resolvePathsToRoot = (node, all = false, resolvedPaths = [[]]) => {
|
|
|
11
11
|
...resolvedPath
|
|
12
12
|
]);
|
|
13
13
|
if (node.parents.length === 0) {
|
|
14
|
+
/*
|
|
15
|
+
* If there is only one path, and has length of 1, it's file self reference
|
|
16
|
+
* It's invalid result, so we return empty paths in that case
|
|
17
|
+
*/
|
|
18
|
+
if (newPaths.length === 1 && newPaths[0].length === 1) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
14
21
|
return newPaths;
|
|
15
22
|
}
|
|
16
23
|
if (all) {
|
|
@@ -20,20 +27,26 @@ const resolvePathsToRoot = (node, all = false, resolvedPaths = [[]]) => {
|
|
|
20
27
|
}
|
|
21
28
|
return resolvePathsToRoot(node.parents[0], false, newPaths);
|
|
22
29
|
};
|
|
23
|
-
const resolve = async ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd = process.cwd(), all, include, exclude }) => {
|
|
30
|
+
const resolve = async ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd = process.cwd(), all, include, exclude, notTraversePaths, ignoreTypesImports }) => {
|
|
24
31
|
let deps, entryPoints;
|
|
25
|
-
if (_entryPoints.length > 0) {
|
|
32
|
+
if (_entryPoints && (_entryPoints === null || _entryPoints === void 0 ? void 0 : _entryPoints.length) > 0) {
|
|
26
33
|
entryPoints = _entryPoints;
|
|
27
34
|
const sanitizedEntryPoints = (0, utils_1.sanitizeUserEntryPoints)(entryPoints);
|
|
28
|
-
deps = await (0, getDepsTree_1.getDepsTree)(cwd, sanitizedEntryPoints, webpackConfig);
|
|
35
|
+
deps = await (0, getDepsTree_1.getDepsTree)(cwd, sanitizedEntryPoints, webpackConfig, ignoreTypesImports);
|
|
29
36
|
}
|
|
30
37
|
else {
|
|
31
38
|
;
|
|
32
|
-
[entryPoints, deps] = await (0, getEntryPoints_1.getEntryPoints)({
|
|
39
|
+
[entryPoints, deps] = await (0, getEntryPoints_1.getEntryPoints)({
|
|
40
|
+
cwd,
|
|
41
|
+
exclude,
|
|
42
|
+
include,
|
|
43
|
+
webpackConfigPath: webpackConfig,
|
|
44
|
+
ignoreTypesImports
|
|
45
|
+
});
|
|
33
46
|
}
|
|
34
47
|
const cleanedEntryPoints = entryPoints.map(utils_1.removeInitialDot);
|
|
35
48
|
const cleanedFilePath = (0, utils_1.removeInitialDot)(filePath);
|
|
36
|
-
const forest = cleanedEntryPoints.map((0, buildDepsGraph_1.
|
|
49
|
+
const forest = cleanedEntryPoints.map((0, buildDepsGraph_1.buildDepsGraph)(deps, cleanedFilePath, notTraversePaths));
|
|
37
50
|
const resolvedPaths = forest.reduce((allPaths, [_, fileNode]) => {
|
|
38
51
|
if (!fileNode) {
|
|
39
52
|
return [...allPaths, []];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a = 5
|