Skip to content

Commit

Permalink
Move to npm workspaces (#24)
Browse files Browse the repository at this point in the history
* Move to npm workspaces

* Bump to latest

* Update path

* Add entry

* Use 0.0.0-0

* Fix bump config path

* React 18.2.0

* Fix @babel/runtime-corejs3 path

* Update caret version
  • Loading branch information
compulim authored Sep 10, 2023
1 parent 97b956b commit e8e2a90
Show file tree
Hide file tree
Showing 13 changed files with 9,429 additions and 19,416 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins:
- react
settings:
react:
version: 17.0.2
version: 18.2.0
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added type-checking for test, by [@compulim](https://github.com/compulim), in PR [#20](https://github.com/compulim/react-chain-of-responsibility/pull/20)
- Updates `tsconfig.json` to extend from [`@tsconfig/strictest`](https://npmjs.com/package/@tsconfig/strictest), by [@compulim](https://github.com/compulim), in PR [#20](https://github.com/compulim/react-chain-of-responsibility/pull/20)
- Bump dependencies, by [@compulim](https://github.com/compulim), in PR [#24](https://github.com/compulim/react-chain-of-responsibility/pull/24)
- Development dependencies
- [`@testing-library/[email protected]`](https://npmjs.com/package/@testing-library/react)
- [`@types/[email protected]`](https://npmjs.com/package/@types/react)
- [`[email protected]`](https://npmjs.com/package/react-dom)
- [`[email protected]`](https://npmjs.com/package/react-test-renderer)
- [`[email protected]`](https://npmjs.com/package/react)

### Fixed

Expand Down
13,159 changes: 9,370 additions & 3,789 deletions package-lock.json

Large diffs are not rendered by default.

31 changes: 13 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,23 @@
"private": true,
"author": "William Wong (https://github.com/compulim)",
"license": "MIT",
"workspaces": [
"packages/react-chain-of-responsibility",
"packages/pages",
"packages/integration-test"
],
"scripts": {
"build": "cd packages/react-chain-of-responsibility && npm run build",
"build": "npm run build --if-present --workspaces",
"bump": "npm run bump:prod && npm run bump:dev && npm run bump:auditfix && npm run bump:packages && npm run bump:eslintrc",
"bump:auditfix": "npm audit fix || exit 0",
"bump:dev": "if [ `cat package.json | jq -r '(.devDependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.devDependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"bump:eslintrc": "if [ -f packages/react-chain-of-responsibility/node_modules/react/package.json ]; then REACT_VERSION=`cat packages/react-chain-of-responsibility/node_modules/react/package.json | jq -r '.version'` sh -c 'cat .eslintrc.yml | docker run -i --rm mikefarah/yq \".settings.react.version = \\\"$REACT_VERSION\\\"\" > .eslintrc.yml.tmp && mv .eslintrc.yml.tmp .eslintrc.yml'; fi",
"bump:packages": "npm run bump:packages:main && npm run bump:packages:pages && npm run bump:packages:integration",
"bump:packages:integration": "cd packages/integration-test && npm run bump || true",
"bump:packages:main": "cd packages/react-chain-of-responsibility && npm run bump",
"bump:packages:pages": "cd packages/pages && npm run bump",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install --save-exact $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"postscaffold": "npm run postscaffold:eslint:react && npm run postscaffold:package",
"postscaffold:eslint:react": "if [ -f packages/react-chain-of-responsibility/node_modules/react/package.json ]; then docker run -e VERSION=$(cat packages/react-chain-of-responsibility/node_modules/react/package.json | jq -r '.version') -i --rm mikefarah/yq '.settings.react.version = strenv(VERSION)' < ./.eslintrc.react.yml | tee /tmp/output.tmp && mv /tmp/output.tmp ./.eslintrc.react.yml; fi",
"postscaffold:package": "cd packages/react-chain-of-responsibility && npm run postscaffold",
"precommit": "npm run precommit:main && npm run precommit:pages && npm run precommit:integration",
"precommit:integration": "cd packages/integration-test && npm run precommit || true",
"precommit:main": "cd packages/react-chain-of-responsibility && npm run precommit",
"precommit:pages": "cd packages/pages && npm run precommit",
"prepare": "cd packages/react-chain-of-responsibility && npm clean-install",
"test": "npm run test:unit && npm run test:integration",
"test:integration": "cd packages/integration-test && npm install && npm test",
"test:unit": "cd packages/react-chain-of-responsibility && npm test"
"bump:eslintrc": "if [ -f node_modules/react/package.json ]; then docker run -e VERSION=$(cat node_modules/react/package.json | jq -r '.version') -i --rm mikefarah/yq '.settings.react.version = strenv(VERSION)' < ./.eslintrc.react.yml | tee /tmp/output.tmp && mv /tmp/output.tmp ./.eslintrc.react.yml; fi",
"bump:packages": "npm run bump --if-present --workspaces",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"postscaffold": "npm run postscaffold:eslint:react && npm run postscaffold --if-present --workspaces",
"postscaffold:eslint:react": "npm run bump:eslintrc",
"precommit": "npm run precommit --if-present --workspaces",
"test": "npm run test --if-present --workspaces"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.6.0",
Expand Down
29 changes: 5 additions & 24 deletions packages/integration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,25 @@
"bump": "npm run bump:prod && npm run bump:dev && npm run bump:auditfix",
"bump:auditfix": "npm audit fix || exit 0",
"bump:dev": "if [ `cat package.json | jq -r '(.devDependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.devDependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install --save-exact $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"postbump": "cat package.json | jq '. + (.dependencies = (((.dependencies // {}) + (.localPeerDependencies // {})) | to_entries | sort_by(.key) | from_entries)) | (.devDependencies = (((.devDependencies // {}) + (.localPeerDevDependencies // {})) | to_entries | sort_by(.key) | from_entries))' > package-temp.json && mv package-temp.json package.json",
"prebump": "cat package.json | jq '(((.localPeerDependencies // {}) | keys | map([\"dependencies\", .])) + ((.localPeerDevDependencies // {}) | keys | map([\"devDependencies\", .]))) as $localPeerPaths | delpaths($localPeerPaths)' > package-temp.json && mv package-temp.json package.json",
"precommit": "eslint --ext .js,.cjs,.mjs ./",
"prepare": "npm install ../react-chain-of-responsibility/react-chain-of-responsibility-0.0.0-0.tgz",
"test": "jest"
},
"author": "William Wong (https://github.com/compulim)",
"license": "MIT",
"pinDependencies": {
"@types/react": [
"17",
"@testing-library/[email protected] does not support react@>=18"
],
"react": [
"17",
"@testing-library/[email protected] does not support react@>=18"
],
"react-test-renderer": [
"17",
"@testing-library/[email protected] does not support react@>=18"
]
},
"devDependencies": {
"@babel/core": "^7.22.17",
"@babel/preset-env": "^7.22.15",
"@testing-library/react-hooks": "^8.0.1",
"@types/react": "^17.0.65",
"@types/react": "^18.2.21",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"react": "^17.0.2",
"react-test-renderer": "^17.0.2",
"react": "^18.2.0",
"react-test-renderer": "^18.2.0",
"typescript": "^5.2.2"
},
"localPeerDependencies": {
"react-chain-of-responsibility": "file:../react-chain-of-responsibility/react-chain-of-responsibility-0.0.0-0.tgz"
},
"dependencies": {
"react-chain-of-responsibility": "file:../react-chain-of-responsibility/react-chain-of-responsibility-0.0.0-0.tgz"
"react-chain-of-responsibility": "^0.0.0-0"
}
}
11 changes: 4 additions & 7 deletions packages/pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"bump": "npm run bump:prod && npm run bump:dev && npm run bump:auditfix",
"bump:auditfix": "npm audit fix || exit 0",
"bump:dev": "if [ `cat package.json | jq -r '(.devDependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.devDependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install --save-exact $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
"postbump": "cat package.json | jq '. + (.dependencies = (((.dependencies // {}) + (.localPeerDependencies // {})) | to_entries | sort_by(.key) | from_entries)) | (.devDependencies = (((.devDependencies // {}) + (.localPeerDevDependencies // {})) | to_entries | sort_by(.key) | from_entries))' > package-temp.json && mv package-temp.json package.json",
"prebump": "cat package.json | jq '(((.localPeerDependencies // {}) | keys | map([\"dependencies\", .])) + ((.localPeerDevDependencies // {}) | keys | map([\"devDependencies\", .]))) as $localPeerPaths | delpaths($localPeerPaths)' > package-temp.json && mv package-temp.json package.json",
"precommit": "npm run precommit:typescript",
Expand All @@ -27,11 +27,8 @@
"typescript": "^5.2.2"
},
"dependencies": {
"react": "18.2.0",
"react-chain-of-responsibility": "file:../react-chain-of-responsibility/react-chain-of-responsibility-0.0.0-0.tgz",
"react-dom": "18.2.0"
},
"localPeerDependencies": {
"react-chain-of-responsibility": "file:../react-chain-of-responsibility/react-chain-of-responsibility-0.0.0-0.tgz"
"react": "^18.2.0",
"react-chain-of-responsibility": "^0.0.0-0",
"react-dom": "^18.2.0"
}
}
6 changes: 5 additions & 1 deletion packages/pages/src/app/decoration/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const middleware: (typeof types.middleware)[] = [
const Next = next(request);

if (request?.has('bold')) {
return props => <Bold>{Next && <Next {...props} />}</Bold>;
const Bolded = (props: Props) => <Bold>{Next && <Next {...props} />}</Bold>;

Bolded.displayName = 'Bolded';

return Bolded;
}

return Next;
Expand Down
4 changes: 2 additions & 2 deletions packages/pages/src/app/fluentButton/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const Orange = () => <Fragment>🍊</Fragment>;
// Constructs an array of middleware to handle the request and return corresponding subcomponents.
// Fallback to `defaultRender` of `IRenderFunction` is handled by the hook.
const middleware: (typeof types.middleware)[] = [
() => next => props => props?.iconProps?.iconName === 'Banana' ? Banana : next(props),
() => next => props => props?.iconProps?.iconName === 'Orange' ? Orange : next(props)
() => next => props => (props?.iconProps?.iconName === 'Banana' ? Banana : next(props)),
() => next => props => (props?.iconProps?.iconName === 'Orange' ? Orange : next(props))
];

const Inner = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import { Proxy } from './private/chainOfResponsibility';

import type { Props } from './private/types';

const Link = (props: Props) => {
const { children, ...passingProps } = props;

return (
<Proxy {...passingProps} request={passingProps.href}>
{children}
</Proxy>
);
};
const Link = ({ children, ...passingProps }: Props) => (
<Proxy {...passingProps} request={passingProps.href}>
{children}
</Proxy>
);

export default Link;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import type { PropsWithChildren } from 'react';

const middleware: (typeof types.middleware)[] = [
// If it does not have "href", treat it as plain text.
() => next => href => !href ? PlainText : next(href),
() => next => href => (!href ? PlainText : next(href)),

// If it is an internal link, whitelisted domain, or empty string, then treat it as internal link.
internalHosts => next => href => !href || isInternalLink(href, internalHosts) ? InternalLink : next(href),
internalHosts => next => href => (!href || isInternalLink(href, internalHosts) ? InternalLink : next(href)),

// Otherwise, treat it as external link:
// - Add rel="noopener noreferrer"
Expand Down
Loading

0 comments on commit e8e2a90

Please sign in to comment.