Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 19 additions & 47 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,59 @@
# Sample workflow for building and deploying a Next.js site to GitHub Pages
#
# To get started with Next.js see: https://nextjs.org/docs/getting-started
#
name: Deploy Next.js site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# 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 job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
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: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9 # Adjust to your local pnpm version

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache: "pnpm"

- name: Setup Pages
uses: actions/configure-pages@v5
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache

- name: Restore Next.js Cache
uses: actions/cache@v4
with:
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.
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-

- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
run: pnpm install --frozen-lockfile

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

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

# Deployment job
deploy:
environment:
name: github-pages
Expand All @@ -91,4 +63,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
40 changes: 15 additions & 25 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,63 @@
// eslint.config.js
import js from '@eslint/js';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import prettierPlugin from 'eslint-plugin-prettier';
import nextPlugin from '@next/eslint-plugin-next';

export default [
js.configs.recommended,

{
files: ['**/*.{js,jsx,ts,tsx,mjs}'],

languageOptions: {
parser: tsParser,
ecmaVersion: 11,
ecmaVersion: 'latest', // Use latest for Next.js 15
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaFeatures: { jsx: true },
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},

plugins: {
react: reactPlugin,
'@typescript-eslint': tsPlugin,
'react-hooks': reactHooks,
prettier: prettierPlugin,
'@next/next': nextPlugin,
},

settings: {
react: {
version: 'detect',
},
react: { version: 'detect' },
},

rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,

'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'newline-before-return': 'error',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',

'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],

'no-console': ['error', { allow: ['warn', 'error'] }],

'prettier/prettier': 'error',
},
},

{
ignores: [
'**/node_modules/*',
'**/out/*',
'**/.next/*',
'**/coverage',
'node_modules/',
'.next/',
'out/',
'dist/',
'build/',
'coverage/',
'src/styles/globals.css',
'dist',
'build',
'out',
],
},
];
];
34 changes: 34 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const nextJest = require('next/jest');

const createJestConfig = nextJest({
dir: './',
});

const customJestConfig = {
testEnvironment: 'jest-environment-jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testRegex: '(/__tests__/.*|(\\.|/)(test))\\.[jt]sx?$',
transformIgnorePatterns: [
'/node_modules/(?!(.pnpm|debounce|flowbite-react|@fortawesome|flowbite)/)',
'^.+\\.module\\.(css|sass|scss)$',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
'^.+\\.(css|sass|scss)$': '<rootDir>/__mocks__/styleMock.js',
'^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$': `<rootDir>/__mocks__/fileMock.js`,
},
};

// IMPORTANT: In Next.js 15, createJestConfig is an async function.
// Using module.exports = createJestConfig(...) is usually fine,
// but sometimes nextJest needs to be forced to respect the ignore pattern.
module.exports = async () => {
const config = await createJestConfig(customJestConfig)();
// Forcefully override the ignore pattern if nextJest stripped it
config.transformIgnorePatterns = [
'/node_modules/(?!(.pnpm|debounce|flowbite-react|@fortawesome|flowbite)/)',
...config.transformIgnorePatterns.filter(pattern => pattern !== '/node_modules/'),
];
return config;
};
60 changes: 0 additions & 60 deletions jest.config.js

This file was deleted.

15 changes: 10 additions & 5 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Optional: configure or set up a testing framework before each test.
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
jest.mock('debounce', () => {
return {
__esModule: true,
default: (fn) => {
fn.cancel = () => {};
fn.flush = () => {};

// Used for __tests__/testing-library.js
// Learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
return fn;
},
};
});
1 change: 1 addition & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './src/lib/env/env.mjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
basePath: '/digimon-partner-kit',
assetPrefix: process.env.NODE_ENV === 'production' ? '/digimon-partner-kit/' : '',
reactStrictMode: true,
Expand Down
Loading
Loading