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

mta

v1.0.8

Published

[![CircleCI](https://circleci.com/gh/SAP/cloud-mta.svg?style=svg&circle-token=ecedd1dce3592adcd72ee4c61481972c32dcfad7)](https://circleci.com/gh/SAP/cloud-mta) [![Go Report Card](https://goreportcard.com/badge/github.com/SAP/cloud-mta)](https://goreportca

Downloads

4,635

Readme

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.

Node.js v10 and lower minor version of Node.js v11, v12, v13 /ECMAScript modules

More and more npm packages use ECMAScript modules instead of commonJS, for ECMAScript modules are the official standard format to package JavaScript code for reuse. From v1.0.5, we use axios instead of binwrap(which has moderate severity vulnerabilities) to download binary files, but axios only supports ECMAScript modules and can't work on Node.js v10 and lower minor version of Node.js v11, v12, v13. The axios can work on latest version of Node.js v11.15, v12.22, v13.14. So since v1.0.5, mta will not support Node.js v10 and lower versions, including lower minor version of Node.js v11, v12, v13.

Contributions

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

Support

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