@@ -10,14 +10,6 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app'); // eslint-disable-
1010const Plugin = require ( 'broccoli-plugin' ) ;
1111const walkSync = require ( 'walk-sync' ) ;
1212
13- const DEFAULT_PROJECTS = {
14- main : {
15- tree : null ,
16- include : null ,
17- includeTrees : [ 'addon' ]
18- }
19- }
20-
2113module . exports = {
2214 name : 'ember-cli-addon-docs' ,
2315
@@ -95,7 +87,7 @@ module.exports = {
9587 }
9688
9789 this . addonOptions = Object . assign ( { } , includer . options [ 'ember-cli-addon-docs' ] ) ;
98- this . addonOptions . projects = Object . assign ( { } , DEFAULT_PROJECTS , this . addonOptions . projects ) ;
90+ this . addonOptions . projects = Object . assign ( { } , this . addonOptions . projects ) ;
9991
10092 includer . options . includeFileExtensionInSnippetNames = includer . options . includeFileExtensionInSnippetNames || false ;
10193 includer . options . snippetSearchPaths = includer . options . snippetSearchPaths || [ 'tests/dummy/app' ] ;
@@ -182,35 +174,10 @@ module.exports = {
182174 let project = this . project ;
183175 let docsTrees = [ ] ;
184176
185- for ( let projectName in this . addonOptions . projects ) {
186- let docProject = this . addonOptions . projects [ projectName ] ;
187-
188- let addonSourceTree ;
189-
190- if ( docProject . tree ) {
191- addonSourceTree = docProject . tree ;
192- } else {
193- let include = docProject . include || [ ] ;
194- let includeTrees = docProject . includeTrees || [ ] ;
195-
196- let includeTreePaths = includeTrees . map ( t => parentAddon . treePaths [ t ] ) ;
197- let includeFunnels = [
198- // We need to be very careful to avoid triggering a watch on the addon root here
199- // because of https://github.com/nodejs/node/issues/15683
200- new Funnel ( new UnwatchedDir ( parentAddon . root ) , {
201- include : [ 'package.json' , 'README.md' ]
202- } )
203- ] ;
204-
205- for ( let path of include . concat ( includeTreePaths ) ) {
206- let fullPath = `${ parentAddon . root } /${ path } ` ;
207- if ( fs . existsSync ( fullPath ) ) {
208- includeFunnels . push ( new Funnel ( fullPath , { destDir : path } ) ) ;
209- }
210- }
177+ this . addonOptions . projects . main = this . addonOptions . projects . main || generateDefaultProject ( parentAddon ) ;
211178
212- addonSourceTree = new MergeTrees ( includeFunnels ) ;
213- }
179+ for ( let projectName in this . addonOptions . projects ) {
180+ let addonSourceTree = this . addonOptions . projects [ projectName ] ;
214181
215182 let pluginRegistry = new PluginRegistry ( project ) ;
216183
@@ -279,6 +246,33 @@ function findImporter(addon) {
279246 }
280247}
281248
249+ function generateDefaultProject ( parentAddon ) {
250+ let includeFunnels = [
251+ // We need to be very careful to avoid triggering a watch on the addon root here
252+ // because of https://github.com/nodejs/node/issues/15683
253+ new Funnel ( new UnwatchedDir ( parentAddon . root ) , {
254+ include : [ 'package.json' , 'README.md' ]
255+ } )
256+ ] ;
257+
258+ let addonTreePath = path . join ( parentAddon . root , parentAddon . treePaths [ 'addon' ] ) ;
259+ let testSupportPath = path . join ( parentAddon . root , parentAddon . treePaths [ 'addon-test-support' ] ) ;
260+
261+ if ( fs . existsSync ( addonTreePath ) ) {
262+ includeFunnels . push ( new Funnel ( addonTreePath , {
263+ destDir : parentAddon . name
264+ } ) ) ;
265+ }
266+
267+ if ( fs . existsSync ( testSupportPath ) ) {
268+ includeFunnels . push ( new Funnel ( testSupportPath , {
269+ destDir : `${ parentAddon . name } /test-support`
270+ } ) ) ;
271+ }
272+
273+ return new MergeTrees ( includeFunnels ) ;
274+ }
275+
282276class FindDummyAppFiles extends Plugin {
283277 build ( ) {
284278 let addonPath = this . inputPaths [ 0 ] ;
0 commit comments