Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #121 from Sitecore/feature/gulp
Browse files Browse the repository at this point in the history
Additional gulp automation
  • Loading branch information
stasmaxymov committed Mar 15, 2016
2 parents a26baf1 + 5ff0104 commit b0f357a
Show file tree
Hide file tree
Showing 34 changed files with 6,959 additions and 2,090 deletions.
9 changes: 5 additions & 4 deletions gulp-config.js
@@ -1,9 +1,10 @@
module.exports = function () {
var config = {
var config = {
websiteRoot: "C:\\websites\\Habitat.local\\Website",
sitecoreLibraries: "C:\\websites\\Habitat.local\\Website\\bin",
solutionName: "Habitat",
buildConfiguration: "Debug"
}
return config;
buildConfiguration: "Debug",
runCleanBuilds: false
}
return config;
}
58 changes: 50 additions & 8 deletions gulpfile.js
Expand Up @@ -8,26 +8,47 @@ var newer = require("gulp-newer");
var runSequence = require("run-sequence");
var path = require("path");
var config = require("./gulp-config.js")();
var nugetRestore = require('gulp-nuget-restore');
var fs = require('fs');
var unicorn = require("./scripts/unicorn.js");
var habitat = require("./scripts/habitat.js");

module.exports.config = config;

gulp.task("default", function (callback) {
config.runCleanBuilds = true;
return runSequence(
"01-Copy-Sitecore-Lib",
"02-Nuget-Restore",
"03-Publish-All-Projects",
"04-Apply-Xml-Transform",
"05-Sync-Unicorn",
callback);
});

/*****************************
Initial setup
*****************************/
gulp.task("01-Copy-Sitecore-Lib", function () {
console.log("Copying Sitecore Libraries");
var files = config.sitecoreLibraries + "/**/*";
gulp.src(files)
.pipe(gulp.dest("./lib/Sitecore"));
return gulp.src(files).pipe(gulp.dest("./lib/Sitecore"));
});

gulp.task("02-Nuget-Restore", function (callback) {
var solution = "./" + config.solutionName + ".sln";
return gulp.src(solution).pipe(nugetRestore());
});

