Update scripts and docs to use `yarn` where appropriate

Most `npm` operations are replaced with `yarn`, which generally has better
behavior. However, steps like publish that write to the NPM registry are left to
`npm`, which currently handles these tasks best.
pull/21833/head
J. Ryan Stinnett 2019-03-11 14:22:02 +00:00
parent db5b76b225
commit 7c947d87ab
11 changed files with 46 additions and 35 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ npm-debug.log
/node_modules
/lib
# version file and tarball created by 'npm pack'
# version file and tarball created by `npm pack` / `yarn pack`
/git-revision.txt
/matrix-react-sdk-*.tgz

View File

@ -20,7 +20,7 @@ matrix:
- name: Linting Checks
script:
# run the linter, but exclude any files known to have errors or warnings.
- npm run lintwithexclusions
- yarn lintwithexclusions
# - name: End-to-End Tests
# if: branch = develop
# install:

View File

@ -66,7 +66,7 @@ practices that anyone working with the SDK needs to be be aware of and uphold:
component is a view or a structure, and then a broad functional grouping
(e.g. 'rooms' here)
* After creating a new component you must run `npm run reskindex` to regenerate
* After creating a new component you must run `yarn reskindex` to regenerate
the `component-index.js` for the SDK (used in future for skinning)
* The view's CSS file MUST have the same name (e.g. view/rooms/MessageTile.css).
@ -131,26 +131,37 @@ for now.
Development
===========
Ensure you have the latest stable Node JS runtime installed (v8.x is the best choice). Then check out
the code and pull in dependencies:
Ensure you have the latest stable Node JS runtime installed (v8.x is the best
choice).
Using `yarn` instead of `npm` is recommended. Please see the Yarn [install
guide](https://yarnpkg.com/docs/install/) if you do not have it already.
Then check out the code and pull in dependencies:
```bash
git clone https://github.com/matrix-org/matrix-react-sdk.git
cd matrix-react-sdk
git checkout develop
npm install
yarn install
```
`matrix-react-sdk` depends on `matrix-js-sdk`. To make use of changes in the
`matrix-react-sdk` depends on `matrix-js-sdk`. To make use of changes in the
latter and to ensure tests run against the develop branch of `matrix-js-sdk`,
you should run the following which will sync changes from the JS sdk here.
you should check out `matrix-js-sdk`, change into that new directory, and run:
```bash
npm link ../matrix-js-sdk
yarn link
```
Command assumes a checked out and installed `matrix-js-sdk` folder in parent
folder.
Then, switch back to `matrix-react-sdk` and run:
```bash
yarn link matrix-js-sdk
```
See the [help for `yarn link`](https://yarnpkg.com/docs/cli/link) for more
details about this.
Running tests
=============
@ -158,5 +169,5 @@ Running tests
Ensure you've followed the above development instructions and then:
```bash
npm run test
yarn test
```

View File

@ -9,24 +9,24 @@ nvm use 10
set -x
# install the other dependencies
npm install
yarn install
scripts/fetchdep.sh matrix-org matrix-js-sdk
rm -r node_modules/matrix-js-sdk || true
ln -s ../matrix-js-sdk node_modules/matrix-js-sdk
(cd matrix-js-sdk && npm install)
(cd matrix-js-sdk && yarn install)
# run the mocha tests
npm run test -- --no-colors
yarn test --no-colors
# run eslint
npm run lintall -- -f checkstyle -o eslint.xml || true
yarn lintall -f checkstyle -o eslint.xml || true
# re-run the linter, excluding any files known to have errors or warnings.
npm run lintwithexclusions
yarn lintwithexclusions
# delete the old tarball, if it exists
rm -f matrix-react-sdk-*.tgz
# build our tarball
npm pack
yarn pack

View File

@ -8,7 +8,7 @@ var fs = require('fs');
* to build everything; however it's the easiest way to load our dependencies
* from node_modules.
*
* If you run karma in multi-run mode (with `npm run test-multi`), it will watch
* If you run karma in multi-run mode (with `yarn test-multi`), it will watch
* the tests for changes, and webpack will rebuild using a cache. This is much quicker
* than a clean rebuild.
*/
@ -35,7 +35,7 @@ function fileExists(name) {
}
}
// try find the gemini-scrollbar css in an npm-version-agnostic way
// try find the gemini-scrollbar css in an version-agnostic way
var gsCss = 'node_modules/gemini-scrollbar/gemini-scrollbar.css';
if (!fileExists(gsCss)) {
gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
@ -198,7 +198,7 @@ module.exports = function (config) {
alias: {
// alias any requires to the react module to the one in our
// path, otherwise we tend to get the react source included
// twice when using npm link.
// twice when using `npm link` / `yarn link`.
react: path.resolve('./node_modules/react'),
'matrix-react-sdk': path.resolve('test/skinned-sdk.js'),

View File

@ -40,17 +40,17 @@
"rethemendex": "res/css/rethemendex.sh",
"i18n": "matrix-gen-i18n",
"prunei18n": "matrix-prune-i18n",
"build": "npm run reskindex && npm run start:init",
"build": "yarn reskindex && yarn start:init",
"build:watch": "babel src -w --skip-initial-build -d lib --source-maps --copy-files",
"emoji-data-strip": "node scripts/emoji-data-strip.js",
"start": "npm run start:init && npm run start:all",
"start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"npm run build:watch\" \"npm run reskindex:watch\"",
"start": "yarn start:init && yarn start:all",
"start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"yarn build:watch\" \"yarn reskindex:watch\"",
"start:init": "babel src -d lib --source-maps --copy-files",
"lint": "eslint src/",
"lintall": "eslint src/ test/",
"lintwithexclusions": "eslint --max-warnings 0 --ignore-path .eslintignore.errorfiles src test",
"clean": "rimraf lib",
"prepublish": "npm run clean && npm run build && git rev-parse HEAD > git-revision.txt",
"prepublish": "yarn clean && yarn build && git rev-parse HEAD > git-revision.txt",
"test": "karma start --single-run=true --browsers ChromeHeadless",
"test-multi": "karma start"
},

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# script which is run by the travis build (after `npm run test`).
# script which is run by the travis build (after `yarn test`).
#
# clones riot-web develop and runs the tests against our version of react-sdk.
@ -13,7 +13,7 @@ scripts/fetchdep.sh vector-im riot-web
pushd "$RIOT_WEB_DIR"
mkdir node_modules
npm install
yarn install
# use the version of js-sdk we just used in the react-sdk tests
rm -r node_modules/matrix-js-sdk
@ -23,5 +23,5 @@ ln -s "$REACT_SDK_DIR/node_modules/matrix-js-sdk" node_modules/matrix-js-sdk
rm -r node_modules/matrix-react-sdk
ln -s "$REACT_SDK_DIR" node_modules/matrix-react-sdk
npm run build
yarn build
popd

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# script which is run by the travis build (after `npm run test`).
# script which is run by the travis build (after `yarn test`).
#
# clones riot-web develop and runs the tests against our version of react-sdk.

View File

@ -1,11 +1,11 @@
#!/bin/sh
set -ex
npm install
yarn install
scripts/fetchdep.sh matrix-org matrix-js-sdk
rm -r node_modules/matrix-js-sdk || true
ln -s ../matrix-js-sdk node_modules/matrix-js-sdk
cd matrix-js-sdk
npm install
yarn install
cd ..

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# script which is run by the travis build (after `npm run test`).
# script which is run by the travis build (after `yarn test`).
#
# clones riot-web develop and runs the tests against our version of react-sdk.
@ -10,5 +10,5 @@ RIOT_WEB_DIR=riot-web
scripts/travis/build.sh
pushd "$RIOT_WEB_DIR"
npm run test
yarn test
popd

View File

@ -1,10 +1,10 @@
#!/bin/bash
#
# script which is run by the travis build (after `npm run test`).
# script which is run by the travis build (after `yarn test`).
#
# clones riot-web develop and runs the tests against our version of react-sdk.
set -ev
scripts/travis/build.sh
CHROME_BIN='/usr/bin/google-chrome-stable' npm run test
CHROME_BIN='/usr/bin/google-chrome-stable' yarn test