generated from jinko-core/lib-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.jk
48 lines (37 loc) · 1.19 KB
/
lib.jk
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
// FIXME: How do we bootstrap this? Since the package library needs these
// two libraries in order to download packages?
incl gitko
incl oslib
// FIXME: Use Maybe[String] for version field
// The package's name should be of the form <author>/<pkg> and should
// correspond to a github repository
type Package(name: string, version: string);
func package(name: string) -> Package {
Package(name: name, version: "")
}
func local_path(pkg: Package) -> string {
".jinko/{pkg.name}-{pkg.version}"
}
func pkg_log(s: string) {
println_err("jinko-pkg > {s}");
}
func fetch(pkg: Package) -> Package {
if pkg.version.is_empty() {
pkg_log("Fetching latest version of package `{pkg.name}`");
} else {
pkg_log("Fetching package `{pkg.name}` version {pkg.version}");
};
repository("https://github.com/{pkg.name}").to_path(pkg.local_path()).clone();
// FIXME: Checkout the correct version
pkg
}
func build(pkg: Package) -> Package {
// FIXME: Use `jinko --build` once implemented
// FIXME: Check if file exists before running this
shell("jinko {pkg.local_path()}/build.jk");
pkg
}
test chain_actions() {
Package(name: "jinko-core/gitko", version: "").fetch();
package("jinko-core/oslib").fetch().build();
}