Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit eab4e48

Browse files
authored
refactor: try next 13 & refactor (#1386)
* chore: upgrade & rm no react-18 compatiable pkgs * chore: provoider wip * chore: rm providers from pages * chore: type for buildlog * chore: type for buildlog
1 parent ae0ee52 commit eab4e48

Some content is hidden

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

77 files changed

+18816
-14842
lines changed

.env

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// .env
1+
# .env
22
SERVE_PORT=3000
3-
// google analysis
3+
# google analysis
44
NEXT_PUBLIC_GA_TRACING_ID=UA-39874160-3
5-
// github
5+
# github
66
NEXT_PUBLIC_GITHUB_CLIENT_ID=3b4281c5e54ffd801f85
77

.jest.setup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
22
import { configure } from 'enzyme'
3-
import Adapter from 'enzyme-adapter-react-16'
3+
import Adapter from '@cfaester/enzyme-adapter-react-18'
44

55
configure({ adapter: new Adapter() })

config/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const APP_VERSION = '1.0.13'
1+
export const APP_VERSION = "1.0.13"

next.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const nextConfig = {
1919
exclude: ['error'],
2020
},
2121
},
22+
// experimental: { appDir: true },
23+
2224
// pwa: {
2325
// dest: 'public',
2426
// disable: process.env.NODE_ENV !== 'production',

package-lock.json

