diff --git a/README.md b/README.md index 55ed367..bf93928 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,31 @@ -#intro +#Intro locally 는 웹 개발 시 로컬 서버를 손쉽게 생성해서 테스트 개발환경을 구축하기 위한 Node.js 기반의 미들웨어이다. 이 프로젝트는 Python 의 SimpleHTTPServer 에서 아이디어를 얻었다. 언제, 어느 작업 디렉토리에 있던 내가 원하는 로컬 서버를 설정하기 위해서 사용된다. -뿐만 아니라 최근의 웹 기술중 서버측 css인 less 를 지원한다. 그리고 향후 유용한 서버측 환경설정 프리셋을 제공하여 손쉽게 마크업 개발 환경을 만들 예정이다. +>뿐만 아니라 최근의 웹 기술중 서버측 css인 less 를 지원한다. 그리고 향후 유용한 서버측 환경설정 프리셋을 제공하여 손쉽게 마크업 개발 환경을 만들 예정이다. <보류> -#locally middleware locally 는 connect 모듈을 기반으로 동작하는데 connect 모듈은 다양한 미들웨어를 추가해서 high class 기능등을 사용할 수 있다. 뿐만 아니라 손쉽게 로컬 웹 서버를 구축해서 마크업 환경을 설정할 수 있다. -#usage +#Install +Require NPM(Node Package Manager) + +``` +curl http://npmjs.org/install.sh | sh +``` + +NPM module install to global + +``` +$ npm install -g locally +``` + + +#Dependencies +locally 는 connect 모듈을 통해 웹 서버가 구동되고 cli 모듈은 commander.js 모듈을 이용하였다. 두가지 모듈 모두 visionmedia 의 TJ 가 개발한 node.js 모듈이다. + +#How to use + **directory structure** ``` @@ -23,43 +40,91 @@ locally 는 connect 모듈을 기반으로 동작하는데 connect 모듈은 다 - about/index.html ``` +**python** + +```python +$ python -m SimpleHTTPServer -p 8080 +``` + **basic command** -``` +```bash //simple command $ locally -p 8080 //full command -$ locally --static ./static --public ./public -port 8080 +$ locally --public ./public -port 8080 + +//short cut command +$ locally -w ./public -p 8080 + +//debug mode +$ locally --debug $ curl http://localhost:8080/ $ curl http://localhost:8080/about ``` -**python** +**help cli** -```python -$ python -m SimpleHTTPServer -p 8080 +```bash +$ locally --help + +Usage: _locally [options] + + Options: + + -h, --help output usage information + -V, --version output the version number + -s, --static directory for serving static files + -w, --public directory for serving public files + -d, --debug debug mode + -p, --port public port + -f, --file set configuration file + -n, --vhost set vhost information + + Examples: + + $ locally -w ./public -p 8080 start basic locally server + $ locally -d debug mode, default + $ locally -f ./conf/.locally force adjust locally configuration file ``` -**help cli** +##options +`locally` 는 기본적으로 실행 위치를 기준으로 `.locally` 파일로 미리 정의된 환경 옵션 셋을 지원한다. + +> 만약 이 파일이 없다면 `locally --help` 를 통해 cli 옵션을 활용할 수 있다. ``` -$ node lib/locally.js --help +$ cd /path/to/my_web_project +$ pwd +/path/to/my_web_project + +$ cat .locally +-w ./src/main +-p 8081 +--debug + +$ locally +document root : /path/to/my_web_project/./src/main +debug mode : true +Serving started at http://localhost:8081 +``` - Usage: locally.js [options] [command] +#Roadmap +* Virtual Host 환경 지원 +* fs.watcher 를 이용한 on the fly 기능 +* markdown preview 기능 지원 - Commands: +#License - init - locally setup webserver configuration +(The MIT License) - Options: +Copyright (c) 2011 Rhio Kim - -h, --help output usage information - -V, --version output the version number - -s, --static directory for serving static files - -d, --public directory for serving public files -``` +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/bin/_locally b/bin/_locally index bb7a63a..828eca9 100755 --- a/bin/_locally +++ b/bin/_locally @@ -32,7 +32,7 @@ program.on('--help', function() { function loadConfiguration() { // locally.opt support try { - var opts = fs.readFileSync(__dirname +'/.locally' , 'utf8') + var opts = fs.readFileSync(process.cwd() +'/.locally' , 'utf8') .trim() .split(/\s+/); @@ -79,7 +79,7 @@ program.parse(process.argv); * connect binding */ function createServer() { - var _static = __dirname +'/'+ program.public; + var _static = process.cwd() +'/'+ program.public; var app = connect( connect.static(_static), connect.bodyParser() diff --git a/example/server.opt b/example/server.opt deleted file mode 100644 index e69de29..0000000 diff --git a/example/server.sample.opt b/example/server.sample.opt deleted file mode 100644 index e69de29..0000000 diff --git a/lib/locally.js b/lib/locally.js index 16419b1..8189880 100644 --- a/lib/locally.js +++ b/lib/locally.js @@ -6,7 +6,7 @@ var connect = require('connect'), * process.argv pre process */ program - .version('0.1.0') + .version('0.1.2') .usage('[options]') .option('-s, --static ', 'directory for serving static files', 'static') .option('-w, --public ', 'directory for serving public files', './') @@ -30,7 +30,7 @@ program.on('--help', function() { function loadConfiguration() { // locally.opt support try { - var opts = fs.readFileSync(__dirname +'/.locally' , 'utf8') + var opts = fs.readFileSync(process.cwd() +'/.locally' , 'utf8') .trim() .split(/\s+/); @@ -77,7 +77,7 @@ program.parse(process.argv); * connect binding */ function createServer() { - var _static = __dirname +'/'+ program.public; + var _static = process.cwd() +'/'+ program.public; var app = connect( connect.static(_static), connect.bodyParser() diff --git a/package.json b/package.json index c1fbadd..3a37842 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "author": "Rhio Kim (http://about.me/rhio)", "name": "locally", - "description": "simple, locally web server", - "version": "0.0.0", - "homepage": "http://about.me/rhio", + "description": "simple, locally web server for file serving & markup job. '$ python -m SimpleHTTPServer 8080' ", + "version": "0.1.2", + "homepage": "http://github.com/rhiokim/locally", "repository": { + "type": "git", "url": "git@github.com:rhiokim/locally.git" }, - "main": "index", + "main": "index.js", "bin": { "locally": "./bin/locally", "_locally": "./bin/_locally" }, "engines": { "node": "~0.6.9" diff --git a/tests/.locally b/tests/.locally index 51e8dd4..fb8f32f 100644 --- a/tests/.locally +++ b/tests/.locally @@ -1 +1 @@ ---public ../tests/public/ +-w ./public diff --git a/tests/locally-test.sh b/tests/locally-test.sh new file mode 100644 index 0000000..0a84336 --- /dev/null +++ b/tests/locally-test.sh @@ -0,0 +1 @@ +node ../lib/locally.js -w public -p 8081 --debug