-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
68 lines (68 loc) · 12 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"name": "grunt-contrib-connect",
"description": "Start a connect web server.",
"version": "0.5.0",
"homepage": "https://github.com/gruntjs/grunt-contrib-connect",
"author": {
"name": "Grunt Team",
"url": "http://gruntjs.com/"
},
"repository": {
"type": "git",
"url": "git://github.com/gruntjs/grunt-contrib-connect.git"
},
"bugs": {
"url": "https://github.com/gruntjs/grunt-contrib-connect/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/gruntjs/grunt-contrib-connect/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {
"connect": "~2.7.11",
"connect-livereload": "~0.2.0",
"open": "0.0.4"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-internal": "~0.4.6",
"grunt": "~0.4.0"
},
"peerDependencies": {
"grunt": "~0.4.0"
},
"keywords": [
"gruntplugin",
"server",
"connect",
"http"
],
"contributors": [
{
"name": "\"Cowboy\" Ben Alman",
"url": "http://benalman.com"
},
{
"name": "Tyler Kellen",
"url": "http://goingslowly.com"
},
{
"name": "Sindre Sorhus",
"url": "http://sindresorhus.com"
}
],
"readme": "# grunt-contrib-connect v0.5.0 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-connect.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-connect)\n\n> Start a connect web server.\n\n\n\n## Getting Started\nThis plugin requires Grunt `~0.4.0`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-contrib-connect --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-contrib-connect');\n```\n\n\n\n\n## Connect task\n_Run this task with the `grunt connect` command._\n\nNote that this server only runs as long as grunt is running. Once grunt's tasks have completed, the web server stops. This behavior can be changed with the [keepalive](#keepalive) option, and can be enabled ad-hoc by running the task like `grunt connect:keepalive`.\n\nThis task was designed to be used in conjunction with another task that is run immediately afterwards, like the [grunt-contrib-qunit plugin](https://github.com/gruntjs/grunt-contrib-qunit) `qunit` task.\n### Options\n\n#### port\nType: `Integer` \nDefault: `8000`\n\nThe port on which the webserver will respond. The task will fail if the specified port is already in use. You can use the special values `0` or `'?'` to use a system-assigned port.\n\n#### protocol\nType: `String` \nDefault: `'http'`\n\nMay be `'http'` or `'https'`.\n\n#### hostname\nType: `String` \nDefault: `'localhost'`\n\nThe hostname the webserver will use.\n\nSetting it to `'*'` will make the server accessible from anywhere.\n\n#### base\nType: `String` or `Array` \nDefault: `'.'`\n\nThe base (or root) directory from which files will be served. Defaults to the project Gruntfile's directory.\n\nCan be an array of bases to serve multiple directories. The last base given will be the directory to become browse-able.\n\n#### directory\nType: `String` \nDefault: `null`\n\nSet to the directory you wish to be browse-able. Used to override the `base` option browse-able directory.\n\n#### keepalive\nType: `Boolean` \nDefault: `false`\n\nKeep the server alive indefinitely. Note that if this option is enabled, any tasks specified after this task will _never run_. By default, once grunt's tasks have completed, the web server stops. This option changes that behavior.\n\nThis option can also be enabled ad-hoc by running the task like `grunt connect:targetname:keepalive`\n\n#### debug\nType: `Boolean` \nDefault: `false`\n\nSet the `debug` option to true to enable logging instead of using the `--debug` flag.\n\n#### livereload\nType: `Boolean` or `Number` \nDefault: `false`\n\nSet to `true` or a port number to inject a live reload script tag into your page using [connect-livereload](https://github.com/intesso/connect-livereload).\n\n*This does not perform live reloading. It is intended to be used in tandem with grunt-contrib-watch or another task that will trigger a live reload server upon files changing.*\n\n#### open\nType: `Boolean` or `String`\nDefault: `false`\n\nOpen the served page in your default browser. Specifying `true` opens the default server URL, while specifying a URL opens that URL.\n\n#### middleware\nType: `Function` \nDefault:\n\n```js\nfunction(connect, options) {\n var middlewares = [];\n var directory = options.directory || options.base[options.base.length - 1];\n if (!Array.isArray(options.base)) {\n options.base = [options.base];\n }\n options.base.forEach(function(base) {\n // Serve static files.\n middlewares.push(connect.static(base));\n });\n // Make directory browse-able.\n middlewares.push(connect.directory(directory));\n return middlewares;\n}\n```\n\nLets you add in your own Connect middlewares. This option expects a function that returns an array of middlewares. See the [project Gruntfile][] and [project unit tests][] for a usage example.\n\n[project Gruntfile]: Gruntfile.js\n[project unit tests]: test/connect_test.js\n\n### Usage examples\n\n#### Basic Use\nIn this example, `grunt connect` (or more verbosely, `grunt connect:server`) will start a static web server at `http://localhost:9001/`, with its base path set to the `www-root` directory relative to the gruntfile, and any tasks run afterwards will be able to access it.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n connect: {\n server: {\n options: {\n port: 9001,\n base: 'www-root'\n }\n }\n }\n});\n```\n\nIf you want your web server to use the default options, just omit the `options` object. You still need to specify a target (`uses_defaults` in this example), but the target's configuration object can otherwise be empty or nonexistent. In this example, `grunt connect` (or more verbosely, `grunt connect:uses_defaults`) will start a static web server using the default options.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n connect: {\n uses_defaults: {}\n }\n});\n```\n\n#### Multiple Servers\nYou can specify multiple servers to be run alone or simultaneously by creating a target for each server. In this example, running either `grunt connect:site1` or `grunt connect:site2` will start the appropriate web server, but running `grunt connect` will run _both_. Note that any server for which the [keepalive](#keepalive) option is specified will prevent _any_ task or target from running after it.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n connect: {\n site1: {\n options: {\n port: 9000,\n base: 'www-roots/site1'\n }\n },\n site2: {\n options: {\n port: 9001,\n base: 'www-roots/site2'\n }\n }\n }\n});\n```\n\n#### Roll Your Own\nLike the [Basic Use](#basic-use) example, this example will start a static web server at `http://localhost:9001/`, with its base path set to the `www-root` directory relative to the gruntfile. Unlike the other example, this is done by creating a brand new task. in fact, this plugin isn't even installed!\n\n```javascript\n// Project configuration.\ngrunt.initConfig({ /* Nothing needed here! */ });\n\n// After running \"npm install connect --save-dev\" to add connect as a dev\n// dependency of your project, you can require it in your gruntfile with:\nvar connect = require('connect');\n\n// Now you can define a \"connect\" task that starts a webserver, using the\n// connect lib, with whatever options and configuration you need:\ngrunt.registerTask('connect', 'Start a custom static web server.', function() {\n grunt.log.writeln('Starting static web server in \"www-root\" on port 9001.');\n connect(connect.static('www-root')).listen(9001);\n});\n```\n\n#### Support for HTTPS\n\nA default certificate authority, certificate and key file are provided and pre-\nconfigured for use when `protocol` has been set to `https`.\n\nNOTE: The passphrase used on the files is `grunt`\n\n####### Advanced HTTPS config\n\nIf the default certificate setup is unsuitable for your environment, OpenSSL\ncan be used to create a set of self-signed certificates with a local ca root.\n\n```shell\n### Generate the CA key\n### Set a passphrase and remember what it is\nopenssl genrsa -des3 -out ca.key 2048\n### Generate a CA root\nopenssl req -new -x509 -days 3650 -key ca.key -out ca.crt\n\n### Generate the server key\nopenssl genrsa -out server.key 1024\n### Generate the request to the self-signed CA root\nopenssl req -new -key server.key -out server.csr\n### Generate the server certificate\nopenssl x509 -req -in server.csr -out server.crt -CA ca.crt -CAkey ca.key -CAcreateserial -days 3650\n```\n\nFor more details on the various options that can be set when configuring SSL,\nplease see the Node documentation for [TLS][].\n\nGrunt configuration would become\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n connect: {\n server: {\n options: {\n protocol: 'https',\n port: 8443,\n key: grunt.file.read('server.key').toString(),\n cert: grunt.file.read('server.crt').toString(),\n ca: grunt.file.read('ca.crt').toString(),\n passphrase: 'grunt',\n },\n },\n },\n});\n```\n\n[TLS]: http://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener\n\n#### Grunt Events\nThe connect plugin will emit a grunt event, `connect.{taskName}.listening`, once the server has started. You can listen for this event to run things against a keepalive server, for example:\n\n```javascript\ngrunt.registerTask('jasmine-server', 'start web server for jasmine tests in browser', function() {\n grunt.task.run('jasmine:tests:build');\n\n grunt.event.once('connect.tests.listening', function(host, port) {\n var specRunnerUrl = 'http://' + host + ':' + port + '/_SpecRunner.html';\n grunt.log.writeln('Jasmine specs available at: ' + specRunnerUrl);\n require('open')(specRunnerUrl);\n });\n\n grunt.task.run('connect:tests:keepalive');\n});\n```\n\n\n## Release History\n\n * 2013-09-05 v0.5.0 Add 'open' option.\n * 2013-09-05 v0.4.2 Un-normalize options.base as it should be a string or an array as the user has set. Fix setting target hostname option.\n * 2013-09-02 v0.4.1 Browse-able directory is the last item supplied to bases. Added directory option to override browse-able directory.\n * 2013-09-01 v0.4.0 Fix logging of which server address. Ability to set multiple bases. Event emitted when server starts listening. Support for HTTPS. debug option added to display debug logging like the --debug flag. livereload option added to inject a livereload snippet into the page.\n * 2013-04-10 v0.3.0 Add ability to listen on system-assigned port.\n * 2013-03-07 v0.2.0 Upgrade connect dependency.\n * 2013-02-17 v0.1.2 Ensure Gruntfile.js is included on npm.\n * 2013-02-15 v0.1.1 First official release for Grunt 0.4.0.\n * 2013-01-18 v0.1.1rc6 Updating grunt/gruntplugin dependencies to rc6. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.\n * 2013-01-09 v0.1.1rc5 Updating to work with grunt v0.4.0rc5.\n * 2012-11-01 v0.1.0 Work in progress, not yet officially released.\n\n---\n\nTask submitted by [\"Cowboy\" Ben Alman](http://benalman.com)\n\n*This file was generated on Thu Sep 05 2013 14:09:10.*\n",
"readmeFilename": "README.md",
"_id": "grunt-contrib-connect@0.5.0",
"_from": "grunt-contrib-connect@~0.5.0"
}