Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgraded yogi serve command

  • Loading branch information...
commit f3b827bebe123a186e73df3599efa556acf03af0 1 parent c0f99ea
@davglass davglass authored
View
113 lib/cmds/serve.js
@@ -21,6 +21,7 @@ var util = require('../util'),
osenv = require('osenv'),
istanbulBase = path.join(osenv.tmpdir(), 'yogi-istanbul'),
portfinder = require('portfinder'),
+ ansispan = require('ansispan'),
mods;
config.register('yui', '<path> set the path to your local yui3 source tree');
@@ -143,6 +144,109 @@ mods = {
});
}
},
+ grover: function() {
+ var self = this;
+
+ this.app.get('/grover', function(req, res) {
+ res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
+ var html = fs.readFileSync(path.join(__dirname, '../../web/shifter.html'), 'utf8');
+
+ res.write(html);
+
+ var cmd = process.argv[0],
+ args = [
+ process.argv[1],
+ 'test'
+ ], sh,
+ cwd = path.join(self.module.dir, self.module.name),
+ handler = function(d) {
+ var line = d.toString().replace(/\n/g, '<br>\n')
+ res.write(ansispan(line));
+ res.write('<script>window.scrollTo(0, 99999999999999);</script>');
+ };
+
+ if (util.isYUI()) {
+ if (self.module.name === 'yui3') {
+ cwd = path.join(self.module.dir, 'src');
+ }
+ }
+
+ Object.keys(req.query).forEach(function(key) {
+ if (req.query[key] === '') {
+ args.push('--' + key);
+ } else {
+ args.push('--' + key + '=' + req.query[key]);
+ }
+ });
+
+ res.write('cd ' + cwd + '<br>');
+ res.write('$ ' + args.join(' ') + '<br>');
+
+ sh = spawn(cmd, args, {
+ cwd: cwd
+ });
+
+ sh.stdout.on('data', handler);
+ sh.stderr.on('data', handler);
+
+ sh.on('exit', function(code) {
+ res.write('yogi exited, code: ' + code);
+ res.end();
+ });
+ });
+ },
+ shifter: function() {
+ var self = this;
+
+ this.app.get('/shifter', function(req, res) {
+ res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
+ var html = fs.readFileSync(path.join(__dirname, '../../web/shifter.html'), 'utf8');
+
+ res.write(html);
+
+ res.write('<p>You can add parameters to the query string to use shifter options: /shifter?istanbul&quiet&foo=bar</p>');
+
+ var shifter = path.join(self.root, 'shifter'),
+ args = [], sh,
+ cwd = path.join(self.module.dir, self.module.name),
+ handler = function(d) {
+ var line = d.toString().replace(/\n/g, '<br>\n')
+ res.write(ansispan(line));
+ res.write('<script>window.scrollTo(0, 99999999999999);</script>');
+ };
+
+ if (util.isYUI()) {
+ if (self.module.name === 'yui3') {
+ cwd = path.join(self.module.dir, 'src');
+ args.push('--walk');
+ args.push('--cache');
+ }
+ }
+
+ Object.keys(req.query).forEach(function(key) {
+ if (req.query[key] === '') {
+ args.push('--' + key);
+ } else {
+ args.push('--' + key + '=' + req.query[key]);
+ }
+ });
+
+ res.write('cd ' + cwd + '<br>');
+ res.write('$ shifter ' + args.join(' ') + '<br>');
+
+ sh = spawn(shifter, args, {
+ cwd: cwd
+ });
+
+ sh.stdout.on('data', handler);
+ sh.stderr.on('data', handler);
+
+ sh.on('exit', function(code) {
+ res.write('shifter exited, code: ' + code);
+ res.end();
+ });
+ });
+ },
selleck: function(callback) {
var self = this;
portfinder.getPort(function (err, port) {
@@ -475,9 +579,10 @@ mods = {
process.exit(1);
});
this.app.listen(port);
- index = index.replace(/\{\{module\}\}/gi, this.module.name);
this.app.get('/', function(req, res) {
+ index = fs.readFileSync(path.join(__dirname, '../../web/index.html'), 'utf8'),
+ index = index.replace(/\{\{module\}\}/gi, self.module.name);
res.header('Yogi-Served', 'Yes');
fs.readdir(testDir, function(err, files) {
var base = path.join(git.findRoot(), '../src'),
@@ -587,6 +692,8 @@ mods = {
if (!this.options.grover) {
this.yuidoc(stack.add(noop));
this.selleck(stack.add(noop));
+ this.shifter(stack.add(noop));
+ this.grover(stack.add(noop));
}
this.tests(stack.add(noop));
stack.done(function() {
@@ -622,6 +729,10 @@ mods = {
this.watch();
},
watch: function() {
+ if (!this.options.parsed.watch) {
+ return;
+ }
+
log.info('shifter watching for changes');
var shifter = path.join(this.root, 'shifter'),
args = [
View
3  package.json
@@ -33,7 +33,8 @@
"wiky.js": "https://github.com/davglass/wiky.js/tarball/master",
"timethat": "*",
"git-travis": "~0.1.2",
- "win-spawn": "*"
+ "win-spawn": "*",
+ "ansispan": "https://github.com/davglass/ansispan/tarball/fixclosing"
},
"scripts": {
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/*.js ./lib/*/*.js",
View
74 web/assets/yogi.css
@@ -3,7 +3,17 @@ body {
padding: 0;
margin: 0;
}
-h1 {
+
+#header img {
+ float: right;
+ margin: 1em;
+}
+
+h2 {
+ color: #EB8C28;
+}
+
+#header {
background: whiteSmoke;
background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
@@ -12,8 +22,70 @@ h1 {
color: black;
margin: 0;
padding: 1em;
+ text-shadow: 4px 4px 4px #aaa;
}
div.main {
padding: 1em;
}
+
+li {
+ color: #E2E2EB;
+ list-style-type: disc;
+}
+
+a:visited {
+ color: #6D93E4;
+}
+a:hover {
+ text-decoration: underline;
+}
+a {
+ color: #356DE4;
+ text-decoration: none;
+}
+
+#status {
+ padding: .5em;
+ border-bottom: 1px solid #DFDFDF;
+ background-color: #DFDFDF;
+ font-size: 85%;
+}
+
+#status .version {
+ text-align: right;
+}
+
+#status .cdn {
+ text-align: center;
+}
+
+.tabs {
+ background: whiteSmoke;
+ background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
+ background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dcdbd9',endColorstr='#F6F5F3',GradientType=0);
+ border-bottom: 1px solid #DFDFDF;
+ color: black;
+ margin: 0;
+ padding: 1em;
+ text-shadow: 4px 4px 4px #aaa;
+
+}
+
+.tabs ul {
+ margin: 0;
+ padding: 0;
+}
+.tabs ul li {
+ list-style-type: none;
+}
+.tabs ul li a {
+}
+
+body.shifter {
+ background-color: #111111;
+ color: green;
+ font-size: 100%;
+ margin: 1em;
+}
View
48 web/assets/yogi.js
@@ -0,0 +1,48 @@
+YUI().use('jsonp', 'node', function(Y) {
+ var status = Y.one('#status .version'),
+ gstatus = Y.one('#status .gallery'),
+ cstatus = Y.one('#status .cdn');
+
+ Y.jsonp('http://yuilibrary.com/api/v1/version?callback={callback}', function(o) {
+ if (o && o.version) {
+ status.setHTML('Current YUI Version: ' + o.version);
+ }
+ });
+
+ Y.jsonp('http://yuilibrary.com/api/v1/cdn/buildtag?callback={callback}', function(o) {
+ if (o && o.buildtag) {
+ gstatus.setHTML('Current Gallery Version: ' + o.buildtag);
+ }
+ });
+
+ Y.jsonp('http://yuilibrary.com/api/v1/cdn/window?callback={callback}', function(o) {
+ if (o) {
+ var stamp = new Date(o.stamp);
+ stamp.setHours(stamp.getHours() + getDSTOffset());
+ var html = 'next cdn deployment window is ' + stamp.toLocaleString();
+ cstatus.setHTML(html);
+ }
+ });
+
+
+
+ var getDSTOffset = function() {
+ var start = new Date(),
+ year = start.getFullYear(),
+ jan = new Date(year, 0); // January 1
+ jul = new Date(year, 6); // July 1
+
+ // northern hemisphere test
+ if (jan.getTimezoneOffset() > jul.getTimezoneOffset() && start.getTimezoneOffset() !== jan.getTimezoneOffset()) {
+ return -1;
+ }
+ // southern hemisphere test
+ if (jan.getTimezoneOffset() < jul.getTimezoneOffset() && start.getTimezoneOffset() !== jul.getTimezoneOffset()) {
+ return -1;
+ }
+ // if we reach this point, DST is not in effect on the client computer.
+ return 0;
+ };
+
+
+});
View
65 web/index.html
@@ -3,26 +3,59 @@
<head>
<title>yogi server</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
+ <link rel="stylesheet" href="/build/cssgrids/cssgrids-min.css">
<link href="/yogi/assets/yogi.css" rel="stylesheet">
+ <script src="/build/yui/yui-min.js"></script>
</head>
<body>
-<h1>yogi is here to help with {{module}}</h1>
-
-<div class="main">
- <h2>Docs and Stuff</h2>
- <ul>
- <li><a href="/docs/{{module}}/">Examples and Landing Page</a></li>
- <li><a href="/api/modules/{{module}}.html">API Documentation</a></li>
- </ul>
- <h2>Unit Tests</h2>
- <ul>
- {{tests}}
- </ul>
+<div id="header" class="main yui3-g">
+ <div class="yui3-u-3-4">
+ <h1>yogi is here to help with {{module}}</h1>
+ </div>
+ <div class="yui3-u-1-4">
+ <img src="http://yuilibrary.com/img/yui-logo.png">
+ </div>
+</div>
+<div id="status" class="yui3-g">
+ <div class="yui3-u-1-3 gallery">
+ fetching gallery stamp
+ </div>
+ <div class="yui3-u-1-3 cdn">
+ fetching cdn window
+ </div>
+ <div class="yui3-u-1-3 version">
+ fetching yui version
+ </div>
+</div>
- <h2>Unit Tests + coverage</h2>
- <ul>
- {{covertests}}
- </ul>
+<div class="main yui3-g">
+ <div class="yui3-u-1-4">
+ <h2>Docs and Stuff</h2>
+ <ul>
+ <li><a href="/docs/{{module}}/">Examples and Landing Page</a></li>
+ <li><a href="/api/modules/{{module}}.html">API Documentation</a></li>
+ </ul>
+ </div>
+ <div class="yui3-u-1-4">
+ <h2>Unit Tests</h2>
+ <ul>
+ {{tests}}
+ </ul>
+ </div>
+ <div class="yui3-u-1-4">
+ <h2>Unit Tests + coverage</h2>
+ <ul>
+ {{covertests}}
+ </ul>
+ </div>
+ <div class="yui3-u-1-4">
+ <h2>Tools</h2>
+ <ul>
+ <li><a href="/shifter">run shifter</a></li>
+ <li><a href="/grover">run grover</a></li>
+ </ul>
+ </div>
</div>
+<script src="/yogi/assets/yogi.js"></script>
</body>
</html>
View
8 web/shifter.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<head>
+ <title>shifter</title>
+ <link href="/yogi/assets/yogi.css" rel="stylesheet">
+</head>
+<body class="shifter">
+<p><a href="/">[Back to yogi]</a></p>
Please sign in to comment.
Something went wrong with that request. Please try again.