diff --git a/src/commands/clear.ts b/src/commands/clear.ts index cc61c4fa..cffbd7fb 100644 --- a/src/commands/clear.ts +++ b/src/commands/clear.ts @@ -1,12 +1,12 @@ import {isNullish} from '@dfinity/utils'; import {hasArgs, nextArg} from '@junobuild/cli-tools'; import {yellow} from 'kleur'; -import {junoConfigExist} from '../configs/juno.config'; +import {noJunoConfig} from '../configs/juno.config'; import {clearAsset, clear as clearServices} from '../services/assets/clear.services'; import {consoleNoConfigFound} from '../utils/msg.utils'; export const clear = async (args?: string[]) => { - if (!(await junoConfigExist())) { + if (await noJunoConfig()) { consoleNoConfigFound(); return; } diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index cb65f649..c6d93cba 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -1,12 +1,12 @@ import {hasArgs} from '@junobuild/cli-tools'; -import {junoConfigExist} from '../configs/juno.config'; +import {noJunoConfig} from '../configs/juno.config'; import {deploy as deployServices} from '../services/assets/deploy.services'; import {config} from '../services/config/config.services'; import {links} from '../services/links.services'; import {init} from './init'; export const deploy = async (args?: string[]) => { - if (!(await junoConfigExist())) { + if (await noJunoConfig()) { await init(); } diff --git a/src/configs/juno.config.ts b/src/configs/juno.config.ts index 73f3b47f..72e5e296 100644 --- a/src/configs/juno.config.ts +++ b/src/configs/juno.config.ts @@ -32,6 +32,10 @@ export const junoConfigExist = async (): Promise => { return await junoConfigExistTools(JUNO_CONFIG_FILE); }; +export const noJunoConfig = async (): Promise => { + return !(await junoConfigExist()); +}; + export const junoConfigFile = (): ConfigFile => junoConfigFileTools(JUNO_CONFIG_FILE); export const detectJunoConfigType = (): ConfigFile | undefined => diff --git a/src/services/init.services.ts b/src/services/init.services.ts index 7fca7aa8..f5368e20 100644 --- a/src/services/init.services.ts +++ b/src/services/init.services.ts @@ -8,8 +8,8 @@ import prompts from 'prompts'; import {getCliOrbiters, getCliSatellites} from '../configs/cli.config'; import { detectJunoConfigType, - junoConfigExist, junoConfigFile, + noJunoConfig, writeJunoConfig, writeJunoConfigPlaceholder } from '../configs/juno.config'; @@ -143,7 +143,7 @@ const promptSource = async ({pm}: {pm: PackageManager | undefined}): Promise => { - if (!(await junoConfigExist())) { + if (await noJunoConfig()) { // We try to automatically detect if we should create a TypeScript or JavaScript (mjs) configuration. const detectedConfig = detectJunoConfigType(); diff --git a/src/services/modules/snapshot/snapshot.satellite.services.ts b/src/services/modules/snapshot/snapshot.satellite.services.ts index 6aecba84..2e1dbdd9 100644 --- a/src/services/modules/snapshot/snapshot.satellite.services.ts +++ b/src/services/modules/snapshot/snapshot.satellite.services.ts @@ -1,5 +1,5 @@ import {assertNonNullish} from '@dfinity/utils'; -import {junoConfigExist} from '../../../configs/juno.config'; +import {noJunoConfig} from '../../../configs/juno.config'; import type {AssetKey} from '../../../types/asset-key'; import {consoleNoConfigFound} from '../../../utils/msg.utils'; import {assertConfigAndLoadSatelliteContext} from '../../../utils/satellite.utils'; @@ -28,7 +28,7 @@ const executeSnapshotFn = async ({ }: { fn: (params: {canisterId: string; segment: AssetKey}) => Promise; }) => { - if (!(await junoConfigExist())) { + if (await noJunoConfig()) { consoleNoConfigFound(); return; } diff --git a/src/utils/satellite.utils.ts b/src/utils/satellite.utils.ts index 19582df7..f99b4abd 100644 --- a/src/utils/satellite.utils.ts +++ b/src/utils/satellite.utils.ts @@ -4,7 +4,7 @@ import type {JunoConfig, SatelliteConfig} from '@junobuild/config'; import {red} from 'kleur'; import {actorParameters} from '../api/actor.api'; import {getCliOrbiters, getCliSatellites} from '../configs/cli.config'; -import {junoConfigExist, readJunoConfig} from '../configs/juno.config'; +import {noJunoConfig, readJunoConfig} from '../configs/juno.config'; import {ENV} from '../env'; import type {SatelliteConfigEnv} from '../types/config'; import type {SatelliteParametersWithId} from '../types/satellite'; @@ -35,7 +35,7 @@ export const assertConfigAndReadSatelliteId = async (): Promise<{satelliteId: Pr }; const assertAndReadJunoConfig = async (): Promise => { - if (!(await junoConfigExist())) { + if (await noJunoConfig()) { consoleNoConfigFound(); process.exit(1); }