-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
101 lines (80 loc) · 1.96 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
// Copyright © 2019 - 2022 Andrew Neitsch. All rights reserved.
import { spawn, SpawnOptionsWithoutStdio } from "child_process";
import { series, parallel } from "./gulp-settled";
import del from "del";
function run(command: string[], options?: SpawnOptionsWithoutStdio) {
return spawn(command[0], command.slice(1), { stdio: "inherit", ...options });
}
// prettier
const filesToPretty = [
"deploy",
"*.js",
"*.ts",
".storybook/*.js",
"*.json",
"src/**/*.{ts,tsx,css}",
];
export function prettierCheck() {
return run(["prettier", "--check", ...filesToPretty]);
}
export function prettier() {
return run(["prettier", "--list-different", "--write", ...filesToPretty]);
}
// test
const testFiles = ["src/**/*-test.ts", "src/**/*-test.tsx"];
export function unitTest() {
return run(["mocha", "-r", "./babel-register", ...testFiles]);
}
export function tsc() {
return run(["tsc"]);
}
export function cypressTsc() {
return run(["tsc"], { cwd: "cypress" });
}
export function cypress() {
return run(["node", "-r", "./babel-register", "run-cypress.ts"]);
}
export function audit() {
return run(["yarn", "audit"]);
}
export const allTsc = parallel(tsc, cypressTsc);
export const test = parallel(
prettierCheck,
tsc,
cypressTsc,
unitTest,
cypress
audit
);
export function coverage() {
return run([
"c8",
"--reporter=text",
"--reporter=html",
"--exclude=src/migrations",
"mocha",
"-r",
"./babel-register",
"--exclude=node_modules/**",
...testFiles,
]);
}
// build
export function clean() {
return del(["lib/**/*", "dist/**/*"], { dot: true });
}
export function babel() {
return run(["babel", "-x", ".ts,.tsx", "-d", "lib", "src"]);
}
export function parcel() {
return run([
"parcel",
"build",
"--no-autoinstall",
"--no-source-maps",
"--public-url=/dist",
"src/frontend/login.css",
"src/frontend/.wrapper.html",
]);
}
export const build = series(clean, parallel(babel, parcel));