+18,287-13,873
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+20-26
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.13",
44
"license": "Apache License 2.0",
55
"scripts": {
6-
"dev": "cross-env NODE_ENV=dev next dev",
7-
"dev.boost": "next-boost",
6+
"dev": "next dev",
7+
"dev2": "next dev --turbo",
88
"ci": "cross-env NODE_ENV=ci node server",
99
"update.version": "node -p \"'export const APP_VERSION = ' + JSON.stringify(require('./package.json').version)\" > config/version.ts",
1010
"build": "next build",
@@ -16,7 +16,6 @@
1616
"serve": "cross-env NODE_ENV=production next start -p ${SERVE_PORT}",
1717
"serve.dev": "cross-env NODE_ENV=dev next start -p ${SERVE_PORT}",
1818
"serve.prod.server": "cross-env NODE_ENV=production SERVE_PORT=${SERVE_PORT} node server",
19-
"serve.prod.boost": "cross-env NODE_ENV=production next-boost -p ${SERVE_PORT}",
2019
"serve.prod": "cross-env NODE_ENV=production next start -p ${SERVE_PORT}",
2120
"dist": "next build && next export -o \"build\"",
2221
"start": "NODE_ENV=production node server.js",
@@ -42,8 +41,6 @@
4241
},
4342
"dependencies": {
4443
"@groupher/react-editor": "^1.1.30",
45-
"@next-boost/hybrid-disk-cache": "^0.3.0",
46-
"@next-boost/next-boost": "^0.15.1",
4744
"@next/bundle-analyzer": "^12.2.5",
4845
"@sentry/browser": "5.17.0",
4946
"@sentry/node": "5.17.0",
@@ -65,15 +62,14 @@
6562
"glob": "^7.1.2",
6663
"graphql": "^15.5.1",
6764
"graphql-request": "3.5.0",
68-
"graphql-voyager": "^1.0.0-rc.31",
6965
"izitoast": "^1.4.0",
7066
"mastani-codehighlight": "0.0.7",
7167
"mobx": "^6.6.2",
7268
"mobx-react": "^7.5.3",
7369
"mobx-state-tree": "^5.1.6",
7470
"module-alias": "^2.0.1",
7571
"nanoid": "^3.1.12",
76-
"next": "^12.2.5",
72+
"next": "^13.0.0",
7773
"next-compose-plugins": "^2.2.0",
7874
"next-i18next": "4.4.1",
7975
"next-pwa": "^5.4.4",
@@ -85,31 +81,29 @@
8581
"promise-timeout": "^1.3.0",
8682
"prop-types": "^15.5.10",
8783
"pubsub-js": "^1.9.3",
88-
"qrcode.react": "^1.0.1",
84+
"qrcode.react": "^3.1.0",
8985
"ramda": "0.26.1",
9086
"react": "^18.2.0",
91-
"react-animation": "^1.2.2",
92-
"react-calendar-heatmap": "1.8.1",
93-
"react-content-loader": "3.4.2",
87+
"@groupher/react-animation": "^1.2.3",
88+
"react-calendar-heatmap": "1.9.0",
89+
"react-content-loader": "6.2.0",
9490
"react-copy-to-clipboard": "^5.0.3",
9591
"react-device-detect": "^2.1.2",
9692
"react-dom": "^18.2.0",
97-
"react-highlight-words": "^0.16.0",
98-
"react-lazy-load-image-component": "1.5.0",
99-
"react-masonry-component": "^6.0.1",
93+
"react-highlight-words": "^0.18.0",
94+
"react-lazy-load-image-component": "1.5.5",
10095
"react-masonry-css": "^1.0.14",
101-
"react-pin-field": "1.0.6",
102-
"react-resize-detector": "4.2.3",
103-
"react-select": "^3.1.0",
104-
"react-sortable-hoc": "1.7.1",
105-
"react-svg": "11.1.2",
106-
"react-swipeable": "^5.5.1",
96+
"react-pin-field": "3.0.16",
97+
"react-resize-detector": "7.1.2",
98+
"react-select": "^5.5.7",
99+
"react-svg": "15.1.10",
100+
"react-swipeable": "^7.0.0",
107101
"react-textarea-autosize": "^8.3.0",
108102
"react-tooltip": "^4.2.21",
109103
"react-trend": "^1.2.4",
110-
"react-use": "15.1.1",
111-
"react-useportal": "^1.0.13",
112-
"react-waypoint": "9.0.2",
104+
"react-use": "17.4.0",
105+
"react-portal": "^4.2.2",
106+
"react-waypoint": "^10.3.0",
113107
"remarkable": "2.0.0",
114108
"remarkable-emoji": "^0.1.3",
115109
"remarkable-mentions": "^0.1.0",
@@ -145,17 +139,17 @@
145139
"cypress": "^8.1.0",
146140
"cz-conventional-changelog": "^3.0.0",
147141
"enzyme": "3.11.0",
148-
"enzyme-adapter-react-16": "1.15.2",
142+
"@cfaester/enzyme-adapter-react-18": "0.5.1",
149143
"enzyme-to-json": "^3.3.4",
150144
"eslint": "^8.23.0",
151-
"eslint-config-next": "^12.2.5",
145+
"eslint-config-next": "^13.0.0",
152146
"husky": "^3.0.0",
153147
"jest": "26.2.2",
154148
"npm-run-all": "^4.1.1",
155149
"plop": "2.7.4",
156150
"prettier": "2.3.2",
157151
"pretty-quick": "^1.10.0",
158-
"react-test-renderer": "16.10.0",
152+
"react-test-renderer": "18.2.0",
159153
"shelljs": "0.8.4",
160154
"standard-version": "^8.0.1",
161155
"start-server-and-test": "1.12.1",

server/index.js

-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const express = require('express')
1111
const cookieParser = require('cookie-parser')
1212
const responseTime = require('response-time')
1313
const mobxReact = require('mobx-react')
14-
// inspect graphql model
15-
const { express: voyagerMiddleware } = require('graphql-voyager/middleware')
1614
// i18n setup
1715
// const nextI18NextMiddleware = require('next-i18next/middleware').default
1816
// const nextI18next = require('../i18n')
@@ -42,10 +40,6 @@ mobxReact.enableStaticRendering(true)
4240
// redirect all the www request to non-www addr
4341
server.use(redirectToNakedUrl)
4442
server.use(express.static('public'))
45-
server.use(
46-
'/model-graphs',
47-
voyagerMiddleware({ endpointUrl: CONFIG.GRAPHQL_ENDPOINT }),
48-
)
4943

5044
// await nextI18next.initPromise
5145
// server.use(nextI18NextMiddleware(nextI18next))

src/containers/content/ExploreContent/SloganText.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Fragment, memo, useEffect, useState } from 'react'
2-
import { AnimateOnChange } from 'react-animation'
2+
import { AnimateOnChange } from '@groupher/react-animation'
33

