Skip to content
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

feat!: bump engines requirement to Node 22 #222

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 2 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@ jobs:
strategy:
matrix:
node-version:
- '20.9'
- '18.17'
- '16.20'
- '14.16'
- '22.13'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I've thought about in the past (and I feel like @BlackHole1 has pointed this out before), is we should probably explicitly test our lower bound Node.js version to ensure we remain compatible with it. It's extra CI runs, but since we just reduced the matrix here we'll still have a net reduction if we add back '20.0.0' to the matrix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the lower bound being 22.0.0 (minimum engines value)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, typo on my part. 🙁

runs-on: macos-latest
steps:
- name: Install Rosetta
if: ${{ matrix.node-version == '14.16' }}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: "${{ matrix.node-version }}"
cache: 'yarn'
architecture: ${{ matrix.node-version == '14.16' && 'x64' || env.RUNNER_ARCH }}
- name: Install (Node.js v16+)
if : ${{ matrix.node-version != '14.16' }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install (Node.js < v16)
if : ${{ matrix.node-version == '14.16' }}
run: yarn install --frozen-lockfile --ignore-engines
- name: Lint
run: yarn lint
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.13.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
22.13.0
22.13.0

From the nvm readme:

The contents of a .nvmrc file must contain precisely one <version> (as described by nvm --help) followed by a newline.

nvm install works fine for me without the newline, but we do have it in all other project files anyway 🤷‍♂️

Also a question: shouldn't this version match the one in the engines field? We're saying we support 22.0.0 as the minimum version, but nvm users working on this project will be using 22.13.0 so they could end up adding code that doesn't work on 22.0.0 and not noticing it.

I think this is a similar point to @dsanders11's on test.yml about testing the lowest supported version - we should pick one of 22.0.0 / 22.13.0 and use it everywhere.

Copy link
Member Author

@erickzhao erickzhao Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having it on the lower bound so that we ensure that development happens on the minimum engines version. :)

I guess the one thing is that leaving it running on the lower bound in theory would leave us open to running insecure Node.js versions (e.g. if 22.x.y contains a vulnerability patch, we should probably be running >=22.x.y in development).

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,25 @@
"lib"
],
"engines": {
"node": ">= 10.0.0"
"node": ">= 22.0.0"
erickzhao marked this conversation as resolved.
Show resolved Hide resolved
},
"publishConfig": {
"provenance": true
},
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.1",
"@types/jest": "^29.0.0",
"@types/node": "^13.7.7",
"@types/node": "^22.10.5",
"@types/promise-retry": "^1.1.3",
"jest": "^29.0.0",
"prettier": "^3.4.2",
"ts-jest": "^29.0.0",
"typedoc": "~0.25.13",
"typedoc-plugin-missing-exports": "^2.2.0",
"typescript": "4.9.3"
"typescript": "~5.4.5"
},
"dependencies": {
"debug": "^4.1.1",
"fs-extra": "^9.0.1",
"promise-retry": "^2.0.1"
}
}
11 changes: 6 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import debug from 'debug';
import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';

import * as fs from 'node:fs/promises';
import * as os from 'node:os';
import * as path from 'node:path';

const d = debug('electron-notarize:helpers');

Expand All @@ -13,11 +14,11 @@ export async function withTempDir<T>(fn: (dir: string) => Promise<T>) {
result = await fn(dir);
} catch (err) {
d('work failed');
await fs.remove(dir);
await fs.rm(dir, { recursive: true });
erickzhao marked this conversation as resolved.
Show resolved Hide resolved
throw err;
}
d('work succeeded');
await fs.remove(dir);
await fs.rm(dir, { recursive: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking my assumptions here, but we had to add the recursive option here due to a behavior change when we moved from fs-extra to Node's fs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. It's not very explicitly documented but fs-extra's remove is recursive while Node's fs is not by default.

If we look at the latest fs-extra code for remove we can see it's just calling through to fs.rm(path, { recursive: true, force: true }) (it's technically using graceful-fs, but looks like that library just passes through fs.rm as-is - yay layers of abstraction).

But this is a good callout, because I think to ensure there's no regression in behavior here we need to add the force: true option. Adding suggestions to do so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping force: true makes things easier for migration purposes, but might just be masking an erroneous call if some folder never exists?

For example, I was running into a case in @electron/get where we were always attempting to delete a folder path that didn't exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I think for migration purposes we should strive for no intentional behavior change, and then we can follow-up with that change after?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think removing force calls after the fact could be a good-first-issue since the acceptance criteria is pretty clear!

erickzhao marked this conversation as resolved.
Show resolved Hide resolved
return result;
}

Expand Down
Loading
Loading