Commit Graph

82 Commits

Author SHA1 Message Date
Slava Kim
89e0373259 Fix progressbars on Windows 2015-03-02 16:34:04 -08:00
Slava Kim
eeeb3d9f3a Always get the width of the terminal through the width method 2015-03-02 16:27:15 -08:00
Slava Kim
ccd666dc6b Make carriage return portable
In unix we can just use '\r';
In Windows the easiest way is to print a lot of '\b';
2015-01-20 22:03:22 -08:00
Ekaterina Kuznetsova
92a6adf5af Merge pull request #3281 from meteor/console-comments
more, cleaner comments in Console.js
2015-01-20 16:00:55 -08:00
ekatek
12d030dd53 completely rewrite of ‘meteor show’; some changes to ‘meteor search’.
The ‘show’ command has been completely rewritten. It has different output
and now does the following:

- Interacts with local package versions. Checks in the local package catalog, and
  returns the local versions along with the server versions. When ‘meteor show’ is
  run with a specific version request (‘meteor show foo@<version>’), default to
  showing the local package version (but show a message that a server version is
  available). Running ‘meteor show foo@local’ will always show the local version
  (useful for version-less local packages).

- Simplify the interface. Instead of various ‘show-*’ flags, we only have one: show-all.
  By default, we only show the top 5 official (non-prerelease) unmigrated versions of a
  package (+ local version, if applicable). This can be overridden with ‘show-all’, and we
  let the user know that more versions are available. For releases, ‘show-all’ will show
  non-recommended releases.

- Display publication time for non-local package versions. This makes it easier to run
  ‘meteor show <name>’ and see if <name> is actively maintained. For local packages,
  we display the root directory (useful for large apps or running with the
  LOCAL_PACKAGE_DIRS variable, for example).

- For non-local package versions, show if the version is ‘installed’ (downloaded into the
  warehouse). This involved minor changes to tropohouse.js. The idea is that this should
  give a pretty good clue whether the version can be added offline.

- Show version dependencies. This should help the user understand, track down and
  debug constraint solver failures.

- Do not show version architectures except in —ejson mode.

- Allow an ‘—ejson’ flag to get the output in EJSON format. That should make scripting
  easier. (As a bonus, for release versions, the EJSON output acts as a nice template
  for the release configuration file.)

The search command now does the following:

- Interacts with local package versions. Specifically, local versions override equivalent
  server versions. Also, ‘search’ works on local packages (so, for example,
  ‘meteor search troposphere’ inside the package server app will give you the troposphere
  package).

- Allows an ‘—ejson’ flag to get the outout in EJSON format.

Minor changes to some minor testing infrastructure:

 - A new skeleton package, package-for-show. Its versions contain different
   values for various metadata, so we can test that metadata comes from
   the right version.

 - In several places, replace the pattern of copying around
   package.js files with using the replace function on a placeholder
   string. (Mostly, as applied to package versions).

This is based on these hackpads: https://mdg.hackpad.com/Showing-Package-Metadata-HdGo3Lzx3hR
and https://mdg.hackpad.com/Meteor-Search-Output-1xxEzrAK9YU.
2015-01-13 13:53:20 -08:00
ekatek
e4a984fb6f fix mistype 2014-12-12 11:13:45 -08:00
ekatek
3b89779736 more, cleaner comments in Console.js
This explains how to use the Console printing functions. It also moves
some of the documentation around to more public functions where it will be
easier for users to find. (ex: moves Console.options documentation
to Console.options, rather than the internal Console.wrapText)
2014-12-11 22:32:43 -08:00
David Glasser
141acd4200 Tweaks to StatusPoller
- Lower STATUS_INTERVAL_MS from 500 to 50. Note that we were effectively
  doing 150 or 100 anyway: the _pollFiber was polling every 100, and the
  nudged _throttledStatusPoll was actually throttling at the default of
  150, not 500, because the Throttled constructor was being invoked
  incorrectly (without the named 'interval' option).

- Use the same throttler for _pollFiber and nudge.
2014-12-11 12:41:25 -08:00
ekatek
c8e2c9f9d9 change to the right slash 2014-12-08 18:44:28 -08:00
ekatek
07ff83f2c9 rename Console.directory to Console.path, do not escape spaces
Rename Console.directory to Console.path.

Do not attempt to automatically escape spaces in file paths -- it is
hard to define a function that does this only sometimes, rather than all
the time. This is something that we could change later, once we have a better
idea of when we use it.
2014-12-08 18:37:49 -08:00
ekatek
9085975913 automatically escape spaces when printing directories
Directories should not wrap, but, also, we should make sure to automatically
escape spaces ("/ab/a\ b.js" vs "/ab/a b.js"). Because we might need to deal with
user input, we don't know if the user has already escaped the spaces before getting
the string. As such, we should only escape spaces that haven't already been escaped.
2014-12-08 14:54:36 -08:00
ekatek
f3e3dc7bca rename doNotWrap to noWrap in console.js' 2014-12-08 14:44:36 -08:00
ekatek
bcf6b200e1 introducing and using Console.directory
I think that this makes the API too complicated, but we might want to treat
directories the same way that we do commands (use some chalk when needed,
do not wrap, etc). This introduces the Console.directory function.

