Skip to content

Commit 308bdf0

Browse files
committed
feat: add platform template
1 parent 2d76ade commit 308bdf0

205 files changed

Lines changed: 4468 additions & 1857 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
"sourceTag": "scope:ui",
3030
"onlyDependOnLibsWithTags": ["scope:shared", "scope:icons", "scope:ui"]
3131
},
32+
{
33+
"sourceTag": "scope:platform",
34+
"onlyDependOnLibsWithTags": ["scope:shared", "scope:icons", "scope:ui", "scope:platform"]
35+
},
3236
{
3337
"sourceTag": "scope:site",
3438
"onlyDependOnLibsWithTags": ["scope:shared", "scope:icons", "scope:ui", "scope:site"]

package.json

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,67 @@
66
"homepage": "https://github.com/DevCloudFE/react-devui",
77
"license": "MIT",
88
"scripts": {
9-
"build:affected": "nx affected --target=build --parallel=5",
9+
"build:affected": "nx affected --target=build --parallel=7",
1010
"build:icons": "ts-node -P ./tools/tsconfig.json ./tools/ui-icons.ts",
1111
"build:vscode-extension": "nx build vscode-extension && cd dist/packages/vscode-extension && yarn install && vsce package --yarn",
12-
"lint:affected": "nx affected --target=lint --parallel=5",
12+
"lint:affected": "nx affected --target=lint --parallel=7",
1313
"lint:style": "stylelint **/*.{css,scss,html,md}",
1414
"lint:style:fix": "yarn lint:style --fix",
1515
"prepare": "husky install && chmod ug+x .husky/*",
16-
"prepublishOnly": "nx run-many --target=build --parallel=5 --exclude=site,vscode-extension",
16+
"prepublishOnly": "yarn util:update-dependencies && nx run-many --target=build --parallel=7 --exclude=site,vscode-extension",
1717
"publish:vscode-extension": "yarn build:vscode-extension && cd dist/packages/vscode-extension && vsce publish --yarn",
1818
"serve:site": "nx serve site",
19-
"test:affected": "nx affected --target=test --parallel=5",
19+
"test:affected": "nx affected --target=test --parallel=7",
2020
"util:check-update": "yarn upgrade-interactive --latest",
21-
"util:sort-package-json": "npx sort-package-json 'package.json' 'packages/*/package.json'",
22-
"version": "npx prettier lerna.json --write"
21+
"util:sort-package-json": "sort-package-json 'package.json' 'packages/*/package.json'",
22+
"util:update-dependencies": "ts-node -P ./tools/tsconfig.json ./tools/update-dependencies.ts",
23+
"version": "prettier lerna.json --write"
2324
},
2425
"devDependencies": {
2526
"@ant-design/icons-svg": "^4.2.1",
26-
"@commitlint/cli": "^17.0.3",
27-
"@commitlint/config-conventional": "^17.0.3",
28-
"@nrwl/cli": "14.5.6",
29-
"@nrwl/cypress": "14.5.6",
30-
"@nrwl/eslint-plugin-nx": "14.5.6",
31-
"@nrwl/jest": "14.5.6",
32-
"@nrwl/linter": "14.5.6",
33-
"@nrwl/nx-cloud": "14.3.0",
34-
"@nrwl/react": "14.5.6",
35-
"@nrwl/tao": "14.5.6",
36-
"@nrwl/web": "14.5.6",
37-
"@nrwl/workspace": "14.5.6",
27+
"@commitlint/cli": "^17.1.2",
28+
"@commitlint/config-conventional": "^17.1.0",
29+
"@nrwl/cli": "14.6.5",
30+
"@nrwl/eslint-plugin-nx": "14.6.5",
31+
"@nrwl/jest": "14.6.5",
32+
"@nrwl/linter": "14.6.5",
33+
"@nrwl/nx-cloud": "14.6.2",
34+
"@nrwl/react": "14.6.5",
35+
"@nrwl/tao": "14.6.5",
36+
"@nrwl/web": "14.6.5",
37+
"@nrwl/workspace": "14.6.5",
3838
"@stackblitz/sdk": "^1.8.0",
3939
"@testing-library/jest-dom": "^5.16.5",
40-
"@testing-library/react": "^13.3.0",
40+
"@testing-library/react": "^13.4.0",
4141
"@types/fs-extra": "^9.0.13",
42-
"@types/glob": "^7.2.0",
42+
"@types/glob": "^8.0.0",
4343
"@types/jest": "^27.4.1",
4444
"@types/lodash": "^4.14.182",
45-
"@types/marked": "^4.0.3",
45+
"@types/marked": "^4.0.7",
4646
"@types/mocha": "^9.1.1",
47-
"@types/node": "^18.7.3",
48-
"@types/react": "^18.0.17",
47+
"@types/node": "^18.7.16",
48+
"@types/react": "^18.0.18",
4949
"@types/react-dom": "^18.0.6",
50-
"@types/vscode": "^1.70.0",
50+
"@types/vscode": "^1.71.0",
5151
"@types/yaml-front-matter": "^4.1.0",
52-
"@typescript-eslint/eslint-plugin": "^5.33.0",
53-
"@typescript-eslint/parser": "^5.33.0",
52+
"@typescript-eslint/eslint-plugin": "^5.36.2",
53+
"@typescript-eslint/parser": "^5.36.2",
5454
"@vscode/test-electron": "^2.1.5",
5555
"axios": "^0.27.2",
5656
"axios-mock-adapter": "^1.21.2",
5757
"babel-jest": "^27.5.1",
5858
"codesandbox": "^2.2.3",
59-
"core-js": "^3.24.1",
60-
"cypress": "^10.2.0",
59+
"colors": "^1.4.0",
60+
"core-js": "^3.25.1",
6161
"dayjs": "^1.11.5",
62-
"eslint": "^8.22.0",
62+
"eslint": "^8.23.0",
6363
"eslint-config-prettier": "^8.5.0",
64-
"eslint-plugin-cypress": "^2.10.3",
6564
"eslint-plugin-import": "^2.26.0",
6665
"eslint-plugin-jsdoc": "^39.3.6",
6766
"eslint-plugin-jsx-a11y": "^6.6.1",
6867
"eslint-plugin-markdown": "^3.0.0",
6968
"eslint-plugin-prettier": "^4.2.1",
70-
"eslint-plugin-react": "^7.30.1",
69+
"eslint-plugin-react": "^7.31.8",
7170
"eslint-plugin-react-hooks": "^4.6.0",
7271
"eslint-plugin-tsdoc": "^0.2.16",
7372
"fs-extra": "^10.1.0",
@@ -76,36 +75,39 @@
7675
"husky": "^8.0.1",
7776
"i18next": "^21.9.0",
7877
"immer": "^9.0.15",
78+
"is-builtin-module": "^3.2.0",
7979
"jest": "^27.5.1",
80-
"lerna": "^5.4.2",
80+
"lerna": "^5.5.0",
8181
"lodash": "^4.17.21",
82-
"marked": "^4.0.18",
82+
"marked": "^4.1.0",
8383
"mocha": "^10.0.0",
84-
"nx": "14.5.6",
84+
"nx": "14.6.5",
8585
"postcss-html": "^1.5.0",
8686
"postcss-markdown": "^1.2.0",
8787
"prettier": "^2.7.1",
8888
"react": "^18.2.0",
8989
"react-dom": "^18.2.0",
90-
"react-i18next": "^11.18.3",
90+
"react-i18next": "^11.18.5",
9191
"react-router-dom": "^6.3.0",
9292
"react-test-renderer": "^18.2.0",
9393
"regenerator-runtime": "^0.13.9",
9494
"rfs": "^9.0.6",
9595
"rxjs": "^7.5.6",
9696
"rxjs-for-await": "^1.0.0",
97-
"sass": "^1.54.4",
97+
"sass": "^1.54.9",
98+
"sort-package-json": "^1.57.0",
9899
"stylelint": "^14.10.0",
99100
"stylelint-config-prettier": "^9.0.3",
100101
"stylelint-config-recess-order": "^3.0.0",
101102
"stylelint-config-recommended-scss": "^7.0.0",
102-
"stylelint-config-standard": "^27.0.0",
103+
"stylelint-config-standard": "^28.0.0",
103104
"stylelint-scss": "^4.3.0",
104105
"swiper": "^8.3.2",
106+
"table": "^6.8.0",
105107
"ts-jest": "^27.1.4",
106108
"ts-node": "^10.9.1",
107109
"tslib": "^2.4.0",
108-
"typescript": "~4.7.4",
110+
"typescript": "~4.8.3",
109111
"yaml-front-matter": "^4.1.1"
110112
},
111113
"engines": {

packages/hooks/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { createGlobalState } from './createGlobalState';
22
export { useAsync } from './useAsync';
3+
export { useBreakpoints } from './useBreakpoints';
34
export { useEvent } from './useEvent';
45
export { useEventCallback } from './useEventCallback';
56
export { useElement } from './useElement';
@@ -9,7 +10,6 @@ export { useForceUpdate } from './useForceUpdate';
910
export { useForkRef } from './useForkRef';
1011
export { useImmer } from './useImmer';
1112
export { useLockScroll } from './useLockScroll';
12-
export { useMediaMatch } from './useMediaMatch';
1313
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
1414
export { useLocalStorage } from './useLocalStorage';
1515
export { useMount } from './useMount';
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ import { isSimpleArrayEqual } from '@react-devui/utils';
55
import { useEvent } from './useEvent';
66
import { useForceUpdate } from './useForceUpdate';
77

8-
function getMediaMatch<P>(breakpoints: Map<P, number>) {
9-
const mediaMatch: P[] = [];
8+
function matchBreakpoints<P>(breakpoints: Map<P, number>) {
9+
const match: P[] = [];
1010
for (const [breakpoint, num] of Array.from(breakpoints).sort((a, b) => a[1] - b[1])) {
1111
if (window.matchMedia(`(min-width: ${num}px)`).matches) {
12-
mediaMatch.push(breakpoint);
12+
match.push(breakpoint);
1313
}
1414
}
15-
return mediaMatch;
15+
return match;
1616
}
1717

18-
export function useMediaMatch<P>(breakpoints: Map<P, number>) {
19-
const mediaMatch = useRef<P[]>([]);
18+
export function useBreakpoints<P>(breakpoints: Map<P, number>) {
19+
const match = useRef<P[]>([]);
2020
if (typeof window !== 'undefined') {
21-
mediaMatch.current = getMediaMatch(breakpoints);
21+
match.current = matchBreakpoints(breakpoints);
2222
}
2323

2424
const forceUpdate = useForceUpdate();
2525

2626
useEvent(window, 'resize', () => {
27-
const currentMediaMatch = getMediaMatch(breakpoints);
28-
if (!isSimpleArrayEqual(currentMediaMatch, mediaMatch.current)) {
27+
const currentMediaMatch = matchBreakpoints(breakpoints);
28+
if (!isSimpleArrayEqual(currentMediaMatch, match.current)) {
2929
forceUpdate();
3030
}
3131
});
3232

33-
return mediaMatch.current;
33+
return match.current;
3434
}

packages/icons/src/useIconProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useContext } from 'react';
33

44
import { DIconContext } from './Icon';
55

6-
export function useIconProps<T>(props: T): T {
6+
export function useIconProps<T extends object>(props: T): T {
77
const context = useContext(DIconContext);
88
const gProps = context.props ?? {};
99
const noUndefinedProps: any = {};

packages/platform/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@nrwl/react/babel",
5+
{
6+
"runtime": "automatic"
7+
}
8+
]
9+
],
10+
"plugins": []
11+
}

packages/platform/.browserslistrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by:
2+
# 1. autoprefixer to adjust CSS to support the below specified browsers
3+
# 2. babel preset-env to adjust included polyfills
4+
#
5+
# For additional information regarding the format and rule options, please see:
6+
# https://github.com/browserslist/browserslist#queries
7+
#
8+
# If you need to support different browsers in production, you may tweak the list below.
9+
10+
last 1 Chrome version
11+
last 1 Firefox version
12+
last 2 Edge major versions
13+
last 2 Safari major version
14+
last 2 iOS major versions
15+
Firefox ESR
16+
not IE 9-11 # For IE 9-11 support, remove 'not'.

packages/platform/.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

packages/platform/jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
displayName: 'platform',
3+
preset: '../../jest.preset.js',
4+
transform: {
5+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
6+
'^.+\\.[tj]sx?$': 'babel-jest',
7+
},
8+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
9+
coverageDirectory: '../../coverage/packages/platform',
10+
};

packages/platform/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "platform",
3+
"version": "0.0.1",
4+
"private": true,
5+
"description": "An out-of-box solution for enterprise applications as a React boilerplate",
6+
"keywords": [
7+
"react",
8+
"devui",
9+
"platform"
10+
],
11+
"homepage": "https://github.com/DevCloudFE/react-devui/tree/main/packages/platform#readme",
12+
"bugs": {
13+
"url": "https://github.com/DevCloudFE/react-devui/issues"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/DevCloudFE/react-devui.git"
18+
},
19+
"license": "MIT",
20+
"author": "Xie Jay <xiejay97@gmail.com>",
21+
"dependencies": {
22+
"@react-devui/hooks": "file:../hooks",
23+
"@react-devui/icons": "file:../icons",
24+
"@react-devui/ui": "file:../ui",
25+
"@react-devui/utils": "file:../utils",
26+
"axios": "^0.27.2",
27+
"axios-mock-adapter": "^1.21.2",
28+
"core-js": "^3.25.1",
29+
"i18next": "^21.9.0",
30+
"lodash": "^4.17.21",
31+
"react": "^18.2.0",
32+
"react-dom": "^18.2.0",
33+
"react-i18next": "^11.18.5",
34+
"react-router-dom": "^6.3.0",
35+
"regenerator-runtime": "^0.13.9",
36+
"rxjs": "^7.5.6"
37+
}
38+
}

0 commit comments

Comments
 (0)