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

build: migrate to lerna from bolt #3058

Merged
merged 16 commits into from
Nov 14, 2022
50 changes: 7 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,8 @@ on:
pull_request:

jobs:
dependabolt:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
- name: Use Node.js LTS
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 #v.3.5.1
with:
node-version: 14.x
cache: yarn
- name: Run dependabolt
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'dependabot/npm_and_yarn') && !contains(github.event.pull_request.head.ref, 'npm_and_yarn/packages') }}
uses: malept/github-action-dependabolt@v4.0.1
env:
DEPENDABOLT_SSH_DEPLOY_KEY: ${{ secrets.DEPENDABOLT_SSH_DEPLOY_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fast-tests:
runs-on: ${{ matrix.os }}
needs: dependabolt
strategy:
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
Expand All @@ -49,26 +30,17 @@ jobs:
run: |
npm install -g npm@8.3.1
npm install -g npm@latest
- name: Install bolt
shell: bash
run: |
case "$(uname -s)" in
Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.24.10 ;;
*) BOLT_VERSION=latest ;;
esac
npm install -g bolt@$BOLT_VERSION
- name: Install
run: bolt
run: yarn install
- name: Lint
run: bolt lint
run: yarn lint
- name: Build
run: bolt build
run: yarn build
- name: Run tests
run: bolt test:fast
run: yarn test:fast

slow-tests:
runs-on: ${{ matrix.os }}
needs: dependabolt
strategy:
matrix:
os: [windows-latest, macOS-latest, ubuntu-20.04]
Expand Down Expand Up @@ -97,19 +69,11 @@ jobs:
with:
node-version: 14.x
cache: yarn
- name: Install bolt
shell: bash
run: |
case "$(uname -s)" in
Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.24.10 ;;
*) BOLT_VERSION=latest ;;
esac
npm install -g bolt@$BOLT_VERSION
- name: Install
run: bolt
run: yarn install
- name: Build
run: bolt build
run: yarn build
- name: Test
run: bolt test
run: yarn test
env:
DEBUG: electron-installer-snap:snapcraft
13 changes: 2 additions & 11 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@ jobs:
node-version: 16.x
cache: yarn

