diff --git a/.gitignore b/.gitignore index 7857bb294f..0c93b88b66 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.nyc_output /coverage /dist +/dist-debug /artifacts /updates /.roadrunner.json diff --git a/.npmignore b/.npmignore index 137ce671c2..9bde84b333 100644 --- a/.npmignore +++ b/.npmignore @@ -24,6 +24,7 @@ /scripts /coverage /dist +/dist-debug /__tests__ /.roadrunner.json .vs diff --git a/appveyor.yml b/appveyor.yml index 9876463ea5..a0e8111203 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,9 +14,8 @@ install: build_script: - ps: if ($env:APPVEYOR_REPO_BRANCH -eq 'master') { node ./scripts/set-dev-version.js } - - npm run build - - ps: ./scripts/build-dist.ps1 - - npm run build-win-installer + - yarn run build-dist + - yarn run build-win-installer test_script: - node --version diff --git a/bin/yarn-bundle-entry.js b/bin/yarn-bundle-entry.js new file mode 100644 index 0000000000..a005a92e24 --- /dev/null +++ b/bin/yarn-bundle-entry.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node + +/* eslint-disable flowtype/require-valid-file-annotation */ +'use strict'; + +require('../lib/v8-compile-cache'); +module.exports = require('../lib/yarn-cli'); diff --git a/circle.yml b/circle.yml index 627a035d4f..5fd904f6f3 100644 --- a/circle.yml +++ b/circle.yml @@ -31,10 +31,12 @@ test: - yarn lint - yarn test-ci -- -- --maxWorkers 3 - yarn check-lockfile - - yarn build-dist - - node ./scripts/build-webpack.js - - ls -t1 artifacts | head -n2 | while read entry; do node "./artifacts/$entry" --version; done - - ./scripts/build-deb.sh + - yarn run build-dist + - yarn run build-deb + # Test that the standalone .js build works as expected + - ./artifacts/yarn-`./dist/bin/yarn --version`.js --version + - ./artifacts/yarn-legacy-`./dist/bin/yarn --version`.js --version + # Test that installing as root works and that it also works # behind a user namespace which Circle CI tests are run under - sudo env "PATH=$PATH" bin/yarn install --force diff --git a/package.json b/package.json index 6241b27590..3e0909ccc5 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,9 @@ "test-only": "jest --coverage --verbose", "lint": "eslint . && flow check", "release-branch": "./scripts/release-branch.sh", - "build-dist": "./scripts/build-dist.sh", + "build-bundle": "node ./scripts/build-webpack.js", + "build-deb": "./scripts/build-deb.sh", + "build-dist": "bash ./scripts/build-dist.sh", "build-chocolatey": "powershell ./scripts/build-chocolatey.ps1", "build-win-installer": "scripts\\build-windows-installer.bat" }, diff --git a/scripts/build-deb.sh b/scripts/build-deb.sh index 993ffb873a..fc3f3475c1 100755 --- a/scripts/build-deb.sh +++ b/scripts/build-deb.sh @@ -27,30 +27,18 @@ mkdir -p $OUTPUT_DIR # Remove old packages rm -f $OUTPUT_DIR/*.deb $OUTPUT_DIR/*.rpm -# Extract to a temporary directory +# Create temporary directory to start building up the package rm -rf $PACKAGE_TMPDIR mkdir -p $PACKAGE_TMPDIR/ umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) -tar zxf $TARBALL_NAME -C $PACKAGE_TMPDIR/ PACKAGE_TMPDIR_ABSOLUTE=$(readlink -f $PACKAGE_TMPDIR) # Create Linux package structure mkdir -p $PACKAGE_TMPDIR/usr/share/yarn/ mkdir -p $PACKAGE_TMPDIR/usr/share/doc/yarn/ -mv $PACKAGE_TMPDIR/dist/bin $PACKAGE_TMPDIR/usr/share/yarn/ -mv $PACKAGE_TMPDIR/dist/lib $PACKAGE_TMPDIR/usr/share/yarn/ -mv $PACKAGE_TMPDIR/dist/lib-legacy $PACKAGE_TMPDIR/usr/share/yarn/ -mv $PACKAGE_TMPDIR/dist/node_modules $PACKAGE_TMPDIR/usr/share/yarn/ -mv $PACKAGE_TMPDIR/dist/package.json $PACKAGE_TMPDIR/usr/share/yarn/ +tar zxf $TARBALL_NAME -C $PACKAGE_TMPDIR/usr/share/yarn/ --strip 1 cp resources/debian/copyright $PACKAGE_TMPDIR/usr/share/doc/yarn/copyright -# These are unneeded and throw lintian lint errors -rm -f $PACKAGE_TMPDIR/usr/share/yarn/node_modules/node-uuid/benchmark/bench.gnu -find $PACKAGE_TMPDIR/usr/share/yarn \( -name '*.md' -o -name '*.md~' -o -name '*.gitmodules' \) -delete - -# Assume everything else is junk we don't need -rm -rf $PACKAGE_TMPDIR/dist - # The Yarn executable expects to be in the same directory as the libraries, so # we can't just copy it directly to /usr/bin. Symlink them instead. mkdir -p $PACKAGE_TMPDIR/usr/bin/ diff --git a/scripts/build-dist-debug.sh b/scripts/build-dist-debug.sh new file mode 100755 index 0000000000..8587426efd --- /dev/null +++ b/scripts/build-dist-debug.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -ex + +# This is similar to build-dist.sh, except it includes the original .js files +# rather than bundling them into a single .js file. This distribution can +# potentially be useful for debugging purposes, but it's more bloated than the +# regular distribution. + +npm run build +npm pack +rm -rf dist-debug +mkdir dist-debug +mkdir -p artifacts +mv yarn-*.tgz dist-debug/pack.tgz + +cd dist-debug +umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) +tar -xzf pack.tgz --strip 1 +rm -rf pack.tgz +# Change this to "yarn install --production" once #1115 is fixed +npm install --production +../scripts/set-installation-method.js $(readlink -f package.json) tar +cd .. + +tar -cvzf artifacts/yarn-v`dist-debug/bin/yarn --version`.tar.gz dist-debug/* +shasum -a 256 artifacts/yarn-*.tar.gz diff --git a/scripts/build-dist.ps1 b/scripts/build-dist.ps1 deleted file mode 100644 index 08ac1d5d69..0000000000 --- a/scripts/build-dist.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -$ErrorActionPreference = 'Stop' - -npm run build -# Change this to "yarn pack" once #1114 is fixed -npm pack -if (Test-Path dist) { - rm dist -Recurse -} -mkdir dist -mv yarn-*.tgz dist/pack.tgz - -cd dist -tar -xzf pack.tgz --strip 1 -rm pack.tgz -# Change this to "yarn install --production" once #1115 is fixed -npm install --production -../scripts/clean-node-modules.ps1 -cd .. diff --git a/scripts/build-dist.sh b/scripts/build-dist.sh index 9146bc6975..1c62a12580 100755 --- a/scripts/build-dist.sh +++ b/scripts/build-dist.sh @@ -1,23 +1,40 @@ -#!/bin/sh - +#!/bin/bash set -ex +# Builds the release tarball for Yarn. + +umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) -npm run build -npm pack +# Workaround for https://github.com/yarnpkg/yarn/issues/2591 +case "$(uname -s)" in + *CYGWIN*|MSYS*|MINGW*) + dist_yarn=dist/bin/yarn.cmd + system_yarn=yarn.cmd + ;; + *) + dist_yarn=dist/bin/yarn + system_yarn=yarn + ;; +esac + +rm -rf artifacts dist rm -rf dist -mkdir dist -mkdir -p artifacts -mv yarn-*.tgz dist/pack.tgz +mkdir artifacts +mkdir dist{,/bin,/lib} -cd dist -umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) -tar -xzf pack.tgz --strip 1 -rm -rf pack.tgz -# Change this to "yarn install --production" once #1115 is fixed -npm install --production -../scripts/clean-node-modules.sh -../scripts/set-installation-method.js $(readlink -f package.json) tar -cd .. +# Workaround for https://github.com/yarnpkg/yarn/issues/2591 +eval $system_yarn run build +eval $system_yarn run build-bundle +chmod +x artifacts/*.js + +cp package.json dist/ +cp LICENSE dist/ +cp artifacts/yarn-legacy-*.js dist/lib/yarn-cli.js +cp bin/yarn-bundle-entry.js dist/bin/yarn.js +cp bin/{yarn,yarnpkg,*.cmd} dist/bin/ +cp -r bin/node-gyp-bin dist/bin/ +# We cannot bundle v8-compile-cache as it must be loaded separately to be effective. +cp node_modules/v8-compile-cache/v8-compile-cache.js dist/lib/v8-compile-cache.js -tar -cvzf artifacts/yarn-v`dist/bin/yarn --version`.tar.gz dist/* -shasum -a 256 artifacts/yarn-*.tar.gz +version=`exec $dist_yarn --version` +./scripts/set-installation-method.js $(readlink -f dist/package.json) tar +tar -cvzf artifacts/yarn-v$version.tar.gz dist/* diff --git a/scripts/build-webpack.js b/scripts/build-webpack.js index b94d2aa7e2..acaa909c59 100755 --- a/scripts/build-webpack.js +++ b/scripts/build-webpack.js @@ -38,7 +38,7 @@ const compiler = webpack({ }); compiler.run((err, stats) => { - const {fileDependencies} = stats.compilation; + const fileDependencies = stats.compilation.fileDependencies; const filenames = fileDependencies.map(x => x.replace(basedir, '')); console.log(util.inspect(filenames, {maxArrayLength: null})); }); diff --git a/scripts/clean-node-modules.ps1 b/scripts/clean-node-modules.ps1 deleted file mode 100755 index 2e705173b6..0000000000 --- a/scripts/clean-node-modules.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -# sometimes folders may not exist according to node/npm version etc so ignore them -$ErrorActionPreference = 'Continue' - -# random browser builds that aren't used -rm node_modules/core-js/client -Recurse - -# remove typescript files -rm node_modules/rx/ts -Recurse - -# naughty modules that have their test folders -rm node_modules/*/test -Recurse diff --git a/scripts/clean-node-modules.sh b/scripts/clean-node-modules.sh deleted file mode 100755 index 7d39da0a26..0000000000 --- a/scripts/clean-node-modules.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# random browser builds that aren't used -rm -rf node_modules/core-js/client - -# remove typescript files -rm -rf node_modules/rx/ts - -# naughty modules that have their test folders -rm -rf node_modules/*/test