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

Commit 625f325

Browse files
committed
chore: merge branch 'restructure' into dev
2 parents 5587bb8 + a85bb60 commit 625f325

File tree

1,217 files changed

+188
-102
lines changed

Some content is hidden

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

1,217 files changed

+188
-102
lines changed

.babelrc

+10-9
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,19 @@
5353
{
5454
"root": ["./"],
5555
"alias": {
56-
"@containers": "./containers",
57-
"@components": "./components",
58-
"@services": "./services",
56+
"@containers": "./src/containers",
57+
"@components": "./src/components",
58+
"@services": "./src/services",
5959
"@constant": "./utils/constant/",
60-
"@hooks": "./components/Hooks",
60+
"@hooks": "./src/hooks",
61+
"@hoc": "./src/hoc",
6162
"@config": "./config",
62-
"@stores": "./stores",
63-
"@model": "./stores/SharedModel",
63+
"@stores": "./src/stores",
64+
"@model": "./src/stores/SharedModel",
6465
"@utils": "./utils",
65-
"@schemas": "./containers/schemas",
66-
"@Img": "./components/Img",
67-
"@SvgIcons": "./components/SvgIcons"
66+
"@schemas": "./src/schemas",
67+
"@Img": "./src/components/Img",
68+
"@SvgIcons": "./src/components/SvgIcons"
6869
}
6970
}
7071
]

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ before_script:
3131
script:
3232
# - codecov
3333
- rm -rf .next
34+
- cp config/config.ci.json config/config.json
3435
- nvm exec 10.12.0 npm run build.ci
3536
- nvm exec 10.12.0 npm run test:ci
3637

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ dep:
2020

2121
# shortcut for serve.local
2222
dev:
23+
cp config/config.local.json config/config.json
2324
npm run local
2425

2526
build:
2627
npm build
2728

2829
build.dev:
30+
cp config/config.dev.json config/config.json
2931
npm run build.dev
3032

3133
build.prod:
34+
cp config/config.prod.json config/config.json
3235
npm run build.prod
3336

3437
serve.help:

config/assets.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const ASSETS_ENDPOINT = 'https://cps-oss.oss-cn-shanghai.aliyuncs.com'
1+
import * as CONFIG from './config.json'
2+
3+
export const { ASSETS_ENDPOINT } = CONFIG
24
// process.env.ALI_OSS_ADDR
35
// export const ASSETS_ENDPOINT = 'https://coderplanets.oss-cn-beijing.aliyuncs.com'
46

config/config.ci.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"// endpoint configs //": "--------------------------------",
3+
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4+
"GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
5+
6+
"// general configs //": "--------------------------------",
7+
"DEFAULT_THEME": "cyan",
8+
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9+
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10+
"PAGE_SIZE": {
11+
"S": 10,
12+
"D": 20,
13+
"M": 30,
14+
"L": 40
15+
},
16+
17+
"// contact configs //": "--------------------------------",
18+
"EMAIL_CLUB": "club@group.coderplanets.com",
19+
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20+
"EMAIL_HELLO": "hello@group.coderplanets.com",
21+
"EMAIL_BUSINESS": "business@group.coderplanets.com"
22+
}

config/config.dev.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"// endpoint configs //": "--------------------------------",
3+
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4+
"GRAPHQL_ENDPOINT": "https://devapi.coderplanets.com/graphiql",
5+
6+
"// general configs //": "--------------------------------",
7+
"DEFAULT_THEME": "cyan",
8+
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9+
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10+
"PAGE_SIZE": {
11+
"S": 10,
12+
"D": 20,
13+
"M": 30,
14+
"L": 40
15+
},
16+
17+
"// contact configs //": "--------------------------------",
18+
"EMAIL_CLUB": "club@group.coderplanets.com",
19+
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20+
"EMAIL_HELLO": "hello@group.coderplanets.com",
21+
"EMAIL_BUSINESS": "business@group.coderplanets.com"
22+
}

config/config.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"// endpoint configs //": "--------------------------------",
3+
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4+
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5+
"//GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
6+
7+
"// general configs //": "--------------------------------",
8+
"DEFAULT_THEME": "cyan",
9+
"SENIOR_AMOUNT_THRESHOLD": 51.2,
10+
"SPONSOR_AMOUNT_THRESHOLD": 3999,
11+
"PAGE_SIZE": {
12+
"S": 10,
13+
"D": 20,
14+
"M": 30,
15+
"L": 40
16+
},
17+
18+
"// contact configs //": "--------------------------------",
19+
"EMAIL_CLUB": "club@group.coderplanets.com",
20+
"EMAIL_SUPPORT": "support@group.coderplanets.com",
21+
"EMAIL_HELLO": "hello@group.coderplanets.com",
22+
"EMAIL_BUSINESS": "business@group.coderplanets.com"
23+
}

config/config.local.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"// endpoint configs //": "--------------------------------",
3+
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4+
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5+
"//GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
6+
7+
"// general configs //": "--------------------------------",
8+
"DEFAULT_THEME": "cyan",
9+
"SENIOR_AMOUNT_THRESHOLD": 51.2,
10+
"SPONSOR_AMOUNT_THRESHOLD": 3999,
11+
"PAGE_SIZE": {
12+
"S": 10,
13+
"D": 20,
14+
"M": 30,
15+
"L": 40
16+
},
17+
18+
"// contact configs //": "--------------------------------",
19+
"EMAIL_CLUB": "club@group.coderplanets.com",
20+
"EMAIL_SUPPORT": "support@group.coderplanets.com",
21+
"EMAIL_HELLO": "hello@group.coderplanets.com",
22+
"EMAIL_BUSINESS": "business@group.coderplanets.com"
23+
}

config/config.prod.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"// endpoint configs //": "--------------------------------",
3+
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4+
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5+
6+
"// general configs //": "--------------------------------",
7+
"DEFAULT_THEME": "cyan",
8+
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9+
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10+
"PAGE_SIZE": {
11+
"S": 10,
12+
"D": 20,
13+
"M": 30,
14+
"L": 40
15+
},
16+
17+
"// contact configs //": "--------------------------------",
18+
"EMAIL_CLUB": "club@group.coderplanets.com",
19+
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20+
"EMAIL_HELLO": "hello@group.coderplanets.com",
21+
"EMAIL_BUSINESS": "business@group.coderplanets.com"
22+
}

config/contacts.js

-4
This file was deleted.

config/endpoint.js

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
/* config for different envs */
22
import { ICON_CMD } from './assets'
3+
import * as CONFIG from './config.json'
34

4-
const getGraphQLEndpoint = () => {
5-
switch (process.env.NODE_ENV) {
6-
case 'production':
7-
return 'https://api.coderplanets.com/graphiql'
8-
9-
case 'dev':
10-
return 'https://devapi.coderplanets.com/graphiql'
11-
12-
case 'ci':
13-
return 'http://localhost:4001/graphiql'
14-
15-
default:
16-
return 'https://api.coderplanets.com/graphiql'
17-
/* return 'http://localhost:4001/graphiql' */
18-
}
19-
}
20-
21-
export const GRAPHQL_ENDPOINT = getGraphQLEndpoint()
5+
export const { GRAPHQL_ENDPOINT } = CONFIG // getGraphQLEndpoint()
226

237
export const SITE_URL = 'https://coderplanets.com'
248
export const GITHUB_WEB_ADDR =

config/general.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
/*
22
general behavior of the site
3+
TODO: move those to config
34
*/
45

5-
export const DEFAULT_THEME = 'cyan'
6-
export const SENIOR_AMOUNT_THRESHOLD = 51.2
7-
export const SPONSOR_AMOUNT_THRESHOLD = 5999
8-
9-
export const PAGE_SIZE = {
10-
S: 10,
11-
D: 20,
12-
M: 30,
13-
L: 40,
14-
}
15-
166
export const WORD_LIMIT = {
177
COMMENT: 300,
188
}

config/index.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
export {
1+
import * as CONFIG from './config.json'
2+
3+
export const { EMAIL_CLUB, EMAIL_SUPPORT, EMAIL_HELLO, EMAIL_BUSINESS } = CONFIG
4+
export const {
25
DEFAULT_THEME,
36
SENIOR_AMOUNT_THRESHOLD,
47
SPONSOR_AMOUNT_THRESHOLD,
58
PAGE_SIZE,
6-
WORD_LIMIT,
7-
TAG_COLORS,
8-
TAG_COLOR_ORDER,
9-
} from './general'
9+
} = CONFIG
10+
11+
export { WORD_LIMIT, TAG_COLORS, TAG_COLOR_ORDER } from './general'
1012

1113
export {
1214
SITE_URL,
@@ -23,13 +25,5 @@ export {
2325
DEFAULT_USER_AVATAR,
2426
} from './endpoint'
2527

26-
export {
27-
EMAIL_CLUB,
28-
EMAIL_SUPPORT,
29-
EMAIL_HELLO,
30-
EMAIL_BUSINESS,
31-
} from './contacts'
32-
3328
export { ASSETS_ENDPOINT, ICON_BASE, ICON_CMD, DEFAULT_ICON } from './assets'
34-
3529
export { default as LABEL_POOL } from './label_pool'

server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ const LRUCache = require('lru-cache')
1212
const helmet = require('helmet')
1313
const mobxReact = require('mobx-react')
1414
const R = require('ramda')
15-
1615
// inspect graphql model
1716
const { express: voyagerMiddleware } = require('graphql-voyager/middleware')
1817

18+
const CONFIG = require('./config/config.json')
19+
1920
const app = next({ dev, quiet: false })
2021
const handle = app.getRequestHandler()
2122
const SERVE_PORT = process.env.SERVE_PORT || 3000
@@ -34,7 +35,7 @@ const ssrCache = new LRUCache({
3435
app.prepare().then(() => {
3536
const server = express()
3637
/* eslint-disable-next-line */
37-
const { Sentry } = require('./services/sentry')({ release: app.buildId })
38+
const { Sentry } = require('./src/services/sentry')({ release: app.buildId })
3839

3940
server.use(Sentry.Handlers.requestHandler())
4041
server.use(cookieParser())
@@ -48,7 +49,7 @@ app.prepare().then(() => {
4849
server.use(helmet())
4950
server.use(
5051
'/model-graphs',
51-
voyagerMiddleware({ endpointUrl: 'https://api.coderplanets.com/graphiql' })
52+
voyagerMiddleware({ endpointUrl: CONFIG.GRAPHQL_ENDPOINT })
5253
)
5354

5455
server.get('/_next/:page?', (req, res) => handle(req, res))

components/ArticleActionsPanel/CommunitySetterOption.js renamed to src/components/ArticleActionsPanel/CommunitySetterOption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import T from 'prop-types'
33

44
import { ICON_CMD } from '@config'
5-
import withGuardian from '@components/HOC/withGuardian'
5+
import { withGuardian } from '@hoc'
66

77
import { Option, OptionIcon, OptionTitle } from './styles'
88

components/ArticleActionsPanel/DeleteOption.js renamed to src/components/ArticleActionsPanel/DeleteOption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import T from 'prop-types'
33

44
import { ICON_CMD } from '@config'
5-
import withGuardian from '@components/HOC/withGuardian'
5+
import { withGuardian } from '@hoc'
66

77
import { Option, OptionIcon, OptionTitle } from './styles'
88

components/ArticleActionsPanel/EditOption.js renamed to src/components/ArticleActionsPanel/EditOption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import T from 'prop-types'
33

44
import { ICON_CMD } from '@config'
55
import { THREAD } from '@constant'
6+
import { withGuardian } from '@hoc'
67

7-
import withGuardian from '@components/HOC/withGuardian'
88
import { Option, OptionIcon, OptionTitle } from './styles'
99

1010
const EditOption = ({ thread, onEdit }) => (

components/ArticleActionsPanel/PinOption.js renamed to src/components/ArticleActionsPanel/PinOption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import T from 'prop-types'
33

44
import { ICON_CMD } from '@config'
5-
import withGuardian from '@components/HOC/withGuardian'
5+
import { withGuardian } from '@hoc'
66

77
import { Option, OptionIcon, OptionTitle } from './styles'
88

components/ArticleActionsPanel/RefineOption.js renamed to src/components/ArticleActionsPanel/RefineOption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import T from 'prop-types'
33
import R from 'ramda'
44

55
import { ICON_CMD } from '@config'
6-
import withGuardian from '@components/HOC/withGuardian'
6+
import { withGuardian } from '@hoc'
77

88
import { Option, OptionIcon, OptionTitle } from './styles'
99

File renamed without changes.
File renamed without changes.

components/ContributorList/index.js renamed to src/components/ContributorList/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import React from 'react'
88
import T from 'prop-types'
99

1010
import { buildLog } from '@utils'
11+
import { withGuardian } from '@hoc'
1112

1213
import AvatarAdder from '@containers/AvatarAdder'
13-
14-
import withGuardian from '@components/HOC/withGuardian'
1514
import Popover from '@components/Popover'
1615
import GithubUserCard from '@components/GithubUserCard'
1716

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/Pagi/styles/mobile_pagination.js renamed to src/components/Pagi/styles/mobile_pagination.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components'
22

33
// import Img from '../../../components/Img'
4-
import { theme, cs } from '../../../utils'
4+
import { theme, cs } from '@utils'
55

66
export const Wrapper = styled.div`
77
${cs.flex('justify-between')};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)