-
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.
feat: select or create new resource group
THIS COMMIT INTRODUCES A LOT OF REFACTORING
- Loading branch information
1 parent
b942c9b
commit c212b57
Showing
12 changed files
with
252 additions
and
76 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
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 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,12 @@ | ||
import { push } from "../features/hosting/command"; | ||
import { Config } from "../lib/utils"; | ||
|
||
module.exports = async function() { | ||
const subscription = Config.get("subscription") as AzureSubscription; | ||
const storage = Config.get("storage") as AzureStorage; | ||
|
||
await push({ | ||
subscriptionId: subscription.id, | ||
storageAccountName: storage.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,22 @@ | ||
import { askForResourceGroupDetails } from "../lib/prompt"; | ||
import { az, saveWorkspace } from "../lib/utils"; | ||
|
||
module.exports = async function() { | ||
let regionsList = await az<AzureRegion[]>( | ||
`account list-locations --query '[].{name:name, id:id, displayName:displayName}'`, | ||
`Loading your regions (this may take few minutes)...` | ||
); | ||
|
||
const { resource, region } = await askForResourceGroupDetails(regionsList); | ||
|
||
let resourceGroup = await az<AzureResourceGroup>( | ||
`group create -l ${region} -n ${resource} --tag cli=nitro --query '[].{name:name, id:id, location:location}'`, | ||
`Creating your resource group...` | ||
); | ||
|
||
console.log("asdasdsdasdasd"); | ||
|
||
saveWorkspace({ | ||
resourceGroup | ||
}); | ||
}; |
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,30 @@ | ||
import { chooseResourceGroup } from "../lib/prompt"; | ||
import { az, Config, saveWorkspace } from "../lib/utils"; | ||
|
||
module.exports = async function() { | ||
let resourceGroupsList = await az<AzureResourceGroup[]>( | ||
`group list --query '[].{name:name, id:id, location:location}'`, | ||
`Loading your resource groups...` | ||
); | ||
|
||
if (resourceGroupsList.length) { | ||
let selectedResourceId = (await chooseResourceGroup(resourceGroupsList)).resourceGroup as string; | ||
|
||
if (selectedResourceId === "") { | ||
// create a new resource group | ||
return (await require(`./resource-group-create`))(); | ||
} else { | ||
const { id, name, location } = resourceGroupsList.find( | ||
(resourceGroup: AzureResourceGroup) => resourceGroup.id === selectedResourceId | ||
) as AzureResourceGroup; | ||
|
||
saveWorkspace({ | ||
resourceGroup: { | ||
id, | ||
location, | ||
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { az } from "../../lib/utils"; | ||
|
||
export async function push() { | ||
export async function push({ subscriptionId, storageAccountName }: { subscriptionId: string, storageAccountName: string }) { | ||
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"` | ||
`storage blob service-properties update --account-name ${storageAccountName} --static-website --404-document 404.html --index-document index.html` | ||
); | ||
// 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
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,7 @@ | ||
import { az } from "../../lib/utils"; | ||
|
||
export async function create({ name }: AzureStorage) { | ||
await az( | ||
`storage account create -n ${name} -g MyResourceGroup -l westus --sku Standard_LRS` | ||
); | ||
} |
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 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.