-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnode.ts
83 lines (70 loc) · 1.67 KB
/
node.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
import { build, EntryPoint } from "https://deno.land/x/dnt@0.22.0/mod.ts";
import type { ShimOptions } from "https://deno.land/x/dnt@0.22.0/lib/shims.ts";
import { publisher } from "./me.ts";
export interface PackageConfig {
keywords: string[];
homepage?: string;
repoName: string;
name?: string;
version: string;
license?: string;
description: string;
}
export interface BuildOptions {
entryPoints?: (string | EntryPoint)[];
outDir?: string;
typeCheck?: false;
supportCJS?: false;
shims?: ShimOptions;
}
export async function buildPackage(
packageConfig: PackageConfig,
buildOptions: BuildOptions = {},
) {
const {
entryPoints = ["./mod.ts"],
outDir = "./node",
typeCheck = true,
supportCJS = undefined,
shims = { deno: true },
} = buildOptions;
const {
keywords,
repoName,
homepage = `https://ulti.js.org/${repoName}`,
name = repoName,
version,
license = "MIT",
description,
} = packageConfig;
await build({
entryPoints,
outDir,
scriptModule: supportCJS,
typeCheck,
shims,
package: {
name,
description,
version,
homepage,
license,
funding: {
type: "patreon",
url: `https://www.patreon.com/${publisher.username}`,
},
repository: `github:${publisher.username}/${repoName}`,
bugs: {
url: `https://github.com/${publisher.username}/${repoName}/issues`,
email: publisher.email,
},
keywords,
},
});
try {
await Deno.copyFile("license", "node/LICENSE");
} catch {
await Deno.copyFile("license.md", "node/LICENSE");
}
await Deno.copyFile("readme.md", "node/README.md");
}