Bump gulp to version 4.0.2.

This commit is contained in:
Phyks (Lucas Verney) 2019-06-20 17:26:18 +02:00
parent ef41a9e5ff
commit 057104331b
4 changed files with 962 additions and 380 deletions

View file

@ -7,4 +7,4 @@ yarn.lock
.prettierignore .prettierignore
.tx/ .tx/
layers/ layers/
locales/*.json locales/*.json

View file

@ -84,12 +84,19 @@ var paths = {
destName: 'brouter-web' destName: 'brouter-web'
}; };
// libs that require loading before config.js gulp.task('clean', function(cb) {
gulp.task('scripts_config', ['clean'], function() { del(paths.dest + '/**/*', cb);
// just copy for now
return gulp.src(paths.scriptsConfig).pipe(gulp.dest(paths.dest));
}); });
// libs that require loading before config.js
gulp.task(
'scripts_config',
gulp.series('clean', function() {
// just copy for now
return gulp.src(paths.scriptsConfig).pipe(gulp.dest(paths.dest));
})
);
gulp.task('scripts', function() { gulp.task('scripts', function() {
if (debug) gutil.log(gutil.colors.yellow('Running in Debug mode')); if (debug) gutil.log(gutil.colors.yellow('Running in Debug mode'));
else gutil.log(gutil.colors.green('Running in Release mode')); else gutil.log(gutil.colors.green('Running in Release mode'));
@ -142,22 +149,18 @@ gulp.task('styles', function() {
.pipe(gulp.dest(paths.dest)); .pipe(gulp.dest(paths.dest));
}); });
gulp.task('images', ['clean'], function() { gulp.task('images', function() {
return gulp.src(paths.images).pipe(gulp.dest(paths.dest + '/images')); return gulp.src(paths.images).pipe(gulp.dest(paths.dest + '/images'));
}); });
gulp.task('fonts', ['clean'], function() { gulp.task('fonts', function() {
return gulp.src(paths.fonts).pipe(gulp.dest(paths.dest + '/fonts')); return gulp.src(paths.fonts).pipe(gulp.dest(paths.dest + '/fonts'));
}); });
gulp.task('locales', ['clean'], function() { gulp.task('locales', function() {
return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales')); return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales'));
}); });
gulp.task('clean', function(cb) {
del(paths.dest + '/**/*', cb);
});
gulp.task('watch', function() { gulp.task('watch', function() {
debug = true; debug = true;
var watcher = gulp.watch(paths.scripts, ['scripts']); var watcher = gulp.watch(paths.scripts, ['scripts']);
@ -200,17 +203,6 @@ gulp.task('inject', function() {
.pipe(gulp.dest('.')); .pipe(gulp.dest('.'));
}); });
gulp.task('default', [
'clean',
'scripts_config',
'layers',
'scripts',
'styles',
'images',
'fonts',
'locales'
]);
gulp.task('debug', function() { gulp.task('debug', function() {
debug = true; debug = true;
gulp.start('default'); gulp.start('default');
@ -259,78 +251,60 @@ gulp.task('release:init', function() {
return; return;
}); });
gulp.task('bump', ['bump:json', 'bump:html']); gulp.task(
'bump:json',
gulp.series('release:init', function() {
gutil.log(gutil.colors.green('Bump to ' + nextVersion));
return gulp
.src(['./package.json'])
.pipe(bump({ version: nextVersion }))
.pipe(gulp.dest('./'));
})
);
gulp.task('bump:json', ['release:init'], function() { gulp.task(
gutil.log(gutil.colors.green('Bump to ' + nextVersion)); 'bump:html',
return gulp gulp.series('release:init', function() {
.src(['./package.json']) return gulp
.pipe(bump({ version: nextVersion })) .src('./index.html')
.pipe(gulp.dest('./')); .pipe(
}); replace(
/<sup class="version">(.*)<\/sup>/,
gulp.task('bump:html', ['release:init'], function() { '<sup class="version">' + nextVersion + '</sup>'
return gulp )
.src('./index.html')
.pipe(
replace(
/<sup class="version">(.*)<\/sup>/,
'<sup class="version">' + nextVersion + '</sup>'
) )
) .pipe(gulp.dest('.'));
.pipe(gulp.dest('.')); })
}); );
gulp.task('release:commit', ['bump'], function() { gulp.task('bump', gulp.series('bump:json', 'bump:html'));
return gulp
.src(['./index.html', './package.json'])
.pipe(git.commit('release: ' + nextVersion));
});
gulp.task('release:tag', ['release:commit'], function() { gulp.task(
return git.tag(nextVersion, '', function(err) {
if (err) throw err;
});
});
gulp.task('release:push', ['release:tag'], function() {
git.push('origin', 'master', { args: '--tags' }, function(err) {
if (err) throw err;
});
});
gulp.task('release:zip', ['release:tag', 'default'], function() {
gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip'));
return gulp
.src(
['dist/**', 'index.html', 'config.template.js', 'keys.template.js'],
{
base: '.'
}
)
.pipe(zip('brouter-web.' + nextVersion + '.zip'))
.pipe(gulp.dest('.'));
});
gulp.task('release:publish', ['release:zip'], function() {
gulp.src('./brouter-web.' + nextVersion + '.zip').pipe(
release({
tag: nextVersion,
token: ghToken,
manifest: pkg
})
);
});
gulp.task('release', [
'release:init',
'bump',
'release:commit', 'release:commit',
gulp.series('bump', function() {
return gulp
.src(['./index.html', './package.json'])
.pipe(git.commit('release: ' + nextVersion));
})
);
gulp.task(
'release:tag', 'release:tag',
gulp.series('release:commit', function() {
return git.tag(nextVersion, '', function(err) {
if (err) throw err;
});
})
);
gulp.task(
'release:push', 'release:push',
'release:zip', gulp.series('release:tag', function() {
'release:publish' git.push('origin', 'master', { args: '--tags' }, function(err) {
]); if (err) throw err;
});
})
);
gulp.task('i18next', function() { gulp.task('i18next', function() {
return gulp return gulp
@ -366,26 +340,92 @@ gulp.task('layers_config', function() {
}); });
// Bundles layer files. To download and extract run "yarn layers" // Bundles layer files. To download and extract run "yarn layers"
gulp.task('layers', ['layers_config'], function() { gulp.task(
return ( 'layers',
gulp gulp.series('layers_config', function() {
.src(paths.layers) return (
// Workaround to get file extension removed from the dictionary key gulp
.pipe(rename({ extname: '.json' })) .src(paths.layers)
.pipe( // Workaround to get file extension removed from the dictionary key
jsonConcat(paths.layersDestName, function(data) { .pipe(rename({ extname: '.json' }))
var header = .pipe(
'// Licensed under the MIT License (https://github.com/nrenner/brouter-web#license + Credits and Licenses),\n' + jsonConcat(paths.layersDestName, function(data) {
'// except JOSM imagery database (dataSource=JOSM) is licensed under Creative Commons (CC-BY-SA),\n' + var header =
'// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n'; '// Licensed under the MIT License (https://github.com/nrenner/brouter-web#license + Credits and Licenses),\n' +
return Buffer.from( '// except JOSM imagery database (dataSource=JOSM) is licensed under Creative Commons (CC-BY-SA),\n' +
header + '// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n';
'BR.layerIndex = ' + return Buffer.from(
JSON.stringify(data, null, 2) + header +
';' 'BR.layerIndex = ' +
); JSON.stringify(data, null, 2) +
}) ';'
);
})
)
.pipe(gulp.dest(paths.dest))
);
})
);
gulp.task(
'default',
gulp.series(
'clean',
'scripts_config',
'layers',
'scripts',
'styles',
'images',
'fonts',
'locales'
)
);
gulp.task(
'release:zip',
gulp.series('release:tag', 'default', function() {
gutil.log(
gutil.colors.green('Build brouter-web.' + nextVersion + '.zip')
);
return gulp
.src(
[
'dist/**',
'index.html',
'config.template.js',
'keys.template.js'
],
{
base: '.'
}
) )
.pipe(gulp.dest(paths.dest)) .pipe(zip('brouter-web.' + nextVersion + '.zip'))
); .pipe(gulp.dest('.'));
}); })
);
gulp.task(
'release:publish',
gulp.series('release:zip', function() {
gulp.src('./brouter-web.' + nextVersion + '.zip').pipe(
release({
tag: nextVersion,
token: ghToken,
manifest: pkg
})
);
})
);
gulp.task(
'release',
gulp.series(
'release:init',
'bump',
'release:commit',
'release:tag',
'release:push',
'release:zip',
'release:publish'
)
);

View file

@ -63,7 +63,7 @@
"devDependencies": { "devDependencies": {
"autoprefixer": "^8.1.0", "autoprefixer": "^8.1.0",
"del": "^1.1.1", "del": "^1.1.1",
"gulp": "^3.8.11", "gulp": "^4.0.2",
"gulp-bump": "^2.7.0", "gulp-bump": "^2.7.0",
"gulp-cached": "^1.0.4", "gulp-cached": "^1.0.4",
"gulp-clean-css": "^4.0.0", "gulp-clean-css": "^4.0.0",

1080
yarn.lock

File diff suppressed because it is too large Load diff