Fix release tasks after upgrade to Gulp 4 (#210)

Completion always needs to be signalled now, use the callback.

'release:init' and 'clean' called twice: 'series' is explicit execution,
not a dependency, implicit duplicate dependency resolving not supported
anymore. Remove 'series' at tasks, solely use seperate 'series' for
execution order.

'process.exit' gets "tasks did not complete" complaint, error code
ignored. Use callback with error instead.
This commit is contained in:
Norbert Renner 2019-06-28 17:26:42 +02:00
parent 88bc4a563f
commit e694629f8a

View file

@ -89,13 +89,10 @@ gulp.task('clean', function(cb) {
});
// libs that require loading before config.js
gulp.task(
'scripts_config',
gulp.series('clean', function() {
gulp.task('scripts_config', function() {
// just copy for now
return gulp.src(paths.scriptsConfig).pipe(gulp.dest(paths.dest));
})
);
});
gulp.task('scripts', function() {
if (debug) gutil.log(gutil.colors.yellow('Running in Debug mode'));
@ -208,58 +205,49 @@ var tags = { patch: 'patch', minor: 'minor', major: 'major' };
var nextVersion;
var ghToken;
gulp.task('release:init', function() {
gulp.task('release:init', function(cb) {
var tag = gutil.env.tag;
if (!tag) {
gutil.log(gutil.colors.red('--tag is required'));
process.exit(1);
return cb(new Error('--tag is required'));
}
if (['major', 'minor', 'patch'].indexOf(tag) < 0) {
gutil.log(gutil.colors.red('--tag must be major, minor or patch'));
process.exit(2);
return cb(new Error('--tag must be major, minor or patch'));
}
ghToken = gutil.env.token;
if (!ghToken) {
gutil.log(
gutil.colors.red(
'--token is required (github personnal access token)'
)
return cb(
new Error('--token is required (github personnal access token')
);
process.exit(3);
}
if (ghToken.length != 40) {
gutil.log(gutil.colors.red('--token length must be 40'));
process.exit(4);
return cb(new Error('--token length must be 40'));
}
nextVersion = semver.inc(pkg.version, tag);
git.status({ args: '--porcelain', quiet: true }, function(err, stdout) {
if (err) throw err;
if (err) return cb(err);
if (stdout.length > 0) {
gutil.log(
gutil.colors.red(
return cb(
new Error(
'Repository is not clean. Please commit or stash your pending modification'
)
);
process.exit(5);
}
cb();
});
nextVersion = semver.inc(pkg.version, tag);
return;
});
gulp.task(
'bump:json',
gulp.series('release:init', function() {
gulp.task('bump:json', function() {
gutil.log(gutil.colors.green('Bump to ' + nextVersion));
return gulp
.src(['./package.json'])
.pipe(bump({ version: nextVersion }))
.pipe(gulp.dest('./'));
})
);
});
gulp.task(
'bump:html',
gulp.series('release:init', function() {
gulp.task('bump:html', function() {
return gulp
.src('./index.html')
.pipe(
@ -269,37 +257,23 @@ gulp.task(
)
)
.pipe(gulp.dest('.'));
})
);
});
gulp.task('bump', gulp.series('bump:json', 'bump:html'));
gulp.task(
'release:commit',
gulp.series('bump', function() {
gulp.task('release:commit', function() {
return gulp
.src(['./index.html', './package.json'])
.pipe(git.commit('release: ' + nextVersion));
})
);
gulp.task(
'release:tag',
gulp.series('release:commit', function() {
return git.tag(nextVersion, '', function(err) {
if (err) throw err;
});
})
);
gulp.task(
'release:push',
gulp.series('release:tag', function() {
git.push('origin', 'master', { args: '--tags' }, function(err) {
if (err) throw err;
gulp.task('release:tag', function(cb) {
return git.tag(nextVersion, '', cb);
});
gulp.task('release:push', function(cb) {
git.push('origin', 'master', { args: '--tags' }, cb);
});
})
);
gulp.task('i18next', function() {
return gulp
@ -335,9 +309,7 @@ gulp.task('layers_config', function() {
});
// Bundles layer files. To download and extract run "yarn layers"
gulp.task(
'layers',
gulp.series('layers_config', function() {
gulp.task('layers', function() {
return (
gulp
.src(paths.layers)
@ -359,14 +331,14 @@ gulp.task(
)
.pipe(gulp.dest(paths.dest))
);
})
);
});
gulp.task(
'default',
gulp.series(
'clean',
'scripts_config',
'layers_config',
'layers',
'scripts',
'styles',
@ -378,47 +350,34 @@ gulp.task(
gulp.task(
'debug',
gulp.series(function(done) {
gulp.series(function(cb) {
debug = true;
done();
cb();
}, 'default')
);
gulp.task(
'release:zip',
gulp.series('release:tag', 'default', function() {
gutil.log(
gutil.colors.green('Build brouter-web.' + nextVersion + '.zip')
);
gulp.task('release:zip', function() {
gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip'));
return gulp
.src(
[
'dist/**',
'index.html',
'config.template.js',
'keys.template.js'
],
['dist/**', 'index.html', 'config.template.js', 'keys.template.js'],
{
base: '.'
}
)
.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(
gulp.task('release:publish', function() {
return gulp.src('./brouter-web.' + nextVersion + '.zip').pipe(
release({
tag: nextVersion,
token: ghToken,
manifest: pkg
})
);
})
);
});
gulp.task(
'release',
@ -428,6 +387,7 @@ gulp.task(
'release:commit',
'release:tag',
'release:push',
'default',
'release:zip',
'release:publish'
)