node-install-release 0.4.6 → 0.4.8
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/dist/cjs/arch.js +67 -0
- package/dist/cjs/arch.js.map +1 -0
- package/dist/cjs/checkMissing.js +48 -0
- package/dist/cjs/checkMissing.js.map +1 -0
- package/dist/cjs/conditionalCache.js +34 -0
- package/dist/cjs/conditionalCache.js.map +1 -0
- package/dist/cjs/conditionalCopy.js +27 -0
- package/dist/cjs/conditionalCopy.js.map +1 -0
- package/dist/cjs/conditionalExtract.js +33 -0
- package/dist/cjs/conditionalExtract.js.map +1 -0
- package/dist/cjs/copyFile.js +30 -0
- package/dist/cjs/copyFile.js.map +1 -0
- package/dist/cjs/endsWithFn.js +20 -0
- package/dist/cjs/endsWithFn.js.map +1 -0
- package/dist/cjs/ensureDestinationParent.js +16 -0
- package/dist/cjs/ensureDestinationParent.js.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/install.js +53 -0
- package/dist/cjs/install.js.map +1 -0
- package/dist/cjs/installNPM/index.js +15 -0
- package/dist/cjs/installNPM/index.js.map +1 -0
- package/dist/cjs/installNPM/installBin.js +55 -0
- package/dist/cjs/installNPM/installBin.js.map +1 -0
- package/dist/cjs/installNPM/installLib.js +40 -0
- package/dist/cjs/installNPM/installLib.js.map +1 -0
- package/dist/cjs/installNode/filenames.js +41 -0
- package/dist/cjs/installNode/filenames.js.map +1 -0
- package/dist/cjs/installNode/findDistPaths.js +25 -0
- package/dist/cjs/installNode/findDistPaths.js.map +1 -0
- package/dist/cjs/installNode/index.js +31 -0
- package/dist/cjs/installNode/index.js.map +1 -0
- package/dist/cjs/installNode/installCompressed.js +38 -0
- package/dist/cjs/installNode/installCompressed.js.map +1 -0
- package/dist/cjs/installNode/installExe.js +23 -0
- package/dist/cjs/installNode/installExe.js.map +1 -0
- package/dist/cjs/installNode/installSource/buildPosix.js +35 -0
- package/dist/cjs/installNode/installSource/buildPosix.js.map +1 -0
- package/dist/cjs/installNode/installSource/buildWin32.js +31 -0
- package/dist/cjs/installNode/installSource/buildWin32.js.map +1 -0
- package/dist/cjs/installNode/installSource/index.js +27 -0
- package/dist/cjs/installNode/installSource/index.js.map +1 -0
- package/dist/cjs/installVersion.js +27 -0
- package/dist/cjs/installVersion.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/polyfills/execCallback.js +11 -0
- package/dist/cjs/polyfills/execCallback.js.map +1 -0
- package/dist/cjs/polyfills/index.js +21 -0
- package/dist/cjs/polyfills/index.js.map +1 -0
- package/dist/cjs/progress.js +13 -0
- package/dist/cjs/progress.js.map +1 -0
- package/dist/types/arch.d.ts +2 -0
- package/dist/types/buildPosix.d.ts +2 -0
- package/dist/types/checkMissing.d.ts +2 -0
- package/dist/types/conditionalCache.d.ts +2 -0
- package/dist/types/conditionalCopy.d.ts +2 -0
- package/dist/types/conditionalExtract.d.ts +2 -0
- package/dist/types/copyFile.d.ts +2 -0
- package/dist/types/endsWithFn.d.ts +2 -0
- package/dist/types/ensureDestinationParent.d.ts +2 -0
- package/dist/types/execCallback.d.ts +4 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/install.d.ts +2 -0
- package/dist/types/installNPM/index.d.ts +2 -0
- package/dist/types/installNPM/installBin.d.ts +2 -0
- package/dist/types/installNPM/installLib.d.ts +2 -0
- package/dist/types/installNode/filenames.d.ts +2 -0
- package/dist/types/installNode/findDistPaths.d.ts +6 -0
- package/dist/types/installNode/index.d.ts +2 -0
- package/dist/types/installNode/installCompressed.d.ts +2 -0
- package/dist/types/installNode/installExe.d.ts +2 -0
- package/dist/types/installNode/installSource/buildPosix.d.ts +2 -0
- package/dist/types/installNode/installSource/buildWin32.d.ts +2 -0
- package/dist/types/installNode/installSource/index.d.ts +2 -0
- package/dist/types/installVersion.d.ts +2 -0
- package/dist/types/polyfills/index.d.ts +1 -0
- package/dist/types/progress.d.ts +2 -0
- package/package.json +27 -24
- package/lib/arch.js +0 -72
- package/lib/checkMissing.js +0 -36
- package/lib/conditionalCache.js +0 -28
- package/lib/conditionalCopy.js +0 -25
- package/lib/conditionalExtract.js +0 -27
- package/lib/copyFile.js +0 -28
- package/lib/endsWithFn.js +0 -12
- package/lib/ensureDestinationParent.js +0 -10
- package/lib/index.js +0 -19
- package/lib/install.js +0 -45
- package/lib/installNPM/index.js +0 -9
- package/lib/installNPM/installBin.js +0 -31
- package/lib/installNPM/installLib.js +0 -39
- package/lib/installNode/filenames.js +0 -31
- package/lib/installNode/findDistPaths.js +0 -13
- package/lib/installNode/index.js +0 -25
- package/lib/installNode/installCompressed.js +0 -31
- package/lib/installNode/installExe.js +0 -19
- package/lib/installNode/installSource/buildPosix.js +0 -21
- package/lib/installNode/installSource/buildWin32.js +0 -25
- package/lib/installNode/installSource/index.js +0 -21
- package/lib/installVersion.js +0 -24
- package/lib/polyfills/execCallback.js +0 -5
- package/lib/polyfills/index.js +0 -15
- package/lib/progress.js +0 -7
package/lib/arch.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// Inline until merged: https://github.com/jakejarvis/arch/blob/detect-arm/index.js
|
|
2
|
-
|
|
3
|
-
/*! arch. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
|
-
var cp = require('child_process');
|
|
5
|
-
var fs = require('fs');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns the operating system's CPU architecture. This is different than
|
|
10
|
-
* `process.arch` or `os.arch()` which returns the architecture the Node.js (or
|
|
11
|
-
* Electron) binary was compiled for.
|
|
12
|
-
*/
|
|
13
|
-
module.exports = function arch() {
|
|
14
|
-
/**
|
|
15
|
-
* On macOS, we need to detect if x64 Node is running because the CPU is truly
|
|
16
|
-
* an Intel chip, or if it's running on Apple Silicon via Rosetta 2:
|
|
17
|
-
* https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment
|
|
18
|
-
*/
|
|
19
|
-
if (process.platform === 'darwin') {
|
|
20
|
-
var nativeArm = process.arch === 'arm64';
|
|
21
|
-
var rosettaArm = cp.execSync('sysctl -in sysctl.proc_translated', { encoding: 'utf8' }) === '1\n';
|
|
22
|
-
|
|
23
|
-
return nativeArm || rosettaArm ? 'arm64' : 'x64';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* On Windows, the most reliable way to detect a 64-bit OS from within a 32-bit
|
|
28
|
-
* app is based on the presence of a WOW64 file: %SystemRoot%\SysNative.
|
|
29
|
-
* See: https://twitter.com/feross/status/776949077208510464
|
|
30
|
-
*/
|
|
31
|
-
if (process.platform === 'win32') {
|
|
32
|
-
var useEnv = false;
|
|
33
|
-
try {
|
|
34
|
-
useEnv = !!(process.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT));
|
|
35
|
-
} catch (err) {}
|
|
36
|
-
|
|
37
|
-
var sysRoot = useEnv ? process.env.SYSTEMROOT : 'C:\\Windows';
|
|
38
|
-
|
|
39
|
-
// If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application.
|
|
40
|
-
var isWOW64 = false;
|
|
41
|
-
try {
|
|
42
|
-
isWOW64 = !!fs.statSync(path.join(sysRoot, 'sysnative'));
|
|
43
|
-
} catch (err) {}
|
|
44
|
-
|
|
45
|
-
return isWOW64 ? 'x64' : 'x86';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* On Linux, use the `getconf` command to get the architecture.
|
|
50
|
-
*/
|
|
51
|
-
if (process.platform === 'linux') {
|
|
52
|
-
try {
|
|
53
|
-
var output1 = cp.execSync('uname -a', { encoding: 'utf8' });
|
|
54
|
-
if (~output1.indexOf('raspberrypi')) return 'arm-pi';
|
|
55
|
-
} catch (err) {}
|
|
56
|
-
|
|
57
|
-
var output = cp.execSync('getconf LONG_BIT', { encoding: 'utf8' });
|
|
58
|
-
return output === '64\n' ? 'x64' : 'x86';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The running binary is 64-bit, so the OS is clearly 64-bit.
|
|
63
|
-
*/
|
|
64
|
-
if (process.arch === 'x64') {
|
|
65
|
-
return 'x64';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* If none of the above, assume the architecture is 32-bit.
|
|
70
|
-
*/
|
|
71
|
-
return 'x86';
|
|
72
|
-
};
|
package/lib/checkMissing.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var keys = require('lodash.keys');
|
|
4
|
-
|
|
5
|
-
var PLATFORM_FILES = {
|
|
6
|
-
win32: {
|
|
7
|
-
node: ['node.exe'],
|
|
8
|
-
npm: ['npm', 'npm.cmd'],
|
|
9
|
-
},
|
|
10
|
-
posix: {
|
|
11
|
-
node: ['node'],
|
|
12
|
-
npm: ['npm'],
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = function checkMissing(dest, options, callback) {
|
|
17
|
-
var platform = options.platform || process.platform;
|
|
18
|
-
var files = PLATFORM_FILES[platform] || PLATFORM_FILES.posix;
|
|
19
|
-
var binPath = platform === 'win32' ? dest : path.join(dest, 'bin');
|
|
20
|
-
|
|
21
|
-
fs.readdir(binPath, function (err, names) {
|
|
22
|
-
if (err || !names.length) return callback(null, keys(files));
|
|
23
|
-
|
|
24
|
-
var missing = [];
|
|
25
|
-
for (var key in files) {
|
|
26
|
-
var needed = files[key];
|
|
27
|
-
for (var index = 0; index < needed.length; index++) {
|
|
28
|
-
if (!~names.indexOf(needed[index])) {
|
|
29
|
-
missing.push(key);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return callback(null, missing);
|
|
35
|
-
});
|
|
36
|
-
};
|
package/lib/conditionalCache.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var get = require('get-remote');
|
|
3
|
-
var access = require('fs-access-compat');
|
|
4
|
-
|
|
5
|
-
var progress = require('./progress');
|
|
6
|
-
var ensureDestinationParent = require('./ensureDestinationParent');
|
|
7
|
-
|
|
8
|
-
module.exports = function conditionalCache(endpoint, dest, options, callback) {
|
|
9
|
-
if (typeof options === 'function') {
|
|
10
|
-
callback = options;
|
|
11
|
-
options = null;
|
|
12
|
-
}
|
|
13
|
-
options = options || {};
|
|
14
|
-
|
|
15
|
-
access(dest, function (err) {
|
|
16
|
-
if (!err) return callback(); // already exists
|
|
17
|
-
|
|
18
|
-
ensureDestinationParent(dest, function (err) {
|
|
19
|
-
if (err) return callback(err);
|
|
20
|
-
|
|
21
|
-
// TODO: do I need assign?
|
|
22
|
-
get(endpoint, Object.assign({ filename: path.basename(dest), progress: progress, time: 1000 }, options)).file(path.dirname(dest), function (err) {
|
|
23
|
-
console.log('');
|
|
24
|
-
callback(err);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
};
|
package/lib/conditionalCopy.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var access = require('fs-access-compat');
|
|
2
|
-
|
|
3
|
-
var copyFile = require('./copyFile');
|
|
4
|
-
var ensureDestinationParent = require('./ensureDestinationParent');
|
|
5
|
-
|
|
6
|
-
module.exports = function conditionalCopy(src, dest, optional, callback) {
|
|
7
|
-
if (typeof optional === 'function') {
|
|
8
|
-
callback = optional;
|
|
9
|
-
optional = false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
access(dest, function (err) {
|
|
13
|
-
if (!err) return callback(); // already exists
|
|
14
|
-
|
|
15
|
-
ensureDestinationParent(dest, function (err) {
|
|
16
|
-
if (err) return callback(err);
|
|
17
|
-
if (!optional) return copyFile(src, dest, callback);
|
|
18
|
-
|
|
19
|
-
access(src, function (err) {
|
|
20
|
-
if (err) return callback(); // optional file missing
|
|
21
|
-
copyFile(src, dest, callback);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var extract = require('fast-extract');
|
|
3
|
-
var mkpath = require('mkpath');
|
|
4
|
-
var access = require('fs-access-compat');
|
|
5
|
-
|
|
6
|
-
var progress = require('./progress');
|
|
7
|
-
|
|
8
|
-
module.exports = function conditionalExtract(src, dest, options, callback) {
|
|
9
|
-
if (typeof options === 'function') {
|
|
10
|
-
callback = options;
|
|
11
|
-
options = null;
|
|
12
|
-
}
|
|
13
|
-
options = options || {};
|
|
14
|
-
|
|
15
|
-
access(dest, function (err) {
|
|
16
|
-
if (!err) return callback(); // already exists
|
|
17
|
-
|
|
18
|
-
mkpath(path.dirname(dest), function () {
|
|
19
|
-
var extractOptions = Object.assign({ strip: 1, progress: progress, time: 1000 }, options);
|
|
20
|
-
|
|
21
|
-
extract(src, dest, extractOptions, function (err) {
|
|
22
|
-
console.log('');
|
|
23
|
-
callback(err);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
};
|
package/lib/copyFile.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
var rimraf = require('rimraf');
|
|
3
|
-
var pump = require('pump');
|
|
4
|
-
var Queue = require('queue-cb');
|
|
5
|
-
|
|
6
|
-
var ensureDestinationParent = require('./ensureDestinationParent');
|
|
7
|
-
|
|
8
|
-
function streamCopyFile(src, dest, callback) {
|
|
9
|
-
fs.stat(src, function (err) {
|
|
10
|
-
if (err) return callback(err);
|
|
11
|
-
pump(fs.createReadStream(src), fs.createWriteStream(dest), callback);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var copyFile = fs.copyFile || streamCopyFile;
|
|
16
|
-
|
|
17
|
-
module.exports = function safeCopyFile(src, dest, callback) {
|
|
18
|
-
var queue = new Queue(1);
|
|
19
|
-
|
|
20
|
-
queue.defer(ensureDestinationParent.bind(null, dest));
|
|
21
|
-
queue.defer(function (callback) {
|
|
22
|
-
rimraf(dest, function (err) {
|
|
23
|
-
err && err.code !== 'EEXIST' ? callback(err) : callback();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
queue.defer(copyFile.bind(null, src, dest));
|
|
27
|
-
queue.await(callback);
|
|
28
|
-
};
|
package/lib/endsWithFn.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var isArray = require('isarray');
|
|
2
|
-
var endsWith = require('end-with');
|
|
3
|
-
|
|
4
|
-
module.exports = function endsWithFn(endings) {
|
|
5
|
-
if (!isArray(endings)) endings = [endings];
|
|
6
|
-
return function (string) {
|
|
7
|
-
for (var index = 0; index < endings.length; index++) {
|
|
8
|
-
if (endsWith(string, endings[index])) return true;
|
|
9
|
-
}
|
|
10
|
-
return false;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var mkpath = require('mkpath');
|
|
3
|
-
|
|
4
|
-
module.exports = function ensureDestinationParent(dest, callback) {
|
|
5
|
-
var parent = path.dirname(dest);
|
|
6
|
-
if (parent === '.' || parent === '/') return callback();
|
|
7
|
-
mkpath(parent, function (err) {
|
|
8
|
-
callback(err);
|
|
9
|
-
});
|
|
10
|
-
};
|
package/lib/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require('./polyfills');
|
|
2
|
-
var install = require('./install');
|
|
3
|
-
|
|
4
|
-
function installRelease(versionDetails, dest, options, callback) {
|
|
5
|
-
if (typeof options === 'function') {
|
|
6
|
-
callback = options;
|
|
7
|
-
options = null;
|
|
8
|
-
}
|
|
9
|
-
options = options || {};
|
|
10
|
-
|
|
11
|
-
if (typeof callback === 'function') return install(versionDetails, dest, options, callback);
|
|
12
|
-
return new Promise(function (resolve, reject) {
|
|
13
|
-
installRelease(versionDetails, dest, options, function installCallback(err, result) {
|
|
14
|
-
err ? reject(err) : resolve(result);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = installRelease;
|
package/lib/install.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var Queue = require('queue-cb');
|
|
3
|
-
var mkpath = require('mkpath');
|
|
4
|
-
|
|
5
|
-
var resolveVersions = require('node-resolve-versions');
|
|
6
|
-
|
|
7
|
-
var installVersion = require('./installVersion');
|
|
8
|
-
|
|
9
|
-
var NIR_DIR = path.join(require('osenv').home(), '.nir');
|
|
10
|
-
var DEFAULT_OPTIONS = {
|
|
11
|
-
cacheDirectory: path.join(NIR_DIR, 'cache'),
|
|
12
|
-
buildDirectory: path.join(NIR_DIR, 'build'),
|
|
13
|
-
downloadURL: function downloadURL(relativePath) {
|
|
14
|
-
return 'https://nodejs.org/dist/' + relativePath;
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
module.exports = function install(versionDetails, dest, options, callback) {
|
|
19
|
-
options = Object.assign({}, DEFAULT_OPTIONS, options, { path: 'raw' });
|
|
20
|
-
resolveVersions(versionDetails, options, function (err, versions) {
|
|
21
|
-
if (err) return callback(err);
|
|
22
|
-
if (!versions.length) return callback(new Error('Could not resolve versions for: ' + JSON.stringify(versionDetails)));
|
|
23
|
-
|
|
24
|
-
var results = [];
|
|
25
|
-
var queue = new Queue(1);
|
|
26
|
-
queue.defer(function (callback) {
|
|
27
|
-
mkpath(options.cacheDirectory, callback.bind(null, null));
|
|
28
|
-
});
|
|
29
|
-
for (var index = 0; index < versions.length; index++) {
|
|
30
|
-
(function (version) {
|
|
31
|
-
queue.defer(function (callback) {
|
|
32
|
-
var installDirectory = dest && versions.length > 1 ? path.join(dest, version.version) : dest;
|
|
33
|
-
installVersion(version, installDirectory, options, function (err, fullPath) {
|
|
34
|
-
if (err) return callback(err);
|
|
35
|
-
results.push({ version: version.version, error: err, fullPath: fullPath });
|
|
36
|
-
callback();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
})(versions[index]);
|
|
40
|
-
}
|
|
41
|
-
queue.await(function (err) {
|
|
42
|
-
err ? callback(err) : callback(null, results);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
};
|
package/lib/installNPM/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var installBin = require('./installBin');
|
|
2
|
-
var installLib = require('./installLib');
|
|
3
|
-
|
|
4
|
-
module.exports = function install(version, dest, options, callback) {
|
|
5
|
-
installLib(version, dest, options, function (err) {
|
|
6
|
-
if (err) return callback(err);
|
|
7
|
-
installBin(version, dest, options, callback);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var Queue = require('queue-cb');
|
|
3
|
-
var conditionalCopy = require('../conditionalCopy');
|
|
4
|
-
|
|
5
|
-
var PLATFORM_FILES = {
|
|
6
|
-
win32: [
|
|
7
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npm'), dest: 'npm' },
|
|
8
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npm.cmd'), dest: 'npm.cmd' },
|
|
9
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npx'), dest: 'npx', optional: true },
|
|
10
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npx.cmd'), dest: 'npx.cmd', optional: true },
|
|
11
|
-
],
|
|
12
|
-
posix: [
|
|
13
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npm-cli.js'), dest: 'npm' },
|
|
14
|
-
{ src: path.join('node_modules', 'npm', 'bin', 'npx-cli.js'), dest: 'npx', optional: true },
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
module.exports = function installBin(version, dest, options, callback) {
|
|
19
|
-
var platform = options.platform || process.platform;
|
|
20
|
-
var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
|
|
21
|
-
var binPath = platform === 'win32' ? dest : path.join(dest, 'bin');
|
|
22
|
-
|
|
23
|
-
var queue = new Queue();
|
|
24
|
-
var files = PLATFORM_FILES[platform] || PLATFORM_FILES.posix;
|
|
25
|
-
for (var index = 0; index < files.length; index++) {
|
|
26
|
-
var file = files[index];
|
|
27
|
-
queue.defer(conditionalCopy.bind(null, path.join(libPath, file.src), path.join(binPath, file.dest), file.optional));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
queue.await(callback);
|
|
31
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var get = require('get-remote');
|
|
3
|
-
|
|
4
|
-
var conditionalCache = require('../conditionalCache');
|
|
5
|
-
var conditionalExtract = require('../conditionalExtract');
|
|
6
|
-
|
|
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;
|
|
10
|
-
|
|
11
|
-
module.exports = function installLib(version, dest, options, callback) {
|
|
12
|
-
var platform = options.platform || process.platform;
|
|
13
|
-
var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
|
|
14
|
-
var installPath = path.join(libPath, 'node_modules', 'npm');
|
|
15
|
-
|
|
16
|
-
get(NODE_DIST_URL).json(function (err, res1) {
|
|
17
|
-
if (err) return callback(err);
|
|
18
|
-
var releases = res1.body;
|
|
19
|
-
|
|
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) {
|
|
27
|
-
if (err) return callback(err);
|
|
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
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var osArch = require('os').arch || require('../arch');
|
|
2
|
-
|
|
3
|
-
var PLATFORM_OS = {
|
|
4
|
-
win32: 'win',
|
|
5
|
-
darwin: 'osx',
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
var PLATFORM_FILES = {
|
|
9
|
-
win32: ['zip', 'exe'],
|
|
10
|
-
darwin: ['tar'],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
module.exports = function prebuiltFilenames(options) {
|
|
14
|
-
var platform = options.platform || process.platform;
|
|
15
|
-
var os = PLATFORM_OS[platform] || platform;
|
|
16
|
-
var archs = [options.arch || osArch()];
|
|
17
|
-
if (platform === 'darwin' && archs[0] === 'arm64') archs.push('x64'); // fallback
|
|
18
|
-
|
|
19
|
-
var files = PLATFORM_FILES[platform];
|
|
20
|
-
var results = [];
|
|
21
|
-
for (var i = 0; i < archs.length; i++) {
|
|
22
|
-
if (typeof files === 'undefined') {
|
|
23
|
-
results.push(os + '-' + archs[i]);
|
|
24
|
-
} else {
|
|
25
|
-
for (var j = 0; j < files.length; j++) {
|
|
26
|
-
results.push(os + '-' + archs[i] + '-' + files[j]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return results;
|
|
31
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var distPaths = require('node-filename-to-dist-paths');
|
|
2
|
-
var prebuiltFilenames = require('./filenames');
|
|
3
|
-
|
|
4
|
-
module.exports = function findDistPaths(version, options) {
|
|
5
|
-
var filenames = options.filename ? [options.filename] : prebuiltFilenames(options);
|
|
6
|
-
for (var index = 0; index < filenames.length; index++) {
|
|
7
|
-
var filename = filenames[index];
|
|
8
|
-
if (!~version.files.indexOf(filename)) continue;
|
|
9
|
-
var relativePaths = distPaths(filename, version.version);
|
|
10
|
-
if (relativePaths && relativePaths.length) return { version: version.version, filename: filename, relativePaths: relativePaths };
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
13
|
-
};
|
package/lib/installNode/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var find = require('lodash.find');
|
|
2
|
-
|
|
3
|
-
var endsWithFn = require('../endsWithFn');
|
|
4
|
-
var findDistPaths = require('./findDistPaths');
|
|
5
|
-
var installCompressed = require('./installCompressed');
|
|
6
|
-
var installExe = require('./installExe');
|
|
7
|
-
var installSource = require('./installSource');
|
|
8
|
-
|
|
9
|
-
module.exports = function install(version, dest, options, callback) {
|
|
10
|
-
var record = findDistPaths(version, options);
|
|
11
|
-
if (record) {
|
|
12
|
-
if (record.filename === 'src') return installSource(record.relativePaths[0], dest, record, options, callback);
|
|
13
|
-
|
|
14
|
-
var relativePath = find(record.relativePaths, endsWithFn(['.tar.gz', '.zip']));
|
|
15
|
-
if (relativePath) return installCompressed(relativePath, dest, record, options, callback);
|
|
16
|
-
|
|
17
|
-
relativePath = find(record.relativePaths, endsWithFn('.exe'));
|
|
18
|
-
if (relativePath) return installExe(relativePath, dest, record, options, callback);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
record = findDistPaths(version, { filename: 'src' });
|
|
22
|
-
if (record && record.relativePaths.length) return installSource(record.relativePaths[0], dest, record, options, callback);
|
|
23
|
-
|
|
24
|
-
callback(new Error('Unable to install ' + version));
|
|
25
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var access = require('fs-access-compat');
|
|
3
|
-
var rimraf = require('rimraf');
|
|
4
|
-
|
|
5
|
-
var conditionalCache = require('../conditionalCache');
|
|
6
|
-
var conditionalExtract = require('../conditionalExtract');
|
|
7
|
-
var progress = require('../progress');
|
|
8
|
-
|
|
9
|
-
module.exports = function installCompressed(relativePath, dest, record, options, callback) {
|
|
10
|
-
var downloadPath = options.downloadURL(relativePath);
|
|
11
|
-
var cachePath = path.join(options.cacheDirectory, path.basename(downloadPath));
|
|
12
|
-
|
|
13
|
-
conditionalCache(downloadPath, cachePath, function (err) {
|
|
14
|
-
if (err) return callback(err);
|
|
15
|
-
access(dest, function (err) {
|
|
16
|
-
if (!err) return callback(); // already exists
|
|
17
|
-
conditionalExtract(cachePath, dest, Object.assign({ strip: 1, progress: progress, time: 1000 }, options), function (err) {
|
|
18
|
-
console.log('');
|
|
19
|
-
if (err) return callback(err);
|
|
20
|
-
|
|
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 () {
|
|
26
|
-
callback(err);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var access = require('fs-access-compat');
|
|
3
|
-
|
|
4
|
-
var conditionalCache = require('../conditionalCache');
|
|
5
|
-
var copyFile = require('../copyFile');
|
|
6
|
-
|
|
7
|
-
module.exports = function installExe(relativePath, dest, record, options, callback) {
|
|
8
|
-
var downloadPath = options.downloadURL(relativePath);
|
|
9
|
-
var cachePath = path.join(options.cacheDirectory, 'node' + '-' + record.version + '.exe');
|
|
10
|
-
var destPath = path.join(dest, path.basename(relativePath));
|
|
11
|
-
|
|
12
|
-
access(destPath, function (err) {
|
|
13
|
-
if (!err) return callback(); // already exists
|
|
14
|
-
conditionalCache(downloadPath, cachePath, function (err) {
|
|
15
|
-
if (err) return callback(err);
|
|
16
|
-
copyFile(cachePath, destPath, callback);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var spawn = require('cross-spawn-cb');
|
|
3
|
-
var Queue = require('queue-cb');
|
|
4
|
-
var access = require('fs-access-compat');
|
|
5
|
-
|
|
6
|
-
module.exports = function installDefault(buildPath, dest, options, callback) {
|
|
7
|
-
var buildTarget = path.join(dest, 'node');
|
|
8
|
-
|
|
9
|
-
access(buildTarget, function (err) {
|
|
10
|
-
if (!err) return callback(); // already exists
|
|
11
|
-
|
|
12
|
-
var queue = new Queue(1);
|
|
13
|
-
queue.defer(function (callback) {
|
|
14
|
-
spawn('./configure', ['--prefix=' + dest], { stdio: 'inherit', cwd: buildPath }, callback);
|
|
15
|
-
});
|
|
16
|
-
queue.defer(function (callback) {
|
|
17
|
-
spawn('make', ['install'], { stdio: 'inherit', cwd: buildPath }, callback);
|
|
18
|
-
});
|
|
19
|
-
queue.await(callback);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var spawn = require('cross-spawn-cb');
|
|
3
|
-
var Queue = require('queue-cb');
|
|
4
|
-
|
|
5
|
-
var access = require('fs-access-compat');
|
|
6
|
-
var conditionalCopy = require('../../conditionalCopy');
|
|
7
|
-
|
|
8
|
-
module.exports = function installWin32(buildPath, dest, options, callback) {
|
|
9
|
-
var buildSource = path.join(buildPath, 'out', 'Release', 'node.exe');
|
|
10
|
-
var buildTarget = path.join(dest, 'node.exe');
|
|
11
|
-
|
|
12
|
-
access(buildTarget, function (err) {
|
|
13
|
-
if (!err) return callback(); // already exists
|
|
14
|
-
|
|
15
|
-
var queue = new Queue(1);
|
|
16
|
-
queue.defer(function (callback) {
|
|
17
|
-
access(buildSource, function (err) {
|
|
18
|
-
if (!err) return callback(); // already exists
|
|
19
|
-
spawn('./vcbuild', [], { stdio: 'inherit', cwd: buildPath }, callback);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
queue.defer(conditionalCopy.bind(null, buildSource, buildTarget));
|
|
23
|
-
queue.await(callback);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var Queue = require('queue-cb');
|
|
3
|
-
|
|
4
|
-
var conditionalCache = require('../../conditionalCache');
|
|
5
|
-
var conditionalExtract = require('../../conditionalExtract');
|
|
6
|
-
var buildPosix = require('./buildPosix');
|
|
7
|
-
var buildWin32 = require('./buildWin32');
|
|
8
|
-
|
|
9
|
-
module.exports = function InstallSource(relativePath, dest, record, options, callback) {
|
|
10
|
-
var platform = options.platform || process.platform;
|
|
11
|
-
var build = platform === 'win32' ? buildWin32 : buildPosix;
|
|
12
|
-
var downloadPath = options.downloadURL(relativePath);
|
|
13
|
-
var buildPath = path.join(options.buildDirectory, path.basename(relativePath));
|
|
14
|
-
var cachePath = path.join(options.cacheDirectory, path.basename(downloadPath));
|
|
15
|
-
|
|
16
|
-
var queue = new Queue(1);
|
|
17
|
-
queue.defer(conditionalCache.bind(null, downloadPath, cachePath));
|
|
18
|
-
queue.defer(conditionalExtract.bind(null, cachePath, buildPath, { strip: 1 }));
|
|
19
|
-
queue.defer(build.bind(null, buildPath, dest, options));
|
|
20
|
-
queue.await(callback);
|
|
21
|
-
};
|
package/lib/installVersion.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
var Queue = require('queue-cb');
|
|
3
|
-
|
|
4
|
-
var installNode = require('./installNode');
|
|
5
|
-
var installNPM = require('./installNPM');
|
|
6
|
-
var checkMissing = require('./checkMissing');
|
|
7
|
-
var ensureDestinationParent = require('./ensureDestinationParent');
|
|
8
|
-
|
|
9
|
-
module.exports = function install(version, dest, options, callback) {
|
|
10
|
-
// use cwd if dest not provided
|
|
11
|
-
if (!dest) dest = path.join(process.cwd(), version.version);
|
|
12
|
-
|
|
13
|
-
checkMissing(dest, options, function (err, missing) {
|
|
14
|
-
if (err || !missing.length) return callback(err, dest);
|
|
15
|
-
|
|
16
|
-
var queue = new Queue(1);
|
|
17
|
-
queue.defer(ensureDestinationParent.bind(null, dest));
|
|
18
|
-
!~missing.indexOf('node') || queue.defer(installNode.bind(null, version, dest, options));
|
|
19
|
-
!~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, dest, options));
|
|
20
|
-
queue.await(function (err) {
|
|
21
|
-
err ? callback(err) : callback(null, dest);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
};
|
package/lib/polyfills/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require('core-js/actual/object/assign');
|
|
2
|
-
require('core-js/actual/promise');
|
|
3
|
-
|
|
4
|
-
var cp = require('child_process');
|
|
5
|
-
if (!cp.execSync) {
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var execCallback = path.join(__dirname, 'execCallback.js');
|
|
8
|
-
|
|
9
|
-
var functionExec = null; // break dependencies
|
|
10
|
-
cp.execSync = function execSyncPolyfill(cmd, options) {
|
|
11
|
-
if (!functionExec) functionExec = require('function-exec-sync');
|
|
12
|
-
|
|
13
|
-
return functionExec({ callbacks: true }, execCallback, cmd, options || {});
|
|
14
|
-
};
|
|
15
|
-
}
|
package/lib/progress.js
DELETED