Skip to content

Commit 7445080

Browse files
authoredAug 2, 2021
Use Yarn instead of NPM (#5541)
1 parent b9cb819 commit 7445080

15 files changed

+28225
-42920
lines changed
 

‎.circleci/Dockerfile.cypress

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM cypress/browsers:node14.0.0-chrome84
1+
FROM cypress/browsers:node14.17.0-chrome91-ff89
22

33
ENV APP /usr/src/app
44
WORKDIR $APP
55

6-
COPY package.json package-lock.json $APP/
6+
COPY package.json yarn.lock .yarnrc $APP/
77
COPY viz-lib $APP/viz-lib
8-
RUN npm ci > /dev/null
8+
RUN npm install yarn@1.22.10 -g && yarn --frozen-lockfile --network-concurrency 1 > /dev/null
99

1010
COPY . $APP
1111

‎.circleci/config.yml

+28-22
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ version: 2.0
22

33
build-docker-image-job: &build-docker-image-job
44
docker:
5-
- image: circleci/node:12
5+
- image: circleci/node:14.17
66
steps:
7-
- setup_remote_docker
7+
- setup_remote_docker:
8+
version: 19.03.13
89
- checkout
910
- run: sudo apt update
1011
- run: sudo apt install python3-pip
1112
- run: sudo pip3 install -r requirements_bundles.txt
1213
- run: .circleci/update_version
13-
- run: npm run bundle
14+
- run: sudo npm install --global --force yarn@1.22.10
15+
- run: yarn bundle
1416
- run: .circleci/docker_build
1517
jobs:
1618
backend-lint:
@@ -27,7 +29,8 @@ jobs:
2729
docker:
2830
- image: circleci/buildpack-deps:xenial
2931
steps:
30-
- setup_remote_docker
32+
- setup_remote_docker:
33+
version: 19.03.13
3134
- checkout
3235
- run:
3336
name: Build Docker Images
@@ -61,34 +64,36 @@ jobs:
6164
CYPRESS_INSTALL_BINARY: 0
6265
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
6366
docker:
64-
- image: circleci/node:12
67+
- image: circleci/node:14.17
6568
steps:
6669
- checkout
6770
- run: mkdir -p /tmp/test-results/eslint
68-
- run: npm ci
69-
- run: npm run lint:ci
71+
- run: sudo npm install --global --force yarn@1.22.10
72+
- run: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
73+
- run: yarn lint:ci
7074
- store_test_results:
7175
path: /tmp/test-results
7276
frontend-unit-tests:
7377
environment:
7478
CYPRESS_INSTALL_BINARY: 0
7579
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
7680
docker:
77-
- image: circleci/node:12
81+
- image: circleci/node:14.17
7882
steps:
7983
- checkout
8084
- run: sudo apt update
8185
- run: sudo apt install python3-pip
8286
- run: sudo pip3 install -r requirements_bundles.txt
83-
- run: npm ci
84-
- run: npm run bundle
87+
- run: sudo npm install --global --force yarn@1.22.10
88+
- run: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
89+
- run: yarn bundle
8590
- run:
8691
name: Run App Tests
87-
command: npm test
92+
command: yarn test
8893
- run:
8994
name: Run Visualizations Tests
90-
command: (cd viz-lib && npm test)
91-
- run: npm run lint
95+
command: (cd viz-lib && yarn test)
96+
- run: yarn lint
9297
frontend-e2e-tests:
9398
environment:
9499
COMPOSE_FILE: .circleci/docker-compose.cypress.yml
@@ -99,9 +104,10 @@ jobs:
99104
CYPRESS_INSTALL_BINARY: 0
100105
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
101106
docker:
102-
- image: circleci/node:12
107+
- image: circleci/node:14.17
103108
steps:
104-
- setup_remote_docker
109+
- setup_remote_docker:
110+
version: 19.03.13
105111
- checkout
106112
- run:
107113
name: Enable Code Coverage report for master branch
@@ -110,19 +116,19 @@ jobs:
110116
echo 'export CODE_COVERAGE=true' >> $BASH_ENV
111117
source $BASH_ENV
112118
fi
119+
- run: sudo npm install --global --force yarn@1.22.10
113120
- run:
114-
name: Install npm dependencies
115-
command: |
116-
npm ci
121+
name: Install frontend dependencies
122+
command: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
117123
- run:
118124
name: Setup Redash server
119125
command: |
120-
npm run cypress build
121-
npm run cypress start -- --skip-db-seed
122-
docker-compose run cypress npm run cypress db-seed
126+
yarn cypress build
127+
yarn cypress start -- --skip-db-seed
128+
docker-compose run cypress yarn cypress db-seed
123129
- run:
124130
name: Execute Cypress tests
125-
command: npm run cypress run-ci
131+
command: yarn cypress run-ci
126132
- run:
127133
name: "Failure: output container logs to console"
128134
command: |

‎.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14.16.1

‎.yarn/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

‎.yarnrc

Whitespace-only changes.

‎Dockerfile

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM node:12 as frontend-builder
1+
FROM node:14.17 as frontend-builder
2+
3+
RUN npm install --global --force yarn@1.22.10
24

35
# Controls whether to build the frontend assets
46
ARG skip_frontend_build
@@ -10,18 +12,19 @@ RUN useradd -m -d /frontend redash
1012
USER redash
1113

1214
WORKDIR /frontend
13-
COPY --chown=redash package.json package-lock.json /frontend/
15+
COPY --chown=redash package.json yarn.lock .yarnrc /frontend/
1416
COPY --chown=redash viz-lib /frontend/viz-lib
1517

1618
# Controls whether to instrument code for coverage information
1719
ARG code_coverage
1820
ENV BABEL_ENV=${code_coverage:+test}
1921

20-
RUN if [ "x$skip_frontend_build" = "x" ] ; then npm ci --unsafe-perm; fi
22+
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn --frozen-lockfile --network-concurrency 1; fi
2123

2224
COPY --chown=redash client /frontend/client
2325
COPY --chown=redash webpack.config.js /frontend/
24-
RUN if [ "x$skip_frontend_build" = "x" ] ; then npm run build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi
26+
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi
27+
2528
FROM python:3.7-slim
2629

2730
EXPOSE 5000
@@ -57,7 +60,7 @@ RUN apt-get update && \
5760
libsasl2-dev \
5861
unzip \
5962
libsasl2-modules-gssapi-mit && \
60-
# MSSQL ODBC Driver:
63+
# MSSQL ODBC Driver:
6164
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
6265
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
6366
apt-get update && \

‎Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ backend-unit-tests: up test_db
3535
docker-compose run --rm --name tests server tests
3636

3737
frontend-unit-tests: bundle
38-
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm ci
39-
npm run bundle
40-
npm test
38+
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn --frozen-lockfile
39+
yarn bundle
40+
yarn test
4141

4242
test: lint backend-unit-tests frontend-unit-tests
4343

4444
build: bundle
45-
npm run build
45+
yarn build
4646

4747
watch: bundle
48-
npm run watch
48+
yarn watch
4949

5050
start: bundle
51-
npm run start
51+
yarn start
5252

5353
redis-cli:
5454
docker-compose run --rm redis redis-cli -h redis

‎client/cypress/cypress.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ switch (command) {
118118
stopServer();
119119
break;
120120
default:
121-
console.log("Usage: npm run cypress [build|start|db-seed|open|run|stop]");
121+
console.log("Usage: yarn cypress [build|start|db-seed|open|run|stop]");
122122
break;
123123
}

‎netlify.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[build]
22
base = "client"
33
publish = "client/dist"
4-
command = "npm ci && npm run build"
4+
# Netlify doesn't seem to install Yarn even though NETLIFY_USE_YARN is set below
5+
# command = "cd ../ && npm i -g yarn@1.22.10 && yarn --frozen-lockfile --force && cd viz-lib && yarn build:babel && cd .. && rm -r ./node_modules/@redash/viz && cp -r ./viz-lib/. ./node_modules/@redash/viz && yarn build && cd ./client"
6+
command = "cd ../ && npm i -g yarn@1.22.10 && yarn cache clean && yarn --frozen-lockfile --network-concurrency 1 && yarn build && cd ./client"
57

68
[build.environment]
7-
NODE_VERSION = "12.18.4"
9+
NODE_VERSION = "14.16.1"
10+
NETLIFY_USE_YARN = "true"
11+
YARN_VERSION = "1.22.10"
812
CYPRESS_INSTALL_BINARY = "0"
913
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = "1"
1014

‎package-lock.json

-27,751
This file was deleted.

‎package.json

+15-14
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,36 @@
77
"start": "npm-run-all --parallel watch:viz webpack-dev-server",
88
"bundle": "bin/bundle-extensions",
99
"clean": "rm -rf ./client/dist/",
10-
"build:viz": "(cd viz-lib && npm run build:babel)",
11-
"build": "npm run clean && npm run build:viz && NODE_ENV=production webpack",
12-
"build:old-node-version": "npm run clean && NODE_ENV=production node --max-old-space-size=4096 node_modules/.bin/webpack",
10+
"build:viz": "(cd viz-lib && yarn build:babel)",
11+
"build": "yarn clean && yarn build:viz && NODE_ENV=production webpack",
12+
"build:old-node-version": "yarn clean && NODE_ENV=production node --max-old-space-size=4096 node_modules/.bin/webpack",
1313
"watch:app": "webpack --watch --progress --colors -d",
14-
"watch:viz": "(cd viz-lib && npm run watch:babel)",
14+
"watch:viz": "(cd viz-lib && yarn watch:babel)",
1515
"watch": "npm-run-all --parallel watch:*",
1616
"webpack-dev-server": "webpack-dev-server",
17-
"analyze": "npm run clean && BUNDLE_ANALYZER=on webpack",
18-
"analyze:build": "npm run clean && NODE_ENV=production BUNDLE_ANALYZER=on webpack",
19-
"lint": "npm run lint:base -- --ext .js --ext .jsx --ext .ts --ext .tsx ./client",
20-
"lint:fix": "npm run lint:base -- --fix --ext .js --ext .jsx --ext .ts --ext .tsx ./client",
17+
"analyze": "yarn clean && BUNDLE_ANALYZER=on webpack",
18+
"analyze:build": "yarn clean && NODE_ENV=production BUNDLE_ANALYZER=on webpack",
19+
"lint": "yarn lint:base --ext .js --ext .jsx --ext .ts --ext .tsx ./client",
20+
"lint:fix": "yarn lint:base --fix --ext .js --ext .jsx --ext .ts --ext .tsx ./client",
2121
"lint:base": "eslint --config ./client/.eslintrc.js --ignore-path ./client/.eslintignore",
22-
"lint:ci": "npm run lint -- --max-warnings 0 --format junit --output-file /tmp/test-results/eslint/results.xml",
22+
"lint:ci": "yarn lint --max-warnings 0 --format junit --output-file /tmp/test-results/eslint/results.xml",
2323
"prettier": "prettier --write 'client/app/**/*.{js,jsx,ts,tsx}' 'client/cypress/**/*.{js,jsx,ts,tsx}'",
2424
"type-check": "tsc --noEmit --project client/tsconfig.json",
25-
"type-check:watch": "npm run type-check -- --watch",
25+
"type-check:watch": "yarn type-check --watch",
2626
"jest": "TZ=Africa/Khartoum jest",
2727
"test": "run-s type-check jest",
2828
"test:watch": "jest --watch",
2929
"cypress": "node client/cypress/cypress.js",
30-
"postinstall": "(cd viz-lib && npm ci && npm run build:babel)"
30+
"preinstall": "cd viz-lib && yarn link --link-folder ../.yarn",
31+
"postinstall": "(cd viz-lib && yarn --frozen-lockfile && yarn build:babel) && yarn link --link-folder ./.yarn @redash/viz"
3132
},
3233
"repository": {
3334
"type": "git",
3435
"url": "git+https://github.com/getredash/redash.git"
3536
},
3637
"engines": {
37-
"node": "^12.0.0",
38-
"npm": "^6.0.0"
38+
"node": "^14.16.1",
39+
"yarn": "^1.22.10"
3940
},
4041
"author": "Redash Contributors",
4142
"license": "BSD-2-Clause",
@@ -154,7 +155,7 @@
154155
"webpack-manifest-plugin": "^2.0.4"
155156
},
156157
"optionalDependencies": {
157-
"fsevents": "^1.2.9"
158+
"fsevents": "^2.3.2"
158159
},
159160
"jest": {
160161
"rootDir": "./client",

‎viz-lib/package-lock.json

-15,113
This file was deleted.

‎viz-lib/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"type-check": "tsc --noEmit",
99
"type-gen": "tsc --emitDeclarationOnly",
1010
"build:babel:base": "babel src --out-dir lib --source-maps --ignore 'src/**/*.test.js' --copy-files --no-copy-ignored --extensions .ts,.tsx,.js,.jsx",
11-
"build:babel": "npm run type-gen && npm run build:babel:base",
11+
"build:babel": "yarn type-gen && yarn build:babel:base",
1212
"build:webpack": "webpack",
1313
"build": " NODE_ENV=production npm-run-all clean build:babel build:webpack",
14-
"watch:babel": "npm run build:babel:base -- --watch",
14+
"watch:babel": "yarn build:babel:base --watch",
1515
"watch:webpack": "webpack --watch",
1616
"watch": "npm-run-all --parallel watch:*",
17-
"version": "npm run build",
17+
"version": "yarn build",
1818
"prettier": "prettier --write 'src/**/*.{ts,tsx}'",
1919
"test": "jest",
2020
"test:watch": "jest --watch"

‎viz-lib/yarn.lock

+11,383
Large diffs are not rendered by default.

‎yarn.lock

+16,769
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.