Skip to content

Commit

Permalink
fix: dont copy default templates for hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Dec 14, 2019
1 parent ce4a95f commit 1687c89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
18 changes: 0 additions & 18 deletions src/core/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,6 @@ export function askForHostingFolder(defaultPublicFolderName: string): Promise<An
return "Please enter a public folder.";
}
}
},
{
type: "confirm",
name: "overrideHtml",
message: ({ folder }) => `Override ${folder}/index.html?`,
when: ({ folder }) => fileExists(`${folder}/index.html`)
},
{
type: "confirm",
name: "override404",
message: ({ folder }) => `Override ${folder}/404.html?`,
when: ({ folder }) => fileExists(`${folder}/404.html`)
},
{
type: "confirm",
name: "overrideError",
message: ({ folder }) => `Override ${folder}/error.html?`,
when: ({ folder }) => fileExists(`${folder}/error.html`)
}
];
return inquirer.prompt(questions);
Expand Down
19 changes: 5 additions & 14 deletions src/features/hosting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,19 @@ module.exports = async function() {
let defaultPublicFolder = "./dist";

// default values
let [folder, overrideHtml, override404, overrideError] = [defaultPublicFolder, false, false, false];
let [folder] = [defaultPublicFolder];

if (isForceModeEnabled) {
// when the Force mode is enabled, use all defaults
[folder, overrideHtml, override404, overrideError] = [defaultPublicFolder, true, true, true];
[folder] = [defaultPublicFolder, true, true, true];
} else {
// when either manual or automatic mode are enabled, ask the user for all the details
({ folder = defaultPublicFolder, overrideHtml, override404, overrideError } = await askForHostingFolder(defaultPublicFolder));
debug(`selected hosting folder=${folder}, overrideHtml=${overrideHtml}, override404=${override404}. overrideError=${overrideError}`);
({ folder = defaultPublicFolder } = await askForHostingFolder(defaultPublicFolder));
debug(`selected hosting folder=${folder}`);
}

createDirectoryIfNotExists(defaultPublicFolder);

if (override404 || typeof override404 === "undefined") {
// copy 404.html
copyTemplate(`init/hosting/404.html.tpl`, `${folder}/404.html`);
}
if (overrideError || typeof overrideError === "undefined") {
// copy errro.html
copyTemplate(`init/hosting/error.html.tpl`, `${folder}/error.html`);
}

const { storage } = readWorkspace();
debug(`using storage ${chalk.green(storage.name)}`);

Expand All @@ -40,7 +31,7 @@ module.exports = async function() {

// https://docs.microsoft.com/en-us/cli/azure/storage/blob/service-properties?view=azure-cli-latest#az-storage-blob-service-properties-update
await az<string>(
`storage blob service-properties update --account-name "${storage.name}" --static-website --404-document 404.html --index-document index.html --query "{staticWebsite: staticWebsite}"`,
`storage blob service-properties update --account-name "${storage.name}" --static-website --404-document index.html --index-document index.html --query "{staticWebsite: staticWebsite}"`,
`Enabling hosting for storage account ${chalk.cyan(storage.name)}...`
);

Expand Down

0 comments on commit 1687c89

Please sign in to comment.