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
30 changes: 0 additions & 30 deletions src/commands/clear.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/commands/deploy.ts

This file was deleted.

16 changes: 16 additions & 0 deletions src/commands/deprecated/clear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {logHelpEmulatorClear} from '../../help/hosting.clear.help';
import {clear as clearServices} from '../../services/assets/clear.services';

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

/**
* @deprecated
*/
export const helpClear = (args?: string[]) => {
logHelpEmulatorClear(args);
};
16 changes: 16 additions & 0 deletions src/commands/deprecated/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {logHelpHostingDeploy} from '../../help/hosting.deploy.help';
import {deploy as deployServices} from '../../services/assets/deploy.services';

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

/**
* @deprecated
*/
export const helpDeploy = (args?: string[]) => {
logHelpHostingDeploy(args);
};
37 changes: 37 additions & 0 deletions src/commands/hosting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {red} from 'kleur';
import {logHelpEmulatorClear} from '../help/hosting.clear.help';
import {logHelpHostingDeploy} from '../help/hosting.deploy.help';
import {logHelpHosting} from '../help/hosting.help';
import {clear} from '../services/assets/clear.services';
import {deploy} from '../services/assets/deploy.services';

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

switch (subCommand) {
case 'deploy':
await deploy(args);
break;
case 'clear':
await clear(args);
break;
default:
console.log(red('Unknown subcommand.'));
logHelpHosting(args);
}
};

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

switch (subCommand) {
case 'deploy':
logHelpHostingDeploy(args);
break;
case 'clear':
logHelpEmulatorClear(args);
break;
default:
logHelpHosting(args);
}
};
9 changes: 6 additions & 3 deletions src/constants/help.constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {magenta, yellow} from 'kleur';

export const CHANGES_DESCRIPTION = 'Review and apply changes submitted to your module.';
export const CLEAR_DESCRIPTION =
'Clear existing app code by removing JavaScript, HTML, CSS, and other files from your satellite.';
export const CONFIG_DESCRIPTION = 'Apply configuration to satellite.';
export const DEPLOY_DESCRIPTION = 'Deploy your app to your satellite.';
export const HOSTING_DESCRIPTION =
'Deploy or clear the frontend code of your app on your satellite.';
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.";
Expand All @@ -25,6 +24,10 @@ 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 HOSTING_DEPLOY_DESCRIPTION = 'Deploy your app to your satellite.';
export const HOSTING_CLEAR_DESCRIPTION =
'Remove frontend files (JS, HTML, CSS, etc.) from your satellite.';

export const EMULATOR_START_DESCRIPTION = 'Start the emulator for local development.';
export const EMULATOR_WAIT_DESCRIPTION = 'Wait until the emulator is ready.';

