-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
117 lines (111 loc) · 2.96 KB
/
build.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import { build, emptyDir } from "dnt/mod.ts";
import { SpecifierMappings } from "dnt/transform.ts";
import project from "./project.json" with { type: "json" };
type ModuleOption = {
name: string;
description?: string;
mappings?: SpecifierMappings;
};
const name = Deno.args[0];
if (!name) throw new Error("No name provided");
const buildModule = async (
{ name, description, mappings }: ModuleOption,
) => {
await emptyDir(`./npm/${name}`);
await build({
entryPoints: [`./modules/${name}/mod.ts`],
outDir: `./npm/${name}`,
package: {
name: `@sentium/${name}`,
version: project.version,
description,
author: "Lukas Heizmann <lukas@heizmann.dev>",
license: "MIT",
repository: {
type: "git",
url: "https://github.com/sentium-js/sentium.git",
directory: `modules/${name}`,
},
bugs: {
url: "https://github.com/sentium-js/sentium/issues",
},
},
shims: {},
test: false,
mappings,
compilerOptions: {
lib: ["DOM", "ESNext"],
target: "ES2022",
},
});
// copy README.md
await Deno.copyFile(`./docs/${name}.md`, `./npm/${name}/README.md`).catch(
() => console.log("No README.md found"),
);
console.log(`Built ${name}@${project.version}`);
};
switch (name) {
case "common":
await buildModule({ name: "common" });
break;
case "metadata":
await buildModule({ name: "metadata" });
break;
case "injectable":
await buildModule({
name: "injectable",
mappings: {
"./modules/common/mod.ts": {
name: "@sentium/common",
version: `^${project.version}`,
},
"./modules/metadata/mod.ts": {
name: "@sentium/metadata",
version: `^${project.version}`,
},
},
});
break;
case "web":
await buildModule({
name: "web",
mappings: {
"./modules/common/mod.ts": {
name: "@sentium/common",
version: `^${project.version}`,
},
"./modules/metadata/mod.ts": {
name: "@sentium/metadata",
version: `^${project.version}`,
},
"./modules/injectable/mod.ts": {
name: "@sentium/injectable",
version: `^${project.version}`,
},
// hono routers
"./modules/web/router/hono/router.ts": {
name: "hono",
version: `^4.0.1`,
subPath: "router",
},
"./modules/web/router/hono/reg-exp-router.ts": {
name: "hono",
version: `^4.0.1`,
subPath: "router/reg-exp-router",
},
"./modules/web/router/hono/smart-router.ts": {
name: "hono",
version: `^4.0.1`,
subPath: "router/smart-router",
},
"./modules/web/router/hono/trie-router.ts": {
name: "hono",
version: `^4.0.1`,
subPath: "router/trie-router",
},
},
});
break;
default:
throw new Error(`Unknown module: ${name}`);
}