Skip to content

Commit

Permalink
Reworked packaging for npm 1.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricemach committed May 6, 2011
1 parent 1449e9a commit 2d2b83c
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
.DS_Store
material/
lib/zappa.js
node_modules/
2 changes: 2 additions & 0 deletions .npmignore
@@ -0,0 +1,2 @@
.git*
material/
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
**v0.1.5** (2010-05-06):

- Reworked packaging for npm 1.x.

**v0.1.4** (2010-01-05):

- Updated to CoffeeScript 1.0.0 and node 0.2.6/0.3.3.
Expand Down
4 changes: 2 additions & 2 deletions Cakefile
@@ -1,9 +1,9 @@
{spawn, exec} = require 'child_process'

{puts} = require 'sys'
{puts} = console.log

task 'build', ->
exec 'coffee -c lib/zappa.coffee', (err) ->
exec 'coffee -o lib -c src/*.coffee', (err) ->
puts err if err

task 'test', ->
Expand Down
7 changes: 7 additions & 0 deletions bin/zappa
@@ -0,0 +1,7 @@
#!/usr/bin/env node

var path = require('path')
var fs = require('fs')
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib')

require(lib + '/cli').run()
1 change: 1 addition & 0 deletions examples/public/foo.txt
@@ -0,0 +1 @@
bar
2 changes: 0 additions & 2 deletions index.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/.gitignore
@@ -0,0 +1 @@
*.js
18 changes: 9 additions & 9 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "zappa",
"description": "Web development, cut-the-crap style.",
"version": "0.1.4",
"version": "0.1.5",
"author": "Maurice Machado <maurice@bitbending.com>",
"contributors": [
{"name": "Maurice Machado", "email": "maurice@bitbending.com"},
Expand All @@ -10,16 +10,16 @@
{"name": "Vladimir Dronnikov", "email": "dronnikov@gmail.com"},
{"name": "Isaac Wolkerstorfer", "email": "agnoster@gmail.com"}
],
"repository": {"type": "git", "url": "http://github.com/mauricemach/zappa.git"},
"dependencies": {
"express": ">= 1.0.1",
"coffeekup": ">= 0.2.2",
"coffee-script": ">= 1.0.0",
"express": ">= 2.3.0",
"coffeekup": ">= 0.2.3",
"coffee-script": ">= 1.0.1",
"socket.io": ">= 0.6.3",
"jquery": ">= 1.4.3"
"jquery": ">= 1.5.1"
},
"keywords": ["framework", "websockets", "coffeescript"],
"bin": { "zappa": "./bin/zappa.coffee" },
"directories": { "lib": "./lib" },
"main": "./lib/index",
"engines": { "node": ">= 0.2.6" }
"bin": "./bin/zappa",
"main": "./lib/zappa",
"engines": { "node": ">= 0.4.1" }
}
71 changes: 33 additions & 38 deletions bin/zappa.coffee → src/cli.coffee 100755 → 100644
@@ -1,6 +1,4 @@
#!/usr/bin/env coffee

zappa = require 'zappa'
zappa = require './zappa'
coffee = require 'coffee-script'
fs = require 'fs'
path = require 'path'
Expand All @@ -12,12 +10,8 @@ child = null
file = null
watching = []

# On coffee-script@0.9.6, argv looks like [filename],
# On coffee-script@1.0.0, argv looks like ["node", "path/to/coffee", filename]
if process.argv[0] is 'node' and process.argv.length >= 2
argv = process.argv[2..]
else
argv = process.argv[0..]
argv = process.argv[2..]
options = null

usage = '''
Usage:
Expand Down Expand Up @@ -70,36 +64,37 @@ watch = (file) ->
child.kill() # Infanticide!
spawn_child()

parser = new OptionParser switches, usage
options = parser.parse argv
args = options.arguments
delete options.arguments
@run = ->
parser = new OptionParser switches, usage
options = parser.parse argv
args = options.arguments
delete options.arguments

if options.port
options.port = if options.port.match /,/ then options.port.split ',' else [options.port]
for i, p of options.port
options.port[i] = parseInt(p)
if options.port
options.port = if options.port.match /,/ then options.port.split ',' else [options.port]
for i, p of options.port
options.port[i] = parseInt(p)

if args.length is 0
puts parser.help() if options.help or argv.length is 0
puts zappa.version if options.version
process.exit()
else
file = args[0]

path.exists file, (exists) ->
if not exists
puts "\"#{file}\" not found."
process.exit -1
if args.length is 0
puts parser.help() if options.help or argv.length is 0
puts zappa.version if options.version
process.exit()
else
file = args[0]

if options.compile
compile file, (err) ->
if err then puts err; process.exit -1
else process.exit()
else
if options.watch
remove_watch_option()
spawn_child()
watch file
path.exists file, (exists) ->
if not exists
puts "\"#{file}\" not found."
process.exit -1
if options.compile
compile file, (err) ->
if err then puts err; process.exit -1
else process.exit()
else
zappa.run_file file, options
if options.watch
remove_watch_option()
spawn_child()
watch file
else
zappa.run_file file, options
2 changes: 1 addition & 1 deletion lib/zappa.coffee → src/zappa.coffee
Expand Up @@ -431,6 +431,6 @@ publish_api = (from, to, methods) ->

z = new Zappa()

zappa.version = '0.1.4'
zappa.version = '0.1.5'
zappa.run = -> z.run.apply z, arguments
zappa.run_file = -> z.run_file.apply z, arguments

0 comments on commit 2d2b83c

Please sign in to comment.