-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.ts
66 lines (58 loc) · 1.33 KB
/
setup.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
import { $ } from "bun";
import { GITHUB_URL } from "~/utils/consts";
import { existsSync, rm } from "node:fs";
import { copyFile } from "node:fs/promises";
interface GitItem {
name: string;
repo: string;
branch?: string;
folder?: string;
install?: boolean;
degit?: boolean;
}
const gits: GitItem[] = [
{
name: "sern-handler-v3",
repo: "handler",
},
{
name: "sern-handler-v4",
repo: "handler",
branch: "feat/v4",
},
{
name: "tools",
repo: "tools",
folder: "packages",
install: false,
degit: true,
},
];
for (const git of gits) {
await $`rm -rf ${git.name}`;
await $`git clone -b ${git.branch ?? "main"} ${GITHUB_URL}/${git.repo} ${git.name}`;
if (git.install ?? true) {
await $`cd ${git.name} && bun install`;
}
if (git.folder) {
await $`mv ${git.name}/${git.folder}/* ${git.name} && rm -rf ${git.name}/${git.folder}`;
}
if (git.degit) {
rm(git.name+"/.git", { recursive: true }, (err) => {
if(err) {
throw err;
}
})
}
}
const tools = (await $`ls -d tools/* | grep -v .github`.text())
.split("\n")
.filter(
(t) => existsSync(`${t}/index.mdx`) && existsSync(`${t}/metadata.json`),
);
for (const tool of tools) {
await copyFile(
`${tool}/index.mdx`,
`src/content/docs/v4/tools/${tool.split("/")[1]}.mdx`,
);
}