Of course, it is not really clear to me what happens if a directory is inside a command.
(ex: 'cd <directory>'). Right now, there is no difference. It makes sense to me that
we might want to keep the entire command the same style, so I am not wrapping those
in additional Console.directory units for now.
2014-12-08 14:15:54 -08:00
ekatek
714ed749e7 for URLs replace spaces with %20 instead of just taking care to not wrap them 2014-12-08 11:57:36 -08:00
ekatek
0b4cdc6e12 minor cleanup
- renamed an argument from 'opts' to 'options' in the comments as well.
- fixed some forgotten quotes.
2014-12-06 18:42:36 -08:00
ekatek
c9928d9c3a responding to minor fixes on 3232
- Wrapping URLs in Console.url. Making Console.url not word-wrap URLs,
on the off-chance that a URL could be wrapped.

- Creating a doNotWrap function on the Console. Call this on things that
are not commands or URLs, but still should not be wrapped.

- fixing minor mistypes, removing a comment about the dev bundle on the
Windows branch.
2014-12-06 18:32:40 -08:00
ekatek
8bf5db2de0 eliminate legacy stdout.write and stderr.write functions from Console
Now that we no longer have an automatic newline on printing, we don't have to support
the awkward legacy functions that the Console used to provide. Eliminating.
2014-12-06 17:42:07 -08:00
ekatek
25dfd39ef1 Everywhere that we call a raw function, add a new line 2014-12-06 17:38:41 -08:00
ekatek
dd96477c51 do not automatically print a newline
Raw print functions should not actually print a new line -- that's
an example of processing that we should be doing in the non-raw functions.
As such, _print should not add a new line at the end!

This means that other functions that DID intend to end a new line should add
one manually. Also, a minor refactor to have less repetitive code in the wrapping functions.
2014-12-06 17:22:04 -08:00
ekatek
24a4ed9bdc Automatically line-wrap output
Includes the following changes to Console.js:

- Console.info, Console.warn, Console.debug and Console.error now automatically
  line-wrap the output to 80 characters, or the width of the terminal screen (if
  known). This is in line with our current style guide on how things should be wrapped!

- Sometimes, there are parts of text that we don't want to line-wrap. For example, if we are
  telling the user to run 'meteor long-command --with --options' we don't want to
  have a newline in the middle of that! Wrap those commands in Console.command, like
  this:
     Console.info("something and then run", Console.command(command), "and then");
  This also makes them bold if chalk is on, as a nice bonus. So, if we ever turn
  chalk back on, the bolding of commands will be more consistent.

- Sometimes, there is bulkier output that we don't want to format at all, including
  line-wrapping: log snippets, stack traces, JSON output, etc. In that case, we can use
  Console.rawInfo, Console.rawError, Console.rawWarn and Console.rawDebug. Don't use
  Console.command inside the raw* functions! It won't be processed (at all).

- There are fancier things that we can do, other than just simply wrapping things.
  We can indent:
  "  Start here and then when wrapping
     continue over here".

  We frequently do this for commands, for example. In the past, we did this manually --
  but we can't do this for long messages that might get wrapped, and anyway, it is
  good to codify this instead of counting spaces. Allows us to be better about consistency,
  for example.

- We can also add a bulletPoint, which is a small notice in the beginning that looks like
  this:
  " => Start here and then when wrapping
       continue below the bulletPoint".

  Since it is a elss intuitive option, I have wrapped most of the time that we use a
  bulletPoint into helper functions on the Console.js.

- Some common bulletpoints that we use are:
    ASCII Checkboxes (Console.success)
    ASCII X-s (Console.failWarn and Console.failInfo)
    =>  (Console.arrowError, Console.arrowWarn, Console.arrowInfo)
    WARNING (Console.labelWarn)

  The => are sometimes indented, so they take an optional indent argument, showing how
  many spaces to indent by.

The wrapper interface would be less complicated, if there was a more unified conceit behind our
terminal messages. If there is one, it is not documented. My hope is that, in many cases,
moving these to Console will make it easier for someone with great product sense to
clean up our terminal messages. It will also make it easier to write such messages, since
it will be easier to follow an accepted standard.

In the codebase outside of Console:

- Went through and looked at our use of Console.error/info/etc, replacing with rawError/etc
  whenever approporiate.

- Went through and modified most of 'stdout' and 'stderr' calls to use the new functions.
  I made an exception for stuff that doesn't want a new line at the end, or otherwise does
  weird things (ex: print user logs directly), on the basis that, at this juncture, it is
  better to be safe than to be sorry.

- Long messages no longer need to break the code style guide by ignoring indentation rules.
  Fixed that where approporiate.

- Fixed the tests! A number of our stock messages are actually longer than 80 chars.

- Personal favourite: The Android license agreement is now line wrapped! Much better experience.

