Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions lib/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 8
},
"extends": ["eslint:recommended", "google"],
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double",
{ "allowTemplateLiterals": true }
],
"semi": [
"error",
"always"
],
"no-negated-condition": "off",
"require-jsdoc": "off",
"no-mixed-requires": "off",
"max-len": ["warn", 120],
"no-implicit-coercion": [
2,
{ "allow": ["!!"] }
],
"comma-dangle": "off",
"no-tabs": "off",
"no-console": "off", // sometimes needed by CLI
'valid-jsdoc': [
2,
{
requireParamDescription: false,
requireReturnDescription: false,
requireReturn: false,
prefer: {return: 'returns'},
}
],
},
"root": true
};
32 changes: 32 additions & 0 deletions lib/tasks/ponyInserter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const stringReplacer = require("@ui5/builder").processors.stringReplacer;

/**
* Generates "sap-ui-messagebundle-preload.js" file for all found message bundles
*
* @param {Object} parameters Parameters
* @param {DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {AbstractReader} parameters.dependencies Reader or Collection to read dependency files
* @param {Object} parameters.options Options
* @param {string} parameters.options.projectName Project name
* @param {string} [parameters.options.configuration] Task configuration if given in ui5.yaml
* @returns {Promise<undefined>} Promise resolving with undefined once data has been written
*/
module.exports = function({workspace, options}) {
const pattern = options.configuration.pattern || "the";

return workspace.byGlob("/**/*.{js,json,html}")
.then((processedResources) => {
return stringReplacer({
resources: processedResources,
options: {
pattern: new RegExp(pattern),
replacement: "pony"
}
});
})
.then((processedResources) => {
return Promise.all(processedResources.map((resource) => {
return workspace.write(resource);
}));
});
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"@openui5/themelib_sap_belize": "^1.52.5"
},
"devDependencies": {
"@ui5/builder": "^0.2.4",
"@ui5/cli": "^0.2.1",
"eslint": "^4.19.1",
"eslint-config-google": "^0.11.0",
"karma": "^2.0.5",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
Expand Down
14 changes: 14 additions & 0 deletions ui5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ specVersion: '0.1'
metadata:
name: openui5-sample-app
type: application
builder:
customTasks:
- name: ponyInserter
beforeTask: uglify
configuration:
pattern: the
---
specVersion: "0.1"
kind: extension
type: task
metadata:
name: ponyInserter
task:
path: lib/tasks/ponyInserter.js