Skip to content

Commit 01593dc

Browse files
committed
front: switch from yarn to npm
Signed-off-by: Yohh <durandyohan@zaclys.net>
1 parent ca461a7 commit 01593dc

15 files changed

+21101
-11187
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+
npx 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
@@ -79,7 +79,6 @@
7979
# Front
8080
fixedNodePackages.create-react-app
8181
fixedNodePackages.eslint
82-
fixedNodePackages.yarn
8382
fixedNode
8483

8584
# Nix formatter

front/.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
.cache
2525

2626
npm-debug.log*
27-
yarn-debug.log*
28-
yarn-error.log*
2927

3028
# sonarqube
3129
.scannerwork

front/README.md

+30-27
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

4241
- Install playwright dependencies `cd ./front/ && yarn playwright install --with-deps`
43-
- Backend containers to be up: `docker compose up --no-build --detach valkey postgres gateway core editoast`
42+
- Backend containers to be up:
43+
`docker compose up --no-build --detach valkey 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 Valkey 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/host-compose.sh <something>`
54+
> `docker compose <something>` above with `osrd/scripts/host-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

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

103-
- components/
104-
- views/
103+
- components/
104+
- views/
105105
- [editor/](#infrastructure-editor-editor)
106106
- components/
107107
- [opendata/](#opendata-importation-opendata)
@@ -204,8 +204,8 @@ All common code (and shared components) supposed to be in `common/`.
204204

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

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

224224
## Dependencies
225225

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

248248
### Updating Dependencies
249-
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.
249+
250+
When `package.json` changes (new packages or updated versions), developers may have issues running
251+
the app with Docker. New packages or versions might not be recognized by Docker.
250252

251253
To fix this, follow these steps:
252254

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

257260
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/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)