node-install-release 0.4.2 → 0.4.5
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.
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
|
-
var match = require('match-semver');
|
|
3
|
-
var find = require('lodash.find');
|
|
4
2
|
var get = require('get-remote');
|
|
5
3
|
|
|
6
4
|
var conditionalCache = require('../conditionalCache');
|
|
7
5
|
var conditionalExtract = require('../conditionalExtract');
|
|
8
|
-
var npmVersions = require('./npmVersions');
|
|
9
6
|
|
|
10
|
-
var
|
|
7
|
+
var NODE_DIST_URL = 'https://nodejs.org/dist/index.json';
|
|
8
|
+
var NPM_DIST_URL = 'https://registry.npmjs.org/npm';
|
|
9
|
+
var NPM_MIN_VERSION = 3;
|
|
11
10
|
|
|
12
11
|
module.exports = function installLib(version, dest, options, callback) {
|
|
13
12
|
var platform = options.platform || process.platform;
|
|
14
|
-
var maximumVersion = find(npmVersions, match.bind(null, version.version)).maximum;
|
|
15
13
|
var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
|
|
16
14
|
var installPath = path.join(libPath, 'node_modules', 'npm');
|
|
17
15
|
|
|
18
|
-
get(
|
|
16
|
+
get(NODE_DIST_URL).json(function (err, res1) {
|
|
19
17
|
if (err) return callback(err);
|
|
18
|
+
var releases = res1.body;
|
|
20
19
|
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
var found = releases.find(function (record) {
|
|
21
|
+
return record.version === version.version;
|
|
22
|
+
});
|
|
23
|
+
var npmMajorPair = found && found.npm ? +found.npm.split('.')[0] : NPM_MIN_VERSION;
|
|
24
|
+
var npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);
|
|
25
|
+
|
|
26
|
+
get(NPM_DIST_URL).json(function (err, res2) {
|
|
25
27
|
if (err) return callback(err);
|
|
26
|
-
|
|
28
|
+
var distTags = res2.body['dist-tags'];
|
|
29
|
+
|
|
30
|
+
var installVersion = distTags['latest-' + npmMajor] || distTags.latest;
|
|
31
|
+
var downloadPath = NPM_DIST_URL + '/-/npm-' + installVersion + '.tgz';
|
|
32
|
+
var cachePath = path.join(options.cacheDirectory, path.basename(downloadPath));
|
|
33
|
+
conditionalCache(downloadPath, cachePath, function (err) {
|
|
34
|
+
if (err) return callback(err);
|
|
35
|
+
conditionalExtract(cachePath, installPath, callback);
|
|
36
|
+
});
|
|
27
37
|
});
|
|
28
38
|
});
|
|
29
39
|
};
|
|
@@ -18,8 +18,11 @@ module.exports = function installCompressed(relativePath, dest, record, options,
|
|
|
18
18
|
console.log('');
|
|
19
19
|
if (err) return callback(err);
|
|
20
20
|
|
|
21
|
-
// some compressed versions of node come with npm pre-installed, but we want to override
|
|
22
|
-
|
|
21
|
+
// some compressed versions of node come with npm pre-installed, but we want to override with a specific version
|
|
22
|
+
var platform = options.platform || process.platform;
|
|
23
|
+
var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
|
|
24
|
+
var installPath = path.join(libPath, 'node_modules', 'npm');
|
|
25
|
+
rimraf(installPath, function () {
|
|
23
26
|
callback(err);
|
|
24
27
|
});
|
|
25
28
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-install-release",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Cross-platform solution for installing releases of Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"isarray": "^2.0.5",
|
|
45
45
|
"lodash.find": "^4.6.0",
|
|
46
46
|
"lodash.keys": "^4.2.0",
|
|
47
|
-
"match-semver": "^0.1.1",
|
|
48
47
|
"mkpath": "^1.0.0",
|
|
49
48
|
"node-filename-to-dist-paths": "^0.2.1",
|
|
50
49
|
"node-resolve-versions": "^0.3.9",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = [
|
|
2
|
-
{ gte: '10.0.0', bundled: '6.14.4' },
|
|
3
|
-
{ gte: '8.0.0', lt: '10.0.0', bundled: '6.13.4' },
|
|
4
|
-
{ gte: '6.0.0', lt: '8.0.0', bundled: '3.10.10' },
|
|
5
|
-
{ gte: '4.0.0', lt: '6.0.0', bundled: '2.15.11', maximum: 5 },
|
|
6
|
-
{ gte: '0.12.0', lt: '4.0.0', bundled: '2.15.11', maximum: 3 },
|
|
7
|
-
{ lt: '0.12.0', bundled: '1.2.30', maximum: 3 },
|
|
8
|
-
];
|