Skip to content

Commit

Permalink
Switch to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Oct 28, 2024
1 parent 39e70fe commit 9fb6312
Show file tree
Hide file tree
Showing 16 changed files with 4,273 additions and 3,475 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ tests
README.md
LICENSE

.yarnrc

biome.json
tsconfig.build.json
tsconfig.json
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache: pnpm

- name: Install dependencies
run: yarn install --pure-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests
run: yarn test
run: pnpm test

- name: Build app
run: yarn build
run: pnpm build
12 changes: 7 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache: pnpm

- name: Install dependencies
run: yarn install --pure-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests
run: yarn test
run: pnpm test

- name: Build app
run: yarn build
run: pnpm build

- name: Configure AWS Credentials
if: ${{ github.repository == 'swan-io/url-shortener' }}
Expand Down Expand Up @@ -55,7 +57,7 @@ jobs:
- name: Deploy
if: ${{ github.repository == 'swan-io/url-shortener' }}
run: yarn deploy-ci
run: pnpm deploy-ci
env:
TAG: master-${{ github.sha }}
DEPLOY_SWAN_TOKEN: ${{ secrets.DEPLOY_SWAN_TOKEN }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache: pnpm

- name: Install dependencies
run: yarn install --pure-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests
run: yarn test
run: pnpm test

- name: Build app
run: yarn build
run: pnpm build

- name: Configure AWS Credentials
if: ${{ github.repository == 'swan-io/url-shortener' }}
Expand Down Expand Up @@ -65,7 +67,7 @@ jobs:
- name: Deploy
if: ${{ github.repository == 'swan-io/url-shortener' }}
run: yarn deploy-ci
run: pnpm deploy-ci
env:
TAG: preprod-${{ steps.version.outputs.version }}
DEPLOY_SWAN_TOKEN: ${{ secrets.DEPLOY_SWAN_TOKEN }}
Expand All @@ -76,4 +78,4 @@ jobs:
DEPLOY_APP_NAME: url-shortener

- name: Create GitHub prerelease
run: yarn tsx scripts/release/createPrerelease.ts
run: pnpm tsx scripts/release/createPrerelease.ts
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache: pnpm

- name: Install dependencies
run: yarn install --pure-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests
run: yarn test
run: pnpm test

- name: Build app
run: yarn build
run: pnpm build

- name: Configure AWS Credentials
if: ${{ github.repository == 'swan-io/url-shortener' }}
Expand Down Expand Up @@ -57,7 +59,7 @@ jobs:
- name: Deploy preprod
if: ${{ github.repository == 'swan-io/url-shortener' }}
run: yarn deploy-ci
run: pnpm deploy-ci
env:
TAG: preprod-${{ github.ref_name }}
DEPLOY_SWAN_TOKEN: ${{ secrets.DEPLOY_SWAN_TOKEN }}
Expand All @@ -69,7 +71,7 @@ jobs:

- name: Deploy prod
if: ${{ github.repository == 'swan-io/url-shortener' }}
run: yarn deploy-ci
run: pnpm deploy-ci
env:
TAG: prod-${{ github.ref_name }}
DEPLOY_SWAN_TOKEN: ${{ secrets.DEPLOY_SWAN_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node-linker=hoisted
save-exact=true
auto-install-peers=false
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
2 changes: 0 additions & 2 deletions .yarnrc

This file was deleted.

5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM node:latest AS builder
WORKDIR /app
COPY . .
RUN yarn install --production
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN pnpm install --prod --frozen-lockfile

FROM cgr.dev/chainguard/node:latest
WORKDIR /app
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple URL shortener server backed by PostgreSQL.

## Getting started

You need to install [yarn](https://classic.yarnpkg.com/en/docs/install#mac-stable).
You need to install [pnpm 9.9.0](https://pnpm.io/installation#installing-a-specific-version).

### Clone

Expand All @@ -15,7 +15,7 @@ $ git clone git@github.com/swan-io/url-shortener.git
### Install

```bash
$ yarn
$ pnpm install
```

### Environment variables
Expand All @@ -27,21 +27,21 @@ At the project root, you should find a `.env.example` file. Copy its contents to
To start the development server, run:

```bash
$ yarn dev
$ pnpm dev
```

## Building

To build the production codebase, run:

```bash
$ yarn build
$ pnpm build
```

## Testing

Run tests (using [vitest](https://vitest.dev) and [pgmock](https://github.com/stackframe-projects/pgmock)):

```bash
$ yarn test
$ pnpm test
```
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignore": ["./dist"]
},
Expand Down
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
"description": "Swan URL shortener server",
"version": "0.3.0",
"license": "MIT",
"packageManager": "pnpm@9.9.0",
"engines": {
"node": ">=20.9.0",
"yarn": "^1.22.0"
"pnpm": "9.9.0"
},
"repository": {
"type": "git",
"url": "https://github.com/swan-io/url-shortener"
},
"scripts": {
"docker:up": "docker compose up -d && yarn migrate",
"docker:up": "docker compose up -d && pnpm migrate",
"docker:down": "docker compose down -v",
"docker:build": "yarn build && docker build -t url-shortener:latest .",
"build": "yarn clean && prettier '**/*' -u -c && yarn lint && yarn codegen && tsc -p tsconfig.build.json",
"docker:build": "pnpm build && docker build -t url-shortener:latest .",
"build": "pnpm clean && prettier '**/*' -u -c && pnpm lint && pnpm codegen && tsc -p tsconfig.build.json",
"clean": "rm -rf dist src/database/generated",
"deploy-ci": "tsx scripts/deploy/deploy.ts",
"release": "tsx scripts/release/createPullRequest.ts",
"codegen": "prisma generate",
"dev": "yarn codegen && tsx watch --clear-screen=false src",
"dev": "pnpm codegen && tsx watch --clear-screen=false src",
"dump-schema": "prisma migrate diff --from-empty --to-schema-datasource prisma/schema.prisma --script > tests/schema.sql",
"format": "prettier '**/*' -u -w && prisma format",
"lint": "biome check . --files-ignore-unknown=true --no-errors-on-unmatched",
Expand All @@ -39,19 +40,19 @@
"@fastify/sensible": "6.0.1",
"@fastify/type-provider-typebox": "5.0.0",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/core": "1.26.0",
"@opentelemetry/exporter-trace-otlp-http": "0.53.0",
"@opentelemetry/instrumentation": "0.53.0",
"@opentelemetry/instrumentation-fastify": "0.40.0",
"@opentelemetry/instrumentation-http": "0.53.0",
"@opentelemetry/instrumentation-pino": "0.42.0",
"@opentelemetry/propagator-jaeger": "1.26.0",
"@opentelemetry/resources": "1.26.0",
"@opentelemetry/sdk-trace-base": "1.26.0",
"@opentelemetry/sdk-trace-node": "1.26.0",
"@opentelemetry/core": "1.27.0",
"@opentelemetry/exporter-trace-otlp-http": "0.54.0",
"@opentelemetry/instrumentation": "0.54.0",
"@opentelemetry/instrumentation-fastify": "0.41.0",
"@opentelemetry/instrumentation-http": "0.54.0",
"@opentelemetry/instrumentation-pino": "0.43.0",
"@opentelemetry/propagator-jaeger": "1.27.0",
"@opentelemetry/resources": "1.27.0",
"@opentelemetry/sdk-trace-base": "1.27.0",
"@opentelemetry/sdk-trace-node": "1.27.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@sinclair/typebox": "0.33.16",
"@swan-io/boxed": "3.0.0",
"@sinclair/typebox": "0.33.17",
"@swan-io/boxed": "3.1.1",
"close-with-grace": "2.1.0",
"dayjs": "1.11.13",
"dotenv": "16.4.5",
Expand All @@ -60,17 +61,17 @@
"fastify-metrics": "12.1.0",
"fastify-plugin": "5.0.1",
"kysely": "0.27.4",
"pg": "8.13.0",
"picocolors": "1.1.0",
"pino-pretty": "11.2.2",
"prisma": "5.20.0",
"pg": "8.13.1",
"picocolors": "1.1.1",
"pino-pretty": "11.3.0",
"prisma": "5.21.1",
"prisma-kysely": "1.8.0",
"toad-scheduler": "3.0.1",
"valienv": "0.7.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.3",
"@types/node": "20.16.11",
"@biomejs/biome": "1.9.4",
"@types/node": "20.17.1",
"@types/pg": "8.11.10",
"@types/prompts": "2.4.9",
"@types/semver": "7.5.8",
Expand All @@ -82,6 +83,6 @@
"tsx": "4.16.5",
"type-fest": "4.26.1",
"typescript": "5.6.3",
"vitest": "2.1.2"
"vitest": "2.1.4"
}
}
Loading

0 comments on commit 9fb6312

Please sign in to comment.