-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4b6449
commit 2304388
Showing
11 changed files
with
293 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { isProjectFileExists, saveProjectConfigToDisk } from "../lib/utils"; | ||
import { | ||
askIfOverrideProjectFile, | ||
askForProjectDetails, | ||
askForFeatures | ||
} from "../lib/prompt"; | ||
import chalk from "chalk"; | ||
|
||
module.exports = async function() { | ||
if (isProjectFileExists()) { | ||
const shouldOverrideConfigFile = await askIfOverrideProjectFile(); | ||
if (shouldOverrideConfigFile.override === false) { | ||
process.exit(0); | ||
} | ||
} | ||
|
||
const project = await askForProjectDetails(); | ||
const { features } = await askForFeatures(); | ||
const featuresConfiguration: any = {}; | ||
|
||
for await (let feature of features) { | ||
console.log(`Configuring ${chalk.green(feature)}:`); | ||
try { | ||
const featureImplementation = require(`./lib/features/${feature}/index`); | ||
const config = await featureImplementation(); | ||
featuresConfiguration[feature] = config; | ||
} catch (error) { | ||
console.error(error.toString()); | ||
} | ||
} | ||
|
||
saveProjectConfigToDisk({ | ||
project, | ||
...featuresConfiguration | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { az, saveProjectConfigToDisk } from "../lib/utils"; | ||
import { chooseSubscription } from "../lib/prompt"; | ||
|
||
module.exports = async function() { | ||
// console.log(chalk.green(`Fetching subscriptions...`)); | ||
|
||
// @todo save these subscriptions globally. | ||
let subscriptions: string = await az( | ||
`login --query '[].{name:name, state:state, id:id}'`, | ||
`Loading your subscriptions...` | ||
); | ||
|
||
if (subscriptions.length) { | ||
const subscriptionsList = JSON.parse(subscriptions) as AzureSubscription[]; | ||
let selectedSubscription = (await chooseSubscription(subscriptionsList)) | ||
.subscription as string; | ||
const { id, name } = subscriptionsList.find( | ||
(sub: AzureSubscription) => sub.name === selectedSubscription | ||
) as AzureSubscription; | ||
saveProjectConfigToDisk({ | ||
subscription: { | ||
id, | ||
name | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { az } from "../../lib/utils"; | ||
|
||
export async function push() { | ||
await az( | ||
`storage blob service-properties update --account-name <storage-account-name> --static-website --404-document <error-document-name> --index-document <index-document-name>` | ||
); | ||
await az( | ||
`storage blob upload-batch -s <source-path> -d \$web --account-name <storage-account-name>` | ||
); | ||
await az( | ||
`storage account show -n <storage-account-name> -g <resource-group-name> --query "primaryEndpoints.web"` | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { QuestionCollection } from "inquirer"; | ||
import { createDirectoryIfNotExists } from "../../lib/utils"; | ||
import inquirer = require("inquirer"); | ||
|
||
// Note: use commonJs exports | ||
module.exports = async function(): Promise<inquirer.Answers> { | ||
const questions: QuestionCollection = [ | ||
{ | ||
type: "input", | ||
name: "folder", | ||
message: "Enter public folder (will be created if not present):", | ||
default: "public", | ||
validate: function(value: string) { | ||
if (value && value.length) { | ||
return createDirectoryIfNotExists(value); | ||
} else { | ||
return "Please enter a public folder."; | ||
} | ||
} | ||
} | ||
]; | ||
return inquirer.prompt(questions); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { QuestionCollection } from "inquirer"; | ||
import inquirer = require("inquirer"); | ||
|
||
// Note: use commonJs exports | ||
module.exports = async function(): Promise<inquirer.Answers> { | ||
const questions: QuestionCollection = [ | ||
{ | ||
type: "input", | ||
name: "name", | ||
message: "Enter your storage account name:", | ||
validate: function(value: string) { | ||
if (value.length) { | ||
return true; | ||
} else { | ||
return "Please enter a valid name."; | ||
} | ||
} | ||
}, | ||
{ | ||
type: "input", | ||
name: "sas", | ||
message: "Enter your storage SAS token:", | ||
validate: function(value: string) { | ||
if (value.length) { | ||
return true; | ||
} else { | ||
return "Please enter a valid SAS token."; | ||
} | ||
} | ||
} | ||
]; | ||
return inquirer.prompt(questions); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.