- There is some more work to do on:
  - longform help (currently comes with built-in linebreaks, would have to change the entire
    mechanism for how that works)
  - Buildmessage sometimes has headers that start with =>, but they are short. I didn't want to
    pass wrapper options all the way to main.captureOrExit before merging the rest of this and
    making sure that we like it. Since these messages are fairly short, I don't think that's
    likely to be a serious problem.

I hope that this makes life easier for us in the future! No more counting chars, no more breaking
the style guide. Better experience for users with wider terminals (or even shorter terminals!).
Let's give this a try.
2014-12-04 17:56:04 -08:00
David Glasser
02856bca84 restore some meteor add error-checking
get some parts of package-tests to pass
2014-11-25 09:06:28 -08:00
David Glasser
4aa33782fa New Console.withProgressDisplayVisible function
This replaces the pattern of turning two flags on and off by hand.

Also, avoid calling _updateProgressDisplay unless you're actually
changing values.
2014-11-11 17:28:30 -08:00
David Glasser
d072249bdf Use util.format for Console print functions
Should be basically backwards compatible (they both join on spaces) but
has the following advantages:

- Objects are printed with util.inspect rather than toString, which
  means no more [object Object].  (We shouldn't be passing objects to
  end-user messages, but they can be useful in Console.debug.)

- The first string can optionally be a printf-style format string, if
  that's a better fit for your message.
2014-11-05 17:09:43 -08:00
David Glasser
cf271511cb document unicode characters 2014-11-05 17:09:43 -08:00
David Glasser
06b5c1fb6b console: use utils.sleepMs 2014-11-05 17:09:43 -08:00
David Glasser
e5380d06b7 console: missing vars 2014-11-05 17:09:42 -08:00
David Glasser
6720d1c850 Revert "console: avoid division by zero"
This reverts commit 2d83bad8f3.

Whoops, that's not how division by zero works in JS! The existing
isFinite check is fine.
2014-11-05 12:25:23 -08:00
David Glasser
2d83bad8f3 console: avoid division by zero 2014-11-05 12:23:18 -08:00
David Glasser
4b2d0d5174 de-globalize console.js constants 2014-11-05 11:30:14 -08:00
David Greenspan
3dbad553b5 Add XXX comment 2014-10-28 10:03:29 -07:00
David Greenspan
480b05bc2c Display progress when restarting the server
Previously, all progress display was turned off after the app’s initial start, so no progress would be displayed on restart due to server code change.

Now, we enable/disable progress display from inside the loop that re-runs the app on change.

Remove the “suppressDisplay” approach to hiding the spinner when there’s an error building the app, because it didn’t work on rebuilds, only the first build.  Better to just call enableProgressDisplay(false) and hope for the best like we do elsewhere.
2014-10-22 13:05:19 -07:00
Nick Martin
ccbac61cf0 Disable color by default. 2014-10-22 11:09:20 -07:00
Justin SB
b569095119 Use the progress startTime for time estimates 2014-10-21 16:40:43 -07:00
Emily Stark
420d6e59e2 Supress progress spinner while waiting for file changes.
This prevents "Starting your app..." from showing immediately after
"Your app is crashing. Waiting for file changes."
2014-10-21 14:10:56 -07:00
Justin SB
f367804f1e Change progress message indent to 3, so it lines up with '=> Started ...' 2014-10-20 11:21:29 -07:00
Justin SB
fe61a5e82f Exit the status poller cleanly, so we never block process exit 2014-10-17 17:30:23 -07:00
Justin SB
78ae5012a1 Include the indent in the space-allocation calculation 2014-10-17 11:27:18 -07:00
Justin SB
fc8ecc53d3 Document the heuristic logic with some comments 2014-10-17 11:27:18 -07:00
Justin SB
c325023f15 Tweak when tasks are marked as done & current, also nudge the spinner when no progress 2014-10-17 11:27:17 -07:00
Justin SB
61cc351b95 Cleanups from self-code review 2014-10-17 11:27:17 -07:00
Justin SB
1b105953dd Don't bother with stop() function, just call depaint() directly 2014-10-17 11:27:17 -07:00
Justin SB
a68a12dd02 Replace the progress npm dependency with our own version
More or less copied code, for now (MIT licensed)
2014-10-17 11:27:17 -07:00
Justin SB
301357674f A few notes on what we need to do fully remove Patience 2014-10-17 11:27:16 -07:00
Justin SB
2f86bdf406 Move patience to console 2014-10-17 11:27:16 -07:00
Justin SB
e8477f3a2c Fix a large number of small mistakes 2014-10-17 11:27:15 -07:00
Justin SB
c24859de70 Advance spinner at constant speed 2014-10-17 11:27:15 -07:00
Justin SB
e279a442f4 Initialize _fraction 2014-10-17 11:27:14 -07:00
Justin SB
ecd1e19bb9 Create repaint / depaint 2014-10-17 11:27:14 -07:00
Justin SB
2381e22906 Support spinner if progress fraction is unknown 2014-10-17 11:27:14 -07:00
Justin SB
8436ee6a5d Move constants higher in console.js 2014-10-17 11:27:14 -07:00