-
Notifications
You must be signed in to change notification settings - Fork 118
/
make.js
105 lines (88 loc) · 2.76 KB
/
make.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
require('shelljs/make');
var path = require('path');
var fs = require('fs');
var semver = require('semver');
var ncp = require('child_process');
var rp = function (relPath) {
return path.join(__dirname, relPath);
}
var fail = function (message) {
console.error('ERROR: ' + message);
process.exit(1);
}
var buildPath = path.join(__dirname, '_build');
var testPath = path.join(__dirname, 'test');
var enforceMinimumVersions = function () {
// enforce minimum Node version
var minimumNodeVersion = '4.8.6';
var currentNodeVersion = process.versions.node;
if (semver.lt(currentNodeVersion, minimumNodeVersion)) {
fail('requires node >= ' + minimumNodeVersion + '. installed: ' + currentNodeVersion);
}
// enforce minimum npm version
// NOTE: We are enforcing this version of npm because we use package-lock.json
var minimumNpmVersion = '3.10.10';
var currentNpmVersion = ncp.execSync('npm -v', { encoding: 'utf-8' });
if (semver.lt(currentNpmVersion, minimumNpmVersion)) {
fail('requires npm >= ' + minimumNpmVersion + '. installed: ' + currentNpmVersion);
}
}
var run = function (cl) {
try {
console.log('> ' + cl);
var rc = exec(cl).code;
if (rc !== 0) {
echo('Exec failed with rc ' + rc);
exit(rc);
}
}
catch (err) {
echo(err.message);
exit(1);
}
}
target.clean = function () {
rm('-Rf', buildPath);
};
target.build = function () {
enforceMinimumVersions();
run(path.join(__dirname, 'node_modules/.bin/tsc') + ' --outDir ' + buildPath);
cp('-Rf', rp('lib/opensource'), buildPath);
cp(rp('LICENSE'), buildPath);
cp(rp('package.json'), buildPath);
cp(rp('package-lock.json'), buildPath);
cp(rp('README.md'), buildPath);
cp(rp('ThirdPartyNotice.txt'), buildPath);
}
target.units = function() {
// install the just built lib into the test proj
pushd('test')
run('npm install ../_build');
popd();
console.log("-------Unit Tests-------");
run('tsc -p ./test/units');
run('mocha test/units');
}
target.test = function() {
// install the just built lib into the test proj
target.units();
console.log("-------Integration Tests-------");
run('tsc -p ./test/tests');
// Increases timeout for each test, which fixes flaky errors in integration tests.
run('mocha test/tests --timeout 180000 --retries 2');
}
//Deprecated since we automatically build in units before testing, keeping for back compat
target.buildtest = function() {
target.test();
}
target.samples = function () {
pushd('samples/basic');
run('npm install');
run('npm start');
popd();
console.log('done');
}
target.validate = function() {
target.test();
target.samples();
}