Skip to content

Switch package manager to pnpm #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
jobs:
test-analyze:
name: 'Run'
uses: infinum/js-pipeline/.github/workflows/pipeline.yml@master
uses: infinum/js-pipeline/.github/workflows/pipeline.yml@main
with:
ci_steps: 'lint test analyze'
ci_steps: 'lint test'
workflow: '.github/workflows/pr.yml'
environment: 'staging'
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"editor.codeActionsOnSave": ["source.fixAll.format", "source.fixAll.eslint"],
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"i18n-ally.localesPaths": ["public/locales", "src/components/shared/messages"],
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
}
}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:20.10.0-bookworm AS base
WORKDIR /app
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN npm install -g [email protected]

# # # PROJECT
FROM base as project
COPY . .

# # # PROD DEPENDENCIES
FROM project AS prod-dependencies
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --ignore-scripts

# # # BUILDER
FROM project AS builder
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --ignore-scripts

ARG NEXT_PUBLIC_BUGSNAG_API_KEY

RUN pnpm build

# # # RUNNER
FROM base AS runner
COPY --from=prod-dependencies /app/node_modules /app/node_modules

COPY --from=builder /app/.next/standalone/ /app/.next/standalone
COPY --from=builder /app/.next/static /app/.next/standalone/.next/static
COPY --from=builder /app/public /app/.next/standalone/public

CMD ["node", ".next/standalone/server.js"]
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

```bash
# Install dependencies
npm ci
pnpm i

# Start the dev server
npm run dev
pnpm dev
```

Use one of the user credentials to log in to the application
Expand Down Expand Up @@ -120,13 +120,13 @@ If you need to start a new project from this template, you have these options:
1. Stripped down version of the App from `project-starter-template` branch

```bash
npx create-next-app@latest PROJECT_NAME -e https://github.com/infinum/JS-React-Example/tree/project-starter-template --use-npm
pnpx create-next-app@latest PROJECT_NAME -e https://github.com/infinum/JS-React-Example/tree/project-starter-template --use-pnpm
```

2. Full-blown example App from the `master` branch

```bash
npx create-next-app@latest PROJECT_NAME -e https://github.com/infinum/JS-React-Example --use-npm
pnpx create-next-app@latest PROJECT_NAME -e https://github.com/infinum/JS-React-Example --use-pnpm
```

> Note: replace PROJECT_NAME with the name of your project
Expand All @@ -141,7 +141,6 @@ git push -u origin main

> Note: Replace REPOSITORY_NAME with the name of your repository. These commands will add the remote repository, rename the branch to main, and push your changes to the remote repository.


# Credits

JS-React-Example is maintained by
Expand Down
22 changes: 11 additions & 11 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

### Prerequisites / Dependencies

You will need to have NodeJS and NPM installed to run this application. Use the [handbook guide](https://infinum.com/handbook/frontend/node/managing-node-npm-versions) to set up the correct NodeJS version.
You will need to have NodeJS and pNPM installed to run this application. Use the Infinum handbooks to set up the [package manager](https://infinum.com/handbook/frontend/node/package-managers-guidelines) and [NodeJS version](https://infinum.com/handbook/frontend/node/managing-node-npm-versions).

### Installation

1. clone this repository: `git clone [TODO:GIT_LINK]`
2. install all the dependencies: `npm ci`
2. install all the dependencies: `pnpm i`

### Post-install

Expand All @@ -51,8 +51,8 @@ To build the app you can use some of the following commands:
npm run build

# TODO: development and production builds if applicable
# npm run build:dev
# npm run build:prod
# pnpm build:dev
# pnpm build:prod

```

Expand All @@ -63,9 +63,9 @@ npm run build
To start the unit tests you can use one of the following commands:

```
npm run test
npm run test:watch
npm run test:coverage
pnpm test
pnpm test:watch
pnpm test:coverage

```

Expand Down Expand Up @@ -106,10 +106,10 @@ You can specify environment variables as per the guide in the [Nuts & Bolts](htt

### List of environment variables

| Variable | Requirement | Description |
| ---------------- | ----------- | ---------------------------------------------------------- |
| API_HOST | required | API endpoint URL |
| ENV | required | Available options: development, production |
| Variable | Requirement | Description |
| -------- | ----------- | ------------------------------------------ |
| API_HOST | required | API endpoint URL |
| ENV | required | Available options: development, production |

## Deployment

Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const customJestConfig = {
// Handle module aliases (this will be automatically configured for you soon)
'^@/(.*)$': '<rootDir>/src/$1',
'^test-utils$': '<rootDir>/scripts/test-utils',
'lodash-es': 'lodash',
},
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/'],
Expand Down
Loading