forked from temporalio/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble.js
executable file
·84 lines (76 loc) · 1.87 KB
/
assemble.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
#!/usr/bin/env node
const {Connection, WorkflowClient} = require("@temporalio/client");
const fs = require("fs-extra");
const path = require("path");
async function run() {
const args = process.argv.slice(2);
let cloud = false;
let coverage = false;
let debug = false;
for (const arg of args) {
if (arg == "--cloud") {
cloud = true;
}
if (arg == "--coverage") {
coverage = true;
}
if (arg == "--debug") {
debug = true;
}
}
const rootDir = path.resolve();
const params = {
rootDir: rootDir,
assemblyDir: "assembly",
runCoverageUpdate: coverage,
debug: debug,
};
let result = "";
if (cloud) {
result = await useCloud(params);
} else {
result = await useLocal(params);
}
console.log(result);
return;
}
async function useCloud(params) {
const cert = await fs.readFile("./assembly/secure/docs-assembly.pem");
const key = await fs.readFile("./assembly/secure/docs-assembly.key");
const data = await fs.readJSON("./assembly/secure/cloud-connection.json");
const connection = await Connection.connect({
address: data.address,
tls: {
clientCertPair: {
crt: cert,
key: key,
},
},
});
const client = new WorkflowClient({
connection,
namespace: data.namespace,
});
const result = await client.execute("fullAssembly", {
taskQueue: `docs-assembly-${data.unique_id}`,
workflowId: `docs-full-assembly-${data.unique_id}`,
args: [params],
});
return result;
}
async function useLocal(params) {
const connection = await Connection.connect({});
const client = new WorkflowClient({
connection,
});
const result = await client.execute("fullAssembly", {
taskQueue: `docs-assembly`,
workflowId: `docs-full-assembly`,
args: [params],
});
return result;
}
run().catch((err) => {
console.error(err);
process.exit(1);
});