ember-cli 4.0.0-beta.4 → 4.1.0

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 (118) hide show
  1. package/.github/workflows/ci.yml +4 -4
  2. package/CHANGELOG.md +28 -17
  3. package/bin/ember +0 -0
  4. package/blueprints/addon/additional-dev-dependencies.json +1 -1
  5. package/blueprints/addon/files/.github/workflows/ci.yml +5 -1
  6. package/blueprints/addon/files/.travis.yml +1 -1
  7. package/blueprints/addon/files/README.md +2 -2
  8. package/blueprints/addon/files/addon-config/ember-try.js +4 -4
  9. package/blueprints/app/files/.github/workflows/ci.yml +4 -0
  10. package/blueprints/app/files/package.json +8 -8
  11. package/blueprints/in-repo-addon/files/__root__/__name__/index.js +0 -0
  12. package/blueprints/in-repo-addon/index.js +0 -0
  13. package/blueprints/lib/index.js +0 -0
  14. package/docs/build/data.json +413 -413
  15. package/lib/models/host-info-cache.js +3 -5
  16. package/lib/models/per-bundle-addon-cache/index.js +2 -3
  17. package/lib/tasks/npm-task.js +1 -1
  18. package/lib/utilities/get-lang-arg.js +45 -45
  19. package/package.json +25 -25
  20. package/.github/ISSUE_TEMPLATE.md +0 -12
  21. package/.github/dependabot.yml +0 -15
  22. package/.github/workflows/coverage.yml +0 -31
  23. package/docs/analytics.md +0 -44
  24. package/docs/architecture.md +0 -316
  25. package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
  26. package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
  27. package/docs/assets/architecture/README.md +0 -5
  28. package/docs/brocfile-transition.md +0 -46
  29. package/docs/build/api.js +0 -44
  30. package/docs/build/assets/css/external-small.png +0 -0
  31. package/docs/build/assets/css/logo.png +0 -0
  32. package/docs/build/assets/css/main.css +0 -555
  33. package/docs/build/assets/favicon.ico +0 -0
  34. package/docs/build/assets/img/spinner.gif +0 -0
  35. package/docs/build/assets/index.html +0 -10
  36. package/docs/build/assets/js/api-filter.js +0 -56
  37. package/docs/build/assets/js/api-list.js +0 -255
  38. package/docs/build/assets/js/api-search.js +0 -98
  39. package/docs/build/assets/js/apidocs.js +0 -376
  40. package/docs/build/assets/js/yui-prettify.js +0 -17
  41. package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
  42. package/docs/build/assets/vendor/prettify/COPYING +0 -202
  43. package/docs/build/assets/vendor/prettify/README.html +0 -203
  44. package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
  45. package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
  46. package/docs/build/classes/Addon.html +0 -4318
  47. package/docs/build/classes/AmdTransformAddon.html +0 -202
  48. package/docs/build/classes/Blueprint.html +0 -4796
  49. package/docs/build/classes/Builder.html +0 -611
  50. package/docs/build/classes/CLI.html +0 -810
  51. package/docs/build/classes/Command.html +0 -1655
  52. package/docs/build/classes/DefaultPackager.html +0 -202
  53. package/docs/build/classes/EmberAddon.html +0 -2207
  54. package/docs/build/classes/EmberApp.html +0 -2225
  55. package/docs/build/classes/HardwareInfo.html +0 -620
  56. package/docs/build/classes/HistorySupportAddon.html +0 -203
  57. package/docs/build/classes/Instrumentation.html +0 -695
  58. package/docs/build/classes/NodeModulesList.html +0 -460
  59. package/docs/build/classes/NpmTask.html +0 -333
  60. package/docs/build/classes/PackageInfo.html +0 -1390
  61. package/docs/build/classes/PackageInfoCache.html +0 -963
  62. package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
  63. package/docs/build/classes/Project.html +0 -2083
  64. package/docs/build/classes/ServeFilesAddon.html +0 -260
  65. package/docs/build/classes/TestsServerAddon.html +0 -203
  66. package/docs/build/classes/WatcherAddon.html +0 -204
  67. package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
  68. package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
  69. package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
  70. package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
  71. package/docs/build/files/lib_cli_cli.js.html +0 -417
  72. package/docs/build/files/lib_models_addon-info.js.html +0 -112
  73. package/docs/build/files/lib_models_addon.js.html +0 -1866
  74. package/docs/build/files/lib_models_blueprint.js.html +0 -1678
  75. package/docs/build/files/lib_models_builder.js.html +0 -417
  76. package/docs/build/files/lib_models_command.js.html +0 -804
  77. package/docs/build/files/lib_models_hardware-info.js.html +0 -479
  78. package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
  79. package/docs/build/files/lib_models_installation-checker.js.html +0 -181
  80. package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
  81. package/docs/build/files/lib_models_instrumentation.js.html +0 -433
  82. package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
  83. package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
  84. package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
  85. package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
  86. package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
  87. package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
  88. package/docs/build/files/lib_models_project.js.html +0 -913
  89. package/docs/build/files/lib_models_task.js.html +0 -117
  90. package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
  91. package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
  92. package/docs/build/files/lib_tasks_serve.js.html +0 -207
  93. package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
  94. package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
  95. package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
  96. package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
  97. package/docs/build/files/lib_tasks_test-server.js.html +0 -167
  98. package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
  99. package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
  100. package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
  101. package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
  102. package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
  103. package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
  104. package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
  105. package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
  106. package/docs/build/index.html +0 -125
  107. package/docs/build/modules/ember-cli.html +0 -152
  108. package/docs/build/modules/is-lazy-engine.html +0 -106
  109. package/docs/build-concurrency.md +0 -15
  110. package/docs/build-pipeline-debugging.md +0 -33
  111. package/docs/code-coverage.md +0 -14
  112. package/docs/error-propagation.md +0 -136
  113. package/docs/experiments.md +0 -53
  114. package/docs/node-support.md +0 -43
  115. package/docs/perf-guide.md +0 -250
  116. package/docs/project_version_preprocessor.js +0 -8
  117. package/docs/sourcemaps.md +0 -60
  118. package/docs/yuidoc.json +0 -13
