create-projx 1.6.5 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -19
- package/dist/{baseline-PZM4KJJW.js → baseline-FHOZNS4D.js} +2 -2
- package/dist/{chunk-6YRBHJ2V.js → chunk-HAT7D4G2.js} +25 -8
- package/dist/{chunk-XQ7FE4U3.js → chunk-IMZKHDIL.js} +161 -19
- package/dist/index.js +1499 -276
- package/dist/{utils-AVKSTHIF.js → utils-BZGSJ7XZ.js} +5 -1
- package/package.json +13 -7
- package/src/addons/orms/drizzle/express/src/app.ts +81 -0
- package/src/addons/orms/drizzle/express/src/modules/_base/auto-routes.ts +278 -0
- package/src/addons/orms/drizzle/express/src/modules/_base/index.ts +20 -0
- package/src/addons/orms/drizzle/express/src/server.ts +32 -0
- package/src/addons/orms/drizzle/express/tests/app.test.ts +24 -0
- package/src/addons/orms/drizzle/express/vitest.config.ts +20 -0
- package/src/addons/orms/drizzle/fastify/src/app.ts +90 -0
- package/src/addons/orms/drizzle/fastify/src/modules/_base/auto-routes.ts +268 -0
- package/src/addons/orms/drizzle/fastify/src/modules/_base/index.ts +20 -0
- package/src/addons/orms/drizzle/fastify/tests/modules/app.test.ts +20 -0
- package/src/addons/orms/drizzle/fastify/vitest.config.ts +31 -0
- package/src/addons/orms/drizzle/gen-entity/express-router.ts +21 -0
- package/src/addons/orms/drizzle/gen-entity/express-test.ts +61 -0
- package/src/addons/orms/drizzle/gen-entity/fastify-router.ts +19 -0
- package/src/addons/orms/drizzle/gen-entity/fastify-test.ts +87 -0
- package/src/addons/orms/drizzle/manifest.json +52 -0
- package/src/addons/orms/drizzle/shared/drizzle.config.ts +12 -0
- package/src/addons/orms/drizzle/shared/src/db/client.ts +17 -0
- package/src/addons/orms/drizzle/shared/src/db/schema.ts +14 -0
- package/src/addons/orms/drizzle/shared/src/modules/_base/query-engine.ts +115 -0
- package/src/addons/orms/drizzle/shared/src/modules/_base/registry.ts +15 -0
- package/src/addons/orms/sequelize/express/src/app.ts +82 -0
- package/src/addons/orms/sequelize/express/src/modules/_base/auto-routes.ts +226 -0
- package/src/addons/orms/sequelize/express/src/modules/_base/index.ts +20 -0
- package/src/addons/orms/sequelize/express/src/server.ts +32 -0
- package/src/addons/orms/sequelize/express/tests/app.test.ts +24 -0
- package/src/addons/orms/sequelize/express/vitest.config.ts +20 -0
- package/src/addons/orms/sequelize/fastify/src/app.ts +83 -0
- package/src/addons/orms/sequelize/fastify/src/modules/_base/auto-routes.ts +216 -0
- package/src/addons/orms/sequelize/fastify/src/modules/_base/index.ts +20 -0
- package/src/addons/orms/sequelize/fastify/tests/modules/app.test.ts +20 -0
- package/src/addons/orms/sequelize/fastify/vitest.config.ts +31 -0
- package/src/addons/orms/sequelize/gen-entity/express-router.ts +17 -0
- package/src/addons/orms/sequelize/gen-entity/express-test.ts +65 -0
- package/src/addons/orms/sequelize/gen-entity/fastify-router.ts +19 -0
- package/src/addons/orms/sequelize/gen-entity/fastify-test.ts +89 -0
- package/src/addons/orms/sequelize/gen-entity/model.ts +21 -0
- package/src/addons/orms/sequelize/manifest.json +53 -0
- package/src/addons/orms/sequelize/shared/scripts/db-sync.ts +14 -0
- package/src/addons/orms/sequelize/shared/src/db/client.ts +19 -0
- package/src/addons/orms/sequelize/shared/src/models/index.ts +9 -0
- package/src/addons/orms/sequelize/shared/src/modules/_base/query-engine.ts +101 -0
- package/src/addons/orms/sequelize/shared/src/modules/_base/registry.ts +15 -0
- package/src/addons/orms/typeorm/express/src/app.ts +82 -0
- package/src/addons/orms/typeorm/express/src/modules/_base/auto-routes.ts +249 -0
- package/src/addons/orms/typeorm/express/src/modules/_base/index.ts +19 -0
- package/src/addons/orms/typeorm/express/src/server.ts +43 -0
- package/src/addons/orms/typeorm/express/tests/app.test.ts +24 -0
- package/src/addons/orms/typeorm/express/vitest.config.ts +20 -0
- package/src/addons/orms/typeorm/fastify/src/app.ts +86 -0
- package/src/addons/orms/typeorm/fastify/src/modules/_base/auto-routes.ts +239 -0
- package/src/addons/orms/typeorm/fastify/src/modules/_base/index.ts +19 -0
- package/src/addons/orms/typeorm/fastify/tests/modules/app.test.ts +20 -0
- package/src/addons/orms/typeorm/fastify/vitest.config.ts +31 -0
- package/src/addons/orms/typeorm/gen-entity/entity.ts +21 -0
- package/src/addons/orms/typeorm/gen-entity/express-router.ts +17 -0
- package/src/addons/orms/typeorm/gen-entity/express-test.ts +66 -0
- package/src/addons/orms/typeorm/gen-entity/fastify-router.ts +19 -0
- package/src/addons/orms/typeorm/gen-entity/fastify-test.ts +89 -0
- package/src/addons/orms/typeorm/manifest.json +53 -0
- package/src/addons/orms/typeorm/shared/scripts/db-sync.ts +14 -0
- package/src/addons/orms/typeorm/shared/src/db/data-source.ts +21 -0
- package/src/addons/orms/typeorm/shared/src/entities/index.ts +8 -0
- package/src/addons/orms/typeorm/shared/src/modules/_base/query-engine.ts +94 -0
- package/src/addons/orms/typeorm/shared/src/modules/_base/registry.ts +15 -0
- package/src/addons/orms/typeorm/shared/tsconfig.json +16 -0
- package/src/templates/README.md.ejs +21 -4
- package/src/templates/ci.yml.ejs +167 -37
- package/src/templates/docker-compose.yml.ejs +72 -5
- package/src/templates/pre-commit.ejs +28 -4
- package/src/templates/setup.sh.ejs +75 -1
- package/src/templates/docker-compose.dev.yml.ejs +0 -189
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ILike, type FindOptionsOrder, type FindOptionsWhere } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export interface ParsedQuery {
|
|
4
|
+
page: number;
|
|
5
|
+
page_size: number;
|
|
6
|
+
order_by?: string;
|
|
7
|
+
search?: string;
|
|
8
|
+
filters: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const RESERVED = new Set(['page', 'page_size', 'order_by', 'search']);
|
|
12
|
+
|
|
13
|
+
export function parseRawQuery(rawQs: string): ParsedQuery {
|
|
14
|
+
const params = new URLSearchParams(rawQs);
|
|
15
|
+
const page = Math.max(1, Number(params.get('page')) || 1);
|
|
16
|
+
const page_size = Math.min(
|
|
17
|
+
100,
|
|
18
|
+
Math.max(1, Number(params.get('page_size')) || 10),
|
|
19
|
+
);
|
|
20
|
+
const filters: Record<string, string> = {};
|
|
21
|
+
for (const [key, value] of params.entries()) {
|
|
22
|
+
if (RESERVED.has(key)) continue;
|
|
23
|
+
filters[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
page,
|
|
27
|
+
page_size,
|
|
28
|
+
order_by: params.get('order_by') ?? undefined,
|
|
29
|
+
search: params.get('search') ?? undefined,
|
|
30
|
+
filters,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function buildWhere<T>(
|
|
35
|
+
columns: Set<string>,
|
|
36
|
+
filters: Record<string, string>,
|
|
37
|
+
): FindOptionsWhere<T> {
|
|
38
|
+
const where: Record<string, unknown> = {};
|
|
39
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
40
|
+
if (!columns.has(key)) continue;
|
|
41
|
+
where[key] = value;
|
|
42
|
+
}
|
|
43
|
+
return where as FindOptionsWhere<T>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function buildSearchWheres<T>(
|
|
47
|
+
searchableFields: string[],
|
|
48
|
+
term: string | undefined,
|
|
49
|
+
): FindOptionsWhere<T>[] {
|
|
50
|
+
if (!term) return [];
|
|
51
|
+
const trimmed = term.trim();
|
|
52
|
+
if (!trimmed || searchableFields.length === 0) return [];
|
|
53
|
+
const pattern = `%${trimmed}%`;
|
|
54
|
+
return searchableFields.map(
|
|
55
|
+
(field) => ({ [field]: ILike(pattern) }) as FindOptionsWhere<T>,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function buildOrder<T>(
|
|
60
|
+
columns: Set<string>,
|
|
61
|
+
orderBy: string | undefined,
|
|
62
|
+
): FindOptionsOrder<T> {
|
|
63
|
+
if (!orderBy) return {} as FindOptionsOrder<T>;
|
|
64
|
+
const out: Record<string, 'ASC' | 'DESC'> = {};
|
|
65
|
+
for (const raw of orderBy.split(',')) {
|
|
66
|
+
const term = raw.trim();
|
|
67
|
+
if (!term) continue;
|
|
68
|
+
const descOrder = term.startsWith('-');
|
|
69
|
+
const fieldName = descOrder ? term.slice(1) : term;
|
|
70
|
+
if (!columns.has(fieldName)) continue;
|
|
71
|
+
out[fieldName] = descOrder ? 'DESC' : 'ASC';
|
|
72
|
+
}
|
|
73
|
+
return out as FindOptionsOrder<T>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface PaginationMeta {
|
|
77
|
+
current_page: number;
|
|
78
|
+
page_size: number;
|
|
79
|
+
total_records: number;
|
|
80
|
+
total_pages: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function buildPagination(
|
|
84
|
+
page: number,
|
|
85
|
+
page_size: number,
|
|
86
|
+
total: number,
|
|
87
|
+
): PaginationMeta {
|
|
88
|
+
return {
|
|
89
|
+
current_page: page,
|
|
90
|
+
page_size,
|
|
91
|
+
total_records: total,
|
|
92
|
+
total_pages: Math.max(1, Math.ceil(total / page_size)),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RegisteredEntity {
|
|
2
|
+
name: string;
|
|
3
|
+
apiPrefix: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const entityList: RegisteredEntity[] = [];
|
|
7
|
+
|
|
8
|
+
export function registerInRegistry(entry: RegisteredEntity): void {
|
|
9
|
+
if (entityList.some((existing) => existing.name === entry.name)) return;
|
|
10
|
+
entityList.push(entry);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function listEntities(): RegisteredEntity[] {
|
|
14
|
+
return [...entityList].sort((a, b) => a.name.localeCompare(b.name));
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"declaration": false,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"emitDecoratorMetadata": true,
|
|
13
|
+
"types": ["node"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src", "tests", "scripts"]
|
|
16
|
+
}
|
|
@@ -10,7 +10,10 @@ Scaffolded with [Projx](https://github.com/ukanhaupa/projx).
|
|
|
10
10
|
| **<%= paths.fastapi %>/** | FastAPI, SQLAlchemy, Alembic, uvicorn |
|
|
11
11
|
<% } %>
|
|
12
12
|
<% if (components.includes('fastify')) { %>
|
|
13
|
-
| **<%= paths.fastify %>/** | Fastify, Prisma
|
|
13
|
+
| **<%= paths.fastify %>/** | Fastify, <%= orm === 'drizzle' ? 'Drizzle' : 'Prisma' %>, TypeBox, TypeScript |
|
|
14
|
+
<% } %>
|
|
15
|
+
<% if (components.includes('express')) { %>
|
|
16
|
+
| **<%= paths.express %>/** | Express 5, TypeScript, <%= orm === 'drizzle' ? 'Drizzle' : 'Prisma, auto-entity CRUD' %> |
|
|
14
17
|
<% } %>
|
|
15
18
|
<% if (components.includes('frontend')) { %>
|
|
16
19
|
| **<%= paths.frontend %>/** | React 19, TypeScript, Vite, React Router |
|
|
@@ -30,8 +33,9 @@ Scaffolded with [Projx](https://github.com/ukanhaupa/projx).
|
|
|
30
33
|
## Getting Started
|
|
31
34
|
|
|
32
35
|
```bash
|
|
33
|
-
./scripts/setup.sh
|
|
34
|
-
|
|
36
|
+
./scripts/setup.sh # Install all dependencies
|
|
37
|
+
# Ensure PostgreSQL is running locally, then run `<%= pm.runDev %>` in each service.
|
|
38
|
+
# Production stack: docker compose up --build
|
|
35
39
|
```
|
|
36
40
|
<% if (components.includes('fastapi')) { %>
|
|
37
41
|
|
|
@@ -48,11 +52,21 @@ API docs at `http://localhost:7860/docs`.
|
|
|
48
52
|
### <%= paths.fastify %>/
|
|
49
53
|
|
|
50
54
|
```bash
|
|
51
|
-
cd <%= paths.fastify %> && cp .env.example .env && <%= pm.install %> && <%= pm.exec
|
|
55
|
+
cd <%= paths.fastify %> && cp .env.example .env && <%= pm.install %> && <%= orm === 'drizzle' ? `${pm.exec} drizzle-kit push --force` : `${pm.exec} prisma migrate dev` %> && <%= pm.run %> dev
|
|
52
56
|
```
|
|
53
57
|
|
|
54
58
|
API docs at `http://localhost:3000/docs`.
|
|
55
59
|
<% } %>
|
|
60
|
+
<% if (components.includes('express')) { %>
|
|
61
|
+
|
|
62
|
+
### <%= paths.express %>/
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd <%= paths.express %> && cp .env.example .env && <%= pm.install %><%= orm === 'drizzle' ? ` && ${pm.exec} drizzle-kit push --force` : '' %> && <%= pm.run %> dev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Health check at `http://localhost:3000/api/health`.
|
|
69
|
+
<% } %>
|
|
56
70
|
<% if (components.includes('frontend')) { %>
|
|
57
71
|
|
|
58
72
|
### <%= paths.frontend %>/
|
|
@@ -79,6 +93,9 @@ cd <%= paths.fastapi %> && uv run pytest
|
|
|
79
93
|
<% if (components.includes('fastify')) { %>
|
|
80
94
|
cd <%= paths.fastify %> && <%= pm.run %> test
|
|
81
95
|
<% } %>
|
|
96
|
+
<% if (components.includes('express')) { %>
|
|
97
|
+
cd <%= paths.express %> && <%= pm.run %> test
|
|
98
|
+
<% } %>
|
|
82
99
|
<% if (components.includes('frontend')) { %>
|
|
83
100
|
cd <%= paths.frontend %> && <%= pm.exec %> vitest run
|
|
84
101
|
<% } %>
|
package/src/templates/ci.yml.ejs
CHANGED
|
@@ -5,13 +5,16 @@ on:
|
|
|
5
5
|
branches: [main]
|
|
6
6
|
push:
|
|
7
7
|
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pull-requests: read
|
|
8
13
|
|
|
9
14
|
jobs:
|
|
10
15
|
changes:
|
|
11
16
|
name: Detect changes
|
|
12
17
|
runs-on: ubuntu-latest
|
|
13
|
-
permissions:
|
|
14
|
-
pull-requests: read
|
|
15
18
|
outputs:
|
|
16
19
|
<% for (const inst of fastapiInstances) { %>
|
|
17
20
|
<%= inst.path %>: ${{ steps.filter.outputs.<%= inst.path %> }}
|
|
@@ -19,6 +22,9 @@ jobs:
|
|
|
19
22
|
<% for (const inst of fastifyInstances) { %>
|
|
20
23
|
<%= inst.path %>: ${{ steps.filter.outputs.<%= inst.path %> }}
|
|
21
24
|
<% } %>
|
|
25
|
+
<% for (const inst of expressInstances) { %>
|
|
26
|
+
<%= inst.path %>: ${{ steps.filter.outputs.<%= inst.path %> }}
|
|
27
|
+
<% } %>
|
|
22
28
|
<% for (const inst of frontendInstances) { %>
|
|
23
29
|
<%= inst.path %>: ${{ steps.filter.outputs.<%= inst.path %> }}
|
|
24
30
|
<% } %>
|
|
@@ -32,8 +38,8 @@ jobs:
|
|
|
32
38
|
<%= inst.path %>: ${{ steps.filter.outputs.<%= inst.path %> }}
|
|
33
39
|
<% } %>
|
|
34
40
|
steps:
|
|
35
|
-
- uses: actions/checkout@v5
|
|
36
|
-
- uses: dorny/paths-filter@v3
|
|
41
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
42
|
+
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3
|
|
37
43
|
id: filter
|
|
38
44
|
with:
|
|
39
45
|
filters: |
|
|
@@ -45,6 +51,10 @@ jobs:
|
|
|
45
51
|
<%= inst.path %>:
|
|
46
52
|
- '<%= inst.path %>/**'
|
|
47
53
|
<% } %>
|
|
54
|
+
<% for (const inst of expressInstances) { %>
|
|
55
|
+
<%= inst.path %>:
|
|
56
|
+
- '<%= inst.path %>/**'
|
|
57
|
+
<% } %>
|
|
48
58
|
<% for (const inst of frontendInstances) { %>
|
|
49
59
|
<%= inst.path %>:
|
|
50
60
|
- '<%= inst.path %>/**'
|
|
@@ -66,88 +76,204 @@ jobs:
|
|
|
66
76
|
name: Secret scan
|
|
67
77
|
runs-on: ubuntu-latest
|
|
68
78
|
steps:
|
|
69
|
-
- uses: actions/checkout@v5
|
|
79
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
70
80
|
with:
|
|
71
81
|
fetch-depth: 0
|
|
72
|
-
- uses: gitleaks/gitleaks-action@v2
|
|
82
|
+
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
|
|
73
83
|
env:
|
|
74
84
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
85
|
+
- run: python3 scripts/style-check.py frontend/src
|
|
75
86
|
<% for (const inst of fastapiInstances) { %>
|
|
76
87
|
|
|
77
88
|
<%= inst.path %>:
|
|
78
|
-
name: <%= inst.display %> (format + lint + typecheck +
|
|
89
|
+
name: <%= inst.display %> (format + lint + typecheck + audit)
|
|
79
90
|
needs: changes
|
|
80
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
91
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
81
92
|
runs-on: ubuntu-latest
|
|
93
|
+
services:
|
|
94
|
+
postgres:
|
|
95
|
+
image: postgres:16
|
|
96
|
+
env:
|
|
97
|
+
POSTGRES_USER: postgres
|
|
98
|
+
POSTGRES_PASSWORD: postgres
|
|
99
|
+
POSTGRES_DB: ci_test
|
|
100
|
+
ports:
|
|
101
|
+
- 5432:5432
|
|
102
|
+
options: >-
|
|
103
|
+
--health-cmd pg_isready
|
|
104
|
+
--health-interval 5s
|
|
105
|
+
--health-timeout 5s
|
|
106
|
+
--health-retries 5
|
|
82
107
|
defaults:
|
|
83
108
|
run:
|
|
84
109
|
working-directory: <%= inst.path %>
|
|
110
|
+
env:
|
|
111
|
+
SQLALCHEMY_DATABASE_URI: postgresql+asyncpg://postgres:postgres@localhost:5432/ci_test
|
|
112
|
+
JWT_PROVIDER: shared_secret
|
|
113
|
+
JWT_SECRET: ci-test-secret # gitleaks:allow
|
|
114
|
+
JWT_ALGORITHMS: HS256
|
|
85
115
|
steps:
|
|
86
|
-
- uses: actions/checkout@v5
|
|
87
|
-
- uses: astral-sh/setup-uv@v4
|
|
116
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
117
|
+
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
|
|
88
118
|
- run: uv sync --group dev
|
|
89
119
|
- run: uv run ruff format --check src tests
|
|
90
120
|
- run: uv run ruff check src tests
|
|
91
121
|
- run: uv run mypy
|
|
92
|
-
-
|
|
93
|
-
|
|
122
|
+
- name: Audit Python dependencies
|
|
123
|
+
run: |
|
|
124
|
+
run_pip_audit() {
|
|
125
|
+
for attempt in 1 2 3; do
|
|
126
|
+
if uv run pip-audit --ignore-vuln CVE-2026-3219; then
|
|
127
|
+
return 0
|
|
128
|
+
fi
|
|
129
|
+
if [ "$attempt" -eq 3 ]; then
|
|
130
|
+
return 1
|
|
131
|
+
fi
|
|
132
|
+
sleep $((attempt * 5))
|
|
133
|
+
done
|
|
134
|
+
}
|
|
135
|
+
run_pip_audit
|
|
94
136
|
<% } %>
|
|
95
137
|
<% for (const inst of fastifyInstances) { %>
|
|
96
138
|
|
|
97
139
|
<%= inst.path %>:
|
|
98
|
-
name: <%= inst.display %> (format + lint + typecheck + audit)
|
|
140
|
+
name: <%= inst.display %> (format + lint + typecheck + build + audit)
|
|
141
|
+
needs: changes
|
|
142
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
services:
|
|
145
|
+
postgres:
|
|
146
|
+
image: postgres:16
|
|
147
|
+
env:
|
|
148
|
+
POSTGRES_USER: postgres
|
|
149
|
+
POSTGRES_PASSWORD: postgres
|
|
150
|
+
POSTGRES_DB: ci_test
|
|
151
|
+
ports:
|
|
152
|
+
- 5432:5432
|
|
153
|
+
options: >-
|
|
154
|
+
--health-cmd pg_isready
|
|
155
|
+
--health-interval 5s
|
|
156
|
+
--health-timeout 5s
|
|
157
|
+
--health-retries 5
|
|
158
|
+
defaults:
|
|
159
|
+
run:
|
|
160
|
+
working-directory: <%= inst.path %>
|
|
161
|
+
env:
|
|
162
|
+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/ci_test
|
|
163
|
+
JWT_SECRET: ci-test-secret # gitleaks:allow
|
|
164
|
+
steps:
|
|
165
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
166
|
+
<% if (pm === 'pnpm') { %>
|
|
167
|
+
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
|
|
168
|
+
with:
|
|
169
|
+
version: 10
|
|
170
|
+
<% } %>
|
|
171
|
+
<% if (pm === 'bun') { %>
|
|
172
|
+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
173
|
+
<% } %>
|
|
174
|
+
<% if (pm !== 'bun') { %>
|
|
175
|
+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
|
176
|
+
with:
|
|
177
|
+
node-version: 22
|
|
178
|
+
cache: <%= pm.name %>
|
|
179
|
+
cache-dependency-path: <%= inst.path %>/<%= pm.lockfile %>
|
|
180
|
+
<% } %>
|
|
181
|
+
- run: <%= pm.ci %>
|
|
182
|
+
<% if (orm === 'drizzle') { %>
|
|
183
|
+
- run: <%= pm.exec %> drizzle-kit push --force
|
|
184
|
+
<% } else if (orm === 'sequelize' || orm === 'typeorm') { %>
|
|
185
|
+
- run: <%= pm.exec %> tsx scripts/db-sync.ts
|
|
186
|
+
<% } else { %>
|
|
187
|
+
- run: <%= pm.prismaExec %> generate
|
|
188
|
+
- run: <%= pm.prismaExec %> migrate deploy
|
|
189
|
+
<% } %>
|
|
190
|
+
- run: <%= pm.exec %> prettier --check .
|
|
191
|
+
- run: <%= pm.exec %> eslint .
|
|
192
|
+
- run: <%= pm.exec %> tsc --noEmit
|
|
193
|
+
- run: <%= pm.run %> build
|
|
194
|
+
- run: <%= pm.audit %>
|
|
195
|
+
<% } %>
|
|
196
|
+
<% for (const inst of expressInstances) { %>
|
|
197
|
+
|
|
198
|
+
<%= inst.path %>:
|
|
199
|
+
name: <%= inst.display %> (format + lint + typecheck + build + test + audit)
|
|
99
200
|
needs: changes
|
|
100
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
201
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
101
202
|
runs-on: ubuntu-latest
|
|
203
|
+
services:
|
|
204
|
+
postgres:
|
|
205
|
+
image: postgres:16
|
|
206
|
+
env:
|
|
207
|
+
POSTGRES_USER: postgres
|
|
208
|
+
POSTGRES_PASSWORD: postgres
|
|
209
|
+
POSTGRES_DB: ci_test
|
|
210
|
+
ports:
|
|
211
|
+
- 5432:5432
|
|
212
|
+
options: >-
|
|
213
|
+
--health-cmd pg_isready
|
|
214
|
+
--health-interval 5s
|
|
215
|
+
--health-timeout 5s
|
|
216
|
+
--health-retries 5
|
|
102
217
|
defaults:
|
|
103
218
|
run:
|
|
104
219
|
working-directory: <%= inst.path %>
|
|
220
|
+
env:
|
|
221
|
+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/ci_test
|
|
105
222
|
steps:
|
|
106
|
-
- uses: actions/checkout@v5
|
|
223
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
107
224
|
<% if (pm === 'pnpm') { %>
|
|
108
|
-
- uses: pnpm/action-setup@v4
|
|
225
|
+
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
|
|
109
226
|
with:
|
|
110
227
|
version: 10
|
|
111
228
|
<% } %>
|
|
112
229
|
<% if (pm === 'bun') { %>
|
|
113
|
-
- uses: oven-sh/setup-bun@v2
|
|
230
|
+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
114
231
|
<% } %>
|
|
115
232
|
<% if (pm !== 'bun') { %>
|
|
116
|
-
- uses: actions/setup-node@v5
|
|
233
|
+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
|
117
234
|
with:
|
|
118
|
-
node-version:
|
|
235
|
+
node-version: 22
|
|
119
236
|
cache: <%= pm.name %>
|
|
120
237
|
cache-dependency-path: <%= inst.path %>/<%= pm.lockfile %>
|
|
121
238
|
<% } %>
|
|
122
239
|
- run: <%= pm.ci %>
|
|
240
|
+
<% if (orm === 'drizzle') { %>
|
|
241
|
+
- run: <%= pm.exec %> drizzle-kit push --force
|
|
242
|
+
<% } else if (orm === 'sequelize' || orm === 'typeorm') { %>
|
|
243
|
+
- run: <%= pm.exec %> tsx scripts/db-sync.ts
|
|
244
|
+
<% } else { %>
|
|
123
245
|
- run: <%= pm.prismaExec %> generate
|
|
246
|
+
- run: <%= pm.prismaExec %> migrate deploy
|
|
247
|
+
<% } %>
|
|
124
248
|
- run: <%= pm.exec %> prettier --check .
|
|
125
249
|
- run: <%= pm.exec %> eslint .
|
|
126
250
|
- run: <%= pm.exec %> tsc --noEmit
|
|
251
|
+
- run: <%= pm.run %> build
|
|
252
|
+
- run: <%= pm.exec %> vitest run --coverage.enabled=false
|
|
127
253
|
- run: <%= pm.audit %>
|
|
128
254
|
<% } %>
|
|
129
255
|
<% for (const inst of frontendInstances) { %>
|
|
130
256
|
|
|
131
257
|
<%= inst.path %>:
|
|
132
|
-
name: <%= inst.display %> (format + lint + typecheck + audit)
|
|
258
|
+
name: <%= inst.display %> (format + lint + typecheck + build + audit)
|
|
133
259
|
needs: changes
|
|
134
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
260
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
135
261
|
runs-on: ubuntu-latest
|
|
136
262
|
defaults:
|
|
137
263
|
run:
|
|
138
264
|
working-directory: <%= inst.path %>
|
|
139
265
|
steps:
|
|
140
|
-
- uses: actions/checkout@v5
|
|
266
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
141
267
|
<% if (pm === 'pnpm') { %>
|
|
142
|
-
- uses: pnpm/action-setup@v4
|
|
268
|
+
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
|
|
143
269
|
with:
|
|
144
270
|
version: 10
|
|
145
271
|
<% } %>
|
|
146
272
|
<% if (pm === 'bun') { %>
|
|
147
|
-
- uses: oven-sh/setup-bun@v2
|
|
273
|
+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
148
274
|
<% } %>
|
|
149
275
|
<% if (pm !== 'bun') { %>
|
|
150
|
-
- uses: actions/setup-node@v5
|
|
276
|
+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
|
151
277
|
with:
|
|
152
278
|
node-version: 22
|
|
153
279
|
cache: <%= pm.name %>
|
|
@@ -157,50 +283,54 @@ jobs:
|
|
|
157
283
|
- run: <%= pm.exec %> prettier --check .
|
|
158
284
|
- run: <%= pm.exec %> eslint 'src/**/*.{ts,tsx}'
|
|
159
285
|
- run: <%= pm.exec %> tsc --noEmit
|
|
286
|
+
- run: <%= pm.run %> build
|
|
287
|
+
- run: bash scripts/check-bundle-size.sh
|
|
160
288
|
- run: <%= pm.audit %>
|
|
161
289
|
<% } %>
|
|
162
290
|
<% for (const inst of mobileInstances) { %>
|
|
163
291
|
|
|
164
292
|
<%= inst.path %>:
|
|
165
|
-
name: <%= inst.display %> (format + analyze)
|
|
293
|
+
name: <%= inst.display %> (format + analyze + test + coverage)
|
|
166
294
|
needs: changes
|
|
167
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
295
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
168
296
|
runs-on: ubuntu-latest
|
|
169
297
|
defaults:
|
|
170
298
|
run:
|
|
171
299
|
working-directory: <%= inst.path %>
|
|
172
300
|
steps:
|
|
173
|
-
- uses: actions/checkout@v5
|
|
174
|
-
- uses: subosito/flutter-action@v2
|
|
301
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
302
|
+
- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
|
|
175
303
|
with:
|
|
176
304
|
channel: stable
|
|
177
305
|
- run: flutter pub get
|
|
178
306
|
- run: dart run build_runner build --delete-conflicting-outputs
|
|
179
307
|
- run: dart format --set-exit-if-changed .
|
|
180
308
|
- run: dart analyze --fatal-infos
|
|
309
|
+
- run: flutter test --coverage
|
|
310
|
+
- run: bash scripts/check-coverage.sh
|
|
181
311
|
<% } %>
|
|
182
312
|
<% for (const inst of e2eInstances) { %>
|
|
183
313
|
|
|
184
314
|
<%= inst.path %>:
|
|
185
315
|
name: <%= inst.display %> (format + lint + typecheck + audit)
|
|
186
316
|
needs: changes
|
|
187
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
317
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
188
318
|
runs-on: ubuntu-latest
|
|
189
319
|
defaults:
|
|
190
320
|
run:
|
|
191
321
|
working-directory: <%= inst.path %>
|
|
192
322
|
steps:
|
|
193
|
-
- uses: actions/checkout@v5
|
|
323
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
194
324
|
<% if (pm === 'pnpm') { %>
|
|
195
|
-
- uses: pnpm/action-setup@v4
|
|
325
|
+
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
|
|
196
326
|
with:
|
|
197
327
|
version: 10
|
|
198
328
|
<% } %>
|
|
199
329
|
<% if (pm === 'bun') { %>
|
|
200
|
-
- uses: oven-sh/setup-bun@v2
|
|
330
|
+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
201
331
|
<% } %>
|
|
202
332
|
<% if (pm !== 'bun') { %>
|
|
203
|
-
- uses: actions/setup-node@v5
|
|
333
|
+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
|
204
334
|
with:
|
|
205
335
|
node-version: 22
|
|
206
336
|
cache: <%= pm.name %>
|
|
@@ -217,14 +347,14 @@ jobs:
|
|
|
217
347
|
<%= inst.path %>:
|
|
218
348
|
name: <%= inst.display %> (fmt + validate)
|
|
219
349
|
needs: changes
|
|
220
|
-
if: needs.changes.outputs.<%= inst.path %> == 'true'
|
|
350
|
+
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.<%= inst.path %> == 'true'
|
|
221
351
|
runs-on: ubuntu-latest
|
|
222
352
|
defaults:
|
|
223
353
|
run:
|
|
224
354
|
working-directory: <%= inst.path %>/stack
|
|
225
355
|
steps:
|
|
226
|
-
- uses: actions/checkout@v5
|
|
227
|
-
- uses: hashicorp/setup-terraform@v3
|
|
356
|
+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
|
|
357
|
+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
|
|
228
358
|
with:
|
|
229
359
|
terraform_version: '1.11'
|
|
230
360
|
- run: terraform fmt -check -recursive
|
|
@@ -30,12 +30,17 @@ services:
|
|
|
30
30
|
retries: 3
|
|
31
31
|
start_period: 15s
|
|
32
32
|
networks:
|
|
33
|
-
|
|
33
|
+
app-network:
|
|
34
|
+
<% if (fastifyInstances.length === 0 && expressInstances.length === 0 && inst.path === fastapiInstances[0].path) { %>
|
|
35
|
+
aliases:
|
|
36
|
+
- backend
|
|
37
|
+
<% } %>
|
|
34
38
|
<% } %>
|
|
35
39
|
<% for (const inst of fastifyInstances) { %>
|
|
36
40
|
<%= inst.path %>-migrate:
|
|
37
|
-
build:
|
|
38
|
-
|
|
41
|
+
build:
|
|
42
|
+
context: ./<%= inst.path %>
|
|
43
|
+
target: migrate
|
|
39
44
|
env_file:
|
|
40
45
|
- ./<%= inst.path %>/.env
|
|
41
46
|
networks:
|
|
@@ -51,13 +56,61 @@ services:
|
|
|
51
56
|
<%= inst.path %>-migrate:
|
|
52
57
|
condition: service_completed_successfully
|
|
53
58
|
healthcheck:
|
|
54
|
-
test:
|
|
59
|
+
test:
|
|
60
|
+
[
|
|
61
|
+
"CMD",
|
|
62
|
+
"node",
|
|
63
|
+
"-e",
|
|
64
|
+
"require('http').get('http://localhost:3000/api/health', r => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))",
|
|
65
|
+
]
|
|
55
66
|
interval: 30s
|
|
56
67
|
timeout: 10s
|
|
57
68
|
retries: 3
|
|
58
69
|
start_period: 15s
|
|
70
|
+
networks:
|
|
71
|
+
app-network:
|
|
72
|
+
<% if (inst.path === fastifyInstances[0].path) { %>
|
|
73
|
+
aliases:
|
|
74
|
+
- backend
|
|
75
|
+
<% } %>
|
|
76
|
+
<% } %>
|
|
77
|
+
<% for (const inst of expressInstances) { %>
|
|
78
|
+
<%= inst.path %>-migrate:
|
|
79
|
+
build:
|
|
80
|
+
context: ./<%= inst.path %>
|
|
81
|
+
target: migrate
|
|
82
|
+
env_file:
|
|
83
|
+
- ./<%= inst.path %>/.env
|
|
59
84
|
networks:
|
|
60
85
|
- app-network
|
|
86
|
+
<%= inst.path %>:
|
|
87
|
+
build: ./<%= inst.path %>
|
|
88
|
+
expose:
|
|
89
|
+
- "3000"
|
|
90
|
+
env_file:
|
|
91
|
+
- ./<%= inst.path %>/.env
|
|
92
|
+
restart: unless-stopped
|
|
93
|
+
depends_on:
|
|
94
|
+
<%= inst.path %>-migrate:
|
|
95
|
+
condition: service_completed_successfully
|
|
96
|
+
healthcheck:
|
|
97
|
+
test:
|
|
98
|
+
[
|
|
99
|
+
"CMD",
|
|
100
|
+
"node",
|
|
101
|
+
"-e",
|
|
102
|
+
"require('http').get('http://localhost:3000/api/health', r => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))",
|
|
103
|
+
]
|
|
104
|
+
interval: 30s
|
|
105
|
+
timeout: 10s
|
|
106
|
+
retries: 3
|
|
107
|
+
start_period: 15s
|
|
108
|
+
networks:
|
|
109
|
+
app-network:
|
|
110
|
+
<% if (fastifyInstances.length === 0 && inst.path === expressInstances[0].path) { %>
|
|
111
|
+
aliases:
|
|
112
|
+
- backend
|
|
113
|
+
<% } %>
|
|
61
114
|
<% } %>
|
|
62
115
|
<% for (const inst of frontendInstances) { %>
|
|
63
116
|
<%= inst.path %>:
|
|
@@ -65,6 +118,8 @@ services:
|
|
|
65
118
|
context: ./<%= inst.path %>
|
|
66
119
|
args:
|
|
67
120
|
VITE_API_URL: ""
|
|
121
|
+
environment:
|
|
122
|
+
DOMAIN: ${DOMAIN:-localhost}
|
|
68
123
|
ports:
|
|
69
124
|
- "80:80"
|
|
70
125
|
- "443:443"
|
|
@@ -75,6 +130,10 @@ services:
|
|
|
75
130
|
depends_on:
|
|
76
131
|
<%= fastifyInstances[0].path %>:
|
|
77
132
|
condition: service_healthy
|
|
133
|
+
<% } else if (expressInstances.length > 0) { %>
|
|
134
|
+
depends_on:
|
|
135
|
+
<%= expressInstances[0].path %>:
|
|
136
|
+
condition: service_healthy
|
|
78
137
|
<% } else if (fastapiInstances.length > 0) { %>
|
|
79
138
|
depends_on:
|
|
80
139
|
<%= fastapiInstances[0].path %>:
|
|
@@ -82,7 +141,15 @@ services:
|
|
|
82
141
|
<% } %>
|
|
83
142
|
restart: unless-stopped
|
|
84
143
|
healthcheck:
|
|
85
|
-
test:
|
|
144
|
+
test:
|
|
145
|
+
[
|
|
146
|
+
"CMD",
|
|
147
|
+
"wget",
|
|
148
|
+
"--spider",
|
|
149
|
+
"-q",
|
|
150
|
+
"--no-check-certificate",
|
|
151
|
+
"https://127.0.0.1/",
|
|
152
|
+
]
|
|
86
153
|
interval: 30s
|
|
87
154
|
timeout: 5s
|
|
88
155
|
retries: 3
|