diff --git a/src/constants/help.constants.ts b/src/constants/help.constants.ts index 9b679a21..dbb80b54 100644 --- a/src/constants/help.constants.ts +++ b/src/constants/help.constants.ts @@ -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).`; diff --git a/src/env.ts b/src/env.ts index fb82ee3d..785d6a01 100644 --- a/src/env.ts +++ b/src/env.ts @@ -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' : '') }; }; diff --git a/src/help/clear.help.ts b/src/help/clear.help.ts index ff4aaa9b..3151da2d 100644 --- a/src/help/clear.help.ts +++ b/src/help/clear.help.ts @@ -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} diff --git a/src/help/common.help.ts b/src/help/common.help.ts index 1c2fcaec..44befee9 100644 --- a/src/help/common.help.ts +++ b/src/help/common.help.ts @@ -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'; diff --git a/src/help/config.help.ts b/src/help/config.help.ts index ed97ed2b..70169e74 100644 --- a/src/help/config.help.ts +++ b/src/help/config.help.ts @@ -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} diff --git a/src/help/deploy.help.ts b/src/help/deploy.help.ts index 1217d9c6..8212ec37 100644 --- a/src/help/deploy.help.ts +++ b/src/help/deploy.help.ts @@ -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]')} @@ -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: diff --git a/src/help/generic.help.ts b/src/help/generic.help.ts index 168868cd..3bc5ff50 100644 --- a/src/help/generic.help.ts +++ b/src/help/generic.help.ts @@ -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 = ( @@ -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} @@ -42,7 +42,7 @@ const docWithMode = ({ \`\`\` ${usage(command)} - ${helpMode} + ${OPTIONS_HELP} \`\`\` `; diff --git a/src/help/init.help.ts b/src/help/init.help.ts index d2955e4c..17cad108 100644 --- a/src/help/init.help.ts +++ b/src/help/init.help.ts @@ -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} diff --git a/src/help/open.help.ts b/src/help/open.help.ts index a7850302..01ad1de5 100644 --- a/src/help/open.help.ts +++ b/src/help/open.help.ts @@ -1,6 +1,6 @@ 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]')} @@ -8,7 +8,7 @@ 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} diff --git a/src/help/snapshot.help.ts b/src/help/snapshot.help.ts index 54525209..0ef2c7a4 100644 --- a/src/help/snapshot.help.ts +++ b/src/help/snapshot.help.ts @@ -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'; @@ -13,7 +13,7 @@ Subcommands: Options: ${targetOption('snapshot')} - ${helpMode} + ${OPTIONS_HELP} ${OPTION_HELP} Notes: diff --git a/src/help/start.help.ts b/src/help/start.help.ts index b28c164f..090a178c 100644 --- a/src/help/start.help.ts +++ b/src/help/start.help.ts @@ -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: diff --git a/src/help/stop.help.ts b/src/help/stop.help.ts index d6787724..1b037cc0 100644 --- a/src/help/stop.help.ts +++ b/src/help/stop.help.ts @@ -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: diff --git a/src/help/upgrade.help.ts b/src/help/upgrade.help.ts index a1e40d9e..427e1681 100644 --- a/src/help/upgrade.help.ts +++ b/src/help/upgrade.help.ts @@ -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'; @@ -15,7 +16,7 @@ Options: ${targetOption('upgrade')} ${OPTION_SRC} ${OPTIONS_UPGRADE} - ${helpMode} + ${OPTIONS_HELP} ${OPTION_HELP} Notes: diff --git a/src/help/version.help.ts b/src/help/version.help.ts index f2880916..9dcf81c0 100644 --- a/src/help/version.help.ts +++ b/src/help/version.help.ts @@ -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}