@@ -11,15 +11,15 @@ import {
1111} from '../../services' ;
1212import {
1313 DEFAULT_CONFIGURATION_ID ,
14- START_ARGS ,
1514 FLAGS ,
16- IMAGE ,
1715 PRO_IMAGE ,
16+ COMMUNITY_IMAGE ,
1817} from '../../constants' ;
1918import { LongMenu } from './Menu' ;
2019import { DockerContainer , DockerImage } from '../../types' ;
2120import { DownloadProgressDialog } from '../Feedback/DownloadProgressDialog' ;
2221import { ProgressButton } from '../Feedback' ;
22+ import { generateCLIArgs } from '../../services/util/cli' ;
2323
2424const EXCLUDED_ERROR_TOAST = [ 'INFO' , 'WARN' , 'DEBUG' ] ;
2525
@@ -28,7 +28,7 @@ export const Controller = (): ReactElement => {
2828 const { data, mutate } = useLocalStack ( ) ;
2929 const { user, os, hasSkippedConfiguration } = useMountPoint ( ) ;
3030 const [ runningConfig , setRunningConfig ] = useState < string > ( configData . runningConfig ?? DEFAULT_CONFIGURATION_ID ) ;
31- const [ downloadProps , setDownloadProps ] = useState ( { open : false , image : IMAGE } ) ;
31+ const [ downloadProps , setDownloadProps ] = useState ( { open : false , image : COMMUNITY_IMAGE } ) ;
3232 const [ isStarting , setIsStarting ] = useState < boolean > ( false ) ;
3333 const [ isStopping , setIsStopping ] = useState < boolean > ( false ) ;
3434 const ddClient = useDDClient ( ) ;
@@ -48,38 +48,49 @@ export const Controller = (): ReactElement => {
4848 }
4949 } , [ isLoading ] ) ;
5050
51-
52- const buildMountArg = ( ) => {
51+ const buildHostArgs = ( ) => {
5352 let location = 'LOCALSTACK_VOLUME_DIR=/tmp/localstack/volume' ;
53+ let homeDir = `HOME=/home/${ user } ` ;
5454
5555 if ( ! hasSkippedConfiguration ) {
5656 switch ( ddClient . host . platform ) {
5757 case 'win32' :
5858 location = `LOCALSTACK_VOLUME_DIR=\\\\wsl$\\${ os } \\home\\${ user } \\.cache\\localstack\\volume` ;
59+ homeDir = `HOME=\\\\wsl$\\${ os } \\home\\${ user } ` ;
5960 break ;
6061 case 'darwin' :
6162 location = `LOCALSTACK_VOLUME_DIR=/Users/${ user } /Library/Caches/localstack/volume` ;
63+ homeDir = `HOME=/Users/${ user } ` ;
6264 break ;
6365 default :
6466 location = `LOCALSTACK_VOLUME_DIR=/home/${ user } /.cache/localstack/volume` ;
67+ homeDir = `HOME=/home/${ user } ` ;
6568 }
6669 }
67- return [ '-e' , location ] ;
70+ return [ '-e' , location , '-e' , homeDir ] ;
6871 } ;
6972
7073 const normalizeArguments = async ( ) => {
7174 const extendedFlag = FLAGS . map ( x => x ) ; // clone
72-
75+ let isPro = false ;
7376 const addedArgs = configData . configs . find ( config => config . id === runningConfig )
7477 . vars . map ( item => {
7578 if ( item . variable === 'DOCKER_FLAGS' ) {
7679 extendedFlag [ 1 ] = FLAGS . at ( 1 ) . slice ( 0 , - 1 ) . concat ( ` ${ item . value } '` ) ;
7780 }
81+ if ( item . variable === 'LOCALSTACK_AUTH_TOKEN' ) {
82+ isPro = true ;
83+ }
7884
7985 return [ '-e' , `${ item . variable } =${ item . value } ` ] ;
8086 } ) . flat ( ) ;
8187
82- return [ ...extendedFlag , ...buildMountArg ( ) , ...addedArgs , ...START_ARGS ] ;
88+ return [
89+ ...extendedFlag ,
90+ ...buildHostArgs ( ) ,
91+ ...addedArgs ,
92+ ...generateCLIArgs ( { call : 'start' , pro : isPro } ) ,
93+ ] ;
8394 } ;
8495
8596 const start = async ( ) => {
@@ -89,26 +100,25 @@ export const Controller = (): ReactElement => {
89100 . vars . some ( item => ( item . variable === 'LOCALSTACK_API_KEY' ||
90101 item . variable === 'LOCALSTACK_AUTH_TOKEN' ) && item . value ) ;
91102
92- const haveCommunity = images . some ( image => image . RepoTags ?. at ( 0 ) === IMAGE ) ;
93- if ( ! haveCommunity ) {
94- setDownloadProps ( { open : true , image : IMAGE } ) ;
103+ const havePro = images . some ( image => removeTagFromImage ( image ) === PRO_IMAGE ) ;
104+ if ( ! havePro && isPro ) {
105+ setDownloadProps ( { open : true , image : PRO_IMAGE } ) ;
95106 return ;
96107 }
97108
98- if ( isPro ) {
99- const havePro = images . some ( image => removeTagFromImage ( image ) === PRO_IMAGE ) ;
100- if ( ! havePro ) {
101- setDownloadProps ( { open : true , image : PRO_IMAGE } ) ;
102- return ;
103- }
109+ const haveCommunity = images . some ( image => removeTagFromImage ( image ) === COMMUNITY_IMAGE ) ;
110+ if ( ! haveCommunity ) {
111+ setDownloadProps ( { open : true , image : COMMUNITY_IMAGE } ) ;
112+ return ;
104113 }
105114
106115 const args = await normalizeArguments ( ) ;
116+
107117 setIsStarting ( true ) ;
108118 ddClient . docker . cli . exec ( 'run' , args , {
109119 stream : {
110120 onOutput ( data ) : void {
111- const shouldDisplayError = ! EXCLUDED_ERROR_TOAST . some ( item => data . stderr . includes ( item ) ) ;
121+ const shouldDisplayError = ! EXCLUDED_ERROR_TOAST . some ( item => data . stderr ? .includes ( item ) ) && data . stderr ;
112122 if ( shouldDisplayError ) {
113123 ddClient . desktopUI . toast . error ( data . stderr ) ;
114124 setIsStarting ( false ) ;
0 commit comments