Switch to Brotli-compressed binaries, requires Node.js 10.16.0+

This commit is contained in:
Lovell Fuller 2020-06-29 20:53:58 +01:00
parent 7c1c48327e
commit ba17db3ab3
7 changed files with 34 additions and 23 deletions

View File

@ -16,7 +16,7 @@ Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available.
Most modern macOS, Windows and Linux systems running Node.js v10+
Most modern macOS, Windows and Linux systems running Node.js v10.16.0+
do not require any additional install or runtime dependencies.
## Examples

View File

@ -16,7 +16,7 @@ Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available.
Most modern macOS, Windows and Linux systems running Node.js v10+
Most modern macOS, Windows and Linux systems running Node.js v10.16.0+
do not require any additional install or runtime dependencies.
### Formats

View File

@ -1,5 +1,13 @@
# Changelog
## v0.26 - *zoom*
Requires libvips v8.9.2
### v0.26.0 - TBD
* Prebuilt libvips binaries are now statically-linked and Brotli-compressed, requiring Node.js 10.16.0+.
## v0.25 - *yield*
Requires libvips v8.9.1

View File

@ -10,19 +10,19 @@ yarn add sharp
## Prerequisites
* Node.js v10+
* Node.js v10.16.0+
## Prebuilt binaries
Ready-compiled sharp and libvips binaries are provided for use with
Node.js v10+ on the most common platforms:
Node.js v10.16.0+ on the most common platforms:
* macOS x64 (>= 10.13)
* Linux x64 (glibc >= 2.17, musl >= 1.1.24)
* Linux ARM64 (glibc >= 2.29)
* Windows
A ~10MB tarball containing libvips and its most commonly used dependencies
A ~7MB tarball containing libvips and its most commonly used dependencies
is downloaded via HTTPS and stored within `node_modules/sharp/vendor` during `npm install`.
This provides support for the
@ -93,7 +93,7 @@ The version subpath and file name are appended to these.
For example, if `sharp_libvips_binary_host` is set to `https://hostname/path`
and the libvips version is `1.2.3` then the resultant URL will be
`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.gz`.
`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.br`.
See the Chinese mirror below for a further example.

View File

@ -3,12 +3,14 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const stream = require('stream');
const zlib = require('zlib');
const detectLibc = require('detect-libc');
const npmLog = require('npmlog');
const semver = require('semver');
const simpleGet = require('simple-get');
const tar = require('tar');
const tarFs = require('tar-fs');
const agent = require('../lib/agent');
const libvips = require('../lib/libvips');
@ -39,18 +41,19 @@ const extractTarball = function (tarPath) {
libvips.mkdirSync(vendorPath);
const versionedVendorPath = path.join(vendorPath, minimumLibvipsVersion);
libvips.mkdirSync(versionedVendorPath);
tar
.extract({
file: tarPath,
cwd: versionedVendorPath,
strict: true
})
.catch(function (err) {
stream.pipeline(
fs.createReadStream(tarPath),
new zlib.BrotliDecompress(),
tarFs.extract(versionedVendorPath),
function (err) {
if (err) {
if (/unexpected end of file/.test(err.message)) {
npmLog.error('sharp', `Please delete ${tarPath} as it is not a valid tarball`);
}
fail(err);
});
}
}
);
};
try {
@ -78,7 +81,7 @@ try {
}
}
// Download to per-process temporary file
const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.gz';
const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.br';
const tarPathCache = path.join(libvips.cachePath(), tarFilename);
if (fs.existsSync(tarPathCache)) {
npmLog.info('sharp', `Using cached ${tarPathCache}`);

View File

@ -116,7 +116,7 @@
"prebuild-install": "^5.3.4",
"semver": "^7.3.2",
"simple-get": "^4.0.0",
"tar": "^6.0.2",
"tar-fs": "^2.1.0",
"tunnel-agent": "^0.6.0"
},
"devDependencies": {
@ -137,10 +137,10 @@
},
"license": "Apache-2.0",
"config": {
"libvips": "8.9.2-alpha2"
"libvips": "8.9.2-alpha5"
},
"engines": {
"node": ">=10"
"node": ">=10.16.0"
},
"funding": {
"url": "https://opencollective.com/libvips"

View File

@ -25,7 +25,7 @@
// Verify platform and compiler compatibility
#if (VIPS_MAJOR_VERSION < 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 9))
#error "libvips version 8.9.1+ is required - please see https://sharp.pixelplumbing.com/install"
#error "libvips version 8.9.2+ is required - please see https://sharp.pixelplumbing.com/install"
#endif
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))