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
4 changes: 2 additions & 2 deletions src/commands/clear.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
@@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions src/configs/juno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const junoConfigExist = async (): Promise<boolean> => {
return await junoConfigExistTools(JUNO_CONFIG_FILE);
};

export const noJunoConfig = async (): Promise<boolean> => {
return !(await junoConfigExist());
};

export const junoConfigFile = (): ConfigFile => junoConfigFileTools(JUNO_CONFIG_FILE);

export const detectJunoConfigType = (): ConfigFile | undefined =>
Expand Down
4 changes: 2 additions & 2 deletions src/services/init.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -143,7 +143,7 @@ const promptSource = async ({pm}: {pm: PackageManager | undefined}): Promise<str
};

const initConfigType = async (): Promise<PartialConfigFile> => {
if (!(await junoConfigExist())) {
if (await noJunoConfig()) {
// We try to automatically detect if we should create a TypeScript or JavaScript (mjs) configuration.
const detectedConfig = detectJunoConfigType();

Expand Down
4 changes: 2 additions & 2 deletions src/services/modules/snapshot/snapshot.satellite.services.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -28,7 +28,7 @@ const executeSnapshotFn = async ({
}: {
fn: (params: {canisterId: string; segment: AssetKey}) => Promise<void>;
}) => {
if (!(await junoConfigExist())) {
if (await noJunoConfig()) {
consoleNoConfigFound();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/satellite.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -35,7 +35,7 @@ export const assertConfigAndReadSatelliteId = async (): Promise<{satelliteId: Pr
};

const assertAndReadJunoConfig = async (): Promise<JunoConfig> => {
if (!(await junoConfigExist())) {
if (await noJunoConfig()) {
consoleNoConfigFound();
process.exit(1);
}
Expand Down