Skip to content

Commit ecbc717

Browse files
chore: Pnpm (#447)
1 parent b41cace commit ecbc717

File tree

20 files changed

+10254
-15379
lines changed

20 files changed

+10254
-15379
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AUTH0_AUDIENCE=https://gataersamla.no
44
AUTH0_CALLBACK=https://gataersamla.no/callback
55
AUTH0_CLIENT_SECRET=xxx
66
AUTH0_COOKIE_SECRET=123
7-
APP_DATABASE_URL=postgres://postgres:password@localhost:5433/postgres
7+
APP_DATABASE_URL=sqlite.db
88

99
DEFAULT_CONTINGENT_SIZE= 600
1010
CONTINGENT_BANK= 000.0123.1230.123

.github/workflows/deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: ⬇️ Checkout repo
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020
- name: 👀 Read app name
2121
uses: SebRollen/[email protected]
2222
id: app_name
2323
with:
24-
file: 'fly.toml'
25-
field: 'app'
24+
file: "fly.toml"
25+
field: "app"
2626
- name: 🎈 Setup Fly
2727
uses: superfly/flyctl-actions/setup-flyctl@master
2828
- name: 🚀 Deploy Production
2929
run: flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
3030
env:
31-
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
31+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.github/workflows/e2e.yml

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,76 @@
1-
name: 'pr'
1+
name: "pr"
22

33
on:
44
push:
55
branches:
6-
- '**'
7-
- '!main'
6+
- "**"
7+
- "!main"
88
workflow_dispatch:
99

10-
1110
jobs:
1211
lint-fe:
1312
name: Lint Frontend
1413
runs-on: "ubuntu-latest"
1514
timeout-minutes: 5
1615
steps:
17-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
17+
- name: Setup pnpm
18+
uses: pnpm/action-setup@v4
1819
with:
19-
ref: ${{ github.ref }}
20-
21-
- name: Setup node
22-
uses: actions/setup-node@v4
20+
package_json_file: "package.json"
21+
run_install: false
22+
- name: Setup Node
23+
uses: actions/setup-node@v6
2324
with:
24-
node-version: 22
25-
26-
- name: Download deps
27-
uses: bahmutov/npm-install@v1
28-
29-
- name: Run linting checks
30-
run: |
31-
npm run typecheck && npm run lint:ci
25+
node-version-file: "package.json"
26+
cache: "pnpm"
27+
cache-dependency-path: "pnpm-lock.yaml"
28+
- run: pnpm i --frozen-lockfile
29+
- run: pnpm typecheck
30+
- run: pnpm lint:ci
3231
knip:
3332
name: Knip Frontend
3433
runs-on: "ubuntu-latest"
3534
timeout-minutes: 5
3635
steps:
37-
- uses: actions/checkout@v4
38-
39-
- name: Setup node
40-
uses: actions/setup-node@v4
36+
- uses: actions/checkout@v5
37+
- name: Setup pnpm
38+
uses: pnpm/action-setup@v4
4139
with:
42-
node-version: 22
43-
44-
- name: Download deps
45-
uses: bahmutov/npm-install@v1
40+
package_json_file: "package.json"
41+
run_install: false
42+
- name: Setup Node
43+
uses: actions/setup-node@v6
44+
with:
45+
node-version-file: "package.json"
46+
cache: "pnpm"
47+
cache-dependency-path: "pnpm-lock.yaml"
48+
- run: pnpm i --frozen-lockfile
49+
- run: pnpm typecheck
50+
- run: pnpm knip
4651

47-
- name: Run frontend tests
48-
run: |
49-
npm run typecheck && npm run knip
5052
integration:
5153
name: Integration tests
5254
runs-on: "ubuntu-latest"
5355
timeout-minutes: 5
5456
steps:
55-
- uses: actions/checkout@v4
56-
57-
- name: Setup node
58-
uses: actions/setup-node@v4
57+
- uses: actions/checkout@v5
58+
- name: Setup pnpm
59+
uses: pnpm/action-setup@v4
5960
with:
60-
node-version: 22
61-
62-
- name: Download deps
63-
uses: bahmutov/npm-install@v1
61+
package_json_file: "package.json"
62+
run_install: false
63+
- name: Setup Node
64+
uses: actions/setup-node@v6
65+
with:
66+
node-version-file: "package.json"
67+
cache: "pnpm"
68+
cache-dependency-path: "pnpm-lock.yaml"
69+
- run: pnpm i --frozen-lockfile
6470

6571
- name: Run frontend tests
6672
run: |
67-
npm run test:ci
73+
pnpm test:ci
6874
6975
playwright:
7076
runs-on: ubuntu-latest
@@ -81,28 +87,30 @@ jobs:
8187
MAKE_FIRST_USER_ADMIN: true
8288

8389
steps:
84-
- name: Cloning repo
85-
uses: actions/checkout@v4
86-
87-
- name: Setup node
88-
uses: actions/setup-node@v4
90+
- uses: actions/checkout@v5
91+
- name: Setup pnpm
92+
uses: pnpm/action-setup@v4
8993
with:
90-
node-version: 22
91-
92-
- name: Download deps
93-
uses: bahmutov/npm-install@v1
94+
package_json_file: "package.json"
95+
run_install: false
96+
- name: Setup Node
97+
uses: actions/setup-node@v6
98+
with:
99+
node-version-file: "package.json"
100+
cache: "pnpm"
101+
cache-dependency-path: "pnpm-lock.yaml"
102+
- run: pnpm i --frozen-lockfile
94103

95104
- name: Build frontend
96-
run: |
97-
npm run build
105+
run: pnpm build
98106

99107
- name: Run migrations
100108
run: |
101-
npm run db:migrate
109+
pnpm db:migrate
102110
103111
- name: Install playwright
104112
run: |
105-
npx playwright install --with-deps chromium
113+
pnpm exec playwright install --with-deps chromium
106114
107115
- name: Run E2E tests
108116
env:
@@ -118,7 +126,7 @@ jobs:
118126
# DEBUG: pw:webserver
119127
# DEBUG: pw:api
120128
run: |
121-
npx playwright test
129+
pnpm exec playwright test
122130
123131
- name: Upload test results
124132
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ playwright-report
1515
playwright/.cache/
1616
*StorageState.json
1717
sqlite*.db
18+
sqlite*.db-journal
1819
/data
1920
/db-backups
2021
.react-router/

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"eslint.useFlatConfig": true,
3+
"typescript.tsdk": "node_modules/typescript/lib",
4+
"editor.quickSuggestions": {
5+
"strings": "on"
6+
},
7+
"eslint.enable": true,
8+
"eslint.format.enable": true,
9+
"editor.codeActionsOnSave": {
10+
"source.fixAll.eslint": "explicit"
11+
}
12+
}

Dockerfile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM node:22.16-alpine3.20 as base
1+
FROM node:24-bookworm-slim AS base
22

33
LABEL fly_launch_runtime="Remix"
4+
RUN npm install -g pnpm
45

56
# Remix app lives here
67
WORKDIR /app
@@ -10,30 +11,28 @@ ENV NODE_ENV=production
1011
ENV APP_DATABASE_URL=/data/sqlite.db
1112
ENV IMAGE_DIR=/data/images
1213

14+
FROM base AS production-deps
15+
WORKDIR /app
16+
ADD package.json pnpm-lock.yaml ./
17+
RUN pnpm i --prod --frozen-lockfile
18+
1319

1420
# Throw-away build stage to reduce size of final image
1521
FROM base as build
16-
17-
# Install node modules
18-
COPY --link package-lock.json package.json ./
19-
RUN npm ci --include=dev
20-
22+
ADD package.json pnpm-lock.yaml ./
23+
RUN pnpm i --frozen-lockfile
2124
# Copy application code
2225
COPY --link . .
23-
2426
# Build application
25-
RUN npm run build
26-
27-
# Remove development dependencies
28-
RUN npm prune --omit=dev
27+
RUN pnpm build
2928

3029

3130
# Final stage for app image
3231
FROM base
3332

3433
# Copy built application
3534
COPY --from=build /app/build /app/build
36-
COPY --from=build /app/node_modules /app/node_modules
35+
COPY --from=production-deps /app/node_modules /app/node_modules
3736
COPY --from=build /app/package.json /app/package.json
3837
COPY --from=build /app/server.mjs /app/server.mjs
3938
COPY --from=build /app/migrations /app/migrations

app/.server/db/gataEvent.ts

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import { RoleName } from "~/utils/roleUtils";
2323
import type { User } from "./user";
2424

2525
export const insertEvent = async (event: Omit<typeof gataEvent.$inferInsert, "createdBy"> & { createdBy: string }) => {
26-
return await db.transaction(async (tx) => {
27-
const [{ eventId }] = await tx.insert(gataEvent).values(event).returning({ eventId: gataEvent.id });
28-
await tx.insert(eventOrganizer).values({ userId: event.createdBy, eventId });
29-
return eventId;
30-
});
26+
const [{ eventId }] = await db.insert(gataEvent).values(event).returning({ eventId: gataEvent.id });
27+
await db.insert(eventOrganizer).values({ userId: event.createdBy, eventId });
28+
return eventId;
3129
};
3230

