@@ -3,15 +3,24 @@ const path = require('path');
3
3
const mkdirp = require ( "mkdirp" ) ;
4
4
const assets = require ( "../../assets-meta.js" ) ;
5
5
6
- const outputFile = path . normalize ( `${ process . argv [ 2 ] } /Themes.js` ) ;
6
+ const inputFolder = path . normalize ( process . argv [ 2 ] ) ;
7
+ const outputFile = path . normalize ( `${ process . argv [ 3 ] } /Themes.js` ) ;
7
8
9
+ // All supported optional themes
8
10
const optionalThemes = assets . themes . all . filter ( theme => theme !== assets . themes . default ) ;
9
11
12
+ // All themes present in the file system
13
+ const dirs = fs . readdirSync ( inputFolder ) ;
14
+ const themesOnFileSystem = dirs . map ( dir => {
15
+ const matches = dir . match ( / s a p _ .* $ / ) ;
16
+ return matches ? dir : undefined ;
17
+ } ) . filter ( key => ! ! key && optionalThemes . includes ( key ) ) ;
18
+
10
19
const packageName = JSON . parse ( fs . readFileSync ( "package.json" ) ) . name ;
11
20
12
- const importLines = optionalThemes . map ( theme => `import ${ theme } from "../assets/themes/${ theme } /parameters-bundle.css.json";` ) . join ( "\n" ) ;
13
- const isInlinedCondition = optionalThemes . map ( theme => `isInlined(${ theme } )` ) . join ( " || " ) ;
14
- const registerLines = optionalThemes . map ( theme => `registerThemeProperties("${ packageName } ", "${ theme } ", ${ theme } );` ) . join ( "\n" ) ;
21
+ const importLines = themesOnFileSystem . map ( theme => `import ${ theme } from "../assets/themes/${ theme } /parameters-bundle.css.json";` ) . join ( "\n" ) ;
22
+ const isInlinedCondition = themesOnFileSystem . map ( theme => `isInlined(${ theme } )` ) . join ( " || " ) ;
23
+ const registerLines = themesOnFileSystem . map ( theme => `registerThemeProperties("${ packageName } ", "${ theme } ", ${ theme } );` ) . join ( "\n" ) ;
15
24
16
25
// Resulting file content
17
26
const content = `import { registerThemeProperties } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
@@ -26,7 +35,7 @@ See rollup-plugin-url or webpack file-loader for more information.
26
35
Suggested pattern: "assets\\\\\\/.*\\\\\\.json"\`);
27
36
}
28
37
29
- ${ registerLines } ;
38
+ ${ registerLines }
30
39
` ;
31
40
32
41
mkdirp . sync ( path . dirname ( outputFile ) ) ;
0 commit comments