registry-sync 4.0.2 → 5.0.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 +1 -1
- package/package.json +20 -20
- package/src/resolve.js +17 -23
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "registry-sync",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "synchronize a remote npm registry for private use",
|
|
5
5
|
"repository": "https://github.com/heikkipora/registry-sync",
|
|
6
6
|
"bin": {
|
|
@@ -20,35 +20,35 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@yarnpkg/lockfile": "1.1.0",
|
|
23
|
-
"axios": "1.
|
|
24
|
-
"commander": "
|
|
25
|
-
"semver": "7.
|
|
26
|
-
"ssri": "10.0.
|
|
27
|
-
"tar-fs": "
|
|
23
|
+
"axios": "1.5.0",
|
|
24
|
+
"commander": "11.0.0",
|
|
25
|
+
"semver": "7.5.4",
|
|
26
|
+
"ssri": "10.0.5",
|
|
27
|
+
"tar-fs": "3.0.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@arkweid/lefthook": "0.7.7",
|
|
31
|
-
"@types/chai": "4.3.
|
|
32
|
-
"@types/lodash": "4.14.
|
|
31
|
+
"@types/chai": "4.3.6",
|
|
32
|
+
"@types/lodash": "4.14.197",
|
|
33
33
|
"@types/mocha": "10.0.1",
|
|
34
|
-
"@types/node": "
|
|
35
|
-
"@types/semver": "7.
|
|
34
|
+
"@types/node": "20.5.9",
|
|
35
|
+
"@types/semver": "7.5.1",
|
|
36
36
|
"@types/ssri": "7.1.1",
|
|
37
37
|
"@types/tar-fs": "2.0.1",
|
|
38
|
-
"@types/yarnpkg__lockfile": "1.1.
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "
|
|
40
|
-
"@typescript-eslint/parser": "
|
|
41
|
-
"chai": "4.3.
|
|
42
|
-
"eslint": "8.
|
|
43
|
-
"eslint-config-prettier": "
|
|
38
|
+
"@types/yarnpkg__lockfile": "1.1.6",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "6.6.0",
|
|
40
|
+
"@typescript-eslint/parser": "6.6.0",
|
|
41
|
+
"chai": "4.3.8",
|
|
42
|
+
"eslint": "8.48.0",
|
|
43
|
+
"eslint-config-prettier": "9.0.0",
|
|
44
44
|
"eslint-formatter-codeframe": "7.32.1",
|
|
45
45
|
"eslint-plugin-mocha": "10.1.0",
|
|
46
46
|
"express": "4.18.2",
|
|
47
|
-
"lint-staged": "
|
|
47
|
+
"lint-staged": "14.0.1",
|
|
48
48
|
"mocha": "10.2.0",
|
|
49
|
-
"prettier": "
|
|
49
|
+
"prettier": "3.0.3",
|
|
50
50
|
"ts-node": "10.9.1",
|
|
51
|
-
"typescript": "
|
|
51
|
+
"typescript": "5.2.2"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"registry",
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"offline"
|
|
59
59
|
],
|
|
60
60
|
"engines": {
|
|
61
|
-
"node": ">=14.0
|
|
61
|
+
"node": ">=16.14.0"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/resolve.js
CHANGED
|
@@ -128,7 +128,11 @@ function resolveNpmPackagesFromYarnLockDependencies(yarnLockDependencies) {
|
|
|
128
128
|
}
|
|
129
129
|
async function parseDependenciesFromNpmLockFile(lockFilepath, includeDevDependencies) {
|
|
130
130
|
const packageLock = JSON.parse(await fs.promises.readFile(lockFilepath, 'utf8'));
|
|
131
|
-
const
|
|
131
|
+
const fileVersion = packageLock.lockfileVersion || 1;
|
|
132
|
+
if (![2, 3].includes(packageLock.lockfileVersion)) {
|
|
133
|
+
throw new Error(`Unsupported package-lock.json version ${fileVersion}`);
|
|
134
|
+
}
|
|
135
|
+
const dependencies = collectNpmLockfileDependencies(packageLock, includeDevDependencies);
|
|
132
136
|
return dependencies.map(({ name, version }) => ({ id: `${name}@${version}`, name, version }));
|
|
133
137
|
}
|
|
134
138
|
async function parseDependenciesFromYarnLockFile(lockFilepath) {
|
|
@@ -180,28 +184,18 @@ function isNotLocal(dependency) {
|
|
|
180
184
|
// that we set up anyway, so don't attempt to synchronize it
|
|
181
185
|
return !dependency.version.startsWith('file:');
|
|
182
186
|
}
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
const [realName, realVersion] = props.version.replace(/^npm:/, '').split('@');
|
|
196
|
-
return { name: realName, version: realVersion };
|
|
197
|
-
}
|
|
198
|
-
return { name, version: props.version };
|
|
199
|
-
}
|
|
200
|
-
function filterOutBundledDependencies([, props]) {
|
|
201
|
-
return !props.bundled;
|
|
202
|
-
}
|
|
203
|
-
function filterOutBundledAndDevDependencies([, props]) {
|
|
204
|
-
return !(props.bundled || props.dev);
|
|
187
|
+
function collectNpmLockfileDependencies({ packages }, includeDevDependencies) {
|
|
188
|
+
return Object.entries(packages)
|
|
189
|
+
.filter(([name, props]) => name.length > 0 && (includeDevDependencies || !props.dev))
|
|
190
|
+
.map(([name, props]) => ({
|
|
191
|
+
name: props.name || pathToName(name),
|
|
192
|
+
version: props.version
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
// "node_modules/lodash" -> "lodash"
|
|
196
|
+
// "node_modules/make-dir/node_modules/semver" -> "semver"
|
|
197
|
+
function pathToName(path) {
|
|
198
|
+
return path.split('node_modules/').pop();
|
|
205
199
|
}
|
|
206
200
|
function isDeepEqual(a, b) {
|
|
207
201
|
try {
|