-
Notifications
You must be signed in to change notification settings - Fork 1
/
Drakefile.ts
97 lines (82 loc) 路 2.6 KB
/
Drakefile.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
import { desc, run, sh, task } from "https://x.nest.land/drake@1.4.4/mod.ts";
import { version } from "./lib/version.ts";
import { join } from "./deps.ts";
const encoder = new TextEncoder();
desc("Install eggs.");
task("install-eggs", [], async function () {
await sh(
`deno install -Af --unstable https://x.nest.land/eggs@0.3.7/eggs.ts`,
);
});
desc("Run tests.");
task("test", [], async function () {
await sh(
`deno test -A --unstable`,
);
});
desc("Format source files.");
task("format", [], async function () {
await sh(
`deno fmt`,
);
});
desc("Format source files.");
task("check-format", [], async function () {
await sh(
`deno fmt --check`,
);
});
desc("Lint source files.");
task("lint", [], async function () {
await sh(
`deno lint --unstable`,
);
});
desc("Links the nest.land API key.");
task("link", [], async function () {
await sh(
`eggs link ${Deno.env.get("NESTAPIKEY") ||
"null"} -Do`,
);
});
desc("Reports the details of what would have been published.");
task("dry-publish", [], async function () {
await sh(
`eggs publish hatcher -DoY --no-check --check-installation --version ${version}-dev --dry-run`,
);
});
desc("Publishes hatcher to the nest.land registry.");
task("publish", [], async function () {
await sh(
`eggs publish hatcher -DoY --no-check --check-installation --version ${version}`,
);
});
desc("Reports the details of what would have been shipped.");
task("dry-ship", ["link", "dry-publish"]);
desc("Ship hatcher to nest.land.");
task("ship", ["link", "publish"]);
task("get-version", [], async function () {
console.log(`Hatcher version: ${version}`);
const env = encoder.encode(`\nHATCHER_VERSION=${version}\n`);
const GITHUB_ENV = Deno.env.get("GITHUB_ENV");
if (!GITHUB_ENV) throw new Error("Unable to get Github env");
await Deno.writeFile(GITHUB_ENV, env, { append: true });
});
task("setup-github-actions", [], async function () {
const process = Deno.run({
cmd: ["deno", "install", "-A", "-n", "drake", "Drakefile.ts"],
});
await process.status();
process.close();
// https://github.com/denoland/setup-deno/issues/5
const home = Deno.env.get("HOME") ?? // for linux / mac
Deno.env.get("USERPROFILE") ?? // for windows
"/";
const path = encoder.encode(join(home, ".deno", "bin"));
const GITHUB_PATH = Deno.env.get("GITHUB_PATH");
if (!GITHUB_PATH) throw new Error("Unable to get Github path");
await Deno.writeFile(GITHUB_PATH, path, { append: true });
});
desc("Development tools. Should ideally be run before each commit.");
task("dev", ["format", "lint", "test", "dry-publish"]);
run();