sapui5-sdk

1.0.5 • Public • Published

SAPUI5 SDK

A package which downloads the official SAPUI5 SDK 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-sdk

or

yarn add -D sapui5-sdk

This will download and unzip the latest SAPUI5 SDK.

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-sdk"{
  "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-sdk 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-sdk as usual.

Get started

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

Express example

const express = require('express')
const sapui5 = require('sapui5-sdk')
const app = express()
 
app.use('/resources', express.static(sapui5.resources))
app.use('/test-resources', express.static(sapui5.testResources))
 
app.listen(3000)

Hapi example

const Hapi = require('hapi')
const inert = require('inert')
const sapui5 = require('sapui5-sdk')
 
const server = Hapi.server({
    port: 3000,
    host: 'localhost'
})
 
const init = async () => {
    await server.register(inert)
    server.route({
        method: 'GET',
        path: '/{param*}',
        handler: {
            directory: {
                path: sapui5.root
            }
        }
    });
    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-sdk/lib/resources"
  name: ui5-middleware-servestatic
    afterMiddleware: compression
    mountPath: /test-resources
    configuration:
      rootPath: "./node_modules/sapui5-sdk/lib/test-resources"

Grunt OpenUI5 example

const sapui5 = require('sapui5-sdk')
 
module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      options: {
        port: 3000,
        hostname: '*'
      },
      src: {},
      dist: {}
    },
    openui5_connect: {
      options: {
        resources: [sapui5.resources],
        testresources: [sapui5.testResources],
        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 ❤️

Package Sidebar

Install

npm i sapui5-sdk

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

11.6 kB

Total Files

6

Last publish

Collaborators

  • bastilimbach