forked from microsoft/vscode-mssql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
288 lines (253 loc) · 12.3 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
var gulp = require('gulp');
var rename = require('gulp-rename');
var gulpTsLint = require('gulp-tslint');
var ts = require('gulp-typescript');
var tslint = require('tslint');
var tsProject = ts.createProject('tsconfig.json');
var del = require('del');
var srcmap = require('gulp-sourcemaps');
var config = require('./tasks/config');
var concat = require('gulp-concat');
var minifier = require('gulp-uglify/minifier');
var uglifyjs = require('uglify-js');
var nls = require('vscode-nls-dev');
var argv = require('yargs').argv;
var min = (argv.min === undefined) ? false : true;
var vscodeTest = require('vscode-test');
var packageJson = require('./package.json');
require('./tasks/packagetasks');
require('./tasks/localizationtasks');
gulp.task('ext:lint', () => {
// !! If updating this make sure to check if you need to update the TSA Scan task in ADO !!
var program = tslint.Linter.createProgram('tsconfig.json');
return gulp.src([
config.paths.project.root + '/src/**/*.ts',
'!' + config.paths.project.root + '/src/views/htmlcontent/**/*',
config.paths.project.root + '/test/**/*.ts'
])
.pipe((gulpTsLint({
program,
formatter: "verbose",
rulesDirectory: "node_modules/tslint-microsoft-contrib"
})))
.pipe(gulpTsLint.report());
});
// Copy icons for OE
gulp.task('ext:copy-OE-assets', (done) => {
return gulp.src([
config.paths.project.root + '/src/objectExplorer/objectTypes/*'
])
.pipe(gulp.dest('out/src/objectExplorer/objectTypes'));
});
// Copy icons for Query History
gulp.task('ext:copy-queryHistory-assets', (done) => {
return gulp.src([
config.paths.project.root + '/src/queryHistory/icons/*'
])
.pipe(gulp.dest('out/src/queryHistory/icons'));
});
// Compile source
gulp.task('ext:compile-src', (done) => {
return gulp.src([
config.paths.project.root + '/src/**/*.ts',
config.paths.project.root + '/src/**/*.js',
'!' + config.paths.project.root + '/typings/**/*.ts',
'!' + config.paths.project.root + '/src/views/htmlcontent/**/*'])
.pipe(srcmap.init())
.pipe(tsProject())
.on('error', function() {
if (process.env.BUILDMACHINE) {
done('Extension Tests failed to build. See Above.');
process.exit(1);
}
})
.pipe(nls.rewriteLocalizeCalls())
.pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false))
.pipe(srcmap.write('.', {
sourceRoot: function(file){ return file.cwd + '/src'; }
}))
.pipe(gulp.dest('out/src/'));
});
// Compile angular view
gulp.task('ext:compile-view', (done) => {
return gulp.src([
config.paths.project.root + '/src/views/htmlcontent/**/*.ts'])
.pipe(srcmap.init())
.pipe(tsProject())
.pipe(nls.rewriteLocalizeCalls())
.pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false))
.pipe(srcmap.write('.', {
sourceRoot: function(file){ return file.cwd + '/src'; }
}))
.pipe(gulp.dest('out/src/views/htmlcontent'));
});
// Copy systemjs config file
gulp.task('ext:copy-systemjs-config', (done) => {
return gulp.src([
config.paths.project.root + '/src/views/htmlcontent/*.js'])
.pipe(gulp.dest('out/src/views/htmlcontent'));
});
// Copy html
gulp.task('ext:copy-html', (done) => {
return gulp.src([
config.paths.project.root + '/src/controllers/sqlOutput.ejs'])
.pipe(gulp.dest('out/src/controllers/'));
});
// Copy css
gulp.task('ext:copy-css', (done) => {
return gulp.src([
config.paths.project.root + '/src/views/htmlcontent/src/css/*.css'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/css'));
});
// Copy images
gulp.task('ext:copy-images', (done) => {
return gulp.src([
config.paths.project.root + '/src/views/htmlcontent/src/images/**/*'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/images'));
});
// Clean angular slickgrid library
gulp.task('ext:clean-library-ts-files', function() {
del(config.paths.project.root + '/node_modules/angular2-slickgrid/**/*.ts');
return del(config.paths.project.root + '/node_modules/rxjs/**/*.ts');
});
// Copy and bundle dependencies into one file (vendor/vendors.js)
// system.config.js can also bundled for convenience
gulp.task('ext:copy-dependencies', (done) => {
gulp.src([config.paths.project.root + '/node_modules/rxjs/**/*'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib/rxjs'));
gulp.src([config.paths.project.root + '/node_modules/angular-in-memory-web-api/**/*'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib/angular-in-memory-web-api'));
// concatenate non-angular2 libs, shims & systemjs-config
if (min) {
gulp.src([
config.paths.project.root + '/node_modules/slickgrid/lib/jquery-1.8.3.js',
config.paths.project.root + '/node_modules/slickgrid/lib/jquery.event.drag-2.2.js',
config.paths.project.root + '/node_modules/slickgrid/lib/jquery-ui-1.9.2.js',
config.paths.project.root + '/node_modules/underscore/underscore-min.js',
config.paths.project.root + '/node_modules/slickgrid/slick.core.js',
config.paths.project.root + '/node_modules/slickgrid/slick.grid.js',
config.paths.project.root + '/node_modules/slickgrid/slick.editors.js',
config.paths.project.root + '/node_modules/core-js/client/shim.min.js',
config.paths.project.root + '/node_modules/zone.js/dist/zone.js',
config.paths.project.root + '/node_modules/rangy/lib/rangy-core.js',
config.paths.project.root + '/node_modules/rangy/lib/rangy-textrange.js',
config.paths.project.root + '/node_modules/reflect-metadata/Reflect.js',
config.paths.project.root + '/node_modules/systemjs/dist/system.src.js',
config.paths.project.root + '/src/views/htmlcontent/systemjs.config.js'
])
.pipe(concat('vendors.min.js'))
.pipe(minifier({}, uglifyjs))
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib'));
} else {
gulp.src([
config.paths.project.root + '/node_modules/slickgrid/lib/jquery-1.8.3.js',
config.paths.project.root + '/node_modules/slickgrid/lib/jquery.event.drag-2.2.js',
config.paths.project.root + '/node_modules/slickgrid/lib/jquery-ui-1.9.2.js',
config.paths.project.root + '/node_modules/underscore/underscore-min.js',
config.paths.project.root + '/node_modules/slickgrid/slick.core.js',
config.paths.project.root + '/node_modules/slickgrid/slick.grid.js',
config.paths.project.root + '/node_modules/slickgrid/slick.editors.js',
config.paths.project.root + '/node_modules/core-js/client/shim.min.js',
config.paths.project.root + '/node_modules/rangy/lib/rangy-core.js',
config.paths.project.root + '/node_modules/rangy/lib/rangy-textrange.js',
config.paths.project.root + '/node_modules/reflect-metadata/Reflect.js',
config.paths.project.root + '/node_modules/systemjs/dist/system.src.js',
config.paths.project.root + '/src/views/htmlcontent/systemjs.config.js'
])
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib'));
gulp.src([config.paths.project.root + '/node_modules/zone.js/**/*'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib/zone.js'));
}
// copy source maps
gulp.src([
// config.paths.html.root + '/node_modules/es6-shim/es6-shim.map',
config.paths.project.root + '/node_modules/reflect-metadata/Reflect.js.map',
config.paths.project.root + '/node_modules/systemjs/dist/system-polyfills.js.map',
config.paths.project.root + '/node_modules/systemjs-plugin-json/json.js'
]).pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib'));
gulp.src([
config.paths.project.root + '/node_modules/angular2-slickgrid/components/css/SlickGrid.css',
config.paths.project.root + '/node_modules/slickgrid/slick.grid.css'
]).pipe(gulp.dest('out/src/views/htmlcontent/src/css'));
gulp.src([
config.paths.project.root + '/node_modules/angular2-slickgrid/index.js',
config.paths.project.root + '/node_modules/angular2-slickgrid/components/**/*.js'
], { base: config.paths.project.root + '/node_modules/angular2-slickgrid' }).pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib/angular2-slickgrid'));
return gulp.src([config.paths.project.root + '/node_modules/@angular/**/*'])
.pipe(gulp.dest('out/src/views/htmlcontent/src/js/lib/@angular'));
});
// Compile tests
gulp.task('ext:compile-tests', (done) => {
return gulp.src([
config.paths.project.root + '/test/**/*.ts',
config.paths.project.root + '/typings/**/*.ts'])
.pipe(srcmap.init())
.pipe(tsProject())
.on('error', function() {
if (process.env.BUILDMACHINE) {
done('Extension Tests failed to build. See Above.');
process.exit(1);
}
})
.pipe(srcmap.write('.', {
sourceRoot: function(file){ return file.cwd + '/test'; }
}))
.pipe(gulp.dest('out/test/'));
});
gulp.task('ext:compile', gulp.series('ext:compile-src', 'ext:compile-tests', 'ext:copy-OE-assets', 'ext:copy-queryHistory-assets'));
gulp.task('ext:copy-tests', () => {
return gulp.src(config.paths.project.root + '/test/resources/**/*')
.pipe(gulp.dest(config.paths.project.root + '/out/test/resources/'))
});
gulp.task('ext:copy-config', () => {
var env = process.env.VsMsSqlEnv;
env = env == undefined ? "dev" : env;
return gulp.src(config.paths.project.root + '/src/configurations/' + env + '.config.json')
.pipe(rename('config.json'))
.pipe(gulp.dest(config.paths.project.root + '/out/src'));
});
gulp.task('ext:copy-js', () => {
return gulp.src([
config.paths.project.root + '/src/**/*.js',
'!' + config.paths.project.root + '/src/views/htmlcontent/**/*'])
.pipe(gulp.dest(config.paths.project.root + '/out/src'))
});
// Copy the files which aren't used in compilation
gulp.task('ext:copy', gulp.series('ext:copy-tests', 'ext:copy-js', 'ext:copy-config', 'ext:copy-systemjs-config', 'ext:copy-dependencies', 'ext:copy-html', 'ext:copy-css', 'ext:copy-images'));
gulp.task('ext:localization', gulp.series('ext:localization:xliff-to-ts', 'ext:localization:xliff-to-json', 'ext:localization:xliff-to-package.nls'));
gulp.task('ext:build', gulp.series('ext:localization', 'ext:copy', 'ext:clean-library-ts-files', 'ext:compile', 'ext:compile-view')); // removed lint before copy
gulp.task('ext:test', (done) => {
let workspace = process.env['WORKSPACE'];
if (!workspace) {
workspace = process.cwd();
}
process.env.JUNIT_REPORT_PATH = workspace + '/test-reports/ext_xunit.xml';
var args = ['--verbose', '--disable-gpu', '--disable-telemetry', '--disable-updates', '-n'];
let vscodeVersion = packageJson.engines.vscode.slice(1);
let extensionTestsPath = `${workspace}/out/test`;
vscodeTest.downloadAndUnzipVSCode(vscodeVersion).then((vscodePath) => {
if (vscodePath) {
vscodeTest.runTests({
vscodeExecutablePath: vscodePath,
extensionDevelopmentPath: workspace,
extensionTestsPath: extensionTestsPath,
launchArgs: args
}).then(() => done()).catch((error) => {
console.log(`stdout: ${process.stdout}`);
console.log(`stderr: ${process.stderr}`);
console.error(`exec error: ${error}`);
done(error);
});
}
})
});
gulp.task('test', gulp.series('ext:test'));
require('./tasks/covertasks');
gulp.task('clean', function (done) {
return del('out', done);
});
gulp.task('build', gulp.series('clean', 'ext:build', 'ext:install-service'));
gulp.task('watch', function(){
return gulp.watch(config.paths.project.root + '/src/**/*', gulp.series('build'))
});
gulp.task('lint', gulp.series('ext:lint'));