mirror of
https://github.com/docker/docs.git
synced 2026-11-06 12:54:24 +03:00
- For now changes in SetupStore are made, to skip steps that do MacOS setup. - Adding deps.ps1 script for installing all required dependencies on windows. - Adding reset.ps1 script for removing all dependencies on windows. - Modifying files to work with windows dependencies - Fix for duplicate react instances in the code. - A fix required to load only one instance of React in the application. Without such fix, on windows application loads two instances of React at start time, and crashes. - Modifying files to support windows paths - Modifying deps and reset powershell scripts to loose chocolatey dependency. Adding windows VirtualBox installation steps. - Improved a workaround for adding Users directory to the shared folder in the VM on windows. Added few more fixes for Windows/Mac compatibility. - Removing unnecessary log from deps.ps1 script, - Updating Gulpfile to download and copy all the dependencies on application start, - Cleaning pre and post install scripts from package.json, as they are not realy friendly for different platforms. - Removing changes from browser.js as they were not necessary or even breaking. - Cleaning pre and post install scripts from package.json, as they are not really friendly for different platforms. - Fixing changes in package.json. - Fixed reset.ps1 file to delete all folders created by the app, - Fixed metrics.js file to properly use userAgent depending on the OS. - Uncommented updateBinaries line in SetupStore. - Adding open as a dependency. - Fixing the setupStore tests. - Adding proper directory to PATH for docker and docker-machine binaries. - Adding support for the docker terminal command. It opens a CMD on windows and sets required env variables for the docker to work. Docker and Docker-Machine should be on the path, as they are set up there on Kitematic startup. - Added Resources module which provides paths to all files stored in the resources directory, - Added docker and docker-machine binary paths to Util module, to have a single place for calling those paths, - Added binaries directory path, to Util module, to have a single place for calling this path, - Added another exec command, which utilizes "child_process" module, and it's "exec" command, as the "exec" used right now is deprecated, - Refactored the Installation step in the SetupStore, and connected with that SetupUtil commands to perform copying binaries from node instead of bash commands. That way application is more cross-platform friendly, - Added new dependencies in form of fs-extra, fs-promise and any-promise, to allow yielding of fs commands in SetupUtil. - The setup process now works correctly on windows from the beginning to end. - Fixing broken tests. - Improving tests. - Adding elevated permissions to the reset script, as it is required to kill processes and remove VirtualBox. - Added ability to run reset scripts through gulp, - Added new npm script for resetting the environment "npm run reset". - Refactored docker-machine module, to use Resources module for finding the machine command and general code cleaning, - Added windows keyboard shortcut support. - Adding the use of Resources module, instead of direct access of files in the resources dir. - Testing appveyor. - Testing appveyor + io.js. - Back to node 0.10. - Fixing permission issues with appveyor. - Testing travis. Signed-off-by: Dominik Deren <dominik.deren@live.com> - Working on changes required to setup client on windows. - For now changes in SetupStore are made, to skip steps that do MacOS setup. - Adding deps.ps1 script for installing all required dependencies on windows. - Adding reset.ps1 script for removing all dependencies on windows. Fix for duplicate react instances in the code. Modifying files to support windows paths - Removing unnecessary log from deps.ps1 script, - Updating Gulpfile to download and copy all the dependencies on application start, - Cleaning pre and post install scripts from package.json, as they are not realy friendly for different platforms. - Removing changes from browser.js as they were not necessary or even breaking. - Fixing changes in package.json. - Uncommented updateBinaries line in SetupStore. - Adding open as a dependency. - Adding proper directory to PATH for docker and docker-machine binaries. - Fixing broken tests. - Improving tests. - Adding elevated permissions to the reset script, as it is required to kill processes and remove VirtualBox. - Added ability to run reset scripts through gulp, - Added new npm script for resetting the environment "npm run reset". - Refactored docker-machine module, to use Resources module for finding the machine command and general code cleaning, - Added windows keyboard shortcut support. - Adding the use of Resources module, instead of direct access of files in the resources dir. - Testing appveyor + io.js. - Back to node 0.10. - Fixing permission issues with appveyor. Signed-off-by: Dominik Deren <dominik.deren@live.com>
159 lines
5.1 KiB
JavaScript
159 lines
5.1 KiB
JavaScript
var _ = require('underscore');
|
|
var crypto = require('crypto');
|
|
var fs = require('fs-promise');
|
|
var path = require('path');
|
|
var request = require('request');
|
|
var progress = require('request-progress');
|
|
var Promise = require('bluebird');
|
|
var util = require('./Util');
|
|
var resources = require('./Resources');
|
|
|
|
var SetupUtil = {
|
|
needsBinaryFix() {
|
|
return !!(util.pathDoesNotExistOrDenied(util.binsPath()) || util.pathDoesNotExistOrDenied(util.dockerBinPath()) || util.pathDoesNotExistOrDenied(util.dockerMachineBinPath()));
|
|
},
|
|
escapePath(str) {
|
|
return str.replace(/ /g, '\\ ').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
|
|
},
|
|
shouldUpdateBinaries() {
|
|
return !fs.existsSync(util.dockerBinPath()) ||
|
|
!fs.existsSync(util.dockerMachineBinPath()) ||
|
|
this.checksum(util.dockerMachineBinPath()) !== this.checksum(resources.docker_machine()) ||
|
|
this.checksum(util.dockerBinPath()) !== this.checksum(resources.docker());
|
|
|
|
},
|
|
copyBinariesCmd: Promise.coroutine(function* () {
|
|
yield fs.mkdirs(util.binsPath());
|
|
yield fs.copy(resources.docker_machine(), util.dockerMachineBinPath());
|
|
yield fs.copy(resources.docker(), util.dockerBinPath());
|
|
return Promise.resolve();
|
|
}),
|
|
fixBinariesCmd: Promise.coroutine(function* () {
|
|
if(util.isWindows()) {
|
|
return;
|
|
}
|
|
|
|
yield fs.chown(util.binsPath(), process.getuid(), '80');
|
|
yield fs.chown(util.dockerBinPath(), process.getuid(), '80');
|
|
yield fs.chown(util.dockerMachineBinPath(), process.getuid(), '80');
|
|
return Promise.resolve();
|
|
}),
|
|
installVirtualBoxCmd: Promise.coroutine(function* () {
|
|
if(util.isWindows()) {
|
|
yield util.execProper(`powershell.exe -ExecutionPolicy unrestricted -Command "Start-Process \\\"${path.join(util.supportDir(), this.virtualBoxFileName())}\\\" -ArgumentList \\\"--silent --msiparams REBOOT=ReallySuppress\\\" -Verb runAs -Wait"`);
|
|
} else {
|
|
yield util.exec(this.macSudoCmd(`installer -pkg ${this.escapePath(path.join(util.supportDir(), this.virtualBoxFileName()))} -target /`));
|
|
}
|
|
|
|
return Promise.resolve();
|
|
}),
|
|
virtualBoxUrl() {
|
|
if(util.isWindows()) {
|
|
return 'http://download.virtualbox.org/virtualbox/4.3.26/VirtualBox-4.3.26-98988-Win.exe';
|
|
} else {
|
|
return `https://github.com/kitematic/virtualbox/releases/download/${util.packagejson()['virtualbox-version']}/${this.virtualBoxFileName()}`;
|
|
}
|
|
},
|
|
macSudoCmd(cmd) {
|
|
return `${this.escapePath(resources.macsudo())} -p "Kitematic requires administrative privileges to install." sh -c \"${cmd}\"`;
|
|
},
|
|
simulateProgress(estimateSeconds, progress) {
|
|
var times = _.range(0, estimateSeconds * 1000, 200);
|
|
var timers = [];
|
|
_.each(times, time => {
|
|
var timer = setTimeout(() => {
|
|
progress(100 * time / (estimateSeconds * 1000));
|
|
}, time);
|
|
timers.push(timer);
|
|
});
|
|
},
|
|
checksum(filename) {
|
|
return crypto.createHash('sha256').update(fs.readFileSync(filename), 'utf8').digest('hex');
|
|
},
|
|
download(url, filename, checksum, percentCallback) {
|
|
return new Promise((resolve, reject) => {
|
|
if (fs.existsSync(filename)) {
|
|
var existingChecksum = this.checksum(filename);
|
|
if (existingChecksum === checksum) {
|
|
resolve();
|
|
return;
|
|
} else {
|
|
fs.unlinkSync(filename);
|
|
}
|
|
}
|
|
|
|
progress(request({ uri: url, rejectUnauthorized: false }), { throttle: 10 }).on('progress', state => {
|
|
if (percentCallback) {
|
|
percentCallback(state.percent);
|
|
}
|
|
}).on('error', err => {
|
|
reject(err);
|
|
}).pipe(fs.createWriteStream(filename)).on('error', err => {
|
|
reject(err);
|
|
}).on('close', err => {
|
|
if (err) {
|
|
reject(err);
|
|
}
|
|
resolve();
|
|
});
|
|
});
|
|
},
|
|
virtualBoxFileName() {
|
|
return util.isWindows() ? util.packagejson()['virtualbox-filename-win'] : util.packagejson()['virtualbox-filename'];
|
|
},
|
|
virtualBoxChecksum() {
|
|
return util.isWindows() ? util.packagejson()['virtualbox-checksum-win'] : util.packagejson()['virtualbox-checksum'];
|
|
},
|
|
compareVersions(v1, v2, options) {
|
|
var lexicographical = options && options.lexicographical,
|
|
zeroExtend = options && options.zeroExtend,
|
|
v1parts = v1.split('.'),
|
|
v2parts = v2.split('.');
|
|
|
|
function isValidPart(x) {
|
|
return (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/).test(x);
|
|
}
|
|
|
|
if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {
|
|
return NaN;
|
|
}
|
|
|
|
if (zeroExtend) {
|
|
while (v1parts.length < v2parts.length) {
|
|
v1parts.push('0');
|
|
}
|
|
while (v2parts.length < v1parts.length) {
|
|
v2parts.push('0');
|
|
}
|
|
}
|
|
|
|
if (!lexicographical) {
|
|
v1parts = v1parts.map(Number);
|
|
v2parts = v2parts.map(Number);
|
|
}
|
|
|
|
for (var i = 0; i < v1parts.length; ++i) {
|
|
if (v2parts.length === i) {
|
|
return 1;
|
|
}
|
|
if (v1parts[i] === v2parts[i]) {
|
|
continue;
|
|
}
|
|
else if (v1parts[i] > v2parts[i]) {
|
|
return 1;
|
|
}
|
|
else {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
if (v1parts.length !== v2parts.length) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
module.exports = SetupUtil;
|