Permalink
Browse files

Fixes #192

  • Loading branch information...
1 parent 4377003 commit 8530cb8316edf164a697739072b9afe23bf72cfd @ebidel ebidel committed Aug 10, 2012
Showing with 59 additions and 55 deletions.
  1. +3 −2 cli/bin/yeoman
  2. +4 −5 {metrics → cli/bin}/yeomaninsight.py
  3. +41 −39 cli/lib/plugins/insight.js
  4. +2 −1 cli/package.json
  5. +9 −8 setup/install.sh
View
@@ -76,7 +76,9 @@ async.series([function(cb) {
// Are we dealing with yeoman in a test environment? If so, skip the
// insight prompt. This is specifically put into the environment by
// our test spawn helper.
- if(process.env.yeoman_test) return cb();
+ if(process.env.yeoman_test) {
+ return cb();
+ }
insight.init({
pkgname : pkg.name,
@@ -85,7 +87,6 @@ async.series([function(cb) {
cb : cb
});
-
}, function(cb) {
// if the route is empty
@@ -13,14 +13,13 @@
import urllib
import urllib2
-#import settings
-
NO_STATS = 'NO_STATS'
-CLI_NAME = 'yeoman' #settings.APP['cli_name']
+CLI_NAME = 'yeoman'
# TODO(ericbidelman): Verify expanduser('~') works on other platforms.
-INSIGHT_DIR = os.path.join(os.path.expanduser('~'), '.yeoman', 'insight')
-LOG_FILE = os.path.join(INSIGHT_DIR, '.log') #os.path.join(os.path.dirname(__file__), '.log')
+# ~/.yeoman/insight
+INSIGHT_DIR = os.path.join(os.path.expanduser('~'), '.' + CLI_NAME, 'insight')
+LOG_FILE = os.path.join(INSIGHT_DIR, '.log') # ~/.yeoman/insight/.log
NUM_SUB_CMDS = 2 # Subcommand depth. TODO: This assumes only "cmd subcmd" format.
NUM_SECONDS_TO_STASH_DATA = 0 # Send data as it happens.
View
@@ -4,29 +4,31 @@ var fs = require('fs'),
colors = require('colors'),
prompt = require('prompt');
-
module.exports = {
- init : function(opts){
+ init: function(opts) {
+
+ // Store global state used throughout the project in the user's home dir.
+ // e.g. /Users/username/.yeoman
+ var YEOMAN_DIR = join(opts.getUserHome(), '.' + opts.pkgname);
- // Store global state used throughout the project in the user's home dir.
- // e.g. /Users/username/.yeoman
- var YEOMAN_DIR = join(opts.getUserHome(), '.' + opts.pkgname);
+ // This should correspond to whatever name is used in package.json.
+ var INSIGHT_SCRIPT = '_' + opts.pkgname + 'insight'
- var insightFolder = join(YEOMAN_DIR, 'insight');
+ var insightFolder = join(YEOMAN_DIR, 'insight');
- // Assume yeomaninsight.py is installed in the user's home dir.
- var insightRecordCmd = [join(insightFolder, 'yeomaninsight.py'), 'record'];
+ // Assume yeomaninsight.py is installed globally (/usr/local/bin/)
+ var insightRecordCmd = ['record'];
- // Record this action in Insight (e.g. python yeomaninsight.py record cmd cmd2).
- spawn('python', insightRecordCmd.concat(opts.cmds));
- //insight.stdout.pipe(process.stdout);
+ // Record this action in Insight (e.g. python yeomaninsight.py record cmd cmd2).
+ spawn(INSIGHT_SCRIPT, insightRecordCmd.concat(opts.cmds));
+ //insight.stdout.pipe(process.stdout);
- fs.stat(join(insightFolder, '.log'), function(err, stats) {
- // Error means file doesn't exist and this is the first run.
- // Go through stat opt-in flow.
- if ( !err ) {
- return opts.cb();
- }
+ fs.stat(join(insightFolder, '.log'), function(err, stats) {
+ // Error means file doesn't exist and this is the first run.
+ // Go through stat opt-in flow.
+ if ( !err ) {
+ return opts.cb();
+ }
/*jshint multistr:true */
var msg = "\
@@ -36,31 +38,31 @@ May we anonymously report usage statistics to improve the tool over time? \n\
More info: http://goo.gl/GPtU9 & http://yeoman.io".yellow + "\n\
==========================================================================".grey;
- prompt.message = '[' + '?'.green + ']';
- prompt.delimiter = ' ';
+ prompt.message = '[' + '?'.green + ']';
+ prompt.delimiter = ' ';
- var properties = [{
- name: 'optin',
- message: '[Y/n]: ',
- "default": 'Y',
- validator: /^[yntf]{1}/i,
- empty: false
- }];
+ var properties = [{
+ name: 'optin',
+ message: '[Y/n]: ',
+ "default": 'Y',
+ validator: /^[yntf]{1}/i,
+ empty: false
+ }];
- prompt.start();
- console.log(msg);
- prompt.get(properties, function(err, result) {
- if (err) {
- return opts.cb(err);
- }
+ prompt.start();
+ console.log(msg);
+ prompt.get(properties, function(err, result) {
+ if (err) {
+ return opts.cb(err);
+ }
- if (/n/i.test(result.optin)) {
- spawn('python', insightRecordCmd.concat(['NO_STATS']));
- }
- opts.cb();
- });
+ if (/n/i.test(result.optin)) {
+ spawn(INSIGHT_SCRIPT, insightRecordCmd.concat(['NO_STATS']));
+ }
+ opts.cb();
+ });
- });
- }
+ });
+ }
};
View
@@ -6,7 +6,8 @@
"homepage": "http://yeoman.io",
"main": "./yeoman",
"bin": {
- "yeoman": "./bin/yeoman"
+ "yeoman": "./bin/yeoman",
+ "_yeomaninsight": "./bin/yeomaninsight.py"
},
"directories": {
"man": "./man"
View
@@ -192,16 +192,17 @@ echo "Okay here we go..."
sudo npm install . -g
echo ""
-echo "Yah Hoo! Yeoman global is in place, now for some housekeeping.."
-
-# let's ask the user if she is okay with reporting anonymous stats so we can build a better tool
+echo "Yah Hoo! Yeoman global is in place."
echo ""
-cd ../metrics
-# TODO: creating a path like this probably doesn't work on Windows.
-python setup.py install --quiet --force --user --install-scripts=~/.yeoman/insight
-echo "Alright now, that bit is done now, too."
-echo ""
+# # let's ask the user if she is okay with reporting anonymous stats so we can build a better tool
+# echo ""
+# cd ../metrics
+# # TODO: creating a path like this probably doesn't work on Windows.
+# python setup.py install --quiet --force --user --install-scripts=~/.yeoman/insight
+
+# echo "Alright now, that bit is done now, too."
+# echo ""
# hop back to start and kill our temp folder off
cd "$BACK" && rm -rf "$TMP"

0 comments on commit 8530cb8

Please sign in to comment.