ember-cli 4.0.0 → 4.1.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 (114) hide show
  1. package/.github/workflows/ci.yml +4 -4
  2. package/CHANGELOG.md +42 -2
  3. package/blueprints/addon/additional-dev-dependencies.json +1 -1
  4. package/blueprints/addon/files/.github/workflows/ci.yml +0 -1
  5. package/blueprints/addon/files/.travis.yml +0 -1
  6. package/blueprints/addon/files/addon-config/ember-try.js +0 -13
  7. package/blueprints/app/files/config/environment.js +1 -1
  8. package/blueprints/app/files/package.json +6 -6
  9. package/docs/build/data.json +3 -3
  10. package/lib/models/host-info-cache.js +3 -5
  11. package/lib/models/per-bundle-addon-cache/index.js +2 -3
  12. package/lib/tasks/npm-task.js +1 -1
  13. package/lib/utilities/get-lang-arg.js +45 -45
  14. package/package.json +25 -25
  15. package/tests/helpers/mock-project.js +1 -1
  16. package/.github/ISSUE_TEMPLATE.md +0 -12
  17. package/.github/dependabot.yml +0 -15
  18. package/.github/workflows/coverage.yml +0 -31
  19. package/docs/analytics.md +0 -44
  20. package/docs/architecture.md +0 -316
  21. package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
  22. package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
  23. package/docs/assets/architecture/README.md +0 -5
  24. package/docs/brocfile-transition.md +0 -46
  25. package/docs/build/api.js +0 -44
  26. package/docs/build/assets/css/external-small.png +0 -0
  27. package/docs/build/assets/css/logo.png +0 -0
  28. package/docs/build/assets/css/main.css +0 -555
  29. package/docs/build/assets/favicon.ico +0 -0
  30. package/docs/build/assets/img/spinner.gif +0 -0
  31. package/docs/build/assets/index.html +0 -10
  32. package/docs/build/assets/js/api-filter.js +0 -56
  33. package/docs/build/assets/js/api-list.js +0 -255
  34. package/docs/build/assets/js/api-search.js +0 -98
  35. package/docs/build/assets/js/apidocs.js +0 -376
  36. package/docs/build/assets/js/yui-prettify.js +0 -17
  37. package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
  38. package/docs/build/assets/vendor/prettify/COPYING +0 -202
  39. package/docs/build/assets/vendor/prettify/README.html +0 -203
  40. package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
  41. package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
  42. package/docs/build/classes/Addon.html +0 -4318
  43. package/docs/build/classes/AmdTransformAddon.html +0 -202
  44. package/docs/build/classes/Blueprint.html +0 -4796
  45. package/docs/build/classes/Builder.html +0 -611
  46. package/docs/build/classes/CLI.html +0 -810
  47. package/docs/build/classes/Command.html +0 -1655
  48. package/docs/build/classes/DefaultPackager.html +0 -202
  49. package/docs/build/classes/EmberAddon.html +0 -2207
  50. package/docs/build/classes/EmberApp.html +0 -2225
  51. package/docs/build/classes/HardwareInfo.html +0 -620
  52. package/docs/build/classes/HistorySupportAddon.html +0 -203
  53. package/docs/build/classes/Instrumentation.html +0 -695
  54. package/docs/build/classes/NodeModulesList.html +0 -460
  55. package/docs/build/classes/NpmTask.html +0 -333
  56. package/docs/build/classes/PackageInfo.html +0 -1390
  57. package/docs/build/classes/PackageInfoCache.html +0 -963
  58. package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
  59. package/docs/build/classes/Project.html +0 -2083
  60. package/docs/build/classes/ServeFilesAddon.html +0 -260
  61. package/docs/build/classes/TestsServerAddon.html +0 -203
  62. package/docs/build/classes/WatcherAddon.html +0 -204
  63. package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
  64. package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
  65. package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
  66. package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
  67. package/docs/build/files/lib_cli_cli.js.html +0 -417
  68. package/docs/build/files/lib_models_addon-info.js.html +0 -112
  69. package/docs/build/files/lib_models_addon.js.html +0 -1866
  70. package/docs/build/files/lib_models_blueprint.js.html +0 -1678
  71. package/docs/build/files/lib_models_builder.js.html +0 -417
  72. package/docs/build/files/lib_models_command.js.html +0 -804
  73. package/docs/build/files/lib_models_hardware-info.js.html +0 -479
  74. package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
  75. package/docs/build/files/lib_models_installation-checker.js.html +0 -181
  76. package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
  77. package/docs/build/files/lib_models_instrumentation.js.html +0 -433
  78. package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
  79. package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
  80. package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
  81. package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
  82. package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
  83. package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
  84. package/docs/build/files/lib_models_project.js.html +0 -913
  85. package/docs/build/files/lib_models_task.js.html +0 -117
  86. package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
  87. package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
  88. package/docs/build/files/lib_tasks_serve.js.html +0 -207
  89. package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
  90. package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
  91. package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
  92. package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
  93. package/docs/build/files/lib_tasks_test-server.js.html +0 -167
  94. package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
  95. package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
  96. package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
  97. package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
  98. package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
  99. package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
  100. package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
  101. package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
  102. package/docs/build/index.html +0 -125
  103. package/docs/build/modules/ember-cli.html +0 -152
  104. package/docs/build/modules/is-lazy-engine.html +0 -106
  105. package/docs/build-concurrency.md +0 -15
  106. package/docs/build-pipeline-debugging.md +0 -33
  107. package/docs/code-coverage.md +0 -14
  108. package/docs/error-propagation.md +0 -136
  109. package/docs/experiments.md +0 -53
  110. package/docs/node-support.md +0 -43
  111. package/docs/perf-guide.md +0 -250
  112. package/docs/project_version_preprocessor.js +0 -8
  113. package/docs/sourcemaps.md +0 -60
  114. package/docs/yuidoc.json +0 -13
