sapui5-runtime

Downloads the official SAPUI5 runtime for local development

Usage no npm install needed!

<script type="module">
  import sapui5Runtime from 'https://cdn.skypack.dev/sapui5-runtime';
</script>

README

SAPUI5 Runtime

A package which downloads the official SAPUI5 runtime from https://tools.hana.ondemand.com/ for local development.

Installation

By using this npm package you agree to the EULA from SAP: https://tools.hana.ondemand.com/developer-license-3_1.txt/

npm install -D sapui5-runtime

or

yarn add -D sapui5-runtime

This will download and unzip the latest SAPUI5 runtime.

Proxy support

It is possible to use this package behind a proxy by setting the environment variables HTTP_PROXY and HTTPS_PROXY.

Linux / macOS
export HTTP_PROXY http://hostname:port
export HTTPS_PROXY https://hostname:port
Windows
set HTTP_PROXY=http://hostname:port
set HTTPS_PROXY=https://hostname:port

It is also possible to use proxy servers which require authentication: https://username:password@hostname:port

Installing a specific version

In case you need a specific version of SAPUI5 you can specify it in your package.json. Add the following line to your package.json:

"sapui5-runtime": {
  "version": "X.Y.Z"
}

You need to replace X.Y.Z with a valid version from https://tools.hana.ondemand.com/.

If you already added sapui5-runtime to your dependencies you need to run npm rebuild after setting a specified version. If you added this setting to your package.json before installing the package, you can just install sapui5-runtime as usual.

Get started

After a successful installation you can use a server to serve the runtime as static files.

Express example

const express = require('express')
const sapui5 = require('sapui5-runtime')
const app = express()

app.use('/resources', express.static(sapui5))

app.listen(3000)

Hapi example

const Hapi = require('hapi')
const inert = require('inert')
const sapui5 = require('sapui5-runtime')

const server = Hapi.server({
    port: 3000,
    host: 'localhost'
})

const init = async () => {
    await server.register(inert)
    server.route({
        method: 'GET',
        path: '/resources/{param*}',
        handler: {
            directory: {
                path: sapui5
            }
        }
    });
    await server.start()
}

init()

UI5 Tooling example

Add the custom UI5 middleware to serve static resources:

npm install -D ui5-middleware-servestatic

or

yarn add -D ui5-middleware-servestatic

Add the UI5 dependency declaration to package.json:

"ui5": {
  "dependencies": [
    "ui5-middleware-servestatic"
  ]
}

Add the custom middleware configuration to ui5.yaml

server:
  customMiddleware:
  - name: ui5-middleware-servestatic
    afterMiddleware: compression
    mountPath: /resources
    configuration:
      rootPath: "./node_modules/sapui5-runtime/lib/resources"

Grunt OpenUI5 example

const sapui5 = require('sapui5-runtime')

module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      options: {
        port: 3000,
        hostname: '*'
      },
      src: {},
      dist: {}
    },
    openui5_connect: {
      options: {
        resources: [sapui5],
        cors: {
          origin: '*'
        }
      },
      src: {
        options: {
          appresources: 'webapp'
        }
      },
      dist: {
        options: {
          appresources: 'dist'
        }
      }
    },
    openui5_preload: {
      component: {
        options: {
          resources: {
            cwd: 'webapp',
            prefix: 'sap/ui/demo/todo',
            src: [
              '**/*.js',
              '**/*.fragment.html',
              '**/*.fragment.json',
              '**/*.fragment.xml',
              '**/*.view.html',
              '**/*.view.json',
              '**/*.view.xml',
              '**/*.properties',
              'manifest.json',
              '!test/**'
            ]
          },
          dest: 'dist'
        },
        components: true
      }
    },
    clean: {
      dist: 'dist',
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          cwd: 'webapp',
          src: [
            '**',
            '!test/**'
          ],
          dest: 'dist'
        }]
      }
    },
  })

  grunt.loadNpmTasks('grunt-contrib-connect')
  grunt.loadNpmTasks('grunt-contrib-clean')
  grunt.loadNpmTasks('grunt-contrib-copy')
  grunt.loadNpmTasks('grunt-openui5')

  grunt.registerTask('serve', function (target) {
    grunt.task.run('openui5_connect:' + (target || 'src') + ':keepalive')
  })
  grunt.registerTask('build', ['clean:dist', 'openui5_preload', 'copy'])
  grunt.registerTask('default', ['serve'])
}

Contribution

I'm happy to accept Pull Requests! Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Credits

This project was heavily inspired by openui5.runtime.downloader by Marius Augenstein.

License

MIT :heart: