Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
714f61f
feat!: bump `engines` requirement to Node 22
erikian Aug 17, 2025
6524015
use `node:` imports
erikian Aug 17, 2025
9bc8e4f
use `"@tsconfig/node22`
erikian Aug 17, 2025
095e079
replace `fs-extra` with `graceful-fs` in `src`
erikian Aug 17, 2025
20262b2
esm: add `"type": "module"` and update imports
erikian Aug 17, 2025
ab75056
esm: update dynamic imports
erikian Aug 17, 2025
7e9c2f4
update `typescript`
erikian Aug 17, 2025
69ec09b
add temporary cjs shim for running tests
erikian Aug 17, 2025
dd5d313
update all `@electron` deps
erikian Aug 17, 2025
8653e98
temp: add `fs-extra` to dev deps for tests
erikian Aug 17, 2025
992472b
update more deps
erikian Aug 17, 2025
952684e
remove temporary shim for Forge introduced in #1641
erikian Aug 17, 2025
33c86c4
update package exports
erikian Aug 18, 2025
ca7702c
Merge branch 'main' into feat/node-22
erickzhao Aug 29, 2025
c8da2d3
re-add import warnings
erickzhao Aug 29, 2025
d5e2044
fix vitest
erickzhao Aug 29, 2025
ece691c
fix types
erickzhao Aug 29, 2025
58aa5f9
deps update
erickzhao Aug 29, 2025
d200ad5
update gen-trust to be ESM
erickzhao Aug 29, 2025
4f2411a
use graceful fs rename
erickzhao Aug 29, 2025
861fb4b
fs rename windows fixes
erickzhao Sep 3, 2025
bf45a7f
fixes
erickzhao Sep 3, 2025
850c372
readFile instead of import
erickzhao Sep 4, 2025
6c6d4da
Update package.json
erickzhao Sep 5, 2025
3b0219a
update lockfile
erickzhao Sep 5, 2025
1a3955d
remove fs-extra
erickzhao Sep 5, 2025
3e49bac
add import rule back
erickzhao Sep 5, 2025
72a1dda
attempt to not use graceful rename
erickzhao Sep 5, 2025
f9548bd
Update src/types.ts
erickzhao Sep 8, 2025
4f56e4a
Update src/win32.ts
erickzhao Sep 8, 2025
241fc21
allowjs false
erickzhao Sep 8, 2025
96a37fe
tighten up packager sign types
erickzhao Sep 8, 2025
cb2c96e
identity is undefined and not null
erickzhao Sep 8, 2025
9d0a25b
guard against EXDEV as well
erickzhao Sep 8, 2025
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
7 changes: 3 additions & 4 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
const eslintConfig = {
extends: ['eslint:recommended', 'prettier'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
env: {
es6: true,
Expand All @@ -11,6 +11,7 @@ const eslintConfig = {
rules: {
'no-console': 0,
strict: 'error',
'import/enforce-node-protocol-usage': ['error', 'always'],
},
overrides: [
{
Expand All @@ -20,13 +21,11 @@ const eslintConfig = {
'plugin:promise/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
},
],
};
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # tag: v4.4.0
with:
node-version: lts/*
node-version-file: .nvmrc
- name: Replace electron with electron-nightly
run: |
cd minimal-repro
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@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20.x
node-version-file: .nvmrc
cache: 'yarn'
- name: Install
run: yarn install --frozen-lockfile
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
strategy:
matrix:
node-version:
- '22.13'
- '20.19'
- '22.12.x'
os:
- macos-latest
- ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ typedoc
.nyc_output
npm-debug.log
dist/
src/targets.js
.eslintcache
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13
22.12
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/test/fixtures/infer-malformed-json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ It generates executables/bundles for the following **target** platforms:

## Installation

This module requires Node.js 16.13.0 or higher to run.
This module requires Node.js 22.12.0 or higher to run.

```sh
npm install --save-dev @electron/packager
Expand Down
18 changes: 0 additions & 18 deletions bin/electron-packager.js

This file was deleted.

4 changes: 4 additions & 0 deletions bin/electron-packager.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
import { run } from '../dist/cli.js';

run(process.argv.slice(2));
89 changes: 44 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "@electron/packager",
"version": "0.0.0-development",
"description": "Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"module": "./dist/index.js",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"electron-packager": "bin/electron-packager.js"
"electron-packager": "./bin/electron-packager.mjs"
},
"repository": {
"type": "git",
Expand All @@ -22,67 +24,67 @@
"bin",
"docs/*.md",
"dist",
"src/targets.js",
"usage.txt"
],
"dependencies": {
"@electron/asar": "^3.2.13",
"@electron/get": "^3.0.0",
"@electron/notarize": "^2.1.0",
"@electron/osx-sign": "^1.0.5",
"@electron/universal": "^2.0.1",
"@electron/windows-sign": "^1.0.0",
"@electron/asar": "^4.0.1",
"@electron/get": "^4.0.2",
"@electron/notarize": "^3.1.0",
"@electron/osx-sign": "^2.2.0",
"@electron/universal": "^3.0.1",
"@electron/windows-sign": "^2.0.2",
"@malept/cross-spawn-promise": "^2.0.0",
"debug": "^4.0.1",
"extract-zip": "^2.0.0",
"filenamify": "^4.1.0",
"fs-extra": "^11.1.0",
"galactus": "^1.0.0",
"debug": "^4.4.1",
"extract-zip": "^2.0.1",
"filenamify": "^6.0.0",
"galactus": "^2.0.2",
"get-package-info": "^1.0.0",
"junk": "^3.1.0",
"graceful-fs": "^4.2.11",
"junk": "^4.0.1",
"parse-author": "^2.0.0",
"plist": "^3.0.0",
"prettier": "^3.4.2",
"resedit": "^2.0.0",
"resolve": "^1.1.6",
"semver": "^7.1.3",
"yargs-parser": "^21.1.1"
"plist": "^3.1.0",
"prettier": "^3.6.2",
"resedit": "^2.0.3",
"resolve": "^1.22.10",
"semver": "^7.7.2",
"yargs-parser": "^22.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.10",
"@types/fs-extra": "^11.0.3",
"@tsconfig/node22": "^22.0.2",
"@types/debug": "^4.1.12",
"@types/graceful-fs": "^4.1.9",
"@types/lodash": "^4.17.20",
"@types/node": "^16.0.0",
"@types/node": "~22.10.7",
"@types/parse-author": "^2.0.2",
"@types/plist": "^3.0.4",
"@types/resolve": "^1.20.4",
"@types/semver": "^7.5.8",
"@types/yargs-parser": "^21.0.2",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.52.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^6.2.0",
"husky": "^8.0.3",
"lint-staged": "^12.1.7",
"@types/plist": "^3.0.5",
"@types/resolve": "^1.20.6",
"@types/semver": "^7.7.0",
"@types/yargs-parser": "^21.0.3",
"@typescript-eslint/eslint-plugin": "8.39.1",
"@typescript-eslint/parser": "^8.39.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^7.2.1",
"husky": "^9.1.7",
"lint-staged": "^16.1.5",
"lodash": "^4.17.21",
"tsx": "^4.20.4",
"typedoc": "~0.25.4",
"typescript": "^5.2.2",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"engines": {
"node": ">= 16.13.0"
"node": ">= 22.12.0"
},
"publishConfig": {
"provenance": true
},
"scripts": {
"build": "tsc",
"build:docs": "npx typedoc",
"lint": "prettier --check \"*.{ts,js,json}\" && eslint . --cache",
"lint": "prettier --check \"*.{ts,js,json}\" && eslint src --cache",
"prepublish": "npm run build",
"pretest": "npm run build",
"test": "vitest run",
Expand All @@ -100,11 +102,8 @@
"funding": {
"url": "https://github.com/electron/packager?sponsor=1"
},
"resolutions": {
"got": "11.8.5"
},
"lint-staged": {
"*.{json}": "prettier --write",
"*.json": "prettier --write",
"*.{js,ts}": [
"prettier --write",
"eslint --fix"
Expand Down
16 changes: 9 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { info, hostInfo, warning } from './common';
import fs from 'fs-extra';
import { info, hostInfo, warning } from './common.js';
import { promisifiedGracefulFs } from './util.js';
import { initializeProxy } from '@electron/get';
import { packager } from './packager';
import path from 'path';
import { packager } from './packager.js';
import path from 'node:path';
import yargs from 'yargs-parser';
import { Options } from './types';
import { Options } from './types.js';

/* istanbul ignore next */
async function printUsageAndExit(isError: boolean) {
const usage = (
await fs.readFile(path.resolve(__dirname, '..', 'usage.txt'))
await promisifiedGracefulFs.readFile(
path.resolve(import.meta.dirname, '..', 'usage.txt'),
)
).toString();
const print = isError ? console.error : console.log;
print(usage);
Expand Down Expand Up @@ -147,7 +149,7 @@ export function parseArgs(argv: string[]) {
'--version does not take an argument. Perhaps you meant --app-version or --electron-version?\n',
);
}
console.log(hostInfo());
console.log(await hostInfo());
process.exit(0);
} else if (!args.dir) {
await printUsageAndExit(true);
Expand Down
25 changes: 15 additions & 10 deletions src/common.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import filenamify from 'filenamify';
import fs from 'fs-extra';
import os from 'os';
import path from 'path';
import fs from 'graceful-fs';
import os from 'node:os';
import path from 'node:path';
import createDebug from 'debug';
import { ComboOptions, Options } from './types';
import { ComboOptions, Options } from './types.js';
import { CreateOptions as AsarOptions } from '@electron/asar';

export const debug = createDebug('electron-packager');
Expand Down Expand Up @@ -105,18 +105,20 @@ export async function validateElectronApp(
debug('Checking for a package.json file');

const bundledPackageJSONPath = path.join(bundledAppDir, 'package.json');
if (!(await fs.pathExists(bundledPackageJSONPath))) {
if (!fs.existsSync(bundledPackageJSONPath)) {
const originalPackageJSONPath = path.join(appDir, 'package.json');
throw new Error(
`Application manifest was not found. Make sure "${originalPackageJSONPath}" exists and does not get ignored by your ignore option`,
);
}

debug('Checking for the main entry point file');
const packageJSON = await fs.readJson(bundledPackageJSONPath);
const packageJSON = JSON.parse(
await fs.promises.readFile(bundledPackageJSONPath, 'utf8'),
);
const mainScriptBasename = packageJSON.main || 'index.js';
const mainScript = path.resolve(bundledAppDir, mainScriptBasename);
if (!(await fs.pathExists(mainScript))) {
if (!fs.existsSync(mainScript)) {
const originalMainScript = path.join(appDir, mainScriptBasename);
throw new Error(
`The main entry point to your app was not found. Make sure "${originalMainScript}" exists and does not get ignored by your ignore option`,
Expand All @@ -126,9 +128,12 @@ export async function validateElectronApp(
debug('Validation complete');
}

export function hostInfo() {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const metadata = require('../package.json');
export async function hostInfo() {
const packageJsonPath = path.resolve(import.meta.dirname, '../package.json');

const { default: metadata } = await import(packageJsonPath, {
with: { type: 'json' },
});

return (
`Electron Packager ${metadata.version}\n` +
Expand Down
20 changes: 10 additions & 10 deletions src/copy-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
ensureArray,
generateFinalBasename,
normalizePath,
} from './common';
import junk from 'junk';
import path from 'path';
import { isModule, Pruner } from './prune';
import { officialPlatformArchCombos } from './targets';
import { ComboOptions, Options } from './types';
import { CopyFilterAsync } from 'fs-extra';
} from './common.js';
import { isJunk } from 'junk';
import path from 'node:path';
import { isModule, Pruner } from './prune.js';
import { officialPlatformArchCombos } from './targets.js';
import { ComboOptions, Options } from './types.js';
import { CopyOptions } from 'node:fs';

const DEFAULT_IGNORES = [
'/package-lock\\.json$',
Expand Down Expand Up @@ -82,7 +82,7 @@ function generateFilterFunction(
}
}

export function userPathFilter(opts: ComboOptions): CopyFilterAsync {
export function userPathFilter(opts: ComboOptions): CopyOptions['filter'] {
const filterFunc = generateFilterFunction(opts.ignore || []);
const ignoredOutDirs = generateIgnoredOutDirs(opts);
const pruner = opts.prune ? new Pruner(opts.dir, Boolean(opts.quiet)) : null;
Expand All @@ -96,7 +96,7 @@ export function userPathFilter(opts: ComboOptions): CopyFilterAsync {

if (opts.junk !== false) {
// defaults to true
if (junk.is(path.basename(fullPath))) {
if (isJunk(path.basename(fullPath))) {
return false;
}
}
Expand All @@ -116,5 +116,5 @@ export function userPathFilter(opts: ComboOptions): CopyFilterAsync {
}

return filterFunc(name);
} as CopyFilterAsync;
};
}
6 changes: 3 additions & 3 deletions src/download.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { debug, subOptionWarning } from './common';
import { debug, subOptionWarning } from './common.js';
import {
downloadArtifact,
ElectronPlatformArtifactDetailsWithDefaults,
} from '@electron/get';
import semver from 'semver';
import { createPlatformArchPairs } from './targets';
import { createPlatformArchPairs } from './targets.js';
import {
DownloadOptions,
IgnoreFunc,
Options,
SupportedArch,
SupportedPlatform,
} from './types';
} from './types.js';

export function createDownloadOpts(
opts: Options,
Expand Down
Loading
Loading