File tree Expand file tree Collapse file tree
services/modules/snapshot Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,8 +8,7 @@ import {DEV} from '../env';
88import { loginEmulatorOnly } from '../services/auth/login.emulator.services' ;
99import { login as loginServices } from '../services/auth/login.services' ;
1010import { reuseController } from '../services/controllers.services' ;
11- import { isHeadless } from '../utils/process.utils' ;
12- import { confirmAndExit } from '../utils/prompt.utils' ;
11+ import { confirmAndExitUnlessHeadlessAndDev } from '../utils/prompt.utils' ;
1312
1413export const logout = async ( ) => {
1514 await clearCliConfig ( ) ;
@@ -63,11 +62,6 @@ const emulatorLogin = async () => {
6362 return ;
6463 }
6564
66- if ( isHeadless ( ) ) {
67- await loginEmulatorOnly ( ) ;
68- return ;
69- }
70-
7165 const token = await getToken ( ) ;
7266
7367 if ( isNullish ( token ) ) {
@@ -78,7 +72,7 @@ const emulatorLogin = async () => {
7872 const identity = Ed25519KeyIdentity . fromParsedJson ( token ) ;
7973 console . log ( `🔐 Your terminal already has access: ${ green ( identity . getPrincipal ( ) . toText ( ) ) } \n` ) ;
8074
81- await confirmAndExit (
75+ await confirmAndExitUnlessHeadlessAndDev (
8276 'Would you like to overwrite the saved development authentication on this device'
8377 ) ;
8478
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import ora from 'ora';
77import { listCanisterSnapshots } from '../../../api/ic.api' ;
88import type { AssetKey } from '../../../types/asset-key' ;
99import { displaySegment } from '../../../utils/display.utils' ;
10- import { confirmAndExit } from '../../../utils/prompt.utils' ;
10+ import { confirmAndExitUnlessHeadlessAndDev } from '../../../utils/prompt.utils' ;
1111
1212const loadSnapshot = async ( {
1313 canisterId
@@ -54,7 +54,7 @@ export const loadSnapshotAndAssertOverwrite = async ({
5454 const existingSnapshotId = await loadSnapshot ( { canisterId} ) ;
5555
5656 if ( nonNullish ( existingSnapshotId ) ) {
57- await confirmAndExit (
57+ await confirmAndExitUnlessHeadlessAndDev (
5858 `A snapshot for your ${ displaySegment ( segment ) } already exists with ID 0x${ encodeSnapshotId ( existingSnapshotId ) } . Do you want to overwrite it?`
5959 ) ;
6060 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
1212import type { AssetKey } from '../../../types/asset-key' ;
1313import { displaySegment } from '../../../utils/display.utils' ;
1414import { assertNonNullishFolderExists } from '../../../utils/fs.utils' ;
15- import { confirmAndExit } from '../../../utils/prompt.utils' ;
15+ import { confirmAndExitUnlessHeadlessAndDev } from '../../../utils/prompt.utils' ;
1616import { assertMatchingJunoPackage } from './_snapshot.assert.services' ;
1717import {
1818 loadSnapshotAndAssertExist ,
@@ -56,7 +56,7 @@ export const restoreSnapshot = async ({
5656
5757 const { snapshotId : existingSnapshotId } = result ;
5858
59- await confirmAndExit (
59+ await confirmAndExitUnlessHeadlessAndDev (
6060 `Restoring the snapshot 0x${ encodeSnapshotId ( existingSnapshotId ) } will permanently overwrite the current state of your ${ displaySegment ( segment ) } . Are you sure you want to proceed?`
6161 ) ;
6262
@@ -84,7 +84,7 @@ export const deleteSnapshot = async ({
8484
8585 const { snapshotId : existingSnapshotId } = result ;
8686
87- await confirmAndExit (
87+ await confirmAndExitUnlessHeadlessAndDev (
8888 `Are you sure you want to delete the snapshot 0x${ encodeSnapshotId ( existingSnapshotId ) } of your ${ displaySegment ( segment ) } ?`
8989 ) ;
9090
Original file line number Diff line number Diff line change 11import prompts from 'prompts' ;
2+ import { DEV } from '../env' ;
3+ import { isHeadless } from './process.utils' ;
24
35export const NEW_CMD_LINE = '\n ' ;
46
@@ -46,3 +48,11 @@ export const confirmAndExit = async (message: string) => {
4648 process . exit ( 1 ) ;
4749 }
4850} ;
51+
52+ export const confirmAndExitUnlessHeadlessAndDev = async ( message : string ) => {
53+ if ( isHeadless ( ) && DEV ) {
54+ return ;
55+ }
56+
57+ await confirmAndExit ( message ) ;
58+ } ;
You can’t perform that action at this time.
0 commit comments