ember-cli 4.0.0 → 4.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/.github/workflows/ci.yml +8 -4
  2. package/CHANGELOG.md +43 -2
  3. package/README.md +1 -1
  4. package/blueprints/addon/additional-dev-dependencies.json +1 -1
  5. package/blueprints/addon/files/CONTRIBUTING.md +1 -1
  6. package/blueprints/app/files/README.md +2 -2
  7. package/blueprints/app/files/package.json +8 -8
  8. package/docs/build/data.json +64 -3
  9. package/lib/debug/assert.js +37 -0
  10. package/lib/debug/deprecate.js +111 -0
  11. package/lib/debug/index.js +6 -0
  12. package/lib/models/host-info-cache.js +3 -5
  13. package/lib/models/per-bundle-addon-cache/index.js +2 -3
  14. package/lib/tasks/npm-task.js +1 -1
  15. package/lib/utilities/get-lang-arg.js +45 -45
  16. package/package.json +31 -31
  17. package/.github/ISSUE_TEMPLATE.md +0 -12
  18. package/.github/dependabot.yml +0 -15
  19. package/.github/workflows/coverage.yml +0 -31
  20. package/docs/analytics.md +0 -44
  21. package/docs/architecture.md +0 -316
  22. package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
  23. package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
  24. package/docs/assets/architecture/README.md +0 -5
  25. package/docs/brocfile-transition.md +0 -46
  26. package/docs/build/api.js +0 -44
  27. package/docs/build/assets/css/external-small.png +0 -0
  28. package/docs/build/assets/css/logo.png +0 -0
  29. package/docs/build/assets/css/main.css +0 -555
  30. package/docs/build/assets/favicon.ico +0 -0
  31. package/docs/build/assets/img/spinner.gif +0 -0
  32. package/docs/build/assets/index.html +0 -10
  33. package/docs/build/assets/js/api-filter.js +0 -56
  34. package/docs/build/assets/js/api-list.js +0 -255
  35. package/docs/build/assets/js/api-search.js +0 -98
  36. package/docs/build/assets/js/apidocs.js +0 -376
  37. package/docs/build/assets/js/yui-prettify.js +0 -17
  38. package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
  39. package/docs/build/assets/vendor/prettify/COPYING +0 -202
  40. package/docs/build/assets/vendor/prettify/README.html +0 -203
  41. package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
  42. package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
  43. package/docs/build/classes/Addon.html +0 -4318
  44. package/docs/build/classes/AmdTransformAddon.html +0 -202
  45. package/docs/build/classes/Blueprint.html +0 -4796
  46. package/docs/build/classes/Builder.html +0 -611
  47. package/docs/build/classes/CLI.html +0 -810
  48. package/docs/build/classes/Command.html +0 -1655
  49. package/docs/build/classes/DefaultPackager.html +0 -202
  50. package/docs/build/classes/EmberAddon.html +0 -2207
  51. package/docs/build/classes/EmberApp.html +0 -2225
  52. package/docs/build/classes/HardwareInfo.html +0 -620
  53. package/docs/build/classes/HistorySupportAddon.html +0 -203
  54. package/docs/build/classes/Instrumentation.html +0 -695
  55. package/docs/build/classes/NodeModulesList.html +0 -460
  56. package/docs/build/classes/NpmTask.html +0 -333
  57. package/docs/build/classes/PackageInfo.html +0 -1390
  58. package/docs/build/classes/PackageInfoCache.html +0 -963
  59. package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
  60. package/docs/build/classes/Project.html +0 -2083
  61. package/docs/build/classes/ServeFilesAddon.html +0 -260
  62. package/docs/build/classes/TestsServerAddon.html +0 -203
  63. package/docs/build/classes/WatcherAddon.html +0 -204
  64. package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
  65. package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
  66. package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
  67. package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
  68. package/docs/build/files/lib_cli_cli.js.html +0 -417
  69. package/docs/build/files/lib_models_addon-info.js.html +0 -112
  70. package/docs/build/files/lib_models_addon.js.html +0 -1866
  71. package/docs/build/files/lib_models_blueprint.js.html +0 -1678
  72. package/docs/build/files/lib_models_builder.js.html +0 -417
  73. package/docs/build/files/lib_models_command.js.html +0 -804
  74. package/docs/build/files/lib_models_hardware-info.js.html +0 -479
  75. package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
  76. package/docs/build/files/lib_models_installation-checker.js.html +0 -181
  77. package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
  78. package/docs/build/files/lib_models_instrumentation.js.html +0 -433
  79. package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
  80. package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
  81. package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
  82. package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
  83. package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
  84. package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
  85. package/docs/build/files/lib_models_project.js.html +0 -913
  86. package/docs/build/files/lib_models_task.js.html +0 -117
  87. package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
  88. package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
  89. package/docs/build/files/lib_tasks_serve.js.html +0 -207
  90. package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
  91. package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
  92. package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
  93. package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
  94. package/docs/build/files/lib_tasks_test-server.js.html +0 -167
  95. package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
  96. package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
  97. package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
  98. package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
  99. package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
  100. package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
  101. package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
  102. package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
  103. package/docs/build/index.html +0 -125
  104. package/docs/build/modules/ember-cli.html +0 -152
  105. package/docs/build/modules/is-lazy-engine.html +0 -106
  106. package/docs/build-concurrency.md +0 -15
  107. package/docs/build-pipeline-debugging.md +0 -33
  108. package/docs/code-coverage.md +0 -14
  109. package/docs/error-propagation.md +0 -136
  110. package/docs/experiments.md +0 -53
  111. package/docs/node-support.md +0 -43
  112. package/docs/perf-guide.md +0 -250
  113. package/docs/project_version_preprocessor.js +0 -8
  114. package/docs/sourcemaps.md +0 -60
  115. package/docs/yuidoc.json +0 -13
