Skip to content

Commit 7955ba1

Browse files
vinitkumarmarksweb
andauthored
Feat/node upgrade (#445)
* Added nvmrc and stop ignoring package lock * Updating gulpfile to gulp 4 style * Problem with webpack. * fix: webpack config issue broken due to upgrade and some breaking changes * fix: issue with nodejs version * fix: don't install npm * fix: install essential deps to build canvas * fix: exclude gulpfile.js for now, since we need to a full overhaul to port everything to modern * fix: issues with failing tests * fix: change the gulp command name in Dockerfile Co-authored-by: Mark Walker <mark.walker@realbuzz.com>
1 parent d6caf92 commit 7955ba1

File tree

15 files changed

+26946
-7348
lines changed

15 files changed

+26946
-7348
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ env/
2323
.sass-cache
2424
*.css.map
2525
npm-debug.log
26-
package-lock.json
2726

2827
local.sqlite
2928
testdb.sqlite*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ FROM python:3.8.12
44
RUN apt-get update \
55
&& apt-get -y install libtiff5-dev libjpeg62-turbo-dev zlib1g-dev \
66
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev \
7-
build-essential
7+
build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
88

99
# Node setup
10-
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
11-
RUN apt-get install -y nodejs npm
12-
RUN npm install -g gulp@3
10+
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
11+
RUN apt install -y nodejs
12+
RUN npm install -g gulp@4
1313

1414
# Preparing files
1515
WORKDIR /app
@@ -20,6 +20,6 @@ COPY ./tests/requirements /app/tests/requirements
2020

2121
RUN npm install
2222

23-
CMD pip install -e . && gulp lint && gulp tests:integration
23+
CMD pip install -e . && gulp lint && gulp tests
2424

2525
ENV TZ="Europe/Zurich"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ local:
2626
make cleanup
2727
pip install -r tests/requirements/django-$(VERSION).txt
2828
pip install -e .
29-
export SCREENSHOT_REFERENCES="./tests/screenshots/reference-$(VERSION)"; gulp lint && gulp tests:integration
29+
export SCREENSHOT_REFERENCES="./tests/screenshots/reference-$(VERSION)"; gulp lint && gulp tests
Binary file not shown.
Binary file not shown.
Binary file not shown.

gulpfile.js

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,44 @@
33
* @copyright: http://www.divio.ch
44
*/
55
/* eslint-disable no-console */
6-
6+
/*jshint esversion: 6 */
77
'use strict';
88

99
// #############################################################################
1010
// #IMPORTS#
11-
var gulp = require('gulp');
12-
var autoprefixer = require('autoprefixer');
13-
var postcss = require('gulp-postcss');
14-
var gulpif = require('gulp-if');
15-
var sass = require('gulp-sass');
16-
var iconfont = require('gulp-iconfont');
17-
var iconfontCss = require('gulp-iconfont-css');
18-
var sourcemaps = require('gulp-sourcemaps');
19-
var minifyCss = require('gulp-minify-css');
20-
var eslint = require('gulp-eslint');
21-
var integrationTests = require('djangocms-casper-helpers/gulp');
22-
var webpack = require('webpack');
23-
var PluginError = require('plugin-error');
24-
25-
var argv = require('minimist')(process.argv.slice(2));
11+
const gulp = require('gulp');
12+
const gutil = require('gulp-util');
13+
const autoprefixer = require('autoprefixer');
14+
const postcss = require('gulp-postcss');
15+
const browserSync = require('browser-sync').create();
16+
const gulpif = require('gulp-if');
17+
const iconfont = require('gulp-iconfont');
18+
const iconfontCss = require('gulp-iconfont-css');
19+
const log = require('fancy-log');
20+
const sass = require('gulp-sass')(require('sass'));
21+
const sourcemaps = require('gulp-sourcemaps');
22+
const minifyCss = require('gulp-clean-css');
23+
const eslint = require('gulp-eslint');
24+
const webpack = require('webpack');
25+
const integrationTests = require('djangocms-casper-helpers/gulp');
26+
27+
const argv = require('minimist')(process.argv.slice(2)); // eslint-disable-line
2628

2729
// #############################################################################
2830
// #SETTINGS#
29-
var options = {
31+
const options = {
3032
debug: argv.debug
3133
};
32-
var PROJECT_ROOT = __dirname;
33-
var PROJECT_PATH = {
34+
const PROJECT_ROOT = __dirname;
35+
const PROJECT_PATH = {
3436
sass: PROJECT_ROOT + '/djangocms_admin_style/sass',
3537
css: PROJECT_ROOT + '/djangocms_admin_style/static/djangocms_admin_style/css',
3638
js: PROJECT_ROOT + '/djangocms_admin_style/static/djangocms_admin_style/js',
3739
tests: PROJECT_ROOT + '/tests/frontend',
3840
icons: PROJECT_ROOT + '/djangocms_admin_style/static/djangocms_admin_style/fonts'
3941
};
4042

41-
var PROJECT_PATTERNS = {
43+
const PROJECT_PATTERNS = {
4244
sass: [PROJECT_PATH.sass + '/**/*.{scss,sass}'],
4345
icons: [PROJECT_PATH.icons + '/src/*.svg'],
4446
js: [
@@ -47,11 +49,10 @@ var PROJECT_PATTERNS = {
4749
'!' + PROJECT_PATH.js + '/**/jquery.*.js',
4850
'!' + PROJECT_PATH.js + '/libs/**/*.js',
4951
'!' + PROJECT_PATH.js + '/dist/**/*.js',
50-
'gulpfile.js'
5152
]
5253
};
5354

54-
var INTEGRATION_TESTS = [
55+
const INTEGRATION_TESTS = [
5556
[
5657
'loginAdmin',
5758
'dashboard',
@@ -62,12 +63,13 @@ var INTEGRATION_TESTS = [
6263

6364
// #############################################################################
6465
// #TASKS#
65-
gulp.task('sass', function () {
66-
gulp.src(PROJECT_PATTERNS.sass)
66+
const css = () => {
67+
return (
68+
gulp.src(PROJECT_PATTERNS.sass)
6769
.pipe(gulpif(options.debug, sourcemaps.init()))
6870
.pipe(sass())
6971
.on('error', function (error) {
70-
console.log('Error (' + error.plugin + '): ' + error.messageFormatted);
72+
log.error('Error (' + error.plugin + '): ' + error.messageFormatted);
7173
})
7274
.pipe(
7375
postcss([
@@ -82,11 +84,13 @@ gulp.task('sass', function () {
8284
})
8385
)
8486
.pipe(gulpif(options.debug, sourcemaps.write()))
85-
.pipe(gulp.dest(PROJECT_PATH.css));
86-
});
87+
.pipe(gulp.dest(PROJECT_PATH.css))
88+
);
89+
};
8790

88-
gulp.task('icons', function () {
89-
gulp.src(PROJECT_PATTERNS.icons)
91+
const icons = () => {
92+
return (
93+
gulp.src(PROJECT_PATTERNS.icons)
9094
.pipe(
9195
iconfontCss({
9296
fontName: 'django-admin-iconfont',
@@ -102,64 +106,72 @@ gulp.task('icons', function () {
102106
})
103107
)
104108
.on('glyphs', function (glyphs, opts) {
105-
console.log(glyphs, opts);
109+
log(glyphs, opts);
106110
})
107-
.pipe(gulp.dest(PROJECT_PATH.icons));
108-
});
111+
.pipe(gulp.dest(PROJECT_PATH.icons))
112+
)
113+
};
114+
115+
const lint = () => {
116+
return (
117+
gulp
118+
.src(PROJECT_PATTERNS.js)
119+
.pipe(eslint())
120+
.pipe(eslint.format())
121+
.pipe(eslint.failAfterError())
122+
)
123+
};
109124

110-
gulp.task('lint', ['lint:javascript']);
111-
gulp.task('lint:javascript', function () {
112-
// DOCS: http://eslint.org
113-
return gulp.src(PROJECT_PATTERNS.js).pipe(eslint()).pipe(eslint.format()).pipe(eslint.failAfterError());
114-
});
115125

116-
var webpackBundle = function (opts) {
117-
var webpackOptions = opts || {};
126+
const webpackBundle = function (opts) {
127+
const webpackOptions = opts || {};
118128

119129
webpackOptions.PROJECT_PATH = PROJECT_PATH;
120130
webpackOptions.debug = options.debug;
121131

122132
return function (done) {
123-
var config = require('./webpack.config')(webpackOptions);
133+
const config = require('./webpack.config')(webpackOptions);
124134

125135
webpack(config, function (err, stats) {
126136
if (err) {
127137
throw new PluginError('webpack', err);
128138
}
129-
console.log('[webpack]', stats.toString({ colors: true }));
139+
log('[webpack]', stats.toString({ colors: true }));
130140
if (typeof done !== 'undefined' && (!opts || !opts.watch)) {
131141
done();
132142
}
133143
});
134144
};
135145
};
136146

137-
gulp.task('bundle:watch', webpackBundle({ watch: true }));
138-
gulp.task('bundle', webpackBundle());
139-
140147
// #######################################
141148
// #TESTS#
142-
gulp.task('tests', ['tests:integration']);
143149

144-
// gulp tests:integration [--clean] [--screenshots] [--tests=loginAdmin,toolbar]
145-
gulp.task(
146-
'tests:integration',
150+
const testsIntegration = (done) => {
147151
integrationTests({
148152
tests: INTEGRATION_TESTS,
149153
pathToTests: PROJECT_PATH.tests,
150154
argv: argv,
151155
dbPath: 'testdb.sqlite',
152156
serverCommand: 'tests/settings-docker.py',
153-
logger: console.log.bind(console)
154-
})
155-
);
157+
logger: gutil.log.bind(gutil),
158+
waitForMigrations: 5 // seconds
159+
});
160+
done();
161+
};
162+
156163

157164
// #############################################################################
158165
// #COMMANDS#
159-
gulp.task('watch', function () {
160-
gulp.start('bundle:watch');
161-
gulp.watch(PROJECT_PATTERNS.sass, ['sass']);
162-
gulp.watch(PROJECT_PATTERNS.js, ['lint']);
163-
});
166+
const watchFiles = () => {
167+
browserSync.init();
168+
gulp.watch(PROJECT_PATTERNS.sass, css);
169+
gulp.watch(PROJECT_PATTERNS.js, lint);
170+
};
164171

165-
gulp.task('default', ['sass', 'lint', 'watch']);
172+
gulp.task("sass", css);
173+
gulp.task("icons", icons);
174+
gulp.task("lint", lint);
175+
gulp.task('watch', gulp.parallel(watchFiles));
176+
gulp.task('tests', testsIntegration);
177+
gulp.task('bundle', webpackBundle());

0 commit comments

Comments
 (0)