-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e57a52c
commit f6936a4
Showing
97 changed files
with
1,736 additions
and
1,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
dist | ||
.git | ||
Dockerfile | ||
.dockerignore |
36 changes: 35 additions & 1 deletion
36
apps/create-aelf-dapp/lib/generator/templates/.eslintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,40 @@ | ||
{ | ||
"plugins": ["tailwindcss"], | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:tailwindcss/recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:@tanstack/eslint-plugin-query/recommended" | ||
] | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": [], | ||
"rules": { | ||
"quotes": [ | ||
"error", | ||
"single", | ||
{ | ||
"avoidEscape": true, | ||
"allowTemplateLiterals": true | ||
} | ||
], | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"tailwindcss/classnames-order": "off", | ||
"tailwindcss/no-custom-classname": "off", | ||
"tailwindcss/no-contradicting-classname": "error", | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"@typescript-eslint/ban-ts-comment": [ | ||
"error", | ||
{ | ||
"ts-ignore": false | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
apps/create-aelf-dapp/lib/generator/templates/.github/workflows/nextBuild.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Next Build | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' # Your node version, default 20 in 2024 | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: Install Dependencies | ||
run: pnpm install | ||
|
||
- name: Run Next Build | ||
run: pnpm build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,5 @@ package | |
|
||
# git ls-files > filelist.txt | ||
filelist.txt | ||
|
||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss"] | ||
"plugins": ["prettier-plugin-tailwindcss"], | ||
"singleQuote": true | ||
} |
37 changes: 37 additions & 0 deletions
37
apps/create-aelf-dapp/lib/generator/templates/.stylelintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"extends": [ | ||
"stylelint-config-standard", | ||
"stylelint-config-css-modules", | ||
"stylelint-prettier/recommended" | ||
], | ||
"plugins": [ | ||
"stylelint-order" | ||
], | ||
"rules": { | ||
"at-rule-no-unknown": [ | ||
true, | ||
{ | ||
"ignoreAtRules": [ | ||
"tailwind", | ||
"apply", | ||
"variants", | ||
"responsive", | ||
"screen" | ||
] | ||
} | ||
], | ||
"order/order": [ | ||
"custom-properties", | ||
"declarations" | ||
], | ||
"order/properties-alphabetical-order": true, | ||
"selector-class-pattern": null, | ||
"prettier/prettier": true | ||
}, | ||
"ignoreFiles": [ | ||
"**/node_modules/**", | ||
"**/dist/**", | ||
"**/build/**", | ||
"**/.next/**" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
FROM node:20-alpine AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS deps | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN \ | ||
if [ -f yarn.lock ]; then yarn run build; \ | ||
elif [ -f package-lock.json ]; then npm run build; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
# Setup Nginx and serve the built application with PM2 | ||
FROM node:20-alpine AS app | ||
|
||
WORKDIR /app | ||
|
||
# Install PM2 globally | ||
RUN npm install -g pm2 | ||
|
||
# Set environment variables | ||
ENV NODE_ENV=production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# Create a system user and group | ||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
# Install Nginx | ||
RUN apk update && apk add --no-cache nginx | ||
|
||
# Copy the Nginx configuration file | ||
COPY nginx-template.conf /etc/nginx/http.d/default.conf | ||
|
||
# Copy the PM2 config file | ||
COPY pm2.config.js /app/pm2.config.js | ||
|
||
# Copy the built Next.js app from the builder stage | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
# Set the correct permission for prerender cache | ||
# RUN mkdir -p .next && chown nextjs:nodejs .next | ||
|
||
# Copy the .env.production file | ||
COPY .env.production /app/.env.production | ||
|
||
# Switch to the non-root user | ||
# USER nextjs | ||
|
||
# Expose the port | ||
EXPOSE 3005 | ||
|
||
# Start Nginx and the Next.js app with PM2 | ||
CMD ["sh", "-c", "nginx && pm2-runtime start pm2.config.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/create-aelf-dapp/lib/generator/templates/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '1.0' | ||
|
||
services: | ||
create-aelf-dapp.nginx: | ||
container_name: create-aelf-dapp.nginx | ||
image: nginx:1.27.1 | ||
ports: | ||
- "3006:3006" | ||
volumes: | ||
- ./create-aelf-dapp.conf:/etc/nginx/conf.d/default.conf | ||
networks: | ||
- create-aelf-dapp_network | ||
restart: unless-stopped | ||
|
||
create-aelf-dapp.interface: | ||
container_name: create-aelf-dapp.interface | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3005:3005" | ||
networks: | ||
- create-aelf-dapp_network | ||
restart: unless-stopped | ||
|
||
networks: | ||
create-aelf-dapp_network: | ||
external: true |
18 changes: 0 additions & 18 deletions
18
apps/create-aelf-dapp/lib/generator/templates/jest.config.js
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
apps/create-aelf-dapp/lib/generator/templates/jest.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
// const nextJest = require('next/jest'); | ||
import nextJest from 'next/jest'; | ||
import type { Config } from 'jest'; | ||
|
||
/** @type {import('jest').Config} */ | ||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}); | ||
|
||
// Add any custom config to be passed to Jest | ||
const config: Config = { | ||
coverageProvider: 'v8', | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageReporters: ['json-summary', 'text'], | ||
testEnvironment: 'jsdom', | ||
// Add more setup options before each test is run | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
moduleNameMapper: { | ||
// '^@/(.*)$': '<rootDir>/src/$1', | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
'^lodash-es$': 'lodash', | ||
'^swiper$': '<rootDir>/._tests__/__mocks__/swiper.js', | ||
}, | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(swiper)/)', | ||
'node_modules/.pnpm/(?!(swiper)/)', | ||
], | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
// module.exports = createJestConfig(config); | ||
export default createJestConfig(config); |
Oops, something went wrong.