diff --git a/.gitignore b/.gitignore index a312f5d6..c20d1458 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ libvips* *.log deps/ target/ +npm/*/* +!npm/*/package.json +npm/img-sharp-libvips-*.tgz diff --git a/README.md b/README.md index 170c35ff..9bac641c 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,8 @@ libvips and its dependencies are provided as pre-compiled shared libraries for the most common operating systems and CPU architectures. -During `npm install`, these binaries are fetched as tarballs from -this repository via HTTPS and stored locally within `node_modules/sharp/vendor`. - -The base URL can be overridden using the -`npm_config_sharp_libvips_binary_host` environment variable. - -https://sharp.pixelplumbing.com/install#custom-prebuilt-binaries +These are [packaged](npm) and published to the npm registry under the +[@img](https://www.npmjs.com/org/img) organisation. ## Creating a tarball diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json new file mode 100644 index 00000000..5e5863db --- /dev/null +++ b/npm/darwin-arm64/package.json @@ -0,0 +1,42 @@ +{ + "name": "@img/sharp-libvips-darwin-arm64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on macOS 64-bit ARM", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/darwin-arm64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "macos": ">=11" + }, + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ] +} diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json new file mode 100644 index 00000000..d95168fc --- /dev/null +++ b/npm/darwin-x64/package.json @@ -0,0 +1,42 @@ +{ + "name": "@img/sharp-libvips-darwin-x64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on macOS x64", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/darwin-x64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "macos": ">=10.13" + }, + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ] +} diff --git a/npm/dev/package.json b/npm/dev/package.json new file mode 100644 index 00000000..a16f7d56 --- /dev/null +++ b/npm/dev/package.json @@ -0,0 +1,30 @@ +{ + "name": "@img/sharp-libvips-dev", + "version": "0.0.2", + "description": "Header files and C++ sources for libvips and dependencies required when compiling sharp from source", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/dev" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "include", + "cplusplus", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./include": "./include/index.js", + "./cplusplus": "./cplusplus/index.js" + } +} diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json new file mode 100644 index 00000000..b4b2f5b7 --- /dev/null +++ b/npm/linux-arm/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linux-arm", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) 32-bit ARM", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linux-arm" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "type": "commonjs", + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "glibc": ">=2.28" + }, + "os": [ + "linux" + ], + "libc": [ + "glibc" + ], + "cpu": [ + "arm" + ] +} diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json new file mode 100644 index 00000000..fa5bd423 --- /dev/null +++ b/npm/linux-arm64/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linux-arm64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) 64-bit ARM", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linux-arm64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "glibc": ">=2.26" + }, + "os": [ + "linux" + ], + "libc": [ + "glibc" + ], + "cpu": [ + "arm64" + ] +} diff --git a/npm/linux-s390x/package.json b/npm/linux-s390x/package.json new file mode 100644 index 00000000..7f753339 --- /dev/null +++ b/npm/linux-s390x/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linux-s390x", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) s390x", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linux-s390x" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "type": "commonjs", + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "glibc": ">=2.28" + }, + "os": [ + "linux" + ], + "libc": [ + "glibc" + ], + "cpu": [ + "s390x" + ] +} diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json new file mode 100644 index 00000000..7aaed92a --- /dev/null +++ b/npm/linux-x64/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linux-x64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linux-x64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "glibc": ">=2.26" + }, + "os": [ + "linux" + ], + "libc": [ + "glibc" + ], + "cpu": [ + "x64" + ] +} diff --git a/npm/linuxmusl-arm64/package.json b/npm/linuxmusl-arm64/package.json new file mode 100644 index 00000000..ad9aaed1 --- /dev/null +++ b/npm/linuxmusl-arm64/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linuxmusl-arm64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (musl) 64-bit ARM", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linuxmusl-arm64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "musl": ">=1.2.2" + }, + "os": [ + "linux" + ], + "libc": [ + "musl" + ], + "cpu": [ + "arm64" + ] +} diff --git a/npm/linuxmusl-x64/package.json b/npm/linuxmusl-x64/package.json new file mode 100644 index 00000000..bc77f597 --- /dev/null +++ b/npm/linuxmusl-x64/package.json @@ -0,0 +1,45 @@ +{ + "name": "@img/sharp-libvips-linuxmusl-x64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/linuxmusl-x64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + }, + "engines": { + "npm": ">=9.6.5", + "yarn": ">=3.2.0", + "pnpm": ">=7.1.0", + "musl": ">=1.2.2" + }, + "os": [ + "linux" + ], + "libc": [ + "musl" + ], + "cpu": [ + "x64" + ] +} diff --git a/npm/package.json b/npm/package.json new file mode 100644 index 00000000..1aaf2db8 --- /dev/null +++ b/npm/package.json @@ -0,0 +1,18 @@ +{ + "name": "@img/sharp-libvips", + "version": "0.0.2", + "private": "true", + "workspaces": [ + "dev", + "darwin-x64", + "darwin-arm64", + "linux-arm", + "linux-arm64", + "linuxmusl-arm64", + "linuxmusl-x64", + "linux-s390x", + "linux-x64", + "win32-ia32", + "win32-x64" + ] +} diff --git a/npm/populate.sh b/npm/populate.sh new file mode 100755 index 00000000..f53f9581 --- /dev/null +++ b/npm/populate.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -e + +LIBVIPS_VERSION=$(cat LIBVIPS_VERSION) +CURL="curl --silent --location" + +download_extract() { + PLATFORM="$1" + PACKAGE="${1%v[68]}" # remove ARM version + echo "$PLATFORM -> $PACKAGE" + rm -rf "npm/$PACKAGE/include" "npm/$PACKAGE/lib" + $CURL \ + "https://github.com/lovell/sharp-libvips/releases/download/v$LIBVIPS_VERSION/libvips-$LIBVIPS_VERSION-$PLATFORM.tar.gz" | \ + tar xzC "npm/$PACKAGE" --exclude="platform.json" +} + +download_cpp() { + $CURL \ + --remote-name --output-dir "npm/dev/cplusplus" --create-dirs \ + "https://raw.githubusercontent.com/libvips/libvips/v$LIBVIPS_VERSION/cplusplus/$1.cpp" +} + +generate_readme() { + PACKAGE="$1" + jq -r '("# `" + .name + "`\n\n" + .description + ".\n")' "npm/$PACKAGE/package.json" > "npm/$PACKAGE/README.md" + echo "## Licensing" >> "npm/$PACKAGE/README.md" + cat "npm/$PACKAGE/THIRD-PARTY-NOTICES.md" | tail -n +2 >> "npm/$PACKAGE/README.md" +} + +generate_index() { + PACKAGE="$1" + for dir in include lib cplusplus; do + if [ -d "npm/$PACKAGE/$dir" ]; then + echo "module.exports = __dirname;" > "npm/$PACKAGE/$dir/index.js" + fi + done +} + +remove_unused() { + PACKAGE="$1" + if [ "$PACKAGE" != "dev" ]; then + rm -r "npm/$PACKAGE/include" + fi + rm "npm/$PACKAGE/THIRD-PARTY-NOTICES.md" +} + +# Download and extract per-platform binaries +PLATFORMS=$(ls platforms --ignore=*armv7 --ignore=win32*) +for platform in $PLATFORMS; do + download_extract "$platform" +done +download_extract "win32-ia32" +download_extract "win32-x64" + +# Common header and source files +cp -r npm/linux-x64/{include,versions.json,THIRD-PARTY-NOTICES.md} npm/dev/ +find npm/dev/include/ -maxdepth 1 -type f -links +1 -delete +for source in VConnection VError VImage VInterpolate VRegion vips-operators; do + download_cpp "$source" +done; + +# Generate README files +PACKAGES=$(jq -r '.workspaces[]' "npm/package.json") +for package in $PACKAGES; do + generate_readme "$package" + generate_index "$package" + remove_unused "$package" +done diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json new file mode 100644 index 00000000..c4de0545 --- /dev/null +++ b/npm/win32-ia32/package.json @@ -0,0 +1,30 @@ +{ + "name": "@img/sharp-libvips-win32-ia32", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Windows x86", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/win32-ia32" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + } +} diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json new file mode 100644 index 00000000..4473650d --- /dev/null +++ b/npm/win32-x64/package.json @@ -0,0 +1,30 @@ +{ + "name": "@img/sharp-libvips-win32-x64", + "version": "0.0.2", + "description": "Prebuilt libvips and dependencies for use with sharp on Windows x64", + "author": "Lovell Fuller ", + "homepage": "https://sharp.pixelplumbing.com", + "repository": { + "type": "git", + "url": "git+https://github.com/lovell/sharp-libvips.git", + "directory": "npm/win32-x64" + }, + "license": "LGPL-3.0-or-later", + "funding": { + "url": "https://opencollective.com/libvips" + }, + "preferUnplugged": true, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "versions.json" + ], + "type": "commonjs", + "exports": { + "./lib": "./lib/index.js", + "./package": "./package.json", + "./versions": "./versions.json" + } +}