Created
May 17, 2017 23:54
-
-
Save digiwano/1df204da60eb628beb4c6146b8a58ec4 to your computer and use it in GitHub Desktop.
yarn install --production brokenness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
toplevel=$(pwd) | |
createPackageJson() { | |
dir=$1 | |
cmd="$2" | |
nodeps=$3 | |
file="${dir}/package.json" | |
if [[ -z "$nodeps" ]]; then | |
cat <<EOF > $file | |
{ | |
"name": "bad-deps-${dir}", | |
"version": "1.0.0", | |
"description": "illustration of '${cmd}' WITH dev dependencies ", | |
"main": "index.js", | |
"scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { "json-stringify-safe": "^5.0.1" }, | |
"devDependencies": { "ava": "^0.19.0", "aws-sdk": "^2.2.0", "nyc": "^10.3.2", "sequelize-cli": "^2.7.0", "serverless": "^1.13.1", "sinon": "^2.2.0" } | |
} | |
EOF | |
else | |
cat <<EOF > $file | |
{ | |
"name": "bad-deps-${dir}", | |
"version": "1.0.0", | |
"description": "illustration of '${cmd}' WITHOUT dev dependencies", | |
"main": "index.js", | |
"scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { "json-stringify-safe": "^5.0.1" } | |
} | |
EOF | |
fi | |
} | |
runTest() { | |
dir=$1 | |
cmd="$2" | |
nodeps=$3 | |
( printf "======= $cmd (./$dir/) :\n" \ | |
&& mkdir $dir \ | |
&& createPackageJson $dir "$cmd" $nodeps \ | |
&& cd $dir \ | |
&& eval "$cmd" > ./install.stdout 2>./install.stderr \ | |
&& printf 'Size of node_modules: ' \ | |
&& du -hs node_modules \ | |
&& printf 'Number of folders in node_modules: ' \ | |
&& (find node_modules -depth 1 -type d | wc -l) \ | |
&& printf 'Number of folders in node_modules (recursively): ' \ | |
&& (find node_modules -type d | wc -l) \ | |
&& printf '\n\n' \ | |
|| exit 1 | |
) | |
} | |
runTest test.npm.dev.withdevdeps "npm install" | |
runTest test.npm.dev.nodevdeps "npm install" true | |
runTest test.yarn.dev.withdevdeps "yarn install" | |
runTest test.yarn.dev.nodevdeps "yarn install" true | |
runTest test.npm.prod.withdevdeps "npm install --production" | |
runTest test.npm.prod.nodevdeps "npm install --production" true | |
runTest test.yarn.prod.withdevdeps "yarn install --production" | |
runTest test.yarn.prod.nodevdeps "yarn install --production" true | |
mkdir -p $toplevel/why-explanations | |
for i in $(find test.yarn.prod.withdevdeps/node_modules -type d -depth 1 | cut -d/ -f3-); do | |
trg="$toplevel/why-explanations/$i.txt" | |
printf "##### $i\n" > $trg | |
(cd $toplevel/test.yarn.prod.withdevdeps && yarn why $i | grep depends | sed 's/^[^"]*"/"/') >> $trg | |
cat $trg | |
printf "\n" | |
done | |
echo | |
md5 test.*/yarn.lock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment