Remove old live-reload mechanism
This commit is contained in:
129
gulpfile.js
129
gulpfile.js
@@ -1,129 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var gulp = require('gulp');
|
|
||||||
var prettify = require('gulp-jsbeautifier');
|
|
||||||
var diff = require('gulp-diff');
|
|
||||||
var electron = require('electron-connect').server.create({
|
|
||||||
path: './dist'
|
|
||||||
});
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
|
|
||||||
const distPackageAuthor = 'Mattermost, Inc.';
|
|
||||||
|
|
||||||
var sources = ['**/*.js', '**/*.json', '**/*.css', '**/*.html', '!**/node_modules/**', '!dist/**', '!release/**', '!**/test_config.json'];
|
|
||||||
|
|
||||||
gulp.task('prettify', ['prettify:sources']);
|
|
||||||
gulp.task('prettify:verify', ['prettify:sources:verify']);
|
|
||||||
|
|
||||||
var prettifyOptions = {
|
|
||||||
html: {
|
|
||||||
indent_size: 2,
|
|
||||||
end_with_newline: true
|
|
||||||
},
|
|
||||||
css: {
|
|
||||||
indent_size: 2,
|
|
||||||
end_with_newline: true
|
|
||||||
},
|
|
||||||
js: {
|
|
||||||
indent_size: 2,
|
|
||||||
brace_style: 'end-expand',
|
|
||||||
end_with_newline: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
gulp.task('prettify:sources', ['sync-meta'], () => {
|
|
||||||
return gulp.src(sources).
|
|
||||||
pipe(prettify(prettifyOptions)).
|
|
||||||
pipe(prettify.reporter()).
|
|
||||||
pipe(diff()).
|
|
||||||
pipe(diff.reporter({
|
|
||||||
quiet: true,
|
|
||||||
fail: false
|
|
||||||
})).
|
|
||||||
pipe(gulp.dest('.'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('prettify:sources:verify', () => {
|
|
||||||
return gulp.src(sources).
|
|
||||||
pipe(prettify(prettifyOptions)).
|
|
||||||
pipe(prettify.reporter()).
|
|
||||||
pipe(diff()).
|
|
||||||
pipe(diff.reporter({
|
|
||||||
quiet: true,
|
|
||||||
fail: true
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('build', ['sync-meta', 'copy'], (cb) => {
|
|
||||||
const appPackageJson = require('./src/package.json');
|
|
||||||
const distPackageJson = Object.assign({}, appPackageJson, {
|
|
||||||
author: {
|
|
||||||
name: distPackageAuthor,
|
|
||||||
email: 'noreply'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs.writeFile('./dist/package.json', JSON.stringify(distPackageJson, null, ' '), cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copy', ['copy:assets', 'copy:html/css', 'copy:modules']);
|
|
||||||
|
|
||||||
gulp.task('copy:assets', () => {
|
|
||||||
return gulp.src('src/assets/**').
|
|
||||||
pipe(gulp.dest('dist/assets'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copy:html/css', () => {
|
|
||||||
return gulp.src(['src/browser/**/*.html', 'src/browser/**/*.css']).
|
|
||||||
pipe(gulp.dest('dist/browser'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copy:modules', () => {
|
|
||||||
return gulp.src(['src/node_modules/bootstrap/dist/**']).
|
|
||||||
pipe(gulp.dest('dist/browser/modules/bootstrap'));
|
|
||||||
});
|
|
||||||
|
|
||||||
function spawnWebpack(config, cb) {
|
|
||||||
const ext = process.platform === 'win32' ? '.cmd' : '';
|
|
||||||
spawn(path.resolve(`./node_modules/.bin/webpack${ext}`), ['--config', config], {
|
|
||||||
stdio: 'inherit'
|
|
||||||
}).on('exit', (code) => {
|
|
||||||
cb(code);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('webpack:main', (cb) => {
|
|
||||||
spawnWebpack('webpack.config.main.js', cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('webpack:renderer', (cb) => {
|
|
||||||
spawnWebpack('webpack.config.renderer.js', cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('watch', ['build', 'webpack:main', 'webpack:renderer'], () => {
|
|
||||||
var options = ['--livereload'];
|
|
||||||
electron.start(options);
|
|
||||||
|
|
||||||
gulp.watch(['src/main.js', 'src/main/**/*.js', 'src/common/**/*.js'], ['webpack:main']);
|
|
||||||
gulp.watch(['src/browser/**/*.js', 'src/browser/**/*.jsx'], ['webpack:renderer']);
|
|
||||||
gulp.watch(['src/browser/**/*.css', 'src/browser/**/*.html', 'src/assets/**/*.png'], ['copy']);
|
|
||||||
|
|
||||||
gulp.watch(['dist/main.js', 'dist/assets/**'], () => {
|
|
||||||
electron.restart(options);
|
|
||||||
});
|
|
||||||
gulp.watch(['dist/browser/*.js'], electron.reload);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('sync-meta', () => {
|
|
||||||
var appPackageJson = require('./src/package.json');
|
|
||||||
var packageJson = require('./package.json');
|
|
||||||
appPackageJson.name = packageJson.name;
|
|
||||||
appPackageJson.productName = packageJson.productName;
|
|
||||||
appPackageJson.version = packageJson.version;
|
|
||||||
appPackageJson.description = packageJson.description;
|
|
||||||
appPackageJson.author = packageJson.author;
|
|
||||||
appPackageJson.license = packageJson.license;
|
|
||||||
fs.writeFileSync('./src/package.json', JSON.stringify(appPackageJson, null, ' ') + '\n');
|
|
||||||
});
|
|
@@ -53,9 +53,6 @@
|
|||||||
"electron-connect": "^0.6.1",
|
"electron-connect": "^0.6.1",
|
||||||
"eslint": "^3.16.1",
|
"eslint": "^3.16.1",
|
||||||
"eslint-plugin-react": "^6.10.0",
|
"eslint-plugin-react": "^6.10.0",
|
||||||
"gulp": "^3.9.1",
|
|
||||||
"gulp-diff": "^1.0.0",
|
|
||||||
"gulp-jsbeautifier": "^2.0.4",
|
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^3.2.0",
|
||||||
"mocha-circleci-reporter": "0.0.2",
|
"mocha-circleci-reporter": "0.0.2",
|
||||||
"npm-run-all": "^4.0.2",
|
"npm-run-all": "^4.0.2",
|
||||||
|
@@ -77,15 +77,6 @@ if (process.platform === 'win32') {
|
|||||||
|
|
||||||
var argv = require('yargs').parse(process.argv.slice(1));
|
var argv = require('yargs').parse(process.argv.slice(1));
|
||||||
|
|
||||||
const electronConnect = argv.livereload ? require('electron-connect') : null;
|
|
||||||
var client;
|
|
||||||
if (argv.livereload) {
|
|
||||||
client = electronConnect.client.create();
|
|
||||||
client.on('reload', () => {
|
|
||||||
mainWindow.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var hideOnStartup;
|
var hideOnStartup;
|
||||||
if (argv.hidden) {
|
if (argv.hidden) {
|
||||||
hideOnStartup = true;
|
hideOnStartup = true;
|
||||||
|
@@ -11,9 +11,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://about.mattermost.com",
|
"homepage": "https://about.mattermost.com",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
|
||||||
"electron-connect": "^0.6.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"auto-launch": "^5.0.1",
|
"auto-launch": "^5.0.1",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
|
Reference in New Issue
Block a user