-
Notifications
You must be signed in to change notification settings - Fork 1
/
oJobOPack.yaml
54 lines (46 loc) · 2.24 KB
/
oJobOPack.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
# oPack oJob functionality
# Copyright 2023 Nuno Aguiar
jobs:
# oPack Pack external
#
- name: oPack Pack external
help: >
Packs an external opack given an url or opack name:
name (String) The url or opack name to pack
filePath (String) The filepath to the opack
tmpDir (String) Temporary folder to use (defaults to "./tmp")
outputDir (String) Output folder where the opack will be placed (defaults to ".")
noVersion (Boolean) Creates the opack without any version info
withSymLink (Boolean) Creates a symlink without version pointing to the version one just created.
exec: |
args.tmpDir = _$(args.tmpDir).isString().default("./tmp");
args.outputDir = _$(args.outputDir).isString().default(".");
args.name = _$(args.name).isString().default(void 0);
args.filePath = _$(args.filePath).isString().default(void 0);
if (isUnDef(args.name) && isUnDef(args.filePath)) throw "You need to define a opack args.name ou args.filePath";
if (getVersion() < 20171106) logWarn("It's advisable to use an OpenAF version equal or greater than 20171106.");
io.rm(args.tmpDir);
io.mkdir(args.tmpDir);
io.mkdir(args.outputDir);
sync(() => {
if (isDef(args.name)) oPack("install " + args.name + " -d " + args.tmpDir + " -justcopy");
if (isDef(args.filePath)) args.tmpDir = args.filePath;
oPack("pack " + args.tmpDir);
}, oPack);
var pack;
try {
pack = io.readFile(args.tmpDir + "/.package.json");
} catch(e) {
pack = io.readFileYAML(args.tmpDir + "/.package.yaml");
}
if (!args.noVersion) {
io.mv(pack.name + "-" + pack.version + ".opack", args.outputDir + "/" + pack.name + "-" + pack.version + ".opack");
} else {
io.mv(pack.name + ".opack", args.outputDir + "/" + pack.name + ".opack");
}
if (args.withSymLink)
sh("ln -s " + args.outputDir + "/" + pack.name + "-" + pack.version + ".opack " + args.outputDir + "/" + args.name + ".opack");
for(var file in pack.files) {
io.rm(args.tmpDir + "/" + pack.files[file]);
}
io.rm(args.tmpDir);