diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..79ae86e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,33 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "npm" + + directory: "/" + + schedule: + interval: "daily" + time: "04:00" + timezone: "Europe/Berlin" + + open-pull-requests-limit: 10 + + assignees: + - "mimmi20" + + labels: + - "dependencies" + + versioning-strategy: "increase" + + target-branch: "master" + + commit-message: + include: "scope" + prefix: "npm" + + rebase-strategy: "auto" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73cb193..8e0f0e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,10 +7,11 @@ jobs: name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 16 - - 18 + - 24 + - 22 - 20 os: - ubuntu-latest diff --git a/lib/index.js b/lib/index.js index 394fc00..b0431b3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,7 @@ import fs from 'node:fs'; import process from 'node:process'; import {fileURLToPath} from 'node:url'; -import BinWrapper from 'bin-wrapper'; +import BinWrapper from '@xhmikosr/bin-wrapper'; const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url))); const url = `https://github.com/imagemin/mozjpeg-bin/raw/${pkg.version}/vendor/`; diff --git a/lib/install.js b/lib/install.js index 86702e2..74b67ff 100644 --- a/lib/install.js +++ b/lib/install.js @@ -3,12 +3,13 @@ import {fileURLToPath} from 'node:url'; import path from 'node:path'; import fs from 'node:fs'; import {execa, $} from 'execa'; -import binBuild from 'bin-build'; +import binBuild from '@localnerve/bin-build'; import bin from './index.js'; -bin.run(['-version']).then(() => { +try { + await bin.run(['-version']); console.log('mozjpeg pre-build test passed successfully'); -}).catch(async error => { +} catch (error) { console.warn(error.message); console.warn('mozjpeg pre-build test failed'); console.info('compiling from source'); @@ -47,9 +48,7 @@ bin.run(['-version']).then(() => { config.push(`-DCMAKE_TOOLCHAIN_FILE=${currentPath}`); } - const cfg = [ - `cmake -DCMAKE_BUILD_TYPE=Release ${config.join(' ')} .`, - ].join(' '); + const cfg = `cmake -DCMAKE_BUILD_TYPE=Release ${config.join(' ')} -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .`; try { const source = fileURLToPath(new URL('../vendor/source/mozjpeg.tar.gz', import.meta.url)); @@ -78,4 +77,4 @@ bin.run(['-version']).then(() => { // eslint-disable-next-line unicorn/no-process-exit process.exit(1); } -}); +} diff --git a/package.json b/package.json index 34b9d60..5b2c8a7 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,11 @@ "exports": "./index.js", "bin": "cli.js", "engines": { - "node": "^16.20.0 || ^18.17.0 || >=20.0.0" + "node": ">=20.0.0" }, "scripts": { "postinstall": "node lib/install.js", - "test": "xo && ava --timeout=180s", + "test": "ava --timeout=180s", "build-linux": "docker build --tag imagemin/mozjpeg docker && docker run --rm --volume $(pwd)/vendor/linux:/src/out imagemin/mozjpeg cp result/cjpeg-static /src/out/cjpeg" }, "files": [ @@ -33,16 +33,16 @@ "optimize" ], "dependencies": { - "bin-build": "^3.0.0", - "bin-wrapper": "^4.1.0" + "@localnerve/bin-build": "^7.7.0", + "@xhmikosr/bin-wrapper": "^13.0.5" }, "devDependencies": { - "ava": "^4.3.3", - "bin-check": "^4.1.0", + "ava": "^6.4.0", + "@lesjoursfr/bin-check": "^7.1.9", "compare-size": "^3.0.0", - "execa": "^7.1.1", + "execa": "^9.6.0", "tempy": "^3.1.0", - "xo": "^0.45.0" + "xo": "^1.1.0" }, "ava": { "serial": true diff --git a/test/test.js b/test/test.js index 8ecc6d8..4e07737 100644 --- a/test/test.js +++ b/test/test.js @@ -5,27 +5,26 @@ import {fileURLToPath} from 'node:url'; import test from 'ava'; import {execa} from 'execa'; import {temporaryDirectory} from 'tempy'; -import binCheck from 'bin-check'; -import binBuild from 'bin-build'; +import binCheck from '@lesjoursfr/bin-check'; +import binBuild from '@localnerve/bin-build'; import compareSize from 'compare-size'; import mozjpeg from '../index.js'; test('rebuild the mozjpeg binaries', async t => { - const temporary = temporaryDirectory(); - const config = []; // Skip the test on Windows if (process.platform === 'win32') { t.pass(); return; } + const temporary = temporaryDirectory(); + const config = []; + if (process.platform === 'darwin') { config.push('-DCMAKE_FIND_FRAMEWORK=LAST -DBUILD_SHARED_LIBS=OFF'); } - const cfg = [ - `cmake ${config.join(' ')} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${temporary}" .`, - ].join(' '); + const cfg = `cmake ${config.join(' ')} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${temporary}" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .`; const source = fileURLToPath(new URL('../vendor/source/mozjpeg.tar.gz', import.meta.url)); await binBuild.file(source, [ @@ -38,10 +37,22 @@ test('rebuild the mozjpeg binaries', async t => { }); test('return path to binary and verify that it is working', async t => { + // Skip the test on Windows + if (process.platform === 'win32') { + t.pass(); + return; + } + t.true(await binCheck(mozjpeg, ['-version'])); }); test('minify a JPG', async t => { + // Skip the test on Windows + if (process.platform === 'win32') { + t.pass(); + return; + } + const temporary = temporaryDirectory(); const src = fileURLToPath(new URL('fixtures/test.jpg', import.meta.url)); const dest = path.join(temporary, 'test.jpg');