Skip to content

Commit a0e6bf8

Browse files
committed
Add advanced ui5 theme compilation method.
1 parent 45176c0 commit a0e6bf8

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is a comment.
2+
# Each line is a file pattern followed by one or more owners.
3+
# Order is important; the last matching pattern takes the most precedence.
4+
5+
# These owners will be the default owners for everything in the repo.
6+
# Unless a later match takes precedence, @global-owner1 and @global-owner2
7+
# will be requested for review when someone opens a pull request.
8+
* @fuchsvomwalde

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ui5-lib-util is designed as an agnostic node module and can be used standalone i
2222
Example with gulp `4.0.0` (JavaScript ES6):
2323
```js
2424
import gulp from 'gulp'
25-
import { ui5Download, ui5Build } from 'ui5-lib-util'
25+
import tap from 'gulp-tap'
26+
import { ui5Download, ui5Build, ui5CompileLessLib } from 'ui5-lib-util'
2627

2728
// create gulp task
2829
const loadUI5 = gulp.series(downloadOpenUI5, buildOpenUI5)
@@ -77,6 +78,21 @@ function buildOpenUI5() {
7778
})
7879
}
7980

81+
// compile a ui5 less theme library
82+
function compileUi5Theme() {
83+
const sLibrarySourcePath = './dist/path/to/my/library/themes/sap_belize'
84+
85+
// create library.css in same directory as library.source.less
86+
return new Promise((resolve, reject) =>
87+
gulp
88+
.src([`${sLibrarySourcePath}/library.source.less`])
89+
// rename UI5 module (app component) paths and update UI5 resource roots in UI5 bootstrap of index.html
90+
.pipe(tap(oFile => {
91+
ui5CompileLessLib(oFile).then(resolve).catch(reject)
92+
}))
93+
)
94+
}
95+
8096
```
8197

8298
Furtheremore, in the [OpenUI5 Starter Kit](https://github.com/pulseshift/openui5-gulp-starter-kit) you can find ui5-lib-util integrated in a complete build script.
@@ -104,6 +120,13 @@ ui5Build(sourcePath, destinationPath, ui5Version, [options])
104120
* `options` (object, optional) The configuration options object.
105121
* `options.onProgress` (function(number, number, object):void, optional) Callback function to track build progress taking as params: current step number, total step number and if available, step details (e.g. name of current step).
106122

123+
### `ui5CompileLessLib`
124+
```js
125+
ui5CompileLessLib(file)
126+
```
127+
128+
* `file` ([Vinyl](https://github.com/gulpjs/vinyl)) File must be the `library.source.less` file that imports all required less resources of the library.
129+
107130
### Outlook
108131

109132
Here is a brief overview on what we are working right know and what will follow, soon. We are interested to hear your opinion on what should follow next.

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const path = require('path')
2626
const builder = new lessOpenUI5.Builder()
2727

2828
// export functions
29-
module.exports = { ui5Download, ui5Build }
29+
module.exports = { ui5Download, ui5Build, ui5CompileLessLib }
3030

3131
/**
3232
* Download OpenUI5 repository from external URL and unzip.
@@ -583,7 +583,7 @@ function ui5Build(sUI5SrcPath, sUI5TargetPath, sUI5Version, oOptions = {}) {
583583
.pipe(
584584
tap(oFile => {
585585
// TODO: tap into library.source.less files to customize ui5 bundle
586-
compileUI5LessLib(oFile)
586+
ui5CompileLessLib(oFile)
587587
})
588588
)
589589
// save at target location
@@ -655,10 +655,10 @@ function ui5Build(sUI5SrcPath, sUI5TargetPath, sUI5Version, oOptions = {}) {
655655
/**
656656
* Compile library.source.less and dependencies to library.css.
657657
*
658-
* @param {Vinyl} [oFile] Vinyl file object of library-preload.json.
659-
* @returns {Vinyl} Transformed library-preload.json.
658+
* @param {Vinyl} [oFile] Vinyl file object of library.source.less.
659+
* @returns {Promise} Promise.
660660
*/
661-
function compileUI5LessLib(oFile) {
661+
function ui5CompileLessLib(oFile) {
662662
const sDestDir = path.dirname(oFile.path)
663663
const sFileName = oFile.path.split('/').pop()
664664
const sLessFileContent = oFile.contents.toString('utf8')
@@ -710,7 +710,7 @@ function compileUI5LessLib(oFile) {
710710
}
711711

712712
// if missing file could be created, try theme build again
713-
return isIssueFixed ? compileUI5LessLib(oFile) : Promise.reject()
713+
return isIssueFixed ? ui5CompileLessLib(oFile) : Promise.reject()
714714
})
715715
.then(oResult => {
716716
// build css content was successfull >> save result

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ui5-lib-util",
3-
"version": "0.1.0",
3+
"version": "0.1.2",
44
"description": "A set of UI5 utilities to download and build OpenUI5 automatically.",
55
"scripts": {
66
"precommit": "lint-staged"

0 commit comments

Comments
 (0)