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
2 changes: 2 additions & 0 deletions src/constants/help.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ export const OPTION_SRC = `${yellow('-s, --src')} A path to a specif
export const OPTIONS_UPGRADE = `${yellow('--clear-chunks')} Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB).
${yellow('--no-snapshot')} Skip creating a snapshot before upgrading.
${yellow('-r, --reset')} Reset to the initial state.`;
export const OPTIONS_HELP = `${yellow('-m, --mode')} Set env mode. For example production or a custom string. Default is production.
${yellow('--container-url')} Override a custom container URL. If not provided, defaults to production or the local container in development mode.`;

export const NOTE_KEEP_STAGED = `The option ${yellow('--keep-staged')} only applies when ${yellow('--no-apply')} is NOT used (i.e. the change is applied immediately).`;
10 changes: 8 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import {nextArg} from '@junobuild/cli-tools';
import type {JunoConfigEnv} from '@junobuild/config';

const loadEnv = (): JunoConfigEnv => {
export type JunoCliEnv = JunoConfigEnv & {
containerUrl?: string;
};

const loadEnv = (): JunoCliEnv => {
const [_, ...args] = process.argv.slice(2);

const mode = nextArg({args, option: '-m'}) ?? nextArg({args, option: '--mode'});
const containerUrl = nextArg({args, option: '--container-url'});

return {
mode: mode ?? 'production'
mode: mode ?? 'production',
containerUrl: containerUrl ?? (mode === 'development' ? 'http://127.0.0.1:5987' : '')
};
};

Expand Down
6 changes: 3 additions & 3 deletions src/help/clear.help.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {cyan, green, yellow} from 'kleur';
import {CLEAR_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {CLEAR_DESCRIPTION, OPTIONS_HELP, OPTION_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

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

const doc = `${CLEAR_DESCRIPTION}
Expand Down
3 changes: 0 additions & 3 deletions src/help/common.help.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {hasArgs} from '@junobuild/cli-tools';
import {yellow} from 'kleur';

export const helpMode = `${yellow('-m, --mode')} Set env mode. For example production or a custom string. Default is production.`;

export const helpOutput = (args?: string[]): 'doc' | 'cli' =>
hasArgs({args, options: ['-d', '--doc']}) ? 'doc' : 'cli';
6 changes: 3 additions & 3 deletions src/help/config.help.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {cyan, green, yellow} from 'kleur';
import {CONFIG_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {CONFIG_DESCRIPTION, OPTIONS_HELP, OPTION_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}`;

const doc = `${CONFIG_DESCRIPTION}
Expand Down
7 changes: 4 additions & 3 deletions src/help/deploy.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
DEPLOY_DESCRIPTION,
NOTE_KEEP_STAGED,
OPTION_HELP,
OPTION_KEEP_STAGED
OPTION_KEEP_STAGED,
OPTIONS_HELP
} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = `Usage: ${green('juno')} ${cyan('deploy')} ${yellow('[options]')}
Expand All @@ -15,7 +16,7 @@ Options:
${yellow('--no-apply')} Submit the deployment as a change but do not apply it yet.
${OPTION_KEEP_STAGED}
${yellow('-i, --immediate')} Deploy files instantly (bypasses the change workflow).
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}

Notes:
Expand Down
8 changes: 4 additions & 4 deletions src/help/generic.help.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {cyan, green, yellow} from 'kleur';
import {OPTION_HELP} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPTIONS_HELP, OPTION_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = (
Expand All @@ -22,7 +22,7 @@ const helpWithMode = ({command, description}: {command: string; description: str
${description}

${usage(command)}
${helpMode}
${OPTIONS_HELP}
`;

const doc = ({command, description}: {command: string; description: string}) => `${description}
Expand All @@ -42,7 +42,7 @@ const docWithMode = ({

\`\`\`
${usage(command)}
${helpMode}
${OPTIONS_HELP}
\`\`\`
`;

Expand Down
6 changes: 3 additions & 3 deletions src/help/init.help.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {cyan, green, yellow} from 'kleur';
import {INIT_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {INIT_DESCRIPTION, OPTION_HELP, OPTIONS_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

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

const doc = `${INIT_DESCRIPTION}
Expand Down
6 changes: 3 additions & 3 deletions src/help/open.help.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {cyan, green, yellow} from 'kleur';
import {OPEN_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPEN_DESCRIPTION, OPTION_HELP, OPTIONS_HELP} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('-b, --browser')} A particular browser to open. supported: chrome|firefox|edge.
${yellow('-c, --console')} Open satellite in the console.
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}`;

const doc = `${OPEN_DESCRIPTION}
Expand Down
6 changes: 3 additions & 3 deletions src/help/snapshot.help.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {OPTION_HELP, SNAPSHOT_DESCRIPTION} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPTIONS_HELP, OPTION_HELP, SNAPSHOT_DESCRIPTION} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';
import {TARGET_OPTION_NOTE, targetOption} from './target.help';

Expand All @@ -13,7 +13,7 @@ Subcommands:

Options:
${targetOption('snapshot')}
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}

Notes:
Expand Down
6 changes: 3 additions & 3 deletions src/help/start.help.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {OPTION_HELP, START_DESCRIPTION} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPTIONS_HELP, OPTION_HELP, START_DESCRIPTION} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('-t, --target')} Which module type should be started? Valid targets are ${magenta('satellite')}, ${magenta('mission-control')} or ${magenta('orbiter')}.
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}

Notes:
Expand Down
6 changes: 3 additions & 3 deletions src/help/stop.help.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {OPTION_HELP, STOP_DESCRIPTION} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPTIONS_HELP, OPTION_HELP, STOP_DESCRIPTION} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('-t, --target')} Which module type should be stopped? Valid targets are ${magenta('satellite')}, ${magenta('mission-control')} or ${magenta('orbiter')}.
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}

Notes:
Expand Down
5 changes: 3 additions & 2 deletions src/help/upgrade.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import {cyan, green, yellow} from 'kleur';
import {
OPTION_HELP,
OPTION_SRC,
OPTIONS_HELP,
OPTIONS_UPGRADE,
UPGRADE_DESCRIPTION
} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {helpOutput} from './common.help';
import {TITLE} from './help';
import {TARGET_OPTION_NOTE, targetOption} from './target.help';

Expand All @@ -15,7 +16,7 @@ Options:
${targetOption('upgrade')}
${OPTION_SRC}
${OPTIONS_UPGRADE}
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}

Notes:
Expand Down
6 changes: 3 additions & 3 deletions src/help/version.help.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {cyan, green, yellow} from 'kleur';
import {OPTION_HELP, VERSION_DESCRIPTION} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {OPTIONS_HELP, OPTION_HELP, VERSION_DESCRIPTION} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

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

Options:
${yellow('-c, --cli')} Check only the version of the CLI.
${helpMode}
${OPTIONS_HELP}
${OPTION_HELP}`;

const doc = `${VERSION_DESCRIPTION}
Expand Down