Skip to content

Commit 0845e2d

Browse files
committed
front: switch from yarn to npm
1 parent 2a70df7 commit 0845e2d

15 files changed

+27758
-16132
lines changed

.github/workflows/build.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ jobs:
444444
-v $PWD/gateway:/gateway
445445
-v $PWD/front/src/common/api:/app/src/common/api
446446
${{ fromJSON(needs.build.outputs.stable_tags).front-build }}
447-
yarn generate-types
447+
npm run generate-types
448448
449449
- name: Check for unexpected changes
450450
run: |
@@ -663,7 +663,7 @@ jobs:
663663
run: |
664664
docker run --name=front-i18n-api-error --net=host -v $PWD/output/openapi.yaml:/editoast/openapi.yaml \
665665
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
666-
yarn i18n-api-errors
666+
npm run i18n-api-errors
667667
exit $(docker wait front-i18n-api-error)
668668
669669
check_gateway:
@@ -815,22 +815,22 @@ jobs:
815815
run: |
816816
docker run --name=front-format --net=host \
817817
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
818-
yarn prettier . --check
818+
npm run prettier . --check
819819
820820
exit $(docker wait front-format)
821821
822822
- name: Check for i18n missing keys
823823
run: |
824824
docker run --name=front-i18n-checker --net=host \
825825
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
826-
yarn i18n-checker
826+
npm run i18n-checker
827827
exit $(docker wait front-i18n-checker)
828828
829829
- name: Execute tests within container
830830
run: |
831831
docker run --name=front-test --net=host -v $PWD/output:/app/tests/unit \
832832
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
833-
yarn test-coverage
833+
npm run test-coverage
834834
835835
exit $(docker wait front-test)
836836
@@ -949,7 +949,7 @@ jobs:
949949
-e CI=true \
950950
-v $PWD/front/test-results:/app/test-results \
951951
${{ fromJSON(needs.build.outputs.stable_tags).front-tests }} \
952-
/bin/sh -c "npx playwright install --with-deps && yarn e2e-tests"
952+
/bin/sh -c "npx playwright install --with-deps && npm run e2e-tests"
953953
954954
exit $(docker wait playwright-test)
955955

flake.nix

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
# Front
8181
fixedNodePackages.create-react-app
8282
fixedNodePackages.eslint
83-
fixedNodePackages.yarn
8483
fixedNode
8584

8685
# Nix formatter

front/.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
.cache
2626

2727
npm-debug.log*
28-
yarn-debug.log*
29-
yarn-error.log*
3028

3129
# sonarqube
3230
.scannerwork

front/README.md

+31-28
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
## How to launch project for development purpose?
44