@@ -1,661 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/models/package-info-cache/package-info.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-beta.4-beta-724190cca6
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/package-info-cache/package-info.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- const path = require(&#x27;path&#x27;);
86
- const ErrorList = require(&#x27;./error-list&#x27;);
87
- const Errors = require(&#x27;./errors&#x27;);
88
- const AddonInfo = require(&#x27;../addon-info&#x27;);
89
- const isAddon = require(&#x27;../../utilities/is-addon&#x27;);
90
- const isEngine = require(&#x27;../../utilities/is-engine&#x27;);
91
- const isLazyEngine = require(&#x27;../../utilities/is-lazy-engine&#x27;);
92
- const logger = require(&#x27;heimdalljs-logger&#x27;)(&#x27;ember-cli:package-info-cache:package-info&#x27;);
93
- const PerBundleAddonCache = require(&#x27;../per-bundle-addon-cache&#x27;);
94
-
95
- function lexicographically(a, b) {
96
- const aIsString = typeof a.name === &#x27;string&#x27;;
97
- const bIsString = typeof b.name === &#x27;string&#x27;;
98
-
99
- if (aIsString &amp;&amp; bIsString) {
100
- return a.name.localeCompare(b.name);
101
- } else if (aIsString) {
102
- return -1;
103
- } else if (bIsString) {
104
- return 1;
105
- } else {
106
- return 0;
107
- }
108
- }
109
-
110
- function pushUnique(array, entry) {
111
- const index = array.indexOf(entry);
112
-
113
- if (index &gt; -1) {
114
- // the entry already exists in the array, but since the presedence between
115
- // addons is &quot;last right wins&quot;. We first remove the duplicate entry, and
116
- // append it to the end of the array.
117
- array.splice(index, 1);
118
- }
119
-
120
- // At this point, the entry is not in the array. So we must append it.
121
- array.push(entry);
122
-
123
- // All this ensures:
124
- // pushUnique([a1,a2,a3], a1)
125
- // results in:
126
- //
127
- // [a2, a3, a1]
128
- //
129
- // which results in the most &quot;least surprising&quot; addon ordering.
130
- }
131
-
132
- /**
133
- * Class that stores information about a single package (directory tree with
134
- * a package.json and other data, like and Addon or Project.) It is one of the
135
- * two types of entries in a PackageInfoCache. It is only created by the
136
- * PackageInfoCache.
137
- *
138
- * @public
139
- * @class PackageInfo
140
- */
141
- class PackageInfo {
142
- constructor(pkgObj, realPath, cache, isRoot = false) {
143
- this.pkg = pkgObj;
144
- this.pkg[&#x27;ember-addon&#x27;] = this.pkg[&#x27;ember-addon&#x27;] || {};
145
- this.realPath = realPath;
146
- this.cache = cache;
147
- this.errors = new ErrorList();
148
-
149
- // other fields that will be set as needed. For JIT we&#x27;ll define
150
- // them here.
151
- this.addonMainPath = undefined; // addons only
152
- this.inRepoAddons = undefined; // (list of PackageInfo - both)
153
- this.internalAddons = undefined; // (list of PackageInfo - project only)
154
- this.cliInfo = undefined; // (PackageInfo - project only)
155
- this.dependencyPackages = undefined; // (obj keyed by dependency name: PackageInfo)
156
- // NOTE: ALL dependencies, not just addons
157
- this.devDependencyPackages = undefined; // (obj keyed by devDependency name: PackageInfo)
158
- // NOTE: these are ALL dependencies, not just addons
159
- this.nodeModules = undefined; // (NodeModulesList, set only if pkg contains node_modules)
160
-
161
- // flag indicating that the packageInfo is considered valid. This will
162
- // be true as long as we have a valid directory and our package.json file
163
- // is okay and, if we&#x27;re an ember addon, that we have a valid &#x27;main&#x27; file.
164
- // Missing dependencies will not be considered an error, since they may
165
- // not actually be used.
166
- this.valid = true;
167
-
168
- this.mayHaveAddons = isRoot || this.isForAddon(); // mayHaveAddons used in index.js
169
-
170
- this._hasDumpedInvalidAddonPackages = false;
171
- }
172
-
173
- // Make various fields of the pkg object available.
174
- get name() {
175
- return this.pkg.name;
176
- }
177
-
178
- /**
179
- * Given error data, add an ErrorEntry to the ErrorList for this object.
180
- * This is used by the _readPackage and _readNodeModulesList methods. It
181
- * should not be called otherwise.
182
- *
183
- * @protected
184
- * @method addError
185
- * @param {String} errorType one of the Errors.ERROR_* constants.
186
- * @param {Object} errorData any error data relevant to the type of error
187
- * being created. See showErrors().
188
- */
189
- addError(errorType, errorData) {
190
- this.errors.addError(errorType, errorData);
191
- }
192
-
193
- /**
194
- * Indicate if there are any errors in the ErrorList for this package. Note that this does
195
- * NOT indicate if there are any errors in the objects referred to by this package (e.g.,
196
- * internal addons or dependencies).
197
- *
198
- * @public
199
- * @method hasErrors
200
- * @param {boolean} true if there are errors in the ErrorList, else false.
201
- */
202
- hasErrors() {
203
- return this.errors.hasErrors();
204
- }
205
-
206
- /**
207
- * Add a reference to an in-repo addon PackageInfo object.
208
- *
209
- * @protected
210
- * @method addInRepoAddon
211
- * @param {PackageInfo} inRepoAddonPkg the PackageInfo for the in-repo addon
212
- * @return null
213
- */
214
- addInRepoAddon(inRepoAddonPkg) {
215
- if (!this.inRepoAddons) {
216
- this.inRepoAddons = [];
217
- }
218
- this.inRepoAddons.push(inRepoAddonPkg);
219
- }
220
-
221
- /**
222
- * Add a reference to an internal addon PackageInfo object.
223
- * &quot;internal&quot; addons (note: not in-repo addons) only exist in
224
- * Projects, not other packages. Since the cache is loaded from
225
- * &#x27;loadProject&#x27;, this can be done appropriately.
226
- *
227
- * @protected
228
- * @method addInternalAddon
229
- * @param {PackageInfo} internalAddonPkg the PackageInfo for the internal addon
230
- * @return null
231
- */
232
- addInternalAddon(internalAddonPkg) {
233
- if (!this.internalAddons) {
234
- this.internalAddons = [];
235
- }
236
- this.internalAddons.push(internalAddonPkg);
237
- }
238
-
239
- /**
240
- * For each dependency in the given list, find the corresponding
241
- * PackageInfo object in the cache (going up the file tree if
242
- * necessary, as in the node resolution algorithm). Return a map
243
- * of the dependencyName to PackageInfo object. Caller can then
244
- * store it wherever they like.
245
- *
246
- * Note: this is not to be called until all packages that can be have
247
- * been added to the cache.
248
- *
249
- * Note: this is for ALL dependencies, not just addons. To get just
250
- * addons, filter the result by calling pkgInfo.isForAddon().
251
- *
252
- * Note: this is only intended for use from PackageInfoCache._resolveDependencies.
253
- * It is not to be called directly by anything else.
254
- *
255
- * @protected
256
- * @method addDependencies
257
- * @param {PackageInfo} dependencies value of &#x27;dependencies&#x27; or &#x27;devDependencies&#x27;
258
- * attributes of a package.json.
259
- * @return {Object} a JavaScript object keyed on dependency name/path with
260
- * values the corresponding PackageInfo object from the cache.
261
- */
262
- addDependencies(dependencies) {
263
- if (!dependencies) {
264
- return null;
265
- }
266
-
267
- let dependencyNames = Object.keys(dependencies);
268
-
269
- if (dependencyNames.length === 0) {
270
- return null;
271
- }
272
-
273
- let packages = Object.create(null);
274
-
275
- let missingDependencies = [];
276
-
277
- dependencyNames.forEach((dependencyName) =&gt; {
278
- logger.info(&#x27;%s: Trying to find dependency %o&#x27;, this.pkg.name, dependencyName);
279
-
280
- let dependencyPackage;
281
-
282
- // much of the time the package will have dependencies in
283
- // a node_modules inside it, so check there first because it&#x27;s
284
- // quicker since we have the reference. Only check externally
285
- // if we don&#x27;t find it there.
286
- if (this.nodeModules) {
287
- dependencyPackage = this.nodeModules.findPackage(dependencyName);
288
- }
289
-
290
- if (!dependencyPackage) {
291
- dependencyPackage = this.cache._findPackage(dependencyName, path.dirname(this.realPath));
292
- }
293
-
294
- if (dependencyPackage) {
295
- packages[dependencyName] = dependencyPackage;
296
- } else {
297
- missingDependencies.push(dependencyName);
298
- }
299
- });
300
-
301
- if (missingDependencies.length &gt; 0) {
302
- this.addError(Errors.ERROR_DEPENDENCIES_MISSING, missingDependencies);
303
- }
304
-
305
- return packages;
306
- }
307
-
308
- /**
309
- * Indicate if this packageInfo is for a project. Should be called only after the project
310
- * has been loaded (see {@link PackageInfoCache#loadProject} for details).
311
- *
312
- * @method isForProject
313
- * @return {Boolean} true if this packageInfo is for a Project, false otherwise.
314
- */
315
- isForProject() {
316
- return !!this.project &amp;&amp; this.project.isEmberCLIProject &amp;&amp; this.project.isEmberCLIProject();
317
- }
318
-
319
- /**
320
- * Indicate if this packageInfo is for an Addon.
321
- *
322
- * @method isForAddon
323
- * @return {Boolean} true if this packageInfo is for an Addon, false otherwise.
324
- */
325
- isForAddon() {
326
- return isAddon(this.pkg.keywords);
327
- }
328
-
329
- /**
330
- * Indicate if this packageInfo represents an engine.
331
- *
332
- * @method isForEngine
333
- * @return {Boolean} true if this pkgInfo is configured as an engine &amp; false otherwise
334
- */
335
- isForEngine() {
336
- return isEngine(this.pkg.keywords);
337
- }
338
-
339
- /**
340
- * Indicate if this packageInfo represents a lazy engine.
341
- *
342
- * @method isForLazyEngine
343
- * @return {Boolean} true if this pkgInfo is configured as an engine and the
344
- * module this represents has lazyLoading enabled, false otherwise.
345
- */
346
- isForLazyEngine() {
347
- return this.isForEngine() &amp;&amp; isLazyEngine(this._getAddonEntryPoint());
348
- }
349
-
350
- /**
351
- * For use with the PerBundleAddonCache, is this packageInfo representing a
352
- * bundle host (for now, a Project or a lazy engine).
353
- *
354
- * @method isForBundleHost
355
- * @return {Boolean} true if this pkgInfo is for a bundle host, false otherwise.
356
- */
357
- isForBundleHost() {
358
- return this.isForProject() || this.isForLazyEngine();
359
- }
360
-
361
- /**
362
- * Add to a list of child addon PackageInfos for this packageInfo.
363
- *
364
- * @method addPackages
365
- * @param {Array} addonPackageList the list of child addon PackageInfos being constructed from various
366
- * sources in this packageInfo.
367
- * @param {Array | Object} packageInfoList a list or map of PackageInfos being considered
368
- * (e.g., pkgInfo.dependencyPackages) for inclusion in the addonPackageList.
369
- * @param {Function} excludeFn an optional function. If passed in, each child PackageInfo
370
- * will be tested against the function and only included in the package map if the function
371
- * returns a truthy value.
372
- */
373
- addPackages(addonPackageList, packageInfoList, excludeFn) {
374
- if (!packageInfoList) {
375
- return;
376
- }
377
-
378
- let result = [];
379
- if (Array.isArray(packageInfoList)) {
380
- if (excludeFn) {
381
- packageInfoList = packageInfoList.filter((pkgInfo) =&gt; !excludeFn(pkgInfo));
382
- }
383
-
384
- packageInfoList.forEach((pkgInfo) =&gt; result.push(pkgInfo));
385
- } else {
386
- // We&#x27;re going to assume we have a map of name to packageInfo
387
- Object.keys(packageInfoList).forEach((name) =&gt; {
388
- let pkgInfo = packageInfoList[name];
389
- if (!excludeFn || !excludeFn(pkgInfo)) {
390
- result.push(pkgInfo);
391
- }
392
- });
393
- }
394
-
395
- result.sort(lexicographically).forEach((pkgInfo) =&gt; pushUnique(addonPackageList, pkgInfo));
396
-
397
- return addonPackageList;
398
- }
399
-
400
- /**
401
- * Discover the child addons for this packageInfo, which corresponds to an Addon.
402
- *
403
- * @method discoverAddonAddons
404
- */
405
- discoverAddonAddons() {
406
- let addonPackageList = [];
407
-
408
- this.addPackages(
409
- addonPackageList,
410
- this.dependencyPackages,
411
- (pkgInfo) =&gt; !pkgInfo.isForAddon() || pkgInfo.name === &#x27;ember-cli&#x27;
412
- );
413
- this.addPackages(addonPackageList, this.inRepoAddons);
414
-
415
- return addonPackageList;
416
- }
417
-
418
- /**
419
- * Discover the child addons for this packageInfo, which corresponds to a Project.
420
- *
421
- * @method discoverProjectAddons
422
- */
423
- discoverProjectAddons() {
424
- let project = this.project;
425
-
426
- let addonPackageList = [];
427
-
428
- this.addPackages(addonPackageList, project.isEmberCLIAddon() ? [this] : null);
429
- this.addPackages(addonPackageList, this.cliInfo ? this.cliInfo.inRepoAddons : null);
430
- this.addPackages(addonPackageList, this.internalAddons);
431
- this.addPackages(addonPackageList, this.devDependencyPackages, (pkgInfo) =&gt; !pkgInfo.isForAddon());
432
- this.addPackages(addonPackageList, this.dependencyPackages, (pkgInfo) =&gt; !pkgInfo.isForAddon());
433
- this.addPackages(addonPackageList, this.inRepoAddons);
434
-
435
- return addonPackageList;
436
- }
437
-
438
- /**
439
- * Given a list of PackageInfo objects, generate the &#x27;addonPackages&#x27; object (keyed by
440
- * name, value = AddonInfo instance, for all packages marked &#x27;valid&#x27;). This is stored in
441
- * both Addon and Project instances.
442
- *
443
- * @method generateAddonPackages
444
- * @param {Array} addonPackageList the list of child addon PackageInfos to work from
445
- * @param {Function} excludeFn an optional function. If passed in, each child PackageInfo
446
- * will be tested against the function and only included in the package map if the function
447
- * returns a truthy value.
448
- */
449
- generateAddonPackages(addonPackageList, excludeFn) {
450
- let validPackages = this.getValidPackages(addonPackageList);
451
-
452
- let packageMap = Object.create(null);
453
-
454
- validPackages.forEach((pkgInfo) =&gt; {
455
- let addonInfo = new AddonInfo(pkgInfo.name, pkgInfo.realPath, pkgInfo.pkg);
456
- if (!excludeFn || !excludeFn(addonInfo)) {
457
- packageMap[pkgInfo.name] = addonInfo;
458
- }
459
- });
460
-
461
- return packageMap;
462
- }
463
-
464
- getValidPackages(addonPackageList) {
465
- return addonPackageList.filter((pkgInfo) =&gt; pkgInfo.valid);
466
- }
467
-
468
- getInvalidPackages(addonPackageList) {
469
- return addonPackageList.filter((pkgInfo) =&gt; !pkgInfo.valid);
470
- }
471
-
472
- dumpInvalidAddonPackages(addonPackageList) {
473
- if (this._hasDumpedInvalidAddonPackages) {
474
- return;
475
- }
476
- this._hasDumpedInvalidAddonPackages = true;
477
-
478
- let invalidPackages = this.getInvalidPackages(addonPackageList);
479
-
480
- if (invalidPackages.length &gt; 0) {
481
- let typeName = this.project ? &#x27;project&#x27; : &#x27;addon&#x27;;
482
-
483
- let msg = &#x60;The &#x27;package.json&#x27; file for the ${typeName} at ${this.realPath}&#x60;;
484
-
485
- let relativePath;
486
- if (invalidPackages.length === 1) {
487
- relativePath = path.relative(this.realPath, invalidPackages[0].realPath);
488
- msg = &#x60;${msg}\n specifies an invalid, malformed or missing addon at relative path &#x27;${relativePath}&#x27;&#x60;;
489
- } else {
490
- msg = &#x60;${msg}\n specifies invalid, malformed or missing addons at relative paths&#x60;;
491
- invalidPackages.forEach((packageInfo) =&gt; {
492
- let relativePath = path.relative(this.realPath, packageInfo.realPath);
493
- msg = &#x60;${msg}\n &#x27;${relativePath}&#x27;&#x60;;
494
- });
495
- }
496
-
497
- if (process.env.EMBER_CLI_ERROR_ON_INVALID_ADDON) {
498
- throw msg;
499
- } else {
500
- this.cache.ui.writeWarnLine(msg);
501
- }
502
- }
503
- }
504
-
505
- /**
506
- * This is only supposed to be called by the addon instantiation code.
507
- * Also, the assumption here is that this PackageInfo really is for an
508
- * Addon, so we don&#x27;t need to check each time.
509
- *
510
- * @private
511
- * @method getAddonConstructor
512
- * @return {AddonConstructor} an instance of a constructor function for the Addon class
513
- * whose package information is stored in this object.
514
- */
515
- getAddonConstructor() {
516
- if (this.addonConstructor) {
517
- return this.addonConstructor;
518
- }
519
-
520
- let module = this._getAddonEntryPoint();
521
- let mainDir = path.dirname(this.addonMainPath);
522
-
523
- let ctor;
524
-
525
- if (typeof module === &#x27;function&#x27;) {
526
- ctor = module;
527
- ctor.prototype.root = ctor.prototype.root || mainDir;
528
- ctor.prototype.packageRoot = ctor.prototype.packageRoot || this.realPath;
529
- ctor.prototype.pkg = ctor.prototype.pkg || this.pkg;
530
- } else {
531
- const Addon = require(&#x27;../addon&#x27;); // done here because of circular dependency
532
-
533
- ctor = Addon.extend(Object.assign({ root: mainDir, packageRoot: this.realPath, pkg: this.pkg }, module));
534
- }
535
-
536
- ctor._meta_ = {
537
- modulePath: this.addonMainPath,
538
- };
539
-
540
- return (this.addonConstructor = ctor);
541
- }
542
-
543
- /**
544
- * Construct an addon instance.
545
- *
546
- * NOTE: this does NOT call constructors for the child addons. That is left to
547
- * the caller to do, so they can insert any other logic they want.
548
- *
549
- * @private
550
- * @method constructAddonInstance
551
- * @param {Project|Addon} parent the parent that directly contains this addon
552
- * @param {Project} project the project that is/contains this addon
553
- */
554
- constructAddonInstance(parent, project) {
555
- let start = Date.now();
556
-
557
- let AddonConstructor = this.getAddonConstructor();
558
-
559
- let addonInstance;
560
-
561
- try {
562
- addonInstance = new AddonConstructor(parent, project);
563
- } catch (e) {
564
- if (parent &amp;&amp; parent.ui) {
565
- parent.ui.writeError(e);
566
- }
567
-
568
- const SilentError = require(&#x27;silent-error&#x27;);
569
- throw new SilentError(&#x60;An error occurred in the constructor for ${this.name} at ${this.realPath}&#x60;);
570
- }
571
-
572
- AddonConstructor._meta_.initializeIn = Date.now() - start;
573
- addonInstance.constructor = AddonConstructor;
574
-
575
- return addonInstance;
576
- }
577
-
578
- /**
579
- * Create an instance of the addon represented by this packageInfo or (if we
580
- * are supporting per-bundle caching and this is an allow-caching-per-bundle addon)
581
- * check if we should be creating a proxy instead.
582
- *
583
- * NOTE: we assume that the value of &#x27;allowCachingPerBundle&#x27; does not change between
584
- * calls to the constructor! A given addon is either allowing or not allowing caching
585
- * for an entire run.
586
- *
587
- * @method getAddonInstance
588
- * @param {} parent the addon/project that is to be the direct parent of the
589
- * addon instance created here
590
- * @param {*} project the project that is to contain this addon instance
591
- * @return {Object} the constructed instance of the addon
592
- */
593
- getAddonInstance(parent, project) {
594
- let addonEntryPointModule = this._getAddonEntryPoint();
595
- let addonInstance;
596
-
597
- if (
598
- PerBundleAddonCache.isEnabled() &amp;&amp;
599
- project &amp;&amp;
600
- project.perBundleAddonCache.allowCachingPerBundle(addonEntryPointModule)
601
- ) {
602
- addonInstance = project.perBundleAddonCache.getAddonInstance(parent, this);
603
- } else {
604
- addonInstance = this.constructAddonInstance(parent, project);
605
- this.initChildAddons(addonInstance);
606
- }
607
-
608
- return addonInstance;
609
- }
610
-
611
- /**
612
- * Initialize the child addons array of a newly-created addon instance. Normally when
613
- * an addon derives from Addon, child addons will be created during &#x27;setupRegistry&#x27; and
614
- * this code is essentially unnecessary. But if an addon is created with custom constructors
615
- * that don&#x27;t call &#x27;setupRegistry&#x27;, any child addons may not yet be initialized.
616
- *
617
- * @method initChildAddons
618
- * @param {Addon} addonInstance
619
- */
620
- initChildAddons(addonInstance) {
621
- if (addonInstance.initializeAddons) {
622
- addonInstance.initializeAddons();
623
- } else {
624
- addonInstance.addons = [];
625
- }
626
- }
627
-
628
- /**
629
- * Gets the addon entry point
630
- *
631
- * @method _getAddonEntryPoint
632
- * @return {Object|Function} The exported addon entry point
633
- * @private
634
- */
635
- _getAddonEntryPoint() {
636
- if (!this.addonMainPath) {
637
- throw new Error(&#x60;${this.pkg.name} at ${this.realPath} is missing its addon main file&#x60;);
638
- }
639
-
640
- // Load the addon.
641
- // TODO: Future work - allow a time budget for loading each addon and warn
642
- // or error for those that take too long.
643
- return require(this.addonMainPath);
644
- }
645
- }
646
-
647
- module.exports = PackageInfo;
648
- module.exports.lexicographically = lexicographically;
649
- module.exports.pushUnique = pushUnique;
650
-
651
- </pre>
652
-
653
- </div>
654
- </div>
655
- </div>
656
- </div>
657
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
658
- <script>prettyPrint();</script>
659
- <script src="../assets/js/yui-prettify.js"></script>
660
- </body>
661
- </html>