Skip to content

Commit

Permalink
Switch to pnpm (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn authored Jun 12, 2024
1 parent 2492d7b commit 3d19bb5
Show file tree
Hide file tree
Showing 11 changed files with 3,999 additions and 3,348 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
!config/locales
!src
!package.json
!.yarnclean
!yarn.lock
!pnpm-lock.yaml
!tsconfig.json
!tsconfig.release.json
26 changes: 26 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: setup
description: Setup Node and install dependencies

inputs:
node_version:
description: Node Version
required: true

runs:
using: composite
steps:
- name: Use pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js ${{ inputs.node_version }}
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: ${{ inputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: 🔧 Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --strict-peer-dependencies
51 changes: 0 additions & 51 deletions .github/workflows/build.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [main, next, 'release/**']
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙ Setup
uses: ./.github/actions/setup
with:
node_version: 20.x

- name: 🎈 Lint and test
run: |
pnpm run format:check
pnpm run lint
pnpm run test
- name: ⛳ SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
48 changes: 28 additions & 20 deletions .github/workflows/publish_npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: 📥 Checkout Repo
uses: actions/checkout@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies 🔧
run: yarn install --frozen-lockfile
- name: Prepare release 🚀
run: yarn release
- name: Publish package on NPM 📦
fetch-depth: 0

- name: ⚙ Setup
uses: ./.github/actions/setup
with:
node_version: 20.x

- name: 🚀 Prepare release
run: pnpm run release

- name: 📦 Publish package on NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -30,19 +34,23 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: 📥 Checkout Repo
uses: actions/checkout@v4
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@utarwyn'
- name: Add scope to package name 📝
fetch-depth: 0

- name: ⚙ Setup
uses: ./.github/actions/setup
with:
node_version: 20.x

- name: 📝 Add scope to package name
run: npx --yes change-package-name @utarwyn/discord-tictactoe
- name: Install dependencies 🔧
run: yarn install --frozen-lockfile
- name: Prepare release 🚀
run: yarn release
- name: Publish package on GitHub Packages 📦

- name: 🚀 Prepare release
run: pnpm run release

- name: 📦 Publish package on GitHub Packages
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 0 additions & 46 deletions .yarnclean

This file was deleted.

27 changes: 14 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
FROM node:20-slim as base
LABEL maintainer="Utarwyn <maxime.malgorn@laposte.net>"

RUN mkdir /app && chown -R node:node /app
WORKDIR /app

####################################################################################################
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

FROM base as build

COPY --chown=node:node . /app
RUN yarn install --silent --pure-lockfile && yarn build && rm -rf node_modules && yarn install --production --silent --pure-lockfile && yarn cache clean
RUN corepack enable
COPY . /app
WORKDIR /app

####################################################################################################
FROM base AS prod-deps
RUN pnpm install --prod --frozen-lockfile

FROM base as release
FROM base AS build
RUN pnpm install --frozen-lockfile
RUN pnpm run build

COPY --from=build --chown=node:node /app .
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist

USER node
ENV NODE_ENV=production
CMD ["yarn", "serve"]
CMD ["pnpm", "serve"]
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
"typescript"
],
"dependencies": {
"discord.js": "^14.14.1"
"discord.js": "^14.15.3"
},
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/node": "^16.18.61",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"eslint": "^8.56.0",
"@types/jest": "^29.5.12",
"@types/node": "^16.18.98",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.6.1",
"eslint-plugin-jest": "^27.9.0",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"replace-in-file": "^7.1.0",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
"prettier": "^3.3.2",
"replace-in-file": "^7.2.0",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
},
"engines": {
"node": ">=18"
Expand All @@ -54,9 +54,9 @@
"format": "prettier --write \"**/**.ts\"",
"lint": "eslint . --ext .ts",
"serve": "node dist/bin/tictactoe.js",
"start": "yarn build && yarn serve",
"start": "pnpm run build && pnpm run serve",
"test": "jest --coverage",
"test:watch": "jest --watch",
"release": "yarn clean && yarn lint && yarn test && yarn format && yarn build"
"release": "pnpm run clean && pnpm run lint && pnpm run test && pnpm run format && pnpm run build"
}
}
Loading

0 comments on commit 3d19bb5

Please sign in to comment.