-
Notifications
You must be signed in to change notification settings - Fork 5
/
Drakefile.ts
84 lines (70 loc) · 2.51 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
import { desc, run, sh, task } from "https://x.nest.land/drake@1.5.0/mod.ts";
import { version } from "./src/version.ts";
import { join } from "./deps.ts";
const encoder = new TextEncoder();
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(
`deno run -A --unstable eggs.ts link ${
Deno.env.get("NESTAPIKEY") ||
"null"
} -Do`,
);
});
desc("Reports the details of what would have been published.");
task("dry-publish", [], async function () {
await sh(
`deno run -A --unstable eggs.ts publish eggs -DYod --entry eggs.ts --version ${version}-dev --no-check --check-installation`,
);
});
desc("Publishes eggs to the nest.land registry.");
task("publish", [], async function () {
await sh(
`deno run -A --unstable eggs.ts publish eggs -DYo --entry eggs.ts --version ${version} --no-check --check-installation`,
);
});
desc("Reports the details of what would have been shipped.");
task("dry-ship", ["link", "dry-publish"]);
desc("Ship eggs to nest.land.");
task("ship", ["link", "publish"]);
task("get-version", [], async function () {
console.log(`Eggs version: ${version}`);
const env = encoder.encode(`\nEGGS_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", "--unstable", "-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();