Skip to content

Commit

Permalink
infra(node) - upgrade to node v22 (#8900)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiladShoham authored Dec 1, 2024
1 parent f943b42 commit 21a0d49
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 33 deletions.
83 changes: 57 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

default_image: &default_image
docker:
- image: cimg/node:20.11.1
- image: cimg/node:22.11.0

default_resource_class: &default_resource_class
resource_class: medium
Expand Down Expand Up @@ -87,7 +87,7 @@ commands: # reusable commands
default: 'BASE_IMAGE'
type: string
docker_build_arg_value:
default: 'node:20.11.1'
default: 'node:22.11.0'
type: string
image_name:
default: 'bitcli/bit'
Expand Down Expand Up @@ -116,7 +116,7 @@ commands: # reusable commands
default: 'BASE_IMAGE'
type: string
docker_build_arg_value:
default: 'node:20.11.1'
default: 'node:22.11.0'
type: string
image_name:
default: 'bitcli/bit'
Expand Down Expand Up @@ -198,13 +198,13 @@ commands: # reusable commands
windows_set_node_version:
parameters:
version:
default: 20.11.1
default: 22.11.0
type: string
steps:
- run: choco upgrade nvm -y
- run: nvm -v
- run: nvm install 20.11.1
- run: nvm use 20.11.1
- run: nvm install 22.11.0
- run: nvm use 22.11.0
- run: node -v
windows_add_bvm_to_path:
steps:
Expand All @@ -230,7 +230,7 @@ commands: # reusable commands
name: Install pnpm
command: >
npm config set prefix '~/.npm-global' &&
npm install --global pnpm@8.10.4 &&
npm install --global pnpm@9.1.2 &&
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV
compress_bit:
Expand Down Expand Up @@ -272,8 +272,18 @@ jobs:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_arg_value: "node:20.11.1"
docker_tag_suffix: "-node-20.11.1"
docker_build_arg_value: "node:20.13.1"
docker_tag_suffix: "-node-20.13.1"

docker_build_node_22:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_arg_value: "node:22.11.0"
docker_tag_suffix: "-node-22.11.0"

# docker_non_root_build:
# machine:
Expand All @@ -285,31 +295,31 @@ jobs:
# image_name: "bitcli/bit-non-root"
# docker_file_name: "Dockerfile-bit-non-root"

docker_non_root_build_node_20:
docker_non_root_build_node_22:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_arg_value: "node:20.11.1"
docker_build_arg_value: "node:22.11.0"
image_name: "bitcli/bit-non-root"
docker_file_name: "Dockerfile-bit-non-root"
docker_tag_suffix: "-node-20.11.1"
docker_tag_suffix: "-node-22.11.0"


server_docker_build_node_20:
server_docker_build_node_22:
machine:
image: ubuntu-2004:202111-02
steps:
- attach_workspace:
at: ./
- docker_build_and_push:
docker_build_arg_name: "BIT_IMAGE"
docker_build_arg_value: "`npm show @teambit/bit version`-node-20.11.1"
docker_build_arg_value: "`npm show @teambit/bit version`-node-22.11.0"
image_name: "bitcli/bit-server"
docker_file_name: "Dockerfile-bit-server"
docker_tag_suffix: "-node-20.11.1"

docker_tag_suffix: "-node-22.11.0"
set_ssh_key:
<<: *defaults
working_directory: ~/.ssh
Expand Down Expand Up @@ -668,6 +678,7 @@ jobs:
echo "registry=https://node-registry.bit.cloud" >> .npmrc &&
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.os --values linux --values linux &&
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.cpu --values x64 --values x64 &&
pnpm dlx @ialdama/jsonmod --key pnpm.overrides.uri-js --values npm:uri-js-replace &&
pnpm add @teambit/bit
- compress_bit
- run:
Expand Down Expand Up @@ -714,6 +725,7 @@ jobs:
echo "registry=https://node-registry.bit.cloud" >> .npmrc &&
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.os --values darwin --values darwin &&
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.cpu --values x64 --values x64 &&
pnpm dlx @ialdama/jsonmod --key pnpm.overrides.uri-js --values npm:uri-js-replace &&
pnpm add @teambit/bit
- compress_bit
- run:
Expand Down Expand Up @@ -762,6 +774,7 @@ jobs:
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.os --values win32 --values win32 &&
pnpm dlx @ialdama/jsonmod --key pnpm.supportedArchitectures.cpu --values x64 --values x64 &&
pnpm dlx @ialdama/jsonmod --key pnpm.neverBuiltDependencies --values cpu-features --values ssh2 &&
pnpm dlx @ialdama/jsonmod --key pnpm.overrides.uri-js --values npm:uri-js-replace &&
pnpm add @teambit/bit
- compress_bit
- run:
Expand Down Expand Up @@ -923,9 +936,9 @@ jobs:
# - run: node -v
# - run: npm -v
# - run: yarn -v
# # - run: choco install nodejs --version 20.11.1
# # - run: choco install nodejs --version 22.11.0
# # - run: node -v
# - run: cinst nodejs --version 20.11.1
# - run: cinst nodejs --version 22.11.0
# - run: node -v

windows_checkout_code:
Expand Down Expand Up @@ -1364,15 +1377,21 @@ workflows:
# - server_docker_build_node_18:
# requires:
# - docker_build_node_18
- docker_build_node_20:
# - docker_build_node_20:
# requires:
# - harmony_publish_to_gcloud
- docker_build_node_22:
requires:
- harmony_publish_to_gcloud
- docker_non_root_build_node_20:
- docker_non_root_build_node_22:
requires:
- harmony_publish_to_gcloud
- server_docker_build_node_20:
# - server_docker_build_node_20:
# requires:
# - docker_build_node_20
- server_docker_build_node_22:
requires:
- docker_build_node_20
- docker_build_node_22

windows-nightly:
triggers:
Expand Down Expand Up @@ -1513,18 +1532,30 @@ workflows:
# requires:
# - harmony_deploy_approval_job
# - docker_build_node_18
- docker_build_node_20:
# - docker_build_node_20:
# requires:
# - harmony_deploy_approval_job
# - harmony_publish_to_gcloud
# - docker_non_root_build_node_20:
# requires:
# - harmony_deploy_approval_job
# - harmony_publish_to_gcloud
# - server_docker_build_node_20:
# requires:
# - harmony_deploy_approval_job
# - docker_build_node_20
- docker_build_node_22:
requires:
- harmony_deploy_approval_job
- harmony_publish_to_gcloud
- docker_non_root_build_node_20:
- docker_non_root_build_node_22:
requires:
- harmony_deploy_approval_job
- harmony_publish_to_gcloud
- server_docker_build_node_20:
- server_docker_build_node_22:
requires:
- harmony_deploy_approval_job
- docker_build_node_20
- docker_build_node_22

# uncomment to update esbuild arm64 cache
# get_arm64_workflow_packages:
Expand Down
37 changes: 35 additions & 2 deletions scopes/harmony/bit/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { BIT_VERSION, GLOBAL_CONFIG, GLOBAL_LOGS } from '@teambit/legacy/dist/co
import { printWarning, shouldDisableConsole, shouldDisableLoader } from '@teambit/legacy/dist/logger/logger';
import { loader } from '@teambit/legacy.loader';

const RECOMMENDED_NODE_VERSIONS = '>=20.0.0 <21.0.0';
const SUPPORTED_NODE_VERSIONS = '>=16.0.0 <21.0.0';
const RECOMMENDED_NODE_VERSIONS = '>=20.0.0 <23.0.0';
const SUPPORTED_NODE_VERSIONS = '>=16.0.0 <23.0.0';

process.env.MEMFS_DONT_WARN = 'true'; // suppress fs experimental warnings from memfs

Expand All @@ -21,6 +21,39 @@ require('regenerator-runtime/runtime');
// eslint-disable-next-line @typescript-eslint/no-misused-promises
process.on('unhandledRejection', async (err: any) => handleUnhandledRejection(err));

const originalEmit = process.emit;
// @ts-expect-error - TS complains about the return type of originalEmit.apply
process.emit = function (name, data) {
// --------------------------------------------
// this fix is based on yarn fix for the similar issue, see code here:
// https://github.com/yarnpkg/berry/blob/2cf0a8fe3e4d4bd7d4d344245d24a85a45d4c5c9/packages/yarnpkg-pnp/sources/loader/applyPatch.ts#L414-L435
// ignore punycode deprecation warning
// ignoring this warning for now, as the main issue is that
// this package https://www.npmjs.com/package/uri-js?activeTab=readme is using it and it's deprecated
// the package have the correct punycode version as a dependency from the user land
// but it uses it incorrectly, it should use it with a trailing slash
// the require in their code is require('punycode') and not require('punycode/') (with trailing slash)
// As this package is not maintained anymore, we can't fix it from our side
// see more at:
// https://github.com/garycourt/uri-js/issues/97
// https://github.com/garycourt/uri-js/pull/95
// on the bit repo we overriding the uri-js package with a fixed version (see overrides in workspace.jsonc)
// "uri-js": "npm:uri-js-replace"
// but we don't want to override it automatically for all the users
// there are many other packages (like webpack, eslint, etc) that are using this uri-js package
// so if we won't ignore it, all users will get this warning
if (
name === `warning` &&
typeof data === `object` &&
((data.name === `DeprecationWarning` && data.message.includes(`punycode`)) || data.code === `DEP0040`)
)
return false;
// --------------------------------------------

// eslint-disable-next-line prefer-rest-params
return originalEmit.apply(process, arguments as unknown as Parameters<typeof process.emit>);
};

// by default Bluebird enables the longStackTraces when env is `development`, or when
// BLUEBIRD_DEBUG is set.
// the drawback of enabling it all the time is a performance hit. (see http://bluebirdjs.com/docs/api/promise.longstacktraces.html)
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-teambit-bit/Dockerfile-bit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=node:20.11.1
ARG BASE_IMAGE=node:22.11.0
FROM $BASE_IMAGE
USER root

Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-teambit-bit/Dockerfile-bit-non-root
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=node:20.11.1
ARG BASE_IMAGE=node:22.11.0
FROM $BASE_IMAGE
RUN adduser --disabled-password --gecos '' user
RUN chown -R user /usr/local/
Expand Down
10 changes: 7 additions & 3 deletions workspace.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,14 @@
"signal-exit@4": "^4.0.2",
"@types/react": "^17.0.67",
"@types/react-dom": "^17.0.21",
"[email protected]": "7.1.3"
"[email protected]": "7.1.3",
// See more info here -
// https://github.com/garycourt/uri-js/pull/95
// https://github.com/garycourt/uri-js/issues/97
"uri-js": "npm:uri-js-replace"
},
"rootComponents": true,
"nodeVersion": "20.11.1",
"nodeVersion": "22.11.0",
"engineStrict": true,
// This is a temporary workaround to fix "bit compile" on macOS and Windows.
// "bit compile" breaks node_modules when hard links are used.
Expand Down Expand Up @@ -616,7 +620,7 @@
"packageJson": {
"name": "@teambit/{name}", // @teambit/discovery.ui.sidebar
"bvm": {
"node": "20.11.1"
"node": "22.11.0"
},
"bin": {
"bbit": "bin/bit"
Expand Down

0 comments on commit 21a0d49

Please sign in to comment.