registry-sync 3.2.5 → 3.3.3
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 +16 -7
- package/package.json +19 -18
- package/src/download.js +8 -8
- package/src/index.js +13 -7
- package/src/metadata.js +3 -3
- package/src/pregyp.js +1 -1
- package/src/resolve.js +11 -3
- package/src/sync.js +4 -4
package/README.md
CHANGED
|
@@ -25,13 +25,22 @@ The local copy can then be used as a simple private NPM registry without publish
|
|
|
25
25
|
--root <path> Path to save NPM package tarballs and metadata to
|
|
26
26
|
--manifest <file> Path to a package-lock.json or yarn.lock file to use as catalog for mirrored NPM packages
|
|
27
27
|
--localUrl <url> URL to use as root in stored package metadata (i.e. where folder defined as --root will be exposed at)
|
|
28
|
-
--binaryAbi <list>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
--
|
|
32
|
-
|
|
28
|
+
--binaryAbi <list> Optional comma-separated list of node C++ ABI numbers to download pre-built binaries for.
|
|
29
|
+
See NODE_MODULE_VERSION column in https://nodejs.org/en/download/releases/.
|
|
30
|
+
Default value is from the current Node.js process.
|
|
31
|
+
--binaryArch <list> Optional comma-separated list of CPU architectures to download pre-built binaries for.
|
|
32
|
+
Valid values: arm, ia32, and x64.
|
|
33
|
+
Default value is from the current Node.js process.
|
|
34
|
+
--binaryPlatform <list> Optional comma-separated list of OS platforms to download pre-built binaries for.
|
|
35
|
+
Valid values: linux, darwin, win32, sunos, freebsd, openbsd, and aix.
|
|
36
|
+
Default value is from the current Node.js process.
|
|
37
|
+
--registryUrl [url] Optional URL to use as NPM registry when fetching packages.
|
|
38
|
+
Default value is https://registry.npmjs.org
|
|
39
|
+
--registryToken [string] Optional Bearer token for the registry.
|
|
40
|
+
Not included by default.
|
|
33
41
|
--dontEnforceHttps Disable the default behavior of downloading tarballs over HTTPS (will use whichever protocol is defined in the registry metadata)
|
|
34
|
-
--includeDev Include also packages found from devDependencies section of the --manifest.
|
|
42
|
+
--includeDev Include also packages found from devDependencies section of the --manifest.
|
|
43
|
+
Not included by default.
|
|
35
44
|
--dryRun Print packages that would be downloaded but do not download them
|
|
36
45
|
|
|
37
46
|
Example:
|
|
@@ -109,5 +118,5 @@ See [releases](https://github.com/heikkipora/registry-sync/releases).
|
|
|
109
118
|
|
|
110
119
|
## Contributing
|
|
111
120
|
|
|
112
|
-
Pull requests are welcome. Kindly check that your code passes ESLint checks by running `npm run eslint` first.
|
|
121
|
+
Pull requests are welcome. Kindly check that your code passes ESLint checks by running `npm run eslint:check` first.
|
|
113
122
|
Integration tests can be run with `npm test`. Both are anyway run automatically by GitHub Actions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "registry-sync",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "synchronize a remote npm registry for private use",
|
|
5
5
|
"repository": "https://github.com/heikkipora/registry-sync",
|
|
6
6
|
"bin": {
|
|
@@ -20,34 +20,35 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@yarnpkg/lockfile": "1.1.0",
|
|
23
|
-
"axios": "0.
|
|
24
|
-
"commander": "8.
|
|
23
|
+
"axios": "0.24.0",
|
|
24
|
+
"commander": "8.3.0",
|
|
25
25
|
"semver": "7.3.5",
|
|
26
26
|
"ssri": "8.0.1",
|
|
27
27
|
"tar-fs": "2.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@arkweid/lefthook": "0.7.
|
|
31
|
-
"@types/chai": "4.
|
|
32
|
-
"@types/lodash": "4.14.
|
|
30
|
+
"@arkweid/lefthook": "0.7.7",
|
|
31
|
+
"@types/chai": "4.3.0",
|
|
32
|
+
"@types/lodash": "4.14.178",
|
|
33
33
|
"@types/mocha": "9.0.0",
|
|
34
|
-
"@types/node": "
|
|
35
|
-
"@types/semver": "7.3.
|
|
34
|
+
"@types/node": "17.0.5",
|
|
35
|
+
"@types/semver": "7.3.9",
|
|
36
36
|
"@types/ssri": "7.1.1",
|
|
37
37
|
"@types/tar-fs": "2.0.1",
|
|
38
38
|
"@types/yarnpkg__lockfile": "1.1.5",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "
|
|
40
|
-
"@typescript-eslint/parser": "
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "5.8.1",
|
|
40
|
+
"@typescript-eslint/parser": "5.8.1",
|
|
41
41
|
"chai": "4.3.4",
|
|
42
|
-
"eslint": "
|
|
42
|
+
"eslint": "8.5.0",
|
|
43
43
|
"eslint-config-prettier": "8.3.0",
|
|
44
|
-
"eslint-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
44
|
+
"eslint-formatter-codeframe": "7.32.1",
|
|
45
|
+
"eslint-plugin-mocha": "10.0.3",
|
|
46
|
+
"express": "4.17.2",
|
|
47
|
+
"lint-staged": "12.1.4",
|
|
48
|
+
"mocha": "9.1.3",
|
|
49
|
+
"prettier": "2.5.1",
|
|
50
|
+
"ts-node": "10.4.0",
|
|
51
|
+
"typescript": "4.5.4"
|
|
51
52
|
},
|
|
52
53
|
"keywords": [
|
|
53
54
|
"registry",
|
package/src/download.js
CHANGED
|
@@ -24,19 +24,19 @@ async function download(registryUrl, registryToken, localUrl, rootFolder, prebui
|
|
|
24
24
|
}
|
|
25
25
|
const localFolder = await ensureLocalFolderExists(name, rootFolder);
|
|
26
26
|
let data = await downloadTarball(versionMetadata, enforceTarballsOverHttps, registryToken);
|
|
27
|
-
if (pregyp_1.hasPrebuiltBinaries(versionMetadata)) {
|
|
27
|
+
if ((0, pregyp_1.hasPrebuiltBinaries)(versionMetadata)) {
|
|
28
28
|
const localPregypFolder = await ensureLocalFolderExists(version, localFolder);
|
|
29
|
-
await pregyp_1.downloadPrebuiltBinaries(versionMetadata, localPregypFolder, prebuiltBinaryProperties);
|
|
30
|
-
data = await metadata_1.rewriteMetadataInTarball(data, versionMetadata, localUrl, localFolder);
|
|
29
|
+
await (0, pregyp_1.downloadPrebuiltBinaries)(versionMetadata, localPregypFolder, prebuiltBinaryProperties);
|
|
30
|
+
data = await (0, metadata_1.rewriteMetadataInTarball)(data, versionMetadata, localUrl, localFolder);
|
|
31
31
|
}
|
|
32
32
|
await saveTarball(versionMetadata, data, localFolder);
|
|
33
|
-
metadata_1.rewriteVersionMetadata(versionMetadata, data, localUrl);
|
|
33
|
+
(0, metadata_1.rewriteVersionMetadata)(versionMetadata, data, localUrl);
|
|
34
34
|
await updateMetadata(versionMetadata, registryMetadata, registryUrl, localFolder);
|
|
35
35
|
}
|
|
36
36
|
async function downloadTarball({ _id: id, dist }, enforceTarballsOverHttps, registryToken) {
|
|
37
37
|
const tarballUrl = enforceTarballsOverHttps ? dist.tarball.replace('http://', 'https://') : dist.tarball;
|
|
38
|
-
const data = await client_1.fetchBinaryData(tarballUrl, registryToken);
|
|
39
|
-
integrity_1.verifyIntegrity(data, id, dist);
|
|
38
|
+
const data = await (0, client_1.fetchBinaryData)(tarballUrl, registryToken);
|
|
39
|
+
(0, integrity_1.verifyIntegrity)(data, id, dist);
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
function saveTarball({ name, version }, data, localFolder) {
|
|
@@ -65,7 +65,7 @@ function saveMetadata(path, metadata) {
|
|
|
65
65
|
return fs.promises.writeFile(path, json, 'utf8');
|
|
66
66
|
}
|
|
67
67
|
function tarballPath(name, version, localFolder) {
|
|
68
|
-
return path.join(localFolder, metadata_1.tarballFilename(name, version));
|
|
68
|
+
return path.join(localFolder, (0, metadata_1.tarballFilename)(name, version));
|
|
69
69
|
}
|
|
70
70
|
async function ensureLocalFolderExists(name, rootFolder) {
|
|
71
71
|
const localFolder = path.resolve(rootFolder, name);
|
|
@@ -74,5 +74,5 @@ async function ensureLocalFolderExists(name, rootFolder) {
|
|
|
74
74
|
}
|
|
75
75
|
function fetchMetadataCloned(name, registryUrl, registryToken) {
|
|
76
76
|
const urlSafeName = name.replace(/\//g, '%2f');
|
|
77
|
-
return client_1.fetchJsonWithCacheCloned(url.resolve(registryUrl, urlSafeName), registryToken);
|
|
77
|
+
return (0, client_1.fetchJsonWithCacheCloned)(url.resolve(registryUrl, urlSafeName), registryToken);
|
|
78
78
|
}
|
package/src/index.js
CHANGED
|
@@ -12,9 +12,9 @@ program
|
|
|
12
12
|
.requiredOption('--root <path>', 'Path to save NPM package tarballs and metadata to')
|
|
13
13
|
.requiredOption('--manifest <file>', 'Path to a package-lock.json or yarn.lock file to use as catalog for mirrored NPM packages.')
|
|
14
14
|
.requiredOption('--localUrl <url>', 'URL to use as root in stored package metadata (i.e. where folder defined as --root will be exposed at)')
|
|
15
|
-
.
|
|
16
|
-
.
|
|
17
|
-
.
|
|
15
|
+
.option('--binaryAbi <list>', 'Comma-separated list of node C++ ABI numbers to download pre-built binaries for. See NODE_MODULE_VERSION column in https://nodejs.org/en/download/releases/')
|
|
16
|
+
.option('--binaryArch <list>', 'Comma-separated list of CPU architectures to download pre-built binaries for. Valid values: arm, ia32, and x64')
|
|
17
|
+
.option('--binaryPlatform <list>', 'Comma-separated list of OS platforms to download pre-built binaries for. Valid values: linux, darwin, win32, sunos, freebsd, openbsd, and aix')
|
|
18
18
|
.option('--registryUrl [url]', 'Optional URL to use as NPM registry when fetching packages. Default value is https://registry.npmjs.org')
|
|
19
19
|
.option('--registryToken [string]', 'Optional Bearer token for the registry.')
|
|
20
20
|
.option('--dontEnforceHttps', 'Disable the default behavior of downloading tarballs over HTTPS (will use whichever protocol is defined in the registry metadata)')
|
|
@@ -22,9 +22,15 @@ program
|
|
|
22
22
|
.option('--dryRun', 'Print packages that would be downloaded but do not download them')
|
|
23
23
|
.parse(process.argv);
|
|
24
24
|
const rawOptions = program.opts();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// use current (abi,arch,platform) triplet as default if none is specified
|
|
26
|
+
// so the user doesn't have to look them up if build is always done on the
|
|
27
|
+
// same kind of machine
|
|
28
|
+
const binaryAbi = rawOptions.binaryAbi || process.versions.modules;
|
|
29
|
+
const binaryArch = rawOptions.binaryArch || process.arch;
|
|
30
|
+
const binaryPlatform = rawOptions.binaryPlatform || process.platform;
|
|
31
|
+
const abis = binaryAbi.split(',').map(Number);
|
|
32
|
+
const architectures = binaryArch.split(',');
|
|
33
|
+
const platforms = binaryPlatform.split(',');
|
|
28
34
|
const prebuiltBinaryProperties = abis
|
|
29
35
|
.map(abi => architectures.map(arch => platforms.map(platform => ({ abi, arch, platform }))).flat())
|
|
30
36
|
.flat();
|
|
@@ -39,4 +45,4 @@ const options = {
|
|
|
39
45
|
includeDevDependencies: Boolean(rawOptions.includeDev),
|
|
40
46
|
dryRun: Boolean(rawOptions.dryRun)
|
|
41
47
|
};
|
|
42
|
-
sync_1.synchronize(options);
|
|
48
|
+
(0, sync_1.synchronize)(options);
|
package/src/metadata.js
CHANGED
|
@@ -10,11 +10,11 @@ const stream_1 = require("stream");
|
|
|
10
10
|
const integrity_1 = require("./integrity");
|
|
11
11
|
function rewriteVersionMetadata(versionMetadata, data, localUrl) {
|
|
12
12
|
versionMetadata.dist.tarball = localTarballUrl(versionMetadata, localUrl);
|
|
13
|
-
if (pregyp_1.hasPrebuiltBinaries(versionMetadata)) {
|
|
13
|
+
if ((0, pregyp_1.hasPrebuiltBinaries)(versionMetadata)) {
|
|
14
14
|
versionMetadata.binary.host = localUrl.origin;
|
|
15
15
|
versionMetadata.binary.remote_path = createPrebuiltBinaryRemotePath(localUrl, versionMetadata);
|
|
16
|
-
versionMetadata.dist.integrity = integrity_1.sha512(data);
|
|
17
|
-
versionMetadata.dist.shasum = integrity_1.sha1(data);
|
|
16
|
+
versionMetadata.dist.integrity = (0, integrity_1.sha512)(data);
|
|
17
|
+
versionMetadata.dist.shasum = (0, integrity_1.sha1)(data);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.rewriteVersionMetadata = rewriteVersionMetadata;
|
package/src/pregyp.js
CHANGED
|
@@ -40,7 +40,7 @@ async function downloadPrebuiltBinary(localFolder, name, version, binary, abi, p
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function fetchPrebuiltBinary(name, version, binary, abi, platform, arch, napiVersion) {
|
|
43
|
-
return client_1.fetchBinaryData(prebuiltBinaryUrl(name, version, binary, abi, platform, arch, napiVersion), '');
|
|
43
|
+
return (0, client_1.fetchBinaryData)(prebuiltBinaryUrl(name, version, binary, abi, platform, arch, napiVersion), '');
|
|
44
44
|
}
|
|
45
45
|
function prebuiltBinaryFilePath(localFolder, name, version, binary, abi, platform, arch, napiVersion) {
|
|
46
46
|
return path.join(localFolder, prebuiltBinaryFileName(name, version, binary, abi, platform, arch, napiVersion));
|
package/src/resolve.js
CHANGED
|
@@ -108,7 +108,7 @@ function resolveNpmPackagesFromYarnLockDependencies(yarnLockDependencies) {
|
|
|
108
108
|
else {
|
|
109
109
|
// Package pattern not yet recognized, continue with parsing logic from
|
|
110
110
|
// https://github.com/yarnpkg/yarn/blob/953c8b6a20e360b097625d64189e6e56ed813e0f/src/package-request.js#L99
|
|
111
|
-
const { name: namePart, range: rangePart } = normalize_yarn_pattern_1.normalizeYarnPackagePattern(packagePattern);
|
|
111
|
+
const { name: namePart, range: rangePart } = (0, normalize_yarn_pattern_1.normalizeYarnPackagePattern)(packagePattern);
|
|
112
112
|
if (isNonRegistryYarnPackagePattern(rangePart)) {
|
|
113
113
|
return filterMappedDependencies;
|
|
114
114
|
}
|
|
@@ -163,7 +163,7 @@ async function dependenciesFromPackageLock(path, includeDevDependencies) {
|
|
|
163
163
|
const dependencies = filename === YARN_LOCK_FILENAME
|
|
164
164
|
? await parseDependenciesFromYarnLockFile(path)
|
|
165
165
|
: await parseDependenciesFromNpmLockFile(path, includeDevDependencies);
|
|
166
|
-
return dependencies.sort(sortById).filter(uniqueById);
|
|
166
|
+
return dependencies.sort(sortById).filter(uniqueById).filter(isNotLocal);
|
|
167
167
|
}
|
|
168
168
|
exports.dependenciesFromPackageLock = dependenciesFromPackageLock;
|
|
169
169
|
function sortById(a, b) {
|
|
@@ -172,6 +172,14 @@ function sortById(a, b) {
|
|
|
172
172
|
function uniqueById(value, index, values) {
|
|
173
173
|
return values.findIndex(v => v.id === value.id) === index;
|
|
174
174
|
}
|
|
175
|
+
function isNotLocal(dependency) {
|
|
176
|
+
// if the version starts with the url scheme 'file:' that means that
|
|
177
|
+
// the package is fetched from the local filesystem relative to the
|
|
178
|
+
// package-lock that we were passed; it could for instance be a git
|
|
179
|
+
// submodule. this package will not be fetched through the web server
|
|
180
|
+
// that we set up anyway, so don't attempt to synchronize it
|
|
181
|
+
return !dependency.version.startsWith('file:');
|
|
182
|
+
}
|
|
175
183
|
function recurseNpmLockfileDependencies({ dependencies }, includeDevDependencies) {
|
|
176
184
|
if (!dependencies) {
|
|
177
185
|
return [];
|
|
@@ -197,7 +205,7 @@ function filterOutBundledAndDevDependencies([, props]) {
|
|
|
197
205
|
}
|
|
198
206
|
function isDeepEqual(a, b) {
|
|
199
207
|
try {
|
|
200
|
-
assert_1.deepStrictEqual(a, b);
|
|
208
|
+
(0, assert_1.deepStrictEqual)(a, b);
|
|
201
209
|
return true;
|
|
202
210
|
}
|
|
203
211
|
catch (ignored) {
|
package/src/sync.js
CHANGED
|
@@ -5,15 +5,15 @@ const download_1 = require("./download");
|
|
|
5
5
|
const resolve_1 = require("./resolve");
|
|
6
6
|
async function synchronize(options) {
|
|
7
7
|
const cacheFilePath = `${options.rootFolder}/.registry-sync-cache.json`;
|
|
8
|
-
const packages = await resolve_1.dependenciesFromPackageLock(options.manifest, options.includeDevDependencies);
|
|
9
|
-
const newPackages = await resolve_1.dependenciesNotInCache(packages, cacheFilePath, options.prebuiltBinaryProperties);
|
|
8
|
+
const packages = await (0, resolve_1.dependenciesFromPackageLock)(options.manifest, options.includeDevDependencies);
|
|
9
|
+
const newPackages = await (0, resolve_1.dependenciesNotInCache)(packages, cacheFilePath, options.prebuiltBinaryProperties);
|
|
10
10
|
if (options.dryRun) {
|
|
11
11
|
console.log(newPackages.map(({ name, version }) => `${name}@${version}`).join('\n'));
|
|
12
12
|
console.log(`\nWould download ${newPackages.length} packages.`);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
await download_1.downloadAll(newPackages, options);
|
|
16
|
-
await resolve_1.updateDependenciesCache(newPackages, cacheFilePath, options.prebuiltBinaryProperties);
|
|
15
|
+
await (0, download_1.downloadAll)(newPackages, options);
|
|
16
|
+
await (0, resolve_1.updateDependenciesCache)(newPackages, cacheFilePath, options.prebuiltBinaryProperties);
|
|
17
17
|
console.log(`Downloaded ${newPackages.length} packages`);
|
|
18
18
|
}
|
|
19
19
|
return newPackages;
|