-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.yaml
88 lines (72 loc) · 2.67 KB
/
build.yaml
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
# Copyright 2023 Nuno Aguiar
init:
paths:
src : src
dist: dist
test: test
todo:
- Clean dist
- Build browser version
- Build OpenAF version
- Test OpenAF version
- Minimize
ojob:
opacks :
- openaf: 20200523
catch : logErr(exception);
logToConsole: true # to change when finished
jobs:
# ----------------
- name: Clean dist
exec: |
args.dist = _$(args.dist, "dist").default(args.init.paths.dist);
log("Deleting '" + args.dist + "'...");
io.rm(args.dist);
log("Recreating '" + args.dist + "'...");
io.mkdir(args.dist);
# ---------------------------
- name: Build browser version
exec: |
args.src = _$(args.src, "src").default(args.init.paths.src);
args.dist = _$(args.dist, "dist").default(args.init.paths.dist);
log("Joining nlinq.js with opeafafsigil.js...");
var nlinq = "// nlinq.js\n//\n\n" + io.readFileString(args.src + "/nlinq.js");
var sigil = "// openafsigil.js\n//\n\n" + io.readFileString(args.src + "/openafsigil.js");
log("Writing '" + args.dist + "/nlinq.js'...");
io.writeFileString(args.dist + "/nlinq.js", nlinq + "\n\n" + sigil);
# --------------------------
- name: Build OpenAF version
exec: |
args.src = _$(args.src, "src").default(args.init.paths.src);
args.dist = _$(args.dist, "dist").default(args.init.paths.dist);
var nlinq = io.readFileString(args.src + "/nlinq.js");
var extra = io.readFileString(args.src + "/openafnlinq.js");
extra = extra.split("\n").map((line, i) => {
if (i > 0) return "\t\t" + line; else return line;
}).join("\n");
nlinq = nlinq.replace("/* --extend here-- */", extra);
log("Writing '" + args.dist + "/openafnlinq.js'...");
io.writeFileString(args.dist + "/openafnlinq.js", nlinq);
# -------------------------
- name: Test OpenAF version
deps: Build OpenAF version
exec: |
// Run tests
$sh("sh " + getOpenAFPath() + "ojob " + args.init.paths.test + "/nlinq-test.yaml nlinq=" + args.init.paths.dist + "/openafnlinq.js test=" + args.init.paths.test)
.prefix("test")
.get();
// Check results
var tests = io.readFileJSON("nlinq-test.json");
if (tests.fail > 0) {
tlogErr("There were {{fail}} tests in {{count}}.", tests)
exit(-1);
}
# ---------------
- name : Minimize
deps : Build OpenAF version
exec : |
args.dist = _$(args.dist, "dist").default(args.init.paths.dist)
$sh("ojob ojob.io/oaf/compile file=" + args.dist + "/nlinq.js" + " output=" + args.dist + "/nlinq.min.js")
.prefix("compile")
.get()
io.writeFileString(args.dist + "/nlinq.min.js", "/*v:0.1.5;b:Nuno Aguiar;Copyright 2023 Nuno Aguiar;*/\n" + io.readFileString(args.dist + "/nlinq.min.js"))