/sapui5-runtime

Downloads the official SAPUI5 runtime for local development

Primary LanguageJavaScriptMIT LicenseMIT

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.

Installing a specific Version

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

"sapui5RuntimeVersion": "X.Y.Z"

where X.Y.Z is a valid version from https://tools.hana.ondemand.com/

Remember to run npm install or yarn install again after specifing your desired version

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()
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 ❤️