gulp.task("02-Publish-All-Projects", function (callback) {
runSequence(

gulp.task("03-Publish-All-Projects", function (callback) {
return runSequence(
"Publish-Foundation-Projects",
"Publish-Feature-Projects",
"Publish-Project-Projects", callback);
});

gulp.task("03-Apply-Xml-Transform", function () {
gulp.task("04-Apply-Xml-Transform", function () {
return gulp.src("./src/Project/**/code/*.csproj")
.pipe(foreach(function (stream, file) {
return stream
Expand All @@ -47,13 +68,30 @@ gulp.task("03-Apply-Xml-Transform", function () {

});

gulp.task("04-Optional-Copy-Local-Assemblies", function () {
gulp.task("05-Sync-Unicorn", function (callback) {
var options = {};
options.configurationConfigFiles = [
__dirname + "/src/Foundation/Serialization/code/App_Config/Include/*/*.Serialization.config",
__dirname + "/src/Foundation/!(Serialization)/code/App_Config/Include/*/*.Serialization.config",
__dirname + "/src/Feature/**/code/App_Config/Include/*/*.Serialization.config",
__dirname + "/src/Project/Common/code/App_Config/Include/*/*.Serialization.config",
__dirname + "/src/Project/!(Common)/code/App_Config/Include/*/*.Serialization.config"];
options.siteHostName = habitat.getSiteUrl();
options.authenticationConfigFile = __dirname + "/src/Foundation/Serialization/code/App_config/Include/Foundation/Foundation.Serialization.config";

unicorn(function() { return callback() }, options);
});

/*****************************
Copy assemblies to all local projects
*****************************/
gulp.task("Copy-Local-Assemblies", function () {
console.log("Copying site assemblies to all local projects");
var files = config.sitecoreLibraries + "/**/*";

var root = "./src";
var projects = root + "/**/code/bin";
gulp.src(projects, { base: root })
return gulp.src(projects, { base: root })
.pipe(foreach(function (stream, file) {
console.log("copying to " + file.path);
gulp.src(files)
Expand All @@ -67,13 +105,17 @@ gulp.task("04-Optional-Copy-Local-Assemblies", function () {
*****************************/
var publishProjects = function (location, dest) {
dest = dest || config.websiteRoot;
var targets = ["Build"];
if (config.runCleanBuilds) {
targets = ["Clean", "Build"]
}
console.log("publish to " + dest + " folder");
return gulp.src([location + "/**/code/*.csproj"])
.pipe(foreach(function (stream, file) {
return stream
.pipe(debug({ title: "Building project:" }))
.pipe(msbuild({
targets: ["Build"],
targets: targets,
configuration: config.buildConfiguration,
logCommand: false,
verbosity: "minimal",
Expand Down
18 changes: 12 additions & 6 deletions package.json
Expand Up @@ -4,24 +4,30 @@
"description": "Sitecore Habitat Node Dependencies",
"main": "gulpfile.js",
"dependencies": {
"async": "^1.5.2",
"glob": "^7.0.3",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-debug": "^2.1.2",
"gulp-load-plugins": "^1.0.0",
"gulp-exec": "^2.1.2",
"gulp-foreach": "^0.1.0",
"gulp-load-plugins": "^1.0.0",
"gulp-msbuild": "0.2.13",
"gulp-newer": "^1.0.0",
"gulp-rename": "^1.2.2",
"gulp-rimraf": "^0.2.0",
"gulp-sass": "^2.0.4",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"gulp-autoprefixer": "^3.1.0",
"gulp-newer": "^1.0.0",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"vinyl": "^1.1.0",
"gulp-rimraf": "^0.2.0",
"rimraf": "^2.4.3",
"xml2js": "^0.4.16",
"xmlpoke": "^0.1.12"
},
"devDependencies": {},
"devDependencies": {
"gulp-nuget-restore": "^0.4.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
Binary file added scripts/Unicorn/MicroCHAP.dll
Binary file not shown.
11 changes: 11 additions & 0 deletions scripts/Unicorn/Sync.ps1
@@ -0,0 +1,11 @@
param([string]$url, [string]$secret, [string]$configurations)
$ErrorActionPreference = 'Stop'

# This is an example PowerShell script that will remotely execute a Unicorn sync using the new CHAP authentication system.

Import-Module .\Unicorn.psm1
$configs = $configurations.Split('^')

Sync-Unicorn -ControlPanelUrl $url -SharedSecret $secret -Configurations $configs

# Note: you may pass -Verb 'Reserialize' for remote reserialize. Usually not needed though.
Binary file added scripts/Unicorn/Unicorn.psm1
Binary file not shown.
33 changes: 33 additions & 0 deletions scripts/habitat.js
@@ -0,0 +1,33 @@
"use strict";
var xml2js = require("xml2js");
var fs = require("fs");

var habitat = {};

habitat.getConfiguration = function getConfigFile(filename) {
var data = fs.readFileSync(filename);

var parser = new xml2js.Parser();
var content;
parser.parseString(data, function (err, result) {
if (err !== null) throw err;

content = result;
});
return content;
};

habitat.getSiteUrl = function getSiteUrl(options) {
if (!options) options = {};

var publishFile = options.publishingSettingsFile ? options.publishingSettingsFile : "./publishsettings.targets";
try {
var configuration = habitat.getConfiguration(publishFile);
return configuration.Project.PropertyGroup[0].publishUrl[0];
} catch(error) {
error.message = "Could not get the Habitat site URL from '" + publishFile + "'. Error:" + error.message;
throw(error);
}
};

module.exports = habitat;
82 changes: 82 additions & 0 deletions scripts/unicorn.js
@@ -0,0 +1,82 @@
"use strict";
var exec = require("child_process").exec;
var xml2js = require("xml2js");
var glob = require("glob");
var async = require("async");
var fs = require("fs");

module.exports = function (callback, options) {
var getUnicornSecret = function () {
if (options.secret)
return options.secret;
var unicornConfigFile = options.authenticationConfigFile;

var data = fs.readFileSync(unicornConfigFile);

var parser = new xml2js.Parser();
var secret;
parser.parseString(data, function (err, result) {
if (err !== null) throw err;

secret = result.configuration.sitecore[0].unicorn[0].authenticationProvider[0].SharedSecret[0];
});
return secret;
}

var getUnicornConfiguration = function (configFile) {
var data = fs.readFileSync(configFile);

var configuration;
var parser = new xml2js.Parser();
parser.parseString(data, function (err, result) {
if (err !== null) throw err;

var configurationNodes = result.configuration.sitecore[0].unicorn[0].configurations[0].configuration;
for (var i = 0; i < configurationNodes.length; i++) {
configuration = (configuration ? configuration + "^" : "") + configurationNodes[i].$.name;
}
});
return configuration;
}

var getUnicornConfigurations = function (filesGlob) {
var configurations;

var files = glob.sync(filesGlob);
for (var i = 0; i < files.length; i++) {
var file = files[i];
var configuration = getUnicornConfiguration(file);
if (configuration) {
configurations = (configurations ? configurations + "^" : "") + configuration;
}
}
return configurations;
};

var getOrderedUnicornConfigurations = function (filesGlobs) {
if (options.configurations)
return options.configurations;

var allConfigurations;

for (var i = 0; i < filesGlobs.length; i++) {
var configurations = getUnicornConfigurations(filesGlobs[i]);
if (configurations) {
allConfigurations = (allConfigurations ? allConfigurations + "^" : "") + configurations;
}
}
return allConfigurations;
}

var secret = getUnicornSecret();
var url = options.siteHostName + "/unicorn.aspx";
var configurations = getOrderedUnicornConfigurations(options.configurationConfigFiles);

var syncScript = "./Sync.ps1 -secret " + secret + " -url " + url + " -configurations " + configurations;
var options = { cwd: __dirname + "/Unicorn/" };
return exec("powershell \"" + syncScript + "\"", options, function(err, stdout, stderr) {
if (err !== null) throw err;
console.log(stdout);
callback();
});
};
Expand Up @@ -19,6 +19,9 @@
Default value: 90
-->
<unicorn>
<authenticationProvider type="Unicorn.ControlPanel.Security.ChapAuthenticationProvider, Unicorn">
<SharedSecret>kl3KGocnbp3L9ncCZYRPwFwiW7jW2UhE02T3GZU6sL5rTCKZzsRyRYLtGzuh8Li</SharedSecret>
</authenticationProvider>
<configurations>
<configuration name="Foundation.Serialization" description="Sitecore.Solution.Framework Root items">
<targetDataStore physicalRootPath="$(sourceFolder)\foundation\serialization\serialization" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" useDataCache="false" singleInstance="true" />
Expand Down
Expand Up @@ -44,6 +44,14 @@
If an item name matches one of these names it will be prefixed with an underscore to make the name valid (e.g. COM1 -> _COM1)
-->
<setting name="Rainbow.SFS.InvalidFilenames" value="CON,PRN,AUX,NUL,COM1,COM2,COM3,COM4,COM5,COM6,COM7,COM8,COM9,LPT1,LPT2,LPT3,LPT4,LPT5,LPT6,LPT7,LPT8,LPT9" />

<!-- Rainbow LEGACY XML FIELD ATTRIBUTE FORMATTING
In Rainbow 1.1 and earlier, XML fields were formatted with all attributes on a single line. This was suboptimal for merging.
Rainbow 1.2 and later will place each XML attribute on its own line by default. If you want to force legacy behaviour, you can use this setting to do so.
The format of the XML does not affect item comparisons, using legacy formatting simply prevents unchanged items from getting extra diffs.
You probably still shouldn't use legacy formatting, but the option is there if you are very very change averse.
-->
<setting name="Rainbow.XmlFormat.UseLegacyAttributeFormatting" value="false" />
</settings>
</sitecore>
</configuration>
Expand Up @@ -62,16 +62,16 @@
<HintPath>..\..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rainbow, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Core.1.1.0\lib\net45\Rainbow.dll</HintPath>
<Reference Include="Rainbow, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Core.1.2.0\lib\net45\Rainbow.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rainbow.Storage.Sc, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Storage.Sc.1.1.0\lib\net45\Rainbow.Storage.Sc.dll</HintPath>
<Reference Include="Rainbow.Storage.Sc, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Storage.Sc.1.2.0\lib\net45\Rainbow.Storage.Sc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rainbow.Storage.Yaml, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Storage.Yaml.1.1.0\lib\net45\Rainbow.Storage.Yaml.dll</HintPath>
<Reference Include="Rainbow.Storage.Yaml, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Rainbow.Storage.Yaml.1.2.0\lib\net45\Rainbow.Storage.Yaml.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
Expand Down Expand Up @@ -113,8 +113,8 @@
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Unicorn, Version=3.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Unicorn.Core.3.1.2\lib\net45\Unicorn.dll</HintPath>
<Reference Include="Unicorn, Version=3.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Unicorn.Core.3.1.4\lib\net45\Unicorn.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/Foundation/Serialization/code/packages.config
Expand Up @@ -8,10 +8,10 @@
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.1" targetFramework="net45" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Rainbow" version="1.1.0" targetFramework="net45" />
<package id="Rainbow.Core" version="1.1.0" targetFramework="net45" />
<package id="Rainbow.Storage.Sc" version="1.1.0" targetFramework="net45" />
<package id="Rainbow.Storage.Yaml" version="1.1.0" targetFramework="net45" />
<package id="Unicorn" version="3.1.2" targetFramework="net45" />
<package id="Unicorn.Core" version="3.1.2" targetFramework="net45" />
<package id="Rainbow" version="1.2.0" targetFramework="net45" />
<package id="Rainbow.Core" version="1.2.0" targetFramework="net45" />
<package id="Rainbow.Storage.Sc" version="1.2.0" targetFramework="net45" />
<package id="Rainbow.Storage.Yaml" version="1.2.0" targetFramework="net45" />
<package id="Unicorn" version="3.1.4" targetFramework="net45" />
<package id="Unicorn.Core" version="3.1.4" targetFramework="net45" />
</packages>
17 changes: 6 additions & 11 deletions src/Foundation/Theming/code/Sitecore.Foundation.Theming.csproj
Expand Up @@ -49,18 +49,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="bower.json" />
<Content Include="bower_components\bootstrap-sass\assets\fonts\bootstrap\glyphicons-halflings-regular.svg" />
<Content Include="bower_components\font-awesome\fonts\fontawesome-webfont.eot" />
<Content Include="bower_components\font-awesome\fonts\fontawesome-webfont.ttf" />
<Content Include="bower_components\font-awesome\fonts\fontawesome-webfont.woff" />
<Content Include="bower_components\font-awesome\fonts\fontawesome-webfont.woff2" />
<Content Include="bower_components\font-awesome\fonts\FontAwesome.otf" />
<Content Include="bower_components\bootstrap-sass\assets\fonts\bootstrap\glyphicons-halflings-regular.eot" />
<Content Include="bower_components\bootstrap-sass\assets\fonts\bootstrap\glyphicons-halflings-regular.ttf" />
<Content Include="bower_components\bootstrap-sass\assets\fonts\bootstrap\glyphicons-halflings-regular.woff" />
<Content Include="bower_components\bootstrap-sass\assets\fonts\bootstrap\glyphicons-halflings-regular.woff2" />
<None Include="bundleconfig.json" />
<Content Include="bower_components\font-awesome\fonts\fontawesome-webfont.svg" />
<Content Include="fonts\fontawesome-webfont.svg" />
<Content Include="scripts\carousel.js" />
<Content Include="scripts\counter.js" />
<Content Include="scripts\disable-wffm-bootstrap.js" />
Expand Down Expand Up @@ -149,6 +139,11 @@
<Content Include="fonts\open-sans-v13-latin-regular.ttf" />
<Content Include="fonts\open-sans-v13-latin-regular.woff" />
<Content Include="fonts\open-sans-v13-latin-regular.woff2" />
<Content Include="fonts\fontawesome-webfont.eot" />
<Content Include="fonts\fontawesome-webfont.ttf" />
<Content Include="fonts\fontawesome-webfont.woff" />
<Content Include="fonts\fontawesome-webfont.woff2" />
<Content Include="fonts\FontAwesome.otf" />
<None Include="Properties\PublishProfiles\Local.pubxml" />
<None Include="compilerconfig.json" />
<None Include="compilerconfig.json.defaults">
Expand Down

0 comments on commit b0f357a

Please sign in to comment.