From 479b13efee8861a6dcd5760a1da65bbcbbe3647c Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Mon, 16 Mar 2026 11:43:15 +0100 Subject: [PATCH 1/2] feat(config): extraHosts format, types and min array 1 --- .../src/satellite/configs/emulator.config.ts | 20 +++++++++++++--- .../satellite/configs/emulator.config.spec.ts | 24 ++++++------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/config/src/satellite/configs/emulator.config.ts b/packages/config/src/satellite/configs/emulator.config.ts index a2fed8017..290aa8318 100644 --- a/packages/config/src/satellite/configs/emulator.config.ts +++ b/packages/config/src/satellite/configs/emulator.config.ts @@ -108,10 +108,18 @@ export interface EmulatorSatellite { } /** - * @see EmulatorRunner + * @see Hostname */ const HostnameSchema = z.string().min(1); +/** + * A non-empty hostname string. + */ +export type Hostname = string; + +/** + * @see EmulatorRunner + */ const EmulatorRunnerSchema = z.strictObject({ type: z.enum(['docker', 'podman']), image: z.string().optional(), @@ -120,7 +128,13 @@ const EmulatorRunnerSchema = z.strictObject({ target: z.string().optional(), platform: z.enum(['linux/amd64', 'linux/arm64']).optional(), extraHosts: z - .array(z.tuple([HostnameSchema, z.union([z.ipv4(), z.ipv6(), z.literal('host-gateway'), HostnameSchema])])) + .array( + z.tuple([ + HostnameSchema, + z.union([z.ipv4(), z.ipv6(), z.literal('host-gateway'), HostnameSchema]) + ]) + ) + .min(1) .optional() }); @@ -179,7 +193,7 @@ export interface EmulatorRunner { * * @see https://docs.docker.com/reference/cli/docker/container/run/#add-host */ - extraHosts?: [string, string][]; + extraHosts?: [Hostname, string | 'host-gateway' | Hostname][]; } /** diff --git a/packages/config/src/tests/satellite/configs/emulator.config.spec.ts b/packages/config/src/tests/satellite/configs/emulator.config.spec.ts index 7fef0061b..3c0508878 100644 --- a/packages/config/src/tests/satellite/configs/emulator.config.spec.ts +++ b/packages/config/src/tests/satellite/configs/emulator.config.spec.ts @@ -599,16 +599,12 @@ describe('emulator.config', () => { }); it('accepts a valid IPv4 entry', () => { - const result = EmulatorConfigSchema.safeParse( - withExtraHosts([['myhost', '192.168.1.1']]) - ); + const result = EmulatorConfigSchema.safeParse(withExtraHosts([['myhost', '192.168.1.1']])); expect(result.success).toBe(true); }); it('accepts a valid IPv6 entry', () => { - const result = EmulatorConfigSchema.safeParse( - withExtraHosts([['myhost', '::1']]) - ); + const result = EmulatorConfigSchema.safeParse(withExtraHosts([['myhost', '::1']])); expect(result.success).toBe(true); }); @@ -637,9 +633,9 @@ describe('emulator.config', () => { expect(result.success).toBe(true); }); - it('accepts an empty array', () => { + it('rejects an empty array', () => { const result = EmulatorConfigSchema.safeParse(withExtraHosts([])); - expect(result.success).toBe(true); + expect(result.success).toBe(false); }); it('is optional (omitted entirely)', () => { @@ -655,16 +651,12 @@ describe('emulator.config', () => { }); it('rejects an entry with an empty hostname', () => { - const result = EmulatorConfigSchema.safeParse( - withExtraHosts([['', '192.168.1.1']]) - ); + const result = EmulatorConfigSchema.safeParse(withExtraHosts([['', '192.168.1.1']])); expect(result.success).toBe(false); }); it('rejects an entry with an empty destination', () => { - const result = EmulatorConfigSchema.safeParse( - withExtraHosts([['myhost', '']]) - ); + const result = EmulatorConfigSchema.safeParse(withExtraHosts([['myhost', '']])); expect(result.success).toBe(false); }); @@ -676,9 +668,7 @@ describe('emulator.config', () => { }); it('rejects a tuple with only one element', () => { - const result = EmulatorConfigSchema.safeParse( - withExtraHosts([['myhost']]) - ); + const result = EmulatorConfigSchema.safeParse(withExtraHosts([['myhost']])); expect(result.success).toBe(false); }); From fb1f0ba88b2559324bef8f48f97c10d62bd3c1a7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:44:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20Documentation=20auto-update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/config/README.md | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/config/README.md b/packages/config/README.md index c54116fbc..654c0643b 100644 --- a/packages/config/README.md +++ b/packages/config/README.md @@ -168,13 +168,13 @@ References: | Constant | Type | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `EmulatorConfigSchema` | `ZodUnion; image: ZodOptional; name: ZodOptional; volume: ZodOptional<...>; target: ZodOptional<...>; platform: ZodOptional<...>; }, $strict>>; network: ZodOptional<...>; skylab: ZodObjec...` | +| `EmulatorConfigSchema` | `ZodUnion; image: ZodOptional; name: ZodOptional; volume: ZodOptional<...>; target: ZodOptional<...>; platform: ZodOptional<...>; extraHosts: ZodOptional<...>; }, $strict>>; network: ZodO...` | References: - EmulatorConfig -[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L249) +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L288) #### :gear: ModuleLogVisibilitySchema @@ -530,16 +530,17 @@ Configuration for the Satellite emulator. Shared options for all runner variants. -| Property | Type | Description | -| ---------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `type` | `"docker" or "podman"` | The containerization tool to run the emulator. | -| `image` | `string or undefined` | Image reference. default: depends on emulator type, e.g. "junobuild/skylab:latest" | -| `name` | `string or undefined` | Optional container name to use for the emulator. Useful for reusing or managing a specific container. | -| `volume` | `string or undefined` | Persistent volume to store internal state. default: "juno" | -| `target` | `string or undefined` | Shared folder for deploying and hot-reloading serverless functions. | -| `platform` | `"linux/amd64" or "linux/arm64" or undefined` | The platform to use when running the emulator container. | +| Property | Type | Description | +| ------------ | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `type` | `"docker" or "podman"` | The containerization tool to run the emulator. | +| `image` | `string or undefined` | Image reference. default: depends on emulator type, e.g. "junobuild/skylab:latest" | +| `name` | `string or undefined` | Optional container name to use for the emulator. Useful for reusing or managing a specific container. | +| `volume` | `string or undefined` | Persistent volume to store internal state. default: "juno" | +| `target` | `string or undefined` | Shared folder for deploying and hot-reloading serverless functions. | +| `platform` | `"linux/amd64" or "linux/arm64" or undefined` | The platform to use when running the emulator container. | +| `extraHosts` | `[string, string][] or undefined` | Additional host-to-IP mappings to inject into the container via `--add-host`. Each entry is a `[hostname, destination]` tuple where destination is an IPv4 address, an IPv6 address, `"host-gateway"`, or an arbitrary host string. This is useful for making host-machine services (e.g. a local Ethereum RPC node) reachable from within the container under a stable DNS name such as `host.docker.internal`. example: `ts runner: { extraHosts: [['host.docker.internal', 'host-gateway']] } `see: https://docs.docker.com/reference/cli/docker/container/run/#add-host | -[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L125) +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L144) #### :gear: NetworkServices @@ -559,7 +560,7 @@ in the local Internet Computer network when the emulator starts. | `internet_identity` | `boolean or undefined` | Internet Identity: Deploys the II canister for authentication. | | `nns_dapp` | `boolean or undefined` | NNS dapp: Deploys the NNS UI canister and frontend application Requires cmc, icp, nns, sns, internet_identity to be enabled. | -[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L180) +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L219) #### :gear: Network @@ -570,7 +571,7 @@ by the emulator. | ---------- | ----------------- | ----------------------------------------------------------- | | `services` | `NetworkServices` | System canisters and applications available in the network. | -[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L239) +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L278) #### :gear: ModuleSettings @@ -746,6 +747,7 @@ changes, typically through CLI commands (e.g., `juno config`). - [RulesType](#gear-rulestype) - [DatastoreCollection](#gear-datastorecollection) - [StorageCollection](#gear-storagecollection) +- [Hostname](#gear-hostname) - [EmulatorConfig](#gear-emulatorconfig) - [ModuleLogVisibility](#gear-modulelogvisibility) - [JunoConfigMode](#gear-junoconfigmode) @@ -794,6 +796,16 @@ changes, typically through CLI commands (e.g., `juno config`). [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/collections.ts#L32) +#### :gear: Hostname + +A non-empty hostname string. + +| Type | Type | +| ---------- | ---- | +| `Hostname` | | + +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L118) + #### :gear: EmulatorConfig The configuration for running the Juno emulator. @@ -802,7 +814,7 @@ The configuration for running the Juno emulator. | ---------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `EmulatorConfig` | ` | {runner?: EmulatorRunner; network?: Network; skylab: EmulatorSkylab} or {runner?: EmulatorRunner; network?: Network; console: EmulatorConsole} or {runner?: EmulatorRunner; network?: Network; satellite: EmulatorSatellite}` | -[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L272) +[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/satellite/configs/emulator.config.ts#L311) #### :gear: ModuleLogVisibility