Skip to content

Commit

Permalink
feat: upgrade to Next.js based project (#96)
Browse files Browse the repository at this point in the history
* feat: init nextjs project

* fix: fix ci to deploy nextjs

* fix: fix deploy basePath

* fix: fix package.json meta info

* fix: add Apache license header for all source files

* fix: code format end with semi true

* fix: netlify.toml config to fit nextjs
  • Loading branch information
yanggggjie authored Feb 24, 2024
1 parent 4ff069b commit 67bd93f
Show file tree
Hide file tree
Showing 57 changed files with 3,936 additions and 11,055 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
16 changes: 0 additions & 16 deletions .eslintrc

This file was deleted.

15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"plugins": [
],
"extends": [
"next/core-web-vitals"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-empty-pattern": "off",
"no-unused-vars": "off",
"arrow-parens": ["error", "always"],
"arrow-body-style": ["error", "always"]
}
}
89 changes: 76 additions & 13 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,86 @@ on:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build-and-deploy:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Checkout
uses: actions/checkout@v4

- name: Install and Build 🔧
- name: Detect package manager
id: detect-package-manager
run: |
yarn install
yarn run build
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: ${{ steps.detect-package-manager.outputs.manager }}

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
- name: Restore cache
uses: actions/cache@v4
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: build
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}

- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
52 changes: 34 additions & 18 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
# OSX
#
.DS_Store
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# vs code
.vscode
# testing
/coverage

# temp
.tmp
# next.js
/.next/
/out/

# IDEA or android-studio
*.iml
.idea
# production
/build

# misc
.DS_Store
*.pem

dist
build
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

package-lock.json
# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# editor
.idea
test
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": true,
"singleQuote": true
}
Loading

0 comments on commit 67bd93f

Please sign in to comment.