Skip to content

feat!: bump engines requirement to Node 22 #1167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.d.ts
/node_modules
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2025,
sourceType: 'module',
},
plugins: ['mocha', '@typescript-eslint'],
env: {
es6: true,
mocha: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'mocha/no-exclusive-tests': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
vars: 'all',
},
],
semi: 'off',
'@typescript-eslint/semi': 'error',
'no-unexpected-multiline': 'error',
},
};
35 changes: 35 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish documentation

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*

permissions:
id-token: write
contents: read

jobs:
docs:
runs-on: ubuntu-latest
environment: docs-publish
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # tag: v4.2.0
with:
node-version: 22.12.x
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build API documentation
run: yarn build:docs
- name: Azure login
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0
with:
client-id: ${{ secrets.AZURE_OIDC_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_OIDC_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_OIDC_SUBSCRIPTION_ID }}
- name: Upload to Azure Blob Storage
uses: azure/cli@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # tag: v2.1.0
with:
inlineScript: |
az storage blob upload-batch --account-name ${{ secrets.AZURE_ECOSYSTEM_PACKAGES_STORAGE_ACCOUNT_NAME }} -d '$web/rebuild/${{ github.ref_name }}' -s ./docs --overwrite --auth-mode login
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: 20.x
node-version: 22.12.x
cache: 'yarn'
- name: Install
run: yarn install --frozen-lockfile
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
strategy:
matrix:
node-version:
- '20.9'
- '18.17'
- '16.20'
- '14.16'
- '22.12.x'
os:
- macos-latest
- ubuntu-latest
Expand All @@ -33,9 +30,6 @@ jobs:
GYP_MSVS_VERSION: '2022'
steps:
- run: git config --global core.autocrlf input
- name: Install Rosetta
if: ${{ matrix.os == 'macos-latest' && (matrix.node-version == '14.16' || matrix.node-version == '12.22') }}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- name: Enable Long Paths (Windows)
if : ${{ matrix.os == 'windows-latest' }}
run: |
Expand All @@ -53,11 +47,7 @@ jobs:
with:
node-version: "${{ matrix.node-version }}"
cache: 'yarn'
architecture: ${{ matrix.os == 'macos-latest' && (matrix.node-version == '14.16' || matrix.node-version == '12.22') && 'x64' || env.RUNNER_ARCH }}
- name: Update npm
if: ${{ matrix.node-version == '14.16' || matrix.node-version == '12.22' }}
run: npm install -g npm@8 # Update npm so it works with latest Python 3
- name: Install
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: yarn run lint
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ node_modules

lib
test-dist

docs
10 changes: 10 additions & 0 deletions .mocharc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// See also: https://github.com/mochajs/mocha/blob/b720ec1b3ca630a90f80311da391b2a0cdfead4e/example/config/.mocharc.js
{
"$schema": "https://json.schemastore.org/mocharc",
"color": false,
"extensions": [
"ts"
],
"import": "tsx",
"spec": ["test/*.ts"]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.12
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ npm run rebuild

### What are the requirements?

Node v12.13.0 or higher is required. Building native modules from source uses
Node v22.12.0 or higher is required. Building native modules from source uses
[`node-gyp`](https://github.com/nodejs/node-gyp#installation), refer to the link for its
installation/runtime requirements.

Expand Down Expand Up @@ -102,7 +102,7 @@ for Electron Packager. For example:

```javascript
import packager from '@electron/packager';
import rebuild from '@electron/rebuild';
import { rebuild } from '@electron/rebuild';

packager({
// … other options
Expand All @@ -128,7 +128,7 @@ electron-rebuild is also a library that you can require into your app or
build process. It has a very simple API:

```javascript
import rebuild from '@electron/rebuild';
import { rebuild } from '@electron/rebuild';

// Public: Rebuilds a node_modules directory with the given Electron version.
//
Expand All @@ -151,16 +151,29 @@ import rebuild from '@electron/rebuild';
A full build process might look something like:

```javascript
const childProcess = require('child_process');
const pathToElectron = require('electron');

rebuild({
buildPath: __dirname,
electronVersion: '1.4.12'
})
.then(() => console.info('Rebuild Successful'))
.catch((e) => {
console.error("Building modules didn't work!");
console.error(e);
});
// ESM
import { rebuild } from '@electron/rebuild'

rebuild({
buildPath: import.meta.dirname,
electronVersion: '35.1.5'
})
.then(() => console.info('Rebuild Successful'))
.catch((e) => {
console.error('Building modules didn\'t work!')
console.error(e)
})

// CommonJS
const { rebuild } = require('@electron/rebuild')

rebuild({
buildPath: __dirname,
electronVersion: '35.1.5'
})
.then(() => console.info('Rebuild Successful'))
.catch((e) => {
console.error('Building modules didn\'t work!')
console.error(e)
})
```
82 changes: 19 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
"name": "@electron/rebuild",
"version": "0.0.0-development",
"description": "Electron supporting package to rebuild native node modules against the currently installed electron",
"main": "lib/main.js",
"type": "module",
"exports": "./lib/main.js",
"typings": "lib/main.d.ts",
"scripts": {
"compile": "tsc",
"build": "tsc",
"build:docs": "typedoc src/main.ts",
"coverage": "npm run prewarm-headers && nyc npm run spec",
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov",
"watch": "tsc -w",
"prepare": "npm run compile",
"mocha": "cross-env TS_NODE_FILES=true mocha",
"prepare": "npm run build",
"lint": "eslint --ext .ts .",
"spec": "tsc && npm run mocha -- test/*.ts",
"spec": "tsc && mocha",
"test": "npm run prewarm-headers && npm run lint && npm run spec",
"prewarm-headers": "node-gyp install --ensure"
},
Expand All @@ -39,7 +40,7 @@
},
"homepage": "https://github.com/electron/rebuild",
"engines": {
"node": ">=12.13.0"
"node": ">=22.12.0"
},
"publishConfig": {
"provenance": true
Expand All @@ -50,10 +51,10 @@
"chalk": "^4.0.0",
"debug": "^4.1.1",
"detect-libc": "^2.0.1",
"fs-extra": "^10.0.0",
"got": "^11.7.0",
"node-abi": "^3.45.0",
"node-api-version": "^0.2.0",
"graceful-fs": "^4.2.11",
"node-abi": "^4.2.0",
"node-api-version": "^0.2.1",
"ora": "^5.1.0",
"read-binary-file-arch": "^1.0.6",
"semver": "^7.3.5",
Expand All @@ -62,74 +63,29 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@tsconfig/node22": "^22.0.0",
"@types/chai": "^4.2.12",
"@types/chai-as-promised": "^7.1.3",
"@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.1",
"@types/graceful-fs": "^4.1.9",
"@types/mocha": "^10.0.10",
"@types/node": "^17.0.8",
"@types/node": "~22.10.7",
"@types/node-abi": "^3.0.0",
"@types/semver": "^7.3.9",
"@types/tar": "^6.1.0",
"@types/yargs": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.2",
"electron": "^22.0.0",
"eslint": "^7.7.0",
"eslint-plugin-mocha": "^9.0.0",
"mocha": "^10.8.2",
"mocha": "^11.1.0",
"nyc": "^15.1.0",
"ts-node": "^10.0.0",
"typescript": "^4.0.2"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"plugins": [
"mocha",
"@typescript-eslint"
],
"env": {
"es6": true,
"mocha": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"mocha/no-exclusive-tests": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "after-used",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"vars": "all"
}
],
"semi": "off",
"@typescript-eslint/semi": "error",
"no-unexpected-multiline": "error"
}
},
"eslintIgnore": [
"*.d.ts",
"node_modules"
],
"mocha": {
"extensions": [
"ts"
],
"require": "ts-node/register"
"tsx": "^4.19.3",
"typedoc": "~0.25.13",
"typescript": "~5.4.5"
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript"
Expand Down
2 changes: 1 addition & 1 deletion src/arch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'child_process';
import { execSync } from 'node:child_process';

/**
* Runs the `uname` command and returns the trimmed output.
Expand Down
Loading