Skip to content

Commit e94b2b8

Browse files
committed
feat!: bump engines to Node.js 22
1 parent e2be210 commit e94b2b8

19 files changed

+2268
-1295
lines changed

.eslintrc.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:jest/recommended",
7+
"plugin:import/errors",
8+
"plugin:import/warnings",
9+
"plugin:import/typescript",
10+
"prettier",
11+
"prettier/@typescript-eslint"
12+
]
13+
}

.github/workflows/test.yml

+3-14
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,24 @@ jobs:
1717
strategy:
1818
matrix:
1919
node-version:
20-
- '20.10'
21-
- '18.18'
22-
- '16.20'
23-
- '14.16'
20+
- '22.13'
2421
os:
2522
- macos-latest
2623
- ubuntu-latest
2724
- windows-latest
2825
runs-on: "${{ matrix.os }}"
2926
steps:
3027
- run: git config --global core.autocrlf input
31-
- name: Install Rosetta
32-
if: ${{ matrix.os == 'macos-latest' && matrix.node-version == '14.16' }}
33-
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
3428
- name: Checkout
3529
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3630
- name: Setup Node.js
3731
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
3832
with:
3933
node-version: "${{ matrix.node-version }}"
4034
cache: 'yarn'
41-
architecture: ${{ matrix.os == 'macos-latest' && matrix.node-version == '14.16' && 'x64' || env.RUNNER_ARCH }}
42-
- name: Install (Node.js v16+)
43-
if : ${{ matrix.node-version != '14.16' }}
35+
- name: Install dependencies
4436
run: yarn install --frozen-lockfile
45-
- name: Install (Node.js < v16)
46-
if : ${{ matrix.node-version == '14.16' }}
47-
run: yarn install --frozen-lockfile --ignore-engines
4837
- name: Test
49-
run: yarn test
38+
run: yarn lint && yarn test
5039
- name: Build docs
5140
run: yarn build:docs

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.13

jest.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const path = require('path');
1+
const path = require('node:path');
22

33
module.exports = {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
6-
testPathIgnorePatterns: ['node_modules', path.resolve(__dirname, 'lib')]
7-
};
6+
testPathIgnorePatterns: ['node_modules', path.resolve(__dirname, 'lib')],
7+
};

package.json

