forked from fictionco/fiction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
54 lines (48 loc) · 1.53 KB
/
index.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
import {
safeDirname,
FactorEnv,
FactorRelease,
FactorBundle,
CliOptions,
} from "@factor/api"
import { execaCommand } from "execa"
import { commands } from "./@factor/www/src/vars"
import { version } from "./package.json"
const cwd = safeDirname(import.meta.url)
export const factorEnv = new FactorEnv({
cwd,
appName: "FactorJS Monorepo",
appEmail: "",
commands,
id: "factorRepo",
version,
})
export const factorRelease = new FactorRelease({ factorEnv })
export const factorBundle = new FactorBundle({ factorEnv })
export const apps = ["@factor/www", "@factor/andrewpowers", "@factor/supereon"]
factorEnv.addHook({
hook: "runCommand",
callback: async (command: string, opts: CliOptions) => {
if (command == "release") {
await factorRelease.releaseRoutine(opts)
} else if (command == "deploy") {
await factorRelease.deployRoutine(opts)
} else if (command == "bundle") {
await factorBundle.bundleAll(opts)
} else if (command == "render") {
const apps = ["@factor/www", "@factor/andrewpowers", "@factor/supereon"]
for (const app of apps) {
const cmd = `npm -w ${app} exec -- factor run render`
await new Promise((resolve) => {
const cmdProcess = execaCommand(cmd)
cmdProcess.stdout?.pipe(process.stdout)
cmdProcess.stderr?.pipe(process.stderr)
cmdProcess.stdout?.on("data", (d: Buffer) => {
const out = d.toString()
if (out.includes("[done:render]")) resolve(1)
})
})
}
}
},
})