@@ -51,14 +51,21 @@ function _isSvgFile(fileName) {
51
51
return path . extname ( fileName ) === '.svg' ;
52
52
}
53
53
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
+
54
59
function _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 } ` ;
56
62
}
57
63
58
64
function _getThemeDestPath ( theme , stagingPath , ext , cssonly , servePlatform , serveDestination ) {
59
65
let dest ;
60
66
let base ;
61
67
const stylePath = config ( 'paths' ) . src . styles ;
68
+ const themePlatform = _getThemePlatform ( theme . platform , theme . name ) ;
62
69
if ( cssonly ) {
63
70
if ( servePlatform === 'web' ) {
64
71
base = path . resolve ( stagingPath ) ;
@@ -69,9 +76,9 @@ function _getThemeDestPath(theme, stagingPath, ext, cssonly, servePlatform, serv
69
76
} else {
70
77
base = path . resolve ( stagingPath , '..' , 'platforms' , servePlatform , 'app/src/main/assets' , 'www' ) ;
71
78
}
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 , '/' ) ) ;
73
80
} 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 , '/' ) ) ;
75
82
}
76
83
return dest ;
77
84
}
@@ -101,23 +108,22 @@ function _copyDefaultResourcesToStaging(theme, stagingPath, themeName) {
101
108
const srcBase = `${ config ( 'paths' ) . staging . themes } /${ themeName } ` ;
102
109
const destBase = util . destPath ( path . join ( stagingPath , config ( 'paths' ) . src . styles , themeName , util . getJETVersion ( ) ) ) ;
103
110
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' ) ;
109
114
115
+ const defaultFontsDest = path . join ( destBase , themePlatform , 'fonts' ) ;
116
+ const defaultImagesDest = path . join ( destBase , themePlatform , 'images' ) ;
110
117
if ( config ( 'defaultTheme' ) === CONSTANTS . DEFAULT_THEME && themeName !== CONSTANTS . DEFAULT_PCSS_THEME && themeName !== CONSTANTS . DEFAULT_STABLE_THEME ) {
111
118
const commonSrc = path . join ( srcBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
112
119
const commonDest = path . join ( destBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
113
120
fs . copySync ( commonSrc , commonDest ) ;
114
121
}
115
-
116
122
fs . copySync ( defaultFontsSrc , defaultFontsDest ) ;
117
123
fs . copySync ( defaultImagesSrc , defaultImagesDest ) ;
118
124
}
119
125
120
- function _copyComponentsToStaging ( componentsSource ) {
126
+ function _copyExchangeComponentsToStaging ( { context , componentsSource } ) {
121
127
return new Promise ( ( resolve ) => {
122
128
if ( util . isObjectEmpty ( componentsSource ) ) {
123
129
// No component source present, continue...
@@ -132,11 +138,15 @@ function _copyComponentsToStaging(componentsSource) {
132
138
componentDirPath , CONSTANTS . JET_COMPONENT_JSON ) ;
133
139
if ( fs . existsSync ( componentJsonPath ) ) {
134
140
const componentJson = util . readJsonAndReturnObject ( componentJsonPath ) ;
135
- const destBase = path . join ( config ( 'paths' ) . staging . stagingPath , config ( 'paths' ) . src . javascript , config ( 'paths' ) . components ) ;
136
141
if ( ! util . hasProperty ( componentJson , 'version' ) ) {
137
142
util . log . error ( `Missing property 'version' in '${ component } ' component's/pack's definition file.` ) ;
138
143
}
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
+ } ) ;
140
150
fs . copySync ( componentDirPath , destPath ) ;
141
151
resolve ( ) ;
142
152
} else {
@@ -175,8 +185,10 @@ function _copySrcResourcesToThemes(theme) {
175
185
const srcBase = `${ config ( 'paths' ) . src . common } /${ config ( 'paths' ) . src . themes } /${ theme . name } ` ;
176
186
const destBase = util . destPath ( path . join ( config ( 'paths' ) . staging . themes , theme . name ) ) ;
177
187
const srcCommon = path . join ( srcBase , CONSTANTS . COMMON_THEME_DIRECTORY ) ;
188
+ const themePlatform = _getThemePlatform ( theme . platform , theme . name ) ;
189
+
178
190
_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 ) ) ;
180
192
}
181
193
182
194
function _copyMultiThemesSrcResourcesToThemes ( themes ) {
@@ -192,8 +204,10 @@ function _copyMultiThemesToStaging(opts, stagingPath, livereload) {
192
204
const srcBase = config ( 'paths' ) . staging . themes ;
193
205
opts . themes . forEach ( ( singleTheme ) => {
194
206
// 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 , '/' ) ) ;
197
211
fs . copySync ( src , dest ) ;
198
212
199
213
// copy common dir
@@ -217,25 +231,23 @@ function _copyThemesToStaging(context) {
217
231
// copy the entire theme/platform folder during build
218
232
const ext = util . getThemeCssExtention ( buildType ) ;
219
233
const src = _getThemeSrcPath ( theme , ext , livereload ) ;
234
+
220
235
const dest = _getThemeDestPath ( theme , stgPath , ext , livereload , platform , opts . destination ) ;
221
236
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 ) {
226
239
const rwsrc = _getThemeSrcPath ( rwood , ext , livereload ) ;
227
240
const rwdest = _getThemeDestPath ( rwood , stgPath , ext , livereload , platform , opts . destination ) ;
228
241
fs . copySync ( rwsrc , rwdest ) ;
229
242
}
230
243
231
244
const stable = Object . assign ( { } ,
232
245
{ 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 ) {
234
247
const stsrc = _getThemeSrcPath ( stable , ext , livereload ) ;
235
248
const stdest = _getThemeDestPath ( stable , stgPath , ext , livereload , platform , opts . destination ) ;
236
249
fs . copySync ( stsrc , stdest ) ;
237
250
}
238
-
239
251
return new Promise ( ( resolve , reject ) => {
240
252
// copy to themes
241
253
if ( ( theme . name !== CONSTANTS . DEFAULT_THEME || theme . name !== CONSTANTS . DEFAULT_PCSS_THEME ||
@@ -407,7 +419,10 @@ module.exports = {
407
419
const fileResult = util . getFileList ( context . buildType , srcFileList ) ;
408
420
409
421
return _copyFileToStaging ( fileResult )
410
- . then ( ( ) => _copyComponentsToStaging ( componentsSource [ 0 ] ) )
422
+ . then ( ( ) => ( _copyExchangeComponentsToStaging ( {
423
+ context,
424
+ componentsSource : componentsSource [ 0 ]
425
+ } ) ) )
411
426
. then ( ( ) => {
412
427
util . log ( 'Copy finished.' ) ;
413
428
return context ;
0 commit comments