-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
36 lines (31 loc) · 1.33 KB
/
Copy pathsetup.ts
File metadata and controls
36 lines (31 loc) · 1.33 KB
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
#!/usr/bin/env bun
/**
* One-time namespace prep. Idempotent -- safe to run again.
*
* Two things happen here:
* 1. Community images expire the default password on first boot, which blocks
* the Management Portal. UnExpireUserPasswords clears that.
* 2. USER is a plain namespace out of the box. EnableNamespace turns on
* interoperability, which is what maps ENSLIB (and therefore EnsLib.HL7)
* into it. Without this step every EnsLib reference fails to compile.
*/
const CONTAINER = "iris-lab";
const BATCH = [
`zn "%SYS"`,
`do ##class(Security.Users).UnExpireUserPasswords("*")`,
`zn "USER"`,
`do ##class(%EnsembleMgr).EnableNamespace($namespace,1)`,
`write "ENSEMBLE-ENABLED=",##class(%EnsembleMgr).IsEnsembleNamespace($namespace),!`,
`write "HL7-CLASS=",##class(%Dictionary.CompiledClass).%ExistsId("EnsLib.HL7.Message"),!`,
`halt`,
"",
].join("\n");
const res = Bun.spawnSync(
["docker", "exec", "-i", CONTAINER, "iris", "session", "IRIS"],
{ stdin: new TextEncoder().encode(BATCH), stdout: "pipe", stderr: "pipe" },
);
const raw = res.stdout.toString() + res.stderr.toString();
console.log(raw.trim());
const ok = raw.includes("ENSEMBLE-ENABLED=1") && raw.includes("HL7-CLASS=1");
console.log(ok ? "\nsetup ok -- run: bun xform.ts" : "\nsetup incomplete -- read the output above");
process.exit(ok ? 0 : 1);