Skip to content

Commit

Permalink
chore: migrate to pnpm (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 authored Aug 31, 2023
1 parent 148edd7 commit 7575ccf
Show file tree
Hide file tree
Showing 25 changed files with 26,253 additions and 24,564 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Thanks for opening a PR! Your contribution is much appreciated!

## Translations

- [ ] `.json` files are formatted: `yarn format`
- [ ] `.json` files are formatted: `pnpm format`
- [ ] Translations are correct
- [ ] New translation? It's been added to `i18n.config.mjs`
31 changes: 23 additions & 8 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,38 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js 18.x
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: 18.x
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn
run: pnpm install

- name: Build packages
run: yarn turbo run build --filter="{packages/**/**}"
run: pnpm turbo run build --filter="{packages/**/**}"
env:
NODE_OPTIONS: --max-old-space-size=6144

Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn
run: pnpm install

- name: Run lint
run: yarn lint
run: pnpm lint
35 changes: 24 additions & 11 deletions .github/workflows/test-builds-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,46 @@ jobs:
node-version: [18.x]

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn
run: pnpm install

- name: Build packages
run: yarn turbo run build --filter="{packages/**/**}"
run: pnpm turbo run build --filter="{packages/**/**}"
env:
NODE_OPTIONS: --max-old-space-size=6144

- name: Build apps
run: yarn turbo run build --filter="{apps/**/**}"
run: pnpm turbo run build --filter="{apps/**/**}"
env:
NODE_OPTIONS: --max-old-space-size=6144

- name: Run turbo typecheck
run: yarn turbo run typecheck
run: pnpm turbo run typecheck

- name: Run turbo test
run: yarn turbo run test --parallel
run: pnpm turbo run test --parallel
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
.next
yarn-error.log
dist
.env

Expand All @@ -20,14 +19,6 @@ apps/client/public/sounds/*.mp3
# eslint
.eslintcache

# yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# typescript
tsconfig.tsbuildinfo

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.0.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

8 changes: 4 additions & 4 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ WORKDIR /snailycad

COPY . ./

RUN yarn config set httpTimeout 1200000 && \
RUN pnpm config set httpTimeout 1200000 && \
npx turbo prune --scope=@snailycad/api --docker && \
yarn install
pnpm install

RUN yarn turbo run build --filter=@snailycad/api
RUN pnpm turbo run build --filter=@snailycad/api

ENV NODE_ENV="production"

CMD ["yarn", "workspace", "@snailycad/api", "start"]
CMD ["pnpm", "workspace", "@snailycad/api", "start"]
22 changes: 13 additions & 9 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "@snailycad/api",
"version": "1.68.7",
"scripts": {
"watch": "yarn prisma generate && yarn nodemon --watch \"./src/**/*.ts\" --ignore \"node_modules/**/*\" --exec node --loader ts-node/esm src/main.ts",
"start": "yarn prisma migrate deploy && yarn prisma generate && node --loader ts-node/esm src/main.ts",
"format": "yarn prisma format",
"generate": "yarn prisma generate",
"typecheck": "yarn run generate && tsc --noEmit",
"watch": "pnpm prisma generate && pnpm nodemon --watch \"./src/**/*.ts\" --ignore \"node_modules/**/*\" --exec node --loader ts-node/esm src/main.ts",
"start": "pnpm prisma migrate deploy && pnpm prisma generate && node --loader ts-node/esm src/main.ts",
"format": "pnpm prisma format",
"generate": "pnpm prisma generate",
"typecheck": "pnpm generate && tsc --noEmit",
"copy-env": "node ../../scripts/copy-env.mjs --api",
"test:watch": "yarn vitest --watch",
"test": "yarn vitest run"
"test:watch": "pnpm vitest --watch",
"test": "pnpm vitest run"
},
"devDependencies": {
"@swc/core": "^1.3.76",
Expand All @@ -20,21 +20,22 @@
"@types/cookie": "^0.5.1",
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.13",
"@types/ejs": "^3.1.2",
"@types/express": "^4.17.17",
"@types/glob": "^8.1.0",
"@types/jsonwebtoken": "9.0.2",
"@types/multer": "^1.4.7",
"@types/node": "^20.4.9",
"@types/qrcode": "^1.5.1",
"@types/sharp": "^0.31.1",
"@vitest/coverage-c8": "^0.33.0",
"dotenv": "^16.3.1",
"esbuild": "^0.17.19",
"esbuild-register": "^3.4.2",
"multer": "^1.4.5-lts.1",
"regenerator-runtime": "^0.14.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"tslib": "^2.6.1",
"typescript": "^5.1.6",
"vite": "^4.4.9",
"vitest": "^0.34.1"
Expand All @@ -43,7 +44,7 @@
"@discordjs/rest": "^2.0.0",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.1.1",
"@sentry/node": "^7.63.0",
"@sentry/node": "^7.64.0",
"@snailycad/audit-logger": "workspace:*",
"@snailycad/config": "^1.68.7",
"@snailycad/image-data-uri": "^3.2.0",
Expand All @@ -58,8 +59,11 @@
"@tsed/di": "^7.34.2",
"@tsed/exceptions": "^7.34.2",
"@tsed/json-mapper": "^7.34.2",
"@tsed/logger": "^6.6.2",
"@tsed/platform-exceptions": "^7.34.2",
"@tsed/platform-express": "^7.34.2",
"@tsed/platform-middlewares": "^7.34.6",
"@tsed/platform-params": "^7.34.6",
"@tsed/schema": "^7.34.2",
"@tsed/socketio": "^7.34.2",
"@tsed/swagger": "^7.34.2",
Expand Down
18 changes: 11 additions & 7 deletions apps/api/src/controllers/admin/admin-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Prisma, WhitelistStatus } from "@prisma/client";
import { UsePermissions } from "middlewares/use-permissions";
import { defaultPermissions, Permissions } from "@snailycad/permissions";
import type { GetAdminDashboardData } from "@snailycad/types/api";
import axios from "axios";
import { request } from "undici";
import { getCADVersion } from "@snailycad/utils/version";