- name: Install Bolt CLI
shell: bash
run: |
case "$(uname -s)" in
Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.21.2 ;;
*) BOLT_VERSION=latest ;;
esac
npm install -g bolt@$BOLT_VERSION
- name: Build
shell: bash
run: |
bolt
bolt docs
yarn
yarn docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
53 changes: 24 additions & 29 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,35 @@ issues/pull requests at [its separate repository](https://github.com/electron-fo

## Changing the Code

Getting the code base running locally requires the `bolt` command installed globally. An example is given below.
An example of how to make your own code edits:

```bash
npm i -g bolt
git clone https://github.com/electron/forge
cd forge
# Installs all dependencies, don't run "yarn" or "npm install" yourself
bolt
# Installs all dependencies
yarn
# Builds all the TS code
bolt build
yarn build
```

### Making Commits

Please ensure that all changes are committed using [semantic commit messages](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md).
We expose a helper (`bolt commit`) to make this easier.

### Running the Tests

The Electron Forge repository has a lot of tests, some of which take a decent
amount of time to run.
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.

```bash
bolt test
lerna run test
```

Tests can also run within a specific scope.

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

## Filing Pull Requests
Expand All @@ -102,32 +107,22 @@ Here are some things to keep in mind as you file pull requests to fix bugs, add

### Release process

When updating a dependency, we also need to make sure that the package is updated in all of the modules where
the packages is needed. To do this, run:

```
bolt upgrade {package-name}@latest

// i.e.
bolt upgrade electron-wix-msi@latest
```

### Release process

- Make sure the tests pass
- `$ ./tools/bump.ts $NEW_VERSION`
- This will commit the changes automatically. Run `git log` to confirm that the changes have been
committed.
- `$NEW_VERSION` should be an un-prefixed [semantic version](https://semver.org/) number (e.g. `6.0.0-beta.67)
- 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.
- `$ node tools/publish.js`
- Ensure that you are logged into npm via command line (`npm login`)
- 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
- Includes a git tag corresponding with the new version number.
- Push your commit upstream to the main/default branch.
- Push your tag upstream with `git push origin <tag_name>` .
- Create a new github release
- Go to releases tab
- Draft a new release and choose the appropriate tag
Expand Down
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "6.0.1",
"npmClient": "yarn"
}
27 changes: 27 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["coverage:base", "test", "test:base", "test:fast", "test:slow"]
}
}
},
"targetDefaults": {
"coverage:base": {
"dependsOn": ["^coverage:base"]
},
"test": {
"dependsOn": ["^test"]
},
"test:base": {
"dependsOn": ["^test:base"]
},
"test:fast": {
"dependsOn": ["^test:fast"]
},
"test:slow": {
"dependsOn": ["^test:slow"]
}
}
}
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,21 @@
"engines": {
"node": ">= 14.17.5"
},
"bolt": {
"workspaces": [
"packages/api/*",
"packages/external/*",
"packages/maker/*",
"packages/publisher/*",
"packages/utils/*",
"packages/plugin/*",
"packages/template/*"
]
},
"scripts": {
"clean": "rimraf dist && bolt ws exec -- rimraf dist tsconfig.tsbuildinfo",
"build": "bolt ws exec -- tsc --emitDeclarationOnly && bolt build:fast",
"build:fast": "bolt ws exec -- swc src --out-dir dist --quiet --extensions \".ts\" --config-file ../../../.swcrc",
"build:full": "bolt ws exec -- tsc -b",
"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",
"postbuild": "ts-node tools/test-dist",
"docs": "bolt build:full && bolt docs:generate",
"docs:generate": "bolt docs:plugin && node --max-old-space-size=8192 -r ts-node/register ./tools/gen-docs.ts",
"docs": "yarn build:full && 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": "bolt docs",
"docs:deploy:build": "yarn docs",
"lint": "prettier --check . && eslint .",
"lint:fix": "prettier --write .",
"link:prepare": "bolt ws exec -- node ../../../tools/silent.js yarn link --link-folder ../../../.links --silent --no-bin-links",
"link:prepare": "lerna exec -- node ../../../tools/silent.js yarn link --link-folder ../../../.links --silent --no-bin-links",
"test": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"test:fast": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TEST_FAST_ONLY=1 TS_NODE_FILES=1 mocha './tools/test-globber.ts'",
"preinstall": "node ./tools/maybe-shim-windows.js",
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
"prepare": "husky install"
},
Expand Down Expand Up @@ -133,9 +121,10 @@
"fetch-mock": "^9.10.7",
"fork-ts-checker-webpack-plugin": "^7.2.13",
"generate-changelog": "^1.8.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"listr2": "^5.0.3",
"husky": "^7.0.1",
"lerna": "^6.0.1",
"lint-staged": "^12.1.7",
"listr2": "^4.0.4",
"minimist": "^1.2.6",
"mocha": "^9.0.1",
"prettier": "^2.4.0",
Expand All @@ -158,7 +147,8 @@
"electron-installer-snap": "^5.1.0",
"electron-windows-store": "^2.1.0",
"electron-winstaller": "^5.0.0",
"electron-wix-msi": "^5.0.0"
"electron-wix-msi": "^5.0.0",
"macos-alias": "^0.2.11"
},
"lint-staged": {
"*.{html,json,md,yml}": "prettier --write",
Expand All @@ -172,5 +162,16 @@
},
"volta": {
"node": "14.17.5"
},
"workspaces": {
"packages": [
"packages/api/*",
"packages/external/*",
"packages/plugin/*",
"packages/maker/*",
"packages/publisher/*",
"packages/template/*",
"packages/utils/*"
]
}
}
5 changes: 4 additions & 1 deletion packages/api/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/npm-.electron-forge-cli?utm_medium=referral&utm_source=npm_fund"
}
]
],
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/api/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,8 @@
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/npm-.electron-forge-core?utm_medium=referral&utm_source=npm_fund"
}
]
],
"publishConfig": {
"access": "public"
}
}
2 changes: 1 addition & 1 deletion packages/api/core/test/slow/api_spec_slow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ for (const nodeInstaller of ['npm', 'yarn']) {

after(async () => {
await fs.remove(dir);
execSync('npm unlink', {
execSync('npm unlink -g', {
cwd: path.resolve(__dirname, '../fixture/custom_init'),
});
});
Expand Down
3 changes: 3 additions & 0 deletions packages/maker/appx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
},
"optionalDependencies": {
"electron-windows-store": "^2.1.0"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/maker/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"@electron-forge/shared-types": "6.0.1",
"fs-extra": "^10.0.0",
"which": "^2.0.2"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/maker/deb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
},
"optionalDependencies": {
"electron-installer-debian": "^3.0.0"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/maker/dmg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
},
"optionalDependencies": {
"electron-installer-dmg": "^4.0.0"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/maker/flatpak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
},
"optionalDependencies": {
"@malept/electron-installer-flatpak": "^0.11.2"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/maker/pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"@electron-forge/maker-base": "6.0.1",
"@electron-forge/shared-types": "6.0.1",
"@electron/osx-sign": "^1.0.1"
},
"publishConfig": {
"access": "public"
}
}