ember-cli 4.0.0 → 4.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/.github/workflows/ci.yml +8 -4
  2. package/CHANGELOG.md +43 -2
  3. package/README.md +1 -1
  4. package/blueprints/addon/additional-dev-dependencies.json +1 -1
  5. package/blueprints/addon/files/CONTRIBUTING.md +1 -1
  6. package/blueprints/app/files/README.md +2 -2
  7. package/blueprints/app/files/package.json +8 -8
  8. package/docs/build/data.json +64 -3
  9. package/lib/debug/assert.js +37 -0
  10. package/lib/debug/deprecate.js +111 -0
  11. package/lib/debug/index.js +6 -0
  12. package/lib/models/host-info-cache.js +3 -5
  13. package/lib/models/per-bundle-addon-cache/index.js +2 -3
  14. package/lib/tasks/npm-task.js +1 -1
  15. package/lib/utilities/get-lang-arg.js +45 -45
  16. package/package.json +31 -31
  17. package/.github/ISSUE_TEMPLATE.md +0 -12
  18. package/.github/dependabot.yml +0 -15
  19. package/.github/workflows/coverage.yml +0 -31
  20. package/docs/analytics.md +0 -44
  21. package/docs/architecture.md +0 -316
  22. package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
  23. package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
  24. package/docs/assets/architecture/README.md +0 -5
  25. package/docs/brocfile-transition.md +0 -46
  26. package/docs/build/api.js +0 -44
  27. package/docs/build/assets/css/external-small.png +0 -0
  28. package/docs/build/assets/css/logo.png +0 -0
  29. package/docs/build/assets/css/main.css +0 -555
  30. package/docs/build/assets/favicon.ico +0 -0
  31. package/docs/build/assets/img/spinner.gif +0 -0
  32. package/docs/build/assets/index.html +0 -10
  33. package/docs/build/assets/js/api-filter.js +0 -56
  34. package/docs/build/assets/js/api-list.js +0 -255
  35. package/docs/build/assets/js/api-search.js +0 -98
  36. package/docs/build/assets/js/apidocs.js +0 -376
  37. package/docs/build/assets/js/yui-prettify.js +0 -17
  38. package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
  39. package/docs/build/assets/vendor/prettify/COPYING +0 -202
  40. package/docs/build/assets/vendor/prettify/README.html +0 -203
  41. package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
  42. package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
  43. package/docs/build/classes/Addon.html +0 -4318
  44. package/docs/build/classes/AmdTransformAddon.html +0 -202
  45. package/docs/build/classes/Blueprint.html +0 -4796
  46. package/docs/build/classes/Builder.html +0 -611
  47. package/docs/build/classes/CLI.html +0 -810
  48. package/docs/build/classes/Command.html +0 -1655
  49. package/docs/build/classes/DefaultPackager.html +0 -202
  50. package/docs/build/classes/EmberAddon.html +0 -2207
  51. package/docs/build/classes/EmberApp.html +0 -2225
  52. package/docs/build/classes/HardwareInfo.html +0 -620
  53. package/docs/build/classes/HistorySupportAddon.html +0 -203
  54. package/docs/build/classes/Instrumentation.html +0 -695
  55. package/docs/build/classes/NodeModulesList.html +0 -460
  56. package/docs/build/classes/NpmTask.html +0 -333
  57. package/docs/build/classes/PackageInfo.html +0 -1390
  58. package/docs/build/classes/PackageInfoCache.html +0 -963
  59. package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
  60. package/docs/build/classes/Project.html +0 -2083
  61. package/docs/build/classes/ServeFilesAddon.html +0 -260
  62. package/docs/build/classes/TestsServerAddon.html +0 -203
  63. package/docs/build/classes/WatcherAddon.html +0 -204
  64. package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
  65. package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
  66. package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
  67. package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
  68. package/docs/build/files/lib_cli_cli.js.html +0 -417
  69. package/docs/build/files/lib_models_addon-info.js.html +0 -112
  70. package/docs/build/files/lib_models_addon.js.html +0 -1866
  71. package/docs/build/files/lib_models_blueprint.js.html +0 -1678
  72. package/docs/build/files/lib_models_builder.js.html +0 -417
  73. package/docs/build/files/lib_models_command.js.html +0 -804
  74. package/docs/build/files/lib_models_hardware-info.js.html +0 -479
  75. package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
  76. package/docs/build/files/lib_models_installation-checker.js.html +0 -181
  77. package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
  78. package/docs/build/files/lib_models_instrumentation.js.html +0 -433
  79. package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
  80. package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
  81. package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
  82. package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
  83. package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
  84. package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
  85. package/docs/build/files/lib_models_project.js.html +0 -913
  86. package/docs/build/files/lib_models_task.js.html +0 -117
  87. package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
  88. package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
  89. package/docs/build/files/lib_tasks_serve.js.html +0 -207
  90. package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
  91. package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
  92. package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
  93. package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
  94. package/docs/build/files/lib_tasks_test-server.js.html +0 -167
  95. package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
  96. package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
  97. package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
  98. package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
  99. package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
  100. package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
  101. package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
  102. package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
  103. package/docs/build/index.html +0 -125
  104. package/docs/build/modules/ember-cli.html +0 -152
  105. package/docs/build/modules/is-lazy-engine.html +0 -106
  106. package/docs/build-concurrency.md +0 -15
  107. package/docs/build-pipeline-debugging.md +0 -33
  108. package/docs/code-coverage.md +0 -14
  109. package/docs/error-propagation.md +0 -136
  110. package/docs/experiments.md +0 -53
  111. package/docs/node-support.md +0 -43
  112. package/docs/perf-guide.md +0 -250
  113. package/docs/project_version_preprocessor.js +0 -8
  114. package/docs/sourcemaps.md +0 -60
  115. package/docs/yuidoc.json +0 -13
@@ -1,191 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/models/instantiate-addons.js - ember-cli</title>
6
- <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
7
- <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/yui-min.js"></script>
9
- </head>
10
- <body class="yui3-skin-sam">
11
-
12
- <div id="doc">
13
- <div class="yui3-g">
14
- <div id="sidebar" class="yui3-u">
15
- <div class="logo">
16
- <a href="../index.html">
17
- <img src="https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png">
18
- </a>
19
- </div>
20
-
21
- <div id="modules" class="sidebox">
22
- <div class="hd">
23
- <h2 class="no-toc">Modules</h2>
24
- </div>
25
- <div class="bd">
26
- <ul>
27
- <li><a href="../modules/ember-cli.html">ember-cli</a>
28
- </li>
29
- <li><a href="../modules/is-lazy-engine.html">is-lazy-engine</a>
30
- </li>
31
- </ul>
32
- </div>
33
- </div>
34
-
35
- <div id="classes" class="sidebox">
36
- <div class="hd">
37
- <h2 class="no-toc">Classes</h2>
38
- </div>
39
- <div class="bd">
40
- <ul>
41
- <li><a href="../classes/Addon.html">Addon</a></li>
42
- <li><a href="../classes/AmdTransformAddon.html">AmdTransformAddon</a></li>
43
- <li><a href="../classes/Blueprint.html">Blueprint</a></li>
44
- <li><a href="../classes/Builder.html">Builder</a></li>
45
- <li><a href="../classes/CLI.html">CLI</a></li>
46
- <li><a href="../classes/Command.html">Command</a></li>
47
- <li><a href="../classes/DefaultPackager.html">DefaultPackager</a></li>
48
- <li><a href="../classes/EmberAddon.html">EmberAddon</a></li>
49
- <li><a href="../classes/EmberApp.html">EmberApp</a></li>
50
- <li><a href="../classes/HardwareInfo.html">HardwareInfo</a></li>
51
- <li><a href="../classes/HistorySupportAddon.html">HistorySupportAddon</a></li>
52
- <li><a href="../classes/Instrumentation.html">Instrumentation</a></li>
53
- <li><a href="../classes/NodeModulesList.html">NodeModulesList</a></li>
54
- <li><a href="../classes/NpmTask.html">NpmTask</a></li>
55
- <li><a href="../classes/PackageInfo.html">PackageInfo</a></li>
56
- <li><a href="../classes/PackageInfoCache.html">PackageInfoCache</a></li>
57
- <li><a href="../classes/PerBundleAddonCache {.html">PerBundleAddonCache {</a></li>
58
- <li><a href="../classes/Project.html">Project</a></li>
59
- <li><a href="../classes/ServeFilesAddon.html">ServeFilesAddon</a></li>
60
- <li><a href="../classes/TestsServerAddon.html">TestsServerAddon</a></li>
61
- <li><a href="../classes/WatcherAddon.html">WatcherAddon</a></li>
62
- <li><a href="../classes/WindowsSymlinkChecker.html">WindowsSymlinkChecker</a></li>
63
- </ul>
64
- </div>
65
- </div>
66
-
67
-
68
-
69
-
70
-
71
- <div class="version-info">
72
- Version: 4.0.0-release-b4cbb1029f
73
- </div>
74
-
75
- </div>
76
-
77
- <div id="main" class="yui3-u">
78
- <div class="content"><div class="title">
79
- <h1 class="file-name">lib/models/instantiate-addons.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- /**
86
- @module ember-cli
87
- */
88
-
89
- const DAGMap = require(&#x27;dag-map&#x27;).default;
90
- const logger = require(&#x27;heimdalljs-logger&#x27;)(&#x27;ember-cli:addons-factory&#x27;);
91
- const heimdall = require(&#x27;heimdalljs&#x27;);
92
- const SilentError = require(&#x27;silent-error&#x27;);
93
-
94
- /**
95
- * Create instances of a set of &quot;child&quot; addons for a parent addon or project.
96
- *
97
- * @method instantiateAddons
98
- * @param {Object} parent an Addon or Project that is the direct containing object of the list
99
- * of children defined in addonPackages.
100
- * @param {Project} project the project that contains the parent (so either the addon&#x27;s project
101
- * if parent is an addon, or the project itself if it is a project). It is possible when
102
- * constructing custom addon instances that the project will actually be undefined--various
103
- * addon tests do this, for example.
104
- * @param {Object} a map of addon name (including scope) to an AddonInfo with the name, path and
105
- * &#x27;pkg&#x27; object for that addon&#x27;s package.json). These are what is turned into addons.
106
- */
107
- function instantiateAddons(parent, project, addonPackages) {
108
- // depending on whether this is really a project or an addon, the &#x27;name&#x27; property may be a getter.
109
- let parentName = typeof parent.name === &#x27;function&#x27; ? parent.name() : parent.name;
110
-
111
- logger.info(&#x27;instantiateAddons for: &#x27;, parentName);
112
-
113
- let addonNames = Object.keys(addonPackages || {});
114
-
115
- if (addonNames.length === 0) {
116
- logger.info(&#x27; no addons&#x27;);
117
- return [];
118
- } else {
119
- logger.info(&#x27; addon names are:&#x27;, addonNames);
120
- }
121
-
122
- let initializeAddonsToken = heimdall.start(&#x60;${parentName}: initializeAddons&#x60;);
123
- let graph = new DAGMap();
124
- let addonInfo, emberAddonConfig;
125
-
126
- addonNames.forEach((name) =&gt; {
127
- addonInfo = addonPackages[name];
128
- emberAddonConfig = addonInfo.pkg[&#x27;ember-addon&#x27;];
129
-
130
- graph.add(name, addonInfo, emberAddonConfig.before, emberAddonConfig.after);
131
- });
132
-
133
- let addons = [];
134
- let timings = new Map();
135
-
136
- graph.each((key, value) =&gt; {
137
- let addonInfo = value;
138
- if (addonInfo) {
139
- let initializeAddonToken = heimdall.start({
140
- name: &#x60;initialize ${addonInfo.name}&#x60;,
141
- addonName: addonInfo.name,
142
- addonInitializationNode: true,
143
- });
144
-
145
- let start = Date.now();
146
-
147
- let pkgInfo = parent.packageInfoCache.getEntry(addonInfo.path);
148
-
149
- if (!pkgInfo || !pkgInfo.valid) {
150
- throw new SilentError(
151
- &#x60;The \&#x60;${addonInfo.pkg.name}\&#x60; addon could not be found at \&#x60;${addonInfo.path}\&#x60; or was otherwise invalid.&#x60;
152
- );
153
- }
154
-
155
- // get an instance of the addon. If that fails it will throw.
156
- let addon = pkgInfo.getAddonInstance(parent, project);
157
-
158
- timings.set(addon, Date.now() - start);
159
-
160
- initializeAddonToken.stop();
161
-
162
- addons.push(addon);
163
- }
164
- });
165
-
166
- logger.info(
167
- &#x27; addon info %o&#x27;,
168
- addons.map((addon) =&gt; ({
169
- name: addon.name,
170
- initializeTotalMillis: timings.get(addon),
171
- }))
172
- );
173
-
174
- initializeAddonsToken.stop();
175
-
176
- return addons;
177
- }
178
-
179
- module.exports = instantiateAddons;
180
-
181
- </pre>
182
-
183
- </div>
184
- </div>
185
- </div>
186
- </div>
187
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
188
- <script>prettyPrint();</script>
189
- <script src="../assets/js/yui-prettify.js"></script>
190
- </body>
191
- </html>
@@ -1,433 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/models/instrumentation.js - ember-cli</title>
6
- <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
7
- <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/yui-min.js"></script>
9
- </head>
10
- <body class="yui3-skin-sam">
11
-
12
- <div id="doc">
13
- <div class="yui3-g">
14
- <div id="sidebar" class="yui3-u">
15
- <div class="logo">
16
- <a href="../index.html">
17
- <img src="https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png">
18
- </a>
19
- </div>
20
-
21
- <div id="modules" class="sidebox">
22
- <div class="hd">
23
- <h2 class="no-toc">Modules</h2>
24
- </div>
25
- <div class="bd">
26
- <ul>
27
- <li><a href="../modules/ember-cli.html">ember-cli</a>
28
- </li>
29
- <li><a href="../modules/is-lazy-engine.html">is-lazy-engine</a>
30
- </li>
31
- </ul>
32
- </div>
33
- </div>
34
-
35
- <div id="classes" class="sidebox">
36
- <div class="hd">
37
- <h2 class="no-toc">Classes</h2>
38
- </div>
39
- <div class="bd">
40
- <ul>
41
- <li><a href="../classes/Addon.html">Addon</a></li>
42
- <li><a href="../classes/AmdTransformAddon.html">AmdTransformAddon</a></li>
43
- <li><a href="../classes/Blueprint.html">Blueprint</a></li>
44
- <li><a href="../classes/Builder.html">Builder</a></li>
45
- <li><a href="../classes/CLI.html">CLI</a></li>
46
- <li><a href="../classes/Command.html">Command</a></li>
47
- <li><a href="../classes/DefaultPackager.html">DefaultPackager</a></li>
48
- <li><a href="../classes/EmberAddon.html">EmberAddon</a></li>
49
- <li><a href="../classes/EmberApp.html">EmberApp</a></li>
50
- <li><a href="../classes/HardwareInfo.html">HardwareInfo</a></li>
51
- <li><a href="../classes/HistorySupportAddon.html">HistorySupportAddon</a></li>
52
- <li><a href="../classes/Instrumentation.html">Instrumentation</a></li>
53
- <li><a href="../classes/NodeModulesList.html">NodeModulesList</a></li>
54
- <li><a href="../classes/NpmTask.html">NpmTask</a></li>
55
- <li><a href="../classes/PackageInfo.html">PackageInfo</a></li>
56
- <li><a href="../classes/PackageInfoCache.html">PackageInfoCache</a></li>
57
- <li><a href="../classes/PerBundleAddonCache {.html">PerBundleAddonCache {</a></li>
58
- <li><a href="../classes/Project.html">Project</a></li>
59
- <li><a href="../classes/ServeFilesAddon.html">ServeFilesAddon</a></li>
60
- <li><a href="../classes/TestsServerAddon.html">TestsServerAddon</a></li>
61
- <li><a href="../classes/WatcherAddon.html">WatcherAddon</a></li>
62
- <li><a href="../classes/WindowsSymlinkChecker.html">WindowsSymlinkChecker</a></li>
63
- </ul>
64
- </div>
65
- </div>
66
-
67
-
68
-
69
-
70
-
71
- <div class="version-info">
72
- Version: 4.0.0-release-b4cbb1029f
73
- </div>
74
-
75
- </div>
76
-
77
- <div id="main" class="yui3-u">
78
- <div class="content"><div class="title">
79
- <h1 class="file-name">lib/models/instrumentation.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- const fs = require(&#x27;fs-extra&#x27;);
86
- const chalk = require(&#x27;chalk&#x27;);
87
- const heimdallGraph = require(&#x27;heimdalljs-graph&#x27;);
88
- const getConfig = require(&#x27;../utilities/get-config&#x27;);
89
- const utilsInstrumentation = require(&#x27;../utilities/instrumentation&#x27;);
90
- const logger = require(&#x27;heimdalljs-logger&#x27;)(&#x27;ember-cli:instrumentation&#x27;);
91
- const hwinfo = require(&#x27;./hardware-info&#x27;);
92
-
93
- let vizEnabled = utilsInstrumentation.vizEnabled;
94
- let instrumentationEnabled = utilsInstrumentation.instrumentationEnabled;
95
-
96
- function _enableFSMonitorIfInstrumentationEnabled(config) {
97
- let monitor;
98
- if (instrumentationEnabled(config)) {
99
- const FSMonitor = require(&#x27;heimdalljs-fs-monitor&#x27;);
100
- monitor = new FSMonitor();
101
- monitor.start();
102
- }
103
- return monitor;
104
- }
105
-
106
- _enableFSMonitorIfInstrumentationEnabled();
107
-
108
- function _getHardwareInfo(platform) {
109
- const startTime = process.hrtime();
110
-
111
- Object.getOwnPropertyNames(hwinfo).forEach((metric) =&gt; (platform[metric] = hwinfo[metric]()));
112
-
113
- const collectionTime = process.hrtime(startTime);
114
-
115
- // Convert from integer [seconds, nanoseconds] to floating-point milliseconds.
116
- platform.collectionTime = collectionTime[0] * 10e3 + collectionTime[1] / 10e6;
117
- }
118
-
119
- class Instrumentation {
120
- /**
121
- An instance of this class is used for invoking the instrumentation
122
- hooks on addons.
123
-
124
- The instrumentation types currently supported are:
125
-
126
- * init
127
- * build
128
- * command
129
- * shutdown
130
-
131
- @class Instrumentation
132
- @private
133
- */
134
- constructor(options) {
135
- this.isVizEnabled = vizEnabled;
136
- this.isEnabled = instrumentationEnabled;
137
-
138
- this.ui = options.ui;
139
-
140
- // project constructor will set up bidirectional link
141
- this.project = null;
142
-
143
- this.instrumentations = {
144
- init: options.initInstrumentation,
145
- build: {
146
- token: null,
147
- node: null,
148
- count: 0,
149
- },
150
- command: {
151
- token: null,
152
- node: null,
153
- },
154
- shutdown: {
155
- token: null,
156
- node: null,
157
- },
158
- };
159
-
160
- this._heimdall = null;
161
-
162
- this.config = getConfig();
163
-
164
- if (!options.initInstrumentation &amp;&amp; this.isEnabled()) {
165
- this.instrumentations.init = {
166
- token: null,
167
- node: null,
168
- };
169
- this.start(&#x27;init&#x27;);
170
- }
171
- }
172
-
173
- _buildSummary(tree, result, resultAnnotation) {
174
- let buildSteps = 0;
175
- let totalTime = 0;
176
-
177
- let node;
178
- let statName;
179
- let statValue;
180
- let nodeItr;
181
- let statsItr;
182
- let nextNode;
183
- let nextStat;
184
-
185
- for (nodeItr = tree.dfsIterator(); ; ) {
186
- nextNode = nodeItr.next();
187
- if (nextNode.done) {
188
- break;
189
- }
190
-
191
- node = nextNode.value;
192
- if (node.label.broccoliNode &amp;&amp; !node.label.broccoliCachedNode) {
193
- ++buildSteps;
194
- }
195
-
196
- for (statsItr = node.statsIterator(); ; ) {
197
- nextStat = statsItr.next();
198
- if (nextStat.done) {
199
- break;
200
- }
201
-
202
- statName = nextStat.value[0];
203
- statValue = nextStat.value[1];
204
-
205
- if (statName === &#x27;time.self&#x27;) {
206
- totalTime += statValue;
207
- }
208
- }
209
- }
210
-
211
- let summary = {
212
- build: {
213
- type: resultAnnotation.type,
214
- count: this.instrumentations.build.count,
215
- outputChangedFiles: null,
216
- },
217
- platform: {
218
- name: process.platform,
219
- },
220
- output: null,
221
- totalTime,
222
- buildSteps,
223
- };
224
-
225
- _getHardwareInfo(summary.platform);
226
-
227
- if (result) {
228
- summary.build.outputChangedFiles = result.outputChanges;
229
- summary.output = result.directory;
230
- }
231
-
232
- if (resultAnnotation.type === &#x27;rebuild&#x27;) {
233
- summary.build.primaryFile = resultAnnotation.primaryFile;
234
- summary.build.changedFileCount = resultAnnotation.changedFiles.length;
235
- summary.build.changedFiles = resultAnnotation.changedFiles.slice(0, 10);
236
- }
237
-
238
- return summary;
239
- }
240
-
241
- _initSummary(tree) {
242
- const summary = {
243
- totalTime: totalTime(tree),
244
- platform: {
245
- name: process.platform,
246
- },
247
- };
248
-
249
- _getHardwareInfo(summary.platform);
250
-
251
- return summary;
252
- }
253
-
254
- _commandSummary(tree, commandName, commandArgs) {
255
- const summary = {
256
- name: commandName,
257
- args: commandArgs,
258
- totalTime: totalTime(tree),
259
- platform: {
260
- name: process.platform,
261
- },
262
- };
263
-
264
- _getHardwareInfo(summary.platform);
265
-
266
- return summary;
267
- }
268
-
269
- _shutdownSummary(tree) {
270
- const summary = {
271
- totalTime: totalTime(tree),
272
- platform: {
273
- name: process.platform,
274
- },
275
- };
276
-
277
- _getHardwareInfo(summary.platform);
278
-
279
- return summary;
280
- }
281
-
282
- _instrumentationFor(name) {
283
- let instr = this.instrumentations[name];
284
- if (!instr) {
285
- throw new Error(&#x60;No such instrumentation &quot;${name}&quot;&#x60;);
286
- }
287
- return instr;
288
- }
289
-
290
- _instrumentationTreeFor(name) {
291
- return heimdallGraph.loadFromNode(this.instrumentations[name].node);
292
- }
293
-
294
- _invokeAddonHook(name, instrumentationInfo) {
295
- if (this.project &amp;&amp; this.project.addons.length) {
296
- this.project.addons.forEach((addon) =&gt; {
297
- if (typeof addon.instrumentation === &#x27;function&#x27;) {
298
- addon.instrumentation(name, instrumentationInfo);
299
- }
300
- });
301
- }
302
- }
303
-
304
- _writeInstrumentation(name, instrumentationInfo) {
305
- if (!vizEnabled()) {
306
- return;
307
- }
308
-
309
- let filename = &#x60;instrumentation.${name}&#x60;;
310
- if (name === &#x27;build&#x27;) {
311
- filename += &#x60;.${this.instrumentations.build.count}&#x60;;
312
- }
313
- filename = &#x60;${filename}.json&#x60;;
314
- fs.writeJsonSync(filename, {
315
- summary: instrumentationInfo.summary,
316
- // we want to change this to tree, to be consistent with the hook, but first
317
- // we must update broccoli-viz
318
- // see see https://github.com/ember-cli/broccoli-viz/issues/35
319
- nodes: instrumentationInfo.tree.toJSON().nodes,
320
- });
321
- }
322
-
323
- start(name) {
324
- if (!instrumentationEnabled(this.config)) {
325
- return;
326
- }
327
-
328
- let instr = this._instrumentationFor(name);
329
- this._heimdall = this._heimdall || require(&#x27;heimdalljs&#x27;);
330
-
331
- if (instr.node) {
332
- // don&#x27;t leak nodes during build. We have already reported on this in the
333
- // previous stopAndReport so no data is lost
334
- instr.node.remove();
335
- }
336
-
337
- let token = this._heimdall.start({ name, emberCLI: true });
338
- instr.token = token;
339
- instr.node = this._heimdall.current;
340
- }
341
-
342
- stopAndReport(name) {
343
- if (!instrumentationEnabled(this.config)) {
344
- return;
345
- }
346
-
347
- let instr = this._instrumentationFor(name);
348
- if (!instr.token) {
349
- throw new Error(&#x60;Cannot stop instrumentation &quot;${name}&quot;. It has not started.&#x60;);
350
- }
351
- try {
352
- instr.token.stop();
353
- } catch (e) {
354
- this.ui.writeLine(chalk.red(&#x60;Error reporting instrumentation &#x27;${name}&#x27;.&#x60;));
355
- logger.error(e.stack);
356
- return;
357
- }
358
-
359
- let instrSummaryName = &#x60;_${name}Summary&#x60;;
360
- if (!this[instrSummaryName]) {
361
- throw new Error(&#x60;No summary found for &quot;${name}&quot;&#x60;);
362
- }
363
-
364
- let tree = this._instrumentationTreeFor(name);
365
- let args = Array.prototype.slice.call(arguments, 1);
366
- args.unshift(tree);
367
-
368
- let instrInfo = {
369
- summary: this[instrSummaryName].apply(this, args),
370
- tree,
371
- };
372
-
373
- this._invokeAddonHook(name, instrInfo);
374
- this._writeInstrumentation(name, instrInfo);
375
-
376
- if (name === &#x27;build&#x27;) {
377
- instr.count++;
378
- }
379
- }
380
- }
381
-
382
- function totalTime(tree) {
383
- let totalTime = 0;
384
- let nodeItr;
385
- let node;
386
- let statName;
387
- let statValue;
388
- let statsItr;
389
- let nextNode;
390
- let nextStat;
391
-
392
- for (nodeItr = tree.dfsIterator(); ; ) {
393
- nextNode = nodeItr.next();
394
- if (nextNode.done) {
395
- break;
396
- }
397
-
398
- node = nextNode.value;
399
-
400
- for (statsItr = node.statsIterator(); ; ) {
401
- nextStat = statsItr.next();
402
- if (nextStat.done) {
403
- break;
404
- }
405
-
406
- statName = nextStat.value[0];
407
- statValue = nextStat.value[1];
408
-
409
- if (statName === &#x27;time.self&#x27;) {
410
- totalTime += statValue;
411
- }
412
- }
413
- }
414
-
415
- return totalTime;
416
- }
417
-
418
- // exported for testing
419
- Instrumentation._enableFSMonitorIfInstrumentationEnabled = _enableFSMonitorIfInstrumentationEnabled;
420
-
421
- module.exports = Instrumentation;
422
-
423
- </pre>
424
-
425
- </div>
426
- </div>
427
- </div>
428
- </div>
429
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
430
- <script>prettyPrint();</script>
431
- <script src="../assets/js/yui-prettify.js"></script>
432
- </body>
433
- </html>