-
Notifications
You must be signed in to change notification settings - Fork 1
/
fuse.js
89 lines (80 loc) · 1.52 KB
/
fuse.js
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
const {
src,
task,
exec,
context,
tsc,
bumpVersion,
npmPublish
} = require("fuse-box/sparky");
const { FuseBox, WebIndexPlugin } = require("fuse-box");
task("default", async context => {
await context.clean();
await context.development();
});
task("tsc", async () => {
await tsc("src", {
target: "esnext",
declaration: true,
outDir: "dist/"
});
});
task("test", async context => {
await context.test();
});
task("dist", async context => {
await context.clean();
await context.prepareDistFolder();
await exec("tsc");
});
task("publish", async () => {
await exec("dist");
await npmPublish({ path: "dist" });
});
context(
class {
async tsc() {
await tsc("src", {
target: "esnext"
});
}
getConfig(){
return FuseBox.init({
homeDir: "src",
log : !!this.log,
output: "dist/$name.js",
target: "server",
plugins: [WebIndexPlugin()]
});
}
async test() {
this.log = false;
this.target = "server@esnext";
this.bundleName = "app";
const fuse = this.getConfig();
await fuse.bundle("app").test(`[**/**.test.ts]`);
await fuse.run();
}
async clean() {
await src("./dist")
.clean("dist/")
.exec();
}
async prepareDistFolder() {
await bumpVersion("package.json", { type: "patch" });
await src("./package.json")
.dest("dist/")
.exec();
}
development() {
const fuse = this.getConfig();
fuse.dev();
fuse
.bundle("app")
.watch()
.completed(proc => proc.start())
.instructions(" > [dev/dev.ts]");
fuse.run();
}
}
);