Commit 9420750c authored by Leo Iannacone's avatar Leo Iannacone

Merge branch 'sbuild' into portable

parents b5212a6d 9e3de8c7
debomatic-webui
===============
**debomatic-webui** is a web interface for [Deb-o-Matic](https://launchpad.net/debomatic) aims to give to users a simple way to browse logs and to know what's going on debomatic build service providing a real-time packages status.
**debomatic-webui** is a web interface for [Deb-o-Matic](http://debomatic.github.io) aims to give to users a simple way to browse logs and to know what's going on debomatic build service providing a real-time packages status.
This interface is built up on [node](http://nodejs.org/) platform and uses intensely [socket.io](http://socket.io/) and [jquery](http://jquery.com/) technologies.
Whenever you want to leave a suggestion or file a bug report, please open a [new issue](https://github.com/LeoIannacone/debomatic-webui/issues).
......
......@@ -29,9 +29,11 @@ from time import time
from json import dumps as toJSON
from json import load as fileToJSON
from collections import defaultdict
from hashlib import md5
class DebomaticModule_JSONLoggerStart:
def __init__(self):
self.logger = DebomaticModule_JSONLogger()
self.first = True
......@@ -44,6 +46,7 @@ class DebomaticModule_JSONLoggerStart:
class DebomaticModule_JSONLoggerStop:
def __init__(self):
self.logger = DebomaticModule_JSONLogger()
self.last = True
......@@ -64,30 +67,33 @@ class DebomaticModule_JSONLogger:
def _set_json_logfile_name(self, args):
"""If debomatic config file has section [jsonlogger] try to get
'jsonfile' option and override the default value."""
if 'opts' in args and \
args['opts'].has_section('jsonlogger') and \
args['opts'].has_option('jsonlogger', 'jsonfile'):
self.jsonfile = args['opts'].get('jsonlogger', 'jsonfile').strip()
if (args.opts.has_section('jsonlogger') and
args.opts.has_option('jsonlogger', 'jsonfile')):
self.jsonfile = args.opts.get('jsonlogger', 'jsonfile').strip()
def _get_package_json_filename(self, args):
"""Get the path of package JSON file"""
return '%(directory)s/pool/%(package)s/%(package)s.json' % args
return ('%(directory)s/pool/%(package)s/%(package)s.json' %
{'directory': args.directory, 'package': args.package})
def _get_distribution_status(self, args):
def _get_distribution_status(self, args, with_success=False):
"""From args to distribution status"""
status = {}
status['status'] = args['cmd']
status['distribution'] = args['distribution']
if 'success' in args:
status['success'] = args['success']
status['status'] = args.action
status['distribution'] = args.distribution
if with_success:
status['success'] = args.success
return status
def _get_package_status(self, args):
"""From args to package status"""
status = {}
for k in ['package', 'distribution', 'uploader']:
if k in args:
status[k] = args[k]
status['package'] = args.package
status['distribution'] = args.distribution
status['uploader'] = args.uploader
if args.uploader != "":
email = args.uploader.lower().encode('utf-8')
status['gravatar'] = md5(email).hexdigest()
return status
def _append_json_logfile(self, args, status):
......@@ -126,11 +132,15 @@ class DebomaticModule_JSONLogger:
num /= 1024.0
def pre_chroot(self, args):
if args.action is None:
return
distribution = self._get_distribution_status(args)
self._append_json_logfile(args, distribution)
def post_chroot(self, args):
distribution = self._get_distribution_status(args)
if args.action is None:
return
distribution = self._get_distribution_status(args, with_success=True)
self._append_json_logfile(args, distribution)
def pre_build(self, args):
......@@ -145,18 +155,19 @@ class DebomaticModule_JSONLogger:
def post_build(self, args):
status = self._get_package_status(args)
status['status'] = 'build'
status['success'] = args['success']
status['success'] = args.success
status['files'] = {}
resultdir = os.path.join(args['directory'], 'pool', args['package'])
resultdir = os.path.join(args.directory, 'pool', args.package)
for filename in os.listdir(resultdir):
if filename.endswith('.json'):
continue
full_path = os.path.join(resultdir, filename)
info = {}
info['size'] = self._get_human_size(os.path.getsize(full_path))
tag = LogParser(full_path).parse()
tag, level = LogParser(full_path).parse()
if tag:
info['tags'] = tag
info['level'] = level
status['files'][filename] = info
self._write_package_json(args, status)
status.pop('files', None)
......@@ -165,6 +176,7 @@ class DebomaticModule_JSONLogger:
# Parser for log files
class LogParser():
def __init__(self, file_path):
self.file = file_path
self.basename = os.path.basename(file_path)
......@@ -173,16 +185,18 @@ class LogParser():
def parse(self):
if not os.path.isfile(self.file):
return None
result = None
tag = None
# level can be: info, warning, danger
level = "info" # by default
if self.extension == 'lintian':
result = self.parse_lintian()
tag, level = self.parse_lintian()
elif self.extension == 'autopkgtest':
result = self.parse_autopkgtest()
tag, level = self.parse_autopkgtest()
elif self.extension == 'piuparts':
result = self.parse_piuparts()
tag, level = self.parse_piuparts()
elif self.extension == 'blhc':
result = self.parse_blhc()
return result
tag, level = self.parse_blhc()
return tag, level
def parse_lintian(self):
tags = defaultdict(int)
......@@ -190,7 +204,13 @@ class LogParser():
for line in fd:
if len(line) >= 2 and line[0] != 'N' and line[1] == ':':
tags[line[0]] += 1
return self._from_tags_to_result(tags)
tags = self._from_tags_to_result(tags)
level = "info"
if 'E' in tags:
level = "danger"
elif 'W' in tags:
level = "warning"
return tags, level
def parse_autopkgtest(self):
tags = defaultdict(int)
......@@ -211,14 +231,14 @@ class LogParser():
tags[info[0]] += 1
elif found and line == '\n':
break
return self._from_tags_to_result(tags)
return self._from_tags_to_result(tags), 'danger'
def parse_piuparts(self):
with open(self.file, 'r') as fd:
lines = fd.readlines()
if len(lines) == 0 or lines[-1].find('ERROR:') >= 0:
return 'E'
return None
return 'E', 'danger'
return None, None
def parse_blhc(self):
tags = defaultdict(int)
......@@ -229,7 +249,7 @@ class LogParser():
continue
tag = info[0].replace('FLAGS', '')
tags[tag] += 1
return ' '.join(sorted(list(tags.keys())))
return ' '.join(sorted(list(tags.keys()))), 'warning'
def _from_tags_to_result(self, tags):
keys = sorted(list(tags.keys()))
......
......@@ -7,6 +7,7 @@ io = require("socket.io")(server)
serve_static = require("serve-static")
serve_index = require("serve-index")
compression = require("compression")
errorhandler = require("errorhandler")
routes = require("../routes")
......@@ -24,6 +25,9 @@ if env is "development"
else
app.use(errorhandler())
# use compression by default
app.use(compression())
# the views
app.set("views", __dirname + "/../views")
app.set("view engine", "ejs")
......@@ -66,6 +70,15 @@ if config.routes.debomatic
res.set('Content-Type', 'text/plain')
next()
# always download log files and some source files, like .dsc and .changes ones
app.all config.routes.debomatic + '/:distribution/pool/:package/:file', (req, res, next) ->
type = utils.file_type(req.params.file)
ext = req.params.file.split('.').pop()
if type is "log" or ext in ["changes", "dsc"]
res.set('Content-Type', 'text/plain')
res.set('Content-Disposition', 'attachment; filename=' + req.params.file)
next()
app.use(config.routes.debomatic, serve_static(config.debomatic.path))
app.use(config.routes.debomatic, serve_index(config.debomatic.path,
{view: "details", icons: true}))
......@@ -73,9 +86,6 @@ if config.routes.debomatic
# serve stylesheet-javascript
app.use(serve_static(__dirname + "/../public"))
# serve dsc files as octet-stream
serve_static.mime.define("application/octet-stream": ["dsc"])
# Listening
server.listen config.port, config.host, null, (err) ->
......
......@@ -20,9 +20,10 @@ get_files_list_from_package = (data, callback) ->
config.routes.debomatic)
file.orig_name = f
file.name = f.split("_")[0]
if file.extension in ["deb", "ddeb", "udeb"]
type = utils.file_type(f)
if type is "deb"
data.package.debs.push(file)
else if file.extension in ["changes", "dsc"] or f.indexOf('.tar.') > 0 or f.indexOf('.diff.') > 0
else if type is "source"
file.name = f.replace(data.package.orig_name + ".", "")
if file.extension is "changes"
file.name = f.split('_').pop()
......@@ -73,7 +74,7 @@ class Client
pack.orig_name = p
read_package_status {distribution: data.distribution, package: pack}, (content) =>
for attr of content
if attr not in ['distribution', 'package', 'status', 'success']
if attr not in ['distribution', 'package', 'status', 'success', 'gravatar']
delete content[attr]
@socket.emit e.distribution_packages_status, content
data.distribution.packages.push pack
......
......@@ -37,8 +37,8 @@ config.debomatic.jsonfile = "/var/log/debomatic-json.log"
Web template configuration
Title and description for the header
###
config.web.debomatic.architecture = "amd64"
config.web.title = "Deb-o-Matic " + config.web.debomatic.architecture
config.web.debomatic.architecture = "system" # or amd64, i386, ...
config.web.title = "Deb-o-Matic"
###
Admin email and name to show in the home page.
......@@ -88,6 +88,7 @@ List of files to not show in webui
config.debomatic.excluded_files = [
"datestamp"
"json"
"build"
]
###
......@@ -163,6 +164,12 @@ try
crypto.createHash("sha256")
.update(config.debomatic.path)
.digest("hex")
if config.web.debomatic.architecture == "system"
check = "dpkg-architecture -qDEB_BUILD_ARCH"
require("child_process").exec check, (error, stdout, stderr) ->
config.web.debomatic.architecture = stdout.trim()
module.exports = config
catch err
......
......@@ -5,6 +5,8 @@ glob = require("glob")
Tail = require("tail").Tail
_check_no_backward = (backward_path) ->
if backward_path is undefined
return false
if typeof backward_path is 'string'
return backward_path.indexOf("..") < 0
return true
......@@ -33,7 +35,7 @@ get_distributions = (callback) ->
if err
errors_handler "get_distributions", err
return
distributions = (dir.split(path.sep)[-2...-1] for dir in directories)
distributions = (dir.split(path.sep)[-2...-1].pop() for dir in directories)
callback(distributions)
get_distribution_pool_path = (data) ->
......@@ -117,6 +119,14 @@ errors_handler = (from, err, socket) ->
socket.emit config.events.error, msg if socket
return
file_type = (filename) ->
extension = filename.split(".").pop()
if extension in ["deb", "ddeb", "udeb"]
return "deb"
if extension in ["changes", "dsc"] or filename.indexOf('.tar.') > 0 or filename.indexOf('.diff.') > 0
return "source"
return "log"
Tail::watchEvent = (e) ->
_this = this
if e is "change"
......@@ -152,5 +162,6 @@ module.exports.get_file_path = get_file_path
module.exports.get_files_list = get_files_list
module.exports.watch_path_onsocket = watch_path_onsocket
module.exports.errors_handler = errors_handler
module.exports.file_type = file_type
module.exports.arrayEqual = arrayEqual
module.exports.Tail = Tail
Copyright (c) 2009-2014 Jeremy Ashkenas
Copyright (c) 2009-2015 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
......
{
"name": "coffee-script",
"version": "1.9.1",
"main": [
"lib/coffee-script/coffee-script.js"
],
"description": "Unfancy JavaScript",
"keywords": [
"javascript",
"language",
"coffeescript",
"compiler"
],
"devDependencies": {
"uglify-js": "~2.2",
"jison": ">=0.2.0",
"highlight.js": "~8.0.0",
"underscore": "~1.5.2",
"docco": "~0.6.2"
},
"author": {
"name": "Jeremy Ashkenas"
},
"ignore": [
"test"
]
}
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var CoffeeScript, compile, runScripts,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
CoffeeScript = require('./coffee-script');
......@@ -34,14 +34,14 @@
if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
compile = function(code, options) {
var js, v3SourceMap, _ref;
var js, ref, v3SourceMap;
if (options == null) {
options = {};
}
options.sourceMap = true;
options.inline = true;
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap;
return "" + js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript";
ref = CoffeeScript.compile(code, options), js = ref.js, v3SourceMap = ref.v3SourceMap;
return js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript";
};
}
......@@ -60,9 +60,9 @@
xhr.overrideMimeType('text/plain');
}
xhr.onreadystatechange = function() {
var param, _ref;
var param, ref;
if (xhr.readyState === 4) {
if ((_ref = xhr.status) === 0 || _ref === 200) {
if ((ref = xhr.status) === 0 || ref === 200) {
param = [xhr.responseText, options];
if (!hold) {
CoffeeScript.run.apply(CoffeeScript, param);
......@@ -79,19 +79,19 @@
};
runScripts = function() {
var coffees, coffeetypes, execute, i, index, s, script, scripts, _fn, _i, _len;
var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts;
scripts = window.document.getElementsByTagName('script');
coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
coffees = (function() {
var _i, _len, _ref, _results;
_results = [];
for (_i = 0, _len = scripts.length; _i < _len; _i++) {
s = scripts[_i];
if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) {
_results.push(s);
var j, len, ref, results;
results = [];
for (j = 0, len = scripts.length; j < len; j++) {
s = scripts[j];
if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) {
results.push(s);
}
}
return _results;
return results;
})();
index = 0;
execute = function() {
......@@ -103,7 +103,7 @@
return execute();
}
};
_fn = function(script, i) {
fn = function(script, i) {
var options;
options = {
literate: script.type === coffeetypes[1]
......@@ -118,9 +118,9 @@
return coffees[i] = [script.innerHTML, options];
}
};
for (i = _i = 0, _len = coffees.length; _i < _len; i = ++_i) {
for (i = j = 0, len = coffees.length; j < len; i = ++j) {
script = coffees[i];
_fn(script, i);
fn(script, i);
}
return execute();
};
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
......@@ -24,9 +24,9 @@
helpers.extend(global, {
task: function(name, description, action) {
var _ref;
var ref;
if (!action) {
_ref = [description, action], action = _ref[0], description = _ref[1];
ref = [description, action], action = ref[0], description = ref[1];
}
return tasks[name] = {
name: name,
......@@ -46,7 +46,7 @@
});
exports.run = function() {
var arg, args, e, _i, _len, _ref, _results;
var arg, args, e, i, len, ref, results;
global.__originalDirname = fs.realpathSync('.');
process.chdir(cakefileDirectory(__originalDirname));
args = process.argv.slice(2);
......@@ -63,20 +63,20 @@
e = _error;
return fatalError("" + e);
}
_ref = options["arguments"];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
arg = _ref[_i];
_results.push(invoke(arg));
ref = options["arguments"];
results = [];
for (i = 0, len = ref.length; i < len; i++) {
arg = ref[i];
results.push(invoke(arg));
}
return _results;
return results;
};
printTasks = function() {
var cakefilePath, desc, name, relative, spaces, task;
relative = path.relative || path.resolve;
cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
console.log("" + cakefilePath + " defines the following tasks:\n");
console.log(cakefilePath + " defines the following tasks:\n");
for (name in tasks) {
task = tasks[name];
spaces = 20 - name.length;
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
fs = require('fs');
......@@ -13,9 +13,7 @@
CoffeeScript = require('./coffee-script');
mkdirp = require('mkdirp');
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
ref = require('child_process'), spawn = ref.spawn, exec = ref.exec;
EventEmitter = require('events').EventEmitter;
......@@ -51,8 +49,10 @@
optionParser = null;
jsToSources = {};
exports.run = function() {
var literals, replCliOpts, source, _i, _len, _ref1, _results;
var i, len, literals, ref1, replCliOpts, results, source;
parseOptions();
replCliOpts = {
useGlobal: true
......@@ -88,19 +88,19 @@
opts.join = path.resolve(opts.join);
console.error('\nThe --join option is deprecated and will be removed in a future version.\n\nIf for some reason it\'s necessary to share local variables between files,\nreplace...\n\n $ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee\n\nwith...\n\n $ cat a.coffee b.coffee c.coffee | coffee --compile --stdio > bundle.js\n');
}
_ref1 = opts["arguments"];
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
source = _ref1[_i];
ref1 = opts["arguments"];
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
source = ref1[i];
source = path.resolve(source);
_results.push(compilePath(source, true, source));
results.push(compilePath(source, true, source));
}
return _results;
return results;
};
compilePath = function(source, topLevel, base) {
var code, err, file, files, stats, _i, _len, _results;
if (__indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
var code, err, file, files, i, len, results, stats;
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
return;
}
try {
......@@ -135,12 +135,12 @@
throw err;
}
}
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
_results.push(compilePath(path.join(source, file), false, base));
results = [];
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
results.push(compilePath(path.join(source, file), false, base));
}
return _results;
return results;
} else if (topLevel || helpers.isCoffee(source)) {
sources.push(source);
sourceCode.push(null);
......@@ -165,10 +165,10 @@
};
findDirectoryIndex = function(source) {
var err, ext, index, _i, _len, _ref1;
_ref1 = CoffeeScript.FILE_EXTENSIONS;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
ext = _ref1[_i];
var err, ext, i, index, len, ref1;
ref1 = CoffeeScript.FILE_EXTENSIONS;
for (i = 0, len = ref1.length; i < len; i++) {
ext = ref1[i];
index = path.join(source, "index" + ext);
try {
if ((fs.statSync(index)).isFile()) {
......@@ -281,7 +281,7 @@
if (err.code !== 'ENOENT') {
throw err;
}
if (__indexOf.call(sources, source) < 0) {
if (indexOf.call(sources, source) < 0) {
return;
}
try {
......@@ -348,7 +348,7 @@
}).on('change', function() {
clearTimeout(readdirTimeout);
return readdirTimeout = wait(25, function() {
var err, file, files, _i, _len, _results;
var err, file, files, i, len, results;
try {
files = fs.readdirSync(source);
} catch (_error) {
......@@ -358,12 +358,12 @@
}
return stopWatcher();
}
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
_results.push(compilePath(path.join(source, file), false, base));
results = [];
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
results.push(compilePath(path.join(source, file), false, base));
}
return _results;
return results;
});
});
};
......@@ -383,11 +383,11 @@
};
removeSourceDir = function(source, base) {
var file, sourcesChanged, _i, _len;
var file, i, len, sourcesChanged;
delete watchedDirs[source];
sourcesChanged = false;
for (_i = 0, _len = sources.length; _i < _len; _i++) {
file = sources[_i];
for (i = 0, len = sources.length; i < len; i++) {
file = sources[i];
if (!(source === path.dirname(file))) {
continue;
}
......@@ -412,12 +412,12 @@
};
silentUnlink = function(path) {
var err, _ref1;
var err, ref1;
try {
return fs.unlinkSync(path);
} catch (_error) {
err = _error;
if ((_ref1 = err.code) !== 'ENOENT' && _ref1 !== 'EPERM') {
if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') {
throw err;
}
}
......@@ -440,6 +440,27 @@
return path.join(dir, basename + extension);
};
mkdirp = function(dir, fn) {
var mkdirs, mode;
mode = 0x1ff & ~process.umask();
return (mkdirs = function(p, fn) {
return fs.exists(p, function(exists) {
if (exists) {
return fn();
} else {
return mkdirs(path.dirname(p), function() {
return fs.mkdir(p, mode, function(err) {
if (err) {
return fn(err);
}
return fn();
});
});
}
});
})(dir, fn);
};
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) {
var compile, jsDir, sourceMapPath;
if (generatedSourceMap == null) {
......@@ -447,13 +468,20 @@
}
sourceMapPath = outputPath(sourcePath, base, ".js.map");
jsDir = path.dirname(jsPath);
if (jsPath in jsToSources) {
printLine("Error: The two following source files have the same output file:");
printLine(" " + jsToSources[jsPath]);
printLine(" " + sourcePath);
process.exit(1);
}
jsToSources[jsPath] = sourcePath;
compile = function() {
if (opts.compile) {
if (js.length <= 0) {
js = ' ';
}
if (generatedSourceMap) {
js = "" + js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n";
js = js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n";
}
fs.writeFile(jsPath, js, function(err) {
if (err) {
......@@ -487,21 +515,21 @@
};
timeLog = function(message) {
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message);
return console.log(((new Date).toLocaleTimeString()) + " - " + message);
};
printTokens = function(tokens) {
var strings, tag, token, value;
strings = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
var i, len, results;
results = [];
for (i = 0, len = tokens.length; i < len; i++) {
token = tokens[i];
tag = token[0];
value = token[1].toString().replace(/\n/, '\\n');
_results.push("[" + tag + " " + value + "]");
results.push("[" + tag + " " + value + "]");
}
return _results;
return results;
})();
return printLine(strings.join(' '));
};
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
......@@ -63,16 +63,26 @@
AlphaNumeric: [
o('NUMBER', function() {
return new Literal($1);
}), o('STRING', function() {
}), o('String')
],
String: [
o('STRING', function() {
return new Literal($1);
}), o('STRING_START Body STRING_END', function() {
return new Parens($2);
})
],
Regex: [
o('REGEX', function() {
return new Literal($1);
}), o('REGEX_START Invocation REGEX_END', function() {
return $2;
})
],
Literal: [
o('AlphaNumeric'), o('JS', function() {
return new Literal($1);
}), o('REGEX', function() {
return new Literal($1);
}), o('DEBUGGER', function() {
}), o('Regex'), o('DEBUGGER', function() {
return new Literal($1);
}), o('UNDEFINED', function() {
return new Undefined;
......@@ -421,6 +431,11 @@
return {
source: LOC(2)(new Value($2))
};
}), o('FOR Range BY Expression', function() {
return {
source: LOC(2)(new Value($2)),
step: $4
};
}), o('ForStart ForSource', function() {
$2.own = $1.own;
$2.name = $1[0];
......@@ -552,6 +567,12 @@
return new Op('+', $2);
}), {
prec: 'UNARY_MATH'
}), o('YIELD Statement', function() {
return new Op($1, $2);
}), o('YIELD Expression', function() {
return new Op($1, $2);
}), o('YIELD FROM Expression', function() {
return new Op($1.concat($2), $3);
}), o('-- SimpleAssignable', function() {
return new Op('--', $2);
}), o('++ SimpleAssignable', function() {
......@@ -594,20 +615,20 @@
]
};
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']];
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', 'YIELD'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']];
tokens = [];
for (name in grammar) {
alternatives = grammar[name];
grammar[name] = (function() {
var _i, _j, _len, _len1, _ref, _results;
_results = [];
for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
alt = alternatives[_i];
_ref = alt[0].split(' ');
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
token = _ref[_j];
var i, j, len, len1, ref, results;
results = [];
for (i = 0, len = alternatives.length; i < len; i++) {
alt = alternatives[i];
ref = alt[0].split(' ');
for (j = 0, len1 = ref.length; j < len1; j++) {
token = ref[j];
if (!grammar[token]) {
tokens.push(token);
}
......@@ -615,9 +636,9 @@
if (name === 'Root') {
alt[1] = "return " + alt[1];
}
_results.push(alt);
results.push(alt);
}
return _results;
return results;
})();
}
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref;
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
exports.starts = function(string, literal, start) {
return literal === string.substr(start, literal.length);
......@@ -26,15 +26,15 @@
};
exports.compact = function(array) {
var item, _i, _len, _results;
_results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
item = array[_i];
var i, item, len1, results;
results = [];
for (i = 0, len1 = array.length; i < len1; i++) {
item = array[i];
if (item) {
_results.push(item);
results.push(item);
}
}
return _results;
return results;
};
exports.count = function(string, substr) {
......@@ -63,10 +63,10 @@
};
exports.flatten = flatten = function(array) {
var element, flattened, _i, _len;
var element, flattened, i, len1;
flattened = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
element = array[_i];
for (i = 0, len1 = array.length; i < len1; i++) {
element = array[i];
if (element instanceof Array) {
flattened = flattened.concat(flatten(element));
} else {
......@@ -83,14 +83,10 @@
return val;
};
exports.last = last = function(array, back) {
return array[array.length - (back || 0) - 1];
};
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
var e, _i, _len;
for (_i = 0, _len = this.length; _i < _len; _i++) {
e = this[_i];
exports.some = (ref = Array.prototype.some) != null ? ref : function(fn) {
var e, i, len1;
for (i = 0, len1 = this.length; i < len1; i++) {
e = this[i];
if (fn(e)) {
return true;
}
......@@ -102,20 +98,20 @@
var line, lines, maybe_code;
maybe_code = true;
lines = (function() {
var _i, _len, _ref1, _results;
_ref1 = code.split('\n');
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
line = _ref1[_i];
var i, len1, ref1, results;
ref1 = code.split('\n');
results = [];
for (i = 0, len1 = ref1.length; i < len1; i++) {
line = ref1[i];
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
_results.push(line);
results.push(line);
} else if (maybe_code = /^\s*$/.test(line)) {
_results.push(line);
results.push(line);
} else {
_results.push('# ' + line);
results.push('# ' + line);
}
}
return _results;
return results;
})();
return lines.join('\n');
};
......@@ -150,7 +146,7 @@
locationData = obj;
}
if (locationData) {
return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1));
return ((locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ((locationData.last_line + 1) + ":" + (locationData.last_column + 1));
} else {
return "No location data";
}
......@@ -205,11 +201,11 @@
};
syntaxErrorToString = function() {
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2;
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start;
if (!(this.code && this.location)) {
return Error.prototype.toString.call(this);
}
_ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column;
ref1 = this.location, first_line = ref1.first_line, first_column = ref1.first_column, last_line = ref1.last_line, last_column = ref1.last_column;
if (last_line == null) {
last_line = first_line;
}
......@@ -224,14 +220,14 @@
if (typeof process !== "undefined" && process !== null) {
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
}
if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) {
if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) {
colorize = function(str) {
return "\x1B[1;31m" + str + "\x1B[0m";
};
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
marker = colorize(marker);
}
return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
return filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
};
exports.nameWhitespaceCharacter = function(string) {
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var key, val, _ref;
var key, ref, val;
_ref = require('./coffee-script');
for (key in _ref) {
val = _ref[key];
ref = require('./coffee-script');
for (key in ref) {
val = ref[key];
exports[key] = val;
}
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
......@@ -11,14 +11,14 @@
}
OptionParser.prototype.parse = function(args) {
var arg, i, isOption, matchedRule, options, originalArgs, pos, rule, seenNonOptionArg, skippingArgument, value, _i, _j, _len, _len1, _ref;
var arg, i, isOption, j, k, len, len1, matchedRule, options, originalArgs, pos, ref, rule, seenNonOptionArg, skippingArgument, value;
options = {
"arguments": []
};
skippingArgument = false;
originalArgs = args;
args = normalizeArguments(args);
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
for (i = j = 0, len = args.length; j < len; i = ++j) {
arg = args[i];
if (skippingArgument) {
skippingArgument = false;
......@@ -33,9 +33,9 @@
seenNonOptionArg = options["arguments"].length > 0;
if (!seenNonOptionArg) {
matchedRule = false;
_ref = this.rules;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
rule = _ref[_j];
ref = this.rules;
for (k = 0, len1 = ref.length; k < len1; k++) {
rule = ref[k];
if (rule.shortFlag === arg || rule.longFlag === arg) {
value = true;
if (rule.hasArgument) {
......@@ -59,14 +59,14 @@
};
OptionParser.prototype.help = function() {
var letPart, lines, rule, spaces, _i, _len, _ref;
var j, len, letPart, lines, ref, rule, spaces;
lines = [];
if (this.banner) {
lines.unshift("" + this.banner + "\n");
lines.unshift(this.banner + "\n");
}
_ref = this.rules;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
rule = _ref[_i];
ref = this.rules;
for (j = 0, len = ref.length; j < len; j++) {
rule = ref[j];
spaces = 15 - rule.longFlag.length;
spaces = spaces > 0 ? repeat(' ', spaces) : '';
letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' ';
......@@ -88,16 +88,16 @@
OPTIONAL = /\[(\w+(\*?))\]/;
buildRules = function(rules) {
var tuple, _i, _len, _results;
_results = [];
for (_i = 0, _len = rules.length; _i < _len; _i++) {
tuple = rules[_i];
var j, len, results, tuple;
results = [];
for (j = 0, len = rules.length; j < len; j++) {
tuple = rules[j];
if (tuple.length < 3) {
tuple.unshift(null);
}
_results.push(buildRule.apply(null, tuple));
results.push(buildRule.apply(null, tuple));
}
return _results;
return results;
};
buildRule = function(shortFlag, longFlag, description, options) {
......@@ -118,15 +118,15 @@
};
normalizeArguments = function(args) {
var arg, l, match, result, _i, _j, _len, _len1, _ref;
var arg, j, k, l, len, len1, match, ref, result;
args = args.slice(0);
result = [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
for (j = 0, len = args.length; j < len; j++) {
arg = args[j];
if (match = arg.match(MULTI_FLAG)) {
_ref = match[1].split('');
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
l = _ref[_j];
ref = match[1].split('');
for (k = 0, len1 = ref.length; k < len1; k++) {
l = ref[k];
result.push('-' + l);
}
} else {
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref;
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
CoffeeScript = require('./coffee-script');
......@@ -17,9 +17,9 @@
};
if (require.extensions) {
_ref = CoffeeScript.FILE_EXTENSIONS;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ext = _ref[_i];
ref = CoffeeScript.FILE_EXTENSIONS;
for (i = 0, len = ref.length; i < len; i++) {
ext = ref[i];
require.extensions[ext] = loadFile;
}
Module = require('module');
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref;
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, updateSyntaxError, vm;
fs = require('fs');
......@@ -12,23 +12,36 @@
CoffeeScript = require('./coffee-script');
_ref = require('./helpers'), merge = _ref.merge, updateSyntaxError = _ref.updateSyntaxError;
ref = require('./helpers'), merge = ref.merge, updateSyntaxError = ref.updateSyntaxError;
replDefaults = {
prompt: 'coffee> ',
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
historyMaxInputSize: 10240,
"eval": function(input, context, filename, cb) {
var Assign, Block, Literal, Value, ast, err, js, result, _ref1;
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, result, token, tokens;
input = input.replace(/\uFF00/g, '\n');
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
_ref1 = require('./nodes'), Block = _ref1.Block, Assign = _ref1.Assign, Value = _ref1.Value, Literal = _ref1.Literal;
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
try {
ast = CoffeeScript.nodes(input);
tokens = CoffeeScript.tokens(input);
referencedVars = (function() {
var i, len, results;
results = [];
for (i = 0, len = tokens.length; i < len; i++) {
token = tokens[i];
if (token.variable) {
results.push(token[1]);
}
}
return results;
})();
ast = CoffeeScript.nodes(tokens);
ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]);
js = ast.compile({
bare: true,
locals: Object.keys(context)
locals: Object.keys(context),
referencedVars: referencedVars
});
result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename);
return cb(null, result);
......@@ -41,9 +54,9 @@
};
addMultilineHandler = function(repl) {
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, rli, _ref1;
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
origPrompt = (_ref1 = repl._prompt) != null ? _ref1 : repl.prompt;
origPrompt = (ref1 = repl._prompt) != null ? ref1 : repl.prompt;
multiline = {
enabled: false,
initialPrompt: origPrompt.replace(/^[^> ]*/, function(x) {
......@@ -58,7 +71,7 @@
rli.removeListener('line', nodeLineListener);
rli.on('line', function(cmd) {
if (multiline.enabled) {
multiline.buffer += "" + cmd + "\n";
multiline.buffer += cmd + "\n";
rli.setPrompt(multiline.prompt);
rli.prompt(true);
} else {
......@@ -118,7 +131,7 @@
fd = fs.openSync(filename, 'a');
repl.rli.addListener('line', function(code) {
if (code && code.length && code !== '.history' && lastLine !== code) {
fs.write(fd, "" + code + "\n");
fs.write(fd, code + "\n");
return lastLine = code;
}
});
......@@ -128,7 +141,7 @@
return repl.commands[getCommandId(repl, 'history')] = {
help: 'Show command history',
action: function() {
repl.outputStream.write("" + (repl.rli.history.slice(0).reverse().join('\n')) + "\n");
repl.outputStream.write((repl.rli.history.slice(0).reverse().join('\n')) + "\n");
return repl.displayPrompt();
}
};
......@@ -146,13 +159,13 @@
module.exports = {
start: function(opts) {
var build, major, minor, repl, _ref1;
var build, major, minor, ref1, repl;
if (opts == null) {
opts = {};
}
_ref1 = process.versions.node.split('.').map(function(n) {
ref1 = process.versions.node.split('.').map(function(n) {
return parseInt(n);
}), major = _ref1[0], minor = _ref1[1], build = _ref1[2];
}), major = ref1[0], minor = ref1[1], build = ref1[2];
if (major === 0 && minor < 8) {
console.warn("Node 0.8.0+ required for CoffeeScript REPL");
process.exit(1);
......
// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.1
(function() {
var LineMap, SourceMap;
LineMap = (function() {
function LineMap(line) {
this.line = line;
function LineMap(line1) {
this.line = line1;
this.columns = [];
}
LineMap.prototype.add = function(column, _arg, options) {
LineMap.prototype.add = function(column, arg, options) {
var sourceColumn, sourceLine;
sourceLine = _arg[0], sourceColumn = _arg[1];
sourceLine = arg[0], sourceColumn = arg[1];
if (options == null) {
options = {};
}
......@@ -45,18 +45,18 @@
}
SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) {
var column, line, lineMap, _base;
var base, column, line, lineMap;
if (options == null) {
options = {};
}
line = generatedLocation[0], column = generatedLocation[1];
lineMap = ((_base = this.lines)[line] || (_base[line] = new LineMap(line)));
lineMap = ((base = this.lines)[line] || (base[line] = new LineMap(line)));
return lineMap.add(column, sourceLocation, options);
};
SourceMap.prototype.sourceLocation = function(_arg) {
SourceMap.prototype.sourceLocation = function(arg) {
var column, line, lineMap;
line = _arg[0], column = _arg[1];
line = arg[0], column = arg[1];
while (!((lineMap = this.lines[line]) || (line <= 0))) {
line--;
}
......@@ -64,7 +64,7 @@
};
SourceMap.prototype.generate = function(options, code) {
var buffer, lastColumn, lastSourceColumn, lastSourceLine, lineMap, lineNumber, mapping, needComma, v3, writingline, _i, _j, _len, _len1, _ref, _ref1;
var buffer, i, j, lastColumn, lastSourceColumn, lastSourceLine, len, len1, lineMap, lineNumber, mapping, needComma, ref, ref1, v3, writingline;
if (options == null) {
options = {};
}
......@@ -77,13 +77,13 @@
lastSourceColumn = 0;
needComma = false;
buffer = "";
_ref = this.lines;
for (lineNumber = _i = 0, _len = _ref.length; _i < _len; lineNumber = ++_i) {
lineMap = _ref[lineNumber];
ref = this.lines;
for (lineNumber = i = 0, len = ref.length; i < len; lineNumber = ++i) {
lineMap = ref[lineNumber];
if (lineMap) {
_ref1 = lineMap.columns;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
mapping = _ref1[_j];
ref1 = lineMap.columns;
for (j = 0, len1 = ref1.length; j < len1; j++) {
mapping = ref1[j];
if (!(mapping)) {
continue;
}
......
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Copyright 2010 James Halliday (mail@substack.net)
This project is free software released under the MIT/X11 license:
The MIT License (MIT)
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment