Skip to content

Commit d38cac4

Browse files
committed
refactor(core): Recreate project scaffolding
1 parent d6d7a36 commit d38cac4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+10727
-4616
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git
2+
**/dist
3+
**/node_modules
4+
**/db-data
5+
.vscode
6+
docs

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = space
9+
indent_size = 2
10+
trim_trailing_whitespace = true

.env.development.local.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ENABLE_ESLINT=true
2+
ENABLE_TYPESCRIPT=true
File renamed without changes.
File renamed without changes.

.eslintrc.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const { resolve } = require("node:path");
2+
3+
const project = resolve(process.cwd(), "tsconfig.json");
4+
5+
/** @type {import("eslint").Linter.Config} */
6+
module.exports = {
7+
root: true,
8+
extends: [
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:prettier/recommended",
11+
"prettier",
12+
require.resolve("@vercel/style-guide/eslint/next"),
13+
"next/core-web-vitals",
14+
],
15+
plugins: ["@typescript-eslint/eslint-plugin"],
16+
parser: "@typescript-eslint/parser",
17+
ignorePatterns: [
18+
".*.js",
19+
"*.setup.js",
20+
"*.config.js",
21+
"dist/",
22+
"coverage/",
23+
"node_modules/",
24+
],
25+
rules: {
26+
"@typescript-eslint/interface-name-prefix": "off",
27+
"@typescript-eslint/explicit-function-return-type": "off",
28+
"@typescript-eslint/explicit-module-boundary-types": "off",
29+
"@typescript-eslint/no-explicit-any": "off",
30+
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
31+
"@typescript-eslint/no-require-imports": "off",
32+
"@typescript-eslint/ban-ts-comment": "off",
33+
"@typescript-eslint/no-unused-vars": [
34+
"warn",
35+
{
36+
argsIgnorePattern: "^_",
37+
varsIgnorePattern: "^_",
38+
caughtErrorsIgnorePattern: "^_",
39+
},
40+
],
41+
"prettier/prettier": ["error", { singleQuote: false }],
42+
},
43+
globals: {
44+
React: true,
45+
JSX: true,
46+
},
47+
env: {
48+
node: true,
49+
browser: true,
50+
},
51+
plugins: ["only-warn"],
52+
settings: {
53+
"import/resolver": {
54+
typescript: {
55+
project,
56+
},
57+
},
58+
},
59+
overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }],
60+
};

.eslintrc.json

-3
This file was deleted.

.husky/commit-msg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
pnpm exec commitlint --edit $1

.husky/post-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm run lint && pnpx lint-staged

.lintst

Whitespace-only changes.

.lintstagedrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"*/**/*.{js,json,jsx,ts,tsx,mdx}": ["prettier --check"],
3+
"*/**/*.css": ["prettier --check", "stylelint"]
4+
}

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.16.0

.prettierignore

Whitespace-only changes.

.vscode/extensions.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"dbaeumer.vscode-eslint",
5+
"redhat.vscode-yaml",
6+
"vscode-icons-team.vscode-icons",
7+
"bradlc.vscode-tailwindcss",
8+
"yoavbls.pretty-ts-errors",
9+
"postman.postman-for-vscode",
10+
"christian-kohler.path-intellisense",
11+
"donjayamanne.githistory",
12+
"mhutchie.git-graph",
13+
"waderyan.gitblame",
14+
"dotenv.dotenv-vscode",
15+
"ms-azuretools.vscode-docker",
16+
"supabase.vscode-supabase-extension"
17+
]
18+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"eslint.workingDirectories": [
3+
{
4+
"mode": "auto"
5+
}
6+
],
7+
"tailwindCSS.experimental.classRegex": ["cn\\(([^)]+)\\)"]
8+
}

.yarnrc.yml

-1
This file was deleted.

Dockerfile

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# syntax=docker.io/docker/dockerfile:1
2+
3+
FROM node:20-alpine AS base
4+
5+
# Add Python and required packages
6+
RUN apk add --no-cache python3 py3-pip git
7+
8+
ENV PNPM_HOME="/pnpm"
9+
ENV PATH="$PNPM_HOME:$PATH"
10+
RUN apk add --no-cache libc6-compat
11+
RUN corepack enable && corepack prepare pnpm@9 --activate
12+
13+
# Install dependencies only when needed
14+
FROM base AS deps
15+
WORKDIR /app
16+
17+
# Copy package files
18+
COPY package.json pnpm-lock.yaml* .npmrc* ./
19+
RUN pnpm install --frozen-lockfile
20+
21+
# Rebuild the source code only when needed
22+
FROM base AS builder
23+
WORKDIR /app
24+
COPY --from=deps /app/node_modules ./node_modules
25+
COPY . .
26+
27+
# Generate Python documentation
28+
RUN python3 -m pip install --upgrade pip && \
29+
pip install sphinx==7.1.2 && \
30+
git clone https://github.com/pygame-community/pygame-ce.git && \
31+
cd pygame-ce && \
32+
python3 setup.py docs && \
33+
cd .. && \
34+
python3 utils/generate_docs.py
35+
36+
# Build Next.js app
37+
RUN pnpm run build
38+
39+
# Production image, copy all the files and run next
40+
FROM base AS runner
41+
WORKDIR /app
42+
43+
ENV NODE_ENV=production
44+
# Uncomment the following line in case you want to disable telemetry during runtime.
45+
# ENV NEXT_TELEMETRY_DISABLED=1
46+
47+
RUN addgroup --system --gid 1001 nodejs
48+
RUN adduser --system --uid 1001 nextjs
49+
50+
COPY --from=builder /app/public ./public
51+
52+
# Automatically leverage output traces to reduce image size
53+
# https://nextjs.org/docs/advanced-features/output-file-tracing
54+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
55+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
56+
57+
USER nextjs
58+
59+
EXPOSE 3000
60+
61+
ENV PORT=3000
62+
63+
# server.js is created by next build from the standalone output
64+
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
65+
ENV HOSTNAME="0.0.0.0"
66+
CMD ["node", "server.js"]

