forked from parse-community/Parse-SDK-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_releases.js
executable file
·66 lines (58 loc) · 1.78 KB
/
build_releases.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
const pkg = require('./package.json');
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
const rmDir = function(dirPath) {
if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(function(file) {
const curPath = path.join(dirPath, file);
if (fs.lstatSync(curPath).isDirectory()) {
rmDir(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(dirPath);
}
};
const execCommand = function(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
console.warn(error);
return reject(error);
}
const output = stdout ? stdout : stderr;
console.log(output);
resolve(output);
});
});
};
console.log(`Building JavaScript SDK v${pkg.version}...\n`)
console.log('Cleaning up old builds...\n');
rmDir(path.join(__dirname, 'dist'));
rmDir(path.join(__dirname, 'lib'));
const crossEnv = 'npm run cross-env';
const gulp = 'npm run gulp';
(async function() {
console.log('Browser Release:');
console.log('Weapp Release:');
console.log('Node.js Release:');
console.log('React Native Release:');
await Promise.all([
execCommand(`${crossEnv} PARSE_BUILD=browser ${gulp} compile`),
execCommand(`${crossEnv} PARSE_BUILD=weapp ${gulp} compile`),
execCommand(`${crossEnv} PARSE_BUILD=node ${gulp} compile`),
execCommand(`${crossEnv} PARSE_BUILD=react-native ${gulp} compile`),
]);
console.log('Bundling and minifying for CDN distribution:');
await Promise.all([
execCommand(`${gulp} browserify`),
execCommand(`${gulp} browserify-weapp`),
]);
await Promise.all([
execCommand(`${gulp} minify`),
execCommand(`${gulp} minify-weapp`),
]);
}());