export async function promptStartDesignTimeOption()

in apps/vs-code-designer/src/app/utils/codeless/startDesignTimeApi.ts [322:362]


export async function promptStartDesignTimeOption(context: IActionContext) {
  if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
    const logicAppFolders = await getWorkspaceLogicAppFolders();
    const showStartDesignTimeMessage = !!getWorkspaceSetting<boolean>(showStartDesignTimeMessageSetting);
    let autoStartDesignTime = !!getWorkspaceSetting<boolean>(autoStartDesignTimeSetting);

    if (logicAppFolders && logicAppFolders.length > 0) {
      if (!autoStartDesignTime && showStartDesignTimeMessage) {
        const message = localize(
          'startDesignTimeApi',
          'Always start the background design-time process at launch? The workflow designer will open faster.'
        );
        const confirm = { title: localize('yesRecommended', 'Yes (Recommended)') };
        let result: MessageItem;
        do {
          result = await context.ui.showWarningMessage(message, confirm, DialogResponses.learnMore, DialogResponses.dontWarnAgain);
          if (result === confirm) {
            await updateGlobalSetting(autoStartDesignTimeSetting, true);
            autoStartDesignTime = true;
          } else if (result === DialogResponses.learnMore) {
            await openUrl('https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local');
          } else if (result === DialogResponses.dontWarnAgain) {
            await updateGlobalSetting(showStartDesignTimeMessageSetting, false);
          }
        } while (result === DialogResponses.learnMore);
      }

      for (const projectPath of logicAppFolders) {
        if (!fs.existsSync(path.join(projectPath, localSettingsFileName))) {
          const settingsFileContent = getLocalSettingsSchema(false, projectPath);
          const projectUri: Uri = Uri.file(projectPath);
          await createJsonFile(projectUri, localSettingsFileName, settingsFileContent);
        }

        if (autoStartDesignTime) {
          startDesignTimeApi(projectPath);
        }
      }
    }
  }
}