From cbf75359c82b6ef9ce276a5d9df578e9975e3508 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Sun, 6 Nov 2022 00:29:28 +0800 Subject: [PATCH 1/4] chore: enable Node 18 --- .github/workflows/integration-test.yml | 2 ++ .github/workflows/main.yml | 6 ++++++ package.json | 4 ++-- packages/cli/package.json | 2 +- packages/console/package.json | 3 +++ packages/core/package.json | 2 +- packages/create/package.json | 2 +- packages/demo-app/package.json | 3 +++ packages/integration-tests/package.json | 3 +++ packages/phrases-ui/package.json | 3 +++ packages/phrases/package.json | 2 +- packages/schemas/package.json | 2 +- packages/shared/package.json | 2 +- packages/ui/package.json | 3 +++ 14 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index f2483f27d..80eafac28 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -46,6 +46,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] + node_version: [16, 18] runs-on: ${{ matrix.os }} @@ -69,6 +70,7 @@ jobs: - name: Setup Node and pnpm uses: silverhand-io/actions-node-pnpm-run-steps@v2 with: + node-version: ${{ matrix.node_version }} run-install: false # Setup integration test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dffec17c5..af5765f0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,11 +47,17 @@ jobs: main-test: runs-on: ubuntu-latest + strategy: + matrix: + node_version: [16, 18] + steps: - uses: actions/checkout@v3 - name: Setup Node and pnpm uses: silverhand-io/actions-node-pnpm-run-steps@v2 + with: + node-version: ${{ matrix.node_version }} - name: Prepack run: pnpm prepack diff --git a/package.json b/package.json index 291afbab8..d4e93b575 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,8 @@ ] }, "engines": { - "node": ">=14.15.0", - "pnpm": ">=6" + "node": "^16.13.0 || ^18.12.0", + "pnpm": "^7.14.0" }, "alias": { "html-parse-stringify": "html-parse-stringify/dist/html-parse-stringify.module.js", diff --git a/packages/cli/package.json b/packages/cli/package.json index de9625cb1..a34330050 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -34,7 +34,7 @@ "prepack": "pnpm build" }, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "bugs": { "url": "https://github.com/logto-io/logto/issues" diff --git a/packages/console/package.json b/packages/console/package.json index 0eb6f0e5b..e0de9a9d7 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -84,6 +84,9 @@ "typescript": "^4.7.4", "zod": "^3.19.1" }, + "engines": { + "node": "^16.13.0 || ^18.12.0" + }, "alias": { "@/*": "./src/$1", "@mdx/components/*": "./src/mdx-components/$1" diff --git a/packages/core/package.json b/packages/core/package.json index 6b76aa0b7..f182c9653 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -100,7 +100,7 @@ "typescript": "^4.7.4" }, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "_moduleAliases": { "@": "./build" diff --git a/packages/create/package.json b/packages/create/package.json index a950e218f..82161724c 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -11,7 +11,7 @@ }, "scripts": {}, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "dependencies": { "@logto/cli": "workspace:^" diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index 245754ce1..c03ab536f 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -44,6 +44,9 @@ "stylelint": "^14.9.1", "typescript": "^4.7.4" }, + "engines": { + "node": "^16.13.0 || ^18.12.0" + }, "alias": { "@/*": "./src/$1" }, diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 9abf959e9..228b5f5f7 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -39,6 +39,9 @@ "ts-node": "^10.9.1", "typescript": "^4.7.4" }, + "engines": { + "node": "^16.13.0 || ^18.12.0" + }, "eslintConfig": { "extends": "@silverhand" }, diff --git a/packages/phrases-ui/package.json b/packages/phrases-ui/package.json index df0a50a77..0b690b2a2 100644 --- a/packages/phrases-ui/package.json +++ b/packages/phrases-ui/package.json @@ -44,6 +44,9 @@ "prettier": "^2.7.1", "typescript": "^4.7.4" }, + "engines": { + "node": "^16.13.0 || ^18.12.0" + }, "eslintConfig": { "extends": "@silverhand" }, diff --git a/packages/phrases/package.json b/packages/phrases/package.json index f79eef4b7..0eef2125d 100644 --- a/packages/phrases/package.json +++ b/packages/phrases/package.json @@ -25,7 +25,7 @@ "prepack": "pnpm build" }, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "bugs": { "url": "https://github.com/logto-io/logto/issues" diff --git a/packages/schemas/package.json b/packages/schemas/package.json index c561267c8..91258e648 100644 --- a/packages/schemas/package.json +++ b/packages/schemas/package.json @@ -27,7 +27,7 @@ "test:ci": "jest" }, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "devDependencies": { "@silverhand/eslint-config": "1.3.0", diff --git a/packages/shared/package.json b/packages/shared/package.json index c44c5ab15..ab3ab05bf 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -33,7 +33,7 @@ "typescript": "^4.7.4" }, "engines": { - "node": "^16.0.0" + "node": "^16.13.0 || ^18.12.0" }, "eslintConfig": { "extends": "@silverhand", diff --git a/packages/ui/package.json b/packages/ui/package.json index 881351cc7..6e4021263 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -71,6 +71,9 @@ "typescript": "^4.7.4", "use-debounced-loader": "^0.1.1" }, + "engines": { + "node": "^16.13.0 || ^18.12.0" + }, "alias": { "@/*": "./src/$1" }, From 33fd811beee092367c15631c0c60c828ef36d3e2 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Sun, 6 Nov 2022 00:48:00 +0800 Subject: [PATCH 2/4] refactor(cli): update node version check --- packages/cli/src/commands/install/utils.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/install/utils.ts b/packages/cli/src/commands/install/utils.ts index e21d7ee0e..529d562f8 100644 --- a/packages/cli/src/commands/install/utils.ts +++ b/packages/cli/src/commands/install/utils.ts @@ -27,16 +27,17 @@ export const defaultPath = path.join(os.homedir(), 'logto'); const pgRequired = new semver.SemVer('14.0.0'); export const validateNodeVersion = () => { - const required = new semver.SemVer('16.0.0'); + const required = [new semver.SemVer('16.13.0'), new semver.SemVer('18.12.0')]; + const requiredVersionString = required.map((version) => '^' + version.version).join(' || '); const current = new semver.SemVer(execSync('node -v', { encoding: 'utf8', stdio: 'pipe' })); - if (required.compare(current) > 0) { - log.error(`Logto requires NodeJS >=${required.version}, but ${current.version} found.`); + if (required.every((version) => version.major !== current.major)) { + log.error(`Logto requires NodeJS ${requiredVersionString}, but ${current.version} found.`); } - if (current.major > required.major) { + if (required.some((version) => version.major === current.major && version.compare(current) > 0)) { log.warn( - `Logto is tested under NodeJS ^${required.version}, but version ${current.version} found.` + `Logto is tested under NodeJS ${requiredVersionString}, but version ${current.version} found.` ); } }; From 117b50af7a35986dad039210c550f372c6610101 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 7 Nov 2022 21:40:09 +0800 Subject: [PATCH 3/4] chore: fix parcel engines issue See https://github.com/parcel-bundler/parcel/issues/7636 --- packages/console/package.json | 8 ++++++++ packages/demo-app/package.json | 8 ++++++++ packages/ui/package.json | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/packages/console/package.json b/packages/console/package.json index e0de9a9d7..1951295f3 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -87,6 +87,14 @@ "engines": { "node": "^16.13.0 || ^18.12.0" }, + "//": "https://github.com/parcel-bundler/parcel/issues/7636", + "targets": { + "default": { + "engines": { + "browsers": "defaults" + } + } + }, "alias": { "@/*": "./src/$1", "@mdx/components/*": "./src/mdx-components/$1" diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index c03ab536f..8e310b50b 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -47,6 +47,14 @@ "engines": { "node": "^16.13.0 || ^18.12.0" }, + "//": "https://github.com/parcel-bundler/parcel/issues/7636", + "targets": { + "default": { + "engines": { + "browsers": "defaults" + } + } + }, "alias": { "@/*": "./src/$1" }, diff --git a/packages/ui/package.json b/packages/ui/package.json index 6e4021263..738397014 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -74,6 +74,14 @@ "engines": { "node": "^16.13.0 || ^18.12.0" }, + "//": "https://github.com/parcel-bundler/parcel/issues/7636", + "targets": { + "default": { + "engines": { + "browsers": "defaults" + } + } + }, "alias": { "@/*": "./src/$1" }, From 3a0df40fc171586e770869cd5c718a5d0aee8800 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 7 Nov 2022 23:11:21 +0800 Subject: [PATCH 4/4] chore: manually install Chromium before integration test --- .github/workflows/integration-test.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 80eafac28..165c7139b 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -18,13 +18,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Cache Puppeteer - uses: actions/cache@v3 - with: - # https://pptr.dev/guides/configuration/#changing-the-default-cache-directory - path: ~/.cache/puppeteer - key: ${{ runner.os }}-pptr-${{ hashFiles('packages/integration-tests/package.json') }} - - name: Setup Node and pnpm uses: silverhand-io/actions-node-pnpm-run-steps@v2 @@ -45,23 +38,15 @@ jobs: strategy: matrix: - os: [ubuntu-latest] node_version: [16, 18] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: path: tests - - name: Cache Puppeteer - uses: actions/cache@v3 - with: - # https://pptr.dev/guides/configuration/#changing-the-default-cache-directory - path: ~/.cache/puppeteer - key: ${{ runner.os }}-pptr-${{ hashFiles('tests/packages/integration-tests/package.json') }} - - name: Copy lockfile run: | cp tests/pnpm-lock.yaml ./ @@ -79,6 +64,9 @@ jobs: cd tests pnpm i pnpm prepack + # Install Chromium + cd packages/integration-tests/node_modules/puppeteer + pnpm postinstall # Setup environment - name: Setup Postgres