Making use of the closure-util package
This provides some initial development utilities for people using Node.
Instructions for installing:
npm install
After pulling down the dependencies, you can start a developement server that provides the libraries (ol and Closure Library) in debug mode (not minified/compiled). Run the dev server with the following:
npm start
Currently, the example index page needs to be built with `build.py`. After building that, you should be able to browse all static files, view the examples and run the tests.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
/examples/*.html.png
|
||||
/examples/example-list.js
|
||||
/examples/example-list.xml
|
||||
/node_modules/
|
||||
|
||||
19
package.json
Normal file
19
package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "openlayers",
|
||||
"version": "3.0.0-beta",
|
||||
"description": "Mapping library",
|
||||
"scripts": {
|
||||
"start": "node tasks/serve.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/openlayers/ol3.git"
|
||||
},
|
||||
"license": "BSD",
|
||||
"bugs": {
|
||||
"url": "https://github.com/openlayers/ol3/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"closure-util": "*"
|
||||
}
|
||||
}
|
||||
46
tasks/serve.js
Normal file
46
tasks/serve.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* This task starts a dev server that provides a script loader for OpenLayers
|
||||
* and Closure Library. In addition, a static server hosts all files in the
|
||||
* repository.
|
||||
*/
|
||||
|
||||
var path = require('path');
|
||||
var url = require('url');
|
||||
|
||||
var closure = require('closure-util');
|
||||
var log = closure.log;
|
||||
|
||||
log.info('ol', 'Parsing dependencies ...');
|
||||
var manager = new closure.Manager({
|
||||
closure: true, // use the bundled Closure Library
|
||||
lib: [
|
||||
'src/**/*.js',
|
||||
'test/spec/**/*.test.js'
|
||||
],
|
||||
main: 'examples/*.js'
|
||||
});
|
||||
manager.on('error', function(e) {
|
||||
log.error('ol', e.message);
|
||||
});
|
||||
manager.on('ready', function() {
|
||||
var server = new closure.Server({
|
||||
manager: manager,
|
||||
loader: /^\/\w+\/loader.js/,
|
||||
getMain: function(req) {
|
||||
var main;
|
||||
var query = url.parse(req.url, true).query;
|
||||
if (query.id) {
|
||||
var referer = req.headers.referer;
|
||||
if (referer) {
|
||||
var from = path.join(process.cwd(),
|
||||
path.dirname(url.parse(referer).pathname));
|
||||
main = path.resolve(from, query.id + '.js');
|
||||
}
|
||||
}
|
||||
return main;
|
||||
}
|
||||
});
|
||||
server.listen(3000, function() {
|
||||
log.info('ol', 'Listening on http://localhost:3000/ (Ctrl+C to stop)');
|
||||
});
|
||||
});
|
||||
50
test/index.html
Normal file
50
test/index.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OL Spec Runner</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="mocha-1.8.1/mocha.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script type="text/javascript" src="jquery-1.9.1/jquery.min.js"></script>
|
||||
<!-- Extended expect.js w/ various methods, see #374 for the differences to 0.2.0 -->
|
||||
<script type="text/javascript" src="expect-0.2.0-ol3/expect.js"></script>
|
||||
<script type="text/javascript" src="sinon-1.6.0/sinon.js"></script>
|
||||
<script type="text/javascript" src="mocha-1.8.1/mocha.js"></script>
|
||||
<script type="text/javascript" src="test-extensions.js"></script>
|
||||
<script>
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
bail: false
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="../build/proj4js/lib/proj4js-combined.js"></script>
|
||||
|
||||
<!-- This script is provided by the debug server (start with `npm start`) -->
|
||||
<script type="text/javascript" src="loader.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/**
|
||||
* The goog.dom.ViewportSizeMonitor (used in map.js) creates a global leak
|
||||
* by setting goog.UID_PROPERTY_ on the monitored window. In order to test
|
||||
* that we don't have other global leaks, we preemptively set the property
|
||||
* so Mocha can compare the global before and after our tests.
|
||||
*/
|
||||
goog.getUid(this);
|
||||
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
<!--
|
||||
Tests should not depend on any specific markup and should instead create
|
||||
whatever elements are needed (cleaning up when done).
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user