Permalink
Browse files

Merge branch 'develop' of github.com:yahoo/mojito into travis-node-10

  • Loading branch information...
caridy committed Apr 5, 2013
2 parents f90a663 + 9d13fbd commit ba0e2920baec43a2980e9715a173427f7a370afc
Showing with 1,294 additions and 639 deletions.
  1. +35 −2 HISTORY.md
  2. +1 −1 docs/dev_guide/intro/mojito_mvc.rst
  3. +9 −4 docs/dev_guide/reference/mojito_cmdline.rst
  4. +5 −0 docs/dev_guide/topics/mojito_logging.rst
  5. +2 −0 docs/dev_guide/topics/mojito_run_dyn_defined_mojits.rst
  6. +10 −4 docs/dev_guide/topics/mojito_testing.rst
  7. +2 −1 lib/app/addons/rs/selector.js
  8. +1 −1 lib/app/autoload/action-context.common.js
  9. +4 −0 lib/app/autoload/mojit-proxy.client.js
  10. +3 −0 lib/app/autoload/mojito-client.client.js
  11. +1 −3 lib/app/autoload/package-walker.server.js
  12. +4 −2 lib/app/autoload/route-maker.common.js
  13. +4 −11 lib/app/autoload/store.server.js
  14. +5 −0 lib/app/autoload/tunnel-client.common.js
  15. +3 −1 lib/app/commands/start.js
  16. +23 −0 lib/app/middleware/mojito-handler-error.js
  17. +110 −0 lib/app/middleware/mojito-handler-tunnel-parser.js
  18. +64 −0 lib/app/middleware/mojito-handler-tunnel-rpc.js
  19. +61 −0 lib/app/middleware/mojito-handler-tunnel-specs.js
  20. +52 −0 lib/app/middleware/mojito-handler-tunnel-type.js
  21. +31 −189 lib/app/middleware/mojito-handler-tunnel.js
  22. +4 −4 lib/mojito.js
  23. +2 −2 package.json
  24. +13 −1 tests/base/mojito-test.js
  25. +1 −1 tests/unit/lib/app/addons/rs/rs_test_descriptor.json
  26. +7 −2 tests/unit/lib/app/autoload/test-action-context.common.js
  27. +28 −0 tests/unit/lib/app/autoload/test-mojit-proxy.client.js
  28. +0 −1 tests/unit/lib/app/autoload/test-store.server.js
  29. +16 −0 tests/unit/lib/app/autoload/test-tunnel.common.js
  30. +68 −107 tests/unit/lib/app/commands/build/test-shared.js
  31. +28 −0 tests/unit/lib/app/commands/test-start.js
  32. +1 −1 tests/unit/lib/app/commands/test-version.js
  33. +32 −0 tests/unit/lib/app/middleware/middleware_test_descriptor.json
  34. +213 −0 tests/unit/lib/app/middleware/test-handler-tunnel-parser.js
  35. +99 −0 tests/unit/lib/app/middleware/test-handler-tunnel-rpc.js
  36. +145 −0 tests/unit/lib/app/middleware/test-handler-tunnel-specs.js
  37. +131 −0 tests/unit/lib/app/middleware/test-handler-tunnel-type.js
  38. +37 −287 tests/unit/lib/app/middleware/test-handler-tunnel.js
  39. +39 −14 tests/unit/lib/test-mojito.js
