This repository has been archived by the owner on Aug 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ts
119 lines (99 loc) · 3.09 KB
/
gulpfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import {Gulpclass, Task, SequenceTask, MergedTask} from "gulpclass/Decorators";
import * as gulp from "gulp";
import * as del from "del";
import * as ts from "gulp-typescript";
import * as nodemon from "gulp-nodemon";
import * as mocha from "gulp-mocha";
import * as replace from "gulp-replace";
import tslint from "gulp-tslint";
let tsProject = ts.createProject("tsconfig.json");
let argv = require("yargs").argv;
@Gulpclass()
export class Gulpfile {
@Task()
lint() {
return gulp.src(["!gulpfile.js", "!build/**", "!**/node_modules/**", "**/*.{ts,js}"])
.pipe(tslint({
configuration: "tslint.json",
formatter: "verbose"
}))
.pipe(tslint.report());
}
@Task()
clean(next: Function) {
return del(["./build/**"], next);
}
@MergedTask()
copy() {
let copyFiles = gulp
.src([".npmrc", "package.json", "logs"])
.pipe(gulp.dest("./build"));
let copyEbextensions = gulp
.src([".ebextensions/**/*"])
.pipe(gulp.dest("./build/.ebextensions"));
let createLogsFolder = gulp
.src("logs/README.md")
.pipe(gulp.dest("./build/logs"));
let copyTestMedia = gulp
.src("api/shared/tests/media/*")
.pipe(gulp.dest("./build/api/shared/tests/media"));
return [copyFiles, copyEbextensions, createLogsFolder, copyTestMedia];
}
@MergedTask()
compile() {
let tsResult = tsProject
.src()
.pipe(tsProject());
return [
tsResult.js.pipe(gulp.dest("build")),
tsResult.dts.pipe(gulp.dest("build"))
];
}
@Task()
watch() {
gulp.watch(["**/*.ts", "!gulpfile.ts", "!build/", ".env"], ["compile"]);
}
@Task()
replace() {
return gulp.src(["build/.npmrc"])
.pipe(replace("${NPM_TOKEN}", process.env.NPM_TOKEN))
.pipe(gulp.dest("build/"));
}
@Task()
e2e() {
process.env.NODE_ENV = "test";
process.env.USER_UPLOADS_SIZE_LIMIT = 50 * 1024; // 50KB
let src = argv.src ? `build/${argv.src.replace(".ts", ".js")}` : ["build/**/*.e2e.js", "build/**/*.spec.js"];
gulp.src(src, {read: false})
// gulp-mocha needs filepaths so you can"t have any plugins before it
.pipe(mocha({timeout: 60000}))
.once("end", () => {
process.exit();
});
}
@SequenceTask()
test() {
return ["clean", "compile", "copy", "e2e"];
}
@SequenceTask() // this special annotation using "run-sequence" module to run returned tasks in sequence
build() {
return ["clean", "compile", "copy", "replace"];
}
@SequenceTask()
default() {
return ["build"];
}
@SequenceTask()
serve() {
return ["clean", "compile", "copy", "run", "watch"];
}
@Task()
run(next: Function) {
let stream = nodemon({
script: "./build/index.js",
ext: "js json",
watch: ["build/**.js"]
});
next();
}
}