Skip to content
Draft
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
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@junobuild/admin": "^3.0.1",
"@junobuild/cdn": "^2.0.1",
"@junobuild/cli-tools": "^0.9.0",
"@junobuild/config": "^2.6.0",
"@junobuild/config": "^2.6.0-next-2025-11-15.1",
"@junobuild/config-loader": "^0.4.6",
"@junobuild/core": "^3.1.0",
"@junobuild/did-tools": "^0.3.4",
Expand Down
17 changes: 4 additions & 13 deletions src/services/emulator/_runner.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import {nonNullish} from '@dfinity/utils';
import {assertAnswerCtrlC, execute, spawn} from '@junobuild/cli-tools';
import {type EmulatorPorts} from '@junobuild/config';
import {red, yellow} from 'kleur';
import {basename, join} from 'node:path';
import prompts from 'prompts';
import {readEmulatorConfig} from '../../configs/emulator.config';
import {junoConfigExist, junoConfigFile} from '../../configs/juno.config';
import {junoConfigExist} from '../../configs/juno.config';
import {
EMULATOR_PORT_ADMIN,
EMULATOR_PORT_CONSOLE,
Expand Down Expand Up @@ -100,9 +99,10 @@ const promptRunnerType = async (): Promise<{runnerType: EmulatorRunnerType}> =>
choices: [
{
title: 'Docker',
value: `docker`
value: 'docker'
},
{title: `Podman`, value: `podman`}
{title: 'Podman', value: 'podman'},
{title: 'Apple container', value: 'container'}
]
});

Expand Down Expand Up @@ -202,12 +202,6 @@ const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfi

const volume = config.runner?.volume ?? containerName.replaceAll('-', '_');

const detectedConfig = junoConfigFile();
const configFile = nonNullish(detectedConfig.configPath)
? basename(detectedConfig.configPath)
: undefined;
const configFilePath = nonNullish(configFile) ? join(process.cwd(), configFile) : undefined;

// Podman does not auto create the path folders.
await createDeployTargetDir({targetDeploy});

Expand Down Expand Up @@ -237,9 +231,6 @@ const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfi
: []),
'-v',
`${volume}:/juno/.juno`,
...(nonNullish(configFile) && nonNullish(configFilePath)
? ['-v', `${configFilePath}:/juno/${configFile}`]
: []),
'-v',
`${targetDeploy}:/juno/target/deploy`,
...(nonNullish(platform) ? [`--platform=${platform}`] : []),
Expand Down
41 changes: 38 additions & 3 deletions src/utils/runner.utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {notEmptyString} from '@dfinity/utils';
import {spawn} from '@junobuild/cli-tools';
import {green, red, yellow} from 'kleur';
import {lt} from 'semver';
Expand Down Expand Up @@ -35,9 +36,13 @@ export const assertContainerRunnerRunning = async ({
runner
}: Pick<CliEmulatorDerivedConfig, 'runner'>) => {
try {
// container does not support ps
// Reference: https://github.com/apple/container/pull/299
const args = runner === 'container' ? ['ls', '--quiet'] : ['ps', '--quiet'];

await spawn({
command: runner,
args: ['ps', '--quiet'],
args,
silentOut: true
});
} catch (_e: unknown) {
Expand All @@ -54,13 +59,27 @@ export const hasExistingContainer = async ({
> => {
try {
let output = '';

const args =
runner === 'container' ? ['ls', '-aq'] : ['ps', '-aq', '-f', `name=^/${containerName}$`];

await spawn({
command: runner,
args: ['ps', '-aq', '-f', `name=^/${containerName}$`],
args,
stdout: (o) => (output += o),
silentOut: true
});

if (runner === 'container') {
const exist = output
.split(/\r?\n/)
.map((line) => line.trim())
.filter(notEmptyString)
.some((name) => name === containerName);

return {exist};
}

return {exist: output.trim().length > 0};
} catch (err: unknown) {
return {err};
Expand All @@ -75,13 +94,29 @@ export const isContainerRunning = async ({
> => {
try {
let output = '';

const args =
runner === 'container'
? ['ls', '--quiet']
: ['ps', '--quiet', '-f', `name=^/${containerName}$`];

await spawn({
command: runner,
args: ['ps', '--quiet', '-f', `name=^/${containerName}$`],
args,
stdout: (o) => (output += o),
silentOut: true
});

if (runner === 'container') {
const running = output
.split(/\r?\n/)
.map((line) => line.trim())
.filter(notEmptyString)
.some((name) => name === containerName);

return {running};
}

return {running: output.trim().length > 0};
} catch (err: unknown) {
return {err};
Expand Down
Loading