+12-46
Original file line numberDiff line numberDiff line change
@@ -14,89 +14,55 @@
1414
"build": "tsc && tsc -p tsconfig.esm.json",
1515
"build:docs": "npx typedoc",
1616
"eslint": "eslint --ext .ts src test",
17-
"jest": "jest --coverage",
17+
"test": "jest",
1818
"lint": "npm run prettier && npm run eslint",
1919
"prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
2020
"prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
2121
"prepublishOnly": "npm run build",
22-
"test": "npm run lint && npm run jest",
2322
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
2423
},
25-
"files": [
26-
"dist/",
27-
"README.md"
28-
],
24+
"files": ["dist/", "README.md"],
2925
"engines": {
30-
"node": ">=14"
26+
"node": ">=22.0.0"
3127
},
3228
"dependencies": {
3329
"debug": "^4.1.1",
3430
"env-paths": "^2.2.0",
35-
"fs-extra": "^8.1.0",
3631
"got": "^11.8.5",
3732
"progress": "^2.0.3",
3833
"semver": "^6.2.0",
3934
"sumchecker": "^3.0.1"
4035
},
4136
"devDependencies": {
4237
"@types/debug": "^4.1.4",
43-
"@types/fs-extra": "^8.0.0",
4438
"@types/jest": "^29.0.0",
45-
"@types/node": "^12.20.55",
39+
"@types/node": "^22.10.5",
4640
"@types/progress": "^2.0.3",
4741
"@types/semver": "^6.2.0",
48-
"@typescript-eslint/eslint-plugin": "^2.34.0",
49-
"@typescript-eslint/parser": "^2.34.0",
50-
"eslint": "^6.8.0",
42+
"@typescript-eslint/eslint-plugin": "^8.19.1",
43+
"@typescript-eslint/parser": "^8.0.0",
44+
"eslint": "^8.57.0",
5145
"eslint-config-prettier": "^6.15.0",
52-
"eslint-plugin-import": "^2.22.1",
53-
"eslint-plugin-jest": "< 24.0.0",
46+
"eslint-plugin-import": "^2.31.0",
47+
"eslint-plugin-jest": "^28.10.0",
5448
"husky": "^2.3.0",
5549
"jest": "^29.3.1",
5650
"lint-staged": "^13.0.4",
5751
"prettier": "^3.4.2",
5852
"ts-jest": "^29.0.0",
5953
"typedoc": "~0.24.8",
60-
"typescript": "^4.9.3"
61-
},
62-
"eslintConfig": {
63-
"parser": "@typescript-eslint/parser",
64-
"extends": [
65-
"eslint:recommended",
66-
"plugin:@typescript-eslint/eslint-recommended",
67-
"plugin:@typescript-eslint/recommended",
68-
"plugin:jest/recommended",
69-
"plugin:import/errors",
70-
"plugin:import/warnings",
71-
"plugin:import/typescript",
72-
"prettier",
73-
"prettier/@typescript-eslint"
74-
]
54+
"typescript": "^5.4.5"
7555
},
7656
"husky": {
7757
"hooks": {
7858
"pre-commit": "lint-staged"
7959
}
8060
},
8161
"lint-staged": {
82-
"*.ts": [
83-
"eslint --fix",
84-
"prettier --write"
85-
]
62+
"*.ts": ["eslint --fix", "prettier --write"]
8663
},
87-
"keywords": [
88-
"electron",
89-
"download",
90-
"prebuild",
91-
"get",
92-
"artifact",
93-
"release"
94-
],
64+
"keywords": ["electron", "download", "prebuild", "get", "artifact", "release"],
9565
"optionalDependencies": {
9666
"global-agent": "^3.0.0"
97-
},
98-
"resolutions": {
99-
"eslint/inquirer": "< 7.3.0",
100-
"**/@typescript-eslint/typescript-estree/semver": "^6.3.0"
10167
}
10268
}

src/Cache.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import debug from 'debug';
22
import envPaths from 'env-paths';
3-
import * as fs from 'fs-extra';
4-
import * as path from 'path';
5-
import * as url from 'url';
6-
import * as crypto from 'crypto';
3+
4+
import crypto from 'node:crypto';
5+
import fs from 'node:fs';
6+
import path from 'node:path';
7+
import url from 'node:url';
78

89
const d = debug('@electron/get:cache');
910

@@ -27,9 +28,9 @@ export class Cache {
2728
return path.resolve(this.cacheRoot, Cache.getCacheDirectory(downloadUrl), fileName);
2829
}
2930

