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.12 #222

Merged
merged 13 commits into from
Mar 14, 2025
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # tag: v4.2.0
with:
node-version: lts/*
node-version: '22.12.x'
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build API documentation
Expand Down
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@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20.x
node-version: '22.12.x'
cache: 'yarn'
- name: Install
run: yarn install --frozen-lockfile
Expand Down
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.12.x'
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@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.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.12
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "@electron/notarize",
"version": "0.0.0-development",
"description": "Notarize your Electron app",
"main": "lib/index.js",
"type": "module",
"exports": "./lib/index.js",
"typings": "lib/index.d.ts",
"author": "Samuel Attard",
"license": "MIT",
Expand All @@ -20,33 +21,32 @@
"lint": "prettier --check \"src/**/*.ts\"",
"prettier:write": "prettier --write \"src/**/*.ts\"",
"prepare": "yarn build",
"test": "jest"
"test": "vitest run"
},
"files": [
"lib"
],
"engines": {
"node": ">= 10.0.0"
"node": ">= 22.12.0"
},
"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",
"@tsconfig/node22": "^22.0.0",
"@types/debug": "^4.1.12",
"@types/graceful-fs": "^4.1.9",
"@types/node": "~22.10.7",
"@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",
"vitest": "^3.0.8"
},
"dependencies": {
"debug": "^4.1.1",
"fs-extra": "^9.0.1",
"debug": "^4.4.0",
"graceful-fs": "^4.2.11",
"promise-retry": "^2.0.1"
}
}
4 changes: 2 additions & 2 deletions src/check-signature.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path';

import { spawn } from './spawn';
import { NotaryToolNotarizeAppOptions } from './types';
import { spawn } from './spawn.js';
import { NotaryToolNotarizeAppOptions } from './types.js';
import debug from 'debug';
const d = debug('electron-notarize');

Expand Down
14 changes: 8 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import debug from 'debug';
import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as fs from 'graceful-fs';

import * as os from 'node:os';
import * as path from 'node:path';
import * as util from 'node:util';

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

export async function withTempDir<T>(fn: (dir: string) => Promise<T>) {
const dir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-notarize-'));
const dir = await util.promisify(fs.mkdtemp)(path.resolve(os.tmpdir(), 'electron-notarize-'));
d('doing work inside temp dir:', dir);
let result: T;
try {
result = await fn(dir);
} catch (err) {
d('work failed');
await fs.remove(dir);
await util.promisify(fs.rm)(dir, { recursive: true, force: true });
throw err;
}
d('work succeeded');
await fs.remove(dir);
await util.promisify(fs.rm)(dir, { recursive: true, force: true });
return result;
}

Expand Down
29 changes: 7 additions & 22 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import debug from 'debug';
import retry from 'promise-retry';

import { checkSignatures } from './check-signature';
import { isNotaryToolAvailable, notarizeAndWaitForNotaryTool } from './notarytool';
import { stapleApp } from './staple';
import {
NotarizeOptions,
NotaryToolStartOptions,
NotarizeOptionsLegacy,
NotarizeOptionsNotaryTool,
} from './types';
import { checkSignatures } from './check-signature.js';
import { isNotaryToolAvailable, notarizeAndWaitForNotaryTool } from './notarytool.js';
import { stapleApp } from './staple.js';
import { NotarizeOptions } from './types.js';

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

export { NotarizeOptions };

export { validateNotaryToolAuthorizationArgs as validateAuthorizationArgs } from './validate-args';
export { validateNotaryToolAuthorizationArgs as validateAuthorizationArgs } from './validate-args.js';

/**
* Sends your app to Apple for notarization with `notarytool` and staples a successful
Expand All @@ -28,19 +23,9 @@ export { validateNotaryToolAuthorizationArgs as validateAuthorizationArgs } from
* @param args Options for notarization
* @returns The Promise resolves once notarization is complete. Note that this may take a few minutes.
*/
async function notarize(args: NotarizeOptionsNotaryTool): Promise<void>;
/**
* @deprecated
*/
async function notarize(args: NotarizeOptionsLegacy): Promise<void>;
async function notarize(args: NotarizeOptions): Promise<void>;

async function notarize({ appPath, ...otherOptions }: NotarizeOptions) {
if (otherOptions.tool === 'legacy') {
throw new Error(
'Notarization with the legacy altool system was decommisioned as of November 2023',
);
}

await checkSignatures({ appPath });

d('notarizing using notarytool');
Expand All @@ -53,7 +38,7 @@ async function notarize({ appPath, ...otherOptions }: NotarizeOptions) {
await notarizeAndWaitForNotaryTool({
appPath,
...otherOptions,
} as NotaryToolStartOptions);
} as NotarizeOptions);

await retry(() => stapleApp({ appPath }), {
retries: 3,
Expand Down
18 changes: 0 additions & 18 deletions src/legacy.ts

This file was deleted.

14 changes: 7 additions & 7 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import debug from 'debug';
import * as path from 'path';
import path from 'node:path';

import { spawn } from './spawn';
import { makeSecret, withTempDir } from './helpers';
import { spawn } from './spawn.js';
import { makeSecret, withTempDir } from './helpers.js';
import {
validateNotaryToolAuthorizationArgs,
isNotaryToolPasswordCredentials,
isNotaryToolApiKeyCredentials,
} from './validate-args';
import { NotaryToolCredentials, NotaryToolStartOptions } from './types';
} from './validate-args.js';
import { NotarizeOptions, NotaryToolCredentials } from './types.js';

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

Expand Down Expand Up @@ -47,7 +47,7 @@ function authorizationArgs(rawOpts: NotaryToolCredentials): string[] {
}
}

async function getNotarizationLogs(opts: NotaryToolStartOptions, id: string) {
async function getNotarizationLogs(opts: NotarizeOptions, id: string) {
try {
const logResult = await runNotaryTool(
['log', id, ...authorizationArgs(opts)],
Expand All @@ -70,7 +70,7 @@ export async function isNotaryToolAvailable(notarytoolPath?: string) {
}
}

export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions) {
export async function notarizeAndWaitForNotaryTool(opts: NotarizeOptions) {
d('starting notarize process for app:', opts.appPath);
return await withTempDir(async (dir) => {
const fileExt = path.extname(opts.appPath);
Expand Down
6 changes: 4 additions & 2 deletions src/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { spawn as cpSpawn, SpawnOptions } from 'child_process';
import { spawn as cpSpawn, SpawnOptions } from 'node:child_process';

import debug from 'debug';
import { isSecret } from './helpers';

import { isSecret } from './helpers.js';

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

Expand Down
4 changes: 2 additions & 2 deletions src/staple.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import debug from 'debug';
import * as path from 'path';

import { spawn } from './spawn';
import { NotaryToolNotarizeAppOptions } from './types';
import { spawn } from './spawn.js';
import { NotaryToolNotarizeAppOptions } from './types.js';

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

Expand Down
Loading