npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ui5-cache-buster

v0.2.2

Published

A reliable cache-buster for OpenUI5.

Downloads

46

Readme

⚡️ ui5-cache-buster (alpha)

Ensure your users are always enjoying the latest version of your app. OpenUI5 provides only solutions proprietary for SAP Gateway and SAP Cloud Platform. With this project, we created a more reliable mechanism that is open source and available for any environment.

Install

Install ui5-cache-buster as a development dependency:

yarn add ui5-cache-buster@alpha --dev

How it works

ui5-cache-buster will parse the UI5 resource roots, e.g.:

<script
  id="sap-ui-bootstrap"
  src="./ui5/1.50.0/resources/sap-ui-core.js"
  data-sap-ui-resourceroots='{
    "my.demo.app": "./apps/my-demo-app"
  }' />

From there the project structure will be injected. At the time, the cache buster supports UI5 app components, UI5 control libraries and asset-roots as resources as well as theme roots.

For example. if an app component is identified, the Component-preload.js and resources listed in manifest.json (contained in Component-preload.js as well) will be read to create a deterministic hash based on the file contents. The app path and the resource roots will then be updated with the hash:

data-sap-ui-resourceroots='{
  "my.demo.app": "./apps/cgfsybfu"
}'

Next time you run cache buster, as long as the Component-preload.js have not changed, also the hash will be the same.

How to use

ui5-cache-buster is designed as an agnostic node module and can be used standalone in your custom build script or as part of e.g. a gulp build task.

Example with gulp 4.0.0 (JavaScript ES6):

import gulp from 'gulp'
import tap from 'gulp-tap'
import ui5Bust from 'ui5-cache-buster'

// hash UI5 module paths to enable cache buster
export function ui5cacheBust() {
  return (
    gulp
      .src(['./index.html'])
      // rename UI5 module (app component) paths and update UI5 resource roots in UI5 bootstrap of index.html
      .pipe(tap(oFile => ui5Bust(oFile)))
      .pipe(gulp.dest('./'))
  )
}

Furtheremore, in the OpenUI5 Starter Kit you can find ui5-cache-buster integrated in a complete build script.

Hint: If you want read/load/fetch from your UI5 app other resources within your app component folder, you must use jQuery.sap.getModulePath to get the correct path:

jQuery.sap.getModulePath(
  'my.demo.app.assets.data.Products',
  '.json'
)
// ./apps/cgfsybfu/assets/data/Products.json

Methods

ui5Bust

ui5Bust(file, [options])
  • file (Vinyl) Entry file must be the HTML file that contains the UI5 bootstrap.
  • options (object, optional) The configuration options object.
  • options.hash (object, optional) The hash generation configuration object).
  • options.hash.type (string, optional) One of sha1, md5, sha256, sha512 or any other node.js supported hash type (default: sha512).
  • options.hash.digestType (string, optional) One of hex, base26, base32, base36, base49, base52, base58, base62, base64 (default: base62).
  • options.hash.maxLength (number, optional) The maximum hash length in chars (default: 8).

License

This project is licensed under the MIT license. Copyright 2017 PulseShift GmbH