Commit Graph

60 Commits

Author SHA1 Message Date
Burak Yigit Kaya
3a3bed7520 build(node4): Drop Node 4 builds which has expired
Thanks for all the fish Node 4, you won't be missed.
2018-04-26 10:19:19 +01:00
kaylieEB
aa855c5c59 fix(CLI): Use process exit instead of exitCode for node < 4 (#5291)
* fix(CLI): Use process exit instead of exitCode

Since node 0.10 doesn't support process.exitCode, use process.exit

* lint
2018-01-30 12:07:39 +00:00
Hiro Asari
0691037487 fix(cli): Write Node4+ error message to stderr (#5094)
**Summary**

_To be a good citizen of UNIX ecosystem._

One may write a script to add `$(yarn global bin)` to `$PATH`, but one must consider different cases depending on what this command returns in STDOUT. This is not ideal. 

And, of course, error messages such as this naturally belongs to STDERR.
 
**Test plan**

```sh-session
$ yarn global bin 2>/dev/null
$
```
2017-12-15 14:23:14 +00:00
Brian K. Christensen
75bc4505df fix(windows): Detect when winpty is present and if the current terminal is a TTY (#4577)
**Summary**

This addresses some of the windows issues regarding running yarn in gitbash and friends envrionment.
with this fix I keep the behavior introduced 5 months ago in yarnpkg/yarn#3245, but try to do a better job detecting when to use winpty out of the box, in order make `piping` of output work with yarn.

Before this fix:
```shell
$ yarn --version
1.1.0
$ yarn --version | cat
1.1.0
$ yarn init
yarn init v1.1.0
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "D:\\workspace\\yarn\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
```

Piping works for simple commands, but interactive commands only work with an environment set to something. This prohibits scripts/tools around yarn that uses pipe, which is quite common to do in an unix like environment, but theses tools cannot work in windows' unix like environment.

WinPTY seems to be the savior here, but we need to only run yarn through winpty when a tty actually needs to be allocated. 

Previous attempts to solve this problem like: 
- yarnpkg/yarn#2230
- yarnpkg/yarn#2243

Did not address the use cases of piping, so they essentially broke that behavior.
Then yarnpkg/yarn#3245 fixed that, but now you have to use `YARN_FORCE_WINPTY=1` environment variable in order for `yarn init` and `yarn upgrade-interactive` to work and that's alright, but if you export that variable then piping is broken yet again because the variable will also be set in the piped command, and we haven't solved any problem.

I suggest we keep the environment variable behavior but open up for better detection when to use winpty out of the box.

This fix detects if the winpty binary is in path, and only use it if stdin is in fact a TTY: `test -t 1`. 

**Test plan**

The output of running:
- `yarn init`
- `yarn upgrade-interactive`
- `yarn --version | cat`

Without having the `YARN_FORCE_WINPTY=1` environment variable set.

```shell
$ ./bin/yarn init
yarn init v1.1.0
question name (yarn):

$ ./bin/yarn upgrade-interactive
yarn upgrade-interactive v1.1.0
info Color legend :
 "<red>"    : Major Update backward-incompatible updates
 "<yellow>" : Minor Update backward-compatible features
 "<green>"  : Patch Update backward-compatible bug fixes
? Choose which packages to update. (Press <space> to select, <a> to toggle all, <i> to inverse selection)
 devDependencies
   name                         range                      from               to             url
>( ) babel-core                   ^6.24.1                    6.24.1          ❯  6.26.0         https://babeljs.io/
 ( ) babylon                      ^6.5.0                     6.17.1          ❯  6.18.0         https://babeljs.io/
 ( ) eslint                       ^4.3.0                     4.3.0           ❯  4.7.2          http://eslint.org
 ( ) eslint-config-fb-strict      ^20.1.0-delta.3            20.1.0-delta.3  ❯  20.1.0-echo.1  https://github.com/facebook/jest#readme
 ( ) eslint-plugin-babel          ^4.0.0                     4.1.1           ❯  4.1.2          https://github.com/babel/eslint-plugin-babel#readme
 ( ) eslint-plugin-flowtype       ^2.35.0                    2.35.0          ❯  2.36.0         https://github.com/gajus/eslint-plugin-flowtype#readme
 ( ) eslint-plugin-jasmine        ^2.6.2                     2.6.2           ❯  2.8.4          https://github.com/tlvince/eslint-plugin-jasmine
 ( ) eslint-plugin-prettier       ^2.1.2                     2.1.2           ❯  2.3.1          https://github.com/prettier/eslint-plugin-prettier#readme
 ( ) eslint-plugin-react          ^7.1.0                     7.1.0           ❯  7.4.0          https://github.com/yannickcr/eslint-plugin-react
 ( ) eslint-plugin-yarn-internal  file:scripts/eslint-rules  0.0.0           ❯  exotic         file:scripts/eslint-rules
 ( ) gulp-sourcemaps              ^2.2.0                     2.6.0           ❯  2.6.1          http://github.com/gulp-sourcemaps/gulp-sourcemaps
 ( ) prettier                     ^1.5.2                     1.5.2           ❯  1.7.2          https://prettier.io
 ( ) webpack                      ^2.1.0-beta.25             2.6.0           ❯  2.7.0          https://github.com/webpack/webpack

 dependencies
   name                         range                      from               to             url
 ( ) babel-runtime                ^6.0.0                     6.23.0          ❯  6.26.0         https://github.com/babel/babel/tree/master/packages/babel-runtime
 ( ) commander                    ^2.9.0                     2.9.0           ❯  2.11.0         https://github.com/tj/commander.js#readme
 ( ) debug                        ^2.2.0                     2.6.8           ❯  2.6.9          https://github.com/visionmedia/debug#readme
 ( ) gunzip-maybe                 ^1.4.0                     1.4.0           ❯  1.4.1          https://github.com/mafintosh/gunzip-maybe
 ( ) inquirer                     ^3.0.1                     3.0.6           ❯  3.3.0          https://github.com/SBoudrias/Inquirer.js#readme
 ( ) node-emoji                   ^1.6.1                     1.6.1           ❯  1.8.1          https://github.com/omnidan/node-emoji#readme
 ( ) request                      ^2.81.0                    2.81.0          ❯  2.83.0         https://github.com/request/request#readme
 ( ) rimraf                       ^2.5.0                     2.6.1           ❯  2.6.2          https://github.com/isaacs/rimraf#readme
 ( ) semver                       ^5.1.0                     5.3.0           ❯  5.4.1          https://github.com/npm/node-semver#readme
 ( ) tar-fs                       ^1.15.1                    1.15.2          ❯  1.15.3         https://github.com/mafintosh/tar-fs
 ( ) uuid                         ^3.0.1                     3.0.1           ❯  3.1.0          https://github.com/kelektiv/node-uuid#readme

$ ./bin/yarn --version | cat
1.1.0
$
```

And importantly when running the interactive commands through a pipe, it will correctly fail by saying you not are running the interactive commands in a TTY:

```shell
 $ ./bin/yarn init | cat
yarn init v1.1.0
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "D:\\workspace\\yarn\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.

 $ ./bin/yarn upgrade-interactive | cat
yarn upgrade-interactive v1.1.0
info Color legend :
 "<red>"    : Major Update backward-incompatible updates
 "<yellow>" : Minor Update backward-compatible features
 "<green>"  : Patch Update backward-compatible bug fixes
Done in 1.43s.
Error: Can't answer a question unless a user TTY
    at D:\workspace\yarn\lib\reporters\console\console-reporter.js:487:31
    at Generator.next (<anonymous>)
    at step (D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:35:14
    at Promise (<anonymous>)
    at F (D:\workspace\yarn\node_modules\core-js\library\modules\_export.js:35:28)
    at D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:14:12
    at ConsoleReporter.prompt (D:\workspace\yarn\lib\reporters\console\console-reporter.js:518:7)
    at Object.<anonymous> (D:\workspace\yarn\lib\cli\commands\upgrade-interactive.js:116:38)
    at Generator.next (<anonymous>)
```
2017-09-29 14:50:03 +01:00
Burak Yiğit Kaya
2c54c02453 Fix: Fix single-file builds and simplify bundles (#4063)
**Summary**

Fixes #4057.

**Test plan**

CI should pass, especially with `build-dist` job.

Manual:

 - Run `yarn build-dist`
 - Run `node artifacts/yarn-0.28.0.js --version`
 - Run `./dist/bin/yarn --version`

Make sure all above commands work without errors.
2017-08-02 12:54:40 +01:00
Burak Yiğit Kaya
357dc22550 Chore: enable no-process-exit lint rule (#4026)
**Summary**

A follow up to #3955 to disable further usage of `process.exit()`.

**Test plan**

`yarn lint` should not produce any errors.
2017-07-27 15:51:30 +01:00
Burak Yiğit Kaya
61e402b1f7 Fix: avoid using process.exit() when possible (#3955)
**Summary**

Refs #3524. We are using `process.exit()` pretty liberally although it is [strongly advised not to use it](https://nodejs.org/api/process.html#process_process_exit_code) since it may cause the `stdout` to get corrupted/terminated before a full flush. This patch changes all possible `process.exit(code)` calls with `process.exitCode = code` statements.

We'd also ideally enable [no-process-exit](http://eslint.org/docs/rules/no-process-exit) rule in ESLint but it requires an upgrade to ESLint v4 which should be handled separately.

**Test plan**

Expect tests to pass and actually finish (not run indefinitely due to `yarn` not exiting at all). Also, the script referenced in #3524 to output something like the following:
```
DATA 18
DATA 8192
DATA 8192
DATA 5392
DATA 15
EXIT 0
```
2017-07-20 17:23:28 +01:00
Roman Dragan
acbb8021aa Add exec to node commands in the binary (#3965) 2017-07-19 15:11:29 +01:00
Kishan Bagaria
9acdd68db4 Refactor and optimize bin/yarn.js (#3482)
* Refactor and optimize yarn.js

* Refactor and add `watch-modern` task
2017-05-26 00:51:06 +01:00
Daniel Lo Nigro
859a6ba4de Make yarn-bundle-entry.js executable 2017-05-12 10:10:36 -07:00
PICHOU Kyâne
44ff2c3fd7 Fix yarn "entrypoint" shell script (#3362)
#3260 PR broke the `bin/yarn` shell script (see issue #3321)
#3338 tried to fix it in a improper way

This way should work.
2017-05-11 14:46:24 +01:00
Konstantin Raev
cd9bdd5d10 fixed unary line 16: [: : integer expression expected (#3260) 2017-04-26 17:17:19 +01:00
mikew
a45a6775eb Change use_winpty logic in bin/yarn to just look at YARN_FORCE_WINPTY in environment (#3245) 2017-04-26 15:57:30 +01:00
Daniel Lo Nigro
50c5bf0cde Use npm's node-gyp if available, otherwise automatically install node-gyp (#3240)
* Attempt to install node-gyp if it's required but missing

* Try to use node-gyp version from npm

* Trailing commas
2017-04-24 10:44:48 +01:00
Daniel Lo Nigro
e086476e8c Remove Roadrunner (#3079) 2017-04-08 14:55:11 -07:00
Daniel Lo Nigro
3af60cf9c1 Use standalone .js bundle in dist tarball rather than individual JS files (#3030)
Instead of including all the raw JS files in the dist tarball, just use the single Yarn JS file that's built as part of the build, along with a few other files that are required. This significantly reduces the number of files in the tarball:

```
C:\src\yarn\dist (bundle-as-dist) (yarn@0.23.0-0)
λ find .
.
./bin
./bin/node-gyp-bin
./bin/node-gyp-bin/node-gyp
./bin/node-gyp-bin/node-gyp.cmd
./bin/yarn
./bin/yarn.cmd
./bin/yarn.js
./bin/yarnpkg
./bin/yarnpkg.cmd
./lib
./lib/v8-compile-cache.js
./lib/yarn-cli.js
./LICENSE
./package.json
```

There are three .js files in the archive:
 - `lib/v8-compile-cache.js`:  Speeds up instantiation time by using the V8 code cache (https://www.npmjs.com/package/v8-compile-cache). This needs to be separate as it has to load **before** the bulk of the application code is loaded, so it can **not** be bundled
 - `lib/yarn-cli.js`: Contains all the bundled Yarn code
 - `bin/yarn.js`: Entry point to the app, just like today. Loads `v8-compile-cache` then loads `yarn-cli`

This change means that **only** the JavaScript files that are actually used are included, resulting in a nice file size reduction for the installation packages:
![](http://ss.dan.cx/2017/04/Yarn_bundle_dist_metrics_-_Google_Sheets_-_Google__01-13.51.49.png)

Differences are due to differing compression algorithms: Debian packages use xz or LZMA, RedHat uses gzip, Windows installer uses Cabinet

They're also slightly faster to extract:
![image 3](https://cloud.githubusercontent.com/assets/91933/24582332/483b41f4-16e2-11e7-9509-8024b1e78a39.png)

Testing was performed on my desktop computer (Intel Core i5 6500, Samsung 850 Evo 1TB SSD, Windows 10), with testing for Linux stuff (like installing the Debian package) tested in a Docker container.

Raw data: https://docs.google.com/spreadsheets/d/1d8jdf3DU_GUFdotlPl08PkYa8SkzStK2tgnQ54ivsm0/edit?usp=sharing

Performance is very slightly faster when using `v8-compile-cache` along with the bundled file, but it's not extremely significant (`yarn --version` went from 0.19s to 0.14s on my BuyVM server). The difference might be bigger on servers with slower disks (HDD) or with more overloaded servers.

I also deleted the `build-dist.ps1` file because we _should_ be able to assume that Bash is available on Windows, particularly if Git is installed (as it comes with Git Bash). I need to verify that this works on AppVeyor.
2017-04-08 14:40:19 -07:00
Aaron Harris
3d20a522a4 Added yarnpkg.cmd batch shim for backwards-compatibility on Windows (#2534) (#2746) 2017-02-25 00:56:11 -08:00
Andres Suarez
b7ba34693f Add v8-compile-cache (#2749) 2017-02-23 14:02:01 +00:00
Daniel Lo Nigro
975051070b Remove logic for loading self-update versions (#2720) 2017-02-19 22:46:11 +00:00
philtay
6a29bfed8c Fix clause termination (#2562) 2017-01-26 23:25:08 +00:00
philtay
e25633a02d Canonicalize symlink on Linux only (#2560) 2017-01-26 22:04:49 +00:00
philtay
d203636000 Canonicalize symbolic link (#2441) 2017-01-14 19:07:08 +00:00
Brian K. Christensen
35ca860581 Support interactive commands in standard MINGW as well (#2243)
* Support interactive commands in standard MINGW as well

Previous fix only supported some old configuration of Git bash
provided by Git for windows, newer Git bash use standard MINGW
which uses a different `uname` but the fix is ultimately the same

Github: #743

* Refactor: use better variable name when determine to use winpty

* Support both MSYS 32bit and 64bit terminal emulators
2016-12-15 15:46:40 +11:00
Andrew Pinkham
f0541aa1b8 Fix #2177 - Remove GLOBAL_INSTALL_DIRECTORY const (#2216)
Replaced by ~/.config/yarn, as seen in the getDirectory() function in
src/constants.js and the CONFIG_DIRECTORY and GLOBAL_MODULE_DIRECTORY
constants.
2016-12-13 15:18:22 +00:00
Brian K. Christensen
8515f9b9ba Fix #743 - make yarn interactive commands run in Git Bash/MSYS env (#2230) 2016-12-13 13:29:58 +11:00
Andrew Pinkham
7fe2e53a59 Fix #1941 - Allow yarn script to be linked (#2217) 2016-12-12 10:33:04 +11:00
Sebastian McKenzie
5ee3721c08 add a cache breaker to the yarn cache based on the current version to prevent dependency shifting (#1965) 2016-11-21 11:57:38 +00:00
Hendrik Purmann
c77ade1812 Gracefully quit when using unsupported node version (#1901)
Fixes #1898
2016-11-17 08:14:02 -06:00
Neil Kistner
4ce67f3d5d Ensure cache diretory exists before using roadrunner (#1902) 2016-11-17 10:12:37 +00:00
Daniel Lo Nigro
e2f5c26886 Convert "yarn" executable to a shell script that runs either "node" or "nodejs" (#1180)
Also fixes Cygwin.
Closes #1142
Closes #819
2016-10-18 16:30:51 +01:00
Hemanth.HM
553e55f146 Better error message. 2016-10-18 15:07:31 +01:00
Daniel Tschinder
b584b4f089 Fix self-update (#676)
* Fix self-update

Pick the correct file to download in self-update
We cannot rely that the first asset is always the tar file
This picks the correct file from the assets

Use dev version of roadrunner and reset it correctly

Enable self-update tests

* Remove github resolving from self-update

* Fix tests.

* Update roadrunner and fix tests

* Increase test timeout to 3 minutes

* disable test because to slow on circleCI
2016-10-17 15:55:45 +01:00
Sebastian McKenzie
40490c25f5 +x on bin/yarnpkg 2016-10-15 20:58:22 +01:00
Sebastian McKenzie
6040f50549 add bin/yarnpkg 2016-10-15 20:08:03 +01:00
Sebastian McKenzie
b642846f98 remove symlink 2016-10-11 16:19:05 +01:00
Daniel Lo Nigro
f1adbc6da5 Make yarn a symlink to yarn.js 2016-10-10 12:01:13 -07:00
Joel Marcey
953c238514 Add bin/ to the wrapper script commmand in bin/yarn
`
2016-10-10 11:50:33 -07:00
Daniel Lo Nigro
2010f7d0c1 Rename yarn back to yarn.js as a bunch of things still rely on it being called yarn.js. Add a wrapper shell script instead. 2016-10-10 10:40:05 -07:00
Sebastian McKenzie
453d396235 Tarball install (#568)
* rename yarn package to yarnpkg

* add install-latest script
2016-10-10 14:38:02 +01:00
Sebastian McKenzie
2465450060 put roadrunner cache in ~/.yarn - fixes #517 (#518) 2016-10-05 18:31:40 +01:00
Sebastian McKenzie
080d7a35b3 prune tag from node version when checking bin/yarn compatibility - fixes #511 (#512) 2016-10-05 15:18:16 +01:00
Daniel Lo Nigro
55d7acdb90 Add batch file (yarn.cmd) for executing Yarn on Windows. 2016-10-04 11:40:53 +01:00
Sebastian McKenzie
e45eecbeb6 use roadrunner for caching node module resolution (#446) 2016-09-26 18:48:52 +09:00
Andres Suarez
0893d6bf83 Misc stylings (#409)
* Remove non-existent file from eslintignore

* Fix file case

* Use as consistent style as possible in non-transpiled files
2016-09-22 09:59:00 +01:00
Sebastian McKenzie
6820fb2d33 Rename kpm to yarn (#362) 2016-09-20 15:03:11 +01:00
Sebastian McKenzie
46e8be5a9b remove patents and facebook license headers 2016-09-16 20:27:37 +01:00
Sebastian McKenzie
fe33d41c76 Rethrow last module not found error when we fail to load bin/kpm - fixes #300 2016-09-08 04:02:35 +01:00
Sebastian McKenzie
5300b482c8 Cleanup workflow (#281)
* Rename --quick-sloppy flag from `kpm check` to --integrity

* Make --save implicit when installing new modules, remove strict lockfiles, always create updated lockfile and populate tarball cache

* Add integrity hash check to `kpm install`

* Update kpm.lock

* remove incorrect assert messages

* split up package resolving and fetching

* update kpm.lock

* clean up activityStep, move back cursor at end to cover worker lines - fixes #262

* use fake jest timers

* remove old test

* add mocks to jest test ignore

* fix test fixture lockfile

* Add lockfile version header - fixes #280

* split up `kpm install` into `kpm add` - closes #284

* fix lint

* fix using `latest` tag when adding new dependencies - fixes #263

* clean up kpm entry files

* add useless `kpm version` command

* rename config.js to Config.js

* remove Makefile and switch to simple npm scripts

* add more flow-typed definitions

* correctly case Config file

* fix misc lint

* fix type annotation of PackageConstraintResolver#reduce

* fix bin/kpm nits and unused variable

* use dashed filenames instead of camelcase

* move add command fixtures to separate folder

* hoist common-mirror test folder
2016-09-06 16:36:48 +01:00
Konstantin Raev
d643e4850f Feature: self updating command that downloads kpm releases from github 2016-08-26 12:18:58 +01:00
Adam Miskiewicz
c9b3b8775f Make node-gyp executable 2016-08-24 17:53:19 -07:00