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.
This commit is contained in:
J. Ryan Stinnett 2019-03-12 11:06:57 +00:00
parent 13aca0716a
commit 1312ba537a
12 changed files with 89 additions and 107 deletions

View file

@ -85,8 +85,8 @@ if [ -n "$conffile" ]; then
pushd "$builddir"
fi
npm install
npm run build:electron
yarn install
yarn build:electron
popd

View file

@ -54,9 +54,6 @@ function dodep() {
fi
echo "$repo set to branch "`git -C "$repo" rev-parse --abbrev-ref HEAD`
mkdir -p node_modules
npm link "./$repo" # This does an npm install for us
}
##############################
@ -66,6 +63,13 @@ echo 'Setting up matrix-js-sdk'
dodep matrix-org matrix-js-sdk
pushd matrix-js-sdk
yarn link
yarn install
popd
yarn link matrix-js-sdk
echo -en 'travis_fold:end:matrix-js-sdk\r'
##############################
@ -75,23 +79,21 @@ echo 'Setting up matrix-react-sdk'
dodep matrix-org matrix-react-sdk
# replace the version of js-sdk that got pulled into react-sdk with a link
# to our version. Make sure to do this *after* doing 'npm i' in react-sdk,
# otherwise npm helpfully moves another-json from matrix-js-sdk/node_modules
# into matrix-react-sdk/node_modules.
#
# (note this matches the instructions in the README.)
cd matrix-react-sdk
npm link ../matrix-js-sdk
cd ../
pushd matrix-react-sdk
yarn link
yarn link matrix-js-sdk
yarn install
popd
yarn link matrix-react-sdk
echo -en 'travis_fold:end:matrix-react-sdk\r'
##############################
# Link the reskindex binary in place: if we used npm link,
# npm would do this for us, but we don't because we'd have
# to define the npm prefix somewhere so it could put the
# Link the reskindex binary in place: if we used `yarn link`,
# Yarn would do this for us, but we don't because we'd have
# to define the Yarn binary prefix somewhere so it could put the
# intermediate symlinks there. Instead, we do it ourselves.
mkdir -p node_modules/.bin
ln -sfv ../matrix-react-sdk/scripts/reskindex.js node_modules/.bin/reskindex

View file

@ -8,31 +8,17 @@ nvm use 10
set -x
npm install
# check out corresponding branches of dependencies.
#
# clone the deps with depth 1: we know we will only ever need that one
# commit.
# We need to do this after npm install otherwise modern node versions
# just reset it back.
# clone the deps with depth 1: we know we will only ever need that one commit.
`dirname $0`/fetch-develop.deps.sh --depth 1
# install olm. A naive 'npm i ./olm/olm-*.tgz' fails because it uses the url
# from our package.json (or even matrix-js-sdk's) in preference.
#
# disabled for now, to avoid the annoying scenario of a release doing something
# different to /develop. Instead, add it to the 'npm install' list above.
# -- rav 2016/02/03
#tar -C olm -xz < olm/olm-*.tgz
#rm -r node_modules/olm
#cp -r olm/package node_modules/olm
yarn install
# run the mocha tests
npm run test
yarn test
# run eslint
npm run lintall -- -f checkstyle -o eslint.xml || true
yarn lintall -- -f checkstyle -o eslint.xml || true
rm dist/riot-*.tar.gz || true # rm previous artifacts without failing if it doesn't exist

View file

@ -13,11 +13,11 @@ else
version=`git describe --dirty --tags || echo unknown`
fi
npm run clean
npm run build$dev
yarn clean
yarn build$dev
# include the sample config in the tarball. Arguably this should be done by
# `npm run build`, but it's just too painful.
# `yarn build`, but it's just too painful.
cp config.sample.json webapp/
mkdir -p dist

View file

@ -9,13 +9,13 @@ if (!moduleName) {
const argString = process.argv.length > 3 ? process.argv.slice(3).join(" ") : "";
if (!argString) {
console.error("Expected an npm argument string to use");
console.error("Expected an yarn argument string to use");
process.exit(1);
}
const modulePath = path.dirname(require.resolve(`${moduleName}/package.json`));
child_process.execSync("npm " + argString, {
child_process.execSync("yarn " + argString, {
env: process.env,
cwd: modulePath,
stdio: ['inherit', 'inherit', 'inherit'],