@appsignal/nodejs-ext
Advanced tools
Comparing version
{ | ||
"name": "@appsignal/nodejs-ext", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"main": "dist/index.js", | ||
@@ -19,2 +19,11 @@ "license": "MIT", | ||
}, | ||
"os": [ | ||
"linux", | ||
"darwin", | ||
"freebsd" | ||
], | ||
"cpu": [ | ||
"x64", | ||
"x86" | ||
], | ||
"engines": { | ||
@@ -26,3 +35,3 @@ "node": ">= 10" | ||
}, | ||
"gitHead": "3e695a7fe2df88f85e4e6e6458d15de1f28fa5e5" | ||
"gitHead": "2ff2349561142986ae330365f5fb1a8c430bf3d9" | ||
} |
@@ -13,3 +13,4 @@ #!/usr/bin/env node | ||
hasLocalBuild, | ||
hasSupportedArchitecture | ||
hasSupportedArchitecture, | ||
hasSupportedOs | ||
} = require("./extension/helpers") | ||
@@ -82,32 +83,44 @@ | ||
console.warn(`Using local build for agent. Skipping download.`) | ||
process.exit(0) | ||
} else if (hasSupportedArchitecture(report)) { | ||
// try and get one from the CDN | ||
const metadata = getMetadataForTarget(report) | ||
const filename = metadata.downloadUrl.split("/")[4] | ||
const outputPath = path.join(EXT_PATH, filename) | ||
return process.exit(0) | ||
} | ||
return download(metadata.downloadUrl, outputPath) | ||
.then(filepath => { | ||
return verify(filepath, metadata.checksum).then(() => extract(filepath)) | ||
}) | ||
.then(() => { | ||
// once extracted, we can then hand off to node-gyp for building | ||
// @TODO: add cleanup step | ||
console.log("The agent has installed successfully!") | ||
process.exit(0) | ||
}) | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) | ||
} else { | ||
// bail :( | ||
if (!hasSupportedArchitecture(report)) { | ||
console.error( | ||
`AppSignal currently does not support your system architecture | ||
(${process.platform} ${process.arch}). Please let us know at | ||
support@appsignal.com, we aim to support everything our customers run.` | ||
(${process.platform} ${process.arch}). Please let us know at | ||
support@appsignal.com, we aim to support everything our customers run.` | ||
) | ||
process.exit(1) | ||
return process.exit(1) | ||
} | ||
if (!hasSupportedOs(report)) { | ||
console.error( | ||
`AppSignal currently does not support your operating system (${process.platform}). | ||
Please let us know at support@appsignal.com, we aim to support everything | ||
our customers run.` | ||
) | ||
return process.exit(1) | ||
} | ||
// try and get one from the CDN | ||
const metadata = getMetadataForTarget(report) | ||
const filename = metadata.downloadUrl.split("/")[4] | ||
const outputPath = path.join(EXT_PATH, filename) | ||
return download(metadata.downloadUrl, outputPath) | ||
.then(filepath => { | ||
return verify(filepath, metadata.checksum).then(() => extract(filepath)) | ||
}) | ||
.then(() => { | ||
// once extracted, we can then hand off to node-gyp for building | ||
// @TODO: add cleanup step | ||
console.log("The agent has installed successfully!") | ||
process.exit(0) | ||
}) | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) | ||
})() |
@@ -33,2 +33,17 @@ const path = require("path") | ||
/** | ||
* Returns `true` if the current operating systrm is supported by the agent. and vice versa | ||
* | ||
* @param {object} report A valid report object | ||
* | ||
* @return {boolean} | ||
*/ | ||
function hasSupportedOs(report) { | ||
return ( | ||
report.build.target === "darwin" || | ||
report.build.target === "freebsd" || | ||
report.build.target === "linux" | ||
) | ||
} | ||
/** | ||
* Returns `true` if the current linux system is using musl as its libc and vice versa | ||
@@ -39,5 +54,10 @@ * | ||
function hasMusl() { | ||
return /musl/.test(child_process.spawnSync("ldd", ["--version"]).stderr); | ||
return /musl/.test(child_process.spawnSync("ldd", ["--version"]).stderr) | ||
} | ||
module.exports = { hasLocalBuild, hasSupportedArchitecture, hasMusl } | ||
module.exports = { | ||
hasLocalBuild, | ||
hasSupportedArchitecture, | ||
hasMusl, | ||
hasSupportedOs | ||
} |
29536
1.54%247
6.01%10
-16.67%