Comparing version 0.0.2 to 0.0.3
(function() { | ||
var CWD, CoffeeScript, Jade, Stylus, cli, express, fs, initializeProject, proto_version, quitWithMsg, serveProject, stamp, sys, | ||
var CWD, CoffeeScript, Jade, Stylus, cli, express, fs, gistProject, initializeProject, proto_version, quitWithMsg, rest, serveProject, stamp, sys, | ||
__slice = [].slice; | ||
@@ -13,2 +13,4 @@ | ||
rest = require('restler'); | ||
CoffeeScript = require('coffee-script'); | ||
@@ -20,3 +22,3 @@ | ||
proto_version = "0.0.2"; | ||
proto_version = "0.0.3"; | ||
@@ -36,4 +38,7 @@ CWD = process.cwd(); | ||
initializeProject = function(project_name) { | ||
initializeProject = function(project_name, from_gist) { | ||
var file_name, project_path, templates, _i, _len, _ref; | ||
if (from_gist == null) { | ||
from_gist = false; | ||
} | ||
templates = { | ||
@@ -61,2 +66,42 @@ 'script.coffee': 'console.log "loaded"\n\n\n', | ||
gistProject = function(project_name) { | ||
var GIST_API, f, post_data, post_req, project_path, sources, _fn, _i, _len; | ||
project_path = "" + CWD + "/" + project_name; | ||
if (!fs.existsSync(project_path)) { | ||
quitWithMsg("Error: " + project_name + " not found. Initialize with `proto -i " + project_name + "`."); | ||
} | ||
post_data = { | ||
description: 'A proto project: https://github.com/droptype/proto', | ||
"public": false, | ||
files: {} | ||
}; | ||
sources = ['script.coffee', 'markup.jade', 'style.styl', 'settings.json', 'notes.md']; | ||
_fn = function() { | ||
var content, source; | ||
source = project_path + '/' + f; | ||
content = fs.readFileSync(source); | ||
return post_data.files[f] = { | ||
content: content.toString() | ||
}; | ||
}; | ||
for (_i = 0, _len = sources.length; _i < _len; _i++) { | ||
f = sources[_i]; | ||
_fn(); | ||
} | ||
GIST_API = 'https://api.github.com/gists'; | ||
post_req = rest.post(GIST_API, { | ||
data: JSON.stringify(post_data) | ||
}); | ||
return post_req.on('complete', function(data, response) { | ||
var gist_url; | ||
if (response.statusCode === 201) { | ||
gist_url = data.html_url; | ||
return quitWithMsg("Success! Gist created at " + gist_url); | ||
} else { | ||
sys.puts("Error: " + request.statusCode); | ||
return sys.puts(data); | ||
} | ||
}); | ||
}; | ||
serveProject = function(project_name, port) { | ||
@@ -80,3 +125,3 @@ var compileMarkupFile, compileScriptFile, compileScriptLibraries, compileStyleFile, compileStyleLibraries, compositePage, doCompilation, loadSettings, project_path, serveContent, sources; | ||
if (settings.version !== proto_version) { | ||
quitWithMsg("Error: " + project_name + "'s version (" + settings.version + ") does not match proto's (" + proto_version + ")"); | ||
quitWithMsg("Error: " + project_name + "'s version (" + settings.version + ") does not match Proto's (" + proto_version + ")"); | ||
} | ||
@@ -171,3 +216,5 @@ return settings; | ||
if (options.init) { | ||
return initializeProject(new_project); | ||
return initializeProject(new_project, options.gist); | ||
} else if (options.gist) { | ||
return gistProject(new_project); | ||
} else { | ||
@@ -174,0 +221,0 @@ return serveProject(new_project, options.port); |
{ | ||
"name": "proto-cli", | ||
"version": "0.0.2", | ||
"description": "A prototyping tool, combining markup, style, and script into a served, rendered page.", | ||
"version": "0.0.3", | ||
"description": "A front-end web prototyping tool, combining markup, style, and script into a served, rendered page.", | ||
"main": "bin/proto", | ||
@@ -12,7 +12,8 @@ "scripts": { | ||
"dependencies": { | ||
"cli": "0.4.4-2", | ||
"coffee-script": "1.3.3", | ||
"express": "3.0.0rc5", | ||
"jade": "0.27.6", | ||
"stylus": "0.29.0", | ||
"express": "3.0.0rc5", | ||
"cli": "0.4.4-2" | ||
"restler": "2.0.1" | ||
}, | ||
@@ -19,0 +20,0 @@ "bin": { |
@@ -37,2 +37,5 @@ # Proto | ||
proto -i <project_name> -g <gist_url> | ||
### Work on a project | ||
@@ -54,3 +57,11 @@ | ||
### Gist a project | ||
To create a GitHub [gist](https://gist.github.com) with the project's contents: | ||
proto -g <project_name> | ||
This will upload the five files in the specified project folder to a private, anonymous gist. | ||
## FAQ | ||
@@ -57,0 +68,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22916
13
212
80
6
+ Addedrestler@2.0.1
+ Addedrestler@2.0.1(transitive)