Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

godiva

1.0.3 • Public • Published

Godiva

Godiva is the command-line interface for SAPUI5. It provides a number of helpful commands that can assist you while you build your application.

Installation

$ npm install godiva -g

Prerequisites

Before starting the SAPUI5 project, you can initialize Godiva by the using init command:

$ godiva init <namespace> [title] [options]
Arguments:
    namespace          Any SAPUI5 valid namespace
    title              Your SAPUI5 Application Title

Options:
    -h, --help  output usage information
    -n, --new   Create a new boilerplate template.

This will create a godiva.json on your root directoy which contains all the basic configuration that Godiva will use for CLI commands. You can also edit godiva.json afterwards according to your needs.

if the -n, --new options is provided, this will create a boilerplate project on your current directory.

{
  "title": "Hello World",
  "version": "1.0.0",
  "namespace": "com.example.app",
  "resource": {
    "path": "https://sapui5.hana.ondemand.com/resources/sap-ui-core.js",
    "dir": "./"
  },
  "controller": "controller",
  "view": "view",
  "fragment": "view/fragment",
  "i18n": "i18n",
  "module": "utils",
  "libs": [
    "sap.m",
    "sap.ui.core",
    "sap.ui.layout"
  ]
}

Usage

The following commands are currently supported by Godiva:

Make

The make command consists of several utility function for generating SAPUI5 files.

Creating an index.html file can be done via:

Usage: make:index [options] <Title>

Create a new index file.

Options:

    -h, --help     output usage information

Examples:

    $ godiva make:index 'Hello World'

Creating a Component.js file can be done via:

Usage: make:component [options] <DeviceModel>

Create a new component file. <DeviceModel> can be set to true to be generated.

Options:

    -h, --help     output usage information

Examples:

    $ godiva make:component true

The statement above will not generate a device model instance on your Component.js

sap.ui.define([
    "sap/ui/core/UIComponent",
    "sap/ui/model/odata/ODataModel",
],function(UIComponent,ODataModel){
    "use strict";
    return UIComponent.extend("com.sap.ui5.Component",{
        metadata : {
            manifest : "json"
        },
        init : function(){
            // call the init function of the parent
            UIComponent.prototype.init.apply(this, arguments);
 
            // create the views based on the url/hash
            this.getRouter().initialize();
 
            // create device model
            var deviceModel = new sap.ui.model.json.JSONModel({
                isTouch : sap.ui.Device.support.touch,
                isNoTouch : !sap.ui.Device.support.touch,
                isPhone : sap.ui.Device.system.phone,
                isNoPhone : !sap.ui.Device.system.phone,
                listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",
                listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"
            });
            this.setModel(deviceModel, "device");
        }
    });
});

Creating a *.controller.js file can be done via:


 Usage: make:controller [options] <ControllerName>

 Create a new controller.

 Options:

    -h, --help  output usage information

Examples:

    $ godiva make:controller Home

By default Godiva, will create the controller folder base on your godiva.json.

Creating a *.view.xml file can be done via:


 Usage: make:controller [options] <ViewName>

 Create a new view.

 Options:

    -h, --help  output usage information
    -a, --attach  Attach this view to a controller with the same name.

Examples:

  $ godiva make:view Home --attach

By default Godiva, will create the view folder base on your godiva.json. if the -a, --attach is provided, the xml view will include a controllerName attribute to the view.

<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" controllerName="com.sap.ui5.controller.Home" >
    <Page title="{i18n>homePageTitle}">
        <content>
            <Label text="{i18n>helloWorld}" />
        </content>
    </Page>
</mvc:View>

Note: XML views are the only currently supported view types.

Creating a *.fragment.xml file can be done via:


  Usage: make:fragment [options] <FragmentName>

  Create a new fragment.

  Options:

    -h, --help  output usage information

Examples:

    $ godiva make:fragment Login

Creating a module or formatter file can be done via:


  Usage: make:module [options] <ModuleName>

  Create a new module (e.g. Formatter).

  Options:

    -h, --help  output usage information

Examples:

    $ godiva make:module Formatter

Godiva also generates message bundle or i18n. This can be achieved by passing multiple locale to the end of the argument:


  Usage: make:i18n <lcoale> [otherLocale...] [options]

  Create a new i18n file.

  Options:

    -h, --help  output usage information

Examples:

    $ godiva make:i18n en us

Deleting Files

If you want to remove the generated files, you can simply delete them on your directory. You can use init to regenerate the godiva.json provided you have the namespace as the parameter.

License: MIT

Author: Ginwene Rueda

Keywords

install

npm i godiva

Downloadsweekly downloads

0

version

1.0.3

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability