@@ -51,14 +51,21 @@ function _isSvgFile(fileName) {
5151 return path . extname ( fileName ) === '.svg' ;
5252}
5353
54+ function _getThemePlatform ( themePlatform , themeName ) {
55+ // No platform other than web for redwood, stable themes
56+ return ( themeName !== CONSTANTS . DEFAULT_PCSS_THEME && themeName !== CONSTANTS . DEFAULT_STABLE_THEME ) ? themePlatform : 'web' ;
57+ }
58+
5459function _getThemeSrcPath ( theme ) {
55- return `${ config ( 'paths' ) . staging . themes } /${ theme . name } /${ theme . platform } ` ;
60+ const themePlatform = _getThemePlatform ( theme . platform , theme . name ) ;
61+ return `${ config ( 'paths' ) . staging . themes } /${ theme . name } /${ themePlatform } ` ;
5662}
5763
5864function _getThemeDestPath ( theme , stagingPath , ext , cssonly , servePlatform , serveDestination ) {
5965 let dest ;
6066 let base ;
6167 const stylePath = config ( 'paths' ) . src . styles ;
68+ const themePlatform = _getThemePlatform ( theme . platform , theme . name ) ;
6269 if ( cssonly ) {
6370 if ( servePlatform === 'web' ) {
6471 base = path . resolve ( stagingPath ) ;
@@ -69,9 +76,9 @@ function _getThemeDestPath(theme, stagingPath, ext, cssonly, servePlatform, serv
6976 } else {
7077 base = path . resolve ( stagingPath , '..' , 'platforms' , servePlatform , 'app/src/main/assets' , 'www' ) ;
7178 }
72- dest = util . destPath ( path . join ( base , stylePath , theme . name , theme . version , theme . platform , '/' ) ) ;
79+ dest = util . destPath ( path . join ( base , stylePath , theme . name , theme . version , themePlatform , '/' ) ) ;
7380 } else {
74- dest = util . destPath ( path . join ( stagingPath , stylePath , theme . name , theme . version , theme . platform , '/' ) ) ;
81+ dest = util . destPath ( path . join ( stagingPath , stylePath , theme . name , theme . version , themePlatform , '/' ) ) ;
7582 }
7683 return dest ;
7784}
@@ -101,23 +108,22 @@ function _copyDefaultResourcesToStaging(theme, stagingPath, themeName) {
101108 const srcBase = `${ config ( 'paths' ) . staging . themes } /${ themeName } ` ;
102109 const destBase = util . destPath ( path . join ( stagingPath , config ( 'paths' ) . src . styles , themeName , util . getJETVersion ( ) ) ) ;
103110
104- const defaultFontsSrc = path . join ( srcBase , theme . platform , 'fonts' ) ;
105- const defaultImagesSrc = path . join ( srcBase , theme . platform , 'images' ) ;
106-
107- const defaultFontsDest = path . join ( destBase , theme . platform , 'fonts' ) ;
108- const defaultImagesDest = path . join ( destBase , theme . platform , 'images' ) ;
111+ const themePlatform = _getThemePlatform ( theme . platform , themeName ) ;
112+ const defaultFontsSrc = path . join ( srcBase , themePlatform , 'fonts' ) ;
113+ const defaultImagesSrc = path . join ( srcBase , themePlatform , 'images' ) ;
109114
115+ const defaultFontsDest = path . join ( destBase , themePlatform , 'fonts' ) ;
116+ const defaultImagesDest = path . join ( destBase , themePlatform , 'images' ) ;
110117 if ( config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_THEME && themeName !== CONSTANTS . DEFAULT_PCSS_THEME && themeName !== CONSTANTS . DEFAULT_STABLE_THEME ) {
111118 const commonSrc = path . join ( srcBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
112119 const commonDest = path . join ( destBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
113120 fs . copySync ( commonSrc , commonDest ) ;
114121 }
115-
116122 fs . copySync ( defaultFontsSrc , defaultFontsDest ) ;
117123 fs . copySync ( defaultImagesSrc , defaultImagesDest ) ;
118124}
119125
120- function _copyComponentsToStaging ( componentsSource ) {
126+ function _copyExchangeComponentsToStaging ( { context , componentsSource } ) {
121127 return new Promise ( ( resolve ) => {
122128 if ( util . isObjectEmpty ( componentsSource ) ) {
123129 // No component source present, continue...
@@ -132,11 +138,15 @@ function _copyComponentsToStaging(componentsSource) {
132138 componentDirPath , CONSTANTS . JET_COMPONENT_JSON ) ;
133139 if ( fs . existsSync ( componentJsonPath ) ) {
134140 const componentJson = util . readJsonAndReturnObject ( componentJsonPath ) ;
135- const destBase = path . join ( config ( 'paths' ) . staging . stagingPath , config ( 'paths' ) . src . javascript , config ( 'paths' ) . components ) ;
136141 if ( ! util . hasProperty ( componentJson , 'version' ) ) {
137142 util . log . error ( `Missing property 'version' in '${ component } ' component's/pack's definition file.` ) ;
138143 }
139- const destPath = path . join ( destBase , component , componentJson . version ) ;
144+ const destPath = util . generatePathToComponentRoot ( {
145+ context,
146+ component,
147+ root : context . opts . stagingPath ,
148+ scripts : configPaths . src . javascript
149+ } ) ;
140150 fs . copySync ( componentDirPath , destPath ) ;
141151 resolve ( ) ;
142152 } else {
@@ -175,8 +185,10 @@ function _copySrcResourcesToThemes(theme) {
175185 const srcBase = `${ config ( 'paths' ) . src . common } /${ config ( 'paths' ) . src . themes } /${ theme . name } ` ;
176186 const destBase = util . destPath ( path . join ( config ( 'paths' ) . staging . themes , theme . name ) ) ;
177187 const srcCommon = path . join ( srcBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
188+ const themePlatform = _getThemePlatform ( theme . platform , theme . name ) ;
189+
178190 _copyFilesExcludeScss ( srcCommon , path . join ( destBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ) ;
179- _copyFilesExcludeScss ( path . join ( srcBase , theme . platform ) , path . join ( destBase , theme . platform ) ) ;
191+ _copyFilesExcludeScss ( path . join ( srcBase , themePlatform ) , path . join ( destBase , themePlatform ) ) ;
180192}
181193
182194function _copyMultiThemesSrcResourcesToThemes ( themes ) {
@@ -192,8 +204,10 @@ function _copyMultiThemesToStaging(opts, stagingPath, livereload) {
192204 const srcBase = config ( 'paths' ) . staging . themes ;
193205 opts . themes . forEach ( ( singleTheme ) => {
194206 // copy css
195- const src = path . join ( srcBase , singleTheme . name , singleTheme . platform ) ;
196- const dest = util . destPath ( path . join ( stagingPath , config ( 'paths' ) . src . styles , singleTheme . name , singleTheme . version , singleTheme . platform , '/' ) ) ;
207+ const themePlatform = _getThemePlatform ( singleTheme . platform , singleTheme . name ) ;
208+
209+ const src = path . join ( srcBase , singleTheme . name , themePlatform ) ;
210+ const dest = util . destPath ( path . join ( stagingPath , config ( 'paths' ) . src . styles , singleTheme . name , singleTheme . version , themePlatform , '/' ) ) ;
197211 fs . copySync ( src , dest ) ;
198212
199213 // copy common dir
@@ -217,25 +231,23 @@ function _copyThemesToStaging(context) {
217231 // copy the entire theme/platform folder during build
218232 const ext = util . getThemeCssExtention ( buildType ) ;
219233 const src = _getThemeSrcPath ( theme , ext , livereload ) ;
234+
220235 const dest = _getThemeDestPath ( theme , stgPath , ext , livereload , platform , opts . destination ) ;
221236 const rwood = Object . assign ( { } ,
222- { name : 'redwood' , platform : 'web' , compile : false , version : util . getJETVersion ( ) } ,
223- { name : 'stable' , platform : 'web' , compile : false , version : util . getJETVersion ( ) } ) ;
224-
225- if ( opts . theme . cssGeneratedType === 'add-on' || ( config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_PCSS_THEME || config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_STABLE_THEME ) ) {
237+ { name : 'redwood' , platform : 'web' , compile : false , version : util . getJETVersion ( ) } ) ;
238+ if ( opts . theme . cssGeneratedType === 'add-on' && opts . theme . basetheme === CONSTANTS . DEFAULT_PCSS_THEME ) {
226239 const rwsrc = _getThemeSrcPath ( rwood , ext , livereload ) ;
227240 const rwdest = _getThemeDestPath ( rwood , stgPath , ext , livereload , platform , opts . destination ) ;
228241 fs . copySync ( rwsrc , rwdest ) ;
229242 }
230243
231244 const stable = Object . assign ( { } ,
232245 { name : 'stable' , platform : 'web' , compile : false , version : util . getJETVersion ( ) } ) ;
233- if ( opts . theme . cssGeneratedType === 'add-on' || ( config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_PCSS_THEME || config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_STABLE_THEME ) ) {
246+ if ( opts . theme . cssGeneratedType === 'add-on' && opts . theme . basetheme === CONSTANTS . DEFAULT_STABLE_THEME ) {
234247 const stsrc = _getThemeSrcPath ( stable , ext , livereload ) ;
235248 const stdest = _getThemeDestPath ( stable , stgPath , ext , livereload , platform , opts . destination ) ;
236249 fs . copySync ( stsrc , stdest ) ;
237250 }
238-
239251 return new Promise ( ( resolve , reject ) => {
240252 // copy to themes
241253 if ( ( theme . name !== CONSTANTS . DEFAULT_THEME || theme . name !== CONSTANTS . DEFAULT_PCSS_THEME ||
@@ -407,7 +419,10 @@ module.exports = {
407419 const fileResult = util . getFileList ( context . buildType , srcFileList ) ;
408420
409421 return _copyFileToStaging ( fileResult )
410- . then ( ( ) => _copyComponentsToStaging ( componentsSource [ 0 ] ) )
422+ . then ( ( ) => ( _copyExchangeComponentsToStaging ( {
423+ context,
424+ componentsSource : componentsSource [ 0 ]
425+ } ) ) )
411426 . then ( ( ) => {
412427 util . log ( 'Copy finished.' ) ;
413428 return context ;
0 commit comments