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.
- package/.github/workflows/ci.yml +4 -4
- package/CHANGELOG.md +42 -2
- package/blueprints/addon/additional-dev-dependencies.json +1 -1
- package/blueprints/addon/files/.github/workflows/ci.yml +0 -1
- package/blueprints/addon/files/.travis.yml +0 -1
- package/blueprints/addon/files/addon-config/ember-try.js +0 -13
- package/blueprints/app/files/config/environment.js +1 -1
- package/blueprints/app/files/package.json +6 -6
- package/docs/build/data.json +3 -3
- package/lib/models/host-info-cache.js +3 -5
- package/lib/models/per-bundle-addon-cache/index.js +2 -3
- package/lib/tasks/npm-task.js +1 -1
- package/lib/utilities/get-lang-arg.js +45 -45
- package/package.json +25 -25
- package/tests/helpers/mock-project.js +1 -1
- package/.github/ISSUE_TEMPLATE.md +0 -12
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/coverage.yml +0 -31
- package/docs/analytics.md +0 -44
- package/docs/architecture.md +0 -316
- package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
- package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
- package/docs/assets/architecture/README.md +0 -5
- package/docs/brocfile-transition.md +0 -46
- package/docs/build/api.js +0 -44
- package/docs/build/assets/css/external-small.png +0 -0
- package/docs/build/assets/css/logo.png +0 -0
- package/docs/build/assets/css/main.css +0 -555
- package/docs/build/assets/favicon.ico +0 -0
- package/docs/build/assets/img/spinner.gif +0 -0
- package/docs/build/assets/index.html +0 -10
- package/docs/build/assets/js/api-filter.js +0 -56
- package/docs/build/assets/js/api-list.js +0 -255
- package/docs/build/assets/js/api-search.js +0 -98
- package/docs/build/assets/js/apidocs.js +0 -376
- package/docs/build/assets/js/yui-prettify.js +0 -17
- package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
- package/docs/build/assets/vendor/prettify/COPYING +0 -202
- package/docs/build/assets/vendor/prettify/README.html +0 -203
- package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
- package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
- package/docs/build/classes/Addon.html +0 -4318
- package/docs/build/classes/AmdTransformAddon.html +0 -202
- package/docs/build/classes/Blueprint.html +0 -4796
- package/docs/build/classes/Builder.html +0 -611
- package/docs/build/classes/CLI.html +0 -810
- package/docs/build/classes/Command.html +0 -1655
- package/docs/build/classes/DefaultPackager.html +0 -202
- package/docs/build/classes/EmberAddon.html +0 -2207
- package/docs/build/classes/EmberApp.html +0 -2225
- package/docs/build/classes/HardwareInfo.html +0 -620
- package/docs/build/classes/HistorySupportAddon.html +0 -203
- package/docs/build/classes/Instrumentation.html +0 -695
- package/docs/build/classes/NodeModulesList.html +0 -460
- package/docs/build/classes/NpmTask.html +0 -333
- package/docs/build/classes/PackageInfo.html +0 -1390
- package/docs/build/classes/PackageInfoCache.html +0 -963
- package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
- package/docs/build/classes/Project.html +0 -2083
- package/docs/build/classes/ServeFilesAddon.html +0 -260
- package/docs/build/classes/TestsServerAddon.html +0 -203
- package/docs/build/classes/WatcherAddon.html +0 -204
- package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
- package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
- package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
- package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
- package/docs/build/files/lib_cli_cli.js.html +0 -417
- package/docs/build/files/lib_models_addon-info.js.html +0 -112
- package/docs/build/files/lib_models_addon.js.html +0 -1866
- package/docs/build/files/lib_models_blueprint.js.html +0 -1678
- package/docs/build/files/lib_models_builder.js.html +0 -417
- package/docs/build/files/lib_models_command.js.html +0 -804
- package/docs/build/files/lib_models_hardware-info.js.html +0 -479
- package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
- package/docs/build/files/lib_models_installation-checker.js.html +0 -181
- package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
- package/docs/build/files/lib_models_instrumentation.js.html +0 -433
- package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
- package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
- package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
- package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
- package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
- package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
- package/docs/build/files/lib_models_project.js.html +0 -913
- package/docs/build/files/lib_models_task.js.html +0 -117
- package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
- package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
- package/docs/build/files/lib_tasks_serve.js.html +0 -207
- package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
- package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
- package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
- package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
- package/docs/build/files/lib_tasks_test-server.js.html +0 -167
- package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
- package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
- package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
- package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
- package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
- package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
- package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
- package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
- package/docs/build/index.html +0 -125
- package/docs/build/modules/ember-cli.html +0 -152
- package/docs/build/modules/is-lazy-engine.html +0 -106
- package/docs/build-concurrency.md +0 -15
- package/docs/build-pipeline-debugging.md +0 -33
- package/docs/code-coverage.md +0 -14
- package/docs/error-propagation.md +0 -136
- package/docs/experiments.md +0 -53
- package/docs/node-support.md +0 -43
- package/docs/perf-guide.md +0 -250
- package/docs/project_version_preprocessor.js +0 -8
- package/docs/sourcemaps.md +0 -60
- 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-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/package-info-cache/package-info.js</h1>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<pre class="code prettyprint linenums">
|
|
83
|
-
'use strict';
|
|
84
|
-
|
|
85
|
-
const path = require('path');
|
|
86
|
-
const ErrorList = require('./error-list');
|
|
87
|
-
const Errors = require('./errors');
|
|
88
|
-
const AddonInfo = require('../addon-info');
|
|
89
|
-
const isAddon = require('../../utilities/is-addon');
|
|
90
|
-
const isEngine = require('../../utilities/is-engine');
|
|
91
|
-
const isLazyEngine = require('../../utilities/is-lazy-engine');
|
|
92
|
-
const logger = require('heimdalljs-logger')('ember-cli:package-info-cache:package-info');
|
|
93
|
-
const PerBundleAddonCache = require('../per-bundle-addon-cache');
|
|
94
|
-
|
|
95
|
-
function lexicographically(a, b) {
|
|
96
|
-
const aIsString = typeof a.name === 'string';
|
|
97
|
-
const bIsString = typeof b.name === 'string';
|
|
98
|
-
|
|
99
|
-
if (aIsString && 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 > -1) {
|
|
114
|
-
// the entry already exists in the array, but since the presedence between
|
|
115
|
-
// addons is "last right wins". 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 "least surprising" 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['ember-addon'] = this.pkg['ember-addon'] || {};
|
|
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'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're an ember addon, that we have a valid 'main' 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
|
-
* "internal" addons (note: not in-repo addons) only exist in
|
|
224
|
-
* Projects, not other packages. Since the cache is loaded from
|
|
225
|
-
* 'loadProject', 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 'dependencies' or 'devDependencies'
|
|
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) => {
|
|
278
|
-
logger.info('%s: Trying to find dependency %o', 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's
|
|
284
|
-
// quicker since we have the reference. Only check externally
|
|
285
|
-
// if we don'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 > 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 && this.project.isEmberCLIProject && 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 & 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() && 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) => !excludeFn(pkgInfo));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
packageInfoList.forEach((pkgInfo) => result.push(pkgInfo));
|
|
385
|
-
} else {
|
|
386
|
-
// We're going to assume we have a map of name to packageInfo
|
|
387
|
-
Object.keys(packageInfoList).forEach((name) => {
|
|
388
|
-
let pkgInfo = packageInfoList[name];
|
|
389
|
-
if (!excludeFn || !excludeFn(pkgInfo)) {
|
|
390
|
-
result.push(pkgInfo);
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
result.sort(lexicographically).forEach((pkgInfo) => 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) => !pkgInfo.isForAddon() || pkgInfo.name === 'ember-cli'
|
|
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) => !pkgInfo.isForAddon());
|
|
432
|
-
this.addPackages(addonPackageList, this.dependencyPackages, (pkgInfo) => !pkgInfo.isForAddon());
|
|
433
|
-
this.addPackages(addonPackageList, this.inRepoAddons);
|
|
434
|
-
|
|
435
|
-
return addonPackageList;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Given a list of PackageInfo objects, generate the 'addonPackages' object (keyed by
|
|
440
|
-
* name, value = AddonInfo instance, for all packages marked 'valid'). 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) => {
|
|
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) => pkgInfo.valid);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
getInvalidPackages(addonPackageList) {
|
|
469
|
-
return addonPackageList.filter((pkgInfo) => !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 > 0) {
|
|
481
|
-
let typeName = this.project ? 'project' : 'addon';
|
|
482
|
-
|
|
483
|
-
let msg = `The 'package.json' file for the ${typeName} at ${this.realPath}`;
|
|
484
|
-
|
|
485
|
-
let relativePath;
|
|
486
|
-
if (invalidPackages.length === 1) {
|
|
487
|
-
relativePath = path.relative(this.realPath, invalidPackages[0].realPath);
|
|
488
|
-
msg = `${msg}\n specifies an invalid, malformed or missing addon at relative path '${relativePath}'`;
|
|
489
|
-
} else {
|
|
490
|
-
msg = `${msg}\n specifies invalid, malformed or missing addons at relative paths`;
|
|
491
|
-
invalidPackages.forEach((packageInfo) => {
|
|
492
|
-
let relativePath = path.relative(this.realPath, packageInfo.realPath);
|
|
493
|
-
msg = `${msg}\n '${relativePath}'`;
|
|
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'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 === 'function') {
|
|
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('../addon'); // 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 && parent.ui) {
|
|
565
|
-
parent.ui.writeError(e);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
const SilentError = require('silent-error');
|
|
569
|
-
throw new SilentError(`An error occurred in the constructor for ${this.name} at ${this.realPath}`);
|
|
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 'allowCachingPerBundle' 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() &&
|
|
599
|
-
project &&
|
|
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 'setupRegistry' and
|
|
614
|
-
* this code is essentially unnecessary. But if an addon is created with custom constructors
|
|
615
|
-
* that don't call 'setupRegistry', 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(`${this.pkg.name} at ${this.realPath} is missing its addon main file`);
|
|
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>
|