Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/configs/emulator.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type EmulatorConfig, EmulatorConfigSchema} from '@junobuild/config';
import {type EmulatorConfig, type EmulatorRunner, EmulatorConfigSchema} from '@junobuild/config';
import {red} from 'kleur';
import * as z from 'zod';
import {DEPLOY_LOCAL_REPLICA_PATH} from '../constants/dev.constants';
Expand Down Expand Up @@ -40,6 +40,11 @@ export const readEmulatorConfig = async (): Promise<

const targetDeploy = config.runner?.target ?? DEPLOY_LOCAL_REPLICA_PATH;

const extraHosts = (config.runner?.extraHosts ?? []).map(
([hostname, destination]: NonNullable<EmulatorRunner['extraHosts']>[number]) =>
`${hostname}:${destination}`
);

return {
success: true,
config: {
Expand All @@ -48,7 +53,8 @@ export const readEmulatorConfig = async (): Promise<
containerName,
emulatorType,
runner,
targetDeploy
targetDeploy,
extraHosts
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/services/emulator/_runner.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const initConfigFile = async () => {
const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfig}) => {
const {
config,
derivedConfig: {emulatorType, containerName, runner, targetDeploy}
derivedConfig: {emulatorType, containerName, runner, targetDeploy, extraHosts}
} = extendedConfig;

const {running} = await assertContainerRunning({containerName, runner});
Expand Down Expand Up @@ -249,6 +249,7 @@ const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfi
'-v',
`${targetDeploy}:/juno/target/deploy`,
...(nonNullish(platform) ? [`--platform=${platform}`] : []),
...extraHosts.flatMap((host) => ['--add-host', host]),
image
]
});
Expand Down
1 change: 1 addition & 0 deletions src/types/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface CliEmulatorDerivedConfig {
runner: EmulatorRunnerType;
emulatorType: EmulatorType;
targetDeploy: string;
extraHosts: string[];
}

export interface CliEmulatorConfig {
Expand Down
Loading