Skip to content

Commit

Permalink
Merge pull request #817 from Azure/developer/mikarmar/sku-picker
Browse files Browse the repository at this point in the history
fix: Allow SKU selection when creating a new site on "swa deploy"
  • Loading branch information
mkarmark committed Mar 20, 2024
2 parents b9675b3 + 00559d3 commit 60b01ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import chalk from "chalk";
import ora from "ora";
import path from "path";
import { swaCLIEnv } from "./env";
import { chooseProjectName, chooseStaticSite, wouldYouLikeToCreateStaticSite, wouldYouLikeToOverrideStaticSite } from "./prompts";
import { chooseProjectName, chooseProjectSku, chooseStaticSite, wouldYouLikeToCreateStaticSite, wouldYouLikeToOverrideStaticSite } from "./prompts";
import { swaCliPersistencePlugin } from "./swa-cli-persistence-plugin";
import { SWACLIPersistenceCachePlugin } from "./swa-cli-persistence-plugin/persistence-cache-plugin";
import { dasherize, logger } from "./utils";
Expand Down Expand Up @@ -125,6 +125,7 @@ async function createStaticSite(options: SWACLIConfig, credentialChain: TokenCre
const defaultStaticSiteName = appName || dasherize(path.basename(process.cwd())).substring(0, maxProjectNameLength);

appName = await chooseProjectName(defaultStaticSiteName, maxProjectNameLength);
const sku = await chooseProjectSku();
resourceGroup = resourceGroup || `${appName}-rg`;

let spinner = ora("Creating a new project...").start();
Expand All @@ -144,7 +145,7 @@ async function createStaticSite(options: SWACLIConfig, credentialChain: TokenCre

const staticSiteEnvelope: StaticSiteARMResource = {
location: AZURE_REGION_LOCATION || DEFAULT_AZURE_LOCATION,
sku: { name: "Free", tier: "Free" },
sku: { name: sku, tier: sku },

// these are mandatory, otherwise the static site will not be created
buildProperties: {
Expand Down
12 changes: 12 additions & 0 deletions src/core/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ export async function chooseProjectName(initial: string, maxLength: number): Pro
return response.projectName;
}

export async function chooseProjectSku(): Promise<string> {
const response = await promptOrUseDefault(false, {
type: "text",
name: "sku",
message: "Choose a SKU:",
initial: "Free",
validate: (value: string) => value === "Free" || value === "Standard" || "Configuration name cannot be empty",
});

return response.sku;
}

export async function chooseTenant(tenants: TenantIdDescription[], initial?: string): Promise<TenantIdDescription | undefined> {
const choices = tenants.map((tenant) => ({
title: tenant.tenantId as string,
Expand Down

0 comments on commit 60b01ca

Please sign in to comment.