diff --git a/package-lock.json b/package-lock.json index 66fb8ad..687cbb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,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", @@ -1735,14 +1735,14 @@ } }, "node_modules/@junobuild/config": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@junobuild/config/-/config-2.6.0.tgz", - "integrity": "sha512-yZhRmitD6ykXXSEK4l/6N6CB83gqW9PlI5+seikWJUsOdTQA9nQaVnCPZRGACvqPzfkp5tbsjl9r8buJdFrSWA==", + "version": "2.6.0-next-2025-11-15.1", + "resolved": "https://registry.npmjs.org/@junobuild/config/-/config-2.6.0-next-2025-11-15.1.tgz", + "integrity": "sha512-8SVbS+IaVYhtslTonEmicTifyAesxcMQL2u2y+71b5G63TsKqLj1EmEPxS4Krf1poofM9Has7MTNasdGv3/RLQ==", "license": "MIT", "peer": true, "peerDependencies": { - "@dfinity/zod-schemas": "^3", - "zod": "^4" + "@dfinity/zod-schemas": "*", + "zod": "*" } }, "node_modules/@junobuild/config-loader": { @@ -7842,9 +7842,9 @@ } }, "@junobuild/config": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@junobuild/config/-/config-2.6.0.tgz", - "integrity": "sha512-yZhRmitD6ykXXSEK4l/6N6CB83gqW9PlI5+seikWJUsOdTQA9nQaVnCPZRGACvqPzfkp5tbsjl9r8buJdFrSWA==", + "version": "2.6.0-next-2025-11-15.1", + "resolved": "https://registry.npmjs.org/@junobuild/config/-/config-2.6.0-next-2025-11-15.1.tgz", + "integrity": "sha512-8SVbS+IaVYhtslTonEmicTifyAesxcMQL2u2y+71b5G63TsKqLj1EmEPxS4Krf1poofM9Has7MTNasdGv3/RLQ==", "peer": true, "requires": {} }, diff --git a/package.json b/package.json index 3287199..02c8046 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/services/emulator/_runner.services.ts b/src/services/emulator/_runner.services.ts index 81948f2..826bf02 100644 --- a/src/services/emulator/_runner.services.ts +++ b/src/services/emulator/_runner.services.ts @@ -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, @@ -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'} ] }); @@ -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}); @@ -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}`] : []), diff --git a/src/utils/runner.utils.ts b/src/utils/runner.utils.ts index 1847cc8..ce4a425 100644 --- a/src/utils/runner.utils.ts +++ b/src/utils/runner.utils.ts @@ -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'; @@ -35,9 +36,13 @@ export const assertContainerRunnerRunning = async ({ runner }: Pick) => { 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) { @@ -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}; @@ -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};