44
import { SloganTextWrapper } from './styles/banner'
55

src/containers/content/FriendsContent/store.ts

-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ import { types as T, getParent, Instance } from 'mobx-state-tree'
66
// import {} from 'ramda'
77

88
import type { TCommunity, TRootStore } from '@/spec'
9-
import { buildLog } from '@/utils/logger'
109
import { markStates, toJS } from '@/utils/mobx'
1110

12-
/* eslint-disable-next-line */
13-
const log = buildLog('S:FriendsContent')
14-
1511
const FriendsContent = T.model('FriendsContent', {})
1612
.views((self) => ({
1713
get curCommunity(): TCommunity {

src/containers/content/HaveADrinkContent/Body/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { FC, memo } from 'react'
8-
import { AnimateOnChange } from 'react-animation'
8+
import { AnimateOnChange } from '@groupher/react-animation'
99

1010
import type { TView, TDrinkItem, TSettingOption } from '../spec'
1111
import { VIEW } from '../constant'

src/containers/digest/CommunityDigest/SimpleLayout/AccountUnit.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FC, memo } from 'react'
22

3+
import Link from 'next/link'
34
import { EVENT, THREAD } from '@/constant'
45
import { send } from '@/utils/helper'
56

@@ -21,11 +22,14 @@ const AccountUnit: FC = () => {
2122
订阅
2223
</SubscribeButton>
2324

24-
<DashboardIcon
25-
onClick={() =>
26-
send(EVENT.COMMUNITY_THREAD_CHANGE, { data: THREAD.DASHBOARD })
27-
}
28-
/>
25+
<Link href="/home/dashboard">
26+
<DashboardIcon
27+
onClick={() => {
28+
// send(EVENT.COMMUNITY_THREAD_CHANGE, { data: THREAD.DASHBOARD })
29+
}}
30+
/>
31+
</Link>
32+
2933
<NotifyIcon />
3034
<Avatar src={`${mockUsers(1)[0].avatar}`} />
3135
</Wrapper>

src/containers/digest/CommunityDigest/SimpleLayout/ThreadTab.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FC, memo } from 'react'
2+
import { useRouter } from 'next/router'
23

34
import type { TCommunityThread, TThread } from '@/spec'
45
import { Wrapper, Title } from '../styles/simple_layout/thread_tab'
@@ -10,13 +11,18 @@ type TProps = {
1011
}
1112

1213
const ThreadTab: FC<TProps> = ({ active, threads, onChange }) => {
14+
const router = useRouter()
15+
1316
return (
1417
<Wrapper>
1518
{threads.map((item) => (
1619
<Title
1720
key={item.raw}
1821
$active={active === item.raw}
19-
onClick={() => onChange(item.raw)}
22+
onClick={() => {
23+
// onChange(item.raw)
24+
router.push(`/home/${item.raw}`)
25+
}}
2026
>
2127
{item.title}
2228
</Title>

src/containers/layout/ThemePalette/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const ThemeContainer: FC<TProps> = ({ children, theme: { themeData } }) => {
4444

4545
<ScrollBarStyle />
4646
{/* @ts-ignore */}
47-
<NextNprogress
47+
{/* <NextNprogress
4848
color={themeData.logoText}
4949
startPosition={0.3}
5050
stopDelayMs={200}
@@ -54,7 +54,7 @@ const ThemeContainer: FC<TProps> = ({ children, theme: { themeData } }) => {
5454
parent: `#${ANCHOR.GLOBAL_HEADER_ID}`,
5555
}}
5656
showOnShallow
57-
/>
57+
/> */}
5858
<Fragment>{children}</Fragment>
5959
{/* @ts-ignore */}
6060
<CodeSyxHighlight />

src/containers/tool/Doraemon/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { Fragment, useEffect } from 'react'
8-
import usePortal from 'react-useportal'
8+
import { Portal } from 'react-portal'
99

1010
import { toggleGlobalBlur } from '@/utils/dom'
1111
import { bond } from '@/utils/mobx'
@@ -22,7 +22,6 @@ import { useInit, hidePanel } from './logic'
2222

2323
const DoraemonContainer = ({ doraemon: store }) => {
2424
useInit(store)
25-
const { Portal } = usePortal()
2625

2726
const {
2827
inputValue,

src/containers/unit/Sidebar/MenuList/index.tsx

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { FC, memo } from 'react'
2-
import dynamic from 'next/dynamic'
2+
// import dynamic from 'next/dynamic'
33
import { reject, propEq } from 'ramda'
44

55
import type { TCommunity } from '@/spec'
66
import { HCN } from '@/constant'
77
import NormalMenuList from './NormalMenuList'
88

99
import { Wrapper } from '../styles/menu_list/index'
10-
import { onSortMenuEnd } from '../logic'
10+
// import { onSortMenuEnd } from '../logic'
1111

12-
export const SortableMenuList = dynamic(() => import('./SortableMenuList'), {
13-
/* eslint-disable react/display-name */
14-
loading: () => <div>..</div>,
15-
})
12+
// export const SortableMenuList = dynamic(() => import('./SortableMenuList'), {
13+
// /* eslint-disable react/display-name */
14+
// loading: () => <div>..</div>,
15+
// })
1616

1717
type TProps = {
1818
items: TCommunity[]
@@ -34,14 +34,15 @@ const MenuList: FC<TProps> = ({ items, pin, sortOptActive, activeRaw }) => {
3434
/>
3535
) : (
3636
// @ts-ignore
37-
<SortableMenuList
38-
communities={sortableCommunities}
39-
sortOptActive={sortOptActive}
40-
distance={5}
41-
pin={pin}
42-
activeRaw={activeRaw}
43-
onSortEnd={onSortMenuEnd}
44-
/>
37+
<div>SortableMenuList</div>
38+
// <SortableMenuList
39+
// communities={sortableCommunities}
40+
// sortOptActive={sortOptActive}
41+
// distance={5}
42+
// pin={pin}
43+
// activeRaw={activeRaw}
44+
// onSortEnd={onSortMenuEnd}
45+
// />
4546
)}
4647
</Wrapper>
4748
)

src/containers/unit/Sidebar/logic.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { arrayMove } from 'react-sortable-hoc'
2+
// import { arrayMove } from 'react-sortable-hoc'
33
import { addIndex, map, reject, propEq, contains } from 'ramda'
44

55
import type { TCommunity } from '@/spec'
@@ -60,11 +60,11 @@ export const sortBtnOnClick = (): void => {
6060
const mapIndexed = addIndex(map)
6161

6262
export type TSortDone = { oldIndex: number; newIndex: number }
63-
export const onSortMenuEnd = ({ oldIndex, newIndex }: TSortDone): void => {
64-
const sortedCommunities = arrayMove(store.communitiesData, oldIndex, newIndex)
65-
setC11N(sortedCommunities)
66-
store.onSortCommunities(sortedCommunities)
67-
}
63+
// export const onSortMenuEnd = ({ oldIndex, newIndex }: TSortDone): void => {
64+
// const sortedCommunities = arrayMove(store.communitiesData, oldIndex, newIndex)
65+
// setC11N(sortedCommunities)
66+
// store.onSortCommunities(sortedCommunities)
67+
// }
6868

6969
const setC11N = (sortedCommunities): void => {
7070
if (!store.isLogin) return store.authWarning()

0 commit comments

Comments
 (0)