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
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
JUNO_URL=http://localhost:5173
CLI_PROJECT_NAME=juno-dev
1 change: 0 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
JUNO_URL=https://console.juno.build
CLI_PROJECT_NAME=juno
1 change: 0 additions & 1 deletion src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const AUTH_URL = `${process.env.JUNO_URL}/cli`;
export const CLI_PROJECT_NAME = process.env.CLI_PROJECT_NAME ?? 'juno';
export const CLI_SETTINGS_NAME = `${CLI_PROJECT_NAME}-cli-settings`;
export const REDIRECT_URL = 'http://localhost:{port}';
Expand Down
3 changes: 2 additions & 1 deletion src/constants/help.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const OPTIONS_UPGRADE = `${yellow('--clear-chunks')} Clear any pre
${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.`;
${yellow('--container-url')} Override a custom container URL. If not provided, defaults to production or the local container in development mode.
${yellow('--console-url')} Specify a custom URL to access the developer Console.`;

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: 9 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import type {JunoConfigEnv} from '@junobuild/config';

export type JunoCliEnv = JunoConfigEnv & {
containerUrl: string | undefined;
authUrl: 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'});
const consoleUrl = nextArg({args, option: '--console-url'});

const envContainerUrl =
containerUrl ?? (mode === 'development' ? 'http://127.0.0.1:5987' : undefined);
const envConsoleUrl =
consoleUrl ?? (mode === 'development' ? 'http://localhost:5866' : 'https://console.juno.build');

return {
mode: mode ?? 'production',
containerUrl: containerUrl ?? (mode === 'development' ? 'http://127.0.0.1:5987' : undefined)
containerUrl: envContainerUrl,
authUrl: `${envConsoleUrl}/cli`
};
};

Expand Down
5 changes: 3 additions & 2 deletions src/utils/auth.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {AUTH_URL, REDIRECT_URL} from '../constants/constants';
import {REDIRECT_URL} from '../constants/constants';
import {ENV} from '../env';

export const authUrl = ({
port,
Expand All @@ -11,7 +12,7 @@ export const authUrl = ({
}): string => {
const callbackUrl = authCallbackUrl({port, nonce});

const authUrl = new URL(AUTH_URL);
const authUrl = new URL(ENV.authUrl);
authUrl.searchParams.set('redirect_uri', encodeURIComponent(callbackUrl));
authUrl.searchParams.set('principal', principal);

Expand Down