Skip to content

Commit

Permalink
Merge branch 'main' into enable-asar-2
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Feb 21, 2023
2 parents 70774fa + 133ad63 commit 4087116
Show file tree
Hide file tree
Showing 84 changed files with 930 additions and 793 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
{
"files": ["**/*.ts"],
"extends": ["@malept/eslint-config/src/typescript"],
"parserOptions": {
"project": ["./tsconfig.base.json"]
},
"rules": {
"no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @electron/wg-ecosystem
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
run: yarn install
- name: Lint
run: yarn lint
- name: Ensure packages in sync
run: yarn syncpack
- name: Build
run: yarn build
- name: Run tests
Expand Down Expand Up @@ -74,6 +76,6 @@ jobs:
- name: Build
run: yarn build
- name: Test
run: yarn test
run: yarn test:slow
env:
DEBUG: electron-installer-snap:snapcraft
26 changes: 26 additions & 0 deletions .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Check Semantic Commit'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
main:
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb # tag: v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
docs
doc
node_modules
lerna-debug.log
yarn-error.log
packages/**/.npmignore
packages/**/tsconfig.json
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

"$(npm bin)"/lint-staged
yarn lint-staged
9 changes: 9 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

BRANCH=`git rev-parse --abbrev-ref HEAD`
PROTECTED_BRANCH="main"

if [ "$BRANCH" = $PROTECTED_BRANCH ]; then
node .husky/pre-push.js < /dev/tty
fi
14 changes: 14 additions & 0 deletions .husky/pre-push.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const inquirer = require('inquirer');

const question = [
{
type: 'confirm',
name: 'continuePush',
message: '[pre-push hook] Warning: this is a protected branch. Continue?',
},
];

inquirer.prompt(question).then((answer) => {
if (!answer.continuePush) process.exit(1);
process.exit(0);
});
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.nyc_output
dist/
docs/
packages/tsconfig.json
packages/*/*/dist
packages/*/*/doc
packages/*/*/index.d.ts
Expand Down
20 changes: 0 additions & 20 deletions .swcrc

This file was deleted.

97 changes: 64 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,33 @@ in the issue tracker to denote fairly-well-scoped-out bugs or feature requests t
can pick up and work on. If any of those labeled issues do not have enough information, please feel
free to ask constructive questions. (This applies to any open issue.)

## Running Forge locally

The easiest way to test changes to Forge during development is by symlinking your local packages
to a sample Forge project.

To create symlinks your local Forge packages, use the `yarn link:prepare` command after
building Forge.

```sh
yarn build
yarn link:prepare
```

Then, you want to initialize a new project with the `electron-forge init` command (which is the
underlying CLI command for `create-electron-app`). To use the symlinks you created in the last step,
pass in the `LINK_FORGE_DEPENDENCIES_ON_INIT` environment variable.

You can choose to run this command via your local build as shown below or run the production init
for versions 6.0.1 and up.

```sh
LINK_FORGE_DEPENDENCIES_ON_INIT=1 node path/to/forge/packages/api/cli/dist/electron-forge-init.js my-app
```

Forge commands executed in your `my-app` sample project should reflect any changes in your local
Forge build. (Make sure to run `yarn build:fast` or `yarn build` between code changes.)

## Documentation changes

When changing the API documentation, here are some rules to keep in mind.
Expand Down Expand Up @@ -71,17 +98,10 @@ Please ensure that all changes are committed using [semantic commit messages](ht
### Running the Tests

The Electron Forge repository has a lot of tests, some of which take a decent
amount of time to run when uncached. The repository will automatically cache test results for future runs.
Adding `skip-nx-cache` will skip the cache.
amount of time to run.

```bash
lerna run test
```

Tests can also run within a specific scope.

```bash
lerna run test --scope @electron-forge/core
yarn test
```

## Filing Pull Requests
Expand All @@ -105,27 +125,38 @@ Here are some things to keep in mind as you file pull requests to fix bugs, add
- If you are continuing the work of another person's PR and need to rebase/squash, please retain the
attribution of the original author(s) and continue the work in subsequent commits.

### Release process

- Make sure the tests pass with `lerna run test`
- Run `git clean -fdx` - this will ensure unneeded build files (and potentially sensitive files) are not included in the npm package.
- Ensure that you are logged into npm via command line (`npm login`)
- `lerna publish --force-publish`
- **running this command without the `--force-publish` flag will only publish packages that have changes since
last release**.
- for beta releases, select `custom prerelease` when prompted, and enter `y` to increment the beta version.
- version numbers should be an un-prefixed [semantic version](https://semver.org/) number (e.g. `6.0.0-beta.67)
- The script will then ask you for your `npm` OTP password.
- The script will commit the changes automatically. Run `git log` to confirm that the changes have been
committed.
- The command will have published your packages to `npm`, and pushed an appropriate tag to github.
- After running the command, you should have a commit which:
- Updates the version field in the package.json file
- Updates the version fields in each of the submodule package.json files
- Push your commit upstream to the main/default branch.
- Create a new github release
- Go to releases tab
- Draft a new release and choose the appropriate tag
- Target default branch
- Generate release notes by copying in CHANGELOG.md contents into the release description or use
GitHub's [automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes)
## Release process

This guide is for maintainers who have:

- Push access to the `electron/forge` repository.
- Collaborator access to the `@electron-forge` packages on npm.

### 1. Prepare your local code checkout

- Switch to the tip of the `main` branch with `git switch main && git pull`.
- Run tests locally with `yarn test`.
- Check that the latest CI run passed on `main` on [GitHub](https://github.com/electron/forge/actions?query=workflow:CI).
- Remove all untracked files and directories from your checkout with `git clean -fdx`.
- Install dependencies with `yarn install`.

### 2. Publish all npm packages

- Log into npm with `npm login`.
- Run the `yarn lerna:publish` command.
- Enter your npm account's time-based one-time password (TOTP).

The `lerna:publish` script will automatically increment the next package version based on the
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. From there, it does two things:

1. It creates a tagged commit that bumps the version number in `package.json` at the root and package levels
and pushes the commit and tag to GitHub.
1. It publishes every `@electron-forge/` package to npm.

### 3. Publish release to GitHub

- Go to the repo's [New Release](https://github.com/electron/forge/releases/new) page.
- Select tag you just published.
- Target the `main` branch.
- [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes)
against the previous Forge release.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "6.0.3",
"version": "6.0.5",
"npmClient": "yarn"
}
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "electron-forge",
"version": "6.0.1",
"version": "0.0.0-development",
"private": true,
"license": "MIT",
"engines": {
"node": ">= 14.17.5"
},
"scripts": {
"clean": "rimraf dist && lerna exec -- rimraf dist tsconfig.tsbuildinfo",
"build": "lerna exec -- tsc --emitDeclarationOnly && yarn build:fast",
"build:fast": "lerna exec -- swc src --out-dir dist --quiet --extensions \".ts\" --config-file ../../../.swcrc",
"build:full": "lerna exec -- tsc -b",
"build": "tsc -b packages",
"build:watch": "yarn build --watch",
"postbuild": "ts-node tools/test-dist",
"docs": "yarn build:full && yarn docs:generate",
"docs": "yarn build && yarn docs:generate",
"docs:generate": "yarn docs:plugin && node --max-old-space-size=8192 -r ts-node/register ./tools/gen-docs.ts",
"docs:plugin": "cd ./tools/doc-plugin && yarn build",
"docs:deploy:build": "yarn docs",
"lerna:publish": "lerna publish --force-publish --conventional-commits --no-changelog --exact",
"lint": "prettier --check . && eslint .",
"lint:fix": "prettier --write .",
"link:prepare": "lerna exec -- node ../../../tools/silent.js yarn link --link-folder ../../../.links --silent --no-bin-links",
"test": "xvfb-maybe cross-env LINK_FORGE_DEPENDENCIES_ON_INIT=1 TS_NODE_PROJECT='./tsconfig.test.json' TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"test:fast": "xvfb-maybe cross-env LINK_FORGE_DEPENDENCIES_ON_INIT=1 TS_NODE_PROJECT='./tsconfig.test.json' TEST_FAST_ONLY=1 TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"test:slow": "xvfb-maybe cross-env LINK_FORGE_DEPENDENCIES_ON_INIT=1 TS_NODE_PROJECT='./tsconfig.test.json' TEST_SLOW_ONLY=1 TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
"prepare": "husky install",
"preversion": "yarn build"
Expand Down Expand Up @@ -78,11 +78,9 @@
"yarn-or-npm": "^3.0.1"
},
"devDependencies": {
"@electron/fuses": ">=1.0.0",
"@knodes/typedoc-plugin-monorepo-readmes": "0.22.5",
"@malept/eslint-config": "^2.0.0",
"@swc/cli": "^0.1.49",
"@swc/core": "^1.2.87",
"@swc/register": "^0.1.7",
"@types/chai": "^4.2.12",
"@types/chai-as-promised": "^7.1.2",
"@types/cross-spawn": "^6.0.1",
Expand Down Expand Up @@ -123,22 +121,25 @@
"fork-ts-checker-webpack-plugin": "^7.2.13",
"generate-changelog": "^1.8.0",
"husky": "^7.0.1",
"inquirer": "^8.0.0",
"lerna": "^6.0.1",
"lint-staged": "^12.1.7",
"listr2": "^4.0.4",
"listr2": "^5.0.3",
"minimist": "^1.2.6",
"mocha": "^9.0.1",
"prettier": "^2.4.0",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.1",
"sinon": "^13.0.1",
"sinon-chai": "^3.6.0",
"syncpack": "^8.4.11",
"ts-node": "^10.0.0",
"typedoc": "^0.22.15",
"typedoc-plugin-missing-exports": "^1.0.0",
"typedoc-plugin-rename-defaults": "^0.6.4",
"typescript": "^4.6.3",
"xvfb-maybe": "^0.2.1"
"xvfb-maybe": "^0.2.1",
"yaml-hook": "^1.0.0"
},
"optionalDependencies": {
"@malept/electron-installer-flatpak": "^0.11.2",
Expand All @@ -151,12 +152,16 @@
"electron-wix-msi": "^5.0.0",
"macos-alias": "^0.2.11"
},
"peerDependencies": {
"@electron/fuses": ">=1.0.0"
},
"lint-staged": {
"*.{html,json,md,yml}": "prettier --write",
"*.{js,ts}": [
"prettier --write",
"eslint --fix"
]
],
"*.{json,lock}": "syncpack"
},
"prettier": {
"singleQuote": true
Expand Down
6 changes: 3 additions & 3 deletions packages/api/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@electron-forge/cli",
"version": "6.0.3",
"version": "6.0.5",
"description": "A complete tool for building modern Electron applications",
"repository": "https://github.com/electron/forge",
"author": "Samuel Attard",
Expand All @@ -17,8 +17,8 @@
"mocha": "^9.0.1"
},
"dependencies": {
"@electron-forge/core": "^6.0.3",
"@electron-forge/shared-types": "^6.0.3",
"@electron-forge/core": "6.0.5",
"@electron-forge/shared-types": "6.0.5",
"@electron/get": "^2.0.0",
"chalk": "^4.0.0",
"commander": "^4.1.1",
Expand Down
1 change: 0 additions & 1 deletion packages/api/cli/src/util/terminate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function redConsoleError(msg: string) {
process.on('unhandledRejection', (reason: string, promise: Promise<unknown>) => {
redConsoleError('\nAn unhandled rejection has occurred inside Forge:');
redConsoleError(reason.toString().trim());
redConsoleError('\nElectron Forge was terminated. Location:');
promise.catch((err: Error) => {
if ('stack' in err) {
const usefulStack = err.stack;
Expand Down
Loading

0 comments on commit 4087116

Please sign in to comment.