Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/install-all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

ROOT=$(pwd)
LIB="$ROOT/lib/wallet-common"

Expand All @@ -9,14 +11,12 @@ LIB="$ROOT/lib/wallet-common"
for dir in */ ; do
if [ -f "$dir/package.json" ]; then
echo "Installing dependencies for $(basename $dir)"
(cd "$dir" && rm -rf node_modules && yarn install)
(cd "$dir" && rm -rf node_modules && yarn install --frozen-lockfile)
fi
done

wait

if [ "${WALLET_COMMON_SOURCE}" = "local" ]; then
node ./scripts/set-wallet-common-source.js local
node ./scripts/set-wallet-common-source.js local --skip-install
elif [ "${WALLET_COMMON_SOURCE}" = "default" ]; then
node ./scripts/set-wallet-common-source.js default
node ./scripts/set-wallet-common-source.js default --skip-install
fi
18 changes: 12 additions & 6 deletions scripts/set-wallet-common-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const path = require('path');
const root = path.resolve(__dirname, '..');
const walletCommonPath = path.join(root, 'lib', 'wallet-common');
const mode = process.argv[2];
const options = new Set(process.argv.slice(3));
const skipInstall = options.has('--skip-install');
const allowedModes = new Set(['local', 'default']);

if (!allowedModes.has(mode)) {
console.error('Usage: node scripts/set-wallet-common-source.js <local|default>');
console.error('Usage: node scripts/set-wallet-common-source.js <local|default> [--skip-install]');
process.exit(1);
}

Expand Down Expand Up @@ -72,8 +74,10 @@ function isLinked(pkgName, cwd) {
}

if (mode === 'local') {
run('yarn', ['install', '--frozen-lockfile'], walletCommonPath);
run('yarn', ['build'], walletCommonPath);
if (!skipInstall) {
run('yarn', ['install', '--frozen-lockfile'], walletCommonPath);
run('yarn', ['build'], walletCommonPath);
}
run('yarn', ['link'], walletCommonPath);
for (const dir of consumers) {
console.log(`Linked wallet-common path: ${path.join(root, dir)}`);
Expand All @@ -92,10 +96,12 @@ if (mode === 'local') {
if (isLinked('wallet-common', walletCommonPath)) {
runOptional('yarn', ['unlink'], walletCommonPath);
} else {
console.log(`Skipping unlink wallet-common from lib/wallet-common - not linked`);
console.log(`Skipping unlink wallet-common from lib/wallet-common - not linked`);
}
for (const dir of consumers) {
run('yarn', ['install', '--frozen-lockfile'], path.join(root, dir));
if (!skipInstall) {
for (const dir of consumers) {
run('yarn', ['install', '--frozen-lockfile'], path.join(root, dir));
}
}
console.log(`Restored wallet-common from package.json in: ${consumers.join(', ')}`);
}