Permalink
Browse files

inital commit

  • Loading branch information...
0 parents commit da94db41412f16207b8a87444732964f29dc2f34 @sintaxi committed Dec 3, 2012
Showing with 146 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +45 −0 README.md
  3. +40 −0 bin/harp
  4. +2 −0 harp.js
  5. +23 −0 lib/compile.js
  6. +18 −0 lib/server.js
  7. +15 −0 package.json
@@ -0,0 +1,3 @@
+.DS_Store
+*.swp
+node_modules
@@ -0,0 +1,45 @@
+# harp
+
+## description
+
+Harp is an opinionated static site generator for building apps. It also acts as a server for harp applications.
+
+## install
+
+ npm install -g harp
+
+## usage
+
+ Usage: harp [app-path] [options]
+
+ Options:
+
+ -g, --generate Generates harp project files within current directory (if empty).
+ -s, --server Start a server for harp app (dynamically compiles).
+ -c, --compile <output-dir> Compiles down to static assets.
+ -h, --help Output usage information.
+
+
+## usage as lib
+
+ var harp = require("harp")
+
+serve up harp application
+
+ harp.server(projectPath, port)
+
+compile harp application
+
+ harp.compile(projectPath, outputPath, callback)
+
+## license
+
+Copyright 2011/2012 Chloi Inc. All rights reserved.
+
+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.
+
+
@@ -0,0 +1,40 @@
+#!/usr/bin/env node
+
+var path = require('path')
+var program = require('commander')
+var pkg = require('../package.json')
+var harp = require('../')
+
+program
+ .version(pkg.version)
+ .usage('[project-path] [options]')
+ .option('-s, --server [port]', 'start a server for harp app (dynamically generates assets)')
+ .option('-c, --compile [output-path]', 'compiles static assets. (relative to project-path)')
+ .parse(process.argv)
+
+if(program.args.length > 0){
+ var projectPath = path.resolve(program.args[0])
+}else{
+ var cwd = process.cwd()
+ var projectPath = path.resolve(cwd)
+}
+
+if(program.server){
+ port = program.server === true
+ ? null
+ : program.server
+ harp.server(projectPath, port)
+}else if(program.compile){
+ outputPath = program.compile === true
+ ? null
+ : program.compile
+ harp.compile(projectPath, outputPath, function(err, out){
+ if(err){
+ console.log(err)
+ }else{
+ console.log("harp application compiled to", out)
+ }
+ })
+}else{
+ program.help()
+}
@@ -0,0 +1,2 @@
+exports.server = require("./lib/server")
+exports.compile = require("./lib/compile")
@@ -0,0 +1,23 @@
+var path = require("path")
+var fse = require("fs-extra")
+
+module.exports = function(projectPath, outputPath, callback){
+ if(!callback){
+ callback = outputPath
+ outputPath = "output"
+ }
+
+ if(!outputPath){
+ outputPath = "output"
+ }
+
+ outputPath = path.resolve(projectPath, outputPath)
+ var publicPath = path.resolve(projectPath, "public")
+ fse.copy(publicPath, outputPath, function(err){
+ if(err){
+ callback(err)
+ }else{
+ callback(null, outputPath)
+ }
+ })
+}
@@ -0,0 +1,18 @@
+var connect = require("connect")
+var path = require("path")
+
+module.exports = function(projectPath, port){
+
+ // default port
+ if(!port) port = 8001
+
+ // get path to public assets
+ var publicPath = path.resolve(projectPath, "public")
+
+ // static server
+ connect.createServer(connect.static(publicPath)).listen(port)
+
+ // output message
+ console.log("harp is listening on port", port)
+
+}
@@ -0,0 +1,15 @@
+{
+ "name": "harp",
+ "version": "0.1.0",
+ "description": "Opinionated static site generator for building apps.",
+ "author": "Brock Whitten <brock@chloi.io>",
+ "main": "harp.js",
+ "dependencies":{
+ "commander": "1.1.1",
+ "connect": "2.7.0",
+ "fs-extra": "0.3.2"
+ },
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "bin": { "harp": "./bin/harp" }
+}

0 comments on commit da94db4

Please sign in to comment.