1
0
mirror of https://github.com/docker/docs.git synced 2026-11-06 12:54:24 +03:00
Files
docs/gulpfile.js
Dominik Deren 046e640eeb - 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.
- 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>
2015-03-31 16:20:35 +01:00

241 lines
8.6 KiB
JavaScript

var babel = require('gulp-babel');
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var rename = require('gulp-rename');
var downloadatomshell = require('gulp-download-atom-shell');
var fs = require('fs');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var gutil = require('gulp-util');
var less = require('gulp-less');
var livereload = require('gulp-livereload');
var packagejson = require('./package.json');
var plumber = require('gulp-plumber');
var react = require('gulp-react');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
var sourcemaps = require('gulp-sourcemaps');
var dependencies = Object.keys(packagejson.dependencies);
var isBeta = process.argv.indexOf('--beta') !== -1;
var settings;
try {
settings = require('./settings.json');
} catch (err) {
settings = {};
}
settings.beta = isBeta;
var options = {
dev: process.argv.indexOf('release') === -1,
beta: isBeta,
appFilename: isBeta ? 'Kitematic (Beta).app' : 'Kitematic.app',
appName: isBeta ? 'Kitematic (Beta)' : 'Kitematic',
name: 'Kitematic',
icon: isBeta ? './util/kitematic-beta.icns' : './util/kitematic.icns',
bundle: 'com.kitematic.kitematic'
};
gulp.task('js', function () {
return gulp.src('src/**/*.js')
.pipe(gulpif(options.dev, changed('./build')))
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red('Error (' + error.plugin + '): ' + error.message));
this.emit('end');
}))
.pipe(sourcemaps.init())
.pipe(react())
.pipe(babel({blacklist: ['regenerator']}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.appFilename + '/Contents/Resources/app/build'))
.pipe(gulpif(options.dev, livereload()));
});
gulp.task('images', function() {
return gulp.src('images/*')
.pipe(gulpif(options.dev, changed('./build')))
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.appFilename + '/Contents/Resources/app/build'))
.pipe(gulpif(options.dev, livereload()));
});
gulp.task('styles', function () {
return gulp.src('styles/main.less')
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red('Error (' + error.plugin + '): ' + error.message));
// emit the end event, to properly end the task
this.emit('end');
}))
.pipe(gulpif(options.dev, changed('./build')))
.pipe(gulpif(options.dev, sourcemaps.init()))
.pipe(less())
.pipe(gulpif(options.dev, sourcemaps.write()))
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.appFilename + '/Contents/Resources/app/build'))
.pipe(gulpif(!options.dev, cssmin()))
.pipe(concat('main.css'))
.pipe(gulpif(options.dev, livereload()));
});
gulp.task('download', function (cb) {
downloadatomshell({
version: packagejson['atom-shell-version'],
outputDir: 'cache'
}, cb);
});
gulp.task('copy', function () {
gulp.src('index.html')
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.appFilename + '/Contents/Resources/app/build'))
.pipe(gulpif(options.dev, livereload()));
gulp.src('fonts/**')
.pipe(gulpif(options.dev, changed('./build')))
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.appFilename + '/Contents/Resources/app/build'))
.pipe(gulpif(options.dev, livereload()));
});
gulp.task('dist', function () {
var stream = gulp.src('').pipe(shell([
'rm -Rf dist',
'mkdir -p ./dist/osx',
'cp -R ./cache/Atom.app ./dist/osx/<%= filename %>',
'mv ./dist/osx/<%= filename %>/Contents/MacOS/Atom ./dist/osx/<%= filename %>/Contents/MacOS/<%= name %>',
'mkdir -p ./dist/osx/<%= filename %>/Contents/Resources/app',
'mkdir -p ./dist/osx/<%= filename %>/Contents/Resources/app/node_modules',
'cp package.json dist/osx/<%= filename %>/Contents/Resources/app/',
'mkdir -p dist/osx/<%= filename %>/Contents/Resources/app/resources',
'cp -v resources/* dist/osx/<%= filename %>/Contents/Resources/app/resources/ || :',
'cp <%= icon %> dist/osx/<%= filename %>/Contents/Resources/atom.icns',
'/usr/libexec/PlistBuddy -c "Set :CFBundleVersion <%= version %>" dist/osx/<%= filename %>/Contents/Info.plist',
'/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName <%= name %>" dist/osx/<%= filename %>/Contents/Info.plist',
'/usr/libexec/PlistBuddy -c "Set :CFBundleName <%= name %>" dist/osx/<%= filename %>/Contents/Info.plist',
'/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier <%= bundle %>" dist/osx/<%= filename %>/Contents/Info.plist',
'/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable <%= name %>" dist/osx/<%= filename %>/Contents/Info.plist'
], {
templateData: {
filename: options.appFilename.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)'),
name: options.appName.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)'),
version: packagejson.version,
bundle: options.bundle,
icon: options.icon
}
}));
dependencies.forEach(function (d) {
stream = stream.pipe(shell([
'cp -R node_modules/' + d + ' dist/osx/<%= filename %>/Contents/Resources/app/node_modules/'
], {
templateData: {
filename: options.appFilename.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)')
}
}));
});
return stream;
});
gulp.task('sign', function () {
try {
var signing_identity = fs.readFileSync('./identity', 'utf8').trim();
return gulp.src('').pipe(shell([
'codesign --deep --force --verbose --sign "' + signing_identity + '" ' + options.appFilename.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)')
], {
cwd: './dist/osx/'
}));
} catch (error) {
gutil.log(gutil.colors.red('Error: ' + error.message));
}
});
gulp.task('zip', function () {
return gulp.src('').pipe(shell([
'ditto -c -k --sequesterRsrc --keepParent ' + options.appFilename.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)') + ' ' + options.name.replace(' ', '\\ ').replace('(','\\(').replace(')','\\)') + '-' + packagejson.version + '.zip'
], {
cwd: './dist/osx/'
}));
});
gulp.task('settings', function () {
var string_src = function (filename, string) {
var src = require('stream').Readable({ objectMode: true });
src._read = function () {
this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }));
this.push(null);
};
return src;
};
string_src('settings.json', JSON.stringify(settings)).pipe(gulp.dest('dist/osx/' + options.appFilename.replace(' ', '\ ').replace('(','\(').replace(')','\)') + '/Contents/Resources/app'));
});
gulp.task('download-deps', function () {
if(process.platform === 'win32') {
return gulp.src('').pipe(
shell(['powershell.exe -ExecutionPolicy unrestricted -File util\\deps.ps1'])
);
} else {
return gulp.src('').pipe(
shell(['./util/deps'])
);
}
});
gulp.task('copy-icns', ['download'], function () {
if(process.platform === 'win32') {
return gulp.src(options.icon)
.pipe(rename('atom.icns'))
.pipe(gulp.dest('./cache/resources'));
} else {
return gulp.src(options.icon)
.pipe(rename('atom.icns'))
.pipe(gulp.dest('./cache/Atom.app/Contents/Resources'));
}
});
gulp.task('copy-plist', ['download'], function (done) {
if(process.platform === 'darwin') {
return gulp.src('./util/Info.plist')
.pipe(gulp.dest('./cache/Atom.app/Contents'));
} else {
done();
}
});
gulp.task('reset', function () {
if(process.platform === 'win32') {
return gulp.src('').pipe(
shell(['powershell.exe -ExecutionPolicy unrestricted -Command "Start-Process powershell -verb runas -ArgumentList \\\"-ExecutionPolicy unrestricted -file c:\\Users\\Dominik\\Documents\\GitHub\\kitematic\\util\\reset.ps1\\\" -Wait"'])
);
} else {
return gulp.src('').pipe(
shell(['./util/reset'])
);
}
});
gulp.task('release', function () {
runSequence('download-deps', 'download', 'copy-icns', 'copy-plist', 'dist', ['copy', 'images', 'js', 'styles', 'settings'], 'sign', 'zip');
});
gulp.task('default', ['download-deps', 'download', 'copy-icns', 'copy-plist', 'copy', 'js', 'images', 'styles'], function () {
gulp.watch('src/**/*.js', ['js']);
gulp.watch('index.html', ['copy']);
gulp.watch('styles/**/*.less', ['styles']);
gulp.watch('images/**', ['images']);
livereload.listen();
var env = process.env;
env.NODE_ENV = 'development';
if(process.platform === 'win32') {
gulp.src('').pipe(shell(['cache\\atom.exe .'], {
env: env
}));
} else {
gulp.src('').pipe(shell(['./cache/Atom.app/Contents/MacOS/Atom .'], {
env: env
}));
}
});