@@ -1,463 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/tasks/npm-task.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/tasks/npm-task.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- // Runs &#x60;npm install&#x60; in cwd
86
-
87
- const chalk = require(&#x27;chalk&#x27;);
88
- const execa = require(&#x27;../utilities/execa&#x27;);
89
- const findUp = require(&#x27;find-up&#x27;);
90
- const semver = require(&#x27;semver&#x27;);
91
- const SilentError = require(&#x27;silent-error&#x27;);
92
- const isYarnProject = require(&#x27;../utilities/is-yarn-project&#x27;);
93
-
94
- const logger = require(&#x27;heimdalljs-logger&#x27;)(&#x27;ember-cli:npm-task&#x27;);
95
-
96
- const Task = require(&#x27;../models/task&#x27;);
97
-
98
- class NpmTask extends Task {
99
- /**
100
- * @private
101
- * @class NpmTask
102
- * @constructor
103
- * @param {Object} options
104
- */
105
- constructor(options) {
106
- super(options);
107
-
108
- // The command to run: can be &#x27;install&#x27; or &#x27;uninstall&#x27;
109
- this.command = &#x27;&#x27;;
110
-
111
- this.versionConstraints = &#x27;3 || 4 || 5 || 6&#x27;;
112
- }
113
-
114
- get packageManagerOutputName() {
115
- return this.packageManager.name;
116
- }
117
-
118
- npm(args) {
119
- logger.info(&#x27;npm: %j&#x27;, args);
120
- return execa(&#x27;npm&#x27;, args, { preferLocal: false });
121
- }
122
-
123
- yarn(args) {
124
- logger.info(&#x27;yarn: %j&#x27;, args);
125
- return execa(&#x27;yarn&#x27;, args, { preferLocal: false });
126
- }
127
-
128
- pnpm(args) {
129
- logger.info(&#x27;pnpm: %j&#x27;, args);
130
- return execa(&#x27;pnpm&#x27;, args, { preferLocal: false });
131
- }
132
-
133
- hasYarnLock() {
134
- return isYarnProject(this.project.root);
135
- }
136
-
137
- async hasPNPMLock() {
138
- return Boolean(await findUp(&#x27;pnpm-lock.yaml&#x27;, { cwd: this.project.root }));
139
- }
140
-
141
- async checkYarn() {
142
- try {
143
- let result = await this.yarn([&#x27;--version&#x27;]);
144
- let version = result.stdout;
145
-
146
- if (semver.gte(version, &#x27;2.0.0&#x27;)) {
147
- logger.warn(&#x27;yarn --version: %s&#x27;, version);
148
- this.ui.writeWarnLine(&#x60;Yarn v2 is not fully supported. Proceeding with yarn: ${version}&#x60;);
149
- } else {
150
- logger.info(&#x27;yarn --version: %s&#x27;, version);
151
- }
152
-
153
- return { name: &#x27;yarn&#x27;, version };
154
- } catch (error) {
155
- logger.error(&#x27;yarn --version failed: %s&#x27;, error);
156
-
157
- if (error.code === &#x27;ENOENT&#x27;) {
158
- throw new SilentError(
159
- &#x27;Ember CLI is now using yarn, but was not able to find it.\n&#x27; +
160
- &#x27;Please install yarn using the instructions at https://classic.yarnpkg.com/en/docs/install&#x27;
161
- );
162
- }
163
-
164
- throw error;
165
- }
166
- }
167
-
168
- async checkPNPM() {
169
- try {
170
- let result = await this.pnpm([&#x27;--version&#x27;]);
171
- let version = result.stdout;
172
-
173
- logger.info(&#x27;pnpm --version: %s&#x27;, version);
174
-
175
- return { name: &#x27;pnpm&#x27;, version };
176
- } catch (error) {
177
- logger.error(&#x27;pnpm --version failed: %s&#x27;, error);
178
-
179
- if (error.code === &#x27;ENOENT&#x27;) {
180
- throw new SilentError(
181
- &#x27;Ember CLI is now using pnpm, but was not able to find it.\n&#x27; +
182
- &#x27;Please install pnpm using the instructions at https://pnpm.io/installation&#x27;
183
- );
184
- }
185
-
186
- throw error;
187
- }
188
- }
189
-
190
- async checkNpmVersion() {
191
- try {
192
- let result = await this.npm([&#x27;--version&#x27;]);
193
- let version = result.stdout;
194
- logger.info(&#x27;npm --version: %s&#x27;, version);
195
-
196
- let ok = semver.satisfies(version, this.versionConstraints);
197
- if (!ok) {
198
- logger.warn(&#x27;npm --version is outside of version constraint: %s&#x27;, this.versionConstraints);
199
-
200
- let below = semver.ltr(version, this.versionConstraints);
201
- if (below) {
202
- throw new SilentError(
203
- &#x27;Ember CLI is now using the global npm, but your npm version is outdated.\n&#x27; +
204
- &#x27;Please update your global npm version by running: npm install -g npm&#x27;
205
- );
206
- }
207
-
208
- this.ui.writeWarnLine(
209
- &#x27;Ember CLI is using the global npm, but your npm version has not yet been &#x27; +
210
- &#x27;verified to work with the current Ember CLI release.&#x27;
211
- );
212
- }
213
-
214
- return { name: &#x27;npm&#x27;, version };
215
- } catch (error) {
216
- logger.error(&#x27;npm --version failed: %s&#x27;, error);
217
-
218
- if (error.code === &#x27;ENOENT&#x27;) {
219
- throw new SilentError(
220
- &#x27;Ember CLI is now using the global npm, but was not able to find it.\n&#x27; +
221
- &#x27;Please install npm using the instructions at https://github.com/npm/npm&#x27;
222
- );
223
- }
224
-
225
- throw error;
226
- }
227
- }
228
-
229
- /**
230
- * This method will determine what package manager (npm or yarn) should be
231
- * used to install the npm dependencies.
232
- *
233
- * Setting &#x60;this.useYarn&#x60; to &#x60;true&#x60; or &#x60;false&#x60; will force the use of yarn
234
- * or npm respectively.
235
- *
236
- * If &#x60;this.useYarn&#x60; is not set we check if &#x60;yarn.lock&#x60; exists and if
237
- * &#x60;yarn&#x60; is available and in that case set &#x60;useYarn&#x60; to &#x60;true&#x60;.
238
- *
239
- * @private
240
- * @method findPackageManager
241
- * @return {Promise}
242
- */
243
- async findPackageManager(packageManager = null) {
244
- if (packageManager === &#x27;yarn&#x27;) {
245
- logger.info(&#x27;yarn requested -&gt; trying yarn&#x27;);
246
- return this.checkYarn();
247
- }
248
-
249
- if (packageManager === &#x27;npm&#x27;) {
250
- logger.info(&#x27;npm requested -&gt; using npm&#x27;);
251
- return this.checkNpmVersion();
252
- }
253
-
254
- if (packageManager === &#x27;pnpm&#x27;) {
255
- logger.info(&#x27;pnpm requested -&gt; using pnpm&#x27;);
256
- return this.checkPNPM();
257
- }
258
-
259
- if (this.hasYarnLock()) {
260
- logger.info(&#x27;yarn.lock found -&gt; trying yarn&#x27;);
261
- try {
262
- const yarnResult = await this.checkYarn();
263
- logger.info(&#x27;yarn found -&gt; using yarn&#x27;);
264
- return yarnResult;
265
- } catch (_err) {
266
- logger.info(&#x27;yarn not found&#x27;);
267
- }
268
- } else {
269
- logger.info(&#x27;yarn.lock not found&#x27;);
270
- }
271
-
272
- if (this.hasPNPMLock()) {
273
- logger.info(&#x27;pnpm-lock.yaml found -&gt; trying pnpm&#x27;);
274
- try {
275
- let result = await this.checkPNPM();
276
- logger.info(&#x27;pnpm found -&gt; using pnpm&#x27;);
277
- return result;
278
- } catch (_err) {
279
- logger.info(&#x27;pnpm not found&#x27;);
280
- }
281
- } else {
282
- logger.info(&#x27;pnpm-lock.yaml not found&#x27;);
283
- }
284
-
285
- logger.info(&#x27;using npm&#x27;);
286
- return this.checkNpmVersion();
287
- }
288
-
289
- async run(options) {
290
- this.packageManager = await this.findPackageManager(options.packageManager);
291
-
292
- let ui = this.ui;
293
- let startMessage = this.formatStartMessage(options.packages);
294
- let completeMessage = this.formatCompleteMessage(options.packages);
295
-
296
- const prependEmoji = require(&#x27;../../lib/utilities/prepend-emoji&#x27;);
297
-
298
- ui.writeLine(&#x27;&#x27;);
299
- ui.writeLine(prependEmoji(&#x27;🚧&#x27;, &#x27;Installing packages... This might take a couple of minutes.&#x27;));
300
- ui.startProgress(chalk.green(startMessage));
301
-
302
- try {
303
- if (this.packageManager.name === &#x27;yarn&#x27;) {
304
- let args = this.toYarnArgs(this.command, options);
305
- await this.yarn(args);
306
- } else if (this.packageManager.name === &#x27;pnpm&#x27;) {
307
- let args = this.toPNPMArgs(this.command, options);
308
- await this.pnpm(args);
309
- } else {
310
- let args = this.toNpmArgs(this.command, options);
311
- await this.npm(args);
312
-
313
- // as of 2018-10-09 npm 5 and 6 _break_ the hierarchy of &#x60;node_modules&#x60;
314
- // after a &#x60;npm install foo&#x60; (deletes files/folders other than
315
- // what was directly installed) in some circumstances, see:
316
- //
317
- // * https://github.com/npm/npm/issues/16853
318
- // * https://github.com/npm/npm/issues/17379
319
- //
320
- // this ensures that we run a full &#x60;npm install&#x60; **after** any &#x60;npm
321
- // install foo&#x60; runs to ensure that we have a fully functional
322
- // node_modules hierarchy
323
- let npmVersion = this.packageManager.version;
324
- if (npmVersion &amp;&amp; semver.lt(npmVersion, &#x27;5.7.1&#x27;)) {
325
- await this.npm([&#x27;install&#x27;]);
326
- }
327
- }
328
- } finally {
329
- ui.stopProgress();
330
- }
331
-
332
- ui.writeLine(chalk.green(completeMessage));
333
- }
334
-
335
- toNpmArgs(command, options) {
336
- let args = [command];
337
-
338
- if (options.save) {
339
- args.push(&#x27;--save&#x27;);
340
- }
341
-
342
- if (options[&#x27;save-dev&#x27;]) {
343
- args.push(&#x27;--save-dev&#x27;);
344
- }
345
-
346
- if (options[&#x27;save-exact&#x27;]) {
347
- args.push(&#x27;--save-exact&#x27;);
348
- }
349
-
350
- if (&#x27;optional&#x27; in options &amp;&amp; !options.optional) {
351
- args.push(&#x27;--no-optional&#x27;);
352
- }
353
-
354
- if (options.verbose) {
355
- args.push(&#x27;--loglevel&#x27;, &#x27;verbose&#x27;);
356
- } else {
357
- args.push(&#x27;--loglevel&#x27;, &#x27;error&#x27;);
358
- }
359
-
360
- if (options.packages) {
361
- args = args.concat(options.packages);
362
- }
363
-
364
- return args;
365
- }
366
-
367
- toYarnArgs(command, options) {
368
- let args = [];
369
-
370
- if (command === &#x27;install&#x27;) {
371
- if (options.save) {
372
- args.push(&#x27;add&#x27;);
373
- } else if (options[&#x27;save-dev&#x27;]) {
374
- args.push(&#x27;add&#x27;, &#x27;--dev&#x27;);
375
- } else if (options.packages) {
376
- throw new Error(&#x60;npm command &quot;${command} ${options.packages.join(&#x27; &#x27;)}&quot; can not be translated to Yarn command&#x60;);
377
- } else {
378
- args.push(&#x27;install&#x27;);
379
- }
380
-
381
- if (options[&#x27;save-exact&#x27;]) {
382
- args.push(&#x27;--exact&#x27;);
383
- }
384
-
385
- if (&#x27;optional&#x27; in options &amp;&amp; !options.optional) {
386
- args.push(&#x27;--ignore-optional&#x27;);
387
- }
388
- } else if (command === &#x27;uninstall&#x27;) {
389
- args.push(&#x27;remove&#x27;);
390
- } else {
391
- throw new Error(&#x60;npm command &quot;${command}&quot; can not be translated to Yarn command&#x60;);
392
- }
393
-
394
- if (options.verbose) {
395
- args.push(&#x27;--verbose&#x27;);
396
- }
397
-
398
- if (options.packages) {
399
- args = args.concat(options.packages);
400
- }
401
-
402
- // Yarn v2 defaults to non-interactive
403
- // with an optional -i flag
404
-
405
- if (semver.lt(this.packageManager.version, &#x27;2.0.0&#x27;)) {
406
- args.push(&#x27;--non-interactive&#x27;);
407
- }
408
-
409
- return args;
410
- }
411
-
412
- toPNPMArgs(command, options) {
413
- let args = [];
414
-
415
- if (command === &#x27;install&#x27;) {
416
- if (options.save) {
417
- args.push(&#x27;add&#x27;);
418
- } else if (options[&#x27;save-dev&#x27;]) {
419
- args.push(&#x27;add&#x27;, &#x27;--save-dev&#x27;);
420
- } else if (options.packages) {
421
- throw new Error(&#x60;npm command &quot;${command} ${options.packages.join(&#x27; &#x27;)}&quot; can not be translated to pnpm command&#x60;);
422
- } else {
423
- args.push(&#x27;install&#x27;);
424
- }
425
-
426
- if (options[&#x27;save-exact&#x27;]) {
427
- args.push(&#x27;--save-exact&#x27;);
428
- }
429
- } else if (command === &#x27;uninstall&#x27;) {
430
- args.push(&#x27;remove&#x27;);
431
- } else {
432
- throw new Error(&#x60;npm command &quot;${command}&quot; can not be translated to pnpm command&#x60;);
433
- }
434
-
435
- if (options.packages) {
436
- args = args.concat(options.packages);
437
- }
438
-
439
- return args;
440
- }
441
-
442
- formatStartMessage(/* packages */) {
443
- return &#x27;&#x27;;
444
- }
445
-
446
- formatCompleteMessage(/* packages */) {
447
- return &#x27;&#x27;;
448
- }
449
- }
450
-
451
- module.exports = NpmTask;
452
-
453
- </pre>
454
-
455
- </div>
456
- </div>
457
- </div>
458
- </div>
459
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
460
- <script>prettyPrint();</script>
461
- <script src="../assets/js/yui-prettify.js"></script>
462
- </body>
463
- </html>
@@ -1,207 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>lib/tasks/serve.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/tasks/serve.js</h1>
80
- </div>
81
-
82
- <pre class="code prettyprint linenums">
83
- &#x27;use strict&#x27;;
84
-
85
- const fs = require(&#x27;fs&#x27;);
86
- const path = require(&#x27;path&#x27;);
87
- const ExpressServer = require(&#x27;./server/express-server&#x27;);
88
- const Task = require(&#x27;../models/task&#x27;);
89
- const Watcher = require(&#x27;../models/watcher&#x27;);
90
- const ServerWatcher = require(&#x27;../models/server-watcher&#x27;);
91
- const Builder = require(&#x27;../models/builder&#x27;);
92
- const SilentError = require(&#x27;silent-error&#x27;);
93
- const serveURL = require(&#x27;../utilities/get-serve-url&#x27;);
94
- const pDefer = require(&#x27;p-defer&#x27;);
95
-
96
- function mockWatcher(distDir) {
97
- let watcher = Promise.resolve({ directory: distDir });
98
- watcher.on = () =&gt; {};
99
- return watcher;
100
- }
101
-
102
- function mockBuilder() {
103
- return {
104
- cleanup: () =&gt; Promise.resolve(),
105
- };
106
- }
107
-
108
- class ServeTask extends Task {
109
- constructor(options) {
110
- super(options);
111
-
112
- this._runDeferred = null;
113
- this._builder = null;
114
- }
115
-
116
- async run(options) {
117
- let hasBuild = !!options.path;
118
-
119
- if (hasBuild) {
120
- if (!fs.existsSync(options.path)) {
121
- throw new SilentError(
122
- &#x60;The path ${options.path} does not exist. Please specify a valid build directory to serve.&#x60;
123
- );
124
- }
125
- options._builder = mockBuilder();
126
- options._watcher = mockWatcher(options.path);
127
- }
128
-
129
- let builder = (this._builder =
130
- options._builder ||
131
- new Builder({
132
- ui: this.ui,
133
- outputPath: options.outputPath,
134
- project: this.project,
135
- environment: options.environment,
136
- }));
137
-
138
- let watcher =
139
- options._watcher ||
140
- new Watcher({
141
- ui: this.ui,
142
- builder,
143
- analytics: this.analytics,
144
- options,
145
- serving: true,
146
- ignored: [path.resolve(this.project.root, options.outputPath)],
147
- });
148
-
149
- let serverRoot = &#x27;./server&#x27;;
150
- let serverWatcher = null;
151
- if (fs.existsSync(serverRoot)) {
152
- serverWatcher = new ServerWatcher({
153
- ui: this.ui,
154
- analytics: this.analytics,
155
- watchedDir: path.resolve(serverRoot),
156
- options,
157
- });
158
- }
159
-
160
- let expressServer =
161
- options._expressServer ||
162
- new ExpressServer({
163
- ui: this.ui,
164
- project: this.project,
165
- analytics: this.analytics,
166
- watcher,
167
- serverRoot,
168
- serverWatcher,
169
- });
170
-
171
- /* hang until the user exits */
172
- this._runDeferred = pDefer();
173
-
174
- await expressServer.start(options);
175
-
176
- if (hasBuild) {
177
- this.ui.writeLine(&#x60;– Serving on ${serveURL(options, this.project)}&#x60;);
178
- }
179
-
180
- return this._runDeferred.promise;
181
- }
182
-
183
- /**
184
- * Exit silently
185
- *
186
- * @private
187
- * @method onInterrupt
188
- */
189
- async onInterrupt() {
190
- await this._builder.cleanup();
191
- return this._runDeferred.resolve();
192
- }
193
- }
194
-
195
- module.exports = ServeTask;
196
-
197
- </pre>
198
-
199
- </div>
200
- </div>
201
- </div>
202
- </div>
203
- <script src="../assets/vendor/prettify/prettify-min.js"></script>
204
- <script>prettyPrint();</script>
205
- <script src="../assets/js/yui-prettify.js"></script>
206
- </body>
207
- </html>