Skip to content

Commit

Permalink
TurboRepo 2.0 (and a new test case for blocksrenderer) (#785)
Browse files Browse the repository at this point in the history
<!--
Filling out this template is required. Any PR that does not include
enough information to be reviewed may be closed at a maintainers'
discretion. All new code requires documentation and tests to ensure
against regressions.
-->

### Description of the Change
<!--
We must be able to understand the design of your change from this
description. The maintainer reviewing this PR may not have worked with
this code recently, so please provide as much detail as possible.

Where possible, please also include:
- verification steps to ensure your change has the desired effects and
has not introduced any regressions
- any benefits that will be realized
- any alternative implementations or possible drawbacks that you
considered
- screenshots or screencasts
-->

<!-- Enter any applicable Issue number(s) here that will be
closed/resolved by this PR. -->
Closes #

### How to test the Change
<!-- Please provide steps on how to test or validate that the change in
this PR works as described. -->

### Changelog Entry
<!--
Please include a summary for this PR, noting whether this is something
being Added / Changed / Deprecated / Removed / Fixed / or Security
related. You can replace the sample entries after this comment block
with the single changelog entry line for this PR. -->
> Added - New feature
> Changed - Existing functionality
> Deprecated - Soon-to-be removed feature
> Removed - Feature
> Fixed - Bug fix
> Security - Vulnerability


### Credits
<!-- Please list any and all contributors on this PR so that they can be
added to this projects CREDITS.md file. -->
Props @username, @username2, ...


### Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you are unsure about any of these, please ask for
clarification. We are here to help! -->
- [ ] I agree to follow this project's [**Code of
Conduct**](https://github.com/10up/.github/blob/trunk/CODE_OF_CONDUCT.md).
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my change.
- [ ] All new and existing tests pass.
  • Loading branch information
nicholasio authored Jun 10, 2024
2 parents 39548e5 + bd41697 commit 6f288c3
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 93 deletions.
72 changes: 36 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -14,14 +14,13 @@
"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",
"test:watch": "turbo run test:watch",
"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",
Expand All @@ -48,8 +47,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",
Expand All @@ -63,11 +62,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": "[email protected]"
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/react/components/__tests__/BlocksRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,22 @@ describe('BlocksRenderer', () => {
</div>
`);
});

it('works correctly with chinese content', () => {
const StrongToDiv = ({ domNode, children }: BlockProps) => {
const className =
domNode instanceof Element ? domNode?.attribs.class || undefined : undefined;
return <div className={className}>{children}</div>;
};

const { container } = render(
<BlocksRenderer
html={`<h3 class="wp-block-heading" data-wp-block='{"level":3,"hash":"9fb25fc5-7456-4704-bffe-aa438487253b"}' data-wp-block-name="core/heading"><strong>&aelig;&acute;&raquo;&aring;&#139;&#149;&aelig;&#156;&#159;&eacute;&#150;&#147;</strong></h3>`}
>
<StrongToDiv tagName="strong" classList={['my-class']} />
</BlocksRenderer>,
);

expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BlocksRenderer works correctly with chinese content 1`] = `
<div>
<h3
class="wp-block-heading"
data-wp-block="{"level":3,"hash":"9fb25fc5-7456-4704-bffe-aa438487253b"}"
data-wp-block-name="core/heading"
>
<strong>
活動期間
</strong>
</h3>
</div>
`;
7 changes: 0 additions & 7 deletions packages/core/tsconfig.ref.json

This file was deleted.

3 changes: 2 additions & 1 deletion packages/next-redis-cache-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 0 additions & 7 deletions packages/next/tsconfig.ref.json

This file was deleted.

10 changes: 1 addition & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
66 changes: 49 additions & 17 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
{
"$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": {
"dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build"],
"outputs": [
""
],
"inputs": [
"src/**/*.tsx",
"src/**/*.ts",
"test/**/*.ts"
]
},
"test:watch": {
"persistent": true,
"dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build"],
"outputs": [
""
],
"inputs": [
"src/**/*.tsx",
"src/**/*.ts",
"test/**/*.ts"
]
},
"lint": {
"outputs": [
""
]
},
"dev": {
"cache": false,
"persistent": true,
"dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build", "//#wp-env", "@10up/next-redis-cache-provider#build"]
},
"//#wp-env": {
"cache": false
}
}
}
}

0 comments on commit 6f288c3

Please sign in to comment.