-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
148 lines (138 loc) · 4.78 KB
/
gulpfile.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
137
138
139
140
141
142
143
144
145
146
147
148
var gulp = require('gulp'),
msbuild = require('gulp-msbuild'),
minifyCss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
assemblyInfo = require('gulp-dotnet-assembly-info'),
config = require('./package.json'),
zip = require('gulp-zip'),
filter = require('gulp-filter'),
merge = require('merge2'),
gutil = require('gulp-util'),
markdown = require('gulp-markdown'),
rename = require('gulp-rename'),
manifest = require('gulp-dnn-manifest'),
path = require('path'),
less = require('gulp-less'),
lessPluginCleanCSS = require('less-plugin-clean-css'),
cleancss = new lessPluginCleanCSS({
advanced: true
});
gulp.task('less', function () {
return gulp.src('src/less/UserAccess.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')],
plugins: [cleancss]
}))
.pipe(gulp.dest('css'));
});
gulp.task('assemblyInfo', function () {
return gulp
.src(['**/AssemblyInfo.cs', '!node_modules/**'])
.pipe(assemblyInfo({
title: config.dnn.friendlyName,
description: config.description,
version: config.version,
fileVersion: config.version,
company: config.dnn.owner.organization,
copyright: function (value) {
return 'Copyright ' + new Date().getFullYear() + ' by ' + config.dnn.owner.organization;
}
}))
.pipe(gulp.dest('.'));
});
gulp.task('build', ['assemblyInfo'], function () {
var outDir = path.join(__dirname, config.dnn.pathToAssemblies);
return gulp.src('./Connect.UserAccess/Connect.UserAccess.csproj')
.pipe(msbuild({
toolsVersion: 14.0,
targets: ['Clean', 'Build'],
errorOnFail: true,
stdout: true,
properties: {
Configuration: 'Release',
OutputPath: outDir
}
}));
});
gulp.task('packageInstall', ['build'], function () {
var packageName = config.dnn.fullName + '_' + config.version;
var dirFilter = filter(fileTest);
var resources = merge(
gulp.src([
'*.html',
'App_LocalResources/*.resx',
'fonts/*.*',
'scripts/**/*.min.js'
], {
base: '.'
}),
gulp.src(['css/UserAccess.css'], {
base: '.'
})
.pipe(minifyCss()),
gulp.src(['scripts/**/*.js', '!scripts/**/*.min.js'], {
base: '.'
})
.pipe(uglify().on('error', gutil.log))
)
.pipe(zip('Resources.zip'));
return merge(
resources,
manifest(config, './_Installation/Connect.UserAccess.dnn')
.pipe(rename('Connect.UserAccess.dnn')),
gulp.src([config.dnn.pathToAssemblies + '/*.dll',
config.dnn.pathToScripts + '/*.SqlDataProvider',
config.dnn.pathToSupplementaryFiles + '/License.txt',
config.dnn.pathToSupplementaryFiles + '/ReleaseNotes.txt'
]),
gulp.src(config.dnn.pathToSupplementaryFiles + '/ReleaseNotes.md')
.pipe(markdown())
.pipe(rename('ReleaseNotes.txt'))
)
.pipe(zip(packageName + '_Install.zip'))
.pipe(gulp.dest(config.dnn.packagesPath));
});
gulp.task('packageSource', ['build'], function () {
var packageName = config.dnn.fullName + '_' + config.version;
var dirFilter = filter(fileTest);
return merge(
gulp.src(['**/*.html',
'**/*.css',
'js/**/*.js',
'**/*.??proj',
'**/*.sln',
'**/*.json',
'**/*.cs',
'**/*.vb',
'**/*.resx',
config.dnn.pathToSupplementaryFiles + '**/*.*'
], {
base: '.'
})
.pipe(dirFilter)
.pipe(zip('Resources.zip')),
gulp.src(config.dnn.pathToSupplementaryFiles + '/*.dnn')
.pipe(manifest(config)),
gulp.src([config.dnn.pathToAssemblies + '/*.dll',
config.dnn.pathToScripts + '/*.SqlDataProvider',
config.dnn.pathToSupplementaryFiles + '/License.txt',
config.dnn.pathToSupplementaryFiles + '/ReleaseNotes.txt'
])
)
.pipe(zip(packageName + '_Source.zip'))
.pipe(gulp.dest(config.dnn.packagesPath));
})
gulp.task('package', ['packageInstall', 'packageSource'], function () {
return null;
})
gulp.task('default', ['package']);
function fileTest(file) {
var res = false;
for (var i = config.dnn.excludeFilter.length - 1; i >= 0; i--) {
res = res | file.relative.startsWith(config.dnn.excludeFilter[i]);
};
return !res;
}
function startsWith(str, strToSearch) {
return str.indexOf(strToSearch) === 0;
}