Merge pull request #3755 from jsaalfeld/gulp_4
upgrade to node v10 and gulp 4
This commit is contained in:
commit
4007610a54
@ -8,7 +8,7 @@ python:
|
|||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.6"
|
- "3.6"
|
||||||
env:
|
env:
|
||||||
- TRAVIS_NODE_VERSION="4"
|
- TRAVIS_NODE_VERSION="10.1"
|
||||||
before_install:
|
before_install:
|
||||||
- nvm install $TRAVIS_NODE_VERSION
|
- nvm install $TRAVIS_NODE_VERSION
|
||||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -3,9 +3,9 @@ RUN apt-get -y update && apt-get -y upgrade
|
|||||||
|
|
||||||
RUN apt-get install -y libpq-dev supervisor curl vim
|
RUN apt-get install -y libpq-dev supervisor curl vim
|
||||||
## BUILD JS STUFF
|
## BUILD JS STUFF
|
||||||
RUN wget https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-x64.tar.xz -P /tmp
|
RUN wget https://nodejs.org/dist/v10.1.0/node-v10.1.0-linux-x64.tar.xz -P /tmp && \
|
||||||
RUN cd /tmp && tar xfvJ node-v6.11.3-linux-x64.tar.xz
|
cd /tmp && tar xfvJ node-v10.1.0-linux-x64.tar.xz && \
|
||||||
RUN ln -sf /tmp/node-v6.11.3-linux-x64/bin/node /usr/bin/node
|
ln -sf /tmp/node-v10.1.0-linux-x64/bin/node /usr/bin/node
|
||||||
RUN useradd -m openslides
|
RUN useradd -m openslides
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
COPY package.json yarn.lock bower.json gulpfile.js /app/
|
COPY package.json yarn.lock bower.json gulpfile.js /app/
|
||||||
@ -27,9 +27,9 @@ RUN rm -rf /var/lib/apt/lists/*
|
|||||||
# BUILD APP
|
# BUILD APP
|
||||||
ADD . /app
|
ADD . /app
|
||||||
|
|
||||||
RUN node_modules/.bin/gulp --production
|
RUN node_modules/.bin/gulp --production && \
|
||||||
RUN rm -fr /app/bower_components
|
rm -fr /app/bower_components && \
|
||||||
RUN rm -fr /app/node_modules
|
rm -fr /app/node_modules
|
||||||
|
|
||||||
RUN mkdir /data && chown openslides /data
|
RUN mkdir /data && chown openslides /data
|
||||||
USER openslides
|
USER openslides
|
||||||
|
150
gulpfile.js
150
gulpfile.js
@ -30,21 +30,28 @@ var argv = require('yargs').argv,
|
|||||||
uglify = require('gulp-uglify'),
|
uglify = require('gulp-uglify'),
|
||||||
vsprintf = require('sprintf-js').vsprintf;
|
vsprintf = require('sprintf-js').vsprintf;
|
||||||
|
|
||||||
|
|
||||||
// Directory where the results go to
|
// Directory where the results go to
|
||||||
var output_directory = path.join('openslides', 'static');
|
var output_directory = path.join('openslides', 'static');
|
||||||
|
|
||||||
|
|
||||||
|
// Container for all watchers
|
||||||
|
var watchers = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default tasks to be run before start.
|
* Default tasks to be run before start.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Catches all JavaScript files (excluded worker files) from all core apps and concats them to one
|
// Catches all JavaScript files (excluded worker files) from all core apps and concats them to one
|
||||||
// file js/openslides.js. In production mode the file is uglified.
|
// file js/openslides.js. In production mode the file is uglified.
|
||||||
gulp.task('js', function () {
|
var js_src = [
|
||||||
return gulp.src([
|
|
||||||
path.join('openslides', '*', 'static', 'js', '**', '*.js'),
|
path.join('openslides', '*', 'static', 'js', '**', '*.js'),
|
||||||
'!' + path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js'),
|
'!' + path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js'),
|
||||||
])
|
];
|
||||||
|
|
||||||
|
gulp.task('js', function () {
|
||||||
|
return gulp.src(js_src)
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(concat('openslides.js'))
|
.pipe(concat('openslides.js'))
|
||||||
.pipe(sourcemaps.write())
|
.pipe(sourcemaps.write())
|
||||||
@ -53,9 +60,14 @@ gulp.task('js', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watchers.push(function () {
|
||||||
|
gulp.watch(js_src, gulp.series('js'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Catches all JavaScript files from all bower components and concats them to
|
// Catches all JavaScript files from all bower components and concats them to
|
||||||
// one file js/openslides-libs.js. In production mode the file is uglified.
|
// one file js/openslides-libs.js. In production mode the file is uglified.
|
||||||
gulp.task('js-libs', function () {
|
gulp.task('js_libs', function () {
|
||||||
return gulp.src(mainBowerFiles({
|
return gulp.src(mainBowerFiles({
|
||||||
filter: /\.js$/
|
filter: /\.js$/
|
||||||
}))
|
}))
|
||||||
@ -70,28 +82,34 @@ gulp.task('js-libs', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Catches all pdfmake files for pdf worker.
|
|
||||||
gulp.task('pdf-worker', function () {
|
// Catches all pdfmake files for pdf worker and pdfmake library.
|
||||||
return gulp.src([
|
var pdf_worker_src = path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js');
|
||||||
path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js'),
|
|
||||||
])
|
gulp.task('pdf_worker', function () {
|
||||||
|
return gulp.src(pdf_worker_src)
|
||||||
.pipe(gulpif(argv.production, uglify()))
|
.pipe(gulpif(argv.production, uglify()))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'js', 'workers')));
|
.pipe(gulp.dest(path.join(output_directory, 'js', 'workers')));
|
||||||
});
|
});
|
||||||
// pdfmake files
|
|
||||||
gulp.task('pdf-worker-libs', function () {
|
gulp.task('pdf_worker_libs', function () {
|
||||||
return gulp.src([
|
return gulp.src(path.join('bower_components', 'pdfmake', 'build', 'pdfmake.min.js'))
|
||||||
path.join('bower_components', 'pdfmake', 'build', 'pdfmake.min.js'),
|
|
||||||
])
|
|
||||||
.pipe(gulpif(argv.production, uglify()))
|
.pipe(gulpif(argv.production, uglify()))
|
||||||
.pipe(rename('pdf-worker-libs.js'))
|
.pipe(rename('pdf-worker-libs.js'))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'js', 'workers')));
|
.pipe(gulp.dest(path.join(output_directory, 'js', 'workers')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watchers.push(function () {
|
||||||
|
gulp.watch(pdf_worker_src, gulp.series('pdf_worker'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Catches all template files from all core apps and concats them to one
|
// Catches all template files from all core apps and concats them to one
|
||||||
// file js/openslides-templates.js. In production mode the file is uglified.
|
// file js/openslides-templates.js. In production mode the file is uglified.
|
||||||
|
var templates_src = path.join('openslides', '*', 'static', 'templates', '**', '*.html');
|
||||||
|
|
||||||
gulp.task('templates', function () {
|
gulp.task('templates', function () {
|
||||||
return gulp.src(path.join('openslides', '*', 'static', 'templates', '**', '*.html'))
|
return gulp.src(templates_src)
|
||||||
.pipe(templateCache('openslides-templates.js', {
|
.pipe(templateCache('openslides-templates.js', {
|
||||||
module: 'OpenSlidesApp-templates',
|
module: 'OpenSlidesApp-templates',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@ -106,33 +124,44 @@ gulp.task('templates', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
.pipe(gulp.dest(path.join(output_directory, 'js')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watchers.push(function () {
|
||||||
|
gulp.watch(templates_src, gulp.series('templates'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Build the openslides-site.css file from the main file core/static/css/site.scss.
|
// Build the openslides-site.css file from the main file core/static/css/site.scss.
|
||||||
// Minimizes the outputfile if the production flag is given.
|
// Minimizes the outputfile if the production flag is given.
|
||||||
gulp.task('css-site', function () {
|
gulp.task('css_site', function () {
|
||||||
return gulp.src([
|
return gulp.src(path.join('openslides', 'core', 'static', 'css', 'site.scss'))
|
||||||
path.join('openslides', 'core', 'static', 'css', 'site.scss')
|
|
||||||
])
|
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(gulpif(argv.production, cssnano({safe: true})))
|
.pipe(gulpif(argv.production, cssnano({safe: true})))
|
||||||
.pipe(rename('openslides-site.css'))
|
.pipe(rename('openslides-site.css'))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Build the openslides-projector.css file from the main file core/static/css/projector.scss.
|
// Build the openslides-projector.css file from the main file core/static/css/projector.scss.
|
||||||
// Minimizes the outputfile if the production flag is given.
|
// Minimizes the outputfile if the production flag is given.
|
||||||
gulp.task('css-projector', function () {
|
gulp.task('css_projector', function () {
|
||||||
return gulp.src([
|
return gulp.src(path.join('openslides', 'core', 'static', 'css', 'projector.scss'))
|
||||||
path.join('openslides', 'core', 'static', 'css', 'projector.scss')
|
|
||||||
])
|
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(gulpif(argv.production, cssnano({safe: true})))
|
.pipe(gulpif(argv.production, cssnano({safe: true})))
|
||||||
.pipe(rename('openslides-projector.css'))
|
.pipe(rename('openslides-projector.css'))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Watcher for scss files.
|
||||||
|
// We cannot differentiate between all scss files which belong to each realm. So if
|
||||||
|
// one scss file changes the site and projector css is rebuild.
|
||||||
|
watchers.push(function () {
|
||||||
|
gulp.watch(path.join('openslides', '*', 'static', 'css', '**', '*.scss'), gulp.parallel('css_site', 'css_projector'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Catches all CSS files from all bower components and concats them to one file
|
// Catches all CSS files from all bower components and concats them to one file
|
||||||
// css/openslides-libs.css. In production mode the file is uglified.
|
// css/openslides-libs.css. In production mode the file is uglified.
|
||||||
gulp.task('css-libs', function () {
|
gulp.task('css_libs', function () {
|
||||||
return gulp.src(mainBowerFiles({
|
return gulp.src(mainBowerFiles({
|
||||||
filter: /\.css$/
|
filter: /\.css$/
|
||||||
}))
|
}))
|
||||||
@ -141,22 +170,25 @@ gulp.task('css-libs', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Catches all font files from all bower components.
|
// Catches all font files from all bower components.
|
||||||
gulp.task('fonts-libs', function() {
|
gulp.task('fonts_libs', function () {
|
||||||
return gulp.src(mainBowerFiles({
|
return gulp.src(mainBowerFiles({
|
||||||
filter: /\.(woff)|(woff2)$/
|
filter: /\.(woff)|(woff2)$/
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'fonts')));
|
.pipe(gulp.dest(path.join(output_directory, 'fonts')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Catches image files for angular-chosen.
|
// Catches image files for angular-chosen.
|
||||||
gulp.task('angular-chosen-img', function () {
|
gulp.task('angular_chosen_img', function () {
|
||||||
return gulp.src(path.join('bower_components', 'chosen', '*.png'))
|
return gulp.src(path.join('bower_components', 'chosen', '*.png'))
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
.pipe(gulp.dest(path.join(output_directory, 'css')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// CKEditor defaults
|
|
||||||
gulp.task('ckeditor-defaults', function () {
|
// Tasks for CKEditor
|
||||||
|
gulp.task('ckeditor_defaults', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
path.join('bower_components', 'ckeditor', 'styles.js'),
|
path.join('bower_components', 'ckeditor', 'styles.js'),
|
||||||
path.join('bower_components', 'ckeditor', 'contents.css'),
|
path.join('bower_components', 'ckeditor', 'contents.css'),
|
||||||
@ -164,8 +196,7 @@ gulp.task('ckeditor-defaults', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'ckeditor')));
|
.pipe(gulp.dest(path.join(output_directory, 'ckeditor')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// CKEditor skins
|
gulp.task('ckeditor_skins', function () {
|
||||||
gulp.task('ckeditor-skins', function () {
|
|
||||||
return gulp.src(
|
return gulp.src(
|
||||||
[
|
[
|
||||||
path.join('bower_components', 'ckeditor', 'skins', 'moono-lisa', '**', '*'),
|
path.join('bower_components', 'ckeditor', 'skins', 'moono-lisa', '**', '*'),
|
||||||
@ -177,8 +208,7 @@ gulp.task('ckeditor-skins', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'skins')));
|
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'skins')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// CKEditor plugins
|
gulp.task('ckeditor_plugins', function () {
|
||||||
gulp.task('ckeditor-plugins', function () {
|
|
||||||
return gulp.src(
|
return gulp.src(
|
||||||
[
|
[
|
||||||
path.join('bower_components', 'ckeditor', 'plugins', 'clipboard', '**', '*'),
|
path.join('bower_components', 'ckeditor', 'plugins', 'clipboard', '**', '*'),
|
||||||
@ -205,8 +235,7 @@ gulp.task('ckeditor-plugins', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'plugins')));
|
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'plugins')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// CKEditor languages
|
gulp.task('ckeditor_lang', function () {
|
||||||
gulp.task('ckeditor-lang', function () {
|
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
path.join('bower_components', 'ckeditor', 'lang', 'en.js'),
|
path.join('bower_components', 'ckeditor', 'lang', 'en.js'),
|
||||||
path.join('bower_components', 'ckeditor', 'lang', 'de.js'),
|
path.join('bower_components', 'ckeditor', 'lang', 'de.js'),
|
||||||
@ -219,8 +248,8 @@ gulp.task('ckeditor-lang', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'lang')));
|
.pipe(gulp.dest(path.join(output_directory, 'ckeditor', 'lang')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Combines all CKEditor related tasks.
|
gulp.task('ckeditor', gulp.parallel('ckeditor_defaults', 'ckeditor_skins', 'ckeditor_plugins', 'ckeditor_lang'));
|
||||||
gulp.task('ckeditor', ['ckeditor-defaults', 'ckeditor-skins', 'ckeditor-plugins', 'ckeditor-lang'], function () {});
|
|
||||||
|
|
||||||
// Compiles translation files (*.po) to *.json and saves them in the directory
|
// Compiles translation files (*.po) to *.json and saves them in the directory
|
||||||
// openslides/static/i18n/.
|
// openslides/static/i18n/.
|
||||||
@ -232,21 +261,22 @@ gulp.task('translations', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'i18n')));
|
.pipe(gulp.dest(path.join(output_directory, 'i18n')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Gulp default task. Runs all other tasks before.
|
// Gulp default task. Runs all other tasks before.
|
||||||
gulp.task('default', [
|
gulp.task('default', gulp.parallel(
|
||||||
'js',
|
'js',
|
||||||
'js-libs',
|
'js_libs',
|
||||||
'pdf-worker',
|
'pdf_worker',
|
||||||
'pdf-worker-libs',
|
'pdf_worker_libs',
|
||||||
'templates',
|
'templates',
|
||||||
'css-site',
|
'css_site',
|
||||||
'css-projector',
|
'css_projector',
|
||||||
'css-libs',
|
'css_libs',
|
||||||
'fonts-libs',
|
'fonts_libs',
|
||||||
|
'angular_chosen_img',
|
||||||
'ckeditor',
|
'ckeditor',
|
||||||
'angular-chosen-img',
|
|
||||||
'translations'
|
'translations'
|
||||||
], function () {});
|
));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,41 +284,41 @@ gulp.task('default', [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Watches changes in JavaScript and templates.
|
// Watches changes in JavaScript and templates.
|
||||||
gulp.task('watch', ['js', 'templates', 'pdf-worker', 'css-site', 'css-projector'], function () {
|
gulp.task('watching', function () {
|
||||||
gulp.watch([
|
// This tasks never completes because it starts all watchers and let them
|
||||||
path.join('openslides', '*', 'static', 'js', '**', '*.js'),
|
// watch forever ...
|
||||||
'!' + path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js')
|
for (var i = 0; i < watchers.length; i++) {
|
||||||
], ['js']);
|
watchers[i]();
|
||||||
gulp.watch(path.join('openslides', '*', 'static', 'templates', '**', '*.html'), ['templates']);
|
}
|
||||||
gulp.watch(path.join('openslides', 'core', 'static', 'js', 'core', 'pdf-worker.js'), ['pdf-worker']);
|
|
||||||
// We cannot differentiate between all scss files which belong to each realm. So if
|
|
||||||
// one scss file changes the site and projector css is rebuild.
|
|
||||||
gulp.watch(path.join('openslides', '*', 'static', 'css', '**', '*.scss'), ['css-site', 'css-projector']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('watch', gulp.series(gulp.parallel('js', 'pdf_worker', 'templates', 'css_site', 'css_projector'), 'watching'));
|
||||||
|
|
||||||
|
|
||||||
// Extracts translatable strings using angular-gettext and saves them in file
|
// Extracts translatable strings using angular-gettext and saves them in file
|
||||||
// openslides/locale/angular-gettext/template-en.pot.
|
// openslides/locale/angular-gettext/template-en.pot.
|
||||||
gulp.task('pot', function () {
|
gulp.task('pot', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
'openslides/core/static/templates/*.html',
|
templates_src,
|
||||||
'openslides/*/static/templates/**/*.html',
|
path.join('openslides', '*', 'static', 'js', '**', '*.js'),
|
||||||
'openslides/*/static/js/*/*.js',
|
|
||||||
])
|
])
|
||||||
.pipe(gettext.extract('template-en.pot', {}))
|
.pipe(gettext.extract('template-en.pot', {}))
|
||||||
.pipe(gulp.dest('openslides/locale/angular-gettext/'));
|
.pipe(gulp.dest('openslides/locale/angular-gettext/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Checks JavaScript using JSHint
|
// Checks JavaScript using JSHint
|
||||||
gulp.task('jshint', function () {
|
gulp.task('jshint', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
'gulpfile.js',
|
'gulpfile.js',
|
||||||
path.join( 'openslides', '*', 'static', '**', '*.js' ),
|
path.join('openslides', '*', 'static', 'js', '**', '*.js'),
|
||||||
])
|
])
|
||||||
.pipe(jshint())
|
.pipe(jshint())
|
||||||
.pipe(jshint.reporter('default'))
|
.pipe(jshint.reporter('default'))
|
||||||
.pipe(jshint.reporter('fail'));
|
.pipe(jshint.reporter('fail'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Extracts names, URLs and licensed of all uses bower components and prints
|
// Extracts names, URLs and licensed of all uses bower components and prints
|
||||||
// it to the console. This is useful to update the README.rst during release
|
// it to the console. This is useful to update the README.rst during release
|
||||||
// process.
|
// process.
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"angular-mocks": "~1.5.11",
|
"angular-mocks": "~1.5.11",
|
||||||
"bower": "^1.8.0",
|
"bower": "^1.8.0",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "~4.0.0",
|
||||||
"gulp-angular-gettext": "^2.2.0",
|
"gulp-angular-gettext": "^2.2.0",
|
||||||
"gulp-angular-templatecache": "^2.0.0",
|
"gulp-angular-templatecache": "^2.0.0",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user