Repository: ember-cli/ember-cli
Pull request #6459 (2016-11-23 21:34:50)

Update uuid to version 3.0.0
## Version 3.0.0 of [uuid](https://github.com/kelektiv/node-uuid) just got published.

Hi there,

This week a new version of the [uuid](https://github.com/kelektiv/node-uuid) module got released. The old module which was available by the name [node-uuid](https://www.npmjs.com/package/node-uuid) got deprecated and will show error message upon every install of the module.

To get rid of those install errors I've created this **automated pull request**. I've run some checks against your code base to test whether you're using one of the [deprecated apis](https://github.com/kelektiv/node-uuid/commit/5ae7287fc935eb55ef39133e4be17ef623ca000e), but this isn't the case.


Please test the changes against your code. I didn't run any tests and therefore can't guarantee that it isn't breaking. You can also just close this pr if you don't want to update your module.

In case there's already another pr open to upgrade uuid, I'm sorry for the effort I'm causing.


Patch:
diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index 624d7df47..31f58671d 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -715,7 +715,7 @@ EmberApp.prototype._templatesTree = function() {
     trees.push(this.podTemplates());
   }
 
-  this._cachedTemplateTree = mergeTrees(trees, {
+  this._cachedTemplateTree = mergeTrees(trees.filter(Boolean), {
     annotation: 'TreeMerge (templates)'
   });
 
diff --git a/lib/broccoli/merge-trees.js b/lib/broccoli/merge-trees.js
index 559ef6846..e56ab17f8 100644
--- a/lib/broccoli/merge-trees.js
+++ b/lib/broccoli/merge-trees.js
@@ -1,42 +1,13 @@
 'use strict';
 
 var upstreamMergeTrees = require('broccoli-merge-trees');
-var EMPTY_MERGE_TREE;
 
-function overrideEmptyTree(tree) {
-  EMPTY_MERGE_TREE = tree;
-}
+module.exports = function(inputTree, options) {
+  options = options || {};
+  options.description = options.annotation;
+  var tree = upstreamMergeTrees(inputTree, options);
 
-function getEmptyTree() {
-  if (EMPTY_MERGE_TREE) {
-    return EMPTY_MERGE_TREE;
-  }
+  tree.description = options && options.description;
 
-  return EMPTY_MERGE_TREE = upstreamMergeTrees([], {
-    annotation: 'EMPTY_MERGE_TREE',
-    description: 'EMPTY_MERGE_TREE'
-  });
-}
-
-module.exports = function mergeTrees(_inputTrees, options) {
-  var inputTrees = _inputTrees.filter(function(input) {
-    return input && input !== getEmptyTree();
-  });
-
-  switch (inputTrees.length) {
-  case 0:
-    return getEmptyTree();
-  case 1:
-    return inputTrees[0];
-  default:
-    options = options || {};
-    options.description = options.annotation;
-    var tree = upstreamMergeTrees(inputTrees, options);
-
-    tree.description = options && options.description;
-
-    return tree;
-  }
+  return tree;
 };
-
-module.exports._overrideEmptyTree = overrideEmptyTree;
diff --git a/lib/cli/index.js b/lib/cli/index.js
index 5ec9f8411..ff92bc981 100644
--- a/lib/cli/index.js
+++ b/lib/cli/index.js
@@ -42,7 +42,7 @@ function clientId() {
   if (id) {
     return id;
   } else {
-    id = require('node-uuid').v4().toString();
+    id = require('uuid').v4().toString();
     configStore.set('client-id', id);
     return id;
   }
diff --git a/lib/models/addon.js b/lib/models/addon.js
index ea11d9dd4..2f79cfd5a 100644
--- a/lib/models/addon.js
+++ b/lib/models/addon.js
@@ -22,10 +22,20 @@ var AddonsFactory   = require('../models/addons-factory');
 var CoreObject = require('core-object');
 var Project = require('./project');
 
-var mergeTrees = require('../broccoli/merge-trees');
+var upstreamMergeTrees = require('broccoli-merge-trees');
 var Funnel     = require('broccoli-funnel');
 var walkSync   = require('walk-sync');
 
+function mergeTrees(inputTree, options) {
+  options = options || {};
+  options.description = options.annotation;
+  var tree = upstreamMergeTrees(inputTree, options);
+
+  tree.description = options && options.description;
+
+  return tree;
+}
+
 function warn(message) {
   if (this.ui) {
     this.ui.writeDeprecateLine(message);
@@ -337,7 +347,7 @@ var Addon = CoreObject.extend({
       trees.push(this.jshintAddonTree());
     }
 
-    return mergeTrees(trees, {
+    return mergeTrees(trees.filter(Boolean), {
       overwrite: true,
       annotation: 'Addon#treeFor (' + this.name + ' - ' + name + ')'
     });
@@ -505,7 +515,7 @@ var Addon = CoreObject.extend({
     var addonTree = this.compileAddon(tree);
     var stylesTree = this.compileStyles(this._treeFor('addon-styles'));
 
-    return mergeTrees([addonTree, stylesTree], {
+    return mergeTrees([addonTree, stylesTree].filter(Boolean), {
       annotation: 'Addon#treeForAddon(' + this.name + ')'
     });
   },
diff --git a/lib/models/builder.js b/lib/models/builder.js
index 8b4357b99..038a86172 100644
--- a/lib/models/builder.js
+++ b/lib/models/builder.js
@@ -12,26 +12,15 @@ var chalk       = require('chalk');
 var attemptNeverIndex = require('../utilities/attempt-never-index');
 var findBuildFile = require('../utilities/find-build-file');
 
+var FSMonitor = require('heimdalljs-fs-monitor');
+var monitor = new FSMonitor();
+monitor.start();
+
 var Sync = require('tree-sync');
 
 var signalsTrapped = false;
 var buildCount = 0;
 
-function _enableFSMonitorIfVizEnabled() {
-  var FSMonitor = require('heimdalljs-fs-monitor');
-  var monitor = new FSMonitor();
-  if (vizEnabled()) {
-    monitor.start();
-  }
-  return monitor;
-}
-
-_enableFSMonitorIfVizEnabled();
-
-function vizEnabled() {
-  return !!process.env.BROCCOLI_VIZ;
-}
-
 function outputViz(count, result) {
   var nodes = result.graph.__heimdall__.toJSONSubgraph();
 
@@ -227,7 +216,7 @@ module.exports = Task.extend({
       })
       .then(function(result) {
 
-        if (vizEnabled()) {
+        if (process.env.BROCCOLI_VIZ) {
           outputViz(buildCount++, result);
         }
         return result;
@@ -318,5 +307,3 @@ module.exports = Task.extend({
     }
   }
 });
-
-module.exports._enableFSMonitorIfVizEnabled = _enableFSMonitorIfVizEnabled;
diff --git a/package.json b/package.json
index 49dfbe38b..527a63d89 100644
--- a/package.json
+++ b/package.json
@@ -94,7 +94,6 @@
     "minimatch": "^3.0.0",
     "morgan": "^1.5.2",
     "node-modules-path": "^1.0.0",
-    "node-uuid": "^1.4.3",
     "nopt": "^3.0.1",
     "npm": "3.10.8",
     "npm-package-arg": "^4.1.1",
@@ -114,6 +113,7 @@
     "through": "^2.3.6",
     "tiny-lr": "^1.0.3",
     "tree-sync": "^1.1.4",
+    "uuid": "^3.0.0",
     "walk-sync": "^0.3.0",
     "yam": "0.0.22"
   },
@@ -123,8 +123,8 @@
     "chai": "^3.4.1",
     "chai-as-promised": "^6.0.0",
     "chai-files": "^1.2.0",
-    "ember-cli-blueprint-test-helpers": "^0.14.0",
-    "ember-cli-internal-test-helpers": "^0.9.0",
+    "ember-cli-blueprint-test-helpers": "^0.13.0",
+    "ember-cli-internal-test-helpers": "^0.8.1",
     "eslint-plugin-chai-expect": "^1.1.1",
     "github": "^6.0.1",
     "istanbul": "^0.4.2",


Test patch:
diff --git a/tests/unit/broccoli/merge-trees-test.js b/tests/unit/broccoli/merge-trees-test.js
deleted file mode 100644
index f2984adb9..000000000
--- a/tests/unit/broccoli/merge-trees-test.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/* global escape */
-
-'use strict';
-
-var fs         = require('fs');
-var expect     = require('chai').expect;
-var proxyquire = require('proxyquire');
-var td = require('testdouble');
-
-var MockUI = require('../../helpers/mock-ui');
-
-var mergeTreesStub;
-var mergeTrees = proxyquire('../../../lib/broccoli/merge-trees', {
-  'broccoli-merge-trees': function() {
-    return mergeTreesStub.apply(this, arguments);
-  }
-});
-
-describe('broccoli/merge-trees', function() {
-  beforeEach(function() {
-    mergeTreesStub = td.function();
-  });
-
-  it('returns the first item when merging single item array', function() {
-    var actual = mergeTrees(['foo']);
-
-    expect(actual).to.equal('foo');
-  });
-
-  it('returns a constant "empty tree" when passed an empty array', function() {
-    var expected = {};
-
-    mergeTrees._overrideEmptyTree(expected);
-
-    var first = mergeTrees([]);
-    var second = mergeTrees([]);
-
-    expect(first).to.equal(expected);
-    expect(second).to.equal(expected);
-  });
-
-  it('passes all inputTrees through when non-empty', function() {
-    var expected = ['foo', 'bar'];
-    var actual;
-
-    mergeTreesStub = function(inputTrees) {
-      actual = inputTrees;
-      return {};
-    };
-
-    mergeTrees(['foo', null, undefined, 'bar']);
-    expect(actual).to.deep.equal(expected);
-  });
-
-  it('filters out empty trees from inputs', function() {
-    var expected = ['bar', 'baz'];
-    var actual;
-
-    mergeTrees._overrideEmptyTree('foo');
-
-    mergeTreesStub = function(inputTrees) {
-      actual = inputTrees;
-      return {};
-    };
-
-    mergeTrees(['foo', 'bar', 'baz']);
-    expect(actual).to.deep.equal(expected);
-  });
-});
diff --git a/tests/unit/models/builder-test.js b/tests/unit/models/builder-test.js
index 801193d10..6027c5caa 100644
--- a/tests/unit/models/builder-test.js
+++ b/tests/unit/models/builder-test.js
@@ -21,34 +21,6 @@ var tmproot         = path.join(root, 'tmp');
 describe('models/builder.js', function() {
   var addon, builder, buildResults, tmpdir;
 
-  describe('._enableFSMonitorIfVizEnabled', function() {
-    var originalBroccoliViz = process.env.BROCCOLI_VIZ;
-
-    afterEach(function() {
-      delete process.env.BROCCOLI_VIZ;
-    });
-
-    it('if VIZ is enabled, monitor', function() {
-      process.env.BROCCOLI_VIZ = '1';
-      var monitor = Builder._enableFSMonitorIfVizEnabled();
-      try {
-        expect(monitor.state).to.eql('active');
-      } finally {
-        monitor.stop();
-      }
-    });
-
-    it('if VIZ is NOT enabled, monitor', function() {
-      var monitor = Builder._enableFSMonitorIfVizEnabled();
-      try {
-        expect(monitor.state).to.eql('idle');
-      } finally {
-        monitor.stop();
-      }
-    });
-
-  });
-
   describe('Windows CTRL + C Capture', function() {
     var originalPlatform, originalStdin;