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
36 changes: 34 additions & 2 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
import {config as configServices} from '../services/config/config.services';
import {red} from 'kleur';
import {logHelpConfigApply} from '../help/config.apply.help';
import {logHelpConfig} from '../help/config.help';
import {logHelpConfigInit} from '../help/config.init.help';
import {applyConfig} from '../services/config/apply.services';
import {init} from '../services/config/init.services';

export const config = async (args?: string[]) => {
await configServices(args);
const [subCommand] = args ?? [];

switch (subCommand) {
case 'apply':
await applyConfig(args);
break;
case 'init':
await init(args);
break;
default:
console.log(red('Unknown subcommand.'));
logHelpConfig(args);
}
};

export const helpConfig = (args?: string[]) => {
const [subCommand] = args ?? [];

switch (subCommand) {
case 'apply':
logHelpConfigApply(args);
break;
case 'init':
logHelpConfigInit(args);
break;
default:
logHelpConfig(args);
}
};
16 changes: 16 additions & 0 deletions src/commands/deprecated/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {logHelpInit} from '../../help/deprecated/init.help';
import {init as initServices} from '../../services/config/init.services';

/**
* @deprecated alias for backwards compatibility
*/
export const init = async (args?: string[]) => {
await initServices(args);
};

/**
* @deprecated
*/
export const helpInit = (args?: string[]) => {
logHelpInit(args);
};
51 changes: 0 additions & 51 deletions src/commands/init.ts

This file was deleted.

6 changes: 4 additions & 2 deletions src/constants/help.constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {magenta, yellow} from 'kleur';

export const CHANGES_DESCRIPTION = 'Review and apply changes submitted to your module.';
export const CONFIG_DESCRIPTION = 'Apply configuration to satellite.';
export const HOSTING_DESCRIPTION =
'Deploy or clear the frontend code of your app on your satellite.';
export const CONFIG_DESCRIPTION = 'Manage your project configuration';
export const EMULATOR_DESCRIPTION =
'Handle tasks related to the emulator like starting/stopping a local network.';
export const FUNCTIONS_DESCRIPTION = "Build and upgrade your satellite's serverless functions.";
export const INIT_DESCRIPTION = 'Set up your project.';
export const LOGIN_DESCRIPTION =
'Generate an authentication for use in non-interactive environments.';
export const LOGOUT_DESCRIPTION =
Expand All @@ -23,6 +22,9 @@ export const WHOAMI_DESCRIPTION =
'Display your current profile, access key, and links to your satellite.';
export const RUN_DESCRIPTION = 'Run a custom script in the CLI context.';

export const CONFIG_APPLY_DESCRIPTION = 'Apply configuration to satellite.';
export const CONFIG_INIT_DESCRIPTION = 'Set up your project by creating a config file.';

