Skip to content

Commit 46dbd2c

Browse files
committed
[add] GitHub repository settings & PR badges
[optimize] simplify Repository model & types based on MobX-GitHub [optimize] upgrade to PNPM 9 & other latest Upstream packages [optimize] update Read Me document
1 parent 34a68d5 commit 46dbd2c

15 files changed

+6638
-4161
lines changed

.github/pr-badge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- icon: visualstudio
2+
label: 'GitHub.dev'
3+
message: 'PR-$prNumber'
4+
color: 'blue'
5+
url: 'https://github.dev/$owner/$repo/pull/$prNumber'
6+
7+
- icon: github
8+
label: 'GitHub codespaces'
9+
message: 'PR-$prNumber'
10+
color: 'black'
11+
url: 'https://codespaces.new/$owner/$repo/pull/$prNumber'
12+
13+
- icon: git
14+
label: 'GitPod.io'
15+
message: 'PR-$prNumber'
16+
color: 'orange'
17+
url: 'https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber'

.github/settings.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
2+
3+
repository:
4+
allow_merge_commit: false
5+
6+
delete_branch_on_merge: true
7+
8+
enable_vulnerability_alerts: true
9+
10+
labels:
11+
- name: bug
12+
color: '#d73a4a'
13+
description: Something isn't working
14+
15+
- name: documentation
16+
color: '#0075ca'
17+
description: Improvements or additions to documentation
18+
19+
- name: duplicate
20+
color: '#cfd3d7'
21+
description: This issue or pull request already exists
22+
23+
- name: enhancement
24+
color: '#a2eeef'
25+
description: Some improvements
26+
27+
- name: feature
28+
color: '#16b33f'
29+
description: New feature or request
30+
31+
- name: good first issue
32+
color: '#7057ff'
33+
description: Good for newcomers
34+
35+
- name: help wanted
36+
color: '#008672'
37+
description: Extra attention is needed
38+
39+
- name: invalid
40+
color: '#e4e669'
41+
description: This doesn't seem right
42+
43+
- name: question
44+
color: '#d876e3'
45+
description: Further information is requested
46+
47+
- name: wontfix
48+
color: '#ffffff'
49+
description: This will not be worked on
50+
51+
branches:
52+
- name: main
53+
# https://docs.github.com/en/rest/reference/repos#update-branch-protection
54+
protection:
55+
# Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
56+
required_pull_request_reviews:
57+
# The number of approvals required. (1-6)
58+
required_approving_review_count: 1
59+
# Dismiss approved reviews automatically when a new commit is pushed.
60+
dismiss_stale_reviews: true
61+
# Blocks merge until code owners have reviewed.
62+
require_code_owner_reviews: true
63+
# Specify which users and teams can dismiss pull request reviews.
64+
# Pass an empty dismissal_restrictions object to disable.
65+
# User and team dismissal_restrictions are only available for organization-owned repositories.
66+
# Omit this parameter for personal repositories.
67+
dismissal_restrictions:
68+
# users: []
69+
# teams: []
70+
# Required. Require status checks to pass before merging. Set to null to disable
71+
required_status_checks:
72+
# Required. Require branches to be up to date before merging.
73+
strict: true
74+
# Required. The list of status checks to require in order to merge into this branch
75+
contexts: []
76+
# Required. Enforce all configured restrictions for administrators.
77+
# Set to true to enforce required status checks for repository administrators.
78+
# Set to null to disable.
79+
enforce_admins: true
80+
# Prevent merge commits from being pushed to matching branches
81+
required_linear_history: true
82+
# Required. Restrict who can push to this branch.
83+
# Team and user restrictions are only available for organization-owned repositories.
84+
# Set to null to disable.
85+
restrictions: null

README.md

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,39 @@
22

33
[React][1] project scaffold based on [TypeScript][2], [Next.js][3], [Bootstrap][4] & [Workbox][5]. And this project bootstrapped with [`create-next-app`][6].
44

5-
[![CI & CD](https://github.com/idea2app/idea2app.github.io/actions/workflows/main.yml/badge.svg)][8]
5+
[![CI & CD](https://github.com/idea2app/idea2app.github.io/actions/workflows/main.yml/badge.svg)][7]
6+
7+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)][8]
8+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][9]
69

710
## Technology stack
811

9-
- Language: [TypeScript v5][2]
12+
- Language: [TypeScript v5][2] + [MDX v3][10]
1013
- Component engine: [Next.js v14][3]
1114
- Component suite: [Bootstrap v5][4]
1215
- PWA framework: [Workbox v6][5]
13-
- State management: [MobX v6][9]
14-
- CI / CD: GitHub [Actions][11] + [Vercel][12]
16+
- State management: [MobX v6][11]
17+
- CI / CD: GitHub [Actions][12] + [Vercel][13]
18+
- Monitor service: [Sentry][14]
19+
20+
## Best practice
21+
22+
1. Install GitHub apps in your organization or account:
23+
24+
1. [Probot settings][15]: set up Issue labels & Pull Request rules
25+
2. [PR badge][16]: set up Online [VS Code][17] editor entries in Pull Request description
26+
27+
2. Click the **[<kbd>Use this template</kbd>][18] button** on the top of this GitHub repository's home page, then create your own repository in the app-installed namespace above
28+
29+
3. Click the **[<kbd>Open in GitHub codespaces</kbd>][8] button** on the top of ReadMe file, then an **online VS Code development environment** will be started immediately
30+
31+
4. Set [Vercel variables][19] as [Repository secrets][20], then every commit will get an independent **Preview URL**
32+
33+
5. Recommend to add a [Notification step in GitHub actions][21] for your Team IM app
34+
35+
6. Remind the PMs & users of your product to submit **Feature/Enhancement** requests or **Bug** reports with [Issue forms][22] instead of IM messages or Mobile Phone calls
36+
37+
7. Collect all these issues into [Project kanbans][23], then create **Pull requests** & add `closes #issue_number` into its description for automation
1538

1639
## Getting Started
1740

@@ -26,26 +49,35 @@ Open http://localhost:3000 with your browser to see the result.
2649

2750
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
2851

29-
[API routes][13] can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in `pages/api/hello.ts`.
52+
[API routes][24] can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in `pages/api/hello.ts`.
3053

31-
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes][13] instead of React pages.
54+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as API routes instead of React pages.
3255

3356
## Learn More
3457

3558
To learn more about Next.js, take a look at the following resources:
3659

37-
- [Next.js Documentation][14] - learn about Next.js features and API.
38-
- [Learn Next.js][15] - an interactive Next.js tutorial.
60+
- [Next.js Documentation][25] - learn about Next.js features and API.
61+
- [Learn Next.js][26] - an interactive Next.js tutorial.
3962

40-
You can check out [the Next.js GitHub repository][16] - your feedback and contributions are welcome!
63+
You can check out [the Next.js GitHub repository][27] - your feedback and contributions are welcome!
4164

4265
## Deployment
4366

67+
### Environment variables
68+
69+
| name | file | description |
70+
| :----------------------: | :----------: | :---------------------: |
71+
| `SENTRY_AUTH_TOKEN` | `.env.local` | [Official document][28] |
72+
| `SENTRY_ORG` | `.env` | [Official document][29] |
73+
| `SENTRY_PROJECT` | `.env` | [Official document][29] |
74+
| `NEXT_PUBLIC_SENTRY_DSN` | `.env` | [Official document][30] |
75+
4476
### Vercel
4577

46-
The easiest way to deploy your Next.js app is to use the [Vercel Platform][12] from the creators of Next.js.
78+
The easiest way to deploy your Next.js app is to use the [Vercel Platform][13] from the creators of Next.js.
4779

48-
Check out our [Next.js deployment documentation][17] for more details.
80+
Check out our [Next.js deployment documentation][31] for more details.
4981

5082
### Docker
5183

@@ -60,12 +92,28 @@ pnpm container
6092
[4]: https://getbootstrap.com/
6193
[5]: https://developers.google.com/web/tools/workbox
6294
[6]: https://github.com/vercel/next.js/tree/canary/packages/create-next-app
63-
[8]: https://github.com/idea2app/idea2app.github.io/actions/workflows/main.yml
64-
[9]: https://mobx.js.org/
65-
[11]: https://github.com/features/actions
66-
[12]: https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme
67-
[13]: https://nextjs.org/docs/api-routes/introduction
68-
[14]: https://nextjs.org/docs
69-
[15]: https://nextjs.org/learn
70-
[16]: https://github.com/vercel/next.js/
71-
[17]: https://nextjs.org/docs/deployment
95+
[7]: https://github.com/idea2app/idea2app.github.io/actions/workflows/main.yml
96+
[8]: https://codespaces.new/idea2app/idea2app.github.io
97+
[9]: https://gitpod.io/?autostart=true#https://github.com/idea2app/idea2app.github.io
98+
[10]: https://mdxjs.com/
99+
[11]: https://mobx.js.org/
100+
[12]: https://github.com/features/actions
101+
[13]: https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme
102+
[14]: https://sentry.io/
103+
[15]: https://github.com/apps/settings
104+
[16]: https://pullrequestbadge.com/
105+
[17]: https://code.visualstudio.com/
106+
[18]: https://github.com/new?template_name=idea2app.github.io&template_owner=idea2app
107+
[19]: https://github.com/idea2app/idea2app.github.io/blob/34a68d5c3a21665c5971edff5aa7c208647d1566/.github/workflows/main.yml#L9-L11
108+
[20]: https://github.com/idea2app/idea2app.github.io/settings/secrets/actions
109+
[21]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/bb4675a56bf1d6b207231313da5ed0af7cf0ebd6/.github/workflows/pull-request.yml#L32-L56
110+
[22]: https://github.com/idea2app/idea2app.github.io/issues/new/choose
111+
[23]: https://github.com/idea2app/idea2app.github.io/projects
112+
[24]: https://nextjs.org/docs/api-routes/introduction
113+
[25]: https://nextjs.org/docs
114+
[26]: https://nextjs.org/learn
115+
[27]: https://github.com/vercel/next.js/
116+
[28]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-configuration-files-for-source-map-upload
117+
[29]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-environment-variables
118+
[30]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files
119+
[31]: https://nextjs.org/docs/deployment

babel.config.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
module.exports = {
22
presets: [
3-
// https://babeljs.io/docs/babel-preset-typescript
4-
[
5-
'@babel/preset-typescript',
6-
{
7-
allowDeclareFields: true,
8-
allowNamespaces: true,
9-
allExtensions: true,
10-
isTSX: true,
11-
},
12-
],
133
// https://babeljs.io/docs/babel-preset-react
144
[
155
'@babel/preset-react',
@@ -19,6 +9,18 @@ module.exports = {
199
},
2010
],
2111
],
22-
// https://babeljs.io/docs/babel-plugin-proposal-decorators#note-compatibility-with-babelplugin-transform-class-properties
23-
plugins: [['@babel/plugin-proposal-decorators', { version: '2023-05' }]],
12+
plugins: [
13+
// https://github.com/babel/babel/issues/16262#issuecomment-1962832499
14+
[
15+
'@babel/plugin-transform-typescript',
16+
{
17+
allowDeclareFields: true,
18+
allowNamespaces: true,
19+
allExtensions: true,
20+
isTSX: true,
21+
},
22+
],
23+
// https://babeljs.io/docs/babel-plugin-proposal-decorators#note-compatibility-with-babelplugin-transform-class-properties
24+
['@babel/plugin-proposal-decorators', { version: '2023-05' }],
25+
],
2426
};

components/Git/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { text2color } from 'idea-react';
2+
import { GitRepository } from 'mobx-github';
23
import { observer } from 'mobx-react';
34
import { FC } from 'react';
45
import { Badge, Button, Card, Col, Row } from 'react-bootstrap';
56

6-
import { GitRepository } from '../../models/Repository';
77
import { i18n } from '../../models/Translation';
88
import { GitLogo } from './Logo';
99

components/Git/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { GitRepository } from 'mobx-github';
12
import { FC } from 'react';
23
import { Col, Row } from 'react-bootstrap';
34

4-
import { GitRepository } from '../../models/Repository';
55
import { GitCard } from './Card';
66

77
export const GitListLayout: FC<{ defaultData: GitRepository[] }> = ({

models/Base.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { HTTPClient } from 'koajax';
33
export const isServer = () => typeof window === 'undefined';
44

55
export const VercelHost = process.env.VERCEL_URL,
6-
GithubToken = process.env.GITHUB_TOKEN,
76
LarkBaseId = process.env.NEXT_PUBLIC_LARK_BASE!;
87

9-
const API_Host = isServer()
8+
export const API_Host = isServer()
109
? VercelHost
1110
? `https://${VercelHost}`
1211
: 'http://localhost:3000'
@@ -16,15 +15,3 @@ export const larkClient = new HTTPClient({
1615
baseURI: `${API_Host}/api/Lark/`,
1716
responseType: 'json',
1817
});
19-
20-
export const githubClient = new HTTPClient({
21-
baseURI: isServer() ? 'https://api.github.com/' : `${API_Host}/api/GitHub/`,
22-
responseType: 'json',
23-
}).use(({ request }, next) => {
24-
if (GithubToken)
25-
request.headers = {
26-
...request.headers,
27-
Authorization: `Bearer ${GithubToken}`,
28-
};
29-
return next();
30-
});

0 commit comments

Comments
 (0)