@freestyle-sh/with-opencode 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ type OpenCodeOptions = {
20
20
  web?: {
21
21
  port?: number;
22
22
  } & OpenCodeAuthOptions;
23
+ env?: Record<string, string>;
23
24
  };
24
25
  type OpenCodeResolvedOptions = {
25
26
  server: {
@@ -28,6 +29,7 @@ type OpenCodeResolvedOptions = {
28
29
  web: {
29
30
  port: number;
30
31
  } & ResolvedOpenCodeAuthOptions;
32
+ env: Record<string, string>;
31
33
  };
32
34
  declare class VmOpenCode extends VmWith<VmOpenCodeInstance> {
33
35
  options: OpenCodeResolvedOptions;
package/dist/index.js CHANGED
@@ -13,38 +13,43 @@ class VmOpenCode extends VmWith {
13
13
  port: options?.server?.port ?? 4096,
14
14
  ...resolveAuth(options?.server)
15
15
  },
16
- web: { port: options?.web?.port ?? 4097, ...resolveAuth(options?.web) }
16
+ web: {
17
+ port: options?.web?.port ?? 4097,
18
+ ...resolveAuth(options?.web)
19
+ },
20
+ env: options?.env ?? {}
17
21
  };
18
22
  }
19
23
  configureSnapshotSpec(spec) {
20
- const webAuthEnv = this.options.web.username ? `OPENCODE_SERVER_USERNAME=${this.options.web.username} OPENCODE_SERVER_PASSWORD=${this.options.web.password}`.trim() : "";
21
- const serverAuthEnv = this.options.server.username ? `OPENCODE_SERVER_USERNAME=${this.options.server.username} OPENCODE_SERVER_PASSWORD=${this.options.server.password}`.trim() : "";
24
+ const envExports = Object.entries(this.options.env).map(([k, v]) => `export ${k}="${v}"`).join("\n");
25
+ const webAuthEnv = this.options.web.username ? `export OPENCODE_SERVER_USERNAME="${this.options.web.username}"
26
+ export OPENCODE_SERVER_PASSWORD="${this.options.web.password}"` : "";
27
+ const serverAuthEnv = this.options.server.username ? `export OPENCODE_SERVER_USERNAME="${this.options.server.username}"
28
+ export OPENCODE_SERVER_PASSWORD="${this.options.server.password}"` : "";
22
29
  return this.composeSpecs(
23
30
  spec,
24
31
  new VmSpec({
25
32
  additionalFiles: {
26
33
  "/opt/install-opencode.sh": {
27
- content: `
28
- #!/bin/bash
29
-
30
- curl -fsSL https://opencode.ai/install | bash
31
- `
34
+ content: `#!/bin/bash
35
+ curl -fsSL https://opencode.ai/install | bash
36
+ `
32
37
  },
33
38
  "/opt/run-opencode-web.sh": {
34
- content: `
35
- #!/bin/bash
36
-
37
- export PATH="$HOME/.local/bin:$PATH"
38
- ${webAuthEnv} /root/.opencode/bin/opencode web --hostname 0.0.0.0 --port ${this.options.web.port}
39
- `
39
+ content: `#!/bin/bash
40
+ export PATH="$HOME/.local/bin:$PATH"
41
+ ${webAuthEnv}
42
+ ${envExports}
43
+ /root/.opencode/bin/opencode web --hostname 0.0.0.0 --port ${this.options.web.port}
44
+ `
40
45
  },
41
46
  "/opt/run-opencode-server.sh": {
42
- content: `
43
- #!/bin/bash
44
-
45
- export PATH="$HOME/.local/bin:$PATH"
46
- ${serverAuthEnv} /root/.opencode/bin/opencode serve --hostname 0.0.0.0 --port ${this.options.server.port}
47
- `
47
+ content: `#!/bin/bash
48
+ export PATH="$HOME/.local/bin:$PATH"
49
+ ${serverAuthEnv}
50
+ ${envExports}
51
+ /root/.opencode/bin/opencode serve --hostname 0.0.0.0 --port ${this.options.server.port}
52
+ `
48
53
  }
49
54
  },
50
55
  systemd: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freestyle-sh/with-opencode",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "packageManager": "pnpm@10.11.0",
5
5
  "private": false,
6
6
  "dependencies": {