Skip to content

Commit

Permalink
Merge pull request #15 from sitecoremaster/release-0.5
Browse files Browse the repository at this point in the history
Release 1.0
  • Loading branch information
dylanyoung-dev authored Feb 25, 2019
2 parents 6a32304 + 113660c commit f1b590c
Show file tree
Hide file tree
Showing 230 changed files with 10,063 additions and 2,834 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
/tools/scripts/.vs
/generators/node_modules

/generators/config.local.yaml
/coverage
.nyc_output
/generators/tests/tmp
/build/Azure/obj
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Yeoman generator - Starter Kit",
"program": "${workspaceFolder}/generators/node_modules/yo/lib/cli.js",
"args": [
"starter" //,
//"--testing"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
// {
// "type": "node",
// "request": "launch",
// "name": "Yeoman generator",
// "program": "c:\\Users\\tempe\\AppData\\Roaming\\npm\\yo.cmd",
// "args": [
// "generator"
// ]
// },
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\gulpfile.js"
}
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
7 changes: 0 additions & 7 deletions NuGet.config

This file was deleted.

59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Helix Starter Kit

[![Build status](https://sitecoremaster.visualstudio.com/Helix%20Starter%20Kit/_apis/build/status/Helix%20Starter%20Kit-CI)](https://sitecoremaster.visualstudio.com/Helix%20Starter%20Kit/_build/latest?definitionId=2)

This is a Helix Starter Kit. What makes it different than Habitat, Habitat Home or Helixbase? Well it's simple, those aren't truly built to be starter kits for your development project. We provide bear essentials and allow you the development manager to decide where you want to take this tool. It's great for smaller projects that can include component development for the Sitecore marketplace, or as big of projects as multiple sites running in a Sitecore instance.

We've made some assumptions, that you can use for your project that you are starting. But don't worry, if you are looking for a Helix starter kit that uses a didn't ORM Wrapper/Mapper or a different tool for serializing items, we are working on different projects coming soon that are based on different technology stacks.

> Sitecore Helix [Helix Documentation](https://helix.sitecore.net)
> .Net MVC 5.2.3
> Sitecore 9.0.2
> Sitecore 9+
> Unicorn
> Glass Mapper 5
> Yeoman for module creation
Expand All @@ -16,29 +18,64 @@ In addition, it includes scaffolding and developer enhancements, to make develop

## Installation

To get started with this solution, you need to clone the repository and move to a folder where your new solution will live. Once you've placed it there, you should run the following commands in the repository, using your favorite command line tool:
To get started using this solution as a starting point for your Sitecore project, download the latest release from the Github Release page.

Then unzip the package with the name of the project that you plan to use. The files that you now have on your file system contain the essential building blocks so that you can start setting up your Sitecore solution.

To get started with this solution, you need to clone the repository and move to a folder where your new solution will live. Example, if I worked for ABC Widgets, I would potentially have a folder where I typically place all of my Git repositories, such as `C:\Development`, so for the ABC Widget project, I would create a new folder called `ABC` and place all of the files in that folder, so I would have something like `C:\Development\ABC\` and you would see the following in that folder:



c:\> .\starter init
#### Update Configuration

Once your folder structure is setup, you next need to configure your yaml configuration. The yaml configuration is used to shorten and enhance the experience of initializing the solution and creating subsequent modules for your Sitecore instance. There are two configuration files that live under the `generators` folder in your repository:

- config.local.example.yml
- config.yaml

The main config.yaml is where you should place configuration specific to the repository. So all of the developers on your team will have the same settings in this config.yaml and it will be committed to source control. If you want to test out specific differences from the main configuration, you can rename `config.local.example.yaml` to `config.local.yaml`. The gitignore file, will automatically ignore this configuration file, so that you can make those changes locally without an issue.

The configuration file allows you to specify default values for Prompts that come up during the `run` command that you will use below. When setting up your instance, you should specify the following variables before you run your first `.\starter run` command.

This will install all the node, yeoman and other pre-requisites on your local machine to run the latest version of Sitecore 9.0.2. You will need to install a local copy of Sitecore 9.0.2 locally.

> Coming Soon we will also setup Sitecore in your local environment.

## Getting Started

The purpose to this repository, is to allow a trimmed down solution, that only includes development acceleration to increase productivity when creating a solution for either your website solution or component for the Sitecore marketplace. If you are looking to contribute, just make sure you keep that simple fact in mind.
Once you've got the core folder structure in place, you will need to initialize the npm install, plus any other pre-requisites. To do this, just run the following batch command:

c:\> .\starter setup

Once that completes, you should be ready to run the solution initialization process, which will run and setup your Sitecore Visual Studio solution based on settings that you specify during the guided commands (or based on configuration specified in the `config.yaml` file). To start the guided commands, run the following batch command in your favorite command line tool in the root folder:

c:\> .\starter run

This will initialize the Yeoman generator which will provide you with the simple option to either `Initialize Solution` or `Create Helix Module`. If this is your first time running this command, make sure you select `Initialize Solution` before you start creating your own Helix Modules.

The Initialization of the Sitecore solution contains 3 different types of solutions:

You can setup a `Base` install which will only contain the very bare essentials for a Sitecore Visual Studio solution with limited projects.

There is a `Website` focused solution, which contains a little more projects in your solution focused towards getting you started building a website focused solution.

And lastly, there is a `Module` focused solution, which is there to help those that are building a Sitecore module for the marketplace.

In the future we will build additional solution types that include the pieces that make sense for those scenarios.

Once you've selected your solution types, you will be presented with various other options to help setup your local Visual Studio solution, this will include gulp configurations, publish settings and more. Once you are done, you should now see a bunch of new root items as well as a new `src` folder.

Once you get to this point, I would recommend committing your changes and then you can proceed with your Sitecore website setup and moving on to the next section on building custom Helix modules.

### New Modules

If you need to add a new module (which is a standard procedure when using a starter kit), this solution includes support for Yeoman, which is a Node JS package that allows you to create templated scaffolding for anything you need.
If you need to add a new module, it's now super simple to do this, just by running a simple batch command:

You can initialize the module creation process by either running the following command in your favorite command line tool:
c:\> .\starter run

c:\> .\starter create
Once you trigger that command, it will ask you a series of questions to determine the layer and naming of the module. This command will also insert the project into your current solution that you previously created in the Getting Started section.

Or you can use the Yeoman command:
## Video Training

c:\> yo starter
I am working on putting together a video training guide on how to use this Starter Kit to get up and running quickly on a Project.

## Contribution

Expand Down
118 changes: 118 additions & 0 deletions build/Azure/bin/Debug/Deploy-AzureResourceGroup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#Requires -Version 3.0

Param(
[string] [Parameter(Mandatory=$true)] $ResourceGroupLocation,
[string] $ResourceGroupName = 'HelixStarterKit',
[switch] $UploadArtifacts,
[string] $StorageAccountName,
[string] $StorageContainerName = $ResourceGroupName.ToLowerInvariant() + '-stageartifacts',
[string] $TemplateFile = 'azuredeploy.json',
[string] $TemplateParametersFile = 'azuredeploy.parameters.json',
[string] $ArtifactStagingDirectory = '.',
[string] $DSCSourceFolder = 'DSC',
[switch] $ValidateOnly
)

try {
[Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent("VSAzureTools-$UI$($host.name)".replace(' ','_'), '3.0.0')
} catch { }

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 3

function Format-ValidationOutput {
param ($ValidationOutput, [int] $Depth = 0)
Set-StrictMode -Off
return @($ValidationOutput | Where-Object { $_ -ne $null } | ForEach-Object { @(' ' * $Depth + ': ' + $_.Message) + @(Format-ValidationOutput @($_.Details) ($Depth + 1)) })
}

$OptionalParameters = New-Object -TypeName Hashtable
$TemplateFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFile))
$TemplateParametersFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile))

if ($UploadArtifacts) {
# Convert relative paths to absolute paths if needed
$ArtifactStagingDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $ArtifactStagingDirectory))
$DSCSourceFolder = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $DSCSourceFolder))

# Parse the parameter file and update the values of artifacts location and artifacts location SAS token if they are present
$JsonParameters = Get-Content $TemplateParametersFile -Raw | ConvertFrom-Json
if (($JsonParameters | Get-Member -Type NoteProperty 'parameters') -ne $null) {
$JsonParameters = $JsonParameters.parameters
}
$ArtifactsLocationName = '_artifactsLocation'
$ArtifactsLocationSasTokenName = '_artifactsLocationSasToken'
$OptionalParameters[$ArtifactsLocationName] = $JsonParameters | Select -Expand $ArtifactsLocationName -ErrorAction Ignore | Select -Expand 'value' -ErrorAction Ignore
$OptionalParameters[$ArtifactsLocationSasTokenName] = $JsonParameters | Select -Expand $ArtifactsLocationSasTokenName -ErrorAction Ignore | Select -Expand 'value' -ErrorAction Ignore

# Create DSC configuration archive
if (Test-Path $DSCSourceFolder) {
$DSCSourceFilePaths = @(Get-ChildItem $DSCSourceFolder -File -Filter '*.ps1' | ForEach-Object -Process {$_.FullName})
foreach ($DSCSourceFilePath in $DSCSourceFilePaths) {
$DSCArchiveFilePath = $DSCSourceFilePath.Substring(0, $DSCSourceFilePath.Length - 4) + '.zip'
Publish-AzureRmVMDscConfiguration $DSCSourceFilePath -OutputArchivePath $DSCArchiveFilePath -Force -Verbose
}
}

# Create a storage account name if none was provided
if ($StorageAccountName -eq '') {
$StorageAccountName = 'stage' + ((Get-AzureRmContext).Subscription.SubscriptionId).Replace('-', '').substring(0, 19)
}

$StorageAccount = (Get-AzureRmStorageAccount | Where-Object{$_.StorageAccountName -eq $StorageAccountName})

# Create the storage account if it doesn't already exist
if ($StorageAccount -eq $null) {
$StorageResourceGroupName = 'ARM_Deploy_Staging'
New-AzureRmResourceGroup -Location "$ResourceGroupLocation" -Name $StorageResourceGroupName -Force
$StorageAccount = New-AzureRmStorageAccount -StorageAccountName $StorageAccountName -Type 'Standard_LRS' -ResourceGroupName $StorageResourceGroupName -Location "$ResourceGroupLocation"
}

# Generate the value for artifacts location if it is not provided in the parameter file
if ($OptionalParameters[$ArtifactsLocationName] -eq $null) {
$OptionalParameters[$ArtifactsLocationName] = $StorageAccount.Context.BlobEndPoint + $StorageContainerName
}

# Copy files from the local storage staging location to the storage account container
New-AzureStorageContainer -Name $StorageContainerName -Context $StorageAccount.Context -ErrorAction SilentlyContinue *>&1

$ArtifactFilePaths = Get-ChildItem $ArtifactStagingDirectory -Recurse -File | ForEach-Object -Process {$_.FullName}
foreach ($SourcePath in $ArtifactFilePaths) {
Set-AzureStorageBlobContent -File $SourcePath -Blob $SourcePath.Substring($ArtifactStagingDirectory.length + 1) `
-Container $StorageContainerName -Context $StorageAccount.Context -Force
}

# Generate a 4 hour SAS token for the artifacts location if one was not provided in the parameters file
if ($OptionalParameters[$ArtifactsLocationSasTokenName] -eq $null) {
$OptionalParameters[$ArtifactsLocationSasTokenName] = ConvertTo-SecureString -AsPlainText -Force `
(New-AzureStorageContainerSASToken -Container $StorageContainerName -Context $StorageAccount.Context -Permission r -ExpiryTime (Get-Date).AddHours(4))
}
}

# Create or update the resource group using the specified template file and template parameters file
New-AzureRmResourceGroup -Name $ResourceGroupName -Location $ResourceGroupLocation -Verbose -Force

if ($ValidateOnly) {
$ErrorMessages = Format-ValidationOutput (Test-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName `
-TemplateFile $TemplateFile `
-TemplateParameterFile $TemplateParametersFile `
@OptionalParameters)
if ($ErrorMessages) {
Write-Output '', 'Validation returned the following errors:', @($ErrorMessages), '', 'Template is invalid.'
}
else {
Write-Output '', 'Template is valid.'
}
}
else {
New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
-ResourceGroupName $ResourceGroupName `
-TemplateFile $TemplateFile `
-TemplateParameterFile $TemplateParametersFile `
@OptionalParameters `
-Force -Verbose `
-ErrorVariable ErrorMessages
if ($ErrorMessages) {
Write-Output '', 'Template deployment returned the following errors:', @(@($ErrorMessages) | ForEach-Object { $_.Exception.Message.TrimEnd("`r`n") })
}
}
Loading

0 comments on commit f1b590c

Please sign in to comment.