@@ -1,1426 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/broccoli/default-packager.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/broccoli/default-packager.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- const p = require(&#x27;ember-cli-preprocess-registry/preprocessors&#x27;);
86
- const path = require(&#x27;path&#x27;);
87
- const concat = require(&#x27;broccoli-concat&#x27;);
88
- const Funnel = require(&#x27;broccoli-funnel&#x27;);
89
- const BroccoliDebug = require(&#x27;broccoli-debug&#x27;);
90
- const mergeTrees = require(&#x27;./merge-trees&#x27;);
91
- const ConfigLoader = require(&#x27;broccoli-config-loader&#x27;);
92
- const UnwatchedDir = require(&#x27;broccoli-source&#x27;).UnwatchedDir;
93
- const ConfigReplace = require(&#x27;broccoli-config-replace&#x27;);
94
- const emberAppUtils = require(&#x27;../utilities/ember-app-utils&#x27;);
95
- const funnelReducer = require(&#x27;broccoli-funnel-reducer&#x27;);
96
- const addonProcessTree = require(&#x27;../utilities/addon-process-tree&#x27;);
97
-
98
- const preprocessCss = p.preprocessCss;
99
- const preprocessJs = p.preprocessJs;
100
- const preprocessTemplates = p.preprocessTemplates;
101
- const preprocessMinifyCss = p.preprocessMinifyCss;
102
-
103
- const DEFAULT_BOWER_PATH = &#x27;bower_components&#x27;;
104
- const DEFAULT_VENDOR_PATH = &#x27;vendor&#x27;;
105
- const EMBER_CLI_INTERNAL_FILES_PATH = &#x27;/vendor/ember-cli/&#x27;;
106
- const EMBER_CLI_FILES = [
107
- &#x27;app-boot.js&#x27;,
108
- &#x27;app-config.js&#x27;,
109
- &#x27;app-prefix.js&#x27;,
110
- &#x27;app-suffix.js&#x27;,
111
- &#x27;test-support-prefix.js&#x27;,
112
- &#x27;test-support-suffix.js&#x27;,
113
- &#x27;tests-prefix.js&#x27;,
114
- &#x27;tests-suffix.js&#x27;,
115
- &#x27;vendor-prefix.js&#x27;,
116
- &#x27;vendor-suffix.js&#x27;,
117
- ];
118
-
119
- const configReplacePatterns = emberAppUtils.configReplacePatterns;
120
-
121
- function callAddonsPreprocessTreeHook(project, type, tree) {
122
- return addonProcessTree(project, &#x27;preprocessTree&#x27;, type, tree);
123
- }
124
-
125
- function callAddonsPostprocessTreeHook(project, type, tree) {
126
- return addonProcessTree(project, &#x27;postprocessTree&#x27;, type, tree);
127
- }
128
-
129
- /*
130
- Creates an object with lists of files to be concatenated into &#x60;vendor.js&#x60; file.
131
-
132
- Given a map that looks like:
133
-
134
- &#x60;&#x60;&#x60;
135
- {
136
- &#x27;assets/vendor.js&#x27;: [
137
- &#x27;vendor/ember-cli-shims/app-shims.js&#x27;,
138
- &#x27;vendor/loader/loader.js&#x27;,
139
- &#x27;vendor/ember-resolver/legacy-shims.js&#x27;,
140
- ...
141
- ]
142
- }
143
- &#x60;&#x60;&#x60;
144
-
145
- Produces an object that looks like:
146
-
147
- &#x60;&#x60;&#x60;
148
- {
149
- headerFiles: [
150
- &#x27;vendor/ember-cli/vendor-prefix.js&#x27;,
151
- &#x27;vendor/loader/loader.js&#x27;,
152
- &#x27;vendor/ember/jquery/jquery.js&#x27;,
153
- &#x27;vendor/ember/ember.debug.js&#x27;,
154
- &#x27;vendor/ember-cli-shims/app-shims.js&#x27;,
155
- &#x27;vendor/ember-resolver/legacy-shims.js&#x27;
156
- ],
157
- inputFiles: [
158
- &#x27;addon-tree-output/**\/*.js&#x27;
159
- ],
160
- footerFiles: [
161
- &#x27;vendor/ember-cli/vendor-suffix.js&#x27;
162
- ],
163
- annotation: &#x27;Vendor JS&#x27;
164
- }
165
- &#x60;&#x60;&#x60;
166
-
167
- @private
168
- @method getVendorFiles
169
- @param {Object} files A list of files to include into &#x60;&lt;file-name&gt;.js&#x60;
170
- @param {Boolean} isMainVendorFile Boolean flag to indicate if we are dealing with &#x60;vendor.js&#x60; file
171
- @return {Object} An object with lists of files to be concatenated into &#x60;vendor.js&#x60; file.
172
- */
173
- function getVendorFiles(files, isMainVendorFile) {
174
- return {
175
- headerFiles: files,
176
- inputFiles: isMainVendorFile ? [&#x27;addon-tree-output/**/*.js&#x27;] : [],
177
- footerFiles: isMainVendorFile ? [&#x27;vendor/ember-cli/vendor-suffix.js&#x27;] : [],
178
- };
179
- }
180
-
181
- /**
182
- * Responsible for packaging Ember.js application.
183
- *
184
- * @class DefaultPackager
185
- * @constructor
186
- */
187
- module.exports = class DefaultPackager {
188
- constructor(options) {
189
- this._cachedTests = null;
190
- this._cachedBower = null;
191
- this._cachedVendor = null;
192
- this._cachedPublic = null;
193
- this._cachedConfig = null;
194
- this._cachedJavascript = null;
195
- this._cachedProcessedIndex = null;
196
- this._cachedTransformedTree = null;
197
- this._cachedProcessedStyles = null;
198
- this._cachedProcessedTemplates = null;
199
- this._cachedProcessedJavascript = null;
200
- this._cachedEmberCliInternalTree = null;
201
- this._cachedProcessedAdditionalAssets = null;
202
- this._cachedProcessedAppAndDependencies = null;
203
-
204
- this.options = options || {};
205
-
206
- this._debugTree = BroccoliDebug.buildDebugCallback(&#x27;default-packager&#x27;);
207
-
208
- this.env = this.options.env;
209
- this.name = this.options.name;
210
- this.autoRun = this.options.autoRun;
211
- this.project = this.options.project;
212
- this.registry = this.options.registry;
213
- this.sourcemaps = this.options.sourcemaps;
214
- this.minifyCSS = this.options.minifyCSS;
215
- this.distPaths = this.options.distPaths;
216
- this.areTestsEnabled = this.options.areTestsEnabled;
217
- this.styleOutputFiles = this.options.styleOutputFiles;
218
- this.scriptOutputFiles = this.options.scriptOutputFiles;
219
- this.storeConfigInMeta = this.options.storeConfigInMeta;
220
- this.customTransformsMap = this.options.customTransformsMap;
221
- this.additionalAssetPaths = this.options.additionalAssetPaths;
222
- this.vendorTestStaticStyles = this.options.vendorTestStaticStyles;
223
- this.legacyTestFilesToAppend = this.options.legacyTestFilesToAppend;
224
- }
225
-
226
- /*
227
- * Replaces variables in &#x60;index.html&#x60; file with values from
228
- * &#x60;config/environment.js&#x60; and returns a single tree that contains
229
- * &#x60;index.html&#x60; file with populated values.
230
- *
231
- * Input tree:
232
- *
233
- * &#x60;&#x60;&#x60;
234
- * /
235
- * ├── addon-tree-output/
236
- * ├── the-best-app-ever/
237
- * ├── bower_components/
238
- * └── vendor/
239
- * &#x60;&#x60;&#x60;
240
- *
241
- * Returns:
242
- *
243
- * &#x60;&#x60;&#x60;
244
- * /
245
- * └── index.html
246
- * &#x60;&#x60;&#x60;
247
- *
248
- * @private
249
- * @method processIndex
250
- * @param {BroccoliTree}
251
- * @return {BroccoliTree}
252
- */
253
- processIndex(tree) {
254
- if (this._cachedProcessedIndex === null) {
255
- let indexFilePath = this.distPaths.appHtmlFile;
256
-
257
- let index = new Funnel(tree, {
258
- allowEmtpy: true,
259
- include: [&#x60;${this.name}/index.html&#x60;],
260
- getDestinationPath: () =&gt; indexFilePath,
261
- annotation: &#x27;Classic: index.html&#x27;,
262
- });
263
-
264
- let patterns = configReplacePatterns({
265
- addons: this.project.addons,
266
- autoRun: this.autoRun,
267
- storeConfigInMeta: this.storeConfigInMeta,
268
- });
269
-
270
- this._cachedProcessedIndex = new ConfigReplace(index, this.packageConfig(), {
271
- configPath: path.join(this.name, &#x27;config&#x27;, &#x27;environments&#x27;, &#x60;${this.env}.json&#x60;),
272
- files: [indexFilePath],
273
- patterns,
274
- });
275
- }
276
-
277
- return this._cachedProcessedIndex;
278
- }
279
-
280
- /*
281
- * Combines compiled javascript, external files (node modules, bower
282
- * components), vendor files and processed configuration (based on the
283
- * environment) into a single tree.
284
- *
285
- * Input tree:
286
- *
287
- * &#x60;&#x60;&#x60;
288
- * /
289
- * ├── addon-tree-output/
290
- * ├── the-best-app-ever/
291
- * ├── bower_components/
292
- * └── vendor/
293
- * &#x60;&#x60;&#x60;
294
- *
295
- * Changes are made &quot;inline&quot; so the output tree has the same structure.
296
- *
297
- * @private
298
- * @method processAppAndDependencies
299
- * @param {BroccoliTree}
300
- * @return {BroccoliTree}
301
- */
302
- processAppAndDependencies(allTrees) {
303
- if (this._cachedProcessedAppAndDependencies === null) {
304
- let config = this.packageConfig();
305
- let internal = this.packageEmberCliInternalFiles();
306
- let appContentsWithCompiledTemplates = this._debugTree(
307
- this.processTemplates(allTrees),
308
- &#x27;app-and-deps:post-templates&#x27;
309
- );
310
-
311
- let trees = [allTrees, appContentsWithCompiledTemplates].filter(Boolean);
312
-
313
- let mergedTree = this._debugTree(
314
- mergeTrees(trees, {
315
- annotation: &#x27;TreeMerger (preprocessedApp &amp; templates)&#x27;,
316
- overwrite: true,
317
- }),
318
- &#x27;app-and-deps:merged&#x27;
319
- );
320
-
321
- let external = this.applyCustomTransforms(allTrees);
322
- let postprocessedApp = this.processJavascript(mergedTree);
323
-
324
- let sourceTrees = [external, postprocessedApp, config, internal];
325
-
326
- this._cachedProcessedAppAndDependencies = this._debugTree(
327
- mergeTrees(sourceTrees, {
328
- overwrite: true,
329
- annotation: &#x27;Processed Application and Dependencies&#x27;,
330
- }),
331
- &#x27;app-and-deps:final&#x27;
332
- );
333
- }
334
-
335
- return this._cachedProcessedAppAndDependencies;
336
- }
337
-
338
- /*
339
- * Adds additional assets to the results tree, given the following list:
340
- *
341
- * &#x60;&#x60;&#x60;
342
- * [{
343
- * src: &#x27;vendor/font-awesome/fonts&#x27;,
344
- * file: &#x27;FontAwesome.otf&#x27;,
345
- * dest: &#x27;fonts&#x27;
346
- * }]
347
- * &#x60;&#x60;&#x60;
348
- *
349
- * where &#x60;src&#x60; is a source path, &#x60;file&#x60; is a file name, and &#x60;dest&#x60; is a new
350
- * destination.
351
- *
352
- * @private
353
- * @method importAdditionalAssets
354
- * @param {BroccoliTree}
355
- * @return {BroccoliTree}
356
- */
357
- importAdditionalAssets(tree) {
358
- if (this._cachedProcessedAdditionalAssets === null) {
359
- let otherAssetTrees = funnelReducer(this.additionalAssetPaths).map((options) =&gt; {
360
- let files = options.include.join(&#x27;,&#x27;);
361
- options.annotation = &#x60;${options.srcDir}/{${files}} =&gt; ${options.destDir}/{${files}}&#x60;;
362
-
363
- return new Funnel(tree, options);
364
- });
365
-
366
- this._cachedProcessedAdditionalAssets = mergeTrees(otherAssetTrees, {
367
- annotation: &#x27;Processed Additional Assets&#x27;,
368
- });
369
- }
370
-
371
- return this._cachedProcessedAdditionalAssets;
372
- }
373
-
374
- /*
375
- * Runs all registered transformations on the passed in tree and returns the
376
- * result.
377
- *
378
- * Passed-in tree:
379
- *
380
- * &#x60;&#x60;&#x60;
381
- * /
382
- * ├── addon-tree-output/
383
- * ├── bower_components/
384
- * └── vendor/
385
- * &#x60;&#x60;&#x60;
386
- *
387
- * &#x60;customTransformsMap&#x60; has information about files that needed to be
388
- * transformed and the actual transformation functions that are executed.
389
- *
390
- * @private
391
- * @method applyCustomTransforms
392
- * @param {BroccoliTree} External (vendor) tree
393
- * @return {BroccoliTree}
394
- */
395
- applyCustomTransforms(externalTree) {
396
- if (this._cachedTransformedTree === null) {
397
- this._cachedTransformedTree = externalTree;
398
-
399
- for (let customTransformEntry of this.customTransformsMap) {
400
- let transformName = customTransformEntry[0];
401
- let transformConfig = customTransformEntry[1];
402
-
403
- let transformTree = new Funnel(this._cachedTransformedTree, {
404
- files: transformConfig.files,
405
- annotation: &#x60;Funnel (custom transform: ${transformName})&#x60;,
406
- });
407
-
408
- this._cachedTransformedTree = mergeTrees(
409
- [this._cachedTransformedTree, transformConfig.callback(transformTree, transformConfig.options)],
410
- {
411
- annotation: &#x60;TreeMerger (custom transform: ${transformName})&#x60;,
412
- overwrite: true,
413
- }
414
- );
415
- }
416
- }
417
-
418
- return this._cachedTransformedTree;
419
- }
420
-
421
- /*
422
- * Returns a single tree with &#x60;ember-cli&#x60; internal files with the following
423
- * structure:
424
- *
425
- * &#x60;&#x60;&#x60;
426
- * vendor/
427
- * └── ember-cli
428
- * ├── app-boot.js
429
- * ├── app-config.js
430
- * ├── app-prefix.js
431
- * ├── app-suffix.js
432
- * ├── test-support-suffix.js
433
- * ├── test-support-prefix.js
434
- * ├── tests-prefix.js
435
- * ├── tests-suffix.js
436
- * ├── vendor-prefix.js
437
- * └── vendor-suffix.js
438
- * &#x60;&#x60;&#x60;
439
- *
440
- * Note, that the contents of these files is being matched against several
441
- * internal &#x60;ember-cli&#x60; variables, such as:
442
- *
443
- * + &#x60;{{MODULE_PREFIX}}&#x60;
444
- * + different types of &#x60;{{content-for}}&#x60; (&#x60;{{content-for &#x27;app-boot&#x27;}}&#x60;)
445
- *
446
- * @private
447
- * @method packageEmberCliInternalFiles
448
- * @return {BroccoliTree}
449
- */
450
- packageEmberCliInternalFiles() {
451
- if (this._cachedEmberCliInternalTree === null) {
452
- let patterns = configReplacePatterns({
453
- addons: this.project.addons,
454
- autoRun: this.autoRun,
455
- storeConfigInMeta: this.storeConfigInMeta,
456
- });
457
-
458
- let configTree = this.packageConfig();
459
- let configPath = path.join(this.name, &#x27;config&#x27;, &#x27;environments&#x27;, &#x60;${this.env}.json&#x60;);
460
-
461
- let emberCLITree = new ConfigReplace(new UnwatchedDir(__dirname), configTree, {
462
- configPath,
463
- files: EMBER_CLI_FILES,
464
- patterns,
465
- });
466
-
467
- this._cachedEmberCliInternalTree = new Funnel(emberCLITree, {
468
- files: EMBER_CLI_FILES,
469
- destDir: EMBER_CLI_INTERNAL_FILES_PATH,
470
- annotation: &#x27;Packaged Ember CLI Internal Files&#x27;,
471
- });
472
- }
473
-
474
- return this._cachedEmberCliInternalTree;
475
- }
476
-
477
- /*
478
- * Runs pre/post-processors hooks on the template files and returns a single
479
- * tree with the processed templates.
480
- *
481
- * Given a tree:
482
- *
483
- * &#x60;&#x60;&#x60;
484
- * /
485
- * ├── addon-tree-output/
486
- * ├── bower_components/
487
- * ├── the-best-app-ever/
488
- * └── vendor/
489
- * &#x60;&#x60;&#x60;
490
- *
491
- * Returns:
492
- *
493
- * &#x60;&#x60;&#x60;
494
- * the-best-app-ever/
495
- * └── templates
496
- * ├── application.js
497
- * ├── error.js
498
- * ├── index.js
499
- * └── loading.js
500
- * &#x60;&#x60;&#x60;
501
- *
502
- * @private
503
- * @method processTemplates
504
- * @param {BroccoliTree} tree
505
- * @return {BroccoliTree}
506
- */
507
- processTemplates(inputTree) {
508
- if (this._cachedProcessedTemplates === null) {
509
- let appFiles = new Funnel(inputTree, {
510
- srcDir: &#x60;${this.name}/&#x60;,
511
- destDir: &#x60;${this.name}/&#x60;,
512
- annotation: &#x27;processTemplates: app files&#x27;,
513
- });
514
-
515
- let mergedTemplates = [appFiles];
516
-
517
- mergedTemplates = mergeTrees(mergedTemplates, {
518
- overwrite: true,
519
- annotation: &#x27;Templates&#x27;,
520
- });
521
- let preprocessedTemplatesFromAddons = callAddonsPreprocessTreeHook(this.project, &#x27;template&#x27;, mergedTemplates);
522
-
523
- this._cachedProcessedTemplates = callAddonsPostprocessTreeHook(
524
- this.project,
525
- &#x27;template&#x27;,
526
- preprocessTemplates(preprocessedTemplatesFromAddons, {
527
- registry: this.registry,
528
- treeType: &#x27;templates&#x27;,
529
- })
530
- );
531
- }
532
-
533
- return this._cachedProcessedTemplates;
534
- }
535
-
536
- /*
537
- * Runs pre/post-processors hooks on the javascript files and returns a single
538
- * tree with the processed javascript.
539
- *
540
- * Given a tree:
541
- *
542
- * &#x60;&#x60;&#x60;
543
- * /
544
- * ├── addon-tree-output/
545
- * ├── bower_components/
546
- * ├── the-best-app-ever/
547
- * └── vendor/
548
- * &#x60;&#x60;&#x60;
549
- *
550
- * Returns:
551
- *
552
- * &#x60;&#x60;&#x60;
553
- * the-best-app-ever/
554
- * ├── adapters
555
- * │ └── application.js
556
- * ├── app.js
557
- * ├── components
558
- * ├── controllers
559
- * ├── helpers
560
- * │ ├── and.js
561
- * │ ├── app-version.js
562
- * │ ├── await.js
563
- * │ ├── camelize.js
564
- * │ ├── cancel-all.js
565
- * │ ├── dasherize.js
566
- * │ ├── dec.js
567
- * │ ├── drop.js
568
- * │ └── eq.js
569
- * ...
570
- * &#x60;&#x60;&#x60;
571
- *
572
- * @private
573
- * @method processJavascript
574
- * @param {BroccoliTree} tree
575
- * @return {BroccoliTree}
576
- */
577
- processJavascript(tree) {
578
- if (this._cachedProcessedJavascript === null) {
579
- let javascript = new Funnel(tree, {
580
- srcDir: this.name,
581
- destDir: this.name,
582
- annotation: &#x27;&#x27;,
583
- });
584
- let app = callAddonsPreprocessTreeHook(this.project, &#x27;js&#x27;, javascript);
585
-
586
- let preprocessedApp = preprocessJs(app, &#x27;/&#x27;, this.name, {
587
- registry: this.registry,
588
- treeType: &#x27;app&#x27;,
589
- });
590
-
591
- this._cachedProcessedJavascript = callAddonsPostprocessTreeHook(this.project, &#x27;js&#x27;, preprocessedApp);
592
- }
593
-
594
- return this._cachedProcessedJavascript;
595
- }
596
-
597
- /*
598
- * Compiles application css files, runs pre/post-processors hooks on the them,
599
- * concatenates them into one application and vendor files and returns a
600
- * single tree.
601
- *
602
- * Given an input tree that looks like:
603
- *
604
- * &#x60;&#x60;&#x60;
605
- * addon-tree-output/
606
- * ...
607
- * bower_components/
608
- * hint.css/
609
- * ...
610
- * the-best-app-ever/
611
- * styles/
612
- * ...
613
- * vendor/
614
- * font-awesome/
615
- * ...
616
- * &#x60;&#x60;&#x60;
617
- *
618
- * Returns:
619
- *
620
- * &#x60;&#x60;&#x60;
621
- * assets/
622
- * the-best-app-ever.css
623
- * vendor.css
624
- * &#x60;&#x60;&#x60;
625
- *
626
- * @private
627
- * @method packageStyles
628
- * @return {BroccoliTree}
629
- */
630
- packageStyles(tree) {
631
- if (this._cachedProcessedStyles === null) {
632
- let cssMinificationEnabled = this.minifyCSS.enabled;
633
- let options = {
634
- outputPaths: this.distPaths.appCssFile,
635
- registry: this.registry,
636
- minifyCSS: this.minifyCSS.options,
637
- treeType: &#x27;styles&#x27;,
638
- };
639
-
640
- let stylesAndVendor = callAddonsPreprocessTreeHook(this.project, &#x27;css&#x27;, tree);
641
- stylesAndVendor = this._debugTree(stylesAndVendor, &#x27;mu-layout:addonsPreprocessTree:css&#x27;);
642
-
643
- let preprocessedStyles = preprocessCss(stylesAndVendor, &#x27;/app/styles&#x27;, &#x27;/assets&#x27;, options);
644
- preprocessedStyles = this._debugTree(preprocessedStyles, &#x27;mu-layout:preprocess:css&#x27;);
645
-
646
- let vendorStyles = [];
647
- for (let outputFile in this.styleOutputFiles) {
648
- let isMainVendorFile = outputFile === this.distPaths.vendorCssFile;
649
- let headerFiles = this.styleOutputFiles[outputFile];
650
- let inputFiles = isMainVendorFile ? [&#x27;addon-tree-output/**/__COMPILED_STYLES__/**/*.css&#x27;] : [];
651
-
652
- vendorStyles.push(
653
- concat(stylesAndVendor, {
654
- headerFiles,
655
- inputFiles,
656
- outputFile,
657
- allowNone: true,
658
- annotation: &#x60;Concat: Vendor Styles${outputFile}&#x60;,
659
- })
660
- );
661
- }
662
-
663
- vendorStyles = mergeTrees(vendorStyles, {
664
- annotation: &#x27;TreeMerger (vendorStyles)&#x27;,
665
- overwrite: true,
666
- });
667
-
668
- if (cssMinificationEnabled === true) {
669
- options.minifyCSS.registry = options.registry;
670
- preprocessedStyles = preprocessMinifyCss(preprocessedStyles, options.minifyCSS);
671
- vendorStyles = preprocessMinifyCss(vendorStyles, options.minifyCSS);
672
- }
673
-
674
- this._cachedProcessedStyles = callAddonsPostprocessTreeHook(
675
- this.project,
676
- &#x27;css&#x27;,
677
- mergeTrees([preprocessedStyles, vendorStyles], {
678
- annotation: &#x27;Packaged Styles&#x27;,
679
- })
680
- );
681
- }
682
-
683
- return this._cachedProcessedStyles;
684
- }
685
-
686
- /*
687
- * Given an input tree, returns a properly assembled Broccoli tree with bower
688
- * components.
689
- *
690
- * Given a tree:
691
- *
692
- * &#x60;&#x60;&#x60;
693
- * ├── ember.js/
694
- * ├── pusher/
695
- * └── raven-js/
696
- * &#x60;&#x60;&#x60;
697
- *
698
- * Returns:
699
- *
700
- * &#x60;&#x60;&#x60;
701
- * [bowerDirectory]/
702
- * ├── ember.js/
703
- * ├── pusher/
704
- * └── raven-js/
705
- * &#x60;&#x60;&#x60;
706
- *
707
- * @private
708
- * @method packageBower
709
- * @param {BroccoliTree} tree
710
- * @param {String} bowerDirectory Custom path to bower components
711
- */
712
- packageBower(tree, bowerDirectory) {
713
- if (this._cachedBower === null) {
714
- this._cachedBower = new Funnel(tree, {
715
- destDir: bowerDirectory || DEFAULT_BOWER_PATH,
716
- annotation: &#x27;Packaged Bower&#x27;,
717
- });
718
- }
719
-
720
- return this._cachedBower;
721
- }
722
-
723
- /*
724
- * Given an input tree, returns a properly assembled Broccoli tree with vendor
725
- * files.
726
- *
727
- * Given a tree:
728
- *
729
- * &#x60;&#x60;&#x60;
730
- * ├── babel-polyfill/
731
- * ├── ember-cli-shims/
732
- * ├── ember-load-initializers/
733
- * ├── ember-qunit/
734
- * ├── ember-resolver/
735
- * ├── sinon/
736
- * └── tether/
737
- * &#x60;&#x60;&#x60;
738
- *
739
- * Returns:
740
- *
741
- * &#x60;&#x60;&#x60;
742
- * vendor/
743
- * ├── babel-polyfill/
744
- * ├── ember-cli-shims/
745
- * ├── ember-load-initializers/
746
- * ├── ember-qunit/
747
- * ├── ember-resolver/
748
- * ├── sinon/
749
- * └── tether/
750
- * &#x60;&#x60;&#x60;
751
- *
752
- * @private
753
- * @method packageVendor
754
- * @param {BroccoliTree} tree
755
- */
756
- packageVendor(tree) {
757
- if (this._cachedVendor === null) {
758
- this._cachedVendor = new Funnel(tree, {
759
- destDir: DEFAULT_VENDOR_PATH,
760
- annotation: &#x27;Packaged Vendor&#x27;,
761
- });
762
- }
763
-
764
- return this._cachedVendor;
765
- }
766
-
767
- /*
768
- * Given an input tree, returns a properly assembled Broccoli tree with tests
769
- * files.
770
- *
771
- * Given a tree:
772
- *
773
- * &#x60;&#x60;&#x60;
774
- * addon-tree-output/
775
- * bower_components/
776
- * the-best-app-ever/
777
- * tests/
778
- * ├── acceptance/
779
- * ├── helpers/
780
- * ├── index.html
781
- * ├── integration/
782
- * ├── test-helper.js
783
- * └── unit/
784
- * &#x60;&#x60;&#x60;
785
- *
786
- * Returns:
787
- *
788
- * &#x60;&#x60;&#x60;
789
- * [name]/
790
- * └── tests
791
- * ├── acceptance/
792
- * ├── helpers/
793
- * ├── index.html
794
- * ├── integration/
795
- * ├── test-helper.js
796
- * └── unit/
797
- * &#x60;&#x60;&#x60;
798
- *
799
- * @private
800
- * @method processTests
801
- * @param {BroccoliTree} tree
802
- */
803
- processTests(tree) {
804
- if (this._cachedTests === null) {
805
- let addonTestSupportTree = new Funnel(tree, {
806
- srcDir: &#x27;tests/addon-test-support&#x27;,
807
- destDir: &#x27;addon-test-support&#x27;,
808
- });
809
-
810
- let testTree = new Funnel(tree, {
811
- srcDir: &#x27;tests&#x27;,
812
- exclude: [&#x27;addon-test-support/**/*&#x27;],
813
- });
814
-
815
- let treeToCompile = new Funnel(testTree, {
816
- destDir: &#x60;${this.name}/tests&#x60;,
817
- annotation: &#x27;Tests To Process&#x27;,
818
- });
819
-
820
- treeToCompile = callAddonsPreprocessTreeHook(this.project, &#x27;test&#x27;, treeToCompile);
821
-
822
- const inputPath = &#x27;/tests&#x27;;
823
- let preprocessedTests = preprocessJs(treeToCompile, inputPath, this.name, {
824
- registry: this.registry,
825
- treeType: &#x27;test&#x27;,
826
- });
827
-
828
- let mergedTestTrees = mergeTrees([addonTestSupportTree, preprocessedTests], {
829
- overwrite: true,
830
- annotation: &#x27;Packaged Tests&#x27;,
831
- });
832
-
833
- this._cachedTests = callAddonsPostprocessTreeHook(this.project, &#x27;test&#x27;, mergedTestTrees);
834
- }
835
-
836
- return this._cachedTests;
837
- }
838
-
839
- /*
840
- * Concatenates all test files into one, as follows:
841
- *
842
- * Given an input tree that looks like:
843
- *
844
- * &#x60;&#x60;&#x60;
845
- * addon-tree-output/
846
- * bower_components/
847
- * the-best-app-ever/
848
- * tests/
849
- * ├── acceptance/
850
- * ├── helpers/
851
- * ├── index.html
852
- * ├── integration/
853
- * ├── test-helper.js
854
- * └── unit/
855
- * vendor/
856
- * &#x60;&#x60;&#x60;
857
- *
858
- * Returns:
859
- *
860
- * &#x60;&#x60;&#x60;
861
- * assets/
862
- * tests.js
863
- * test.map (if sourcemaps are enabled)
864
- * test-support.js
865
- * test-support.map (if sourcemaps are enabled)
866
- * test-support.css
867
- * &#x60;&#x60;&#x60;
868
- *
869
- * @private
870
- * @method packageTests
871
- * @param {BroccoliTree}
872
- * @return {BroccoliTree}
873
- */
874
- packageTests(tree) {
875
- let coreTestTree = this.processTests(tree);
876
-
877
- let testIndex = this.processTestIndex(tree);
878
- let appTestTree = this.packageApplicationTests(coreTestTree);
879
- let testFilesTree = this.packageTestFiles(tree, coreTestTree);
880
-
881
- return mergeTrees([testIndex, appTestTree, testFilesTree], {
882
- annotation: &#x27;Packaged Tests&#x27;,
883
- });
884
- }
885
-
886
- /*
887
- * Replaces variables in &#x60;tests/index.html&#x60; file with values from
888
- * &#x60;config/environment.js&#x60; and returns a single tree that contains
889
- * &#x60;index.html&#x60; file with populated values.
890
- *
891
- * Input tree:
892
- *
893
- * &#x60;&#x60;&#x60;
894
- * /
895
- * ├── addon-tree-output/
896
- * ├── the-best-app-ever/
897
- * ├── bower_components/
898
- * ├── tests/
899
- * └── vendor/
900
- * &#x60;&#x60;&#x60;
901
- *
902
- * Returns:
903
- *
904
- * &#x60;&#x60;&#x60;
905
- * └── tests
906
- * └── index.html/
907
- * &#x60;&#x60;&#x60;
908
- *
909
- * @private
910
- * @method processTestIndex
911
- * @param {BroccoliTree}
912
- * @return {BroccoliTree}
913
- */
914
- processTestIndex(tree) {
915
- let index = new Funnel(tree, {
916
- srcDir: &#x27;/tests&#x27;,
917
- files: [&#x27;index.html&#x27;],
918
- destDir: &#x27;/tests&#x27;,
919
- annotation: &#x27;Funnel (test index)&#x27;,
920
- });
921
-
922
- let patterns = configReplacePatterns({
923
- addons: this.project.addons,
924
- autoRun: this.autoRun,
925
- storeConfigInMeta: this.storeConfigInMeta,
926
- });
927
-
928
- let configPath = path.join(this.name, &#x27;config&#x27;, &#x27;environments&#x27;, &#x27;test.json&#x27;);
929
-
930
- return new ConfigReplace(index, this.packageConfig(), {
931
- configPath,
932
- files: [&#x27;tests/index.html&#x27;],
933
- env: &#x27;test&#x27;,
934
- patterns,
935
- });
936
- }
937
-
938
- /*
939
- * Wraps application configuration into AMD module:
940
- *
941
- * &#x60;&#x60;&#x60;javascript
942
- * define(&#x27;the-best-app-ever/config/environment&#x27;, [], function() {
943
- * // read the meta tag that contains escaped configuration from
944
- * // &#x60;index.html&#x60; and return as an object
945
- * });
946
- * &#x60;&#x60;&#x60;
947
- *
948
- * Given a tree:
949
- *
950
- * &#x60;&#x60;&#x60;
951
- * environments/
952
- * ├── development.json
953
- * └── test.json
954
- * &#x60;&#x60;&#x60;
955
- *
956
- * Returns:
957
- *
958
- * &#x60;&#x60;&#x60;
959
- * └── vendor
960
- * └── ember-cli
961
- * └── app-config.js
962
- * &#x60;&#x60;&#x60;
963
- * @private
964
- * @method packageTestApplicationConfig
965
- */
966
- packageTestApplicationConfig() {
967
- let files = [&#x27;app-config.js&#x27;];
968
- let patterns = configReplacePatterns({
969
- addons: this.project.addons,
970
- autoRun: this.autoRun,
971
- storeConfigInMeta: this.storeConfigInMeta,
972
- });
973
-
974
- let configPath = path.join(this.name, &#x27;config&#x27;, &#x27;environments&#x27;, &#x60;test.json&#x60;);
975
- let emberCLITree = new ConfigReplace(new UnwatchedDir(__dirname), this.packageConfig(), {
976
- configPath,
977
- files,
978
- patterns,
979
- });
980
-
981
- return new Funnel(emberCLITree, {
982
- files,
983
- srcDir: &#x27;/&#x27;,
984
- destDir: &#x27;/vendor/ember-cli/&#x27;,
985
- annotation: &#x27;Funnel (test-app-config-tree)&#x27;,
986
- });
987
- }
988
-
989
- /*
990
- * Concatenates all application test files into one, as follows:
991
- *
992
- * Given an input tree that looks like:
993
- *
994
- * &#x60;&#x60;&#x60;
995
- * addon-tree-output/
996
- * bower_components/
997
- * the-best-app-ever/
998
- * tests/
999
- * ├── acceptance/
1000
- * ├── helpers/
1001
- * ├── index.html
1002
- * ├── integration/
1003
- * ├── test-helper.js
1004
- * └── unit/
1005
- * vendor/
1006
- * &#x60;&#x60;&#x60;
1007
- *
1008
- * Returns:
1009
- *
1010
- * &#x60;&#x60;&#x60;
1011
- * assets/
1012
- * tests.js
1013
- * test.map (if sourcemaps are enabled)
1014
- * &#x60;&#x60;&#x60;
1015
- *
1016
- * @private
1017
- * @method packageApplicationTests
1018
- * @param {BroccoliTree}
1019
- * @return {BroccoliTree}
1020
- */
1021
- packageApplicationTests(tree) {
1022
- let appTestTrees = []
1023
- .concat(this.packageEmberCliInternalFiles(), this.packageTestApplicationConfig(), tree)
1024
- .filter(Boolean);
1025
-
1026
- appTestTrees = mergeTrees(appTestTrees, {
1027
- overwrite: true,
1028
- annotation: &#x27;TreeMerger (appTestTrees)&#x27;,
1029
- });
1030
-
1031
- return concat(appTestTrees, {
1032
- inputFiles: [&#x27;**/tests/**/*.js&#x27;],
1033
- headerFiles: [&#x27;vendor/ember-cli/tests-prefix.js&#x27;],
1034
- footerFiles: [&#x27;vendor/ember-cli/app-config.js&#x27;, &#x27;vendor/ember-cli/tests-suffix.js&#x27;],
1035
- outputFile: this.distPaths.testJsFile,
1036
- annotation: &#x27;Concat: App Tests&#x27;,
1037
- sourceMapConfig: this.sourcemaps,
1038
- });
1039
- }
1040
-
1041
- /*
1042
- * Concatenates all test support files into one, as follows:
1043
- *
1044
- * Given an input tree that looks like:
1045
- *
1046
- * &#x60;&#x60;&#x60;
1047
- * addon-tree-output/
1048
- * bower_components/
1049
- * the-best-app-ever/
1050
- * tests/
1051
- * ├── acceptance/
1052
- * ├── helpers/
1053
- * ├── index.html
1054
- * ├── integration/
1055
- * ├── test-helper.js
1056
- * └── unit/
1057
- * vendor/
1058
- * &#x60;&#x60;&#x60;
1059
- *
1060
- * Returns:
1061
- *
1062
- * &#x60;&#x60;&#x60;
1063
- * assets/
1064
- * test-support.js
1065
- * test-support.map (if sourcemaps are enabled)
1066
- * test-support.css
1067
- * &#x60;&#x60;&#x60;
1068
- *
1069
- * @private
1070
- * @method packageTestFiles
1071
- * @return {BroccoliTree}
1072
- */
1073
- packageTestFiles(tree, coreTestTree) {
1074
- let testSupportPath = this.distPaths.testSupportJsFile;
1075
-
1076
- testSupportPath = testSupportPath.testSupport || testSupportPath;
1077
-
1078
- let emberCLITree = this.packageEmberCliInternalFiles();
1079
-
1080
- let headerFiles = [].concat(&#x27;vendor/ember-cli/test-support-prefix.js&#x27;, this.legacyTestFilesToAppend);
1081
-
1082
- let inputFiles = [&#x27;addon-test-support/**/*.js&#x27;];
1083
-
1084
- let footerFiles = [&#x27;vendor/ember-cli/test-support-suffix.js&#x27;];
1085
-
1086
- let external = this.applyCustomTransforms(tree);
1087
-
1088
- let baseMergedTree = mergeTrees([emberCLITree, tree, external, coreTestTree], {
1089
- overwrite: true,
1090
- });
1091
- let testJs = concat(baseMergedTree, {
1092
- headerFiles,
1093
- inputFiles,
1094
- footerFiles,
1095
- outputFile: testSupportPath,
1096
- annotation: &#x27;Concat: Test Support JS&#x27;,
1097
- allowNone: true,
1098
- sourceMapConfig: this.sourcemaps,
1099
- });
1100
-
1101
- let testemPath = path.join(__dirname, &#x27;testem&#x27;);
1102
- testemPath = path.dirname(testemPath);
1103
-
1104
- let testemTree = new Funnel(new UnwatchedDir(testemPath), {
1105
- files: [&#x27;testem.js&#x27;],
1106
- annotation: &#x27;Funnel (testem)&#x27;,
1107
- });
1108
-
1109
- let sourceTrees = [testemTree, testJs];
1110
-
1111
- if (this.vendorTestStaticStyles.length &gt; 0) {
1112
- sourceTrees.push(
1113
- concat(tree, {
1114
- headerFiles: this.vendorTestStaticStyles,
1115
- outputFile: this.distPaths.testSupportCssFile,
1116
- annotation: &#x27;Concat: Test Support CSS&#x27;,
1117
- sourceMapConfig: this.sourcemaps,
1118
- })
1119
- );
1120
- }
1121
-
1122
- return mergeTrees(sourceTrees, {
1123
- overwrite: true,
1124
- annotation: &#x27;TreeMerger (testFiles)&#x27;,
1125
- });
1126
- }
1127
-
1128
- /*
1129
- * Returns a flattened input tree.
1130
- *
1131
- * Given a tree:
1132
- *
1133
- * &#x60;&#x60;&#x60;
1134
- * public
1135
- * ├── crossdomain.xml
1136
- * ├── ember-fetch
1137
- * ├── favicon.ico
1138
- * ├── images
1139
- * └── robots.txt
1140
- * &#x60;&#x60;&#x60;
1141
- *
1142
- * Returns:
1143
- *
1144
- * &#x60;&#x60;&#x60;
1145
- * ├── crossdomain.xml
1146
- * ├── ember-fetch
1147
- * ├── favicon.ico
1148
- * ├── images
1149
- * └── robots.txt
1150
- * &#x60;&#x60;&#x60;
1151
- *
1152
- * @private
1153
- * @method packagePublic
1154
- * @param {BroccoliTree} tree
1155
- * @return {BroccoliTree}
1156
- */
1157
- packagePublic(tree) {
1158
- if (this._cachedPublic === null) {
1159
- this._cachedPublic = new Funnel(tree, {
1160
- srcDir: &#x27;public&#x27;,
1161
- destDir: &#x27;.&#x27;,
1162
- });
1163
- }
1164
-
1165
- return this._cachedPublic;
1166
- }
1167
-
1168
- /*
1169
- * Given an input tree, returns a properly assembled Broccoli tree with
1170
- * configuration files.
1171
- *
1172
- * Given a tree:
1173
- *
1174
- * &#x60;&#x60;&#x60;
1175
- * environments/
1176
- * ├── development.json
1177
- * └── test.json
1178
- * &#x60;&#x60;&#x60;
1179
- *
1180
- * Returns:
1181
- *
1182
- * &#x60;&#x60;&#x60;
1183
- * └── [name]
1184
- * └── config
1185
- * └── environments
1186
- * ├── development.json
1187
- * └── test.json
1188
- * &#x60;&#x60;&#x60;
1189
- * @private
1190
- * @method packageConfig
1191
- */
1192
- packageConfig() {
1193
- let env = this.env;
1194
- let name = this.name;
1195
- let project = this.project;
1196
- let configPath = this.project.configPath();
1197
-
1198
- if (this._cachedConfig === null) {
1199
- let configTree = new ConfigLoader(path.dirname(configPath), {
1200
- env,
1201
- tests: this.areTestsEnabled || false,
1202
- project,
1203
- });
1204
-
1205
- this._cachedConfig = new Funnel(configTree, {
1206
- destDir: &#x60;${name}/config&#x60;,
1207
- annotation: &#x27;Packaged Config&#x27;,
1208
- });
1209
- }
1210
-
1211
- return this._cachedConfig;
1212
- }
1213
-
1214
- /*
1215
- * Concatenates all javascript Broccoli trees into one, as follows:
1216
- *
1217
- * Given an input tree that looks like:
1218
- *
1219
- * &#x60;&#x60;&#x60;
1220
- * addon-tree-output/
1221
- * ember-ajax/
1222
- * ember-data/
1223
- * ember-engines/
1224
- * ember-resolver/
1225
- * ...
1226
- * bower_components/
1227
- * usertiming/
1228
- * sinonjs/
1229
- * ...
1230
- * the-best-app-ever/
1231
- * components/
1232
- * config/
1233
- * helpers/
1234
- * routes/
1235
- * ...
1236
- * vendor/
1237
- * ...
1238
- * babel-core/
1239
- * ...
1240
- * broccoli-concat/
1241
- * ...
1242
- * ember-cli-template-lint/
1243
- * ...
1244
- * &#x60;&#x60;&#x60;
1245
- *
1246
- * Returns:
1247
- *
1248
- * &#x60;&#x60;&#x60;
1249
- * assets/
1250
- * the-best-app-ever.js
1251
- * the-best-app-ever.map (if sourcemaps are enabled)
1252
- * vendor.js
1253
- * vendor.map (if sourcemaps are enabled)
1254
- * &#x60;&#x60;&#x60;
1255
- *
1256
- * @private
1257
- * @method packageJavascript
1258
- * @return {BroccoliTree}
1259
- */
1260
- packageJavascript(tree) {
1261
- if (this._cachedJavascript === null) {
1262
- let applicationJs = this.processAppAndDependencies(tree);
1263
-
1264
- let vendorFilePath = this.distPaths.vendorJsFile;
1265
- this.scriptOutputFiles[vendorFilePath].unshift(&#x27;vendor/ember-cli/vendor-prefix.js&#x27;);
1266
-
1267
- let appJs = this.packageApplicationJs(applicationJs);
1268
- let vendorJs = this.packageVendorJs(applicationJs);
1269
-
1270
- this._cachedJavascript = mergeTrees([appJs, vendorJs], {
1271
- overwrite: true,
1272
- annotation: &#x27;Packaged Javascript&#x27;,
1273
- });
1274
- }
1275
-
1276
- return this._cachedJavascript;
1277
- }
1278
-
1279
- /*
1280
- * Concatenates all application&#x27;s javascript Broccoli trees into one, as follows:
1281
- *
1282
- * Given an input tree that looks like:
1283
- *
1284
- * &#x60;&#x60;&#x60;
1285
- * addon-tree-output/
1286
- * ember-ajax/
1287
- * ember-data/
1288
- * ember-engines/
1289
- * ember-resolver/
1290
- * ...
1291
- * bower_components/
1292
- * usertiming/
1293
- * sinonjs/
1294
- * ...
1295
- * the-best-app-ever/
1296
- * components/
1297
- * config/
1298
- * helpers/
1299
- * routes/
1300
- * ...
1301
- * vendor/
1302
- * ...
1303
- * babel-core/
1304
- * ...
1305
- * broccoli-concat/
1306
- * ...
1307
- * ember-cli-template-lint/
1308
- * ...
1309
- * &#x60;&#x60;&#x60;
1310
- *
1311
- * Returns:
1312
- *
1313
- * &#x60;&#x60;&#x60;
1314
- * assets/
1315
- * the-best-app-ever.js
1316
- * the-best-app-ever.map (if sourcemaps are enabled)
1317
- * &#x60;&#x60;&#x60;
1318
- *
1319
- * @private
1320
- * @method packageApplicationJs
1321
- * @return {BroccoliTree}
1322
- */
1323
- packageApplicationJs(tree) {
1324
- let inputFiles = [&#x60;${this.name}/**/*.js&#x60;];
1325
- let headerFiles = [&#x27;vendor/ember-cli/app-prefix.js&#x27;];
1326
- let footerFiles = [
1327
- &#x27;vendor/ember-cli/app-suffix.js&#x27;,
1328
- &#x27;vendor/ember-cli/app-config.js&#x27;,
1329
- &#x27;vendor/ember-cli/app-boot.js&#x27;,
1330
- ];
1331
-
1332
- return concat(tree, {
1333
- inputFiles,
1334
- headerFiles,
1335
- footerFiles,
1336
- outputFile: this.distPaths.appJsFile,
1337
- annotation: &#x27;Packaged Application Javascript&#x27;,
1338
- separator: &#x27;\n;&#x27;,
1339
- sourceMapConfig: this.sourcemaps,
1340
- });
1341
- }
1342
-
1343
- /*
1344
- * Concatenates all application&#x27;s vendor javascript Broccoli trees into one, as follows:
1345
- *
1346
- * Given an input tree that looks like:
1347
- * &#x60;&#x60;&#x60;
1348
- * addon-tree-output/
1349
- * ember-ajax/
1350
- * ember-data/
1351
- * ember-engines/
1352
- * ember-resolver/
1353
- * ...
1354
- * bower_components/
1355
- * usertiming/
1356
- * sinonjs/
1357
- * ...
1358
- * the-best-app-ever/
1359
- * components/
1360
- * config/
1361
- * helpers/
1362
- * routes/
1363
- * ...
1364
- * vendor/
1365
- * ...
1366
- * babel-core/
1367
- * ...
1368
- * broccoli-concat/
1369
- * ...
1370
- * ember-cli-template-lint/
1371
- * ...
1372
- * &#x60;&#x60;&#x60;
1373
- *
1374
- * Returns:
1375
- *
1376
- * &#x60;&#x60;&#x60;
1377
- * assets/
1378
- * vendor.js
1379
- * vendor.map (if sourcemaps are enabled)
1380
- * &#x60;&#x60;&#x60;
1381
- *
1382
- * @method packageVendorJs
1383
- * @param {BroccoliTree} tree
1384
- * @return {BroccoliTree}
1385
- */
1386
- packageVendorJs(tree) {
1387
- let importPaths = Object.keys(this.scriptOutputFiles);
1388
-
1389
- // iterate over the keys and concat files
1390
- // to support scenarios like
1391
- // app.import(&#x27;vendor/foobar.js&#x27;, { outputFile: &#x27;assets/baz.js&#x27; });
1392
- let vendorTrees = importPaths.map((importPath) =&gt; {
1393
- let files = this.scriptOutputFiles[importPath];
1394
- let isMainVendorFile = importPath === this.distPaths.vendorJsFile;
1395
-
1396
- const vendorObject = getVendorFiles(files, isMainVendorFile);
1397
-
1398
- return concat(tree, {
1399
- inputFiles: vendorObject.inputFiles,
1400
- headerFiles: vendorObject.headerFiles,
1401
- footerFiles: vendorObject.footerFiles,
1402
- outputFile: importPath,
1403
- annotation: &#x60;Package ${importPath}&#x60;,
1404
- separator: &#x27;\n;&#x27;,
1405
- sourceMapConfig: this.sourcemaps,
1406
- });
1407
- });
1408
-
1409
- return mergeTrees(vendorTrees, {
1410
- overwrite: true,
1411
- annotation: &#x27;Packaged Vendor Javascript&#x27;,
1412
- });
1413
- }
1414
- };
1415
-
1416
- </pre>
1417
-
1418
- </div>
1419
- </div>
1420
- </div>
1421
- </div>
1422
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
1423
- <script>prettyPrint();</script>
1424
- <script src="../assets/js/yui-prettify.js"></script>
1425
- </body>
1426
- </html>