Skip to content

Commit

Permalink
feat(package-manager): migrate from yarn to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Muñoz Tous committed Jun 27, 2024
1 parent cc4e353 commit 7554764
Show file tree
Hide file tree
Showing 12 changed files with 7,952 additions and 10,340 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: "${{ github.repository }}"

HUSKY: 0
jobs:
build:
environment: ${{ github.ref_name == 'master' && 'production' || 'staging'}}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
- name: Install dependencies and config
run: |
corepack enable
yarn
yarn ioc-generate
pnpm install
pnpm ioc-generate
- name: Check types
run: yarn check-types
run: pnpm check-types

- name: ESlint
run: yarn lint
run: pnpm lint

- name: Check formatting
run: yarn prettier-check
run: pnpm prettier-check
5 changes: 5 additions & 0 deletions .husky/install.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
process.exit(0);
}
const husky = (await import("husky")).default;
console.log(husky());
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
"**/*": [() => "just nvm-exec 'yarn check-types'", () => "just nvm-exec 'yarn lint'", "yarn prettier-check"]
"**/*": [() => "just nvm-exec 'pnpm check-types'", () => "just nvm-exec 'pnpm lint'", () => "just nvm-exec 'pnpm prettier-check'"]
};
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
coverage
yarn.lock
./.husky/install.mjs
*.yaml
*.yml
*.json
*.md
11 changes: 0 additions & 11 deletions .yarnrc.yml

This file was deleted.

8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM node:18-alpine AS base
RUN corepack enable
RUN yarn set version stable
RUN yarn config set enableImmutableInstalls false

# Install dependencies only when needed
FROM base AS deps
Expand All @@ -10,8 +8,8 @@ RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock .yarnrc.yml ./
RUN yarn
COPY package.json pnpm-lock.yaml ./
RUN pnpm install


# Rebuild the source code only when needed
Expand All @@ -28,7 +26,7 @@ COPY . .
RUN --mount=type=secret,id=next_env_variables \
cat /run/secrets/next_env_variables > .env.local

RUN yarn build
RUN pnpm build

# If using npm comment out above and use below instead
# RUN npm run build
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nvm install
```

Finally, enable [corepack](https://github.com/nodejs/corepack) so the correct
version of yarn is used.
version of pnpm is used.

```shell
just corepack-enable
Expand Down Expand Up @@ -61,7 +61,7 @@ just
**Proxy commands through nvm**

```shell
just nvm-exec "yarn add @front_web_mrmilu/hooks"
just nvm-exec "pnpm add @front_web_mrmilu/hooks"
```

### Environment variables
Expand Down Expand Up @@ -97,7 +97,7 @@ SENTRY_AUTH_TOKEN=sentry-user-auth-token
### CI/CD build commands

```shell
yarn install
yarn ioc-generate
yarn build
pnpm install
pnpm ioc-generate
pnpm build
```
20 changes: 12 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,34 @@ corepack-enable:

# Installs project package.json dependencies
install-deps:
./nvm_exec.sh yarn
./nvm_exec.sh pnpm install

# Starts Next development server
dev:
./nvm_exec.sh yarn dev
./nvm_exec.sh pnpm dev
# Builds Next application
build:
./nvm_exec.sh yarn build
./nvm_exec.sh pnpm build

# Starts Next server for built application
start:
./nvm_exec.sh yarn start
./nvm_exec.sh pnpm start

fix:
./nvm_exec.sh yarn lint
./nvm_exec.sh yarn prettier-fix
./nvm_exec.sh pnpm lint
./nvm_exec.sh pnpm prettier-fix

# Generate inversify bindings (watch execution)
ioc-generate-watch:
./nvm_exec.sh yarn ioc-generate --watch
./nvm_exec.sh pnpm ioc-generate --watch

# Generate inversify bindings
ioc-generate:
./nvm_exec.sh yarn ioc-generate
./nvm_exec.sh pnpm ioc-generate

# Commit
commit:
./nvm_exec.sh pnpm commit

# Proxy comand through nvm
nvm-exec command:
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"prepare": "node .husky/install.mjs",
"dev": "NODE_OPTIONS='--inspect' next dev",
"analyze": "ANALYZE=true next build",
"build": "next build",
Expand All @@ -20,6 +21,7 @@
"@front_web_mrmilu/services": "~2.1.0",
"@front_web_mrmilu/utils": "~2.1.0",
"@hookform/resolvers": "~3.6.0",
"@react-spring/web": "~9.7.3",
"@sentry/nextjs": "~7.102.1",
"@svgr/webpack": "~8.1.0",
"@vanilla-extract/css": "~1.15.3",
Expand All @@ -37,7 +39,7 @@
"react": "~18.3.1",
"react-dom": "~18.3.1",
"react-hook-form": "~7.52.0",
"react-spring": "~9.7.3",

"reflect-metadata": "~0.2.2",
"yup": "~1.4.0",
"zustand": "~4.5.2"
Expand All @@ -62,5 +64,5 @@
"prettier": "~3.3.2",
"typescript": "~5.5.2"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]+sha1.01c55344d677f3b481c6bb6ffba9a6b3c6dbd91d"
}
Loading

0 comments on commit 7554764

Please sign in to comment.