Skip to content

Commit 6faaf0c

Browse files
feat: rename (with alias) juno dev to juno emulator (#359)
1 parent a8a8a3b commit 6faaf0c

19 files changed

Lines changed: 115 additions & 37 deletions

src/commands/dev.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {red} from 'kleur';
22
import {logHelpDev} from '../help/dev.help';
3-
import {logHelpDevStart} from '../help/dev.start.help';
4-
import {logHelpDevWait} from '../help/dev.wait.help';
3+
import {logHelpEmulatorStart} from '../help/emulator.start.help';
4+
import {logHelpEmulatorWait} from '../help/emulator.wait.help';
55
import {logHelpFunctionsBuild} from '../help/functions.build.help';
66
import {logHelpFunctionsEject} from '../help/functions.eject.help';
7-
import {start} from '../services/dev/start.services';
8-
import {stop} from '../services/dev/stop.services';
9-
import {wait} from '../services/dev/wait.services';
7+
import {start} from '../services/emulator/start.services';
8+
import {stop} from '../services/emulator/stop.services';
9+
import {wait} from '../services/emulator/wait.services';
1010
import {build} from '../services/functions/build/build.services';
1111
import {eject} from '../services/functions/eject/eject.services';
1212

@@ -40,10 +40,10 @@ export const helpDev = (args?: string[]) => {
4040

4141
switch (subCommand) {
4242
case 'start':
43-
logHelpDevStart(args);
43+
logHelpEmulatorStart(args);
4444
break;
4545
case 'wait':
46-
logHelpDevWait(args);
46+
logHelpEmulatorWait(args);
4747
break;
4848
case 'build':
4949
logHelpFunctionsBuild(args);

src/commands/emulator.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {red} from 'kleur';
2+
import {logHelpEmulator} from '../help/emulator.help';
3+
import {logHelpEmulatorStart} from '../help/emulator.start.help';
4+
import {logHelpEmulatorWait} from '../help/emulator.wait.help';
5+
import {start} from '../services/emulator/start.services';
6+
import {stop} from '../services/emulator/stop.services';
7+
import {wait} from '../services/emulator/wait.services';
8+
9+
export const emulator = async (args?: string[]) => {
10+
const [subCommand] = args ?? [];
11+
12+
switch (subCommand) {
13+
case 'start':
14+
await start(args);
15+
break;
16+
case 'stop':
17+
await stop();
18+
break;
19+
case 'wait':
20+
await wait(args);
21+
break;
22+
default:
23+
console.log(red('Unknown subcommand.'));
24+
logHelpEmulator(args);
25+
}
26+
};
27+
28+
export const helpEmulator = (args?: string[]) => {
29+
const [subCommand] = args ?? [];
30+
31+
switch (subCommand) {
32+
case 'start':
33+
logHelpEmulatorStart(args);
34+
break;
35+
case 'wait':
36+
logHelpEmulatorWait(args);
37+
break;
38+
default:
39+
logHelpEmulator(args);
40+
}
41+
};

src/constants/help.constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export const CLEAR_DESCRIPTION =
55
'Clear existing app code by removing JavaScript, HTML, CSS, and other files from your satellite.';
66
export const CONFIG_DESCRIPTION = 'Apply configuration to satellite.';
77
export const DEPLOY_DESCRIPTION = 'Deploy your app to your satellite.';
8-
export const DEV_DESCRIPTION = 'Handle developer tasks like starting/stopping a local network.';
8+
export const EMULATOR_DESCRIPTION =
9+
'Handle tasks related to the emulator like starting/stopping a local network.';
910
export const FUNCTIONS_DESCRIPTION = "Build and upgrade your satellite's serverless functions.";
1011
export const INIT_DESCRIPTION = 'Set up your project.';
1112
export const LOGIN_DESCRIPTION =
@@ -23,8 +24,8 @@ export const STATUS_DESCRIPTION = 'Check the status of the modules.';
2324
export const WHOAMI_DESCRIPTION =
2425
'Display your current profile, access key, and links to your satellite.';
2526

26-
export const DEV_START_DESCRIPTION = 'Start a local Internet Computer network in a container.';
27-
export const DEV_WAIT_DESCRIPTION = 'Wait until the emulator is ready.';
27+
export const EMULATOR_START_DESCRIPTION = 'Start the emulator for local development.';
28+
export const EMULATOR_WAIT_DESCRIPTION = 'Wait until the emulator is ready.';
2829

2930
export const FUNCTIONS_PUBLISH_DESCRIPTION = 'Publish a new version of your serverless functions.';
3031
export const FUNCTIONS_UPGRADE_DESCRIPTION = 'Upgrade your serverless functions.';

src/help/dev.help.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import {cyan, green, magenta, yellow} from 'kleur';
2-
import {
3-
DEV_DESCRIPTION,
4-
DEV_START_DESCRIPTION,
5-
DEV_WAIT_DESCRIPTION
6-
} from '../constants/help.constants';
2+
import {EMULATOR_DESCRIPTION} from '../constants/help.constants';
73
import {helpOutput} from './common.help';
84
import {TITLE} from './help';
95

106
const usage = `Usage: ${green('juno')} ${cyan('dev')} ${magenta('<subcommand>')} ${yellow('[options]')}
117
128
Subcommands:
13-
${magenta('start')} ${DEV_START_DESCRIPTION}
14-
${magenta('stop')} Stop the local network.
15-
${magenta('wait')} ${DEV_WAIT_DESCRIPTION}
9+
${magenta('start')} Alias for ${green('juno')} ${cyan('emulator')} ${magenta('start')}.
10+
${magenta('stop')} Alias for ${green('juno')} ${cyan('emulator')} ${magenta('stop')}.
11+
${magenta('wait')} Alias for ${green('juno')} ${cyan('emulator')} ${magenta('wait')}.
1612
${magenta('build')} Alias for ${green('juno')} ${cyan('functions')} ${magenta('build')}.
1713
${magenta('eject')} Alias for ${green('juno')} ${cyan('functions')} ${magenta('eject')}.`;
1814

19-
const doc = `${DEV_DESCRIPTION}
15+
const doc = `${EMULATOR_DESCRIPTION}
2016
2117
\`\`\`
2218
${usage}
@@ -25,7 +21,7 @@ ${usage}
2521

2622
const help = `${TITLE}
2723
28-
${DEV_DESCRIPTION}
24+
${EMULATOR_DESCRIPTION}
2925
3026
${usage}
3127
`;

src/help/emulator.help.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {cyan, green, magenta, yellow} from 'kleur';
2+
import {
3+
EMULATOR_DESCRIPTION,
4+
EMULATOR_START_DESCRIPTION,
5+
EMULATOR_WAIT_DESCRIPTION
6+
} from '../constants/help.constants';
7+
import {helpOutput} from './common.help';
8+
import {TITLE} from './help';
9+
10+
const usage = `Usage: ${green('juno')} ${cyan('emulator')} ${magenta('<subcommand>')} ${yellow('[options]')}
11+
12+
Subcommands:
13+
${magenta('start')} ${EMULATOR_START_DESCRIPTION}
14+
${magenta('stop')} Stop the local network.
15+
${magenta('wait')} ${EMULATOR_WAIT_DESCRIPTION}`;
16+
17+
const doc = `${EMULATOR_DESCRIPTION}
18+
19+
\`\`\`
20+
${usage}
21+
\`\`\`
22+
`;
23+
24+
const help = `${TITLE}
25+
26+
${EMULATOR_DESCRIPTION}
27+
28+
${usage}
29+
`;
30+
31+
export const logHelpEmulator = (args?: string[]) => {
32+
console.log(helpOutput(args) === 'doc' ? doc : help);
33+
};
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {cyan, green, magenta, yellow} from 'kleur';
22
import {
3-
DEV_START_DESCRIPTION,
3+
EMULATOR_START_DESCRIPTION,
44
FUNCTIONS_BUILD_NOTES,
55
OPTION_HELP,
66
OPTIONS_BUILD
77
} from '../constants/help.constants';
88
import {helpOutput} from './common.help';
99
import {TITLE} from './help';
1010

11-
const usage = `Usage: ${green('juno')} ${cyan('dev')} ${magenta('start')} ${yellow('[options]')}
11+
const usage = `Usage: ${green('juno')} ${cyan('emulator')} ${magenta('start')} ${yellow('[options]')}
1212
1313
Options:
1414
${OPTIONS_BUILD}
@@ -20,7 +20,7 @@ Notes:
2020
- The language and path options are only used in combination with watch.
2121
${FUNCTIONS_BUILD_NOTES}`;
2222

23-
const doc = `${DEV_START_DESCRIPTION}
23+
const doc = `${EMULATOR_START_DESCRIPTION}
2424
2525
\`\`\`
2626
${usage}
@@ -29,11 +29,11 @@ ${usage}
2929

3030
const help = `${TITLE}
3131
32-
${DEV_START_DESCRIPTION}
32+
${EMULATOR_START_DESCRIPTION}
3333
3434
${usage}
3535
`;
3636

37-
export const logHelpDevStart = (args?: string[]) => {
37+
export const logHelpEmulatorStart = (args?: string[]) => {
3838
console.log(helpOutput(args) === 'doc' ? doc : help);
3939
};
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {cyan, green, magenta, yellow} from 'kleur';
2-
import {DEV_WAIT_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
2+
import {EMULATOR_WAIT_DESCRIPTION, OPTION_HELP} from '../constants/help.constants';
33
import {helpOutput} from './common.help';
44
import {TITLE} from './help';
55

@@ -9,7 +9,7 @@ Options:
99
${yellow('-t, --timeout')} Timeout for the emulator to be ready (in ms, default 2min).
1010
${OPTION_HELP}`;
1111

12-
const doc = `${DEV_WAIT_DESCRIPTION}
12+
const doc = `${EMULATOR_WAIT_DESCRIPTION}
1313
1414
\`\`\`
1515
${usage}
@@ -18,11 +18,11 @@ ${usage}
1818

1919
const help = `${TITLE}
2020
21-
${DEV_WAIT_DESCRIPTION}
21+
${EMULATOR_WAIT_DESCRIPTION}
2222
2323
${usage}
2424
`;
2525

26-
export const logHelpDevWait = (args?: string[]) => {
26+
export const logHelpEmulatorWait = (args?: string[]) => {
2727
console.log(helpOutput(args) === 'doc' ? doc : help);
2828
};

src/help/help.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
CLEAR_DESCRIPTION,
55
CONFIG_DESCRIPTION,
66
DEPLOY_DESCRIPTION,
7-
DEV_DESCRIPTION,
7+
EMULATOR_DESCRIPTION,
88
FUNCTIONS_DESCRIPTION,
99
INIT_DESCRIPTION,
1010
LOGIN_DESCRIPTION,
@@ -38,7 +38,7 @@ Commands:
3838
${cyan('clear')} ${CLEAR_DESCRIPTION}
3939
${cyan('config')} ${CONFIG_DESCRIPTION}
4040
${cyan('deploy')} ${DEPLOY_DESCRIPTION}
41-
${cyan('dev')} ${DEV_DESCRIPTION}
41+
${cyan('dev')} ${EMULATOR_DESCRIPTION}
4242
${cyan('functions')} ${FUNCTIONS_DESCRIPTION}
4343
${cyan('init')} ${INIT_DESCRIPTION}
4444
${cyan('help')} Display help information.

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {clear} from './commands/clear';
66
import {config} from './commands/config';
77
import {deploy} from './commands/deploy';
88
import {dev, helpDev} from './commands/dev';
9+
import {emulator, helpEmulator} from './commands/emulator';
910
import {functions, helpFunctions} from './commands/functions';
1011
import {init} from './commands/init';
1112
import {open} from './commands/open';
@@ -78,6 +79,9 @@ export const run = async () => {
7879
case 'deploy':
7980
logHelpDeploy(args);
8081
break;
82+
case 'emulator':
83+
helpEmulator(args);
84+
break;
8185
case 'dev':
8286
helpDev(args);
8387
break;
@@ -159,6 +163,9 @@ export const run = async () => {
159163
case 'start':
160164
await startStop({args, action: 'start'});
161165
break;
166+
case 'emulator':
167+
await emulator(args);
168+
break;
162169
case 'dev':
163170
await dev(args);
164171
break;

src/services/auth/login.emulator.services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {readEmulatorConfig} from '../../configs/emulator.config';
77
import {ENV} from '../../env';
88
import {generateToken} from '../../utils/auth.utils';
99
import {assertConfigAndReadSatelliteId} from '../../utils/satellite.utils';
10-
import {dispatchRequest} from '../emulator/emulator.admin.services';
10+
import {dispatchRequest} from '../emulator/admin.services';
1111

1212
export const loginEmulatorOnly = async () => {
1313
const spinner = ora('Granting terminal access...').start();

0 commit comments

Comments
 (0)