generated from NodeFactoryIo/node-ts-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasksfile.ts
70 lines (59 loc) · 1.86 KB
/
tasksfile.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
import {ICLIOptions} from "@pawelgalazka/cli";
import {cli, help, sh, rawArgs} from "tasksfile";
function clean(): void {
sh("rm -rf node_modules");
sh("rm -rf build");
}
function lint(): void {
sh("docker-compose run --rm backend yarn run lint", {async: false, nopipe: true});
}
function npm(): void {
sh("docker-compose run --rm backend yarn run " + rawArgs().join(" "), {async: false, nopipe: true});
}
function compile(): void {
sh("docker-compose run --rm backend yarn run build", {async: false, nopipe: true});
}
function build(): void {
sh("docker-compose down", {async: false, nopipe: true});
sh("docker-compose -f docker-compose-cleanup.yml down -v", {async: false, nopipe: true});
sh("docker-compose build", {async: false, nopipe: true});
}
function e2e(): void {
sh("docker-compose -f docker-compose.e2e.yml up --abort-on-container-exit --exit-code-from backend",
{async: false, nopipe: true});
}
function unit(): void {
sh("docker-compose run -e NODE_ENV=test --no-deps --rm backend yarn run test:unit", {async: false, nopipe: true});
}
function test(options: ICLIOptions, type = ""): void {
if (type === "unit") {
unit();
} else if (type === "e2e") {
e2e();
} else {
sh("docker-compose run -e NODE_ENV=test --no-deps --rm backend yarn run test", {async: false, nopipe: true});
}
}
function dev(): void {
sh("docker-compose up", {async: false, nopipe: true});
}
help(e2e, "Runs end-to-end tests");
help(unit, "Runs nodejs unit tests");
help(test, "Runs nodejs tests");
help(dev, "Starts application and all dependent services");
help(npm, "Executes yarn script");
help(compile, "Transpiles files to es5");
help(clean, "Removes all build directories and dependencies");
help(lint, "Runs eslint on current project");
help(build, "Builds new docker image");
cli({
clean,
lint,
npm,
build,
unit,
test,
compile,
dev,
e2e,
});