mbt 1.2.24 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/bin/mbt +0 -12
- package/index.js +1 -20
- package/install.js +189 -0
- package/package.json +7 -11
package/README.md
CHANGED
|
@@ -48,7 +48,11 @@ It is also possible to download and "install" the `mbt` executable via github re
|
|
|
48
48
|
|
|
49
49
|
The Cloud MTA Build Tool published docker images on docker hub with a pre-configured set of runtime tools (nodejs/java/maven/...).
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
## Node.js v10/ECMAScript modules
|
|
52
|
+
|
|
53
|
+
More and more npm packages use ECMAScript modules instead of commonJS, for ECMAScript modules are the official standard format to package JavaScript code for reuse. From v1.2.25, we use axios instead of binwrap(which has moderate severity vulnerabilities) to download binary files, but axios only supports ECMAScript modules and can't work on Node.js v10. So since v1.2.25, mbt will not support Node.js v10 and lower versions.
|
|
54
|
+
|
|
55
|
+
## License
|
|
52
56
|
|
|
53
57
|
Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
|
|
54
58
|
Please note that Docker images can contain other software which may be licensed under different licenses. This License file is also included in the Docker image. For any usage of built Docker images please make sure to check the licenses of the artifacts contained in the images.
|
package/bin/mbt
CHANGED
|
@@ -30,16 +30,4 @@ function execBin() {
|
|
|
30
30
|
|
|
31
31
|
if (fs.existsSync(binPath)) {
|
|
32
32
|
execBin();
|
|
33
|
-
} else {
|
|
34
|
-
console.error("INFO: Running " + path.basename(__filename) + " for the first time; downloading the actual binary");
|
|
35
|
-
|
|
36
|
-
var packageInfo = require(path.join(__dirname, "..", "package.json"));
|
|
37
|
-
var package = require(path.join(__dirname, "..", packageInfo.main));
|
|
38
|
-
|
|
39
|
-
package.install(unpackedBinPath, os, arch).then(function(result) {
|
|
40
|
-
execBin();
|
|
41
|
-
}, function(err) {
|
|
42
|
-
console.log("ERR", err);
|
|
43
|
-
process.exit(1);
|
|
44
|
-
});
|
|
45
33
|
}
|
package/index.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var path = require('path');
|
|
3
|
-
|
|
4
|
-
var packageInfo = require(path.join(__dirname, 'package.json'));
|
|
5
|
-
var version = packageInfo.version;
|
|
6
|
-
var root = (process.env.XMAKE_IMPORT_COMMON_0 ? `${process.env.XMAKE_IMPORT_COMMON_0}/com/github/sap/cloud-mta-build-tool/${version}/cloud-mta-build-tool-${version}-` : `https://github.com/SAP/cloud-mta-build-tool/releases/download/v${version}/cloud-mta-build-tool_${version}_`);
|
|
7
|
-
|
|
8
|
-
module.exports = binwrap({
|
|
9
|
-
dirname: __dirname,
|
|
10
|
-
binaries: [
|
|
11
|
-
'mbt'
|
|
12
|
-
],
|
|
13
|
-
urls: {
|
|
14
|
-
'darwin-arm64': root + 'Darwin_arm64.tar.gz',
|
|
15
|
-
'darwin-x64': root + 'Darwin_amd64.tar.gz',
|
|
16
|
-
'linux-x64': root + 'Linux_amd64.tar.gz',
|
|
17
|
-
'linux-arm64': root + 'Linux_arm64.tar.gz',
|
|
18
|
-
'win32-x64': root + 'Windows_amd64.tar.gz'
|
|
19
|
-
}
|
|
20
|
-
});
|
|
1
|
+
module.exports = {};
|
package/install.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
var fs = require("fs");
|
|
2
|
+
var axios = require("axios");
|
|
3
|
+
var tar = require("tar");
|
|
4
|
+
var zlib = require("zlib");
|
|
5
|
+
var unzip = require("unzip-stream");
|
|
6
|
+
var path = require("path");
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var packageInfo = require(path.join(process.cwd(), "package.json"));
|
|
10
|
+
var version = packageInfo.version;
|
|
11
|
+
|
|
12
|
+
var binName = process.argv[2];
|
|
13
|
+
var os = process.argv[3] || process.platform;
|
|
14
|
+
var arch = process.argv[4] || process.arch;
|
|
15
|
+
var root = `https://github.com/SAP/${binName}/releases/download/v${version}/${binName}_${version}_`;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var requested = os + "-" + arch;
|
|
19
|
+
var current = process.platform + "-" + process.arch;
|
|
20
|
+
if (requested !== current ) {
|
|
21
|
+
console.error("WARNING: Installing binaries for the requested platform (" + requested + ") instead of for the actual platform (" + current + ").")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var unpackedBinPath = path.join(process.cwd(), "unpacked_bin");
|
|
25
|
+
var config = {
|
|
26
|
+
dirname: __dirname,
|
|
27
|
+
binaries: [
|
|
28
|
+
'mbt'
|
|
29
|
+
],
|
|
30
|
+
urls: {
|
|
31
|
+
'darwin-arm64': root + 'Darwin_arm64.tar.gz',
|
|
32
|
+
'darwin-x64': root + 'Darwin_amd64.tar.gz',
|
|
33
|
+
'linux-x64': root + 'Linux_amd64.tar.gz',
|
|
34
|
+
'win32-x64': root + 'Windows_amd64.tar.gz'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (!fs.existsSync("bin")) {
|
|
38
|
+
fs.mkdirSync("bin");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var binExt = "";
|
|
42
|
+
if (os == "win32") {
|
|
43
|
+
binExt = ".exe";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var buildId = os + "-" + arch;
|
|
47
|
+
var url = config.urls[buildId];
|
|
48
|
+
if (!url) {
|
|
49
|
+
throw new Error("No binaries are available for your platform: " + buildId);
|
|
50
|
+
}
|
|
51
|
+
function binstall(url, path, options) {
|
|
52
|
+
if (url.endsWith(".zip")) {
|
|
53
|
+
return unzipUrl(url, path, options);
|
|
54
|
+
} else {
|
|
55
|
+
return untgz(url, path, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function untgz(url, path, options) {
|
|
60
|
+
options = options || {};
|
|
61
|
+
|
|
62
|
+
var verbose = options.verbose;
|
|
63
|
+
var verify = options.verify;
|
|
64
|
+
|
|
65
|
+
return new Promise(function (resolve, reject) {
|
|
66
|
+
var untar = tar
|
|
67
|
+
.x({ cwd: path })
|
|
68
|
+
.on("error", function (error) {
|
|
69
|
+
reject("Error extracting " + url + " - " + error);
|
|
70
|
+
})
|
|
71
|
+
.on("end", function () {
|
|
72
|
+
var successMessage = "Successfully downloaded and processed " + url;
|
|
73
|
+
|
|
74
|
+
if (verify) {
|
|
75
|
+
verifyContents(verify)
|
|
76
|
+
.then(function () {
|
|
77
|
+
resolve(successMessage);
|
|
78
|
+
})
|
|
79
|
+
.catch(reject);
|
|
80
|
+
} else {
|
|
81
|
+
resolve(successMessage);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var gunzip = zlib.createGunzip().on("error", function (error) {
|
|
86
|
+
reject("Error decompressing " + url + " " + error);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
fs.mkdirSync(path);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error.code !== "EEXIST") throw error;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (verbose) {
|
|
96
|
+
console.log("Downloading binaries from " + url);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
axios
|
|
100
|
+
.get(url, { responseType: "stream" })
|
|
101
|
+
.then((response) => {
|
|
102
|
+
response.data.pipe(gunzip).pipe(untar);
|
|
103
|
+
})
|
|
104
|
+
.catch((error) => {
|
|
105
|
+
if (verbose) {
|
|
106
|
+
console.error(error);
|
|
107
|
+
} else {
|
|
108
|
+
console.error(error.message);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function unzipUrl(url, path, options) {
|
|
115
|
+
options = options || {};
|
|
116
|
+
|
|
117
|
+
var verbose = options.verbose;
|
|
118
|
+
var verify = options.verify;
|
|
119
|
+
|
|
120
|
+
return new Promise(function (resolve, reject) {
|
|
121
|
+
var writeStream = unzip
|
|
122
|
+
.Extract({ path: path })
|
|
123
|
+
.on("error", function (error) {
|
|
124
|
+
reject("Error extracting " + url + " - " + error);
|
|
125
|
+
})
|
|
126
|
+
.on("entry", function (entry) {
|
|
127
|
+
console.log("Entry: " + entry.path);
|
|
128
|
+
})
|
|
129
|
+
.on("close", function () {
|
|
130
|
+
var successMessage = "Successfully downloaded and processed " + url;
|
|
131
|
+
|
|
132
|
+
if (verify) {
|
|
133
|
+
verifyContents(verify)
|
|
134
|
+
.then(function () {
|
|
135
|
+
resolve(successMessage);
|
|
136
|
+
})
|
|
137
|
+
.catch(reject);
|
|
138
|
+
} else {
|
|
139
|
+
resolve(successMessage);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (verbose) {
|
|
144
|
+
console.log("Downloading binaries from " + url);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
axios
|
|
148
|
+
.get(url, { responseType: "stream" })
|
|
149
|
+
.then((response) => {
|
|
150
|
+
response.data.pipe(writeStream);
|
|
151
|
+
})
|
|
152
|
+
.catch((error) => {
|
|
153
|
+
if (verbose) {
|
|
154
|
+
console.error(error);
|
|
155
|
+
} else {
|
|
156
|
+
console.error(error.message);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function verifyContents(files) {
|
|
163
|
+
return Promise.all(
|
|
164
|
+
files.map(function (filePath) {
|
|
165
|
+
return new Promise(function (resolve, reject) {
|
|
166
|
+
fs.stat(filePath, function (err, stats) {
|
|
167
|
+
if (err) {
|
|
168
|
+
reject(filePath + " was not found.");
|
|
169
|
+
} else if (!stats.isFile()) {
|
|
170
|
+
reject(filePath + " was not a file.");
|
|
171
|
+
} else {
|
|
172
|
+
resolve();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
binstall(url, unpackedBinPath).then(function() {
|
|
181
|
+
config.binaries.forEach(function(bin) {
|
|
182
|
+
fs.chmodSync(path.join(unpackedBinPath, bin + binExt), "755");
|
|
183
|
+
});
|
|
184
|
+
}).then(function(result) {
|
|
185
|
+
process.exit(0);
|
|
186
|
+
}, function(result) {
|
|
187
|
+
console.error("ERR", result);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mbt",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.26",
|
|
4
4
|
"description": "[](https://circleci.com/gh/SAP/cloud-mta-build-tool) [](https://goreportcard.com/report/github.com/SAP/cloud-mta-build-tool) [](https://coveralls.io/github/SAP/cloud-mta-build-tool?branch=cover)  ",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"index.js",
|
|
8
|
+
"install.js",
|
|
8
9
|
"bin"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
|
-
"install": "
|
|
12
|
-
"
|
|
13
|
-
"build": "binwrap-prepare",
|
|
14
|
-
"test": "npm-run-all test:*",
|
|
15
|
-
"test:binwrap-links": "binwrap-test",
|
|
16
|
-
"test:binwrap-binary": "node ./bin/mbt"
|
|
12
|
+
"install": "node install cloud-mta-build-tool",
|
|
13
|
+
"test": "node ./bin/mbt"
|
|
17
14
|
},
|
|
18
15
|
"bin": {
|
|
19
16
|
"mbt": "bin/mbt"
|
|
@@ -29,9 +26,8 @@
|
|
|
29
26
|
},
|
|
30
27
|
"homepage": "https://github.com/SAP/cloud-mta-build-tool#readme",
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"npm-run-all": "4.1.5"
|
|
29
|
+
"axios": "^1.4.0",
|
|
30
|
+
"tar": "^6.1.0",
|
|
31
|
+
"unzip-stream": "^0.3.1"
|
|
36
32
|
}
|
|
37
33
|
}
|