Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:yahoo/mojito into travis-node-10
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy committed Apr 5, 2013
2 parents f90a663 + 9d13fbd commit ba0e292
Show file tree
Hide file tree
Showing 39 changed files with 1,294 additions and 639 deletions.
37 changes: 35 additions & 2 deletions HISTORY.md
Expand Up @@ -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
=================
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_guide/intro/mojito_mvc.rst
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions docs/dev_guide/reference/mojito_cmdline.rst
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions docs/dev_guide/topics/mojito_logging.rst
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/dev_guide/topics/mojito_run_dyn_defined_mojits.rst
Expand Up @@ -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:

Expand Down
14 changes: 10 additions & 4 deletions docs/dev_guide/topics/mojito_testing.rst
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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``
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/app/addons/rs/selector.js
Expand Up @@ -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;
},


Expand Down
2 changes: 1 addition & 1 deletion lib/app/autoload/action-context.common.js
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/app/autoload/mojit-proxy.client.js
Expand Up @@ -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);
},

Expand Down
3 changes: 3 additions & 0 deletions lib/app/autoload/mojito-client.client.js
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/app/autoload/package-walker.server.js
Expand Up @@ -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
Expand Down Expand Up @@ -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)
});
}
};
Expand Down
6 changes: 4 additions & 2 deletions lib/app/autoload/route-maker.common.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
},


Expand Down
15 changes: 4 additions & 11 deletions lib/app/autoload/store.server.js
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
*/
/**
Expand Down Expand Up @@ -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;
},


Expand Down Expand Up @@ -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 = {
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions lib/app/autoload/tunnel-client.common.js
Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion lib/app/commands/start.js
Expand Up @@ -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;
}
Expand Down
23 changes: 23 additions & 0 deletions lib/app/middleware/mojito-handler-error.js
@@ -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
});
};
};

0 comments on commit ba0e292

Please sign in to comment.