forked from microsoft/vscode-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
142 lines (122 loc) · 5.08 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
"use strict"
var gulp = require('gulp');
var rename = require('gulp-rename');
var install = require('gulp-install');
var tslint = require('gulp-tslint');
var filter = require('gulp-filter');
var ts = require('gulp-typescript');
var tsProject = ts.createProject('tsconfig.json');
var del = require('del');
var srcmap = require('gulp-sourcemaps');
var config = require('./tasks/config');
var request = require('request');
var fs = require('fs');
var gutil = require('gulp-util');
var through = require('through2');
var cproc = require('child_process');
var os = require('os');
var jeditor = require("gulp-json-editor");
var path = require('path');
var nls = require('vscode-nls-dev');
var localization = require('./tasks/localizationtasks');
require('./tasks/htmltasks')
require('./tasks/packagetasks')
gulp.task('ext:lint', () => {
return gulp.src([
config.paths.project.root + '/src/**/*.ts',
'!' + config.paths.project.root + '/src/views/htmlcontent/**/*',
config.paths.project.root + '/test/**/*.ts'
])
.pipe((tslint({
formatter: "verbose"
})))
.pipe(tslint.report());
});
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/'));
});
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'));
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.VsPgSqlEnv;
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'))
});
gulp.task('ext:copy', gulp.series('ext:copy-tests', 'ext:copy-js', 'ext:copy-config'));
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:compile', 'ext: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';
cproc.exec(`code --extensionDevelopmentPath="${workspace}" --extensionTestsPath="${workspace}/out/test" --verbose`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
process.exit(1);
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
done();
});
});
gulp.task('test', gulp.series('html:test', 'ext:test'));
require('./tasks/covertasks');
gulp.task('clean', function (done) {
return del('out', done);
});
gulp.task('build', gulp.series('clean', 'html:build', 'ext:build'));
gulp.task('install', function() {
return gulp.src(['./package.json', './src/views/htmlcontent/package.json'])
.pipe(install());
});
gulp.task('watch', function(){
return gulp.watch(config.paths.project.root + '/src/**/*', gulp.series('build'))
});