dependabot-npm_and_yarn 0.366.0 → 0.367.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.
- checksums.yaml +4 -4
- data/helpers/.prettierignore +2 -0
- data/helpers/.prettierrc.json +3 -0
- data/helpers/README.md +57 -9
- data/helpers/build +4 -1
- data/helpers/eslint.config.js +29 -19
- data/helpers/jest.config.js +7 -0
- data/helpers/lib/npm/conflicting-dependency-parser.ts +94 -0
- data/helpers/lib/npm/index.ts +7 -0
- data/helpers/lib/npm/vulnerability-auditor.ts +437 -0
- data/helpers/lib/npm6/helpers.ts +25 -0
- data/helpers/lib/npm6/index.ts +4 -0
- data/helpers/lib/npm6/{peer-dependency-checker.js → peer-dependency-checker.ts} +26 -18
- data/helpers/lib/npm6/remove-dependencies-from-lockfile.ts +28 -0
- data/helpers/lib/npm6/{subdependency-updater.js → subdependency-updater.ts} +21 -14
- data/helpers/lib/npm6/types.ts +17 -0
- data/helpers/lib/pnpm/index.ts +3 -0
- data/helpers/lib/pnpm/lockfile-parser.ts +116 -0
- data/helpers/lib/yarn/{conflicting-dependency-parser.js → conflicting-dependency-parser.ts} +67 -27
- data/helpers/lib/yarn/{fix-duplicates.js → fix-duplicates.ts} +38 -19
- data/helpers/lib/yarn/{helpers.js → helpers.ts} +28 -12
- data/helpers/lib/yarn/index.ts +13 -0
- data/helpers/lib/yarn/lockfile-parser.ts +28 -0
- data/helpers/lib/yarn/{peer-dependency-checker.js → peer-dependency-checker.ts} +41 -25
- data/helpers/lib/yarn/{replace-lockfile-declaration.js → replace-lockfile-declaration.ts} +26 -19
- data/helpers/lib/yarn/{subdependency-updater.js → subdependency-updater.ts} +42 -25
- data/helpers/lib/yarn/{updater.js → updater.ts} +60 -43
- data/helpers/package-lock.json +1491 -89
- data/helpers/package.json +19 -6
- data/helpers/run.ts +53 -0
- data/helpers/test/npm/helpers.ts +19 -0
- data/helpers/test/npm/{vulnerability-auditor.test.js → vulnerability-auditor.test.ts} +34 -41
- data/helpers/test/npm6/{conflicting-dependency-parser.test.js → conflicting-dependency-parser.test.ts} +6 -8
- data/helpers/test/npm6/helpers.ts +19 -0
- data/helpers/test/pnpm/lockfile-parser.test.ts +58 -0
- data/helpers/test/yarn/{conflicting-dependency-parser.test.js → conflicting-dependency-parser.test.ts} +7 -9
- data/helpers/test/yarn/helpers.ts +16 -0
- data/helpers/test/yarn/{updater.test.js → updater.test.ts} +26 -26
- data/helpers/tsconfig.build.json +5 -0
- data/helpers/tsconfig.json +17 -0
- data/lib/dependabot/npm_and_yarn/dependency_grapher.rb +5 -5
- data/lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb +75 -6
- data/lib/dependabot/npm_and_yarn/file_updater.rb +23 -2
- data/lib/dependabot/npm_and_yarn/native_helpers.rb +1 -1
- data/lib/dependabot/npm_and_yarn/update_checker.rb +31 -11
- metadata +37 -37
- data/helpers/lib/npm/conflicting-dependency-parser.js +0 -78
- data/helpers/lib/npm/index.js +0 -9
- data/helpers/lib/npm/vulnerability-auditor.js +0 -335
- data/helpers/lib/npm6/helpers.js +0 -25
- data/helpers/lib/npm6/index.js +0 -9
- data/helpers/lib/npm6/remove-dependencies-from-lockfile.js +0 -22
- data/helpers/lib/npm6/updater.js +0 -198
- data/helpers/lib/pnpm/index.js +0 -5
- data/helpers/lib/pnpm/lockfile-parser.js +0 -82
- data/helpers/lib/yarn/index.js +0 -14
- data/helpers/lib/yarn/lockfile-parser.js +0 -21
- data/helpers/run.js +0 -30
- data/helpers/test/npm/helpers.js +0 -21
- data/helpers/test/npm6/fixtures/updater/original/package-lock.json +0 -16
- data/helpers/test/npm6/fixtures/updater/original/package.json +0 -9
- data/helpers/test/npm6/fixtures/updater/updated/package-lock.json +0 -16
- data/helpers/test/npm6/helpers.js +0 -21
- data/helpers/test/npm6/updater.test.js +0 -30
- data/helpers/test/pnpm/lockfile-parser.test.js +0 -62
- data/helpers/test/yarn/helpers.js +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd642987850077bbb8f9db021a67d28d12aa0d0274f8a544fee343a94b1305cf
|
|
4
|
+
data.tar.gz: 6cac0fa8ba502e9add46b664963d05f1014244aaf682958dc9f0788b60684077
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 328b4b756719e6865bc4a3f2b5f180b69505827b6ce06764e8c3c8a266b56367bc034cbfca1f1ea916fb53700b21aff58f130f3ccd4795bdd8ab500dda767c0c
|
|
7
|
+
data.tar.gz: 45857c428d9744dc94744674ebe2951f92f4e07f914c4ad8c7e5dd67fe649e0864e246bb96a6203d443e0d96cdf9ca44f64a902d72bb1d7b32977155501c51e8
|
data/helpers/README.md
CHANGED
|
@@ -1,22 +1,70 @@
|
|
|
1
|
-
Native
|
|
2
|
-
-------------------------
|
|
1
|
+
## Native TypeScript helpers
|
|
3
2
|
|
|
4
|
-
This directory contains helper functions for npm and
|
|
5
|
-
|
|
3
|
+
This directory contains helper functions for npm, yarn, and pnpm, written in
|
|
4
|
+
TypeScript, so that we can utilize the package managers' internal APIs and other
|
|
6
5
|
native tooling for these ecosystems.
|
|
7
6
|
|
|
8
|
-
These helpers are called from the Ruby code via `run.
|
|
7
|
+
These helpers are called from the Ruby code via `run.ts`, they are passed
|
|
9
8
|
arguments via stdin and return JSON data to stdout.
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## Development
|
|
11
|
+
|
|
12
|
+
Install dependencies:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Building
|
|
19
|
+
|
|
20
|
+
The helpers are compiled from TypeScript to JavaScript before being used at
|
|
21
|
+
runtime. To build:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
npm run build
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The compiled output goes to `dist/`.
|
|
28
|
+
|
|
29
|
+
### Type checking
|
|
30
|
+
|
|
31
|
+
Run the TypeScript compiler in check-only mode (no output):
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
npm run typecheck
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Linting
|
|
38
|
+
|
|
39
|
+
ESLint is used for code quality checks:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm run lint
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Formatting
|
|
46
|
+
|
|
47
|
+
Prettier is used for code formatting. To check for formatting issues:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
npm run format
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To auto-fix formatting:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
npm run format:fix
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Testing
|
|
12
60
|
|
|
13
61
|
When working on these helpers, it's convenient to write some high level tests in
|
|
14
|
-
|
|
62
|
+
TypeScript to make it easier to debug the code.
|
|
15
63
|
|
|
16
|
-
|
|
64
|
+
Run the tests from this directory:
|
|
17
65
|
|
|
18
66
|
```
|
|
19
|
-
|
|
67
|
+
npm test
|
|
20
68
|
```
|
|
21
69
|
|
|
22
70
|
### Debugging
|
data/helpers/build
CHANGED
|
@@ -14,7 +14,9 @@ helpers_dir="$(dirname "${BASH_SOURCE[0]}")"
|
|
|
14
14
|
cp -r \
|
|
15
15
|
"$helpers_dir/lib" \
|
|
16
16
|
"$helpers_dir/test" \
|
|
17
|
-
"$helpers_dir/run.
|
|
17
|
+
"$helpers_dir/run.ts" \
|
|
18
|
+
"$helpers_dir/tsconfig.json" \
|
|
19
|
+
"$helpers_dir/tsconfig.build.json" \
|
|
18
20
|
"$helpers_dir/eslint.config.js" \
|
|
19
21
|
"$helpers_dir/jest.config.js" \
|
|
20
22
|
"$helpers_dir/package.json" \
|
|
@@ -24,3 +26,4 @@ cp -r \
|
|
|
24
26
|
|
|
25
27
|
cd "$install_dir"
|
|
26
28
|
npm ci --fetch-timeout=600000 --fetch-retries=5
|
|
29
|
+
npm run build
|
data/helpers/eslint.config.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
const globals = require("globals");
|
|
2
2
|
const { defineConfig } = require("eslint/config");
|
|
3
3
|
const js = require("@eslint/js");
|
|
4
|
+
const tseslint = require("typescript-eslint");
|
|
4
5
|
const eslintConfigPrettier = require("eslint-config-prettier/flat");
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
module.exports = defineConfig([
|
|
8
|
+
js.configs.recommended,
|
|
9
|
+
tseslint.configs.recommended,
|
|
10
|
+
{
|
|
11
|
+
languageOptions: {
|
|
12
|
+
globals: {
|
|
13
|
+
...globals.node,
|
|
14
|
+
...globals.jest,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
8
19
|
rules: {
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
20
|
+
"@typescript-eslint/no-unused-vars": [
|
|
21
|
+
"error",
|
|
22
|
+
{ argsIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_" },
|
|
23
|
+
],
|
|
24
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
12
25
|
},
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
js
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
globals: {
|
|
20
|
-
...globals.node,
|
|
21
|
-
...globals.jest
|
|
22
|
-
}
|
|
23
|
-
},
|
|
26
|
+
},
|
|
27
|
+
eslintConfigPrettier,
|
|
28
|
+
{
|
|
29
|
+
files: ["**/*.js"],
|
|
30
|
+
rules: {
|
|
31
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
24
32
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
ignores: ["dist/**"],
|
|
36
|
+
},
|
|
37
|
+
]);
|
data/helpers/jest.config.js
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* Conflicting dependency parser for npm
|
|
2
|
+
*
|
|
3
|
+
* Inputs:
|
|
4
|
+
* - directory containing a package.json and a yarn.lock
|
|
5
|
+
* - dependency name
|
|
6
|
+
* - target dependency version
|
|
7
|
+
*
|
|
8
|
+
* Outputs:
|
|
9
|
+
* - An array of objects with conflicting dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import Arborist from "@npmcli/arborist";
|
|
13
|
+
import semver from "semver";
|
|
14
|
+
|
|
15
|
+
interface ConflictingDependency {
|
|
16
|
+
explanation: string;
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
requirement: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function findConflictingDependencies(
|
|
23
|
+
directory: string,
|
|
24
|
+
depName: string,
|
|
25
|
+
targetVersion: string
|
|
26
|
+
): Promise<ConflictingDependency[]> {
|
|
27
|
+
const arb = new Arborist({
|
|
28
|
+
path: directory,
|
|
29
|
+
dryRun: true,
|
|
30
|
+
ignoreScripts: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return await arb.loadVirtual().then((tree) => {
|
|
34
|
+
const parents: ConflictingDependency[] = [];
|
|
35
|
+
for (const node of tree.inventory.query("name", depName)) {
|
|
36
|
+
for (const edge of node.edgesIn) {
|
|
37
|
+
if (!semver.satisfies(targetVersion, edge.spec)) {
|
|
38
|
+
findTopLevelEdges(edge).forEach((topLevel) => {
|
|
39
|
+
const explanation = buildExplanation(node, edge, topLevel);
|
|
40
|
+
|
|
41
|
+
parents.push({
|
|
42
|
+
explanation: explanation,
|
|
43
|
+
name: edge.from!.name,
|
|
44
|
+
version: edge.from!.version,
|
|
45
|
+
requirement: edge.spec,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return parents;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function buildExplanation(
|
|
57
|
+
node: Arborist.Node,
|
|
58
|
+
directEdge: Arborist.Edge,
|
|
59
|
+
topLevelEdge: Arborist.Edge
|
|
60
|
+
): string {
|
|
61
|
+
if (directEdge.from === topLevelEdge.to) {
|
|
62
|
+
// The nodes parent is top-level
|
|
63
|
+
return `${directEdge.from!.name}@${directEdge.from!.version} requires ${directEdge.to!.name}@${directEdge.spec}`;
|
|
64
|
+
} else if (topLevelEdge.to!.edgesOut.has(directEdge.from!.name)) {
|
|
65
|
+
// The nodes parent is a direct dependency of the top-level dependency
|
|
66
|
+
return (
|
|
67
|
+
`${topLevelEdge.to!.name}@${topLevelEdge.to!.version} requires ${directEdge.to!.name}@${directEdge.spec} ` +
|
|
68
|
+
`via ${directEdge.from!.name}@${directEdge.from!.version}`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
// The nodes parent is a transitive dependency of the top-level dependency
|
|
72
|
+
return (
|
|
73
|
+
`${topLevelEdge.to!.name}@${topLevelEdge.to!.version} requires ${directEdge.to!.name}@${directEdge.spec} ` +
|
|
74
|
+
`via a transitive dependency on ${directEdge.from!.name}@${directEdge.from!.version}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function findTopLevelEdges(
|
|
80
|
+
edge: Arborist.Edge,
|
|
81
|
+
parents: Arborist.Edge[] = []
|
|
82
|
+
): Arborist.Edge[] {
|
|
83
|
+
edge.from!.edgesIn.forEach((parent) => {
|
|
84
|
+
if (parent.from!.edgesIn.size === 0) {
|
|
85
|
+
if (!parents.includes(parent)) {
|
|
86
|
+
parents.push(parent);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
findTopLevelEdges(parent, parents);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return parents;
|
|
94
|
+
}
|