-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile-ci.js
136 lines (123 loc) · 4.65 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var gulp = require("gulp");
var gutil = require("gulp-util");
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 unicorn = require("./scripts/unicorn.js");
var websiteRootBackup = config.websiteRoot;
gulp.task("CI-Publish", function (callback) {
config.websiteRoot = path.resolve("./temp");
config.buildConfiguration = "Release";
fs.mkdirSync(config.websiteRoot);
runSequence(
"Build-Solution",
"Publish-Foundation-Projects",
"Publish-Feature-Projects",
"Publish-Project-Projects", callback);
});
gulp.task("CI-Prepare-Package-Files", function (callback) {
var excludeList = [
config.websiteRoot + "\\bin\\{Sitecore,Lucene,Newtonsoft,System,Microsoft.Web.Infrastructure}*dll",
config.websiteRoot + "\\compilerconfig.json.defaults",
config.websiteRoot + "\\packages.config",
config.websiteRoot + "\\App_Config\\Include\\{Feature,Foundation,Project}\\*Serialization.config",
config.websiteRoot + "\\App_Config\\Include\\{Feature,Foundation,Project}\\z.*DevSettings.config",
"!" + config.websiteRoot + "\\bin\\Sitecore.Support*dll",
"!" + config.websiteRoot + "\\bin\\Sitecore.{Feature,Foundation,Habitat,Demo,Common}*dll"
];
console.log(excludeList);
return gulp.src(excludeList, { read: false }).pipe(rimraf({ force: true }));
});
gulp.task("CI-Enumerate-Files", function () {
var packageFiles = [];
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;
})).pipe(gutil.buffer(function () {
xmlpoke("./package.xml", function (xml) {
for (var idx in packageFiles) {
xml.add("project/Sources/xfiles/Entries/x-item", packageFiles[idx]);
}
});
}));
});
gulp.task("CI-Enumerate-Items", function () {
var itemPaths = [];
var allowedPatterns = [
"./src/**/serialization/**/*.yml",
"!./src/**/serialization/*.Roles/**/*.yml",
"!./src/**/serialization/*.Users/**/*.yml"
];
return gulp.src(allowedPatterns)
.pipe(foreach(function (stream, file) {
console.log(file);
var itemPath = unicorn.getFullItemPath(file);
itemPaths.push(itemPath);
return stream;
})).pipe(gutil.buffer(function () {
xmlpoke("./package.xml", function (xml) {
for (var idx in itemPaths) {
xml.add("project/Sources/xitems/Entries/x-item", itemPaths[idx]);
}
});
}));
});
gulp.task("CI-Enumerate-Users", function () {
var users = [];
return gulp.src("./src/**/serialization/*.Users/**/*.yml")
.pipe(foreach(function (stream, file) {
console.log(file);
var fileContent = file.contents.toString();
var userName = unicorn.getUserPath(file);
users.push(userName);
return stream;
})).pipe(gutil.buffer(function () {
xmlpoke("./package.xml", function (xml) {
for (var idx in users) {
xml.add("project/Sources/accounts/Entries/x-item", users[idx]);
}
});
}));
});
gulp.task("CI-Enumerate-Roles", function () {
var roles = [];
return gulp.src("./src/**/serialization/*.Roles/**/*.yml")
.pipe(foreach(function (stream, file) {
console.log(file);
var fileContent = file.contents.toString();
var roleName = unicorn.getRolePath(file);
roles.push(roleName);
return stream;
})).pipe(gutil.buffer(function () {
xmlpoke("./package.xml", function (xml) {
for (var idx in roles) {
xml.add("project/Sources/accounts/Entries/x-item", roles[idx]);
}
});
}));
});
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-Enumerate-Items",
"CI-Enumerate-Users",
"CI-Enumerate-Roles",
"CI-Clean",
callback);
});