export async function chooseOrCreateProjectDetails()

in src/core/account.ts [272:306]


export async function chooseOrCreateProjectDetails(
  options: SWACLIConfig,
  credentialChain: TokenCredential,
  subscriptionId: string,
  shouldPrintToken: boolean | undefined
) {
  const staticSite = (await chooseOrCreateStaticSite(options, credentialChain, subscriptionId)) as StaticSiteARMResource;

  logger.silly("Static site found!");
  logger.silly({ staticSite });

  if (staticSite && staticSite.id) {
    if (!shouldPrintToken && staticSite.provider !== "Custom" && staticSite.provider !== "None" && staticSite.provider !== "SwaCli") {
      // TODO: add a temporary warning message until we ship `swa link/unlink`
      logger.error(`The project "${staticSite.name}" is linked to "${staticSite.provider}"!`);
      logger.error(`Unlink the project from the "${staticSite.provider}" provider and try again.`, true);
      return;
    }

    // in case we have a static site, we will use its resource group and name
    // get resource group name from static site id:
    //   /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/swa-resource-groupe-name/providers/Microsoft.Web/sites/swa-static-site
    // 0 /      1      /                   2                /        3     /             4
    const resourceGroup = staticSite.id.split("/")[4];
    const staticSiteName = staticSite.name;
    return {
      resourceGroup,
      staticSiteName,
    };
  } else {
    logger.error("No project found. Create a new project and try again.", true);
  }

  return;
}