New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@capsulajs/capsulahub-cli

Package Overview
Dependencies
Maintainers
5
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capsulajs/capsulahub-cli

This package provides an ability to use CLI to run and build Capsulahub application.

  • 0.0.2-alpha.1567332840.14
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-98.59%
Maintainers
5
Weekly downloads
 
Created
Source

Build Status

Capsula Hub

Description

CapsulaHub is part of CapsulaJS project, it is one of CapsulaJS pillars but it can be used stand alone. It is an CLI tool to help you to develop and test your micro-frontend services!

Local development

# from the root
npm link packages/cli
cd packages/cli/node_modules
find . -maxdepth 1 -type d \! \( -name ".bin" -o -name ".cache" \) -exec rm -rf "{}" \;
# now you can use capsulahub binary anywhere in the repository
# for example:
capsulahub --help
capsulahub run --token=http://localhost:3000/configuration --configProvider=httpFile --port=8888

Install

NPM

npm install --save-dev @capsulajs/capsulahub-cli

Yarn

yarn add -D @capsulajs/capsulahub-cli

Usage

capsulahub --help
Usage: capsulahub [options] [command]

Options:
  -h, --help       output usage information

Commands:
  run [options]    Run a Capsulahub application locally in development mode
  build [options]  Build Capsulahub application files in a specific folder (ready to deploy)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

capsulahub run --help
 Usage: run [options]
 
 Run a Capsulahub application locally in development mode
 
 Options:
   -t, --token <token>                    The token that will be used to get the configuration (required)
   -c, --configProvider <configProvider>  The type of configuration provider (optional - default is "httpFile"). Possible options: 'localFile', 'httpFile', 'scalecube', 'httpServer', 'localStorage'
   -p, --port <port>                      The port on which the application will run locally (for instance, http://localhost:55555/) (optional - default is "55555")
   -d, --dispatcherUrl <dispatcherUrl>    The url of the dispatcher for those providers that use dispatcher (optional)
   -h, --help                             output usage information

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

capsulahub build --help
    Usage: build [options]
    
    Build Capsulahub application files in a specific folder (ready to deploy)
    
    Options:
      -t, --token <token>                    The token that will be used to get the configuration (required)
      -c, --configProvider <configProvider>  The type of configuration provider (optional - default is "httpFile"). Possible options: 'localFile', 'httpFile', 'scalecube', 'httpServer', 'localStorage'
      -o, --output <output>                  Relative path to the output folder (optional - default is "./dist")
      -d, --dispatcherUrl <dispatcherUrl>    The url of the dispatcher for those providers that use dispatcher (optional)
      -h, --help                             output usage information

Example

HttpFile

Make sure, that you have httpServer running on the port 1111 and you have a configuration file in ./configuration/workspace.json (the path is relative to the root of your server).

In order to run the application locally run:

capsulahub run --token=http://localhost:1111/configuration

If you want to generate a bundle containing the app in order to serve it by yourself, you should run:

capsulahub build --token=http://localhost:1111/configuration

Configuration

The configuration should be a .json file which match this API.

This file should be accessible following the configProvider that you choose to use (docs).
The url to reach it is passed as the token.

Example: config.json

{
  "name": "baseWorkspace",
  "services": [
    {
      "serviceName": "ServiceA",
      "path": "http://localhost:1111/services/serviceA.js",
      "definition": {
        "serviceName": "ServiceA",
        "methods": {
          "getMessage": { "asyncModel": "requestResponse" }
        }
      },
      "config": { "message": "Message from ServiceA from PORT 1111 HTTP File" }
    },
    {
      "serviceName": "ServiceFlows",
      "path": "http://localhost:1111/services/serviceFlows.js",
      "definition": {
        "serviceName": "ServiceFlows",
        "methods": {}
      },
      "config": {
        "componentName": "web-component-a"
      }
    },
    {
      "serviceName": "RendererService",
      "path": "https://capsulajs.s3.amazonaws.com/develop/capsulahub-service-renderer/index.js",
      "definition": {
        "serviceName": "RendererService",
        "methods": {
          "renderLayouts": { "asyncModel": "requestResponse" },
          "renderItems": { "asyncModel": "requestResponse" },
          "renderItem": { "asyncModel": "requestResponse" }
        }
      },
      "config": {}
    }
  ],
  "components": {
    "layouts": {
      "capsulahub-root": {
        "componentName": "web-grid",
        "path": "http://localhost:1111/widgets/Grid.js",
        "config": {
          "title": "Base Grid from PORT 1111 HTTP File",
          "innerComponentId": "web-component-a"
        }
      }
    },
    "items": {
      "web-component-a": {
        "componentName": "web-component-a",
        "path": "http://localhost:1111/widgets/ComponentA.js",
        "config": { "name": "ComponentA(PORT 1111 HTTP File)" }
      }
    }
  }
}

Mount point

Please notice, that the first component, that is supposed to be mounted on the application, should have the key "capsulahub-root" (as it is in configuration example).

License

CapsulaHub is released under MIT License.

FAQs

Package last updated on 01 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc