Compare commits

...

12 Commits

Author SHA1 Message Date
Lovell Fuller
ab00e34d0d Prerelease 0.33.0-alpha.7 2023-10-10 14:47:13 +01:00
Lovell Fuller
7c2f883b67 CI: add pnpm and yarn to npm smoke tests 2023-10-10 11:15:55 +01:00
Lovell Fuller
9b5eecba8f Yarn pnp unsupported, use alternative nodeLinker 2023-10-10 11:14:39 +01:00
Lovell Fuller
4b028edfe9 Revert "Remove extraneous rpath"
This reverts commit 3f54ef7525.

The filesystem layout used by pnpm means that a nesting of 2
directories deep is used in the wild and must remain.
2023-10-10 09:56:07 +01:00
Lovell Fuller
7e25dd7be1 Ensure versions prop detects use of global libvips 2023-10-10 09:18:25 +01:00
Lovell Fuller
09460d7af4 CI: use correct version of write-file action 2023-10-09 13:36:03 +01:00
Lovell Fuller
3b22640077 Use std::snprintf to concat libvips version parts 2023-10-09 13:35:20 +01:00
Lovell Fuller
946976ba8f Prerelease 0.33.0-alpha.6 2023-10-09 10:46:16 +01:00
Lovell Fuller
29a83250a4 CI: Add smoke test for npm-published package
These tests will fail on their first run as a tag will exist but
the matching packages will not yet have been published.

The workflow can be manually re-run after publishing to npm.

Eventually, when there's some form of automated publishing, this
logic can become part of the post-publish checks.
2023-10-09 07:59:47 +01:00
Lovell Fuller
3f54ef7525 Remove extraneous rpath
The sharp.node shared library should now always end up being
nested either 3 subdirectories deep into the package root or exist
within same namespace of the node_modules tree.
2023-10-09 07:58:14 +01:00
Lovell Fuller
4dc2467f49 CI: simplify prebuild file copying 2023-10-08 23:07:02 +01:00
Lovell Fuller
f54ceb0973 CI: create prebuilds in src directory 2023-10-08 21:49:58 +01:00
20 changed files with 169 additions and 38 deletions

View File

@@ -42,7 +42,7 @@ jobs:
sudo docker exec sharp sh -c "npm run clean"
sudo docker exec sharp sh -c "npm install --ignore-scripts"
sudo docker exec sharp sh -c "npm test"
- run: "[[ -n $CIRCLE_TAG ]] && sudo docker exec --env prebuild_upload sharp sh -c \"npx prebuild --upload=$prebuild_upload\" || true"
- run: "[[ -n $CIRCLE_TAG ]] && sudo docker exec --env prebuild_upload sharp sh -c \"cd src && ln -s ../package.json && npx prebuild --upload=$prebuild_upload\" || true"
linux-arm64-glibc-node-20:
resource_class: arm.medium
machine:
@@ -83,7 +83,7 @@ jobs:
sudo docker exec sharp sh -c "npm run clean"
sudo docker exec sharp sh -c "npm install --ignore-scripts"
sudo docker exec sharp sh -c "npm test"
- run: "[[ -n $CIRCLE_TAG ]] && sudo docker exec --env prebuild_upload sharp sh -c \"npx prebuild --upload=$prebuild_upload\" || true"
- run: "[[ -n $CIRCLE_TAG ]] && sudo docker exec --env prebuild_upload sharp sh -c \"cd src && ln -s ../package.json && npx prebuild --upload=$prebuild_upload\" || true"
linux-arm64-musl-node-20:
resource_class: arm.medium
machine:

View File

@@ -114,7 +114,10 @@ jobs:
if: matrix.prebuild && startsWith(github.ref, 'refs/tags/')
env:
prebuild_upload: ${{ secrets.GITHUB_TOKEN }}
run: npx prebuild
run: |
node -e "require('fs').cpSync('package.json', 'src/package.json')"
cd src
npx prebuild
github-runner-qemu:
permissions:
contents: write
@@ -142,7 +145,7 @@ jobs:
npm run clean
npm install --ignore-scripts
npx mocha --no-config --spec=test/unit/io.js --timeout=30000
[[ -n $prebuild_upload ]] && npx prebuild || true
[[ -n $prebuild_upload ]] && cd src && ln -s ../package.json && npx prebuild || true
macstadium-runner:
permissions:
contents: write
@@ -187,4 +190,4 @@ jobs:
if: matrix.prebuild && startsWith(github.ref, 'refs/tags/')
env:
prebuild_upload: ${{ secrets.GITHUB_TOKEN }}
run: npx prebuild
run: cd src && ln -s ../package.json && npx prebuild

100
.github/workflows/npm.yml vendored Normal file
View File

@@ -0,0 +1,100 @@
name: "CI: npm smoke test"
on:
push:
tags:
- "v**"
permissions: {}
jobs:
release-smoke-test:
name: "${{ github.ref }} ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64
os: ubuntu-22.04
- name: darwin-x64
os: macos-11
- name: win32-x64
os: windows-2019
steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Install Bun
if: ${{ !contains(matrix.os, 'windows') }}
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Version
id: version
uses: actions/github-script@v6
with:
script: |
core.setOutput('semver', context.ref.replace('refs/tags/v',''))
- name: Create package.json
uses: DamianReeves/write-file-action@v1.2
with:
path: package.json
contents: |
{
"dependencies": {
"sharp": "${{ steps.version.outputs.semver }}"
}
}
- name: Create release.mjs
uses: DamianReeves/write-file-action@v1.2
with:
path: release.mjs
contents: |
import { createRequire } from 'node:module';
import { deepStrictEqual } from 'node:assert';
const require = createRequire(import.meta.url);
const sharp = require('sharp');
deepStrictEqual(['.jpg', '.jpeg', '.jpe'], sharp.format.jpeg.input.fileSuffix);
- name: Run with Node.js + npm
run: |
npm install --ignore-scripts
node release.mjs
rm -r node_modules/ package-lock.json
- name: Run with Node.js + pnpm
run: |
pnpm install --ignore-scripts
node release.mjs
rm -r node_modules/ pnpm-lock.yaml
- name: Run with Node.js + yarn
run: |
corepack enable
yarn set version stable
yarn config set enableScripts false
yarn config set nodeLinker node-modules
yarn install
node release.mjs
rm -r node_modules/ .yarn/ yarn.lock .yarnrc.yml
corepack disable
- name: Run with Deno
run: deno run --allow-read --allow-ffi release.mjs
- name: Run with Bun
if: ${{ !contains(matrix.os, 'windows') }}
run: |
bun install --ignore-scripts
bun release.mjs

View File

@@ -1,7 +1,8 @@
## versions
> versions
An Object containing the version numbers of sharp, libvips and its dependencies.
An Object containing the version numbers of sharp, libvips
and (when using prebuilt binaries) its dependencies.
**Example**

View File