commitlint.config.ts

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import type { UserConfig } from "@commitlint/types";
2+
import { RuleConfigSeverity } from "@commitlint/types";
3+
4+
const types = [
5+
"feat", // new user-facing feature (must have (or may introduce a new) scope)
6+
"enha", // enhancement of any kind (must have a scope)
7+
"fix", // bug fix (must have a scope)
8+
"docs", // documentation enhancement (same as 'enha(docs)')
9+
"style", // code style enhancement (same as 'enha(style)')
10+
11+
"refactor", // refactoring code enhancement (must have a scope)
12+
13+
"perf", // performance improvement enhancement (must have a scope)
14+
"test", // testing enhancement (must have a scope)
15+
"build", // build enhancement
16+
"ci", // ci enhancement
17+
"chore", // Relating to repository maintenance
18+
"revert", // reverting a previous commit
19+
"merge", // merging branches
20+
];
21+
22+
const typesRequiringScope = ["feat", "enha", "fix", "refactor", "perf", "test"];
23+
24+
/**
25+
* Scopes are used to describe the area of the project that the commit affects.
26+
* They are used to group commits together and to provide context to the commit
27+
* message.
28+
*
29+
* The scopes are divided into two categories: areas and topics. Areas are
30+
* broader categories that describe the area of the project that the commit
31+
* affects, while topics are more specific categories that describe the
32+
* functionality or purpose of the commit.
33+
*
34+
* For example, commits that add a new feature to the frontend user interface
35+
* might look like this:
36+
*
37+
* - `feat(ui,auth): add forgot password functionality ...`
38+
* - `feat(ui,projects): Implement project url sharing ...`
39+
*
40+
* Another example might be a commit that adds a new feature to the backend API related to
41+
* user authentication:
42+
*
43+
* `feat(api,auth): use new endpoint for user authentication ...`
44+
*
45+
*/
46+
const scopes = {
47+
areas: [
48+
/* Frontend */
49+
"ui", // UI related changes
50+
51+
"api", // REST API related changes
52+
"supabase", // Supabase related changes
53+
54+
/* Others */
55+
"core", // core changes neither specific to frontend nor backend
56+
"docs", // documentation changes
57+
"style", // code style changes
58+
"webserver", // webserver and proxying changes
59+
"version", // version bumping
60+
],
61+
topics: [
62+
"auth",
63+
"blog",
64+
"analytics",
65+
"automation",
66+
"faq",
67+
"projects",
68+
"roles",
69+
"settings",
70+
"inbox",
71+
],
72+
};
73+
74+
const Configuration: UserConfig = {
75+
extends: ["@commitlint/config-conventional"],
76+
rules: {
77+
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"],
78+
"type-empty": [RuleConfigSeverity.Error, "never"],
79+
"type-enum": [RuleConfigSeverity.Error, "always", types],
80+
"subject-case": [RuleConfigSeverity.Disabled, "always", "lower-case"],
81+
"subject-empty": [RuleConfigSeverity.Error, "never"],
82+
"subject-outer-whitespace": [RuleConfigSeverity.Error, "always"],
83+
"scope-rich": [RuleConfigSeverity.Error, "always"],
84+
"body-max-line-length": [RuleConfigSeverity.Warning, "always", 150],
85+
"header-max-length": [RuleConfigSeverity.Warning, "always", 100],
86+
},
87+
plugins: [
88+
{
89+
rules: {
90+
"scope-rich": (commit, when) => {
91+
const errorMessages: string[] = [
92+
"scope is required for commit of type" +
93+
`[${typesRequiringScope.join(", ")}]`,
94+
`scope must be one of the areas [${scopes.areas.join(", ")}], ` +
95+
"optionally paired with one of the topics " +
96+
`[${scopes.topics.join(", ")}], ` +
97+
"all separated by a comma (no spaces)",
98+
];
99+
100+
const scope = commit.scope ?? "";
101+
const scopeRequired = typesRequiringScope.includes(commit.type!);
102+
103+
if (when !== "always" || !scopeRequired) return [true, undefined];
104+
105+
if (scopeRequired && !scope.length) {
106+
return [false, errorMessages[0]];
107+
}
108+
109+
if (scope.includes(",")) {
110+
// area must be provided and valid, and if topics are provided,
111+
// they must be valid
112+
const [area, ...topics] = scope.split(",");
113+
if (
114+
!scopes.areas.includes(area) ||
115+
topics.some((topic) => !scopes.topics.includes(topic))
116+
) {
117+
return [false, errorMessages[1]];
118+
}
119+
} else if (!scopes.areas.includes(scope)) {
120+
return [false, errorMessages[1]];
121+
}
122+
123+
return [true, undefined];
124+
},
125+
"subject-outer-whitespace": (commit, when) => {
126+
const errorMessages: string[] = [
127+
"subject must not have more than one preceding whitespace character",
128+
];
129+
130+
if (when !== "always" || !commit.subject) return [true, undefined];
131+
132+
if ([" ", "\t", "\n", "\r"].includes(commit.subject[0])) {
133+
return [false, errorMessages[0]];
134+
}
135+
136+
return [true, undefined];
137+
},
138+
},
139+
},
140+
],
141+
};
142+
143+
export default Configuration;

components.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

docker-compose.dev.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: pygame.community
2+
3+
services:
4+
pygame-community:
5+
container_name: pygame-community
6+
build:
7+
context: .
8+
dockerfile: ./Dockerfile
9+
restart: always
10+
ports:
11+
- 3000:3000

docker-compose.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pygame.community
2+
3+
services:
4+
frontend:
5+
container_name: frontend
6+
depends_on:
7+
- backend
8+
build:
9+
context: .
10+
dockerfile: ./Dockerfile
11+
args:
12+
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
13+
- NEXT_PUBLIC_SUPABASE_PROJECT_URL=${NEXT_PUBLIC_SUPABASE_PROJECT_URL}
14+
- NEXT_PUBLIC_SUPABASE_PUBLIC_ANON_KEY=${NEXT_PUBLIC_SUPABASE_PUBLIC_ANON_KEY}
15+
- NODE_ENV=${NODE_ENV:-production}
16+
restart: always
17+
ports:
18+
- 3000:3000
19+
# networks:
20+
# - appnet
21+
environment:
22+
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-https://api.pygame.community}
23+
- NEXT_PUBLIC_SUPABASE_PROJECT_URL=${NEXT_PUBLIC_SUPABASE_PROJECT_URL:-https://kong.pygame.community}
24+
- NEXT_PUBLIC_SUPABASE_PUBLIC_ANON_KEY=${NEXT_PUBLIC_SUPABASE_PUBLIC_ANON_KEY}
25+
- NODE_ENV=${NODE_ENV:-production}

0 commit comments

Comments
 (0)