Skip to content

Commit

Permalink
Build on Nodejs 12 (#530)
Browse files Browse the repository at this point in the history
* im done

* Update server.js

* cr fixes
  • Loading branch information
Artyom Egorov authored Feb 10, 2020
1 parent 14393b4 commit 962da57
Show file tree
Hide file tree
Showing 50 changed files with 4,209 additions and 3,002 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"strict": 0,
"key-spacing": 0,
"no-shadow": 0,
"no-console": 1
"no-console": 1,
"no-useless-escape": 0,
"no-prototype-builtins": 0
},
"globals": {
"DG": true,
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: false
node_js:
- 10
- 12
after_success: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
notifications:
slack:
Expand Down
1 change: 0 additions & 1 deletion gulp/deps/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ var deps = {
'DGCustomization/src/DGMap.BaseLayer.js',
'DGCustomization/src/DGMap.TilesCheck.js',
'DGCustomization/src/DGMap.Drag.js',
'DGCustomization/src/DGMarker.js',
'DGCustomization/src/DGPolyUtil.js',
'DGCustomization/src/DGMobileImprove.js'
],
Expand Down
33 changes: 18 additions & 15 deletions gulp/tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
var buildEnd = require('../util/buildEnd.js');
var { buildEnd } = require('../util/buildEnd.js');
var config = require('../../app/config.js');
var runSequence = require('run-sequence');
var argv = require('minimist')(process.argv.slice(2));
var gulp = require('gulp');
var { clean } = require('./clean');
var { buildStyles } = require('./buildStyles');
var { buildScripts } = require('./buildScripts');
var { doc } = require('./doc');
var { loader } = require('./loader');
var { copyAssets } = require('./copyAssets');
var { copyIndexPage } = require('./copyIndexPage');

gulp.task('build', function (cb) {
function npmConfigModify(done) {
if (argv.npm) {
// Disable local config for npm builds
config.appConfig = config.mainConfig;

// Make npm builds https-only
config.appConfig.protocol = 'https:';
}
done();
}

runSequence('clean', 'buildStyles', [
'buildScripts',
'doc',
'loader',
'copyAssets',
'copyIndexPage',
'hooks'
], function() {
buildEnd();
cb();
});
});
exports.build = gulp.series(npmConfigModify, clean, buildStyles, gulp.parallel(
buildScripts,
doc,
loader,
copyAssets,
copyIndexPage
), buildEnd);
4 changes: 2 additions & 2 deletions gulp/tasks/buildLeaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function getLeafletFiles(compsBase32) {
}

// leaflet-custom-build parameter for set id of leaflet build. See more in leaflet/build/build.html
gulp.task('buildLeaflet', function () {
exports.buildLeaflet = function buildLeaflet() {
var leafletCustomBuild = argv['leaflet-custom-build'];
return (leafletCustomBuild ? gulp.src(getLeafletFiles(leafletCustomBuild).map(function (file) {
return path.resolve(path.join(__dirname, '../../node_modules/leaflet/', file))
})) : gulp.src(deps.getJSFiles({source: 'leaflet'})))
.pipe(concat('leaflet-src.js'))
.pipe(gulp.dest('node_modules/leaflet/dist/'));
});
};
15 changes: 8 additions & 7 deletions gulp/tasks/buildScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var es = require('event-stream');
var mergeStream = require('merge-stream');
var gulpif = require('gulp-if');
var argv = require('minimist')(process.argv.slice(2));
var gulp = require('gulp');
var path = require('path');
var map = require('map-stream');
var insert = require('gulp-insert');
var sourcemaps = require('gulp-sourcemaps');
var { concatScripts } = require('./concatScripts');

gulp.task('buildScripts', ['concatScripts'], function() {
function buildScripts() {
var isCustom = argv.pkg || argv.skin;
var packages;

Expand All @@ -27,7 +28,7 @@ gulp.task('buildScripts', ['concatScripts'], function() {
packages = Object.keys(config.packages);
}

return packages.map(function(pkg) {
return mergeStream(packages.map(function(pkg) {
var name = 'script.' + (!isCustom ? pkg + '.' : '') + 'js';
var src = path.join('gulp', 'tmp', 'js', name);

Expand Down Expand Up @@ -59,7 +60,7 @@ gulp.task('buildScripts', ['concatScripts'], function() {
.pipe(gulpif(argv.release, sourcemaps.write('./')))
.pipe(map(stat.save))
.pipe(gulp.dest('dist/js/'));
}).reduce(function(prev, curr) {
return es.merge(prev, curr);
});
});
}));
}

exports.buildScripts = gulp.series(concatScripts, buildScripts);
17 changes: 9 additions & 8 deletions gulp/tasks/buildStyles.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var gulp = require('gulp');

var destCSS = require('../util/destCSS');
var { destCSS } = require('../util/destCSS');
var { collectImagesStats } = require('./collectImagesStats');
var { generateSprites } = require('./generateSprites');
var { imageMinify } = require('./imageMinify');

gulp.task('buildStyles', [
'collectImagesStats',
'generateSprites',
'imageMinify'
], function() {
return destCSS();
});
exports.buildStyles = gulp.series(gulp.parallel(
collectImagesStats,
generateSprites,
imageMinify
), destCSS);
34 changes: 19 additions & 15 deletions gulp/tasks/buildTest.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
var runSequence = require('run-sequence');
var gulp = require('gulp');

var buildEnd = require('../util/buildEnd.js');
var { buildEnd } = require('../util/buildEnd.js');
var { buildStyles } = require('./buildStyles');
var { buildScripts } = require('./buildScripts');
var { doc } = require('./doc');
var { clean } = require('./clean');
var { loader } = require('./loader');
var { copyAssets } = require('./copyAssets');
var { copyIndexPage } = require('./copyIndexPage');

gulp.task('buildTest', function(cb) {
function enableTestBuild(done) {
global.isTestBuild = true;
done();
}

runSequence('clean', [
'buildScripts',
'buildStyles',
'doc',
'loader',
'copyAssets',
'copyIndexPage'
], function() {
buildEnd();
cb();
});
});
exports.buildTest = gulp.series(enableTestBuild, clean, gulp.parallel(
buildScripts,
buildStyles,
doc,
loader,
copyAssets,
copyIndexPage
), buildEnd);
18 changes: 0 additions & 18 deletions gulp/tasks/buildTestFunc.js

This file was deleted.

5 changes: 2 additions & 3 deletions gulp/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var gulp = require('gulp');
var del = require('del');

gulp.task('clean', function() {
exports.clean = function clean() {
return del(['dist', 'gulp/tmp']);
});
};
7 changes: 5 additions & 2 deletions gulp/tasks/collectImagesStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var mkdirp = require('mkdirp');

var config = require('../../app/config');
var deps = require('../deps')(config);
var { copyImg } = require('./copyImg');

gulp.task('collectImagesStats', ['copyImg'], function(cb) {
function collectImagesStats(cb) {
var skins = deps.getSkinsList();
var imagesStatsPerSkin = deps.getImagesFilesStats(skins);

Expand Down Expand Up @@ -46,4 +47,6 @@ gulp.task('collectImagesStats', ['copyImg'], function(cb) {
});

cb();
});
}

exports.collectImagesStats = gulp.series(copyImg, collectImagesStats);
8 changes: 4 additions & 4 deletions gulp/tasks/collectImagesUsageStats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var header = require('gulp-header');
var rename = require('gulp-rename');
var es = require('event-stream');
var mergeStream = require('merge-stream');
var less = require('gulp-less');
var gulp = require('gulp');
var path = require('path');
Expand All @@ -10,7 +10,7 @@ var error = require('../util/error');
var config = require('../../app/config');
var deps = require('../deps')(config);

gulp.task('collectImagesUsageStats', function() {
exports.collectImagesUsageStats = function collectImagesUsageStats() {
var skins = deps.getSkinsList();

var imagesBasePath = path.resolve(__dirname + '/../../dist/img');
Expand Down Expand Up @@ -48,5 +48,5 @@ gulp.task('collectImagesUsageStats', function() {
.pipe(gulp.dest('gulp/tmp/less/'));
});

return es.concat.apply(null, statisticsStreams);
});
return mergeStream(statisticsStreams);
};
23 changes: 14 additions & 9 deletions gulp/tasks/concatScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var sourcemaps = require('gulp-sourcemaps');
var streamqueue = require('streamqueue');
var concat = require('gulp-concat');
var footer = require('gulp-footer');
var es = require('event-stream');
var mergeStream = require('merge-stream');
var gulpif = require('gulp-if');
var argv = require('minimist')(process.argv.slice(2));
var gulp = require('gulp');
Expand All @@ -13,14 +13,14 @@ var deps = require('../deps')(config);
var templateStream = require('../util/templateStream');
var projectList = require('../util/projectList');
var error = require('../util/error');

var dependencies = argv['project-list'] !== false ? ['loadProjectList', 'buildLeaflet'] : ['buildLeaflet'];
var { loadProjectList } = require('./loadProjectList');
var { buildLeaflet } = require('./buildLeaflet');

function getStyleRequireStatement(pack, skin) {
return 'require("../../../dist/css/styles.' + pack + '.' + skin + '.css");';
}

gulp.task('concatScripts', dependencies, function() {
function concatScripts() {
var isCustom = argv.pkg || argv.skin;
var packages;

Expand All @@ -37,7 +37,7 @@ gulp.task('concatScripts', dependencies, function() {
config.appConfig.tileServer = '';
}

return packages.map(function(pkg) {
return mergeStream(packages.map(function(pkg) {
var stream = streamqueue(
{objectMode: true},
gulp.src(deps.getJSFiles({pkg: pkg}), {base: '.'}),
Expand All @@ -56,7 +56,12 @@ gulp.task('concatScripts', dependencies, function() {
return stream
.pipe(gulpif(!argv.release, sourcemaps.write()))
.pipe(gulp.dest('gulp/tmp/js'));
}).reduce(function(prev, curr) {
return es.merge(prev, curr);
});
});
}));
}

const projectListTask = argv['project-list'] !== false ? [loadProjectList] : [];

exports.concatScripts = gulp.series(gulp.parallel(
...projectListTask,
buildLeaflet
), concatScripts);
4 changes: 2 additions & 2 deletions gulp/tasks/copyAssets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var gulp = require('gulp');
var error = require('../util/error');

gulp.task('copyAssets', function() {
exports.copyAssets = function copyAssets() {
return gulp.src(['assets/**/*'])
.pipe(error.handle())
.pipe(gulp.dest('dist'));
});
};
4 changes: 2 additions & 2 deletions gulp/tasks/copyImg.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ var error = require('../util/error');
var config = require('../../app/config');
var deps = require('../deps')(config);

gulp.task('copyImg', function() {
exports.copyImg = function copyImg() {
return gulp.src(deps.getImgGlob(argv))
.pipe(error.handle())
.pipe(rename(function(p) {
p.dirname = '';
}))
.pipe(gulp.dest('dist/img'));
});
};
4 changes: 2 additions & 2 deletions gulp/tasks/copyIndexPage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var gulp = require('gulp');
var error = require('../util/error');

gulp.task('copyIndexPage', function() {
exports.copyIndexPage = function copyIndexPage() {
return gulp.src(['app/index.html'])
.pipe(error.handle())
.pipe(gulp.dest('dist'));
});
};
3 changes: 0 additions & 3 deletions gulp/tasks/default.js

This file was deleted.

8 changes: 4 additions & 4 deletions gulp/tasks/dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var runSequence = require('run-sequence');
var gulp = require('gulp');
var { build } = require('./build');
var { server } = require('./server');
var { watch } = require('./watch');

gulp.task('dev', function(cb) {
runSequence('build', 'server', 'watch', cb);
});
exports.dev = gulp.series(build, server, watch);
7 changes: 3 additions & 4 deletions gulp/tasks/doc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var gulp = require('gulp');

var gendoc = require('../util/gendoc');
var config = require('../../app/config');

gulp.task('doc', function() {
exports.doc = function doc(done) {
var doc = config.doc;

gendoc.generateDocumentation(doc.menu, doc.input, doc.output);
});
done();
};
Loading

0 comments on commit 962da57

Please sign in to comment.