55
- go inside `/front/` from OSRD main project
6-
- you'll need [`npm`](https://nodejs.org/en/download/package-manager) and
7-
[`yarn`](https://classic.yarnpkg.com/lang/en/docs/install/)
8-
- exec `yarn` (hope you have a good connexion and a good cup of tea)
9-
- exec `yarn start` (perhaps you'll need `NODE_OPTIONS="--openssl-legacy-provider"` if your node
6+
- you'll need [`npm`](https://nodejs.org/en/download/package-manager)
7+
- exec `npm install` (hope you have a good connexion and a good cup of tea)
8+
- exec `npm start` (perhaps you'll need `NODE_OPTIONS="--openssl-legacy-provider"` if your node
109
version is too new)
1110
- enjoy
1211

1312
## Commands
1413

15-
### `yarn start`
14+
### `npm start`
1615

1716
Runs the app in a local development environment.
1817

@@ -21,45 +20,46 @@ well.
2120

2221
See [Main Readme](../README.md) if you need more information to run the docker.
2322

24-
### `yarn test`
23+
### `npm run test`
2524

2625
Launches the test runner in the interactive watch mode.
2726

28-
### `yarn build`
27+
### `npm run build`
2928

3029
Builds the app for production to the `build` folder.
3130

32-
### `yarn generate-licenses`
31+
### `npm run generate-licenses`
3332

3433
Update licenses attributions in /src/common/ReleaseInformations/json/
3534

36-
### `yarn e2e-tests`
35+
### `npm run e2e-tests`
3736

3837
Launches end to end tests.
3938

4039
It requires:
4140

42-
- Install playwright dependencies `cd ./front/ && yarn playwright install --with-deps`
43-
- Backend containers to be up: `docker compose up --no-build --detach redis postgres gateway core editoast`
41+
- Install playwright dependencies `cd ./front/ && npm run playwright install --with-deps`
42+
- Backend containers to be up:
43+
`docker compose up --no-build --detach redis postgres gateway core editoast`
4444
- Running front with `docker compose up --build --detach front`
4545

46-
Now you can run the test with `cd front/ && yarn e2e-tests`.
46+
Now you can run the test with `cd front/ && npm run e2e-tests`.
4747

48-
> [!CAUTION]
49-
> If you try to run `yarn start` instead of running it through docker, you'll notice it doesn't
50-
> work because the gateway can't access your local port from inside a container. 2 solutions:
48+
> [!CAUTION] If you try to run `npm run start` instead of running it through docker, you'll notice
49+
> it doesn't work because the gateway can't access your local port from inside a container. 2
50+
> solutions:
5151
>
5252
> - run all the components locally (you might keep Postgres and Redis in containers)
5353
> - if on Linux, you can also launch all the containers on the host network: you can replace the
54-
> `docker compose <something>` above with `osrd/scripts/osrd-compose.sh <something>`
54+
> `docker compose <something>` above with `osrd/scripts/osrd-compose.sh <something>`
5555
5656
If the tests fail, you'll find a `front/test-results` folder that will contain videos of the fail
5757
test executions. They might be of help to understand what's going on. Note that the CI also exports
5858
these videos as artifacts.
5959

60-
You may also want to explore the documentation of the test framework [Playwright](https://playwright.dev/).
61-
For example, try launching each test independently using `yarn playwright test --ui`, or debug a
62-
test with `yarn playwright test --debug`.
60+
You may also want to explore the documentation of the test framework
61+
[Playwright](https://playwright.dev/). For example, try launching each test independently using
62+
`npm run playwright test --ui`, or debug a test with `npm run playwright test --debug`.
6363

6464
## Design rules
6565

@@ -101,8 +101,8 @@ organized in folders.
101101
**The components propose the main JS/TS file and eventually another folder with same name containing
102102
some minor subcomponents linked to.**
103103

104-
- components/
105-
- views/
104+
- components/
105+
- views/
106106
- [editor/](#infrastructure-editor-editor)
107107
- components/
108108
- [opendata/](#opendata-importation-opendata)
@@ -205,8 +205,8 @@ All common code (and shared components) supposed to be in `common/`.
205205

206206
- ESLint is used as linter and prettier as formatter. Both are configured as devDependencies to
207207
enforce default eslint configuration eventually overidden by
208-
[airbnb rules](https://airbnb.io/javascript/) translation. A few rules (see eslintrc) has
209-
been disabled and will be re-enabled in the near future):
208+
[airbnb rules](https://airbnb.io/javascript/) translation. A few rules (see eslintrc) has been
209+
disabled and will be re-enabled in the near future):
210210
- 'no-named-as-default': 'off',
211211
- 'react/jsx-props-no-spreading': 0,
212212
- 'react/static-property-placement': 0,
@@ -220,7 +220,7 @@ All common code (and shared components) supposed to be in `common/`.
220220
[Prettier - Code Formatter Extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
221221
and follow instructions.
222222

223-
You may also use `yarn lint-fix` to format/lint.
223+
You may also use `npm run lint-fix` to format/lint.
224224

225225
## Dependencies
226226

@@ -247,12 +247,15 @@ You may also use `yarn lint-fix` to format/lint.
247247
- jsdocs
248248

249249
### Updating Dependencies
250-
When `package.json` changes (new packages or updated versions), developers may have issues running the app with Docker. New packages or versions might not be recognized by Docker.
250+
251+
When `package.json` changes (new packages or updated versions), developers may have issues running
252+
the app with Docker. New packages or versions might not be recognized by Docker.
251253

252254
To fix this, follow these steps:
253255

254-
1. After pulling new changes, run `yarn install` to update local dependencies.
255-
2. If issues persist, delete `node_modules` and run `yarn install` again.
256-
3. Run `docker compose build --no-cache` to rebuild Docker images from scratch with new dependencies.
256+
1. After pulling new changes, run `npm install` to update local dependencies.
257+
2. If issues persist, delete `node_modules` and run `npm install` again.
258+
3. Run `docker compose build --no-cache` to rebuild Docker images from scratch with new
259+
dependencies.
257260

258261
This ensures developers can run the app with the latest dependencies using Docker.

front/docker/Dockerfile.devel

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ WORKDIR /app
1919
# Start the app
2020
COPY docker/dev-entrypoint.sh /
2121
ENTRYPOINT ["/dev-entrypoint.sh"]
22-
CMD ["sh", "-c", "id && yarn install && exec yarn start-container"]
22+
CMD ["sh", "-c", "id && npm install && exec npm run start-container"]

front/docker/Dockerfile.nginx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ FROM node:20-bookworm as build
55
WORKDIR /app
66

77
# Build dependencies
8-
COPY package.json yarn.lock /app/
9-
RUN yarn install --frozen-lockfile
8+
COPY package.json package-lock.json /app/
9+
RUN npm install --frozen-lockfile --legacy-peer-deps
1010

1111
# Generate the licenses file and build
1212
COPY . /app
13-
RUN yarn generate-licenses && yarn build
13+
RUN npm run generate-licenses && npm run build
1414

1515
### TESTS STAGE
1616

front/docker/Dockerfile.storybook

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ WORKDIR /app
66
ENV PATH /app/node_modules/.bin:$PATH
77

88
# build dependencies
9-
COPY package.json yarn.lock /app/
10-
RUN yarn install --frozen-lockfile
9+
COPY package.json package-lock.json /app/
10+
RUN npm install --frozen-lockfile
1111

1212
# build the storybook
1313
COPY . /app
14-
RUN yarn build-storybook
14+
RUN npm run build-storybook
1515

1616
# Copy & serve app
1717
FROM nginx:alpine

front/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
You can add webfonts, meta tags, or analytics to this file.
2828
The build step will place the bundled scripts into the <body> tag.
2929
30-
To begin the development, run `npm start` or `yarn start`.
31-
To create a production bundle, use `npm run build` or `yarn build`.
30+
To begin the development, run `npm start`.
31+
To create a production bundle, use `npm run build`.
3232
-->
3333
</body>
3434
</html>

0 commit comments

Comments
 (0)