@@ -11,7 +11,6 @@ const fs = require('fs-extra');
11
11
const _ = require ( 'lodash' ) ;
12
12
let logger = require ( 'heimdalljs-logger' ) ( 'ember-cli:project' ) ;
13
13
const nodeModulesPath = require ( 'node-modules-path' ) ;
14
- const heimdall = require ( 'heimdalljs' ) ;
15
14
16
15
let processCwd = process . cwd ( ) ;
17
16
// ensure NULL_PROJECT is a singleton
@@ -89,16 +88,10 @@ class Project {
89
88
return false ;
90
89
} ;
91
90
92
- NULL_PROJECT . isEmberCLIAddon = function ( ) {
93
- return false ;
94
- } ;
95
-
96
91
NULL_PROJECT . name = function ( ) {
97
92
return path . basename ( process . cwd ( ) ) ;
98
93
} ;
99
94
100
- NULL_PROJECT . initializeAddons ( ) ;
101
-
102
95
return NULL_PROJECT ;
103
96
}
104
97
@@ -126,15 +119,6 @@ class Project {
126
119
|| '@angular/cli' in this . dependencies ( ) ;
127
120
}
128
121
129
- /**
130
- Returns whether or not this is an Ember CLI addon.
131
- @method isEmberCLIAddon
132
- @return {Boolean } Whether or not this is an Ember CLI Addon.
133
- */
134
- isEmberCLIAddon ( ) {
135
- return ! ! this . pkg . keywords && this . pkg . keywords . indexOf ( 'ember-addon' ) > - 1 ;
136
- }
137
-
138
122
/**
139
123
Loads the configuration for this project and its addons.
140
124
@public
@@ -143,8 +127,6 @@ class Project {
143
127
@return {Object } Merged confiration object
144
128
*/
145
129
config ( env ) {
146
- this . initializeAddons ( ) ;
147
-
148
130
let initialConfig = { } ;
149
131
150
132
return this . addons . reduce ( ( config , addon ) => {
@@ -231,139 +213,6 @@ class Project {
231
213
return _ . assign ( { } , devDependencies , pkg [ 'dependencies' ] ) ;
232
214
}
233
215
234
- /**
235
- Provides the list of paths to consult for addons that may be provided
236
- internally to this project. Used for middleware addons with built-in support.
237
- @private
238
- @method supportedInternalAddonPaths
239
- */
240
- supportedInternalAddonPaths ( ) {
241
- if ( ! this . root ) { return [ ] ; }
242
-
243
- let internalMiddlewarePath = path . join ( __dirname , '../tasks/server/middleware' ) ;
244
- let legacyBlueprintsPath = require . resolve ( 'ember-cli-legacy-blueprints' ) ;
245
- let emberTryPath = require . resolve ( 'ember-try' ) ;
246
- return [
247
- path . join ( internalMiddlewarePath , 'testem-url-rewriter' ) ,
248
- path . join ( internalMiddlewarePath , 'tests-server' ) ,
249
- path . join ( internalMiddlewarePath , 'history-support' ) ,
250
- path . join ( internalMiddlewarePath , 'broccoli-watcher' ) ,
251
- path . join ( internalMiddlewarePath , 'broccoli-serve-files' ) ,
252
- path . join ( internalMiddlewarePath , 'proxy-server' ) ,
253
- path . dirname ( legacyBlueprintsPath ) ,
254
- path . dirname ( emberTryPath ) ,
255
- ] ;
256
- }
257
-
258
- /**
259
- Loads and initializes all addons for this project.
260
- @private
261
- @method initializeAddons
262
- */
263
- initializeAddons ( ) {
264
- if ( this . _addonsInitialized ) {
265
- return ;
266
- }
267
- this . _addonsInitialized = true ;
268
-
269
- logger . info ( 'initializeAddons for: %s' , this . name ( ) ) ;
270
- }
271
-
272
- /**
273
- Returns what commands are made available by addons by inspecting
274
- `includedCommands` for every addon.
275
- @private
276
- @method addonCommands
277
- @return {Object } Addon names and command maps as key-value pairs
278
- */
279
- addonCommands ( ) {
280
- const Command = require ( '../models/command' ) ;
281
- let commands = { } ;
282
- this . addons . forEach ( addon => {
283
- if ( ! addon . includedCommands ) { return ; }
284
-
285
- let token = heimdall . start ( {
286
- name : `lookup-commands: ${ addon . name } ` ,
287
- addonName : addon . name ,
288
- addonCommandInitialization : true ,
289
- } ) ;
290
-
291
- let includedCommands = addon . includedCommands ( ) ;
292
- let addonCommands = { } ;
293
-
294
- for ( let key in includedCommands ) {
295
- if ( typeof includedCommands [ key ] === 'function' ) {
296
- addonCommands [ key ] = includedCommands [ key ] ;
297
- } else {
298
- addonCommands [ key ] = Command . extend ( includedCommands [ key ] ) ;
299
- }
300
- }
301
- if ( Object . keys ( addonCommands ) . length ) {
302
- commands [ addon . name ] = addonCommands ;
303
- }
304
-
305
- token . stop ( ) ;
306
- } ) ;
307
- return commands ;
308
- }
309
-
310
- /**
311
- Execute a given callback for every addon command.
312
- Example:
313
- ```
314
- project.eachAddonCommand(function(addonName, commands) {
315
- console.log('Addon ' + addonName + ' exported the following commands:' + commands.keys().join(', '));
316
- });
317
- ```
318
- @private
319
- @method eachAddonCommand
320
- @param {Function } callback [description]
321
- */
322
- eachAddonCommand ( callback ) {
323
- if ( this . initializeAddons && this . addonCommands ) {
324
- this . initializeAddons ( ) ;
325
- let addonCommands = this . addonCommands ( ) ;
326
-
327
- _ . forOwn ( addonCommands , ( commands , addonName ) => callback ( addonName , commands ) ) ;
328
- }
329
- }
330
-
331
- /**
332
- Path to the blueprints for this project.
333
- @private
334
- @method localBlueprintLookupPath
335
- @return {String } Path to blueprints
336
- */
337
- localBlueprintLookupPath ( ) {
338
- return path . join ( this . cli . root , 'blueprints' ) ;
339
- }
340
-
341
- /**
342
- Returns a list of paths (including addon paths) where blueprints will be looked up.
343
- @private
344
- @method blueprintLookupPaths
345
- @return {Array } List of paths
346
- */
347
- blueprintLookupPaths ( ) {
348
- return [ this . localBlueprintLookupPath ( ) ] ;
349
- }
350
-
351
- /**
352
- Returns a list of addon paths where blueprints will be looked up.
353
- @private
354
- @method addonBlueprintLookupPaths
355
- @return {Array } List of paths
356
- */
357
- addonBlueprintLookupPaths ( ) {
358
- let addonPaths = this . addons . map ( addon => {
359
- if ( addon . blueprintsPath ) {
360
- return addon . blueprintsPath ( ) ;
361
- }
362
- } , this ) ;
363
-
364
- return addonPaths . filter ( Boolean ) . reverse ( ) ;
365
- }
366
-
367
216
/**
368
217
Reloads package.json
369
218
@private
@@ -379,62 +228,6 @@ class Project {
379
228
return this . pkg ;
380
229
}
381
230
382
- /**
383
- Re-initializes addons.
384
- @private
385
- @method reloadAddons
386
- */
387
- reloadAddons ( ) {
388
- this . reloadPkg ( ) ;
389
- this . _addonsInitialized = false ;
390
- return this . initializeAddons ( ) ;
391
- }
392
-
393
- /**
394
- Find an addon by its name
395
- @private
396
- @method findAddonByName
397
- @param {String } name Addon name as specified in package.json
398
- @return {Addon } Addon instance
399
- */
400
- findAddonByName ( name ) {
401
- this . initializeAddons ( ) ;
402
-
403
- var exactMatch = _ . find ( this . addons , function ( addon ) {
404
- return name === addon . name || ( addon . pkg && name === addon . pkg . name ) ;
405
- } ) ;
406
-
407
- if ( exactMatch ) {
408
- return exactMatch ;
409
- }
410
-
411
- return _ . find ( this . addons , function ( addon ) {
412
- return name . indexOf ( addon . name ) > - 1 || ( addon . pkg && name . indexOf ( addon . pkg . name ) > - 1 ) ;
413
- } ) ;
414
- }
415
-
416
- /**
417
- Generate test file contents.
418
- This method is supposed to be overwritten by test framework addons
419
- like `ember-cli-qunit` and `ember-cli-mocha`.
420
- @public
421
- @method generateTestFile
422
- @param {String } moduleName Name of the test module (e.g. `JSHint`)
423
- @param {Object[] } tests Array of tests with `name`, `passed` and `errorMessage` properties
424
- @return {String } The test file content
425
- */
426
- generateTestFile ( ) {
427
- let message = 'Please install an Ember.js test framework addon or update your dependencies.' ;
428
-
429
- if ( this . ui ) {
430
- this . ui . writeDeprecateLine ( message ) ;
431
- } else {
432
- console . warn ( message ) ;
433
- }
434
-
435
- return '' ;
436
- }
437
-
438
231
/**
439
232
Returns a new project based on the first package.json that is found
440
233
in `pathName`.
0 commit comments