passenger 5.0.21 → 5.0.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (203) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +38 -2
  5. data/CONTRIBUTORS +3 -0
  6. data/README.md +5 -1
  7. data/bin/passenger-status +2 -7
  8. data/build/agent.rb +2 -0
  9. data/build/cxx_dependency_map.rb +1464 -162
  10. data/build/node_tests.rb +1 -1
  11. data/build/packaging.rb +1 -1
  12. data/dev/ci/run_travis.sh +1 -1
  13. data/dev/vagrant/provision.sh +1 -1
  14. data/npm-shrinkwrap.json +635 -125
  15. data/package.json +1 -1
  16. data/resources/templates/standalone/config.erb +33 -161
  17. data/resources/templates/standalone/global.erb +15 -0
  18. data/resources/templates/standalone/http.erb +40 -0
  19. data/resources/templates/standalone/mass_deployment_default_server.erb +11 -0
  20. data/resources/templates/standalone/rails_asset_pipeline.erb +22 -0
  21. data/resources/templates/standalone/server.erb +58 -0
  22. data/src/agent/Core/ApiServer.h +37 -32
  23. data/src/agent/Core/ApplicationPool/BasicGroupInfo.h +1 -1
  24. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +6 -0
  25. data/src/agent/Core/ApplicationPool/Common.h +1 -1
  26. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  27. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +4 -0
  28. data/src/agent/Core/ApplicationPool/Implementation.cpp +2 -2
  29. data/src/agent/Core/ApplicationPool/Options.h +18 -1
  30. data/src/agent/Core/ApplicationPool/Pool.h +1 -1
  31. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +6 -6
  32. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +3 -3
  33. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +1 -1
  34. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +6 -0
  35. data/src/agent/Core/ApplicationPool/Process.h +6 -1
  36. data/src/agent/Core/ApplicationPool/Socket.h +9 -12
  37. data/src/agent/Core/Controller.h +422 -0
  38. data/src/agent/Core/{RequestHandler → Controller}/AppResponse.h +2 -0
  39. data/src/agent/Core/{RequestHandler → Controller}/BufferBody.cpp +27 -5
  40. data/src/agent/Core/{RequestHandler → Controller}/CheckoutSession.cpp +61 -31
  41. data/src/agent/Core/{RequestHandler → Controller}/Client.h +5 -2
  42. data/src/agent/Core/{RequestHandler → Controller}/ForwardResponse.cpp +93 -42
  43. data/src/agent/Core/{RequestHandler → Controller}/Hooks.cpp +107 -60
  44. data/src/agent/Core/Controller/Implementation.cpp +38 -0
  45. data/src/agent/Core/{RequestHandler → Controller}/InitRequest.cpp +134 -80
  46. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +165 -0
  47. data/src/agent/Core/{RequestHandler/Utils.cpp → Controller/InternalUtils.cpp} +49 -32
  48. data/src/agent/Core/Controller/Miscellaneous.cpp +116 -0
  49. data/src/agent/Core/{RequestHandler → Controller}/Request.h +6 -4
  50. data/src/agent/Core/{RequestHandler → Controller}/SendRequest.cpp +205 -130
  51. data/src/agent/Core/Controller/StateInspectionAndConfiguration.cpp +161 -0
  52. data/src/agent/Core/{RequestHandler → Controller}/TurboCaching.h +3 -0
  53. data/src/agent/Core/CoreMain.cpp +62 -51
  54. data/src/agent/Core/OptionParser.h +24 -0
  55. data/src/agent/Core/ResponseCache.h +5 -5
  56. data/src/agent/Core/SpawningKit/Config.h +2 -2
  57. data/src/agent/Core/SpawningKit/SmartSpawner.h +1 -1
  58. data/src/agent/Core/UnionStation/{Core.h → Context.h} +14 -18
  59. data/src/agent/Core/UnionStation/StopwatchLog.h +3 -2
  60. data/src/agent/Core/UnionStation/Transaction.h +7 -7
  61. data/src/agent/Shared/ApiServerUtils.h +9 -1
  62. data/src/agent/UstRouter/ApiServer.h +5 -2
  63. data/src/agent/UstRouter/Controller.h +27 -9
  64. data/src/agent/UstRouter/UstRouterMain.cpp +1 -0
  65. data/src/agent/Watchdog/ApiServer.h +5 -2
  66. data/src/apache2_module/ConfigurationCommands.cpp +7 -0
  67. data/src/apache2_module/ConfigurationFields.hpp +2 -0
  68. data/src/apache2_module/ConfigurationSetters.cpp +24 -0
  69. data/src/apache2_module/CreateDirConfig.cpp +1 -0
  70. data/src/apache2_module/Hooks.cpp +6 -5
  71. data/src/apache2_module/MergeDirConfig.cpp +7 -0
  72. data/src/apache2_module/SetHeaders.cpp +5 -0
  73. data/src/cxx_supportlib/Constants.h +5 -3
  74. data/src/cxx_supportlib/SafeLibev.h +2 -1
  75. data/src/cxx_supportlib/UnionStationFilterSupport.h +2 -1
  76. data/src/cxx_supportlib/Utils/ReleaseableScopedPointer.h +70 -0
  77. data/src/cxx_supportlib/vendor-modified/boost/libs/regex/src/regex_raw_buffer.cpp +6 -6
  78. data/src/helper-scripts/node-loader.js +59 -0
  79. data/src/nginx_module/CacheLocationConfig.c +48 -0
  80. data/src/nginx_module/ConfigurationCommands.c +20 -0
  81. data/src/nginx_module/ConfigurationFields.h +4 -0
  82. data/src/nginx_module/CreateLocationConfig.c +8 -0
  83. data/src/nginx_module/MergeLocationConfig.c +12 -0
  84. data/src/nodejs_supportlib/phusion_passenger/log_express.js +106 -0
  85. data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +203 -0
  86. data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +227 -0
  87. data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +446 -0
  88. data/src/nodejs_supportlib/vendor-copy/codify/codify.js +44 -0
  89. data/src/nodejs_supportlib/vendor-copy/codify/package.json +29 -0
  90. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/context.js +200 -0
  91. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/glue.js +488 -0
  92. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/index.js +407 -0
  93. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/index.js +90 -0
  94. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/package.json +40 -0
  95. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/package.json +54 -0
  96. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/listener.js +160 -0
  97. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/index.js +90 -0
  98. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/package.json +40 -0
  99. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/package.json +46 -0
  100. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/package.json +56 -0
  101. data/src/nodejs_supportlib/vendor-copy/network-byte-order/lib/index.js +102 -0
  102. data/src/nodejs_supportlib/vendor-copy/network-byte-order/package.json +51 -0
  103. data/src/nodejs_supportlib/vendor-copy/winston/LICENSE +19 -0
  104. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston.js +165 -0
  105. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/common.js +483 -0
  106. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js +62 -0
  107. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/cli-config.js +35 -0
  108. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/npm-config.js +27 -0
  109. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/syslog-config.js +31 -0
  110. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/container.js +127 -0
  111. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/exception.js +56 -0
  112. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/logger.js +701 -0
  113. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports.js +34 -0
  114. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/console.js +128 -0
  115. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/daily-rotate-file.js +601 -0
  116. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/file.js +675 -0
  117. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/http.js +232 -0
  118. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/memory.js +89 -0
  119. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/transport.js +135 -0
  120. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/webhook.js +146 -0
  121. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/LICENSE +19 -0
  122. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/lib/async.js +1283 -0
  123. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/package.json +66 -0
  124. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/support/sync-package-managers.js +53 -0
  125. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/MIT-LICENSE.txt +23 -0
  126. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/colors.js +176 -0
  127. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/trap.js +45 -0
  128. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/zalgo.js +104 -0
  129. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/extendStringPrototype.js +118 -0
  130. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/index.js +12 -0
  131. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/america.js +12 -0
  132. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/rainbow.js +13 -0
  133. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/random.js +8 -0
  134. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/zebra.js +5 -0
  135. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/styles.js +77 -0
  136. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/system/supports-colors.js +61 -0
  137. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/package.json +35 -0
  138. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/safe.js +9 -0
  139. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/themes/generic-logging.js +12 -0
  140. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/cycle.js +170 -0
  141. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/package.json +30 -0
  142. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/LICENSE +20 -0
  143. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/lib/eyes.js +236 -0
  144. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/package.json +42 -0
  145. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/LICENSE.md +11 -0
  146. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/isstream.js +27 -0
  147. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/package.json +42 -0
  148. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/LICENSE +19 -0
  149. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/lib/pkginfo.js +136 -0
  150. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/package.json +56 -0
  151. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/License +19 -0
  152. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/lib/stack-trace.js +111 -0
  153. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/package.json +33 -0
  154. data/src/nodejs_supportlib/vendor-copy/winston/package.json +87 -0
  155. data/src/ruby_supportlib/phusion_passenger.rb +3 -4
  156. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +19 -2
  157. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
  158. data/src/ruby_supportlib/phusion_passenger/config/list_instances_command.rb +2 -6
  159. data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +13 -0
  160. data/src/ruby_supportlib/phusion_passenger/config/restart_app_command.rb +3 -0
  161. data/src/ruby_supportlib/phusion_passenger/config/utils.rb +9 -7
  162. data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +8 -1
  163. data/src/ruby_supportlib/phusion_passenger/constants.rb +3 -1
  164. data/src/ruby_supportlib/phusion_passenger/native_support.rb +20 -4
  165. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +8 -0
  166. data/src/ruby_supportlib/phusion_passenger/packaging.rb +1 -0
  167. data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +1 -1
  168. data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +11 -4
  169. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  170. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +647 -0
  171. data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +229 -15
  172. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +35 -323
  173. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +36 -12
  174. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +123 -14
  175. data/src/ruby_supportlib/phusion_passenger/standalone/status_command.rb +32 -17
  176. data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +32 -21
  177. data/src/ruby_supportlib/phusion_passenger/standalone/version_command.rb +5 -5
  178. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +2 -2
  179. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +5 -1
  180. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +68 -24
  181. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +9 -1
  182. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +9 -7
  183. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +3 -2
  184. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +8 -5
  185. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +395 -0
  186. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +10 -7
  187. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +14 -0
  188. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +2 -2
  189. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml +4 -2
  190. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +2 -2
  191. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +2 -2
  192. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +16 -0
  193. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +1 -1
  194. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +2 -2
  195. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +1 -1
  196. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +44 -17
  197. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +16 -7
  198. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +2 -2
  199. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +1 -1
  200. metadata +99 -16
  201. metadata.gz.asc +7 -7
  202. data/resources/oss-binaries.phusionpassenger.com.crt +0 -248
  203. data/src/agent/Core/RequestHandler.h +0 -471
@@ -0,0 +1,118 @@
1
+ var colors = require('./colors'),
2
+ styles = require('./styles');
3
+
4
+ module['exports'] = function () {
5
+
6
+ //
7
+ // Extends prototype of native string object to allow for "foo".red syntax
8
+ //
9
+ var addProperty = function (color, func) {
10
+ String.prototype.__defineGetter__(color, func);
11
+ };
12
+
13
+ var sequencer = function sequencer (map, str) {
14
+ return function () {
15
+ var exploded = this.split(""), i = 0;
16
+ exploded = exploded.map(map);
17
+ return exploded.join("");
18
+ }
19
+ };
20
+
21
+ var stylize = function stylize (str, style) {
22
+ return styles[style].open + str + styles[style].close;
23
+ }
24
+
25
+ addProperty('strip', function () {
26
+ return colors.strip(this);
27
+ });
28
+
29
+ addProperty('stripColors', function () {
30
+ return colors.strip(this);
31
+ });
32
+
33
+ addProperty("trap", function(){
34
+ return colors.trap(this);
35
+ });
36
+
37
+ addProperty("zalgo", function(){
38
+ return colors.zalgo(this);
39
+ });
40
+
41
+ addProperty("zebra", function(){
42
+ return colors.zebra(this);
43
+ });
44
+
45
+ addProperty("rainbow", function(){
46
+ return colors.rainbow(this);
47
+ });
48
+
49
+ addProperty("random", function(){
50
+ return colors.random(this);
51
+ });
52
+
53
+ addProperty("america", function(){
54
+ return colors.america(this);
55
+ });
56
+
57
+ //
58
+ // Iterate through all default styles and colors
59
+ //
60
+ var x = Object.keys(colors.styles);
61
+ x.forEach(function (style) {
62
+ addProperty(style, function () {
63
+ return stylize(this, style);
64
+ });
65
+ });
66
+
67
+ function applyTheme(theme) {
68
+ //
69
+ // Remark: This is a list of methods that exist
70
+ // on String that you should not overwrite.
71
+ //
72
+ var stringPrototypeBlacklist = [
73
+ '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
74
+ 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
75
+ 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
76
+ 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
77
+ ];
78
+
79
+ Object.keys(theme).forEach(function (prop) {
80
+ if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
81
+ console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
82
+ }
83
+ else {
84
+ if (typeof(theme[prop]) === 'string') {
85
+ colors[prop] = colors[theme[prop]];
86
+ addProperty(prop, function () {
87
+ return colors[theme[prop]](this);
88
+ });
89
+ }
90
+ else {
91
+ addProperty(prop, function () {
92
+ var ret = this;
93
+ for (var t = 0; t < theme[prop].length; t++) {
94
+ ret = exports[theme[prop][t]](ret);
95
+ }
96
+ return ret;
97
+ });
98
+ }
99
+ }
100
+ });
101
+ }
102
+
103
+ colors.setTheme = function (theme) {
104
+ if (typeof theme === 'string') {
105
+ try {
106
+ colors.themes[theme] = require(theme);
107
+ applyTheme(colors.themes[theme]);
108
+ return colors.themes[theme];
109
+ } catch (err) {
110
+ console.log(err);
111
+ return err;
112
+ }
113
+ } else {
114
+ applyTheme(theme);
115
+ }
116
+ };
117
+
118
+ };
@@ -0,0 +1,12 @@
1
+ var colors = require('./colors');
2
+ module['exports'] = colors;
3
+
4
+ // Remark: By default, colors will add style properties to String.prototype
5
+ //
6
+ // If you don't wish to extend String.prototype you can do this instead and native String will not be touched
7
+ //
8
+ // var colors = require('colors/safe);
9
+ // colors.red("foo")
10
+ //
11
+ //
12
+ var extendStringPrototype = require('./extendStringPrototype')();
@@ -0,0 +1,12 @@
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function() {
4
+ return function (letter, i, exploded) {
5
+ if(letter === " ") return letter;
6
+ switch(i%3) {
7
+ case 0: return colors.red(letter);
8
+ case 1: return colors.white(letter)
9
+ case 2: return colors.blue(letter)
10
+ }
11
+ }
12
+ })();
@@ -0,0 +1,13 @@
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function () {
4
+ var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
5
+ return function (letter, i, exploded) {
6
+ if (letter === " ") {
7
+ return letter;
8
+ } else {
9
+ return colors[rainbowColors[i++ % rainbowColors.length]](letter);
10
+ }
11
+ };
12
+ })();
13
+
@@ -0,0 +1,8 @@
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function () {
4
+ var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
5
+ return function(letter, i, exploded) {
6
+ return letter === " " ? letter : colors[available[Math.round(Math.random() * (available.length - 1))]](letter);
7
+ };
8
+ })();
@@ -0,0 +1,5 @@
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = function (letter, i, exploded) {
4
+ return i % 2 === 0 ? letter : colors.inverse(letter);
5
+ };
@@ -0,0 +1,77 @@
1
+ /*
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+
24
+ */
25
+
26
+ var styles = {};
27
+ module['exports'] = styles;
28
+
29
+ var codes = {
30
+ reset: [0, 0],
31
+
32
+ bold: [1, 22],
33
+ dim: [2, 22],
34
+ italic: [3, 23],
35
+ underline: [4, 24],
36
+ inverse: [7, 27],
37
+ hidden: [8, 28],
38
+ strikethrough: [9, 29],
39
+
40
+ black: [30, 39],
41
+ red: [31, 39],
42
+ green: [32, 39],
43
+ yellow: [33, 39],
44
+ blue: [34, 39],
45
+ magenta: [35, 39],
46
+ cyan: [36, 39],
47
+ white: [37, 39],
48
+ gray: [90, 39],
49
+ grey: [90, 39],
50
+
51
+ bgBlack: [40, 49],
52
+ bgRed: [41, 49],
53
+ bgGreen: [42, 49],
54
+ bgYellow: [43, 49],
55
+ bgBlue: [44, 49],
56
+ bgMagenta: [45, 49],
57
+ bgCyan: [46, 49],
58
+ bgWhite: [47, 49],
59
+
60
+ // legacy styles for colors pre v1.0.0
61
+ blackBG: [40, 49],
62
+ redBG: [41, 49],
63
+ greenBG: [42, 49],
64
+ yellowBG: [43, 49],
65
+ blueBG: [44, 49],
66
+ magentaBG: [45, 49],
67
+ cyanBG: [46, 49],
68
+ whiteBG: [47, 49]
69
+
70
+ };
71
+
72
+ Object.keys(codes).forEach(function (key) {
73
+ var val = codes[key];
74
+ var style = styles[key] = [];
75
+ style.open = '\u001b[' + val[0] + 'm';
76
+ style.close = '\u001b[' + val[1] + 'm';
77
+ });
@@ -0,0 +1,61 @@
1
+ /*
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+
24
+ */
25
+
26
+ var argv = process.argv;
27
+
28
+ module.exports = (function () {
29
+ if (argv.indexOf('--no-color') !== -1 ||
30
+ argv.indexOf('--color=false') !== -1) {
31
+ return false;
32
+ }
33
+
34
+ if (argv.indexOf('--color') !== -1 ||
35
+ argv.indexOf('--color=true') !== -1 ||
36
+ argv.indexOf('--color=always') !== -1) {
37
+ return true;
38
+ }
39
+
40
+ if (process.stdout && !process.stdout.isTTY) {
41
+ return false;
42
+ }
43
+
44
+ if (process.platform === 'win32') {
45
+ return true;
46
+ }
47
+
48
+ if ('COLORTERM' in process.env) {
49
+ return true;
50
+ }
51
+
52
+ if (process.env.TERM === 'dumb') {
53
+ return false;
54
+ }
55
+
56
+ if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
57
+ return true;
58
+ }
59
+
60
+ return false;
61
+ })();
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "colors",
3
+ "description": "get colors in your node.js console",
4
+ "version": "1.0.3",
5
+ "author": {
6
+ "name": "Marak Squires"
7
+ },
8
+ "homepage": "https://github.com/Marak/colors.js",
9
+ "bugs": {
10
+ "url": "https://github.com/Marak/colors.js/issues"
11
+ },
12
+ "keywords": [
13
+ "ansi",
14
+ "terminal",
15
+ "colors"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com/Marak/colors.js.git"
20
+ },
21
+ "license": "MIT",
22
+ "scripts": {
23
+ "test": "node tests/basic-test.js && node tests/safe-test.js"
24
+ },
25
+ "engines": {
26
+ "node": ">=0.1.90"
27
+ },
28
+ "main": "./lib/index",
29
+ "readme": "# colors.js\n\n## get color and style in your node.js console\n\n<img src=\"https://github.com/Marak/colors.js/raw/master/screenshots/colors.png\"/>\n\n## Installation\n\n npm install colors\n\n## colors and styles!\n\n### text colors\n\n - black\n - red\n - green\n - yellow\n - blue\n - magenta\n - cyan\n - white\n - gray\n - grey\n\n### background colors\n\n\n\n - bgBlack\n - bgRed\n - bgGreen\n - bgYellow\n - bgBlue\n - bgMagenta\n - bgCyan\n - bgWhite\n\n### styles\n\n - reset\n - bold\n - dim\n - italic\n - underline\n - inverse\n - hidden\n - strikethrough\n\n### extras\n\n - rainbow\n - zebra\n - america\n - trap\n - random\n\n\n## Usage\n\nBy popular demand, `colors` now ships with two types of usages!\n\nThe super nifty way\n\n```js\nvar colors = require('colors');\n\nconsole.log('hello'.green); // outputs green text\nconsole.log('i like cake and pies'.underline.red) // outputs red underlined text\nconsole.log('inverse the color'.inverse); // inverses the color\nconsole.log('OMG Rainbows!'.rainbow); // rainbow\nconsole.log('Run the trap'.trap); // Drops the bass\n\n```\n\nor a slightly less nifty way which doesn't extend `String.prototype`\n\n```js\nvar colors = require('colors/safe');\n\nconsole.log(colors.green('hello')); // outputs green text\nconsole.log(colors.red.underline('i like cake and pies')) // outputs red underlined text\nconsole.log(colors.inverse('inverse the color')); // inverses the color\nconsole.log(colors.rainbow('OMG Rainbows!')); // rainbow\nconsole.log(colors.trap('Run the trap')); // Drops the bass\n\n```\n\nI prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way. \n\nIf you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.\n\n## Disabling Colors\n\nTo disable colors you can pass the following arguments in the command line to your application:\n\n```bash\nnode myapp.js --no-color\n```\n\n## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)\n\n```js\nvar name = 'Marak';\nconsole.log(colors.green('Hello %s'), name);\n// outputs -> 'Hello Marak'\n```\n\n## Custom themes\n\n### Using standard API\n\n```js\n\nvar colors = require('colors');\n\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(\"this is an error\".error);\n\n// outputs yellow text\nconsole.log(\"this is a warning\".warn);\n```\n\n### Using string safe API\n\n```js\nvar colors = require('colors/safe');\n\n// set single property\nvar error = colors.red;\nerror('this is red');\n\n// set theme\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(colors.error(\"this is an error\"));\n\n// outputs yellow text\nconsole.log(colors.warn(\"this is a warning\"));\n```\n\n*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*",
30
+ "readmeFilename": "ReadMe.md",
31
+ "_id": "colors@1.0.3",
32
+ "_shasum": "0433f44d809680fdeb60ed260f1b0c262e82a40b",
33
+ "_from": "colors@1.0.x",
34
+ "_resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz"
35
+ }
@@ -0,0 +1,9 @@
1
+ //
2
+ // Remark: Requiring this file will use the "safe" colors API which will not touch String.prototype
3
+ //
4
+ // var colors = require('colors/safe);
5
+ // colors.red("foo")
6
+ //
7
+ //
8
+ var colors = require('./lib/colors');
9
+ module['exports'] = colors;
@@ -0,0 +1,12 @@
1
+ module['exports'] = {
2
+ silly: 'rainbow',
3
+ input: 'grey',
4
+ verbose: 'cyan',
5
+ prompt: 'grey',
6
+ info: 'green',
7
+ data: 'grey',
8
+ help: 'cyan',
9
+ warn: 'yellow',
10
+ debug: 'blue',
11
+ error: 'red'
12
+ };
@@ -0,0 +1,170 @@
1
+ /*
2
+ cycle.js
3
+ 2013-02-19
4
+
5
+ Public Domain.
6
+
7
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
+
9
+ This code should be minified before deployment.
10
+ See http://javascript.crockford.com/jsmin.html
11
+
12
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
13
+ NOT CONTROL.
14
+ */
15
+
16
+ /*jslint evil: true, regexp: true */
17
+
18
+ /*members $ref, apply, call, decycle, hasOwnProperty, length, prototype, push,
19
+ retrocycle, stringify, test, toString
20
+ */
21
+
22
+ var cycle = exports;
23
+
24
+ cycle.decycle = function decycle(object) {
25
+ 'use strict';
26
+
27
+ // Make a deep copy of an object or array, assuring that there is at most
28
+ // one instance of each object or array in the resulting structure. The
29
+ // duplicate references (which might be forming cycles) are replaced with
30
+ // an object of the form
31
+ // {$ref: PATH}
32
+ // where the PATH is a JSONPath string that locates the first occurance.
33
+ // So,
34
+ // var a = [];
35
+ // a[0] = a;
36
+ // return JSON.stringify(JSON.decycle(a));
37
+ // produces the string '[{"$ref":"$"}]'.
38
+
39
+ // JSONPath is used to locate the unique object. $ indicates the top level of
40
+ // the object or array. [NUMBER] or [STRING] indicates a child member or
41
+ // property.
42
+
43
+ var objects = [], // Keep a reference to each unique object or array
44
+ paths = []; // Keep the path to each unique object or array
45
+
46
+ return (function derez(value, path) {
47
+
48
+ // The derez recurses through the object, producing the deep copy.
49
+
50
+ var i, // The loop counter
51
+ name, // Property name
52
+ nu; // The new object or array
53
+
54
+ // typeof null === 'object', so go on if this value is really an object but not
55
+ // one of the weird builtin objects.
56
+
57
+ if (typeof value === 'object' && value !== null &&
58
+ !(value instanceof Boolean) &&
59
+ !(value instanceof Date) &&
60
+ !(value instanceof Number) &&
61
+ !(value instanceof RegExp) &&
62
+ !(value instanceof String)) {
63
+
64
+ // If the value is an object or array, look to see if we have already
65
+ // encountered it. If so, return a $ref/path object. This is a hard way,
66
+ // linear search that will get slower as the number of unique objects grows.
67
+
68
+ for (i = 0; i < objects.length; i += 1) {
69
+ if (objects[i] === value) {
70
+ return {$ref: paths[i]};
71
+ }
72
+ }
73
+
74
+ // Otherwise, accumulate the unique value and its path.
75
+
76
+ objects.push(value);
77
+ paths.push(path);
78
+
79
+ // If it is an array, replicate the array.
80
+
81
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
82
+ nu = [];
83
+ for (i = 0; i < value.length; i += 1) {
84
+ nu[i] = derez(value[i], path + '[' + i + ']');
85
+ }
86
+ } else {
87
+
88
+ // If it is an object, replicate the object.
89
+
90
+ nu = {};
91
+ for (name in value) {
92
+ if (Object.prototype.hasOwnProperty.call(value, name)) {
93
+ nu[name] = derez(value[name],
94
+ path + '[' + JSON.stringify(name) + ']');
95
+ }
96
+ }
97
+ }
98
+ return nu;
99
+ }
100
+ return value;
101
+ }(object, '$'));
102
+ };
103
+
104
+
105
+ cycle.retrocycle = function retrocycle($) {
106
+ 'use strict';
107
+
108
+ // Restore an object that was reduced by decycle. Members whose values are
109
+ // objects of the form
110
+ // {$ref: PATH}
111
+ // are replaced with references to the value found by the PATH. This will
112
+ // restore cycles. The object will be mutated.
113
+
114
+ // The eval function is used to locate the values described by a PATH. The
115
+ // root object is kept in a $ variable. A regular expression is used to
116
+ // assure that the PATH is extremely well formed. The regexp contains nested
117
+ // * quantifiers. That has been known to have extremely bad performance
118
+ // problems on some browsers for very long strings. A PATH is expected to be
119
+ // reasonably short. A PATH is allowed to belong to a very restricted subset of
120
+ // Goessner's JSONPath.
121
+
122
+ // So,
123
+ // var s = '[{"$ref":"$"}]';
124
+ // return JSON.retrocycle(JSON.parse(s));
125
+ // produces an array containing a single element which is the array itself.
126
+
127
+ var px =
128
+ /^\$(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/;
129
+
130
+ (function rez(value) {
131
+
132
+ // The rez function walks recursively through the object looking for $ref
133
+ // properties. When it finds one that has a value that is a path, then it
134
+ // replaces the $ref object with a reference to the value that is found by
135
+ // the path.
136
+
137
+ var i, item, name, path;
138
+
139
+ if (value && typeof value === 'object') {
140
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
141
+ for (i = 0; i < value.length; i += 1) {
142
+ item = value[i];
143
+ if (item && typeof item === 'object') {
144
+ path = item.$ref;
145
+ if (typeof path === 'string' && px.test(path)) {
146
+ value[i] = eval(path);
147
+ } else {
148
+ rez(item);
149
+ }
150
+ }
151
+ }
152
+ } else {
153
+ for (name in value) {
154
+ if (typeof value[name] === 'object') {
155
+ item = value[name];
156
+ if (item) {
157
+ path = item.$ref;
158
+ if (typeof path === 'string' && px.test(path)) {
159
+ value[name] = eval(path);
160
+ } else {
161
+ rez(item);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }($));
169
+ return $;
170
+ };