Update prettier version

This commit is contained in:
Gautier P 2020-12-05 11:50:30 +01:00
parent c49b821db7
commit 25429b3c24
42 changed files with 2480 additions and 2490 deletions

View file

@ -34,16 +34,16 @@ var debug = false;
var paths = {
// see overrides in package.json
scriptsConfig: mainNpmFiles().filter(f => RegExp('url-search-params/.*\\.js', 'i').test(f)),
scriptsConfig: mainNpmFiles().filter((f) => RegExp('url-search-params/.*\\.js', 'i').test(f)),
scripts: [
'node_modules/jquery/dist/jquery.js',
'node_modules/tether/dist/js/tether.js',
'node_modules/async/lib/async.js',
'node_modules/leaflet/dist/leaflet-src.js'
'node_modules/leaflet/dist/leaflet-src.js',
]
.concat(
mainNpmFiles().filter(
f =>
(f) =>
RegExp('.*\\.js', 'i').test(f) &&
!RegExp('.*\\.min\\.js', 'i').test(f) &&
!RegExp('url-search-params/.*\\.js', 'i').test(f)
@ -58,13 +58,13 @@ var paths = {
'js/util/*.js',
'js/plugin/*.js',
'js/control/*.js',
'js/index.js'
'js/index.js',
]),
styles: mainNpmFiles()
.filter(f => RegExp('.*\\.css', 'i').test(f) && !RegExp('.*\\.min\\.css', 'i').test(f))
.filter((f) => RegExp('.*\\.css', 'i').test(f) && !RegExp('.*\\.min\\.css', 'i').test(f))
.concat('css/*.css'),
images: mainNpmFiles().filter(f => RegExp('.*.+(png|gif|svg)', 'i').test(f)),
fonts: mainNpmFiles().filter(f => RegExp('font-awesome/fonts/.*', 'i').test(f)),
images: mainNpmFiles().filter((f) => RegExp('.*.+(png|gif|svg)', 'i').test(f)),
fonts: mainNpmFiles().filter((f) => RegExp('font-awesome/fonts/.*', 'i').test(f)),
locales: 'locales/*.json',
layers: 'layers/**/*.geojson',
layersDestName: 'layers.js',
@ -72,25 +72,25 @@ var paths = {
'layers/config/config.js',
'layers/config/tree.js',
'layers/config/overrides.js',
'layers/config/geometry.js'
'layers/config/geometry.js',
],
layersConfigDestName: 'layersConf.js',
zip: ['dist/**', 'index.html', 'config.template.js', 'keys.template.js'],
dest: 'dist',
destName: 'brouter-web'
destName: 'brouter-web',
};
gulp.task('clean', function(cb) {
gulp.task('clean', function (cb) {
del(paths.dest + '/**/*', cb);
});
// libs that require loading before config.js
gulp.task('scripts_config', function() {
gulp.task('scripts_config', 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'));
else gutil.log(gutil.colors.green('Running in Release mode'));
@ -106,14 +106,14 @@ gulp.task('scripts', function() {
});
// separate, fallback task for debugging (switch manually in index.html)
gulp.task('concat', function() {
gulp.task('concat', function () {
return gulp
.src(paths.scripts)
.pipe(concat(paths.destName + '.src.js'))
.pipe(gulp.dest(paths.dest));
});
gulp.task('styles', function() {
gulp.task('styles', function () {
return gulp
.src(paths.styles)
.pipe(
@ -129,40 +129,40 @@ gulp.task('styles', function() {
}
return distUrl;
}
},
})
)
.pipe(concat(paths.destName + '.css'))
.pipe(
cleanCSS({
rebase: false
rebase: false,
})
)
.pipe(postcss([autoprefixer({ remove: false })]))
.pipe(gulp.dest(paths.dest));
});
gulp.task('images', function() {
gulp.task('images', function () {
return gulp.src(paths.images).pipe(gulp.dest(paths.dest + '/images'));
});
gulp.task('fonts', function() {
gulp.task('fonts', function () {
return gulp.src(paths.fonts).pipe(gulp.dest(paths.dest + '/fonts'));
});
gulp.task('locales', function() {
gulp.task('locales', function () {
return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales'));
});
gulp.task('reload', function(done) {
gulp.task('reload', function (done) {
server.reload();
done();
});
gulp.task('watch', function() {
gulp.task('watch', function () {
debug = true;
var watcher = gulp.watch(paths.scripts, gulp.series('scripts', 'reload'));
watcher.on('change', function(event) {
watcher.on('change', function (event) {
if (event.type === 'deleted') {
delete cached.caches.scripts[event.path];
remember.forget('scripts', event.path);
@ -171,35 +171,26 @@ gulp.task('watch', function() {
gulp.watch(paths.locales, gulp.series('locales', 'reload'));
gulp.watch(paths.styles, gulp.series('styles', 'reload'));
gulp.watch(paths.layersConfig, gulp.series('layers_config', 'reload'));
gulp.watch(
['./index.html']
.concat(paths.images)
.concat(paths.fonts)
.concat(paths.locales),
gulp.series('reload')
);
gulp.watch(['./index.html'].concat(paths.images).concat(paths.fonts).concat(paths.locales), gulp.series('reload'));
});
// Print paths to console, for manually debugging the gulp build
// (comment out corresponding line of paths to print)
gulp.task('log', function() {
gulp.task('log', function () {
// var src = paths.scripts
// var src = paths.styles
// var src = paths.images
// var src = paths.locales
var src = paths.scripts
.concat(paths.styles)
.concat(paths.images)
.concat(paths.locales);
var src = paths.scripts.concat(paths.styles).concat(paths.images).concat(paths.locales);
return gulp.src(src).pipe(gulpDebug());
});
gulp.task('inject', function() {
gulp.task('inject', function () {
var target = gulp.src('index.html');
var sources = gulp.src(paths.scripts.concat(paths.styles), {
base: '.',
read: false
read: false,
});
return target.pipe(inject(sources, { relative: true })).pipe(gulp.dest('.'));
@ -209,7 +200,7 @@ var pkg = require('./package.json');
var nextVersion;
var ghToken;
gulp.task('release:init', function(cb) {
gulp.task('release:init', function (cb) {
var tag = gutil.env.tag;
if (!tag) {
return cb(new Error('--tag is required'));
@ -227,7 +218,7 @@ gulp.task('release:init', function(cb) {
nextVersion = semver.inc(pkg.version, tag);
git.status({ args: '--porcelain', quiet: true }, function(err, stdout) {
git.status({ args: '--porcelain', quiet: true }, function (err, stdout) {
if (err) return cb(err);
if (stdout.length > 0) {
return cb(new Error('Repository is not clean. Please commit or stash your pending modification'));
@ -237,7 +228,7 @@ gulp.task('release:init', function(cb) {
});
});
gulp.task('bump:json', function() {
gulp.task('bump:json', function () {
gutil.log(gutil.colors.green('Bump to ' + nextVersion));
return gulp
.src(['./package.json'])
@ -245,7 +236,7 @@ gulp.task('bump:json', function() {
.pipe(gulp.dest('./'));
});
gulp.task('bump:html', function() {
gulp.task('bump:html', function () {
return gulp
.src('./index.html')
.pipe(replace(/<sup class="version">(.*)<\/sup>/, '<sup class="version">' + nextVersion + '</sup>'))
@ -254,19 +245,19 @@ gulp.task('bump:html', function() {
gulp.task('bump', gulp.series('bump:json', 'bump:html'));
gulp.task('release:commit', function() {
gulp.task('release:commit', function () {
return gulp.src(['./index.html', './package.json']).pipe(git.commit('release: ' + nextVersion));
});
gulp.task('release:tag', function(cb) {
gulp.task('release:tag', function (cb) {
return git.tag(nextVersion, '', cb);
});
gulp.task('release:push', function(cb) {
gulp.task('release:push', function (cb) {
git.push('origin', 'master', { args: '--tags' }, cb);
});
gulp.task('i18next', function() {
gulp.task('i18next', function () {
return gulp
.src(['index.html', 'locales/keys.js', 'layers/config/overrides.js', 'js/**/*.js'])
.pipe(sort())
@ -280,29 +271,26 @@ gulp.task('i18next', function() {
loadPath: 'locales/{{lng}}.json',
// the destination path is relative to your `gulp.dest()` path
savePath: 'locales/{{lng}}.json'
}
savePath: 'locales/{{lng}}.json',
},
})
)
.pipe(gulp.dest('.'));
});
gulp.task('layers_config', function() {
return gulp
.src(paths.layersConfig)
.pipe(concat(paths.layersConfigDestName))
.pipe(gulp.dest(paths.dest));
gulp.task('layers_config', function () {
return gulp.src(paths.layersConfig).pipe(concat(paths.layersConfigDestName)).pipe(gulp.dest(paths.dest));
});
// Bundles layer files. To download and extract run "yarn layers"
gulp.task('layers', function() {
gulp.task('layers', function () {
return (
gulp
.src(paths.layers)
// Workaround to get file extension removed from the dictionary key
.pipe(rename({ extname: '.json' }))
.pipe(
jsonConcat(paths.layersDestName, function(data) {
jsonConcat(paths.layersDestName, function (data) {
var header =
'// Licensed under the MIT License (https://github.com/nrenner/brouter-web#license + Credits and Licenses),\n' +
'// except JOSM imagery database (dataSource=JOSM) is licensed under Creative Commons (CC-BY-SA),\n' +
@ -321,7 +309,7 @@ gulp.task(
gulp.task(
'debug',
gulp.series(function(cb) {
gulp.series(function (cb) {
debug = true;
cb();
}, 'default')
@ -329,28 +317,28 @@ gulp.task(
gulp.task(
'serve',
gulp.series('debug', function(cb) {
gulp.series('debug', function (cb) {
server.init({
server: {
baseDir: './'
baseDir: './',
},
open: false
open: false,
});
cb();
})
);
gulp.task('release:zip', function() {
gulp.task('release:zip', function () {
gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip'));
return gulp
.src(paths.zip, {
base: '.'
base: '.',
})
.pipe(zip('brouter-web.' + nextVersion + '.zip'))
.pipe(gulp.dest('.'));
});
gulp.task('release:zip_standalone', function() {
gulp.task('release:zip_standalone', function () {
var version = pkg.version;
var destName = 'brouter-web-standalone.' + version + '.zip';
@ -358,10 +346,10 @@ gulp.task('release:zip_standalone', function() {
var brouterWeb = gulp
.src(paths.zip, {
base: '.'
base: '.',
})
.pipe(
rename(function(path) {
rename(function (path) {
path.dirname = 'brouter-web/' + path.dirname;
})
);
@ -372,14 +360,14 @@ gulp.task('release:zip_standalone', function() {
.src(
[
'misc/readmes/profile_developers_guide.txt',
'brouter-server/target/brouter-server-*-jar-with-dependencies.jar'
'brouter-server/target/brouter-server-*-jar-with-dependencies.jar',
],
{
cwd: path.join(process.cwd(), '../brouter')
cwd: path.join(process.cwd(), '../brouter'),
}
)
.pipe(
rename(function(path) {
rename(function (path) {
if (path.basename.startsWith('brouter-server-')) {
path.basename = 'brouter';
}
@ -392,30 +380,28 @@ gulp.task('release:zip_standalone', function() {
'!profiles2/all.brf',
'!profiles2/car-eco-suspect_scan.brf',
'!profiles2/car-traffic_analysis.brf',
'!profiles2/softaccess.brf'
'!profiles2/softaccess.brf',
],
{
cwd: path.join(process.cwd(), '../brouter/misc/'),
base: '../brouter/misc/'
base: '../brouter/misc/',
}
);
var serverScripts = gulp.src(['standalone/**'], {
cwd: path.join(process.cwd(), '../brouter/misc/scripts/'),
base: '../brouter/misc/scripts/'
base: '../brouter/misc/scripts/',
});
return merge(brouterWeb, root, serverRoot, serverProfiles, serverScripts)
.pipe(zip(destName))
.pipe(gulp.dest('.'));
return merge(brouterWeb, root, serverRoot, serverProfiles, serverScripts).pipe(zip(destName)).pipe(gulp.dest('.'));
});
gulp.task('release:publish', function() {
gulp.task('release:publish', function () {
return gulp.src('./brouter-web.' + nextVersion + '.zip').pipe(
release({
tag: nextVersion,
token: ghToken,
manifest: pkg
manifest: pkg,
})
);
});