Migrate to new gulp & gulpfile version by sheer incompetence

This commit is contained in:
Igor Toporkov 2020-09-15 13:57:48 +03:00
parent 58cce8f713
commit 75cacf5fa4
2 changed files with 34 additions and 30 deletions

View File

@ -10,8 +10,34 @@ const swaggerRepo = require('swagger-repo');
const DIST_DIR = 'web_deploy'; const DIST_DIR = 'web_deploy';
const SPEC_DIR = 'spec'; const SPEC_DIR = 'spec';
gulp.task('serve', ['build', 'watch', 'edit'], function () {
portfinder.getPort({port: 3000}, function (err, port) { gulp.task('build', function (cb) {
exec('npm run build', function (err, stdout, stderr) {
console.log(stderr);
cb(err);
});
});
gulp.task('edit', function () {
portfinder.getPort({ port: 5000 }, function (err, port) {
let app = connect();
app.use(swaggerRepo.swaggerEditorMiddleware());
app.listen(port);
util.log(util.colors.green('swagger-editor started http://localhost:' + port));
});
});
gulp.task('reload', gulp.series('build', function () {
gulp.src(DIST_DIR).pipe(gulpConnect.reload())
}));
gulp.task('watch', function () {
gulp.watch([`${SPEC_DIR}/**/*`, 'web/**/*'], gulp.series('reload'));
});
gulp.task('serve', gulp.parallel('build', 'edit', 'watch', function () {
portfinder.getPort({ port: 3000 }, function (err, port) {
gulpConnect.server({ gulpConnect.server({
root: [DIST_DIR], root: [DIST_DIR],
livereload: true, livereload: true,
@ -23,28 +49,4 @@ gulp.task('serve', ['build', 'watch', 'edit'], function () {
} }
}); });
}); });
}); }));
gulp.task('edit', function () {
portfinder.getPort({port: 5000}, function (err, port) {
let app = connect();
app.use(swaggerRepo.swaggerEditorMiddleware());
app.listen(port);
util.log(util.colors.green('swagger-editor started http://localhost:' + port));
});
});
gulp.task('build', function (cb) {
exec('npm run build', function (err, stdout, stderr) {
console.log(stderr);
cb(err);
});
});
gulp.task('reload', ['build'], function () {
gulp.src(DIST_DIR).pipe(gulpConnect.reload())
});
gulp.task('watch', function () {
gulp.watch([`${SPEC_DIR}/**/*`, 'web/**/*'], ['reload']);
});

View File

@ -6,15 +6,14 @@
"connect": "^3.4.1", "connect": "^3.4.1",
"cors": "^2.7.1", "cors": "^2.7.1",
"deploy-to-gh-pages": "^1.1.0", "deploy-to-gh-pages": "^1.1.0",
"gulp": "^3.9.1",
"gulp-connect": "^4.2.0", "gulp-connect": "^4.2.0",
"gulp-util": "^3.0.7", "gulp-util": "^3.0.7",
"json-merge-patch": "^0.2.3",
"npm": "^5.7.1", "npm": "^5.7.1",
"portfinder": "^1.0.3", "portfinder": "^1.0.3",
"shelljs": "^0.7.0", "shelljs": "^0.7.0",
"swagger-repo": "^1.0.0", "swagger-repo": "^1.0.0",
"swagger-ui": "^2.1.4", "swagger-ui": "^2.1.4"
"json-merge-patch": "^0.2.3"
}, },
"private": true, "private": true,
"scripts": { "scripts": {
@ -22,5 +21,8 @@
"swagger": "swagger-repo", "swagger": "swagger-repo",
"test": "swagger-repo validate", "test": "swagger-repo validate",
"start": "gulp serve" "start": "gulp serve"
},
"devDependencies": {
"gulp": "github:gulpjs/gulp"
} }
} }