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

Update Node.js, Electron and node-pty #39296

Merged
merged 11 commits into from
Mar 19, 2024
4 changes: 2 additions & 2 deletions .github/workflows/check-devbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ jobs:
uses: jetpack-io/devbox-install-action@4a7f1d5332cc72057d5e8080edebfcdf652e642e # v0.8.0
with:
enable-cache: true
devbox-version: 0.9.0
sha256-sum: a4f66cacf6091530f3d51148df83a08353906496c8ada001b0edd7ac29226dc5
devbox-version: 0.9.1
sha256-checksum: f58202279237b9e0e7d69ef9334c7ca0628db31e5575f105dad6f41a171ebb6a
2 changes: 1 addition & 1 deletion build.assets/versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
GOLANG_VERSION ?= go1.22.1
GOLANGCI_LINT_VERSION ?= v1.56.2

NODE_VERSION ?= 18.19.1
NODE_VERSION ?= 20.11.1

# Run lint-rust check locally before merging code after you bump this.
RUST_VERSION ?= 1.71.1
Expand Down
2 changes: 1 addition & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"[email protected]",
"[email protected]",
"[email protected]",
"nodejs@18.16.1",
"nodejs@20.11.1",
"[email protected]",
"[email protected]",

Expand Down
22 changes: 18 additions & 4 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,25 @@
"source": "devbox-search",
"version": "14.0.6"
},
"nodejs@18.16.1": {
"last_modified": "2023-06-30T04:44:22Z",
"resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#nodejs_18",
"nodejs@20.11.1": {
"last_modified": "2024-03-08T13:51:52Z",
"resolved": "github:NixOS/nixpkgs/a343533bccc62400e8a9560423486a3b6c11a23b#nodejs_20",
"source": "devbox-search",
"version": "18.16.1"
"version": "20.11.1",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/5c0nzhy641v5hqnpb056vvdgg3pl9hgc-nodejs-20.11.1"
},
"aarch64-linux": {
"store_path": "/nix/store/mx6ji5alyrzm731x3nxpah9ag66dak0h-nodejs-20.11.1"
},
"x86_64-darwin": {
"store_path": "/nix/store/sx7h48g69jlq5dhxmi3bwyw5qpd9lp9h-nodejs-20.11.1"
},
"x86_64-linux": {
"store_path": "/nix/store/rxpjn1vzbpv0a2i5lx887wka8054gpwj-nodejs-20.11.1"
}
}
},
"openssl@latest": {
"last_modified": "2023-08-30T00:25:28Z",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"start-teleport-e": "yarn workspace @gravitational/teleport.e start",
"build-term": "yarn workspace @gravitational/teleterm build",
"start-term": "yarn workspace @gravitational/teleterm start",
"start-term-skip-native-deps": "yarn workspace @gravitational/teleterm start-skip-native-deps",
"package-term": "yarn workspace @gravitational/teleterm package",
"storybook": "start-storybook -p 9002 -c web/.storybook -s web/.storybook/public",
"storybook-smoke-test": "yarn storybook --ci --smoke-test",
Expand Down
21 changes: 11 additions & 10 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ You can make production builds locally or you can use Docker to do that.

### Local Build

Make sure that [you have yarn installed](https://yarnpkg.com/lang/en/docs/install/#debian-stable)
on your system since this monorepo uses the yarn package manager.
Make sure that you have [Yarn 1](https://classic.yarnpkg.com/en/docs/install/) installed. The
Node.js version should match the one reported by executing `make -C build.assets print-node-version`
from the root directory.

Then you need download and initialize these repository dependencies.
Then you need to download and initialize JavaScript dependencies.

```
$ yarn install
yarn install
```

You will also need the following tools installed:
Expand All @@ -35,7 +36,7 @@ You will also need the following tools installed:
To build the Teleport open source version

```
$ yarn build-ui-oss
yarn build-ui-oss
```

The resulting output will be in the `webassets` folder.
Expand All @@ -45,7 +46,7 @@ The resulting output will be in the `webassets` folder.
To build the Teleport community version

```
$ make docker-ui
make docker-ui
```

## Getting Started with Teleport Connect
Expand Down Expand Up @@ -139,13 +140,13 @@ We use [jest](https://jestjs.io/) as our testing framework.
To run all jest unit-tests:

```
$ yarn run test
yarn run test
```

To run jest in watch-mode

```
$ yarn run tdd
yarn run tdd
```

### Interactive Testing
Expand All @@ -157,7 +158,7 @@ each component, and interactively develop and test components.
To start a storybook:

```
$ yarn run storybook
yarn run storybook
```

This command will open a new browser window with storybook in it. There
Expand All @@ -169,7 +170,7 @@ and iterate on shared functionality.
We are targeting last 2 versions of all major browsers. To quickly find out which ones exactly, use the following command:

```
$ yarn browserslist 'last 2 chrome version, last 2 edge version, last 2 firefox version, last 2 safari version'
yarn browserslist 'last 2 chrome version, last 2 edge version, last 2 firefox version, last 2 safari version'
```

### Setup Prettier on VSCode
Expand Down
2 changes: 1 addition & 1 deletion web/packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.10",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.17",
"@types/node": "^20.11.26",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"@types/react-router-dom": "^5.1.1",
Expand Down
2 changes: 1 addition & 1 deletion web/packages/teleterm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ make build/tsh
The build output can be found in the `build` directory. The tsh binary will be packed together with
the Electron app.

Next, we're going to build the Electron app. **This project uses Node.js v16 and Yarn v1.**
Next, we're going to build the Electron app.

```bash
cd teleport
Expand Down
10 changes: 1 addition & 9 deletions web/packages/teleterm/electron-builder-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,7 @@ module.exports = {
fs.writeFileSync(path, tshAppPlist);
}
},
files: [
'build/app',
// node-pty creates some files that differ across architecture builds causing
// the error "can't reconcile the non-macho files" as they cant be combined
// with lipo for a universal build. They aren't needed so skip them.
'!node_modules/node-pty/build/*/.forge-meta',
'!node_modules/node-pty/build/Debug/.deps/**',
'!node_modules/node-pty/bin',
],
files: ['build/app'],
protocols: [
{
// name ultimately becomes CFBundleURLName which is the URL identifier. [1] Apple recommends
Expand Down
8 changes: 3 additions & 5 deletions web/packages/teleterm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
},
"license": "Apache-2.0",
"scripts": {
"start": "yarn build-native-deps && yarn start-skip-native-deps",
"start-skip-native-deps": "electron-vite dev",
"start": "electron-vite dev",
"start-electron": "electron build/app/dist/main/main.js",
"build": "electron-vite build",
"build-native-deps": "electron-builder install-app-deps",
Copy link
Member

Choose a reason for hiding this comment

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

Not depending on nan and not having to rebuild binaries each time that the Electron version changes is huge.

I don't have the time to thoroughly review this today, but what I think the switch to Node-API means is that node-pty is not bound to a particular Node version but instead works with any Node that supports Node-API, see:

I suppose that's why it works without manually rebuilding the native deps.

It's fine that electron-builder rebuilds it during packaging. This way we're always sure that the node-pty version shipped with the app was built with the same Node version that's going to be used by the app.

"package": "electron-builder build --config electron-builder-config.js --publish never -c.extraMetadata.name=teleport-connect",
"generate-grpc-shared": "npx -y --target_arch=x64 --package=@protobuf-ts/[email protected] -- protoc -I=src/sharedProcess/api/proto --ts_opt long_type_number,eslint_disable,add_pb_suffix,client_grpc1,server_grpc1,ts_nocheck --ts_out=src/sharedProcess/api/protogen src/sharedProcess/api/proto/*.proto"
},
Expand All @@ -28,7 +26,7 @@
"dependencies": {
"@grpc/grpc-js": "1.8.8",
"node-forge": "^1.3.1",
"node-pty": "1.1.0-beta5",
"node-pty": "1.1.0-beta12",
"ring-buffer-ts": "^1.2.0",
"split2": "4.1.0",
"strip-ansi": "^7.1.0",
Expand All @@ -46,7 +44,7 @@
"@types/tar-fs": "^2.0.1",
"@types/whatwg-url": "^11.0.1",
"clean-webpack-plugin": "4.0.0",
"electron": "28.2.3",
"electron": "29.1.4",
"electron-notarize": "^1.2.1",
"electron-vite": "^2.0.0",
"eslint-import-resolver-webpack": "0.13.2",
Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4127,10 +4127,10 @@
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^18.11.18", "@types/node@^18.19.17":
version "18.19.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.17.tgz#a581a9fb4b2cfdbc61f008804f4436b2d5c40354"
integrity sha512-SzyGKgwPzuWp2SHhlpXKzCX0pIOfcI4V2eF37nNBJOhwlegQ83omtVQ1XxZpDE06V/d6AQvfQdPfnw0tRC//Ng==
"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^20.11.26", "@types/node@^20.9.0":
version "20.11.26"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.26.tgz#3fbda536e51d5c79281e1d9657dcb0131baabd2d"
integrity sha512-YwOMmyhNnAWijOBQweOJnQPl068Oqd4K3OFbTc6AHJwzweUwwWG3GIFY74OKks2PJUDkQPeddOQES9mLn1CTEQ==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -7447,13 +7447,13 @@ electron-vite@^2.0.0:
magic-string "^0.30.5"
picocolors "^1.0.0"

electron@28.2.3:
version "28.2.3"
resolved "https://registry.yarnpkg.com/electron/-/electron-28.2.3.tgz#d26821bcfda7ee445b4b75231da4b057a7ce6e7b"
integrity sha512-he9nGphZo03ejDjYBXpmFVw0KBKogXvR2tYxE4dyYvnfw42uaFIBFrwGeenvqoEOfheJfcI0u4rFG6h3QxDwnA==
electron@29.1.4:
version "29.1.4"
resolved "https://registry.yarnpkg.com/electron/-/electron-29.1.4.tgz#6c47467ba50be5dd60b99b8737f69cd12fc0733f"
integrity sha512-IWXys0SqgmIfrqXusUGQC0gGG7CCqA5vfmNsUMj8dFkAnK3lisKyjSESStWlrsste/OX/AAC5wsVlf23reUNnw==
dependencies:
"@electron/get" "^2.0.0"
"@types/node" "^18.11.18"
"@types/node" "^20.9.0"
extract-zip "^2.0.1"

emittery@^0.13.1:
Expand Down Expand Up @@ -11926,11 +11926,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==

nan@^2.17.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.18.0.tgz#26a6faae7ffbeb293a39660e88a76b82e30b7554"
integrity sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==

nanoid@^3.3.1, nanoid@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
Expand Down Expand Up @@ -11996,6 +11991,11 @@ node-addon-api@^1.6.3:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.2.tgz#3df30b95720b53c24e59948b49532b662444f54d"
integrity sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==

node-addon-api@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-7.1.0.tgz#71f609369379c08e251c558527a107107b5e0fdb"
integrity sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==

node-dir@^0.1.10:
version "0.1.17"
resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5"
Expand Down Expand Up @@ -12036,12 +12036,12 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=

[email protected]beta5:
version "1.1.0-beta5"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.1.0-beta5.tgz#364386b7058a93070234064f13164ec1ef914993"
integrity sha512-j3QdgFHnLY0JWxztrvM3g67RaQLOGvytv+C6mFu0PqD+JILlzqfwuoyqRqVxdZZjoOTUXPfSRj1qPVCaCH+eOw==
[email protected]beta12:
version "1.1.0-beta12"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.1.0-beta12.tgz#702f8c05ac1d175dcbc17901f1c66ee5d67b27cd"
integrity sha512-xhWrczF9AN+TnIZoHcSiclt4dkD1IcncUOzcdgx3by0jwctt54ZgWEp68O0lE0D8ydxa/bk3nA9sWEDhDNJuwg==
dependencies:
nan "^2.17.0"
node-addon-api "^7.1.0"

node-releases@^2.0.13:
version "2.0.13"
Expand Down
Loading