-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuilderman.js
More file actions
140 lines (131 loc) · 2.78 KB
/
Copy pathbuilderman.js
File metadata and controls
140 lines (131 loc) · 2.78 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// @ts-check
import { task, pipeline } from "builderman"
import { pnpm } from "@builderman/resolvers-pnpm"
const libCacheConfig = {
inputs: ["src", pnpm.package()],
outputs: ["dist"],
}
const lib = task({
name: "lib",
cwd: "packages/lib",
commands: {
build: {
run: "pnpm build",
cache: libCacheConfig,
},
dev: {
run: "pnpm dev",
readyWhen: (output) => output.includes("Watching for file changes."),
},
test: {
run: "pnpm test",
env: {
NODE_ENV: "development",
},
cache: libCacheConfig,
},
},
})
const devtoolsHost = task({
name: "devtools-host",
cwd: "packages/devtools-host",
commands: {
build: {
run: "pnpm build",
cache: {
inputs: ["src", lib.artifact("build"), pnpm.package()],
outputs: ["dist"],
},
},
dev: {
run: "pnpm dev",
readyWhen: (output) => output.includes("Build complete!"),
},
},
})
const vitePlugin = task({
name: "vite-plugin-kiru",
cwd: "packages/vite-plugin-kiru",
commands: {
build: {
run: "pnpm build",
cache: {
inputs: [
"src",
lib.artifact("build"),
devtoolsHost.artifact("build"),
pnpm.package(),
],
outputs: ["dist"],
},
},
dev: {
run: "pnpm dev",
dependencies: [lib, devtoolsHost],
},
},
})
const E2ECachConfig = {
inputs: [
"src",
lib.artifact("build"),
vitePlugin.artifact("build"),
pnpm.package(),
],
outputs: ["dist"],
}
const csrTest = task({
name: "e2e:csr",
cwd: "e2e/csr",
commands: {
build: {
run: "pnpm build",
cache: E2ECachConfig,
},
test: {
run: "pnpm test",
cache: E2ECachConfig,
},
},
dependencies: [lib],
env: {
NODE_ENV: "development",
},
})
const ssgTest = task({
name: "e2e:ssg",
cwd: "e2e/ssg",
commands: {
build: {
run: "pnpm build",
cache: E2ECachConfig,
},
test: {
run: "pnpm test",
cache: E2ECachConfig,
},
},
// github can't run two cypress tests in parallel
dependencies: [...(process.env.GITHUB ? [csrTest] : []), lib],
env: {
NODE_ENV: "development",
},
})
const [, , command, ...args] = process.argv
if (!["build", "dev", "test"].includes(command)) {
console.error(`Invalid command: ${command}`)
process.exit(1)
}
const result = await pipeline([
lib,
devtoolsHost,
vitePlugin,
...(args.includes("--skip-e2e") ? [] : [csrTest, ssgTest]),
]).run({
command,
onTaskBegin: (taskName) => console.log(`~~~~~ Task begin: ${taskName}`),
onTaskSkipped: (taskName, _, __, reason) =>
console.log(`~~~~~ Task skipped: ${taskName} - reason: ${reason}`),
onTaskComplete: (taskName) => console.log(`~~~~~ Task complete: ${taskName}`),
})
console.log(result)