Skip to content

Commit 79d9480

Browse files
authored
UI: Replace yarn by npm (#4564)
Signed-off-by: Augustin Husson <[email protected]>
1 parent 40040fc commit 79d9480

File tree

8 files changed

+38851
-12844
lines changed

8 files changed

+38851
-12844
lines changed

.github/workflows/react.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ jobs:
1515
name: React UI test on Node ${{ matrix.node }}
1616
steps:
1717
- uses: actions/checkout@v2
18-
- name: Setup node
19-
uses: actions/setup-node@v1
18+
- name: install nodejs
19+
uses: actions/setup-node@v2
2020
with:
2121
node-version: ${{ matrix.node }}
22-
- name: Get yarn cache directory path
23-
id: yarn-cache-dir-path
24-
run: echo "::set-output name=dir::$(yarn cache dir)"
25-
26-
- uses: actions/cache@v1
27-
id: yarn-cache
22+
- uses: actions/cache@v2
2823
with:
29-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
30-
key: ${{ runner.os }}-yarn-${{ hashFiles('pkg/ui/react-app/yarn.lock') }}
24+
path: ~/.npm
25+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
3126
restore-keys: |
32-
${{ runner.os }}-yarn-
27+
${{ runner.os }}-node-
3328
- run: make react-app-test

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The following section explains various suggestions and procedures to note during
6868

6969
* It is strongly recommended that you use Linux distributions systems or OSX for development.
7070
* Go 1.13.9 or newer installed.
71-
* For React UI, you will need a working NodeJS environment and the Yarn package manager to compile the Web UI assets.
71+
* For React UI, you will need a working NodeJS environment and the npm package manager to compile the Web UI assets.
7272

7373
### First Steps
7474

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ help: ## Displays help.
8888
.PHONY: all
8989
all: format build
9090

91-
$(REACT_APP_NODE_MODULES_PATH): $(REACT_APP_PATH)/package.json $(REACT_APP_PATH)/yarn.lock
92-
cd $(REACT_APP_PATH) && yarn --frozen-lockfile
91+
$(REACT_APP_NODE_MODULES_PATH): $(REACT_APP_PATH)/package.json $(REACT_APP_PATH)/package-lock.json
92+
cd $(REACT_APP_PATH) && npm ci
9393

9494
$(REACT_APP_OUTPUT_DIR): $(REACT_APP_NODE_MODULES_PATH) $(REACT_APP_SOURCE_FILES)
9595
@echo ">> building React app"
@@ -107,22 +107,22 @@ assets: $(GO_BINDATA) $(REACT_APP_OUTPUT_DIR)
107107
.PHONY: react-app-lint
108108
react-app-lint: $(REACT_APP_NODE_MODULES_PATH)
109109
@echo ">> running React app linting"
110-
cd $(REACT_APP_PATH) && yarn lint:ci
110+
cd $(REACT_APP_PATH) && npm run lint:ci
111111

112112
.PHONY: react-app-lint-fix
113113
react-app-lint-fix:
114114
@echo ">> running React app linting and fixing errors where possible"
115-
cd $(REACT_APP_PATH) && yarn lint
115+
cd $(REACT_APP_PATH) && npm run lint
116116

117117
.PHONY: react-app-test
118118
react-app-test: | $(REACT_APP_NODE_MODULES_PATH) react-app-lint
119119
@echo ">> running React app tests"
120-
cd $(REACT_APP_PATH) && export CI=true && yarn test --no-watch
120+
cd $(REACT_APP_PATH) && export CI=true && npm test --no-watch
121121

122122
.PHONY: react-app-start
123123
react-app-start: $(REACT_APP_NODE_MODULES_PATH)
124124
@echo ">> running React app"
125-
cd $(REACT_APP_PATH) && yarn start
125+
cd $(REACT_APP_PATH) && npm start
126126

127127
.PHONY: build
128128
build: ## Builds Thanos binary using `promu`.

pkg/ui/react-app/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ Instead of plain JavaScript, we use [TypeScript](https://www.typescriptlang.org/
1313
To work with the React UI code, you will need to have the following tools installed:
1414

1515
* The [Node.js](https://nodejs.org/) JavaScript runtime.
16-
* The [Yarn](https://yarnpkg.com/) package manager.
16+
* The [npm](https://www.npmjs.com/) package manager. Once you installed Node, npm should already be available.
1717
* *Recommended:* An editor with TypeScript, React, and [ESLint](https://eslint.org/) linting support. See e.g. [Create React App's editor setup instructions](https://create-react-app.dev/docs/setting-up-your-editor/). If you are not sure which editor to use, we recommend using [Visual Studio Code](https://code.visualstudio.com/docs/languages/typescript). Make sure that [the editor uses the project's TypeScript version rather than its own](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript).
1818

1919
**NOTE**: When using Visual Studio Code, be sure to open the `pkg/ui/react-app` directory in the editor instead of the root of the repository. This way, the right ESLint and TypeScript configuration will be picked up from the React workspace.
2020

2121
## Installing npm dependencies
2222

23-
The React UI depends on a large number of [npm](https://www.npmjs.com/) packages. These are not checked in, so you will need to download and install them locally via the Yarn package manager:
23+
The React UI depends on a large number of [npm](https://www.npmjs.com/) packages. These are not checked in, so you will need to download and install them locally via the npm package manager:
2424

25-
yarn
25+
npm install
2626

27-
Yarn consults the `package.json` and `yarn.lock` files for dependencies to install. It creates a `node_modules` directory with all installed dependencies.
27+
npm consults the `package.json` and `package-lock.json` files for dependencies to install. It creates a `node_modules` directory with all installed dependencies.
2828

2929
## Running a local development server
3030

3131
You can start a development server for the React UI outside of a running Thanos server by running:
3232

33-
yarn start
33+
npm start
3434

3535
This will open a browser window with the React app running on http://localhost:3000/. The page will reload if you make edits to the source code. You will also see any lint errors in the console.
3636

@@ -42,11 +42,11 @@ Due to a `"proxy": "http://localhost:10902"` setting in the `package.json` file,
4242

4343
Create React App uses the [Jest](https://jestjs.io/) framework for running tests. To run tests in interactive watch mode:
4444

45-
yarn test
45+
npm test
4646

4747
To generate an HTML-based test coverage report, run:
4848

49-
CI=true yarn test --coverage
49+
CI=true npm test --coverage
5050

5151
This creates a `coverage` subdirectory with the generated report. Open `coverage/lcov-report/index.html` in the browser to view it.
5252

@@ -60,15 +60,15 @@ We define linting rules for the [ESLint](https://eslint.org/) linter. We recomme
6060

6161
To detect and automatically fix lint errors, run:
6262

63-
yarn lint
63+
npm run lint
6464

6565
This is also available via the `react-app-lint-fix` target in the main Thanos `Makefile`.
6666

6767
## Building the app for production
6868

6969
To build a production-optimized version of the React app to a `build` subdirectory, run:
7070

71-
yarn build
71+
npm run build
7272

7373
**NOTE:** You will likely not need to do this directly. Instead, this is taken care of by the `assets` target in the main Thanos `Makefile` when building the full binary.
7474

0 commit comments

Comments
 (0)