export const HOSTING_DEPLOY_DESCRIPTION = 'Deploy your app to your satellite.';
export const HOSTING_CLEAR_DESCRIPTION =
'Remove frontend files (JS, HTML, CSS, etc.) from your satellite.';
Expand Down
29 changes: 29 additions & 0 deletions src/help/config.apply.help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {CONFIG_APPLY_DESCRIPTION, OPTIONS_ENV, OPTION_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = `Usage: ${green('juno')} ${cyan('config')} ${magenta('apply')} ${yellow('[options]')}

Options:
${yellow('--force')} Overwrite configuration without checks.
${OPTIONS_ENV}
${OPTION_HELP}`;

const doc = `${CONFIG_APPLY_DESCRIPTION}

\`\`\`
${usage}
\`\`\`
`;

const help = `${TITLE}

${CONFIG_APPLY_DESCRIPTION}

${usage}
`;

export const logHelpConfigApply = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
17 changes: 10 additions & 7 deletions src/help/config.help.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import {cyan, green, yellow} from 'kleur';
import {CONFIG_DESCRIPTION, OPTIONS_ENV, OPTION_HELP} from '../constants/help.constants';
import {cyan, green, magenta, yellow} from 'kleur';
import {
CONFIG_APPLY_DESCRIPTION,
CONFIG_DESCRIPTION,
CONFIG_INIT_DESCRIPTION
} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = `Usage: ${green('juno')} ${cyan('config')} ${yellow('[options]')}
const usage = `Usage: ${green('juno')} ${cyan('config')} ${magenta('<subcommand>')} ${yellow('[options]')}

Options:
${yellow('--force')} Overwrite configuration without checks.
${OPTIONS_ENV}
${OPTION_HELP}`;
Subcommands:
${magenta('apply')} ${CONFIG_APPLY_DESCRIPTION}
${magenta('init')} ${CONFIG_INIT_DESCRIPTION}`;

const doc = `${CONFIG_DESCRIPTION}

Expand Down
29 changes: 29 additions & 0 deletions src/help/config.init.help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {CONFIG_INIT_DESCRIPTION, OPTION_HELP, OPTIONS_ENV} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = `Usage: ${green('juno')} ${cyan('config')} ${magenta('init')} ${yellow('[options]')}

Options:
${yellow('--minimal')} Skip few prompts and generate a config file with a placeholder satellite ID.
${OPTIONS_ENV}
${OPTION_HELP}`;

const doc = `${CONFIG_INIT_DESCRIPTION}

\`\`\`
${usage}
\`\`\`
`;

const help = `${TITLE}

${CONFIG_INIT_DESCRIPTION}

${usage}
`;

export const logHelpConfigInit = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
24 changes: 24 additions & 0 deletions src/help/deprecated/init.help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {CONFIG_INIT_DESCRIPTION} from '../../constants/help.constants';
import {helpOutput} from '../common.help';
import {TITLE} from '../help';

const usage = `Alias for: ${green('juno')} ${cyan('config')} ${magenta('init')} ${yellow('[options]')}`;

const doc = `${CONFIG_INIT_DESCRIPTION}

\`\`\`
${usage}
\`\`\`
`;

const help = `${TITLE}

${CONFIG_INIT_DESCRIPTION}

${usage}
`;

export const logHelpInit = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
2 changes: 0 additions & 2 deletions src/help/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
EMULATOR_DESCRIPTION,
FUNCTIONS_DESCRIPTION,
HOSTING_DESCRIPTION,
INIT_DESCRIPTION,
LOGIN_DESCRIPTION,
LOGOUT_DESCRIPTION,
OPEN_DESCRIPTION,
Expand Down Expand Up @@ -38,7 +37,6 @@ Commands:
${cyan('functions')} ${FUNCTIONS_DESCRIPTION}
${cyan('help')} Display help information.
${cyan('hosting')} ${HOSTING_DESCRIPTION}
${cyan('init')} ${INIT_DESCRIPTION}
${cyan('login')} ${LOGIN_DESCRIPTION}
${cyan('logout')} ${LOGOUT_DESCRIPTION}
${cyan('open')} ${OPEN_DESCRIPTION}
Expand Down
29 changes: 0 additions & 29 deletions src/help/init.help.ts

This file was deleted.

10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {hasArgs} from '@junobuild/cli-tools';
import {red} from 'kleur';
import {login, logout} from './commands/auth';
import {changes, helpChanges} from './commands/changes';
import {config} from './commands/config';
import {config, helpConfig} from './commands/config';
import {clear, helpClear} from './commands/deprecated/clear';
import {deploy, helpDeploy} from './commands/deprecated/deploy';
import {dev, helpDev} from './commands/deprecated/dev';
import {helpInit, init} from './commands/deprecated/init';
import {emulator, helpEmulator} from './commands/emulator';
import {functions, helpFunctions} from './commands/functions';
import {helpHosting, hosting} from './commands/hosting';
import {init} from './commands/init';
import {open} from './commands/open';
import {helpRun, run as runCmd} from './commands/run';
import {snapshot} from './commands/snapshot';
Expand All @@ -18,9 +18,7 @@ import {status} from './commands/status';
import {upgrade} from './commands/upgrade';
import {version as versionCommand} from './commands/version';
import {whoami} from './commands/whoami';
import {logHelpConfig} from './help/config.help';
import {help} from './help/help';
import {logHelpInit} from './help/init.help';
import {logHelpLogin} from './help/login.help';
import {logHelpLogout} from './help/logout.help';
import {logHelpOpen} from './help/open.help';
Expand Down Expand Up @@ -71,7 +69,7 @@ export const run = async () => {
logHelpOpen(args);
break;
case 'config':
logHelpConfig(args);
helpConfig(args);
break;
case 'clear':
helpClear(args);
Expand Down Expand Up @@ -99,7 +97,7 @@ export const run = async () => {
logHelpSnapshot(args);
break;
case 'init':
logHelpInit(args);
helpInit(args);
break;
case 'logout':
logHelpLogout(args);
Expand Down
6 changes: 3 additions & 3 deletions src/services/assets/deploy.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {isEmptyString} from '@dfinity/utils';
import {hasArgs, nextArg} from '@junobuild/cli-tools';
import {yellow} from 'kleur';
import {compare} from 'semver';
import {init} from '../../commands/init';
import {noJunoConfig} from '../../configs/juno.config';
import {type DeployOptions} from '../../types/deploy';
import {clearProposalStagedAssets} from '../changes/changes.clear.services';
import {config} from '../config/config.services';
import {applyConfig} from '../config/apply.services';
import {init} from '../config/init.services';
import {links} from '../links.services';
import {getSatelliteVersion} from '../version.services';
import {deployImmediate} from './_deploy/deploy.individual.services';
Expand All @@ -22,7 +22,7 @@ export const deploy = async (args?: string[]) => {
const configOption = hasArgs({args, options: ['--config']});
if (configOption) {
console.log('');
await config(args);
await applyConfig(args);
}

await links();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type SetConfigResults = [

type EditConfig = Omit<SatelliteConfig, 'assertions'>;

export const config = async (args?: string[]) => {
export const applyConfig = async (args?: string[]) => {
const {satellite, satelliteConfig} = await assertConfigAndLoadSatelliteContext();
const {satelliteId} = satellite;

Expand Down Expand Up @@ -87,7 +87,7 @@ export const config = async (args?: string[]) => {
}

// Effectively update the configurations and collections of the Satellite
const results = await applyConfig({satellite, editConfig});
const results = await executeSetConfigs({satellite, editConfig});

// Save the new hashes in the CLI state
saveLastAppliedConfigHashes({
Expand Down Expand Up @@ -251,7 +251,7 @@ const loadCurrentConfig = async (params: {
}
};

const applyConfig = async ({
const executeSetConfigs = async ({
satellite,
editConfig
}: {
Expand Down
Loading