Skip to content

Commit

Permalink
Merge branch 'release/v0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia1984 committed Sep 7, 2024
2 parents 82fbde9 + 989f7d9 commit 8692880
Show file tree
Hide file tree
Showing 493 changed files with 22,411 additions and 15,850 deletions.
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ BASE_STORAGE_PATH =
PAYMENT_TOKEN =
PAYMENT_ID =
PAYMENT_SERVICE =

# OAuth 2.0 for apple login and google login
GOOGLE_CLIENT_ID = google-client-id
GOOGLE_CLIENT_SECRET = google-client-secret

APPLE_CLIENT_ID = com.company.app
APPLE_CLIENT_SECRET = apple-client-secret
APPLE_KEY_ID = apple-key-id
APPLE_TEAM_ID = apple-team-id
APPLE_PRIVATE_KEY = apple-private-key

NEXTAUTH_URL = https://isunfa.com/
NEXTAUTH_SECRET = generated-random-secret
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
camelcase: ['error', { properties: 'never' }],
'object-curly-newline': 'off',
'react/jsx-props-no-spreading': 'off',
'no-console': 'error',
Expand Down Expand Up @@ -65,7 +66,10 @@ module.exports = {
'react/jsx-tag-spacing': 'off',
'react/jsx-wrap-multilines': 'off',
'no-else-return': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: false, optionalDependencies: false, peerDependencies: false },
],
'no-nested-ternary': 'off',
'react/require-default-props': 'off',
'@typescript-eslint/naming-convention': [
Expand All @@ -89,6 +93,7 @@ module.exports = {
'plugin:react/recommended',
],
rules: {
camelcase: ['error', { properties: 'never' }],
'object-curly-newline': 'off',
'react/jsx-props-no-spreading': 'off',
'no-console': 'error',
Expand Down Expand Up @@ -131,6 +136,8 @@ module.exports = {
'react/jsx-wrap-multilines': 'off',
'no-nested-ternary': 'off',
'react/require-default-props': 'off',
'no-eval': 'error',
'no-new-func': 'error',
},

// 整合 prettier 和解決 prettier 衝突問題
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package-lock.json
# production
/build

/private

# misc
.DS_Store
*.pem
Expand Down
10 changes: 10 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Info: (20240829 - Jacky) - Make sure NVM is loaded before running the tests
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Info: (20240830 - Shirley) 檢查 stage files,有不符合規定就會阻止 commit
npx lint-staged

# Info: (20240830 - Shirley) 測試和版本更新
npm run test
npm run update-version
6 changes: 2 additions & 4 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"**/*.+(js|jsx|ts|tsx)": [
"./node_modules/.bin/eslint --fix",
"./node_modules/.bin/prettier --write",
"git add"
"./node_modules/.bin/eslint --fix"
],
"**/*.+(css)": [
"./node_modules/.bin/eslint/tailwindcss --fix",
"./node_modules/.bin/prettier --write",
"git add"
"./node_modules/.bin/eslint/tailwindcss --fix"
]
}
3 changes: 1 addition & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* https://jestjs.io/docs/configuration
*/
import type { Config } from 'jest';
// eslint-disable-next-line import/extensions
import nextJest from 'next/jest.js';
import nextJest from 'next/jest';

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
Expand Down
39 changes: 34 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
/** @type {import('next').NextConfig} */

// Info: (20240531 - Murky) - Use "lodash-es" for esm support, but eslint doesn't support it, so disable the rule
// eslint-disable-next-line import/no-extraneous-dependencies
const cloneDeep = require('lodash/cloneDeep');
const { i18n } = require('./next-i18next.config');

/**
* echo -n "window['dataLayer'] = window['dataLayer'] || []; function gtag(){window['dataLayer'].push(arguments);} gtag('js', new Date()); gtag('config', 'G-ZNVVW7JP0N');" | openssl dgst -sha256 -binary | openssl base64
*/

// const cspHeader = `
// default-src 'self';
// script-src 'self' 'sha256-AWYvreN84Mjp/63ULk+PPMBA9Sgj2Z4oZJASFhXoUJw=' https://www.googletagmanager.com;
// style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
// img-src 'self' blob: data: https://isunfa.com https://*.googleusercontent.com https://storage.googleapis.com www.googletagmanager.com;
// font-src 'self' https://fonts.gstatic.com;
// object-src 'none';
// base-uri 'self';
// form-action 'self';
// frame-ancestors 'none';
// upgrade-insecure-requests;
// connect-src 'self' www.googletagmanager.com http://localhost:3000;
// `;

const nextConfig = {
poweredByHeader: false,
async headers() {
return [
{
Expand All @@ -21,6 +39,15 @@ const nextConfig = {
},
],
},
// {
// source: '/(.*)',
// headers: [
// {
// key: 'Content-Security-Policy',
// value: cspHeader.replace(/\n/g, ' ').trim(),
// },
// ],
// },
];
},
reactStrictMode: true,
Expand All @@ -36,18 +63,20 @@ const nextConfig = {
},
images: {
loader: 'custom',
loaderFile: '/src/lib/utils/image-loader.js',
loaderFile: '/src/lib/utils/image_loader.js',
},
webpack: (config) => {
const newConfig = cloneDeep(config);
// Info: do as `react-pdf` doc says (https://github.com/wojtekmaj/react-pdf) (20240502 - Shirley)
// eslint-disable-next-line no-param-reassign
// Info: (20240502 - Shirley) do as `react-pdf` doc says (https://github.com/wojtekmaj/react-pdf)
newConfig.resolve.alias.canvas = false;

// Fixes npm packages that depend on `fs` module
// Info: (20240531 - Murky) Fixes npm packages that depend on `fs` module
newConfig.resolve.fallback = { fs: false };
return newConfig;
},
experimental: {
instrumentationHook: true, // Info: (20240812 - Murky) this is for function run before server start
},
};

