@capsulajs/capsulahub-cli
This package provides an ability to use CLI to run and build Capsulahub application.
Last updated 6 months ago by capsulajsci .
MIT · Original npm · Tarball · package.json
$ cnpm install @capsulajs/capsulahub-cli 
SYNC missed versions from official npm registry.

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).

<!-- To put back later for local dev Run it locally

What to do Command
To run the linter: yarn lint
To run the tests: yarn test
To generate the doc: yarn doc

Development

  • Clone the project then do yarn or npm i
  • Create a capsulahub.json file at the root with the following structure:
    {
      "token": "your_token"
    }
    
  • Run yarn start or npm run start. -->

License

CapsulaHub is released under MIT License.

Current Tags

  • 0.0.3                                ...           latest (6 months ago)
  • 0.0.2-next.35                                ...           next (6 months ago)
  • 0.0.2-alpha.1575380902.32                                ...           snapshot (6 months ago)

69 Versions

Downloads
Today 0
This Week 0
This Month 69
Last Day 0
Last Week 69
Last Month 0
Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |