Skip to content

Commit 8a5fd4b

Browse files
committed
[migrate] upgrade to Node.js 22, PNPM 9, Next.js 15, Idea React 2, ESLint 9, Husky 9 & other latest Upstream packages
[add] Prettier CSS plugins [add] Vercel deployment & Lark notification
1 parent 8211df4 commit 8a5fd4b

File tree

15 files changed

+6178
-4263
lines changed

15 files changed

+6178
-4263
lines changed

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,59 @@ name: CI & CD
22
on:
33
push:
44
branches:
5-
- main
5+
- '*'
66
jobs:
77
Build-and-Deploy:
8+
env:
9+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
10+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
11+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
812
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
915
steps:
10-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
17+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
1118

12-
- uses: pnpm/action-setup@v2
19+
- name: Deploy to Vercel
20+
id: vercel-deployment
21+
uses: amondnet/vercel-action@v25
22+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
1323
with:
14-
version: 8
15-
- name: Use Node.js
16-
uses: actions/setup-node@v3
17-
with:
18-
node-version: 18
19-
cache: pnpm
20-
21-
- name: Install
22-
run: pnpm i --frozen-lockfile
23-
- name: Build
24-
run: pnpm build
24+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
27+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
28+
working-directory: ./
29+
vercel-args: ${{ github.ref == 'refs/heads/main' && ' --prod' || '' }}
2530

26-
- name: Deploy
27-
uses: peaceiris/actions-gh-pages@v3
31+
- name: Lark notification
32+
uses: foxundermoon/feishu-action@v2
2833
with:
29-
publish_dir: ./out
30-
personal_token: ${{ secrets.GITHUB_TOKEN }}
31-
force_orphan: true
34+
url: ${{ secrets.LARK_CHATBOT_HOOK_URL }}
35+
msg_type: post
36+
content: |
37+
post:
38+
en_us:
39+
title: "Vercel Preview Environment"
40+
content:
41+
- - tag: text
42+
text: "Git Repository: "
43+
- tag: a
44+
text: ${{ github.server_url }}/${{ github.repository }}
45+
href: ${{ github.server_url }}/${{ github.repository }}
46+
- - tag: text
47+
text: "Code Branch: "
48+
- tag: a
49+
text: ${{ github.ref }}
50+
href: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
51+
- - tag: text
52+
text: "Commit Author: "
53+
- tag: a
54+
text: ${{ github.actor }}
55+
href: ${{ github.server_url }}/${{ github.actor }}
56+
- - tag: text
57+
text: "Preview Link: "
58+
- tag: a
59+
text: ${{ steps.vercel-deployment.outputs.preview-url }}
60+
href: ${{ steps.vercel-deployment.outputs.preview-url }}

.husky/pre-commit

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
#!/bin/sh
2-
3-
. "$(dirname "$0")/_/husky.sh"
4-
51
npm test

.husky/pre-push

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
#!/bin/sh
2-
3-
. "$(dirname "$0")/_/husky.sh"
4-
51
npm run build

components/PageContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MDXProvider } from '@mdx-js/react';
22
import type { PropsWithChildren } from 'react';
3-
import { Container, Card } from 'react-bootstrap';
3+
import { Card, Container } from 'react-bootstrap';
44

55
import styles from '../../styles/Home.module.scss';
66
import pageContentStyles from './PageContent.module.scss';

components/PageHead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { PropsWithChildren } from 'react';
21
import Head from 'next/head';
2+
import type { PropsWithChildren } from 'react';
33

44
export type PageHeadProps = PropsWithChildren<{
55
title?: string;

eslint.config.mjs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// @ts-check
2+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
3+
import { FlatCompat } from '@eslint/eslintrc';
4+
import eslint from '@eslint/js';
5+
import eslintConfigPrettier from 'eslint-config-prettier';
6+
import reactPlugin from 'eslint-plugin-react';
7+
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
8+
import globals from 'globals';
9+
import tsEslint from 'typescript-eslint';
10+
import { fileURLToPath } from 'url';
11+
12+
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url)),
13+
flatCompat = new FlatCompat();
14+
15+
export default tsEslint.config(
16+
// register all of the plugins up-front
17+
{
18+
plugins: {
19+
'@typescript-eslint': tsEslint.plugin,
20+
react: fixupPluginRules(reactPlugin),
21+
'simple-import-sort': simpleImportSortPlugin,
22+
},
23+
},
24+
{
25+
// config with just ignores is the replacement for `.eslintignore`
26+
ignores: ['**/node_modules/**', '**/public/**', '**/.next/**'],
27+
},
28+
29+
// extends ...
30+
eslint.configs.recommended,
31+
...tsEslint.configs.recommended,
32+
...fixupConfigRules(flatCompat.extends('plugin:@next/next/core-web-vitals')),
33+
34+
// base config
35+
{
36+
languageOptions: {
37+
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
38+
parserOptions: {
39+
projectService: true,
40+
tsconfigRootDir,
41+
warnOnUnsupportedTypeScriptVersion: false,
42+
},
43+
},
44+
rules: {
45+
'no-empty-pattern': 'warn',
46+
'simple-import-sort/exports': 'error',
47+
'simple-import-sort/imports': 'error',
48+
'@typescript-eslint/no-unused-vars': 'warn',
49+
'@typescript-eslint/no-explicit-any': 'warn',
50+
'@typescript-eslint/no-empty-object-type': 'off',
51+
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
52+
'react/jsx-no-target-blank': 'warn',
53+
'react/jsx-sort-props': [
54+
'error',
55+
{
56+
reservedFirst: true,
57+
callbacksLast: true,
58+
noSortAlphabetically: true,
59+
},
60+
],
61+
'@next/next/no-sync-scripts': 'warn',
62+
},
63+
},
64+
{
65+
files: ['**/*.js'],
66+
extends: [tsEslint.configs.disableTypeChecked],
67+
rules: {
68+
// turn off other type-aware rules
69+
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
70+
71+
// turn off rules that don't apply to JS code
72+
'@typescript-eslint/explicit-function-return-type': 'off',
73+
},
74+
},
75+
eslintConfigPrettier,
76+
);

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

next.config.mjs renamed to next.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const withMDX = setMDX({
1616
disable: process.env.NODE_ENV === 'development',
1717
});
1818

19-
/** @type {import('next').NextConfig} */
2019
export default withPWA(
2120
withMDX({
2221
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],

package.json

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,66 @@
11
{
22
"name": "@open-source-bazaar/web-site",
3-
"version": "0.0.2",
3+
"version": "1.0.0",
44
"description": "Open Source Bazaar web-site",
55
"private": true,
66
"scripts": {
7-
"prepare": "husky install",
7+
"prepare": "husky",
88
"dev": "next dev",
99
"build": "next build",
1010
"start": "next start",
11-
"lint": "next lint",
12-
"test": "npm run lint && lint-staged"
11+
"lint": "next lint && tsc --noEmit",
12+
"test": "lint-staged && npm run lint"
1313
},
1414
"dependencies": {
15-
"@mdx-js/loader": "^3.0.0",
16-
"@mdx-js/react": "^3.0.0",
17-
"@next/mdx": "^14.0.3",
18-
"idea-react": "^1.0.0-rc.30",
19-
"next": "^14.0.3",
15+
"@mdx-js/loader": "^3.1.0",
16+
"@mdx-js/react": "^3.1.0",
17+
"@next/mdx": "^15.1.6",
18+
"idea-react": "^2.0.0-rc.8",
19+
"next": "^15.1.6",
2020
"next-pwa": "^5.6.0",
21-
"react": "^18.2.0",
22-
"react-bootstrap": "^2.9.1",
23-
"react-dom": "^18.2.0",
21+
"react": "^18.3.1",
22+
"react-bootstrap": "^2.10.9",
23+
"react-dom": "^18.3.1",
2424
"react-typed-component": "^1.0.6"
2525
},
2626
"devDependencies": {
27-
"@types/node": "^18.18.9",
28-
"@types/react": "^18.2.37",
29-
"eslint": "^8.53.0",
30-
"eslint-config-next": "^14.0.3",
31-
"husky": "^8.0.3",
32-
"lint-staged": "^15.1.0",
33-
"prettier": "^3.1.0",
34-
"sass": "^1.69.5",
35-
"typescript": "~5.2.2"
27+
"@eslint/compat": "^1.2.6",
28+
"@eslint/eslintrc": "^3.2.0",
29+
"@eslint/js": "^9.19.0",
30+
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
31+
"@types/eslint-config-prettier": "^6.11.3",
32+
"@types/eslint__eslintrc": "^2.1.2",
33+
"@types/next-pwa": "^5.6.9",
34+
"@types/node": "^22.13.1",
35+
"@types/react": "^18.3.18",
36+
"@types/react-dom": "^18",
37+
"eslint": "^9.19.0",
38+
"eslint-config-next": "^15.1.6",
39+
"eslint-config-prettier": "^10.0.1",
40+
"eslint-plugin-react": "^7.37.4",
41+
"eslint-plugin-simple-import-sort": "^12.1.1",
42+
"globals": "^15.14.0",
43+
"husky": "^9.1.7",
44+
"lint-staged": "^15.4.3",
45+
"prettier": "^3.4.2",
46+
"prettier-plugin-css-order": "^2.1.2",
47+
"sass": "^1.84.0",
48+
"typescript": "~5.7.3",
49+
"typescript-eslint": "^8.23.0"
50+
},
51+
"resolutions": {
52+
"next": "$next"
3653
},
3754
"prettier": {
3855
"singleQuote": true,
3956
"trailingComma": "all",
40-
"arrowParens": "avoid"
57+
"arrowParens": "avoid",
58+
"plugins": [
59+
"prettier-plugin-css-order",
60+
"@softonus/prettier-plugin-duplicate-remover"
61+
]
4162
},
4263
"lint-staged": {
43-
"*.{html,md,scss,json,yml,js,mjs,ts,tsx}": "prettier --write",
44-
"*.{js,mjs,ts,tsx}": "eslint --fix"
64+
"*.{html,md,scss,json,yml,js,mjs,ts,tsx}": "prettier --write"
4565
}
4666
}

0 commit comments

Comments
 (0)