forked from dahood/metropolis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
121 lines (101 loc) · 4.04 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
// Gulp Modules
var del = require('del');
var argv = require('yargs').argv;
var gulp = require('gulp');
var exec = require('sync-exec');
var nunit = require('gulp-nunit-runner');
var assemblyInfo = require('gulp-dotnet-assembly-info');
// Gulp Variables
var buildPath = '%CD%\\build';
var msBuildConfiguration = 'Release';
var version = '0.0.1'; //using package.json
var nunitConsole = 'packages\\NUnit.ConsoleRunner.3.5.0\\tools\\nunit3-console.exe';
// Gulp Default
gulp.task('default', ['test']);
// Gulp Tasks
gulp.task('compile', ['assemblyInfo', 'msbuild']);
gulp.task('assemblyInfo', function() {
var package = require('./package.json');
version = package.version;
console.log('Version Number: ' + version);
gulp.src('**/AssemblyInfo.cs')
.pipe(assemblyInfo({
title: 'Metropolis',
description: 'A code reivew and visualization tool',
configuration: 'Release',
company: 'Dahood.io',
product: 'Metropolis',
copyright: 'Copyright © Jonathan McCracken, Greg Cook, and Richard Hurst 2016',
trademark: 'Dahood.io',
version: '0.' + version,
fileVersion: '0.' + version}))
.pipe(gulp.dest('.'));
});
gulp.task('msbuild', function () {
console.log('MSBuild Release Configuration: ' + msBuildConfiguration);
var cmd = '"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe\" Metropolis.sln /t:Rebuild ' +
'/p:OutDir=' + buildPath + ';Configuration=' + msBuildConfiguration + ' /maxcpucount';
console.log(exec(cmd).stdout);
});
gulp.task('test', ['compile'], function () {
gulp.src(['build\\*.Test.dll'], {read: false})
.pipe(nunit({
noresult: true, //TODO: Fix this
result: 'build\\Foo.xml',
err: 'build\\NUnitErrors.txt',
teamcity: false,
nologo: true,
executable: nunitConsole
}));
});
// Usage: gulp dist -m "patch notes"
// Usage: gulp dist (test mode)
gulp.task('dist',['version', 'compile', 'package'], function() {
console.log('Please wait while npm trys to install your release candidate...');
console.log(exec('npm install . -g').stdout);
if (argv.m)
{
console.log("Publishing to npm...");
console.log(exec('npm publish').stdout);
console.log("Pushing to GitHub...");
console.log(exec('git commit -a -m \"' + argv.m + '\"').stdout);
console.log(exec('git push origin master').stdout);
}
});
// Usage: gulp version -m "patch notes"
gulp.task('version', function() {
if (argv.m)
{
console.log('Versioning...');
console.log(exec('npm version patch').stdout);
}
});
// Dist depends on both metropolis binaries, Collection Settings (e.g. checkstyle xml config),
// Collection Binaries (e.g. checkstyle .jar) for eslint, checkstyle, fxcop, etc that parsers
// use to automate the collection of metrics
gulp.task('package', ['package-clean', 'package-collection-cpd', 'package-collection-checkstyle',
'package-collection-settings'], function() {
gulp.src(['build\\*.dll', 'build\\*.exe', 'build\\*.config',
// exclude all these test files
'!build\\Metropolis.Test.dll',
'!build\\FluentAssertions.Core.dll',
'!build\\FluentAssertions.dll',
'!build\\nunit.framework.dll',
'!build\\Moq.dll'])
.pipe(gulp.dest('dist'));
});
gulp.task('package-clean'), function(){
del(['dist']);
}
gulp.task('package-collection-settings', function() {
gulp.src(['build\\Collection\\Settings\\**'])
.pipe(gulp.dest('dist\\Collection\\Settings'));
});
gulp.task('package-collection-checkstyle', function() {
gulp.src(['build\\Collection\\Binaries\\*.jar'])
.pipe(gulp.dest('dist\\Collection\\Binaries'));
});
gulp.task('package-collection-cpd', function() {
gulp.src(['build\\Collection\\Binaries\\cpd\\*.jar'])
.pipe(gulp.dest('dist\\Collection\\Binaries\\cpd'));
});