View
@@ -2,17 +2,50 @@ version @VERSION@
=================
Notes
-------------
+-----
Deprecations
------------
+Features
+--------
+
+Bug Fixes
+---------
+
+
+version 0.5.7
+=============
+
+Notes
+------------
+* A middleware called `mojito-handler-error` has been added to handle
+ middleware errors. If you have redefined the middleware stack and do not have
+ your own error handler, then it is your responsibility to add it so that
+ errors can be handled appropriately.
+
+* An early preview of [`mojito-cli`](https://github.com/yahoo/mojito-cli) has been published. Users can choose to try it with `npm install --global mojito-cli`. There should be no significant changes in functionality. It is intended to replace the functionality provided by installing the mojito npm package globally (which has been deprecated). Notes:
+ * users install mojito-cli package globally (if they choose to in this preview release period).
+ * users should install the mojito package _locally_, as an npm dependency of their application.
+ * all existing mojito command line commands should continue to operate in much the same way.
+ * `mojito create app Foo`, when mojito-cli has been installed, will use `npm` to install `mojito` locally automatically after generating the app files and directories.
+
Features
------------
-* Upgraded to YUI 3.9.0
+* Upgraded to YUI 3.9.1
+* [issue #979](/yahoo/mojito/issues/979):
+ * The `mojito-handler-tunnel` middleware was refactored into a middleware
+ substack that more loosens the coupling between the parsing and handling
+ phases of a tunnel request. This means that applications will have an
+ easier time overriding and customizing tunnel behavior.
+ * The URL is now customizable per request using the `tunnelUrl` option for
+ `mojitProxy.invoke()`, but is still subject to the `tunnelPrefix`
+ restriction.
+
Bug Fixes
------------
+* issue bz6160815: port argument must be an integer
version 0.5.6
=================
@@ -870,7 +870,7 @@ Yahoo! pages to ``ac.done``:
...
In the template, we can now use the block helper ``each`` to
-create links with the objects and their properties``name`` and ``url``:
+create links with the objects and their properties ``name`` and ``url``:
.. code-block: html
@@ -284,11 +284,16 @@ applications.
.. _mj_cmdlne-compile_sys:
-Compile System
-==============
+Compile System (Deprecated)
+===========================
-Mojito comes with a compile command for generating files to optimize an application for
-production.
+The ``compile`` command for generating files to optimize an application for
+production has been **deprecated** and may not be available in the future.
+
+We recommend that you use the npm module `Shaker <https://github.com/yahoo/mojito-shaker>`_,
+which lets you compile (i.e., create rollups of) one or more input files. See the
+`Shaker documentation <http://developer.yahoo.com/cocktails/shaker/>`_
+to learn how to use Shaker in Mojito applications.
.. _compile_sys-syntax
@@ -7,6 +7,11 @@ log messages are handled by a YUI instance that Mojito creates based on YUI conf
defined in ``application.json`` or ``application.yaml``. You can set logging levels to
control the degree of detail in your log reports.
+Mojito does not write logs to a file. Instead, Mojito writes logs to the Node.js console.
+Thus, once logs are passed to Node.js, Mojito has no control over whether Node.js writes
+logs to a file, transmits them into an aggregated hub for multiple cores, or uses another
+implementation for logging.
+
.. _mojito_logging-levels:
Log Levels
@@ -52,6 +52,8 @@ Mojito also provides the ``dispatch`` method that can be called from the
``ActionContext`` object to run a dynamically defined child mojit. The
``dispatch`` method also allows you to define your own ``flush``,
``done``, and ``error`` functions for the child mojit instance.
+The ``done`` and ``error`` methods are executed synchronously,
+but the ``flush`` method is executed asynchronously.
.. _dyn_defined_mojits-use_cases:
@@ -581,6 +581,7 @@ Required Software
- `Java <http://www.java.com/en/download/manual.jsp>`_
- `Node.js 0.6 or higher (packaged with npm) <http://nodejs.org/>`_
- `Git <http://git-scm.com/downloads>`_
+- `Firefox v20 <http://www.mozilla.org/en-US/products/download>`_
.. _func_unit_reqs-macs:
@@ -632,15 +633,20 @@ Installing Selenium (recommended)
The following instructions work for both Macs and Linux.
-#. `Download the Selenium JAR executable <http://selenium.googlecode.com/files/selenium-server-standalone-2.22.0.jar>`_.
+#. `Download the Selenium v2.13.0 JAR executable <http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar>`_.
#. Start the Selenium server:
- ``$ java -jar path/to/selenium-server.jar``
+ ``$ java -jar path/to/selenium-server-standalone-2.31.0.jar``
#. Confirm Selenium is running by going to the following URL:
`http://localhost:4444/wd/hub/static/resource/hub.html <http://localhost:4444/wd/hub/static/resource/hub.html>`_
#. Shut down the Selenium server with ``Ctrl-C`` command.
+.. warning:: If you are not using Firefox v20 and the Selenium Standalone Server v2.31.0, you
+ may run into backward compatibility issues. Please see the
+ `Platforms Supported by Selenium <http://docs.seleniumhq.org/about/platforms.jsp>`_
+ to learn what Selenium and browser versions are compatible.
+
.. _func_unit-run:
Running Tests
@@ -665,7 +671,7 @@ or unit tests with one command.
``$ java -jar path/to/selenium-server.jar &``
#. Run the unit tests for the framework and client:
- ``$ ./run.js test -u --path unit --group fw,client,server``
+ ``$ ./run.js test -u --path unit --group fw,client,server --reuseSession``
#. You can also run all the functional tests with the below command.
``$ ./run.js test -f --path func --port 4000``
@@ -676,7 +682,7 @@ or unit tests with one command.
#. To run individual unit and functional tests, you pass the test descriptor
to ``run.js``.
- ``$ ./run.js test -f --path func --descriptor examples/newsboxes/newsboxes_descriptor.json --port 4000``
+ ``$ ./run.js test -f --path func --descriptor examples/newsboxes/newsboxes_descriptor.json --port 4000 --reuseSession``
The command above runs the functional test for the
``newsboxes`` application. The ``--path`` option indicates that the
@@ -91,7 +91,8 @@ YUI.add('addon-rs-selector', function(Y, NAME) {
}
this._poslCache[cacheKey] = posl;
}
- return Y.mojito.util.copy(posl);
+ // NOTE: We used to copy() here. Research suggested that it was safe to drop.
+ return posl;
},
@@ -308,7 +308,7 @@ YUI.add('mojito-action-context', function(Y, NAME) {
this._adapter = opts.adapter;
// pathToRoot, viewEngine, amoung others will be available through this.
- this.staticAppConfig = store.getStaticAppConfig();
+ this.staticAppConfig = (this._adapter.page && this._adapter.page.staticAppConfig) || store.getStaticAppConfig();
// Create a function which will properly delegate to the dispatcher to
// perform the actual processing.
@@ -196,6 +196,10 @@ YUI.add('mojito-mojit-proxy', function(Y, NAME) {
rpc: options.rpc || false
};
+ if (options.tunnelUrl) {
+ command._tunnelUrl = options.tunnelUrl;
+ }
+
this._client.executeAction(command, this.getId(), callback);
},
@@ -338,6 +338,9 @@ YUI.add('mojito-client', function(Y, NAME) {
// pass globalHookhandler to addons that may want to use hooks
globalHookHandler: globalHookHandler
};
+
+ this.page.staticAppConfig = appConfig;
+
fireLifecycle('pre-init', forwardConfig);
// if we didn't originaly have hooks enabled, copy back from config object.
// This is the case where an add-on module wants to turn on hooks and
@@ -45,7 +45,6 @@ function BreadthFirstPackageWalker(root) {
* pkg {object} contents of the package's package.json
* depth {interger} how deeply nested the package is
* parents {array} list of ancestor package names
- * inherit {anything} contents of the info.inherit from an ancestor's callback
*
* @param cb {function(error, info)} callback called for each package
* @return {nothing} results returned via callback
@@ -136,8 +135,7 @@ BreadthFirstPackageWalker.prototype._walkModules = function(work) {
this.todo.push({
depth: work.depth + 1,
parents: parents,
- dir: libpath.join(modulesDir, subdir),
- inherit: copy(work.inherit)
+ dir: libpath.join(modulesDir, subdir)
});
}
};
@@ -292,7 +292,8 @@ YUI.add('mojito-route-maker', function(Y, NAME) {
// Y.log('[UriRouter] found route: ' + JSON.stringify(route));
- match = Y.mojito.util.copy(route);
+ // NOTE: We used to copy() here. Research suggested that it was safe to drop.
+ match = route;
// Add the extracted URI params to the query obj
ret = new RegExp(route.ext_match).exec(uri);
@@ -323,7 +324,8 @@ YUI.add('mojito-route-maker', function(Y, NAME) {
* @return {object} computed routes.
*/
getComputedRoutes: function() {
- return Y.mojito.util.copy(CACHE.routes);
+ // NOTE: We used to copy() here. Research suggested that it was safe to drop.
+ return CACHE.routes;
},
@@ -538,7 +538,7 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
// type details
try {
- typeDetails = this.getMojitTypeDetails(env, ctx, spec.type, null, true);
+ typeDetails = this.getMojitTypeDetails(env, ctx, spec.type);
} catch (err2) {
return cb(err2);
}
@@ -567,8 +567,6 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
* @param {object} ctx the context
* @param {string} mojitType mojit type
* @param {object} dest DEPRECATED: object in which to place the results
- * @param {boolean} DANGERDANGERreturnRawCacheValue optional indicates
- * that the cache value should be returned directly, instead of a copy. defaults to false.
* @return {object} details about the mojit type
*/
/**
@@ -617,10 +615,7 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
Y.log('The "dest" parameter to store.getMojitTypeDetails() is deprecated.', 'warn', NAME);
Y.mojito.util.mergeRecursive(dest, cacheValue);
}
- if (DANGERDANGERreturnRawCacheValue) {
- return cacheValue;
- }
- return Y.mojito.util.copy(cacheValue);
+ return cacheValue;
},
@@ -1661,12 +1656,10 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
var dir,
pkg,
visitKey;
- // FUTURE: use info.inherit to scope mojit dependencies
/*
console.log('--PACKAGE-- ' + info.depth + ' ' + info.pkg.name + '@' + info.pkg.version
+ ' \t' + (info.pkg.yahoo && info.pkg.yahoo.mojito && info.pkg.yahoo.mojito.type)
+ ' \t[' + info.parents.join(',') + ']'
- // + ' \t-- ' + JSON.stringify(info.inherit)
);
*/
pkg = {
@@ -1692,11 +1685,11 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
switch (info.pkg.yahoo.mojito.type) {
case 'bundle':
- dir = this._libs.path.join(info.dir, info.pkg.yahoo.mojito.location);
+ dir = this._libs.path.join(info.dir, info.pkg.yahoo.mojito.location || '');
this._preloadDirBundle(dir, pkg);
break;
case 'mojit':
- dir = this._libs.path.join(info.dir, info.pkg.yahoo.mojito.location);
+ dir = this._libs.path.join(info.dir, info.pkg.yahoo.mojito.location || '');
this._preloadDirMojit(dir, 'pkg', pkg);
break;
default:
@@ -25,6 +25,11 @@ YUI.add('mojito-tunnel-client', function(Y, NAME) {
url = this._appConfig.tunnelPrefix;
+ if (command._tunnelUrl) {
+ url = command._tunnelUrl;
+ command._tunnelUrl = undefined;
+ }
+
cfg = {
method: 'POST',
data: Y.JSON.stringify(command),
@@ -76,7 +76,9 @@ exports.run = function(params, opts, callback) {
pack = store.config.readConfigJSON(path.join(root, 'package.json'));
- options.port = params[0] || appConfig.appPort || process.env.PORT || 8666;
+ options.port = parseInt(params[0], 10) || appConfig.appPort;
+ options.port = options.port || process.env.PORT || 8666;
+
if (inputOptions.context) {
options.context = inputOptions.context;
}
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved.
+ * Copyrights licensed under the New BSD License.
+ * See the accompanying LICENSE file for terms.
+ */
+
+/*global require, module*/
+/*jslint sloppy:true, nomen:true*/
+
+/**
+ * Export a middleware error handler.
+ * @param {Object} The configuration.
+ * @return {Object} The handler.
+ */
+module.exports = function (config) {
+ return function (err, req, res, next) {
+ var statusCode = res.statusCode || 500;
+ res.send(statusCode, {
+ code: statusCode,
+ error: err.message
+ });
+ };
+};
Oops, something went wrong.

0 comments on commit ba0e292

Please sign in to comment.