forked from buildabonfire/Bonfire.JavascriptLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
132 lines (119 loc) · 3.26 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import ignite from 'gulp-ignite';
import browserify from 'gulp-ignite-browserify';
import babelify from 'babelify';
import inject from 'gulp-inject';
import uglify from 'uglify-js';
import yargs from 'yargs';
import Nuget from 'nuget-runner';
import msbuild from 'gulp-msbuild';
import del from 'del';
import assemblyInfo from 'gulp-dotnet-assembly-info';
import { IGNITE_UTILS } from 'gulp-ignite/utils';
import pkg from './package.json';
const SRC_PATH = './src/Bonfire.JavascriptLoader';
const DEMO_PATH = './src/Bonfire.JavascriptLoader.Demo';
const version = pkg.version;
const assembly = {
name: 'assembly-info',
fn() {
return gulp
.src(`${SRC_PATH}/Properties/AssemblyInfo.cs`)
.pipe(assemblyInfo({
title: 'Bonfire.JavascriptLoader',
description: 'Enable javascript loading for component based architecture.',
product: 'Bonfire.JavascriptLoader',
fileVersion: version,
company: 'Bonfire, Inc.',
copyright: `Copyright © ${new Date().getFullYear()}`,
version,
}))
.pipe(gulp.dest(`${SRC_PATH}/Properties`));
},
};
const build = {
name: 'build',
fn() {
return gulp
.src(`${SRC_PATH}/Bonfire.JavascriptLoader.csproj`)
.pipe(msbuild({
toolsVersion: 14.0,
targets: ['Clean', 'Build'],
errorOnFail: true,
stdout: false,
configuration: yargs.argv.config || 'Release'
}));
},
}
const injectLoaderJS = {
name: 'inject-loaderjs',
fn() {
return gulp.src(`${SRC_PATH}/Core/JavascriptConfiguration.cs`)
.pipe(inject(gulp.src(`${SRC_PATH}/Assets/loader.js`), {
starttag: '/*INJECT:JS*/',
endtag: '/*ENDINJECT:JS*/',
transform: (filepath, file) => {
return `"${uglify.minify(file.contents.toString('utf8'), { fromString: true }).code.slice(1)}"`;
}
}))
.pipe(gulp.dest(`${SRC_PATH}/Core`));
}
};
const nugetPack = {
name: 'nuget-pack',
fn(options, end) {
gulp.src(`${SRC_PATH}/bin/Release/Bonfire.JavascriptLoader.dll`)
.pipe(gulp.dest('./build/nuget/lib/net45'))
.on('end', () => {
const nuget = Nuget();
nuget.pack({
spec: './build/nuget/JavascriptLoader.nuspec',
outputDirectory: 'build/',
version,
}).then(() => end());
});
}
};
const nugetPush = {
name: 'nuget-push',
fn(options, end, error) {
const nuget = Nuget();
if (!yargs.argv.key) {
console.log('error');
return error("No Api Key provided.");
}
nuget.push(`./build/Bonfire.JavascriptLoader.${version}.nupkg`, {
source: 'https://www.myget.org/F/bonfire/api/v2/package',
timeout: 600,
apiKey: yargs.argv.key,
verbosity: 'normal',
});
}
}
const publish = {
name: 'publish',
run: ['assembly-info', 'inject-loaderjs', 'build', 'nuget-pack', 'nuget-push'],
};
const tasks = [
assembly,
nugetPack,
browserify,
injectLoaderJS,
build,
publish,
nugetPush,
];
const options = {
browserify: {
src: `${DEMO_PATH}/Assets/main.js`,
dest: `${DEMO_PATH}/Content/js`,
filename: 'main.js',
options: {
transform: [babelify],
},
watchFiles: [
`${DEMO_PATH}/Assets/*`,
],
},
};
ignite.start(tasks, options);