Skip to content

Commit

Permalink
Updated gulp dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodmg committed Aug 3, 2019
1 parent 3257ab7 commit a1a7983
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 76 deletions.
140 changes: 69 additions & 71 deletions generators/app/templates/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
"use strict";
var gulp = require("gulp");
var tsc = require("gulp-typescript");
var del = require("del");
var sourcemaps = require("gulp-sourcemaps");
var path = require("path");
var spawn = require("child_process").spawn;
var runSequence = require("run-sequence");
var shell = require("gulp-shell");
const gulp = require("gulp");
const tsc = require("gulp-typescript");
const del = require("del");
const sourcemaps = require("gulp-sourcemaps");
const spawn = require("child_process").spawn;
const shell = require("gulp-shell");
const tsProject = tsc.createProject("tsconfig.json");

// Node process
var node = null;
let node = null;
// Executes a node script with params
// @params: string[] -> The params you would pass to the node command
function execute(params) {
if (node) node.kill();
node = spawn("node", params, {
stdio: "inherit"
});
node.on("close", function(code) {
if (code === 8) {
gulp.log("Error detected, waiting for changes...");
}
});
return Promise.resolve();
}

var tsProject = tsc.createProject("tsconfig.json");
function clean() {
return del("dist");
}

gulp.task("clean", function(cb) {
return del("dist", cb);
});
function copyViews() {
return gulp.src("app/views/**").pipe(gulp.dest("dist/views/"));
}

gulp.task("compile", function() {
var tsResult = gulp
function copyLocales() {
return gulp.src("app/locales/**").pipe(gulp.dest("dist/locales/"));
}

function compile() {
const tsResult = gulp
.src(["app/**/*.ts"])
.pipe(sourcemaps.init())
.pipe(tsProject());
Expand All @@ -31,72 +50,51 @@ gulp.task("compile", function() {
})
)
.pipe(gulp.dest("dist"));
});
}

gulp.task("build", function(cb) {
runSequence("clean", "compile", "copy-views", "copy-locales", cb);
});
const build = gulp.series(clean, compile, copyViews, copyLocales);

gulp.task("clean-serve", function(cb) {
runSequence("clean", "copy-views", "copy-locales", "serve", cb);
});
function doServe() {
return execute(["--require", "source-map-support/register", "dist/main.js"]);
}
const serve = gulp.series(compile, doServe);

// first time cleans and compiles, subsecuent times only compiles
gulp.task("watch", ["clean-serve"], function() {
gulp.watch("app/**/*.ts", ["serve"]);
});
const cleanServe = gulp.series(clean, copyViews, copyLocales, serve);

gulp.task("copy-views", function() {
return gulp.src("app/views/**").pipe(gulp.dest("dist/views/"));
});

gulp.task("copy-locales", function() {
return gulp.src("app/locales/**").pipe(gulp.dest("dist/locales/"));
});

gulp.task("serve", ["compile"], function() {
if (node) node.kill();
node = spawn("node", ["--require", "source-map-support/register", "dist/main.js"], {
stdio: "inherit"
});
node.on("close", function(code) {
if (code === 8) {
gulp.log("Error detected, waiting for changes...");
}
});
});

gulp.task("sql", ["compile"], function() {
if (node) node.kill();
node = spawn("node", ["--require", "source-map-support/register", "dist/dumpDbCreate.js"], {
stdio: "inherit"
});
node.on("close", function(code) {
if (code === 8) {
gulp.log("Error detected, waiting for changes...");
}
});
});
// first time cleans and compiles, subsecuent times only compiles
function doWatch() {
return gulp.watch("app/**/*.ts", serve);
}
const watch = gulp.series(cleanServe, doWatch);

gulp.task("seed", ["compile"], function() {
if (node) node.kill();
node = spawn("node", ["--require", "source-map-support/register", "dist/seed.js"], {
stdio: "inherit"
});
node.on("close", function(code) {
if (code === 8) {
gulp.log("Error detected, waiting for changes...");
}
});
});
function doSql() {
return execute(["--require", "source-map-support/register", "dist/dumpDbCreate.js"]);
}
const sql = gulp.series(compile, doSql);

gulp.task("test", ["build"], shell.task("npm test"));
function doSeed() {
return execute(["--require", "source-map-support/register", "dist/seed.js"]);
}
const seed = gulp.series(compile, doSeed);

gulp.task("production", ["build"]);
const test = gulp.series(build, shell.task("npm test"));

gulp.task("default", ["production"]);
const production = gulp.series(build);

// clean up if an error goes unhandled.
process.on("exit", function() {
if (node) node.kill();
});

module.exports = {
clean,
build,
cleanServe,
watch,
serve,
sql,
seed,
test,
production,
default: production
};
7 changes: 3 additions & 4 deletions generators/app/templates/package.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
"chai": "4.1.2",
"del": "3.0.0",
"fs-jetpack": "2.1.0",
"gulp": "3.9.1",
"gulp": "4.0.2",
"gulp-shell": "0.6.5",
"gulp-sourcemaps": "2.6.4",
"gulp-typescript": "4.0.2",
"mocha": "5.2.0",
"run-sequence": "2.2.1",
"sqlite3": "4.0.2",
"typescript": "2.9.2"
},
Expand All @@ -50,12 +49,12 @@
"dotenv": "6.0.0",
"ejs": "2.6.1",
"express": "4.16.3",
"hbs": "4.0.3",
"hbs": "4.0.4",
"helmet": "3.13.0",
"i18n": "0.8.3",
"ip": "1.1.5",
"jsonwebtoken": "8.3.0",
"lodash": "4.17.11",
"lodash": "4.17.15",
"method-override": "3.0.0",
"moment": "2.22.2",
"morgan": "1.9.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-flugzeug",
"version": "1.0.6",
"version": "1.0.7",
"description": "Flugzeug Framework",
"homepage": "http://rodrigomendez.me",
"author": {
Expand Down

0 comments on commit a1a7983

Please sign in to comment.