-
Notifications
You must be signed in to change notification settings - Fork 1
/
ghjk.ts
122 lines (111 loc) · 3.4 KB
/
ghjk.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
118
119
120
121
122
import { stdDeps } from "../../files/mod.ts";
import { file } from "../../mod.ts";
import * as ports from "../../ports/mod.ts";
const ghjk = file({
// configre an empty env so that no ports are avail by default in our workdir
defaultEnv: "empty",
envs: [{ name: "empty", inherit: false }],
// we wan't all other envs to start from empty unless they opt otherwise
defaultBaseEnv: "empty",
// we won't use the following for now
// but they pretty much configure the "main" env
allowedBuildDeps: [],
installs: [],
stdDeps: true,
enableRuntimes: true,
// tasks aren't attached to envs
tasks: {},
});
// we need this export for this file to be a valid ghjkfile
// it's the one thing used by the ghjk host implementation to
// interact with your ghjkfile
export const sophon = ghjk.sophon;
const { install, env, task } = ghjk;
// we can configure main like this as well
env("main")
// provision env vars to be acccessbile in the env
.var("RUST_LOG", "info,actix=warn")
// provision programs to be avail in the env
.install(ports.jq_ghrel())
.allowedBuildDeps(
// ports can use the following installs at build time
// very WIP mechanism but this is meant to prevent ports from
// pulling whatever dependency they want at build time unless
// explicitly allowed to do so
ports.node({ version: "1.2.3" }),
ports.rust({ version: "stable" }),
// add the std deps including the runtime ports.
// These includes node and python and this will override
// the node from above since it comes after ordinally
...stdDeps({ enableRuntimes: true }),
);
// these top level installs go to the main env as well
install(
// ports can declare their own config params
ports.rust({
version: "1.78.0",
profile: "minimal",
components: ["rustfmt"],
}),
// some ports use other programs as backends
ports.pipi({ packageName: "pre-commit" })[0],
ports.cargobi({ crateName: "mise" }),
);
const ci = env("ci", {
// this inherits from main so it gets jq
inherit: "main",
// extra installs
installs: [ports.protoc(), ports.curl()],
// it has extra allowed deps
allowedBuildDeps: [ports.pnpm()],
// more env vars
vars: {
CI: 1,
},
desc: "do ci stuff",
});
// tasks are invocable from the cli
task("install-app", ($) => $`cargo fetch`);
task("build-app", {
dependsOn: "install-app",
// the task's env inherits from ci
inherit: ci.name,
// it can add more items to that env
installs: [],
// vars
vars: {
RUST_BACKTRACE: 1,
},
// allowed build deps
allowedBuildDeps: [ports.zstd()],
desc: "build the app",
fn: async ($) => {
await $`cargo build -p app`;
// we can access zstd here from the ci env
await $`zstd ./target/debug/app -o app.tar.gz`;
},
});
env("python")
// all envs will inherit from `defaultBaseEnv`
// unless set to false which ensures true isolation
.inherit(false)
.install(
ports.cpy_bs({ version: "3.8.18", releaseTag: "20240224" }),
)
.allowedBuildDeps(
ports.cpy_bs({ version: "3.8.18", releaseTag: "20240224" }),
ports.tar(),
ports.zstd(),
);
env("dev")
// we can inherit from many envs
// if conflict on variables or build deps, the one declared
// later overrides
.inherit(["main", "python"])
// we can set tasks to run on activation/decativation
// which are inheritable
.onEnter(task(($) => $`echo enter`))
.onEnter(task({
workingDir: "..",
fn: ($) => $`ls`,
}));