3331
export const getUpCommingEvents = async (loggedInUserId: string) => {
@@ -142,11 +140,9 @@ type InsertPollVote = {
142140
};
143141

144142
export const insertPollVote = async ({ userId, pollId, options }: InsertPollVote) => {
145-
await db.transaction(async (tx) => {
146-
await tx.delete(pollVote).where(and(eq(pollVote.userId, userId), eq(pollVote.pollId, pollId)));
147-
if (!options.length) return;
148-
await tx.insert(pollVote).values(options.map((pollOptionId) => ({ pollId, pollOptionId, userId })));
149-
});
143+
await db.delete(pollVote).where(and(eq(pollVote.userId, userId), eq(pollVote.pollId, pollId)));
144+
if (!options.length) return;
145+
await db.insert(pollVote).values(options.map((pollOptionId) => ({ pollId, pollOptionId, userId })));
150146
};
151147

152148
export const updatePoll = async (pollId: number, values: Partial<typeof poll.$inferInsert>) => {
@@ -158,29 +154,23 @@ export const deletePoll = async (pollId: number) => {
158154
};
159155

160156
export const insertNewPoll = async (eventId: number, pollValues: typeof poll.$inferInsert, options: string[]) => {
161-
await db.transaction(async (tx) => {
162-
const [{ pollId }] = await tx.insert(poll).values(pollValues).returning({ pollId: poll.id });
163-
await tx.insert(eventPolls).values({ pollId, eventId });
164-
await tx.insert(pollOption).values(options.map((textOption) => ({ textOption, pollId })));
165-
});
157+
const [{ pollId }] = await db.insert(poll).values(pollValues).returning({ pollId: poll.id });
158+
await db.insert(eventPolls).values({ pollId, eventId });
159+
await db.insert(pollOption).values(options.map((textOption) => ({ textOption, pollId })));
166160
};
167161

168162
export const insertPollOptions = async (pollId: number, options: string[]) => {
169163
await db.insert(pollOption).values(options.map((textOption) => ({ textOption, pollId })));
170164
};
171165

172166
export const updateOrganizers = async (eventId: number, organizers: string[]) => {
173-
await db.transaction(async (tx) => {
174-
await tx.delete(eventOrganizer).where(eq(eventOrganizer.eventId, eventId));
175-
await tx.insert(eventOrganizer).values(organizers.map((userId) => ({ userId, eventId })));
176-
});
167+
await db.delete(eventOrganizer).where(eq(eventOrganizer.eventId, eventId));
168+
await db.insert(eventOrganizer).values(organizers.map((userId) => ({ userId, eventId })));
177169
};
178170

179171
export const insertCloudinaryImage = async (eventId: number, values: typeof cloudinaryImage.$inferInsert) => {
180-
return await db.transaction(async (tx) => {
181-
await tx.insert(cloudinaryImage).values(values);
182-
await tx.insert(eventCloudinaryImages).values({ eventId, cloudId: values.cloudId });
183-
});
172+
await db.insert(cloudinaryImage).values(values);
173+
await db.insert(eventCloudinaryImages).values({ eventId, cloudId: values.cloudId });
184174
};
185175

186176
export const getEventCloudinaryImages = async (eventId: number) => {
@@ -265,25 +255,18 @@ export const getEventMessages = async (eventId: number) => {
265255
};
266256

267257
export const insertEventMessage = async (eventId: number, userId: string, message: string) => {
268-
return await db.transaction(async (tx) => {
269-
const [{ messageId }] = await tx
270-
.insert(messages)
271-
.values({ userId, message })
272-
.returning({ messageId: messages.id });
273-
await tx.insert(eventMessages).values({ messageId, eventId });
274-
return messageId;
275-
});
258+
const [{ messageId }] = await db.insert(messages).values({ userId, message }).returning({ messageId: messages.id });
259+
await db.insert(eventMessages).values({ messageId, eventId });
260+
return messageId;
276261
};
277262

278263
export const insertEventMessageReply = async (userId: string, messageId: number, reply: string) => {
279-
return await db.transaction(async (tx) => {
280-
const [{ replyId }] = await tx
281-
.insert(messages)
282-
.values({ userId, message: reply })
283-
.returning({ replyId: messages.id });
284-
await tx.insert(messageReplies).values({ messageId, replyId });
285-
return replyId;
286-
});
264+
const [{ replyId }] = await db
265+
.insert(messages)
266+
.values({ userId, message: reply })
267+
.returning({ replyId: messages.id });
268+
await db.insert(messageReplies).values({ messageId, replyId });
269+
return replyId;
287270
};
288271

289272
export const insertMessageLike = async (userId: string, messageId: number, type: string) => {

0 commit comments

Comments
 (0)