forked from denofn/denopack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ts
94 lines (86 loc) · 1.89 KB
/
install.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
import { join, parse, resolve } from "https://deno.land/[email protected]/path/mod.ts";
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
const url = import.meta.url;
function buildURL(target: string): string {
const { dir } = parse(url);
if (url.startsWith("https://")) {
return new URL(join(dir, target)).href;
} else {
if (Deno.build.os === "windows") {
return resolve(dir.replace("file:///", ""), target);
}
return resolve(dir.replace("file://", ""), target);
}
}
// Cache all deps
// Main deps
assert(
(await Deno.run({
cmd: [
"deno",
"cache",
"--unstable",
"--reload",
`${buildURL("./deps.ts")}`,
],
}).status()).success,
"Failed to install dependencies.",
);
// Terser
assert(
(await Deno.run({
cmd: [
"deno",
"cache",
"--unstable",
"--reload",
`${buildURL("./plugin/terserTransform/deps.ts")}`,
],
}).status()).success,
"Failed to install terserTransform dependencies.",
);
// Serve
assert(
(await Deno.run({
cmd: [
"deno",
"cache",
"--unstable",
"--reload",
`${buildURL("./plugin/serve/deps.ts")}`,
],
}).status()).success,
"Failed to install serve plugin dependencies.",
);
// Unstable plugin deps
assert(
(await Deno.run({
cmd: [
"deno",
"cache",
"--unstable",
"--no-check", // remove when https://github.com/denoland/deno/issues/7145 is resolved
"--reload",
`${buildURL("./plugin/deps.ts")}`,
],
}).status()).success,
"Failed to install plugin dependencies.",
);
// Install
assert(
(await Deno.run({
cmd: [
"deno",
"install",
"--unstable",
"--allow-read",
"--allow-write",
"--allow-env",
"--allow-net",
"-f",
"--name=denopack",
`${buildURL("cli.ts")}`,
],
}).status()).success,
"Failed to install denopack.",
);