Expand Down
29 changes: 0 additions & 29 deletions src/help/clear.help.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/help/help.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {cyan, green, grey} from 'kleur';
import {version} from '../../package.json';
import {
CLEAR_DESCRIPTION,
CONFIG_DESCRIPTION,
DEPLOY_DESCRIPTION,
EMULATOR_DESCRIPTION,
FUNCTIONS_DESCRIPTION,
HOSTING_DESCRIPTION,
INIT_DESCRIPTION,
LOGIN_DESCRIPTION,
LOGOUT_DESCRIPTION,
Expand Down Expand Up @@ -35,13 +34,12 @@ ${TITLE}
Usage: ${green('juno')} ${cyan('<command>')}

Commands:
${cyan('clear')} ${CLEAR_DESCRIPTION}
${cyan('config')} ${CONFIG_DESCRIPTION}
${cyan('deploy')} ${DEPLOY_DESCRIPTION}
${cyan('emulator')} ${EMULATOR_DESCRIPTION}
${cyan('functions')} ${FUNCTIONS_DESCRIPTION}
${cyan('init')} ${INIT_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: 29 additions & 0 deletions src/help/hosting.clear.help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {HOSTING_CLEAR_DESCRIPTION, OPTIONS_ENV, OPTION_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('-f, --fullPath')} Clear a particular file of your app.
${OPTIONS_ENV}
${OPTION_HELP}`;

const doc = `${HOSTING_CLEAR_DESCRIPTION}

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

const help = `${TITLE}

${HOSTING_CLEAR_DESCRIPTION}

${usage}
`;

export const logHelpEmulatorClear = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
12 changes: 6 additions & 6 deletions src/help/deploy.help.ts → src/help/hosting.deploy.help.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {cyan, green, yellow} from 'kleur';
import {cyan, green, magenta, yellow} from 'kleur';
import {
DEPLOY_DESCRIPTION,
HOSTING_DEPLOY_DESCRIPTION,
NOTE_KEEP_STAGED,
OPTION_HELP,
OPTION_KEEP_STAGED,
Expand All @@ -9,7 +9,7 @@ import {
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('--batch')} Number of files to upload in parallel per batch (default: 50).
Expand All @@ -25,7 +25,7 @@ Notes:

- ${NOTE_KEEP_STAGED}`;

const doc = `${DEPLOY_DESCRIPTION}
const doc = `${HOSTING_DEPLOY_DESCRIPTION}

\`\`\`
${usage}
Expand All @@ -34,11 +34,11 @@ ${usage}

const help = `${TITLE}

${DEPLOY_DESCRIPTION}
${HOSTING_DEPLOY_DESCRIPTION}

${usage}
`;

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

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

Subcommands:
${magenta('deploy')} ${HOSTING_DEPLOY_DESCRIPTION}
${magenta('clear')} ${HOSTING_CLEAR_DESCRIPTION}`;

const doc = `${HOSTING_DESCRIPTION}

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

const help = `${TITLE}

${HOSTING_DESCRIPTION}

${usage}
`;

export const logHelpHosting = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
21 changes: 13 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {hasArgs} from '@junobuild/cli-tools';
import {red} from 'kleur';
import {login, logout} from './commands/auth';
import {changes, helpChanges} from './commands/changes';
import {clear} from './commands/clear';
import {config} from './commands/config';
import {deploy} from './commands/deploy';
import {clear, helpClear} from './commands/deprecated/clear';
import {deploy, helpDeploy} from './commands/deprecated/deploy';
import {dev, helpDev} from './commands/dev';
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';
Expand All @@ -17,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 {logHelpClear} from './help/clear.help';
import {logHelpConfig} from './help/config.help';
import {logHelpDeploy} from './help/deploy.help';
import {help} from './help/help';
import {logHelpInit} from './help/init.help';
import {logHelpLogin} from './help/login.help';
Expand Down Expand Up @@ -71,14 +70,17 @@ export const run = async () => {
case 'open':
logHelpOpen(args);
break;
case 'clear':
logHelpClear(args);
break;
case 'config':
logHelpConfig(args);
break;
case 'clear':
helpClear(args);
break;
case 'deploy':
logHelpDeploy(args);
helpDeploy(args);
break;
case 'hosting':
helpHosting(args);
break;
case 'emulator':
helpEmulator(args);
Expand Down Expand Up @@ -170,6 +172,9 @@ export const run = async () => {
case 'emulator':
await emulator(args);
break;
case 'hosting':
await hosting(args);
break;
case 'dev':
await dev(args);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/services/assets/_deploy/deploy.individual.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type DeployOptions,
type UploadFileFnParams
} from '../../../types/deploy';
import {clear} from '../clear.services';
import {executeClear} from '../clear.services';
import {executeDeployImmediate} from './deploy.execute.services';

export const deployImmediate = async ({
Expand All @@ -16,7 +16,7 @@ export const deployImmediate = async ({
clearOption: boolean;
} & DeployOptions) => {
if (clearOption) {
await clear();
await executeClear();
}

const deployFn = async ({deploy: {params, upload}}: DeployFnParams): Promise<DeployResult> =>
Expand Down
Loading