From 57a35a076eb56aca26030741fc3af91e89dacfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcholas=20Oliveira?= Date: Mon, 10 Jun 2024 12:47:24 -0300 Subject: [PATCH 1/3] chore: migrate to turbo 2.0 --- package-lock.json | 72 ++++++++++++++++----------------- package.json | 21 +++++----- packages/core/tsconfig.ref.json | 7 ---- packages/next/tsconfig.ref.json | 7 ---- tsconfig.json | 10 +---- turbo.json | 48 ++++++++++++++-------- 6 files changed, 79 insertions(+), 86 deletions(-) delete mode 100644 packages/core/tsconfig.ref.json delete mode 100644 packages/next/tsconfig.ref.json diff --git a/package-lock.json b/package-lock.json index b56f0c56c..4ae720f4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@10up/headless_framework", + "name": "@10up/headstartwp", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@10up/headless_framework", + "name": "@10up/headstartwp", "version": "1.0.0", "workspaces": [ "packages/core", @@ -28,19 +28,19 @@ "jest-environment-jsdom": "^29.0.3", "lint-staged": "^11.1.2", "prettier": "3.2.5", - "turbo": "^1.9.3" + "turbo": "^2.0.3" }, "engines": { "node": ">=18.0.0", "npm": ">=9.0.0" }, "optionalDependencies": { - "turbo-darwin-64": "^1.9.3", - "turbo-darwin-arm64": "^1.9.3", - "turbo-linux-64": "^1.9.3", - "turbo-linux-arm64": "^1.9.3", - "turbo-windows-64": "^1.9.3", - "turbo-windows-arm64": "^1.9.3" + "turbo-darwin-64": "^2.0.3", + "turbo-darwin-arm64": "^2.0.3", + "turbo-linux-64": "^2.0.3", + "turbo-linux-arm64": "^2.0.3", + "turbo-windows-64": "^2.0.3", + "turbo-windows-arm64": "^2.0.3" } }, "node_modules/@10up/babel-preset-default": { @@ -20666,26 +20666,26 @@ } }, "node_modules/turbo": { - "version": "1.9.3", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.0.3.tgz", + "integrity": "sha512-jF1K0tTUyryEWmgqk1V0ALbSz3VdeZ8FXUo6B64WsPksCMCE48N5jUezGOH2MN0+epdaRMH8/WcPU0QQaVfeLA==", "dev": true, - "hasInstallScript": true, - "license": "MPL-2.0", "bin": { "turbo": "bin/turbo" }, "optionalDependencies": { - "turbo-darwin-64": "1.9.3", - "turbo-darwin-arm64": "1.9.3", - "turbo-linux-64": "1.9.3", - "turbo-linux-arm64": "1.9.3", - "turbo-windows-64": "1.9.3", - "turbo-windows-arm64": "1.9.3" + "turbo-darwin-64": "2.0.3", + "turbo-darwin-arm64": "2.0.3", + "turbo-linux-64": "2.0.3", + "turbo-linux-arm64": "2.0.3", + "turbo-windows-64": "2.0.3", + "turbo-windows-arm64": "2.0.3" } }, "node_modules/turbo-darwin-64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-1.9.3.tgz", - "integrity": "sha512-0dFc2cWXl82kRE4Z+QqPHhbEFEpUZho1msHXHWbz5+PqLxn8FY0lEVOHkq5tgKNNEd5KnGyj33gC/bHhpZOk5g==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.0.3.tgz", + "integrity": "sha512-v7ztJ8sxdHw3SLfO2MhGFeeU4LQhFii1hIGs9uBiXns/0YTGOvxLeifnfGqhfSrAIIhrCoByXO7nR9wlm10n3Q==", "cpu": [ "x64" ], @@ -20695,9 +20695,9 @@ ] }, "node_modules/turbo-darwin-arm64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.9.3.tgz", - "integrity": "sha512-1cYbjqLBA2zYE1nbf/qVnEkrHa4PkJJbLo7hnuMuGM0bPzh4+AnTNe98gELhqI1mkTWBu/XAEeF5u6dgz0jLNA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.0.3.tgz", + "integrity": "sha512-LUcqvkV9Bxtng6QHbevp8IK8zzwbIxM6HMjCE7FEW6yJBN1KwvTtRtsGBwwmTxaaLO0wD1Jgl3vgkXAmQ4fqUw==", "cpu": [ "arm64" ], @@ -20707,9 +20707,9 @@ ] }, "node_modules/turbo-linux-64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-1.9.3.tgz", - "integrity": "sha512-UuBPFefawEwpuxh5pM9Jqq3q4C8M0vYxVYlB3qea/nHQ80pxYq7ZcaLGEpb10SGnr3oMUUs1zZvkXWDNKCJb8Q==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.0.3.tgz", + "integrity": "sha512-xpdY1suXoEbsQsu0kPep2zrB8ijv/S5aKKrntGuQ62hCiwDFoDcA/Z7FZ8IHQ2u+dpJARa7yfiByHmizFE0r5Q==", "cpu": [ "x64" ], @@ -20719,9 +20719,9 @@ ] }, "node_modules/turbo-linux-arm64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-1.9.3.tgz", - "integrity": "sha512-vUrNGa3hyDtRh9W0MkO+l1dzP8Co2gKnOVmlJQW0hdpOlWlIh22nHNGGlICg+xFa2f9j4PbQlWTsc22c019s8Q==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.0.3.tgz", + "integrity": "sha512-MBACTcSR874L1FtLL7gkgbI4yYJWBUCqeBN/iE29D+8EFe0d3fAyviFlbQP4K/HaDYet1i26xkkOiWr0z7/V9A==", "cpu": [ "arm64" ], @@ -20731,9 +20731,9 @@ ] }, "node_modules/turbo-windows-64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-1.9.3.tgz", - "integrity": "sha512-0BZ7YaHs6r+K4ksqWus1GKK3W45DuDqlmfjm/yuUbTEVc8szmMCs12vugU2Zi5GdrdJSYfoKfEJ/PeegSLIQGQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.0.3.tgz", + "integrity": "sha512-zi3YuKPkM9JxMTshZo3excPk37hUrj5WfnCqh4FjI26ux6j/LJK+Dh3SebMHd9mR7wP9CMam4GhmLCT+gDfM+w==", "cpu": [ "x64" ], @@ -20743,9 +20743,9 @@ ] }, "node_modules/turbo-windows-arm64": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-1.9.3.tgz", - "integrity": "sha512-QJUYLSsxdXOsR1TquiOmLdAgtYcQ/RuSRpScGvnZb1hY0oLc7JWU0llkYB81wVtWs469y8H9O0cxbKwCZGR4RQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.0.3.tgz", + "integrity": "sha512-wmed4kkenLvRbidi7gISB4PU77ujBuZfgVGDZ4DXTFslE/kYpINulwzkVwJIvNXsJtHqyOq0n6jL8Zwl3BrwDg==", "cpu": [ "arm64" ], diff --git a/package.json b/package.json index c4ea133b7..7809faa3e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@10up/headless_framework", + "name": "@10up/headstartwp", "version": "1.0.0", "description": "Monorepo for headless framework", "homepage": "https://github.com/10up/headstartwp#readme", @@ -48,8 +48,8 @@ "jest": "^29.0.3", "jest-environment-jsdom": "^29.0.3", "lint-staged": "^11.1.2", - "turbo": "^1.9.3", - "prettier": "3.2.5" + "prettier": "3.2.5", + "turbo": "^2.0.3" }, "nextBundleAnalysis": { "buildOutputDirectory": "./projects/wp-nextjs/.next", @@ -63,11 +63,12 @@ "npm": ">=9.0.0" }, "optionalDependencies": { - "turbo-darwin-64": "^1.9.3", - "turbo-darwin-arm64": "^1.9.3", - "turbo-linux-64": "^1.9.3", - "turbo-linux-arm64": "^1.9.3", - "turbo-windows-64": "^1.9.3", - "turbo-windows-arm64": "^1.9.3" - } + "turbo-darwin-64": "^2.0.3", + "turbo-darwin-arm64": "^2.0.3", + "turbo-linux-64": "^2.0.3", + "turbo-linux-arm64": "^2.0.3", + "turbo-windows-64": "^2.0.3", + "turbo-windows-arm64": "^2.0.3" + }, + "packageManager": "npm@10.5.0" } diff --git a/packages/core/tsconfig.ref.json b/packages/core/tsconfig.ref.json deleted file mode 100644 index 996ce91c3..000000000 --- a/packages/core/tsconfig.ref.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src/**/*"], - "compilerOptions": { - "composite": true, - }, - } \ No newline at end of file diff --git a/packages/next/tsconfig.ref.json b/packages/next/tsconfig.ref.json deleted file mode 100644 index f995bb5c3..000000000 --- a/packages/next/tsconfig.ref.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src/**/*"], - "compilerOptions": { - "composite": true - }, -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index e1ce3db82..26cae1ed1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,13 +22,5 @@ "jsx": "react-jsx", "noImplicitAny": false, }, - "compileOnSave": false, - "references": [ - { - "path": "./packages/core/tsconfig.ref.json" - }, - { - "path": "./packages/next/tsconfig.ref.json" - } - ] + "compileOnSave": false } \ No newline at end of file diff --git a/turbo.json b/turbo.json index 2ab79145b..6e16d75ff 100644 --- a/turbo.json +++ b/turbo.json @@ -1,19 +1,33 @@ { - "$schema": "https://turborepo.org/schema.json", - "pipeline": { - "build": { - "dependsOn": ["^build"], - "outputs": ["dist/**", ".next/**", "!.next/cache/**"] - }, - "test": { - "outputs": [""], - "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts"] - }, - "lint": { - "outputs": [""] - }, - "dev": { - "cache": false - } + "$schema": "https://turborepo.org/schema.json", + "tasks": { + "build": { + "dependsOn": [ + "^build" + ], + "outputs": [ + "dist/**", + ".next/**", + "!.next/cache/**" + ] + }, + "test": { + "outputs": [ + "" + ], + "inputs": [ + "src/**/*.tsx", + "src/**/*.ts", + "test/**/*.ts" + ] + }, + "lint": { + "outputs": [ + "" + ] + }, + "dev": { + "cache": false } -} \ No newline at end of file + } +} From 07b2c8f8d18fad2e69a36ed2407921c4d868e280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcholas=20Oliveira?= Date: Mon, 10 Jun 2024 13:09:50 -0300 Subject: [PATCH 2/3] chore: migrate to turbo 2.0 --- package.json | 10 ++++------ turbo.json | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7809faa3e..52469dead 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,12 @@ "scripts": { "build": "turbo run build", "build:packages": "turbo run build --filter=./packages/*", - "build:wpnextjs": "npm run build:packages && turbo run build --filter=./projects/wp-nextjs", - "test": "npm run build:packages && turbo run test", + "build:wpnextjs": "turbo run build --filter=./projects/wp-nextjs", + "test": "turbo run test", "lint": "turbo run lint", "wp-env": "npm run wp-env:start -w=wp/headless-wp", - "nextjs:dev": "turbo run dev --parallel --filter=!./projects/wp-multisite-nextjs --filter=!./projects/wp-multisite-i18n-nextjs --filter=!./projects/wp-nextjs-ts", - "nextjs:dev-multisite": "turbo run dev --parallel --filter=!./projects/wp-nextjs", - "dev": "npm run build:packages && npm run wp-env && npm run nextjs:dev", - "dev:multisite": "npm run build:packages && npm run wp-env && npm run nextjs:dev-multisite", + "dev": "turbo run dev --parallel --filter=!./projects/wp-multisite-nextjs --filter=!./projects/wp-multisite-i18n-nextjs", + "dev:multisite": "turbo run dev --parallel --filter=!./projects/wp-nextjs", "prepare": "husky install", "typedoc": "typedoc", "typedoc:watch": "typedoc --watch", diff --git a/turbo.json b/turbo.json index 6e16d75ff..268de177c 100644 --- a/turbo.json +++ b/turbo.json @@ -12,6 +12,7 @@ ] }, "test": { + "dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build"], "outputs": [ "" ], @@ -27,6 +28,11 @@ ] }, "dev": { + "cache": false, + "persistent": true, + "dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build", "//#wp-env", "@10up/next-redis-cache-provider#build"] + }, + "//#wp-env": { "cache": false } } From bd41697a28450bdba3a084dfc9a87bafadb23ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcholas=20Oliveira?= Date: Mon, 10 Jun 2024 13:51:33 -0300 Subject: [PATCH 3/3] test: add new blocks renderer test --- package.json | 1 + packages/core/package.json | 1 + .../components/__tests__/BlocksRenderer.tsx | 18 ++++++++++++++++++ .../__snapshots__/BlocksRenderer.tsx.snap | 15 +++++++++++++++ .../next-redis-cache-provider/package.json | 3 ++- packages/next/package.json | 1 + turbo.json | 12 ++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap diff --git a/package.json b/package.json index 52469dead..21733cdfa 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build:packages": "turbo run build --filter=./packages/*", "build:wpnextjs": "turbo run build --filter=./projects/wp-nextjs", "test": "turbo run test", + "test:watch": "turbo run test:watch", "lint": "turbo run lint", "wp-env": "npm run wp-env:start -w=wp/headless-wp", "dev": "turbo run dev --parallel --filter=!./projects/wp-multisite-nextjs --filter=!./projects/wp-multisite-i18n-nextjs", diff --git a/packages/core/package.json b/packages/core/package.json index ab8fcc9c4..28024cd55 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -48,6 +48,7 @@ "watch:ts:cjs": "npm run ts:cjs -- --watch", "watch:ts": "npm run ts -- --watch", "test": "jest", + "test:watch": "jest --watch", "lint": "eslint src/" }, "devDependencies": { diff --git a/packages/core/src/react/components/__tests__/BlocksRenderer.tsx b/packages/core/src/react/components/__tests__/BlocksRenderer.tsx index 5a9b7d62f..9bd53c039 100644 --- a/packages/core/src/react/components/__tests__/BlocksRenderer.tsx +++ b/packages/core/src/react/components/__tests__/BlocksRenderer.tsx @@ -203,4 +203,22 @@ describe('BlocksRenderer', () => { `); }); + + it('works correctly with chinese content', () => { + const StrongToDiv = ({ domNode, children }: BlockProps) => { + const className = + domNode instanceof Element ? domNode?.attribs.class || undefined : undefined; + return
{children}
; + }; + + const { container } = render( + 活動期間`} + > + + , + ); + + expect(container).toMatchSnapshot(); + }); }); diff --git a/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap b/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap new file mode 100644 index 000000000..60cb6caa8 --- /dev/null +++ b/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BlocksRenderer works correctly with chinese content 1`] = ` +
+

+ + 活動期間 + +

+
+`; diff --git a/packages/next-redis-cache-provider/package.json b/packages/next-redis-cache-provider/package.json index cb7f5cb78..868494a5e 100644 --- a/packages/next-redis-cache-provider/package.json +++ b/packages/next-redis-cache-provider/package.json @@ -21,7 +21,8 @@ "dev": "npm run watch:ts", "watch:ts": "npm run ts -- --watch", "lint": "eslint src", - "test": "jest" + "test": "jest", + "test:watch": "jest --watch" }, "dependencies": { "ioredis": "^5.3.1" diff --git a/packages/next/package.json b/packages/next/package.json index f28870f4b..2269f8ee6 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -46,6 +46,7 @@ "watch:ts:cjs": "npm run ts:cjs -- --watch", "watch:ts": "npm run ts -- --watch", "test": "jest", + "test:watch": "jest --watch", "lint": "eslint src" }, "dependencies": { diff --git a/turbo.json b/turbo.json index 268de177c..725121ec3 100644 --- a/turbo.json +++ b/turbo.json @@ -22,6 +22,18 @@ "test/**/*.ts" ] }, + "test:watch": { + "persistent": true, + "dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build"], + "outputs": [ + "" + ], + "inputs": [ + "src/**/*.tsx", + "src/**/*.ts", + "test/**/*.ts" + ] + }, "lint": { "outputs": [ ""