@@ -5,13 +5,15 @@ npm install sharp
```
```sh
yarn add sharp
pnpm add sharp
```
```sh
pnpm add sharp
yarn add sharp
```
Yarn Plug'n'Play is unsupported.
## Prerequisites
* Node.js >= 18.17.0

File diff suppressed because one or more lines are too long

View File

@@ -53,6 +53,10 @@ try {
if (errPackage.code === 'ERR_DLOPEN_DISABLED') {
help.push('- Run Node.js without using the --no-addons flag');
}
if (process.versions.pnp) {
help.push('- Use a supported yarn linker, either pnpm or node-modules');
help.push(' yarn config set nodeLinker node-modules');
}
// Link to installation docs
if (isLinux && /Module did not self-register/.test(errLocal.message + errPackage.message)) {
help.push('- Using worker threads on Linux? See https://sharp.pixelplumbing.com/install#worker-threads');

View File

@@ -10,6 +10,9 @@ const is = require('./is');
const { runtimePlatformArch } = require('./libvips');
const sharp = require('./sharp');
const runtimePlatform = runtimePlatformArch();
const libvipsVersion = sharp.libvipsVersion();
/**
* An Object containing nested boolean values representing the available input and output formats/methods.
* @member
@@ -44,20 +47,25 @@ const interpolators = {
};
/**
* An Object containing the version numbers of sharp, libvips and its dependencies.
* An Object containing the version numbers of sharp, libvips
* and (when using prebuilt binaries) its dependencies.
*
* @member
* @example
* console.log(sharp.versions);
*/
let versions = {
vips: sharp.libvipsVersion()
vips: libvipsVersion.semver
};
try {
versions = require(`@sharpen/sharp-${runtimePlatformArch()}/versions`);
} catch (_) {
/* istanbul ignore next */
if (!libvipsVersion.isGlobal) {
try {
versions = require(`@sharpen/sharp-libvips-${runtimePlatformArch()}/versions`);
} catch (_) {}
versions = require(`@sharpen/sharp-${runtimePlatform}/versions`);
} catch (_) {
try {
versions = require(`@sharpen/sharp-libvips-${runtimePlatform}/versions`);
} catch (_) {}
}
}
versions.sharp = require('../package.json').version;

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-darwin-arm64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with macOS ARM64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-darwin-x64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with macOS x64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-linux-arm",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Linux (glibc) ARM (32-bit)",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-linux-arm64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Linux (glibc) ARM64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-linux-x64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Linux (glibc) x64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-linuxmusl-arm64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Linux (musl) ARM64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-linuxmusl-x64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Linux (musl) x64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-win32-ia32",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Windows x86 (32-bit)",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@sharpen/sharp-win32-x64",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.7",
"description": "Prebuilt sharp for use with Windows x64",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {

View File

@@ -1,7 +1,7 @@
{
"name": "sharp",
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
"version": "0.33.0-alpha.5",
"version": "0.33.0-alpha.7",
"author": "Lovell Fuller <npm@lovell.info>",
"homepage": "https://github.com/lovell/sharp",
"contributors": [
@@ -139,8 +139,8 @@
"semver": "^7.5.4"
},
"optionalDependencies": {
"@sharpen/sharp-darwin-arm64": "0.0.1-alpha.5",
"@sharpen/sharp-darwin-x64": "0.0.1-alpha.5",
"@sharpen/sharp-darwin-arm64": "0.0.1-alpha.7",
"@sharpen/sharp-darwin-x64": "0.0.1-alpha.7",
"@sharpen/sharp-libvips-darwin-arm64": "0.0.1-alpha.2",
"@sharpen/sharp-libvips-darwin-x64": "0.0.1-alpha.2",
"@sharpen/sharp-libvips-linux-arm": "0.0.1-alpha.2",
@@ -148,13 +148,13 @@
"@sharpen/sharp-libvips-linux-x64": "0.0.1-alpha.2",
"@sharpen/sharp-libvips-linuxmusl-arm64": "0.0.1-alpha.2",
"@sharpen/sharp-libvips-linuxmusl-x64": "0.0.1-alpha.2",
"@sharpen/sharp-linux-arm": "0.0.1-alpha.5",
"@sharpen/sharp-linux-arm64": "0.0.1-alpha.5",
"@sharpen/sharp-linux-x64": "0.0.1-alpha.5",
"@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.5",
"@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.5",
"@sharpen/sharp-win32-ia32": "0.0.1-alpha.5",
"@sharpen/sharp-win32-x64": "0.0.1-alpha.5"
"@sharpen/sharp-linux-arm": "0.0.1-alpha.7",
"@sharpen/sharp-linux-arm64": "0.0.1-alpha.7",
"@sharpen/sharp-linux-x64": "0.0.1-alpha.7",
"@sharpen/sharp-linuxmusl-arm64": "0.0.1-alpha.7",
"@sharpen/sharp-linuxmusl-x64": "0.0.1-alpha.7",
"@sharpen/sharp-win32-ia32": "0.0.1-alpha.7",
"@sharpen/sharp-win32-x64": "0.0.1-alpha.7"
},
"devDependencies": {
"@sharpen/sharp-libvips-dev": "0.0.1-alpha.2",

View File

@@ -111,6 +111,9 @@
# Use pkg-config for include and lib
'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
'defines': [
'SHARP_USE_GLOBAL_LIBVIPS'
],
'conditions': [
['OS == "linux"', {
'defines': [

View File

@@ -3,6 +3,7 @@
#include <cmath>
#include <string>
#include <cstdio>
#include <napi.h>
#include <vips/vips8>
@@ -91,9 +92,18 @@ Napi::Value simd(const Napi::CallbackInfo& info) {
Get libvips version
*/
Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
char version[9];
g_snprintf(version, sizeof(version), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
return Napi::String::New(info.Env(), version);
Napi::Env env = info.Env();
Napi::Object version = Napi::Object::New(env);
char semver[9];
std::snprintf(semver, sizeof(semver), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
version.Set("semver", Napi::String::New(env, semver));
#ifdef SHARP_USE_GLOBAL_LIBVIPS
version.Set("isGlobal", Napi::Boolean::New(env, true));
#else
version.Set("isGlobal", Napi::Boolean::New(env, false));
#endif
return version;
}
/*