2
2
3
3
const fs = require ( 'fs' ) ;
4
4
const path = require ( 'path' ) ;
5
- const resolve = require ( 'resolve' ) ;
6
5
const UnwatchedDir = require ( 'broccoli-source' ) . UnwatchedDir ;
7
6
const MergeTrees = require ( 'broccoli-merge-trees' ) ;
8
7
const Funnel = require ( 'broccoli-funnel' ) ;
9
8
const EmberApp = require ( 'ember-cli/lib/broccoli/ember-app' ) ; // eslint-disable-line node/no-unpublished-require
10
9
const Plugin = require ( 'broccoli-plugin' ) ;
11
10
const walkSync = require ( 'walk-sync' ) ;
12
11
12
+ const LATEST_VERSION_NAME = '-latest' ;
13
+
13
14
module . exports = {
14
15
name : 'ember-cli-addon-docs' ,
15
16
17
+ LATEST_VERSION_NAME ,
18
+
16
19
options : {
17
- ace : {
18
- modes : [ 'handlebars' ]
19
- } ,
20
20
nodeAssets : {
21
21
'highlight.js' : {
22
22
public : {
@@ -42,6 +42,7 @@ module.exports = {
42
42
config ( env , baseConfig ) {
43
43
let repo = this . parent . pkg . repository ;
44
44
let info = require ( 'hosted-git-info' ) . fromUrl ( repo . url || repo ) ;
45
+ let userConfig = this . _readUserConfig ( ) ;
45
46
46
47
let config = {
47
48
'ember-component-css' : {
@@ -51,6 +52,8 @@ module.exports = {
51
52
projectName : this . parent . pkg . name ,
52
53
projectTag : this . parent . pkg . version ,
53
54
projectHref : info && info . browse ( ) ,
55
+ primaryBranch : userConfig . getPrimaryBranch ( ) ,
56
+ latestVersionName : LATEST_VERSION_NAME ,
54
57
deployVersion : 'ADDON_DOCS_DEPLOY_VERSION'
55
58
}
56
59
} ;
@@ -93,13 +96,12 @@ module.exports = {
93
96
includer . options . includeFileExtensionInSnippetNames = includer . options . includeFileExtensionInSnippetNames || false ;
94
97
includer . options . snippetSearchPaths = includer . options . snippetSearchPaths || [ 'tests/dummy/app' ] ;
95
98
includer . options . snippetRegexes = Object . assign ( { } , {
96
- begin : / { { # (?: d o c s - s n i p p e t | d e m o .e x a m p l e | d e m o . l i v e - e x a m p l e ) \s n a m e = (?: " | ' ) ( \S + ) (?: " | ' ) / ,
97
- end : / { { \/ (?: d o c s - s n i p p e t | d e m o .e x a m p l e | d e m o . l i v e - e x a m p l e ) } } / ,
99
+ begin : / { { # (?: d o c s - s n i p p e t | d e m o .e x a m p l e ) \s n a m e = (?: " | ' ) ( \S + ) (?: " | ' ) / ,
100
+ end : / { { \/ (?: d o c s - s n i p p e t | d e m o .e x a m p l e ) } } / ,
98
101
} , includer . options . snippetRegexes ) ;
99
102
100
103
let importer = findImporter ( this ) ;
101
104
102
- importer . import ( `${ this . _hasEmberSource ( ) ? 'vendor' : 'bower_components' } /ember/ember-template-compiler.js` ) ;
103
105
importer . import ( 'vendor/lunr/lunr.js' , {
104
106
using : [ { transformation : 'amd' , as : 'lunr' } ]
105
107
} ) ;
@@ -112,10 +114,7 @@ module.exports = {
112
114
113
115
createDeployPlugin ( ) {
114
116
const AddonDocsDeployPlugin = require ( './lib/deploy/plugin' ) ;
115
- const readConfig = require ( './lib/utils/read-config' ) ;
116
-
117
- let userConfig = readConfig ( this . project ) ;
118
- return new AddonDocsDeployPlugin ( userConfig ) ;
117
+ return new AddonDocsDeployPlugin ( this . _readUserConfig ( ) ) ;
119
118
} ,
120
119
121
120
setupPreprocessorRegistry ( type , registry ) {
@@ -157,8 +156,7 @@ module.exports = {
157
156
return new MergeTrees ( [
158
157
vendor ,
159
158
this . _highlightJSTree ( ) ,
160
- this . _lunrTree ( ) ,
161
- this . _templateCompilerTree ( )
159
+ this . _lunrTree ( )
162
160
] . filter ( Boolean ) ) ;
163
161
} ,
164
162
@@ -218,17 +216,13 @@ module.exports = {
218
216
} ) ;
219
217
} ,
220
218
221
- _templateCompilerTree ( ) {
222
- if ( this . _hasEmberSource ( ) ) {
223
- return new Funnel ( path . dirname ( resolve . sync ( 'ember-source/package.json' ) , { basedir : this . project . root } ) , {
224
- srcDir : 'dist' ,
225
- destDir : 'ember'
226
- } ) ;
219
+ _readUserConfig ( ) {
220
+ if ( ! this . _userConfig ) {
221
+ const readConfig = require ( './lib/utils/read-config' ) ;
222
+ this . _userConfig = readConfig ( this . project ) ;
227
223
}
228
- } ,
229
224
230
- _hasEmberSource ( ) {
231
- return 'ember-source' in this . project . pkg . devDependencies ;
225
+ return this . _userConfig ;
232
226
}
233
227
} ;
234
228
0 commit comments