module.exports = nextConfig;
68 changes: 41 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iSunFA",
"version": "0.8.0",
"version": "0.8.1",
"private": false,
"scripts": {
"dev": "next dev",
Expand All @@ -9,19 +9,18 @@
"start": "next start",
"lint": "next lint && eslint --fix --ext .js,.jsx,.ts,.tsx .",
"test": "jest",
"check-format": "prettier --ignore-path .gitignore --list-different \"**/*.+(js|jsx|ts|tsx|json)\"",
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|jsx|ts|tsx|json)\"",
"validate": "npm run test && npm run check-format && npm run lint",
"check-format": "prettier --ignore-path .gitignore --list-different \"**/*.+(js|jsx|ts|tsx|json|css)\"",
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|jsx|ts|tsx|json|css)\"",
"validate": "prettier --ignore-path .gitignore --write \"**/*.+(js|jsx|ts|tsx|json|css)\" && next lint && eslint --fix --ext .js,.jsx,.ts,.tsx . && npm run test",
"production": "next start -p 80",
"update-version": "ts-node -r tsconfig-paths/register --compiler-options '{\"module\":\"CommonJS\"}' scripts/update_version.ts && git add package.json"
"update-version": "ts-node -r tsconfig-paths/register --compiler-options '{\"module\":\"CommonJS\"}' scripts/update_version.ts && git add package.json",
"prepare": "husky"
},
"dependencies": {
"@google-cloud/storage": "^7.11.1",
"@next/third-parties": "^14.2.5",
"@passwordless-id/webauthn": "^1.5.0",
"@prisma/client": "^5.14.0",
"@types/formidable": "^3.4.5",
"@types/react-chartjs-2": "^2.5.7",
"apexcharts": "^3.48.0",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
Expand All @@ -31,52 +30,67 @@
"cookie": "^0.6.0",
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
"eslint-config-airbnb": "^19.0.4",
"formidable": "^3.5.1",
"i18next": "^23.11.5",
"jest-mock-extended": "^3.0.7",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"next": "^14.2.5",
"next-auth": "^4.24.7",
"next-i18next": "^15.2.0",
"next-logger": "^5.0.0",
"next-session": "^4.0.5",
"nodemailer": "^6.9.8",
"react": "^18",
"pino": "^9.3.2",
"pino-multi-stream": "^6.0.0",
"pino-pretty": "^11.2.2",
"react": "^18.3.1",
"react-apexcharts": "^1.4.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18",
"react-i18next": "^14.1.2",
"react-dom": "^18.3.1",
"react-i18next": "^15.0.1",
"react-icons": "^5.0.1",
"react-pdf": "^8.0.2",
"react-pdf": "^9.1.0",
"react-toastify": "^10.0.5",
"react-usestateref": "^1.0.8",
"rotating-file-stream": "^3.2.3",
"sharp": "^0.33.3",
"tailwind-merge": "^2.2.2",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"uuid": "^10.0.0",
"winston": "^3.14.2"
},
"devDependencies": {
"@babel/eslint-plugin": "^7.23.5",
"@babel/eslint-plugin": "^7.25.1",
"@babel/preset-typescript": "^7.24.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.3.1",
"@testing-library/react": "^16.0.0",
"@types/cookie": "^0.6.0",
"@types/jest": "^29.5.11",
"@types/node": "^20",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "^22.4.2",
"@types/nodemailer": "^6.4.15",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@types/pino": "^7.0.5",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"autoprefixer": "^10.4.16",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-next": "14.0.4",
"eslint-config-next": "^14.2.5",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-tailwindcss": "^3.13.0",
"husky": "^4.3.8",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-tailwindcss": "^3.17.4",
"husky": "^9.1.5",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.0",
"postcss": "^8.4.32",
"prettier": "^3.3.2",
Expand All @@ -88,7 +102,7 @@
},
"husky": {
"hooks": {
"pre-commit": "npm run test && lint-staged && npm run update-version"
"pre-commit": "next lint && eslint --fix --ext .js,.jsx,.ts,.tsx . && npm run test && lint-staged && npm run update-version"
}
},
"engines": {
Expand Down
Loading

0 comments on commit 8692880

Please sign in to comment.