-
Notifications
You must be signed in to change notification settings - Fork 11
/
generate.js
97 lines (81 loc) · 2.51 KB
/
generate.js
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
console.log("\n💎 Preparing implementations report...\n");
const path = require("path");
const fs = require("fs");
const shell = require("shelljs");
const ignoreImplementations = ["mock"];
const implementationPath = path.join(__dirname, "./implementations");
const keysPath = path.join(__dirname, "./data/keys");
const credentialsPath = path.join(__dirname, "./data/credentials");
const presentationsPath = path.join(__dirname, "./data/presentations");
const implementations = fs.readdirSync(implementationPath).filter((i) => {
return !ignoreImplementations.includes(i);
});
const keys = fs.readdirSync(keysPath);
const credentials = fs.readdirSync(credentialsPath);
const presentations = fs.readdirSync(presentationsPath);
const credentialFormats = ["vc", "vc-jwt"];
const presentationFormats = ["vp", "vp-jwt"];
const focusedImplementations = implementations.filter((imp) => {
// test one...
// return imp === "transmute";
// test all...
return true;
});
const generateCredentials = (imp, k, f) => {
credentials.forEach((c) => {
const credentialName = c.split(".json")[0];
const keyName = k.split(".json")[0];
const command = `
IMPLEMENTATION=${imp}
INPUT=/data/credentials/${c}
KEY=/data/keys/${k}
FORMAT=${f}
OUTPUT=/data/implementations/$IMPLEMENTATION/${credentialName}--${keyName}.${f}.json
docker-compose run -d $IMPLEMENTATION \
credential create \
--input $INPUT \
--output $OUTPUT \
--key $KEY \
--format $FORMAT
`;
console.log(`${command}`);
const { code, stdout } = shell.exec(command, { silent: true });
if (code !== 0) {
console.warn(stdout);
}
});
};
const generatePresentations = (imp, k, f) => {
presentations.forEach((p) => {
const presentationName = p.split(".json")[0];
const keyName = k.split(".json")[0];
const command = `
IMPLEMENTATION=${imp}
INPUT=/data/presentations/${p}
KEY=/data/keys/${k}
FORMAT=${f}
OUTPUT=/data/implementations/$IMPLEMENTATION/${presentationName}--${keyName}.${f}.json
docker-compose run -d $IMPLEMENTATION \
presentation create \
--input $INPUT \
--output $OUTPUT \
--key $KEY \
--format $FORMAT
`;
console.log(`${command}`);
const { code, stdout } = shell.exec(command, { silent: true });
if (code !== 0) {
console.warn(stdout);
}
});
};
focusedImplementations.forEach((imp) => {
keys.forEach((key) => {
credentialFormats.forEach((format) => {
generateCredentials(imp, key, format);
});
presentationFormats.forEach((format) => {
generatePresentations(imp, key, format);
});
});
});