File tree Expand file tree Collapse file tree 2 files changed +12
-22
lines changed
Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -78,13 +78,22 @@ export default class LightningDevComponent extends SfCommand<ComponentPreviewRes
7878 // If local dev is not enabled, prompt the user to enable local dev
7979 const setupConnection = targetOrg . getConnection ( undefined ) ;
8080 const isLightningPreviewEnabled = await MetaUtils . isLightningPreviewEnabled ( setupConnection ) ;
81+
8182 if ( ! isLightningPreviewEnabled ) {
82- const enableLocalDev = await PromptUtils . promptUserToEnableLocalDev ( ) ;
83+ const autoEnableLocalDev = process . env . AUTO_ENABLE_LOCAL_DEV ;
84+
85+ // If executed via VSCode command, autoEnableLocalDev will contain the users choice, provided via UI.
86+ // Else, prompt the user on the command line.
87+ const enableLocalDev =
88+ autoEnableLocalDev !== undefined
89+ ? autoEnableLocalDev === 'true'
90+ : await PromptUtils . promptUserToEnableLocalDev ( ) ;
91+
8392 if ( enableLocalDev ) {
8493 try {
85- await MetaUtils . ensureLightningPreviewEnabled ( setupConnection ) ;
94+ await MetaUtils . setLightningPreviewEnabled ( setupConnection , true ) ;
8695 await MetaUtils . ensureFirstPartyCookiesNotRequired ( setupConnection ) ;
87- this . log ( 'Local dev is now enabled for this org.' ) ;
96+ this . log ( 'Local dev has been enabled for this org.' ) ;
8897 } catch ( error ) {
8998 this . log ( 'Error autoenabling local dev' , error ) ;
9099 }
Original file line number Diff line number Diff line change @@ -199,25 +199,6 @@ export class MetaUtils {
199199 this . logger . debug ( 'Successfully updated first-party cookie requirement' ) ;
200200 }
201201
202- /**
203- * Ensures Lightning Preview is enabled for the org. If it's not enabled, this method will enable it.
204- *
205- * @param connection the connection to the org
206- * @returns boolean indicating whether Lightning Preview was already enabled (true) or had to be enabled (false)
207- */
208- public static async ensureLightningPreviewEnabled ( connection : Connection ) : Promise < boolean > {
209- const isEnabled = await this . isLightningPreviewEnabled ( connection ) ;
210-
211- if ( ! isEnabled ) {
212- this . logger . info ( 'Lightning Preview is not enabled. Enabling it now...' ) ;
213- await this . setLightningPreviewEnabled ( connection , true ) ;
214- return false ;
215- }
216-
217- this . logger . debug ( 'Lightning Preview is already enabled' ) ;
218- return true ;
219- }
220-
221202 /**
222203 * Ensures first-party cookies are not required for the org. If they are required, this method will disable the requirement.
223204 *
You can’t perform that action at this time.
0 commit comments