Skip to content

Commit dd992d8

Browse files
committed
Test UI5 Tooling Task Extensibility Feature
Under development. Depends on: SAP/ui5-project#64 SAP/ui5-builder#106
1 parent 07f901c commit dd992d8

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

lib/.eslintrc.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
"env": {
3+
"node": true,
4+
"es6": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 8
8+
},
9+
"extends": ["eslint:recommended", "google"],
10+
"rules": {
11+
"indent": [
12+
"error",
13+
"tab"
14+
],
15+
"linebreak-style": [
16+
"error",
17+
"unix"
18+
],
19+
"quotes": [
20+
"error",
21+
"double",
22+
{ "allowTemplateLiterals": true }
23+
],
24+
"semi": [
25+
"error",
26+
"always"
27+
],
28+
"no-negated-condition": "off",
29+
"require-jsdoc": "off",
30+
"no-mixed-requires": "off",
31+
"max-len": ["warn", 120],
32+
"no-implicit-coercion": [
33+
2,
34+
{ "allow": ["!!"] }
35+
],
36+
"comma-dangle": "off",
37+
"no-tabs": "off",
38+
"no-console": "off", // sometimes needed by CLI
39+
'valid-jsdoc': [
40+
2,
41+
{
42+
requireParamDescription: false,
43+
requireReturnDescription: false,
44+
requireReturn: false,
45+
prefer: {return: 'returns'},
46+
}
47+
],
48+
},
49+
"root": true
50+
};

lib/tasks/ponyInserter.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const stringReplacer = require("@ui5/builder").processors.stringReplacer;
2+
3+
/**
4+
* Generates "sap-ui-messagebundle-preload.js" file for all found message bundles
5+
*
6+
* @param {Object} parameters Parameters
7+
* @param {DuplexCollection} parameters.workspace DuplexCollection to read and write files
8+
* @param {AbstractReader} parameters.dependencies Reader or Collection to read dependency files
9+
* @param {Object} parameters.options Options
10+
* @param {string} parameters.options.projectName Project name
11+
* @param {string} [parameters.options.configuration] Task configuration if given in ui5.yaml
12+
* @returns {Promise<undefined>} Promise resolving with undefined once data has been written
13+
*/
14+
module.exports = function({workspace, options}) {
15+
const pattern = options.configuration.pattern || "the";
16+
17+
return workspace.byGlob("/**/*.{js,json,html}")
18+
.then((processedResources) => {
19+
return stringReplacer({
20+
resources: processedResources,
21+
options: {
22+
pattern: new RegExp(pattern),
23+
replacement: "pony"
24+
}
25+
});
26+
})
27+
.then((processedResources) => {
28+
return Promise.all(processedResources.map((resource) => {
29+
return workspace.write(resource);
30+
}));
31+
});
32+
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"@openui5/themelib_sap_belize": "^1.52.5"
1919
},
2020
"devDependencies": {
21+
"@ui5/builder": "^0.2.4",
2122
"@ui5/cli": "^0.2.1",
2223
"eslint": "^4.19.1",
24+
"eslint-config-google": "^0.11.0",
2325
"karma": "^2.0.5",
2426
"karma-chrome-launcher": "^2.2.0",
2527
"karma-coverage": "^1.1.2",

ui5.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,17 @@ specVersion: '0.1'
22
metadata:
33
name: openui5-sample-app
44
type: application
5+
builder:
6+
customTasks:
7+
- name: ponyInserter
8+
beforeTask: uglify
9+
configuration:
10+
pattern: the
11+
---
12+
specVersion: "0.1"
13+
kind: extension
14+
type: task
15+
metadata:
16+
name: ponyInserter
17+
task:
18+
path: lib/tasks/ponyInserter.js

0 commit comments

Comments
 (0)