30-
public async getPathForFileInCache(url: string, fileName: string): Promise<string | null> {
31+
public getPathForFileInCache(url: string, fileName: string): string | null {
3132
const cachePath = this.getCachePath(url, fileName);
32-
if (await fs.pathExists(cachePath)) {
33+
if (fs.existsSync(cachePath)) {
3334
return cachePath;
3435
}
3536

@@ -39,12 +40,16 @@ export class Cache {
3940
public async putFileInCache(url: string, currentPath: string, fileName: string): Promise<string> {
4041
const cachePath = this.getCachePath(url, fileName);
4142
d(`Moving ${currentPath} to ${cachePath}`);
42-
if (await fs.pathExists(cachePath)) {
43-
d('* Replacing existing file');
44-
await fs.remove(cachePath);
43+
44+
if (!fs.existsSync(path.dirname(cachePath))) {
45+
await fs.promises.mkdir(path.dirname(cachePath), { recursive: true });
4546
}
4647

47-
await fs.move(currentPath, cachePath);
48+
if (fs.existsSync(cachePath)) {
49+
d('* Replacing existing file');
50+
await fs.promises.rm(cachePath, { recursive: true, force: true });
51+
}
52+
await fs.promises.rename(currentPath, cachePath);
4853

4954
return cachePath;
5055
}

src/GotDownloader.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as fs from 'fs-extra';
21
import got, { HTTPError, Progress as GotProgress, Options as GotOptions } from 'got';
3-
import * as path from 'path';
4-
import * as ProgressBar from 'progress';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import ProgressBar from 'progress';
55

66
import { Downloader } from './Downloader';
77

@@ -44,7 +44,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
4444
let bar: ProgressBar | undefined;
4545
let progressPercent: number;
4646
let timeout: NodeJS.Timeout | undefined = undefined;
47-
await fs.mkdirp(path.dirname(targetFilePath));
47+
await fs.promises.mkdir(path.dirname(targetFilePath), { recursive: true });
4848
const writeStream = fs.createWriteStream(targetFilePath);
4949

5050
if (!quiet || !process.env.ELECTRON_GET_NO_PROGRESS) {

src/index.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import debug from 'debug';
2-
import * as fs from 'fs-extra';
3-
import * as path from 'path';
4-
import * as semver from 'semver';
5-
import * as sumchecker from 'sumchecker';
2+
import fs from 'node:fs/promises';
3+
import path from 'node:path';
4+
import semver from 'semver';
5+
import sumchecker from 'sumchecker';
66

77
import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils';
88
import {
@@ -110,7 +110,7 @@ async function validateArtifact(
110110
}
111111
} finally {
112112
// Once we're done make sure we clean up the shasum temp dir
113-
await fs.remove(path.dirname(shasumPath));
113+
await fs.rm(path.dirname(shasumPath), { recursive: true, force: true });
114114
}
115115
}
116116
},
@@ -162,7 +162,7 @@ export async function downloadArtifact(
162162
// Do not check if the file exists in the cache when force === true
163163
if (shouldTryReadCache(cacheMode)) {
164164
d(`Checking the cache (${details.cacheRoot}) for ${fileName} (${url})`);
165-
const cachedPath = await cache.getPathForFileInCache(url, fileName);
165+
const cachedPath = cache.getPathForFileInCache(url, fileName);
166166

167167
if (cachedPath === null) {
168168
d('Cache miss');
@@ -182,7 +182,7 @@ export async function downloadArtifact(
182182
return artifactPath;
183183
} catch (err) {
184184
if (doesCallerOwnTemporaryOutput(cacheMode)) {
185-
await fs.remove(path.dirname(artifactPath));
185+
await fs.rm(path.dirname(artifactPath), { recursive: true, force: true });
186186
}
187187
d("Artifact in cache didn't match checksums", err);
188188
d('falling back to re-download');
@@ -216,8 +216,11 @@ export async function downloadArtifact(
216216
);
217217
await downloader.download(url, tempDownloadPath, details.downloadOptions);
218218

219+
d('attempting to validate artifact...', { details });
219220
await validateArtifact(details, tempDownloadPath, downloadArtifact);
220221

222+
d('artifact validated');
223+
221224
if (doesCallerOwnTemporaryOutput(cacheMode)) {
222225
return tempDownloadPath;
223226
} else {

src/proxy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as debug from 'debug';
1+
import debug from 'debug';
22
import { getEnv, setEnv } from './utils';
33

44
const d = debug('@electron/get:proxy');
@@ -32,6 +32,7 @@ export function initializeProxy(): void {
3232
* TODO: replace global-agent with a hpagent. @BlackHole1
3333
* https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
3434
*/
35+
// eslint-disable-next-line @typescript-eslint/no-require-imports
3536
require('global-agent').bootstrap();
3637
} catch (e) {
3738
d('Could not load either proxy modules, built-in proxy support not available:', e);

src/utils.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import * as childProcess from 'child_process';
2-
import * as fs from 'fs-extra';
3-
import * as os from 'os';
4-
import * as path from 'path';
1+
import childProcess from 'node:child_process';
2+
import fs from 'node:fs/promises';
3+
import os from 'node:os';
4+
import path from 'node:path';
5+
56
import {
67
ElectronDownloadCacheMode,
78
ElectronGenericArtifactDetails,
@@ -16,8 +17,9 @@ async function useAndRemoveDirectory<T>(
1617
try {
1718
result = await fn(directory);
1819
} finally {
19-
await fs.remove(directory);
20+
await fs.rm(directory, { recursive: true, force: true });
2021
}
22+
2123
return result;
2224
}
2325

0 commit comments

Comments
 (0)