Skip to content

Commit

Permalink
Remove insight module for now (#771)
Browse files Browse the repository at this point in the history
This is a quick solution to fix #753
  • Loading branch information
mischah committed Nov 7, 2022
1 parent 1fe6ad1 commit 1163e5d
Show file tree
Hide file tree
Showing 23 changed files with 188 additions and 812 deletions.
37 changes: 3 additions & 34 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const Insight = require('insight');
const yosay = require('yosay');
const stringLength = require('string-length');
const rootCheck = require('root-check');
Expand Down Expand Up @@ -51,11 +50,6 @@ const cli = gens.map(gen => {
const firstCmd = cli[0] || {opts: {}, args: {}};
const cmd = firstCmd.args[0];

const insight = new Insight({
trackingCode: 'UA-31537568-1',
pkg
});

function updateCheck() {
const notifier = updateNotifier({pkg});
const message = [];
Expand Down Expand Up @@ -173,8 +167,7 @@ function init() {
}

function runYo(env) {
const router = new Router(env, insight);
router.insight.track('yoyo', 'init');
const router = new Router(env);
router.registerRoute('help', require('./routes/help'));
router.registerRoute('update', require('./routes/update'));
router.registerRoute('run', require('./routes/run'));
Expand All @@ -191,30 +184,6 @@ function runYo(env) {

rootCheck('\n' + chalk.red('Easy with the `sudo`. Yeoman is the master around here.') + '\n\nSince yo is a user command, there is no need to execute it with root\npermissions. If you\'re having permission errors when using yo without sudo,\nplease spend a few minutes learning more about how your system should work\nand make any necessary repairs.\n\nA quick solution would be to change where npm stores global packages by\nputting ~/npm/bin in your PATH and running:\n' + chalk.blue('npm config set prefix ~/npm') + '\n\nSee: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md');

const insightMessage = chalk.gray('==========================================================================') +
chalk.yellow('\nWe\'re constantly looking for ways to make ') + chalk.bold.red(pkg.name) +
chalk.yellow(
' better! \nMay we anonymously report usage statistics to improve the tool over time? \n' +
'More info: https://github.com/yeoman/insight & http://yeoman.io'
) +
chalk.gray('\n==========================================================================');

if (firstCmd.opts.insight === false) {
insight.config.set('optOut', true);
} else if (firstCmd.opts.insight) {
insight.config.set('optOut', false);
}
updateCheck();

if (firstCmd.opts.insight !== false && insight.optOut === undefined) {
insight.optOut = insight.config.get('optOut');
insight.track('downloaded');
insight.askPermission(insightMessage, pre);
} else {
if (firstCmd.opts.insight !== false) {
// Only track the two first subcommands
insight.track(...firstCmd.args.slice(0, 2));
}

updateCheck();
pre();
}
pre();
4 changes: 1 addition & 3 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ const {namespaceToName} = require('yeoman-environment');
* The router is in charge of handling `yo` different screens.
* @constructor
* @param {Environment} env A yeoman environment instance
* @param {Insight} insight An insight instance
* @param {Configstore} [conf] An optional config store instance
*/
class Router {
constructor(env, insight, conf) {
constructor(env, conf) {
const pkg = require('../package.json');
this.routes = {};
this.env = env;
this.insight = insight;
this.conf = conf || new Configstore(pkg.name, {
generatorRunCount: {}
});
Expand Down
4 changes: 0 additions & 4 deletions lib/routes/clear-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const {namespaceToName} = require('yeoman-environment');
const globalConfig = require('../utils/global-config');

module.exports = async app => {
app.insight.track('yoyo', 'clearGlobalConfig');

const defaultChoices = [
{
name: 'Take me back home, Yo!',
Expand Down Expand Up @@ -55,8 +53,6 @@ module.exports = async app => {
defaultChoices
])
}]).then(answer => {
app.insight.track('yoyo', 'clearGlobalConfig', answer);

if (answer.whatNext === 'home') {
return app.navigate('home');
}
Expand Down
4 changes: 1 addition & 3 deletions lib/routes/exit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';
const yosay = require('yosay');

module.exports = async app => {
app.insight.track('yoyo', 'exit');

module.exports = async () => {
const PADDING = 5;
const url = 'http://yeoman.io';
const maxLength = url.length + PADDING;
Expand Down
4 changes: 0 additions & 4 deletions lib/routes/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const inquirer = require('inquirer');
const open = require('open');

module.exports = async app => {
app.insight.track('yoyo', 'help');

return inquirer.prompt([{
name: 'whereTo',
type: 'list',
Expand All @@ -23,8 +21,6 @@ module.exports = async app => {
value: 'home'
}]
}]).then(async answer => {
app.insight.track('yoyo', 'help', answer);

if (answer.whereTo === 'home') {
console.log('I get it, you like learning on your own. I respect that.');
return app.navigate('home');
Expand Down
2 changes: 0 additions & 2 deletions lib/routes/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ module.exports = async app => {
});
}

app.insight.track('yoyo', 'home');

return fullname().then(name => {
const allo = (name && isString(name)) ? `'Allo ${name.split(' ')[0]}! ` : '\'Allo! ';

Expand Down
7 changes: 0 additions & 7 deletions lib/routes/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const OFFICIAL_GENERATORS = new Set([
]);

module.exports = app => {
app.insight.track('yoyo', 'install');

return inquirer.prompt([{
name: 'searchTerm',
message: 'Search npm for generators:'
Expand Down Expand Up @@ -131,16 +129,11 @@ function promptInstallOptions(app, choices) {
}

function installGenerator(app, pkgName) {
app.insight.track('yoyo', 'install', pkgName);

return spawn('npm', ['install', '--global', pkgName], {stdio: 'inherit'})
.on('error', error => {
app.insight.track('yoyo:err', 'install', pkgName);
throw error;
})
.on('close', () => {
app.insight.track('yoyo', 'installed', pkgName);

console.log(
'\nI just installed a generator by running:\n' +
chalk.blue.bold('\n npm install -g ' + pkgName + '\n')
Expand Down
1 change: 0 additions & 1 deletion lib/routes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {namespaceToName} = require('yeoman-environment');

module.exports = async (app, name) => {
const baseName = namespaceToName(name);
app.insight.track('yoyo', 'run', baseName);

console.log(
chalk.yellow('\nMake sure you are in the directory you want to scaffold into.') +
Expand Down
3 changes: 0 additions & 3 deletions lib/routes/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const successMessage = 'I\'ve just updated your generators. Remember, you can up
chalk.magenta('\n npm install -g generator-_______');

function updateSuccess(app) {
app.insight.track('yoyo', 'updated');
console.log(`\n${chalk.cyan(successMessage)}\n`);
app.env.lookup();
app.updateAvailableGenerators();
Expand All @@ -20,8 +19,6 @@ function updateGenerators(app, pkgs) {
}

module.exports = app => {
app.insight.track('yoyo', 'update');

return inquirer.prompt([{
name: 'generators',
message: 'Generators to update',
Expand Down
1 change: 0 additions & 1 deletion lib/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ General options:
-f, --force # Overwrite files that already exist
--version # Print version
--no-color # Disable colors
--[no-]insight # Toggle anonymous tracking
--generators # Print available generators
--local-only # Disable lookup of globally-installed generators

Expand Down
Loading

0 comments on commit 1163e5d

Please sign in to comment.