GithubHelp home page GithubHelp logo

isabella232 / cloud-mta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sap/cloud-mta

0.0 0.0 0.0 872 KB

Built-in tools to work with Multi-Target-Application (MTA) projects

License: Apache License 2.0

Makefile 0.31% Go 98.70% Smarty 0.02% JavaScript 0.94% Shell 0.03%

cloud-mta's Introduction

CircleCI Go Report Card Coverage Status contributions welcome GoDoc pre-alpha dependentbot REUSE status

Description

MTA tool for exploring and validating the multitarget application descriptor (mta.yaml).

The tool can be used as a Go library or as a command-line tool, also available as an npm package.

Multitarget Applications

A multitarget application is a package comprised of multiple application and resource modules that have been created using different technologies and deployed to different run-times; however, they have a common life cycle. A user can bundle the modules together using the mta.yaml file, describe them along with their inter-dependencies to other modules, services, and interfaces, and package them in an MTA project.

Go Library

The tool commands (APIs) are used to do the following:

  • Explore the structure of the mta.yaml file objects, such as retrieving a list of resources required by a specific module.
  • Validate an mta.yaml file against a specified schema version.
  • Ensure semantic correctness of an mta.yaml file, such as the uniqueness of module/resources names, the resolution of requires/provides pairs, and so on.
  • Validate the descriptor against the project folder structure, such as the path attribute reference in an existing project folder.
  • Get data for constructing a deployment MTA descriptor, such as deployment module types.

Requirements

Download and Installation

  1. Set your workspace.

  2. Download and install it:

    $ go get github.com/SAP/cloud-mta/mta

Usage

  • Import it into your source code:

    import "github.com/SAP/cloud-mta/mta"
  • Quick start example:

    // sets the path to the MTA project.
    mf, _ := ioutil.ReadFile("/path/mta.yaml")
    // Returns an MTA object.
    if err != nil {
    	return err
    }
    // unmarshal MTA content.
    m := Unmarshal(mf)
    if err != nil {
    	return err
    }
    // Returns the module properties.
    module, err := m.GetModuleByName(moduleName)
    if err != nil {
    	return err
    }

Command-Line Tool

Some of the tool's features are available as an command-line tool, which can be downloaded from the GitHub releases page or installed as an npm package.

The commands of the CLI tool are used as APIs by other programs, such as the mta-lib npm package which exposes Javascript APIs for reading and manipulating the mta.yaml file.

npm package

mta

The mta npm package installs the executable and allows you to run it from a shell or command line. You can install it globally via the command:

npm install -g mta

mta-local

The mta-local npm package exposes the same CLI tool without installing it globally. It is packaged by other libraries, and it provides a way to lazily download the executable according to the current operating system and run it. You can use it in the following way:

// You can use "cross-spawn" library instead of "process" for compatibility to Windows systems
const { spawn } = require("process");
const mtaPath = require("mta-local").paths["mta"];
const childProcess = spawn(mtaPath, args);
// Handle the process events ...

Packaging with webpack

To use these npm libraries from an application packaged with webpack, you have to copy the bin/mta file to the webpack output directory (keeping the same file structure), make it executable and enable __dirname to be used.

Note: while the packaged bin/mta file is already executable, the CopyWebpackPlugin loses the executable bits during the copy. See this issue.

For example, if the results are in the dist folder, add this configuration inside your webpack configuration file:

const path = require("path");
const fs = require("fs");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const config = {
    // ...
    node: {
        __dirname: false,
    },
    plugins: [
        new CopyWebpackPlugin({
            patterns: [
                {
                  from: path.join(require.resolve("mta-local"), "..", "bin"),
                  to: path.resolve(__dirname, "dist", "bin"),
                }
            ]
        }),
        function (compiler) {
          compiler.hooks.done.tap("ExecuteChmodOnBinMta", () => {
            fs.chmodSync(path.resolve(__dirname, "dist", "bin", "mta"), "755");
          });
        }
    ]
};

Note: if you did not previously use copy-webpack-plugin you will need to add it to the devDependencies in your package.json file.

Contributions

Contributions are greatly appreciated. See CONTRIBUTING.md for details.

Known Issues

No known major issues. To report a new issue, please use our GitHub bug tracking system.

Support

Please follow our issue template on how to report an issue.

cloud-mta's People

Contributors

allavolkov avatar bd82 avatar cloudmtabot avatar dependabot-preview[bot] avatar dependabot[bot] avatar jhornik avatar jonathanbaker7 avatar katunin-ng avatar michawai avatar rayakoren avatar sapirpol avatar sebastianwolf-sap avatar shimit avatar tal-sapan avatar veredcon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.