forked from Sitecore/Habitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile-ci.js
74 lines (64 loc) · 2.62 KB
/
gulpfile-ci.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var gulp = require("gulp");
var foreach = require("gulp-foreach");
var rimrafDir = require("rimraf");
var rimraf = require("gulp-rimraf");
var runSequence = require("run-sequence");
var fs = require("fs");
var path = require("path");
var xmlpoke = require("xmlpoke");
var config = require("./gulpfile.js").config;
var websiteRootBackup = config.websiteRoot;
var packageFiles = [];
gulp.task("CI-Publish", function (callback) {
packageFiles = [];
config.websiteRoot = path.resolve("./temp");
config.buildConfiguration = "Release";
fs.mkdirSync(config.websiteRoot);
runSequence(
"Publish-Foundation-Projects",
"Publish-Feature-Projects",
"Publish-Project-Projects", callback);
});
gulp.task("CI-Prepare-Package-Files", function (callback) {
var foldersToExclude = [config.websiteRoot + "\\App_config\\include\\Unicorn"];
foldersToExclude.forEach(function (item, index, array) {
rimrafDir.sync(config.websiteRoot + item);
});
var excludeList = [
config.websiteRoot + "\\bin\\{Sitecore,Lucene,Newtonsoft,Unicorn,Kamsar,Rainbow,System,Microsoft.Web.Infrastructure}*dll",
config.websiteRoot + "\\compilerconfig.json.defaults",
config.websiteRoot + "\\packages.config",
config.websiteRoot + "\\App_Config\\Include\\Rainbow*",
config.websiteRoot + "\\App_Config\\Include\\Unicorn\\*",
config.websiteRoot + "\\App_Config\\Include\\Habitat\\*Serialization.config",
"!" + config.websiteRoot + "\\bin\\Sitecore.Support*dll",
"!" + config.websiteRoot + "\\bin\\Sitecore.{Feature,Foundation,Habitat}*dll"
];
console.log(excludeList);
return gulp.src(excludeList, { read: false }).pipe(rimraf({ force: true }));
});
gulp.task("CI-Enumerate-Files", function () {
config.websiteRoot = websiteRootBackup;
return gulp.src(path.resolve("./temp") + "/**/*.*", { base: "temp", read: false })
.pipe(foreach(function (stream, file) {
var item = "/" + file.relative.replace(/\\/g, "/");
console.log("Added to the package:" + item);
packageFiles.push(item);
return stream;
}));
});
gulp.task("CI-Update-Xml", function (cb) {
xmlpoke("./package.xml", function (xml) {
for (var idx in packageFiles) {
xml.add("project/Sources/xfiles/Entries/x-item", packageFiles[idx]);
}
});
cb();
});
gulp.task("CI-Clean", function (callback) {
rimrafDir.sync(path.resolve("./temp"));
callback();
});
gulp.task("CI-Do-magic", function (callback) {
runSequence("CI-Clean", "CI-Publish", "CI-Prepare-Package-Files", "CI-Enumerate-Files", "CI-Clean", "CI-Update-Xml", callback);
});