Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 2.33 KB

File metadata and controls

82 lines (62 loc) · 2.33 KB

UI5 task for replacing strings from any files while creating build

Task for ui5-builder, replacing string values.

Install

npm install ui5-task-stringreplacer --save-dev

or

yarn install --dev ui5-task-stringreplacer

Configuration options (in $yourapp/ui5.yaml)

  • debug: true|false
    verbose logging
  • files: string|array
    Placeholders will be replaced with their values in files matched by this glob pattern
  • replace: array
    List of placeholder, value pairs

Usage

  1. Define the dependency in $yourapp/package.json:
"devDependencies": {
    // ...
    "ui5-task-stringreplacer": "*"
    // ...
},
"ui5": {
  "dependencies": [
    // ...
    "ui5-task-stringreplacer",
    // ...
  ]
}

As the devDependencies are not recognized by the UI5 tooling, they need to be listed in the ui5 > dependencies array. In addition, once using the ui5 > dependencies array you need to list all UI5 tooling relevant dependencies.

  1. configure it in $yourapp/ui5.yaml:
builder:
  customTasks:
    - name: ui5-task-stringreplacer
      afterTask: replaceVersion
      configuration:
        files:
          - "**/*.js"
          - "**/*.xml"
      replace:
        - placeholder: ${project.artifactId}
          value: my.sample.app
        - placeholder: ${project.version}
          value: 1.0.0-SNAPSHOT
        - placeholder: '{{app.AppTitle}}'
          value: My Sample App
  1. Maintain all string placeholders and values in .env file
stringreplacer.BASE_URL_PLACEHOLDER = http://localhost:2000
stringreplacer.some.deeply.nested.ANOTHER_PLACEHOLDER = Replace with this text

How it works

The task reads all files based on configuration patterns and replaces all string placeholders with values for all files. All the string placeholders which are maintained in .env with prefix 'stringreplacer.' will be taken into account.

License

This work is dual-licensed under Apache 2.0 and the Derived Beer-ware License. The official license will be Apache 2.0 but finally, you can choose between one of them if you use this work.

When you like this stuff, buy @vobu a beer or buy @pmuessig or @TheVivekGowda a coke when you see them.