export const ONE_DAY = 60 * 60 * 24;
Expand Down Expand Up @@ -112,10 +112,12 @@ export class AdminController {
async getChangelog(@Res() res: Res) {
try {
const version = await getCADVersion();
const response = await axios({
url: `https://api.github.com/repos/SnailyCAD/snaily-cadv4/releases/tags/${version?.currentVersion}`,
headers: { accept: "application/vnd.github+json" },
});
const response = await request(
`https://api.github.com/repos/SnailyCAD/snaily-cadv4/releases/tags/${version?.currentVersion}`,
{
headers: { accept: "application/vnd.github+json" },
},
);

res.setHeader(
"Cache-Control",
Expand All @@ -126,8 +128,10 @@ export class AdminController {
return this.changelogBody;
}

this.changelogBody = response.data.body;
const json = response.data as { body: string };
const body = (await response.body.json()) as { body: string };

this.changelogBody = body.body;
const json = body.body;
return json;
} catch (e) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions apps/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ WORKDIR /snailycad

COPY . ./

RUN yarn config set httpTimeout 1200000 && \
RUN pnpm config set httpTimeout 1200000 && \
npx turbo prune --scope=@snailycad/client --docker && \
yarn install
pnpm install

RUN yarn turbo run build --filter=@snailycad/client
RUN pnpm turbo run build --filter=@snailycad/client

ENV NODE_ENV="production"

CMD ["yarn", "workspace", "@snailycad/client", "start"]
CMD ["pnpm", "workspace", "@snailycad/client", "start"]
24 changes: 14 additions & 10 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
"version": "1.68.7",
"sideEffects": false,
"scripts": {
"dev": " yarn next dev",
"dev": " pnpm next dev",
"watch": "npm run dev",
"build": "yarn validate && yarn workspace @snailycad/api generate && yarn workspace @snailycad/ui build && yarn next-build",
"next-build": "yarn next build",
"start": "yarn next start",
"start:proxy-experimental": "yarn next start --port 80",
"build": "pnpm validate && pnpm --filter \"@snailycad/api\" generate && pnpm --filter \"@snailycad/ui\" build && pnpm next-build",
"next-build": "pnpm next build",
"start": "pnpm next start",
"start:proxy-experimental": "pnpm next start --port 80",
"validate": "node ../../scripts/validate.mjs",
"typecheck": "yarn tsc --noEmit",
"typecheck": "pnpm tsc --noEmit",
"copy-env": "node ../../scripts/copy-env.mjs --client",
"validate-locales": "node ../../scripts/validate-locales.mjs",
"test:watch": "yarn vitest --watch",
"test": "yarn vitest run",
"test:watch": "pnpm vitest --watch",
"test": "pnpm vitest run",
"create-images-domain": "node ../../scripts/create-images-domain.mjs"
},
"dependencies": {
Expand All @@ -26,8 +26,9 @@
"@radix-ui/react-tooltip": "^1.0.6",
"@react-aria/label": "^3.6.1",
"@react-aria/ssr": "^3.7.1",
"@sentry/nextjs": "^7.63.0",
"@sentry/tracing": "^7.63.0",
"@sentry/browser": "^7.66.0",
"@sentry/nextjs": "^7.66.0",
"@sentry/tracing": "^7.66.0",
"@snailycad/audit-logger": "workspace:*",
"@snailycad/config": "^1.68.7",
"@snailycad/permissions": "workspace:*",
Expand Down Expand Up @@ -83,7 +84,10 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@react-types/shared": "^3.18.1",
"@types/color": "^3.0.3",
"@types/connect": "^3.4.35",
"@types/is-hotkey": "^0.1.7",
"@types/leaflet": "^1.9.3",
"@types/nprogress": "^0.2.0",
"@types/react": "^18.2.20",
Expand Down
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
"private": true,
"name": "snailycad",
"version": "1.68.7",
"packageManager": "[email protected]",
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"start": "yarn run concurrently \"yarn workspace @snailycad/client start\" \"yarn workspace @snailycad/api generate && yarn workspace @snailycad/api start\"",
"build": "yarn turbo run build --filter=\"{packages/**/**}\" && yarn turbo run build --filter=\"{apps/**/**}\"",
"dev": "docker compose up -d && yarn turbo run watch --parallel --concurrency 11",
"start": "pnpm concurrently \"pnpm --filter \"@snailycad/client\" start\" \"pnpm --filter \"@snailycad/api\" generate && pnpm --filter \"@snailycad/api\" start\"",
"build": "pnpm turbo run build --filter=\"{packages/**/**}\" && pnpm turbo run build --filter=\"{apps/**/**}\"",
"dev": "docker compose up -d && pnpm turbo run watch --parallel --concurrency 11",
"format": "prettier --write \"./(packages|apps)/**/**/*.{js,jsx,ts,mjs,tsx,md,css,json}\" --ignore-path .gitignore",
"lint": "yarn run eslint . --ext .ts,.js,.tsx,.jsx,.mjs",
"lint:fix": "yarn run eslint . --ext .ts,.js,.tsx,.jsx,.mjs --fix",
"lint": "pnpm eslint . --ext .ts,.js,.tsx,.jsx,.mjs",
"lint:fix": "pnpm eslint . --ext .ts,.js,.tsx,.jsx,.mjs --fix",
"prepare": "husky install",
"bump-version": "node scripts/bump-version.mjs",
"postinstall": "husky install"
"postinstall": "husky install",
"typecheck": "pnpm turbo run typecheck"
},
"license": "MIT",
"devDependencies": {
Expand Down
Loading

0 comments on commit 7575ccf

Please sign in to comment.