Skip to content

Commit 653bebe

Browse files
Yohhemersion
authored andcommitted
front: switch from yarn to npm
Signed-off-by: Yohh <durandyohan@zaclys.net>
1 parent 888ffd4 commit 653bebe

16 files changed

+21200
-11236
lines changed

.github/workflows/build.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ jobs:
484484
-v $PWD/gateway:/gateway
485485
-v $PWD/front/src/common/api:/app/src/common/api
486486
${{ fromJSON(needs.build.outputs.stable_tags).front-build }}
487-
yarn generate-types
487+
npm run generate-types
488488
489489
- name: Check for unexpected changes
490490
run: |
@@ -704,7 +704,7 @@ jobs:
704704
run: |
705705
docker run --name=front-i18n-api-error --net=host -v $PWD/output/openapi.yaml:/editoast/openapi.yaml \
706706
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
707-
yarn i18n-api-errors
707+
npm run i18n-api-errors
708708
exit $(docker wait front-i18n-api-error)
709709
710710
check_gateway:
@@ -859,22 +859,22 @@ jobs:
859859
run: |
860860
docker run --name=front-format --net=host \
861861
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
862-
yarn prettier . --check
862+
npx prettier . --check
863863
864864
exit $(docker wait front-format)
865865
866866
- name: Check for i18n missing keys
867867
run: |
868868
docker run --name=front-i18n-checker --net=host \
869869
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
870-
yarn i18n-checker
870+
npm run i18n-checker
871871
exit $(docker wait front-i18n-checker)
872872
873873
- name: Execute tests within container
874874
run: |
875875
docker run --name=front-test --net=host -v $PWD/output:/app/tests/unit \
876876
${{ fromJSON(needs.build.outputs.stable_tags).front-build }} \
877-
yarn test-coverage
877+
npm run test-coverage
878878
879879
exit $(docker wait front-test)
880880
@@ -1098,7 +1098,7 @@ jobs:
10981098
-e CI=true \
10991099
--ipc=host \
11001100
-v "$PWD/front/test-results:/app/front/test-results" \
1101-
osrd-playwright:latest yarn playwright test
1101+
osrd-playwright:latest npx playwright test
11021102
exit $(docker wait playwright-test)
11031103
11041104
- uses: actions/upload-artifact@v4

flake.nix

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
# Front
7676
fixedNodePackages.create-react-app
7777
fixedNodePackages.eslint
78-
fixedNodePackages.yarn
7978
fixedNode
8079

8180
# 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

+33-29
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,36 +20,38 @@ 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 valkey postgres gateway core editoast`
41+
- Install playwright dependencies `cd ./front/ && npx playwright install --with-deps`
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-
If you are using a Linux distribution not supported by playwright (which only supports Windows, macOS and Ubuntu/Debian),
49-
you can instead start the tests inside a docker container using `osrd/scripts/run-front-playwright-container.sh`.
50-
You may pass the same options and arguments to this script as you would to `yarn e2e-tests` or `yarn playwright test`.
48+
If you are using a Linux distribution not supported by playwright (which only supports Windows,
49+
macOS and Ubuntu/Debian), you can instead start the tests inside a docker container using
50+
`osrd/scripts/run-front-playwright-container.sh`. You may pass the same options and arguments to
51+
this script as you would to `npm run e2e-tests` or `npx playwright test`.
5152

52-
> [!CAUTION] If you try to run `yarn start` instead of running it through docker, you'll notice it
53-
> doesn't work because the gateway can't access your local port from inside a container. 2
53+
> [!CAUTION] If you try to run `npm run start` instead of running it through docker, you'll notice
54+
> it doesn't work because the gateway can't access your local port from inside a container. 2
5455
> solutions:
5556
>
5657
> - run all the components locally (you might keep Postgres and Valkey in containers)
@@ -63,9 +64,9 @@ these videos as artifacts.
6364

6465
You may also want to explore the documentation of the test framework
6566
[Playwright](https://playwright.dev/). For example, try launching each test independently using
66-
`yarn playwright test --ui`, debug a test with `yarn playwright test --debug`, or launch a specified
67-
test of a specified test file with a specified browser once with for example
68-
`yarn playwright test 011-op-times-and-stops-tab.spec.ts -g "should correctly set and display times and stops tables" --project=firefox --retries=0`.
67+
`npm run playwright test --ui`, debug a test with `npm run playwright test --debug`, or launch a
68+
specified test of a specified test file with a specified browser once with for example
69+
`npm run playwright test 011-op-times-and-stops-tab.spec.ts -g "should correctly set and display times and stops tables" --project=firefox --retries=0`.
6970

7071
## Design rules
7172

@@ -106,8 +107,8 @@ organized in folders.
106107
**The components propose the main JS/TS file and eventually another folder with same name containing
107108
some minor subcomponents linked to.**
108109

109-
- components/
110-
- views/
110+
- components/
111+
- views/
111112
- [editor/](#infrastructure-editor-editor)
112113
- components/
113114
- [opendata/](#opendata-importation-opendata)
@@ -210,8 +211,8 @@ All common code (and shared components) supposed to be in `common/`.
210211

211212
- ESLint is used as linter and prettier as formatter. Both are configured as devDependencies to
212213
enforce default eslint configuration eventually overidden by
213-
[airbnb rules](https://airbnb.io/javascript/) translation. A few rules (see eslintrc) has
214-
been disabled and will be re-enabled in the near future):
214+
[airbnb rules](https://airbnb.io/javascript/) translation. A few rules (see eslintrc) has been
215+
disabled and will be re-enabled in the near future):
215216
- 'no-named-as-default': 'off',
216217
- 'react/jsx-props-no-spreading': 0,
217218
- 'react/static-property-placement': 0,
@@ -225,7 +226,7 @@ All common code (and shared components) supposed to be in `common/`.
225226
[Prettier - Code Formatter Extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
226227
and follow instructions.
227228

228-
You may also use `yarn lint-fix` to format/lint.
229+
You may also use `npm run lint-fix` to format/lint.
229230

230231
## Dependencies
231232

@@ -252,12 +253,15 @@ You may also use `yarn lint-fix` to format/lint.
252253
- jsdocs
253254

254255
### Updating Dependencies
255-
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.
256+
257+
When `package.json` changes (new packages or updated versions), developers may have issues running
258+
the app with Docker. New packages or versions might not be recognized by Docker.
256259

257260
To fix this, follow these steps:
258261

259-
1. After pulling new changes, run `yarn install` to update local dependencies.
260-
2. If issues persist, delete `node_modules` and run `yarn install` again.
261-
3. Run `docker compose build --no-cache` to rebuild Docker images from scratch with new dependencies.
262+
1. After pulling new changes, run `npm install` to update local dependencies.
263+
2. If issues persist, delete `node_modules` and run `npm install` again.
264+
3. Run `docker compose build --no-cache` to rebuild Docker images from scratch with new
265+
dependencies.
262266

263267
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
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.playwright

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ARG PLAYWRIGHT_VERSION=latest
22
FROM mcr.microsoft.com/playwright:$PLAYWRIGHT_VERSION
33

4-
COPY front/package.json front/yarn.lock /app/front/
4+
COPY front/package.json front/package-lock.json /app/front/
55
WORKDIR /app/front
6-
RUN yarn install --frozen-lockfile
6+
RUN npm install --frozen-lockfile
77

88
COPY front /app/front/
99
COPY tests /app/tests

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)