Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2773 from jryans/yarn
Browse files Browse the repository at this point in the history
Switch to `yarn` for dependency management
  • Loading branch information
jryans authored Mar 13, 2019
2 parents c0bb9c8 + d9063bb commit 9585f11
Show file tree
Hide file tree
Showing 12 changed files with 7,184 additions and 57 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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

Expand All @@ -15,6 +15,3 @@ npm-debug.log
/src/component-index.js

.DS_Store

# https://github.com/vector-im/riot-web/issues/7083
package-lock.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -131,32 +131,42 @@ 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.

`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 set up `matrix-js-sdk`:

```bash
git clone https://github.com/matrix-org/matrix-react-sdk.git
cd matrix-react-sdk
git clone https://github.com/matrix-org/matrix-js-sdk
cd matrix-js-sdk
git checkout develop
npm install
yarn link
yarn install
```

`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.
Then check out `matrix-react-sdk` and pull in dependencies:

```bash
npm link ../matrix-js-sdk
git clone https://github.com/matrix-org/matrix-react-sdk
cd matrix-react-sdk
git checkout develop
yarn link matrix-js-sdk
yarn install
```

Command assumes a checked out and installed `matrix-js-sdk` folder in parent
folder.
See the [help for `yarn link`](https://yarnpkg.com/docs/cli/link) for more
details about this.

Running tests
=============

Ensure you've followed the above development instructions and then:

```bash
npm run test
yarn test
```
24 changes: 14 additions & 10 deletions jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ nvm use 10

set -x

# install the other dependencies
npm 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)

pushd matrix-js-sdk
yarn link
yarn install
popd

yarn link matrix-js-sdk

# install the other dependencies
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
6 changes: 3 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
Expand Down Expand Up @@ -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'),
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"prepare": "yarn clean && yarn build && git rev-parse HEAD > git-revision.txt",
"test": "karma start --single-run=true --browsers ChromeHeadless",
"test-multi": "karma start"
},
Expand Down
18 changes: 8 additions & 10 deletions scripts/travis/build.sh
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -9,19 +9,17 @@ set -ev
RIOT_WEB_DIR=riot-web
REACT_SDK_DIR=`pwd`

yarn link

scripts/fetchdep.sh vector-im riot-web

pushd "$RIOT_WEB_DIR"

mkdir node_modules
npm install
yarn link matrix-js-sdk
yarn link matrix-react-sdk

# use the version of js-sdk we just used in the react-sdk tests
rm -r node_modules/matrix-js-sdk
ln -s "$REACT_SDK_DIR/node_modules/matrix-js-sdk" node_modules/matrix-js-sdk
yarn install

# ... and, of course, the version of react-sdk we just built
rm -r node_modules/matrix-react-sdk
ln -s "$REACT_SDK_DIR" node_modules/matrix-react-sdk
yarn build

npm run build
popd
2 changes: 1 addition & 1 deletion scripts/travis/end-to-end-tests.sh
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
16 changes: 9 additions & 7 deletions scripts/travis/install-deps.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/sh
#!/bin/bash

set -ex
npm 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 ..
pushd matrix-js-sdk
yarn link
yarn install
popd

yarn link matrix-js-sdk
yarn install
4 changes: 2 additions & 2 deletions scripts/travis/riot-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -10,5 +10,5 @@ RIOT_WEB_DIR=riot-web

scripts/travis/build.sh
pushd "$RIOT_WEB_DIR"
npm run test
yarn test
popd
4 changes: 2 additions & 2 deletions scripts/travis/unit-tests.sh
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 9585f11

Please sign in to comment.