2.1.1 • Published 21 days ago

bhoos-cli v2.1.1

Weekly downloads
44
License
UNLICENSED
Repository
github
Last release
21 days ago

bhoos-cli

Bhoos cli for internal use. Bhoos CLI can

  • install packages & applications
  • run applications throught Agent.
    • Agent takes care of respawing the worker process if they die
    • sends logs to ManagementServer
    • watches for updates, and gracefully updates running application
  • publish packages to the internal registry

also, you can add new commands to Bhoos CLI if they serve useful purpose to everyone (see CONTIBUTING#New Commands).

Installation

  1. Install the package. Either
	yarn global add bhoos-cli
  1. Register your auth token and create config files:
bhoos auth --token <<TOKEN>> --name <<YOUR NAME>>

This will register your token to management server, and create/update ~/.bhoosrc and ~/.npmrc config files.

Config files

These files are created by bhoos auth automatically.

  1. ~/.bhoosrc file is created with following content:
	{
		"packageUrl":"https://pkg.bhoos.com",
		"cloudUrl":"https://cloud.bhoos.com",
		"accessToken" : "<<TOKEN>>"
	}

It specifies the registry and management server url, and your authentication token.

  1. And .npmrc file will look like:
//npm.pkg.github.com/:_authToken=<<TOKEN>>
//npm.pkg.github.com/bhoos/:_authToken=<<TOKEN>>
//pkg.bhoos.com/:_authToken=<<TOKEN>>
@bhoos:registry=https://pkg.bhoos.com/

This directs yarn and npm to use https://pkg.bhoos.com as the registry for @bhoos/ packages. If the requested pacakge is not found there the registry will itself redirect yarn|npm to the main registry https://npm.pkg.github.com. So, the token for both the registries must be same.

Use

  1. Installing a package
	bhoos install @bhoos/engine-server@latest

Some example pacakge name: - @bhoos/engine-server@dev - @bhoos/engine-server@1.0.1 - @bhoos/engine-server@1.0.1-bpanthi

this will install the pacakge inside ~/.bhoos directory

  1. Running the installed application
	bhoos run @bhoos/engine-server@latest

this will run the installed application (at ~/.bhoos) directory under the supervision of bhoos-cli Agent. It will then send logs, and other stats to the management server, and auto update itself if new updates arrive.

Note: Agent tries to store logs inside /var/log/bhoos/ at /var/log/bhoos/@bhoos directory. So, make sure those directories exist and the application has write premissions. If they don't exist, log won't be presisted locally. However error logs are always send to management server (at the cloudUrl specified in .bhoorc). Also if you want logrotation create a config at /etc/logrotate.d/ accordingly (See CONTRIBUTING#LogRotation for a sample)

  1. Publishing a package
	bhoos publish ./path/to/package/dir -m "publish message" -t "tag"

Publishes the application to registry. See bhoos help publish for further details.

There are three types of packages. And the publish action depends on the type of application being published.

  • node-app : These are application thay need to be run. node_modules is included in the bundle along with other files. So, there are no dependencies to install. Just the bundle file is sufficient.
  • npm : node_modules is not included. There are libraries intended to be imported in other projects.
  • react-native: Android and iOS bundles which can be loaded by mobile application are published.

Note:

  • once package is published to latest or staging, it is locked. And pacakges with same version cannot be published again.
  • yarn build command must be defined
  • For react-native application, yarn setup must also be defined. (See the FAQ section)
  • Published bundles contain only dist and es6 files by default. If other files need to be bundled you have to specify them in package.json files field.
  • Bhoos CLI tries to determine the type of package but if it guesses wrong (shown during publish operation) , you have to specify the type of package in bhoos->pkg-type field of package.json
  1. Changing tag of published package (i.e. tagging package)
	bhoos tag ./ -t latest

Changes the tag of package at ./ to latest. (name and version number is taken from package.json)

	bhoos tag -pkg @bhoos/management-server@1.0.2 -t staging

Changes the tag of @bhoos/management-server@1.0.2 package to staging

FAQ

Checksum / Integrity check failed

Q: I tried to yarn or yarn install in my repo and yarn says checksum failed for a package I had published to registry proxy. Solution: remove your yarn.lock file. Even better, remove the entry for the offending package from the yarn.lock file.

Reason: This happens when you have published a version multiple times in the registry proxy, and yarn installed in the past. So, yarn remembers the checksum of the older package it installed. This is completely normal, and a result of our intented use cases.

Publish your react native bundle to Management Server

bhoos publish on a react native project is intended to create react native bundles for ios and android and then upload them to server. But this requires some hacks, and configuration.

  1. Create a metro-asset-plugin.js See at doc/ file in your react native project and include this plugin in the metro.config.js:
module.exports = {
  transformer: {
	//...
	assetPlugins: [require.resolve('./metro-asset-plugin')],
	//...
  },
  // ...
};
  1. In your package.json make following changes:

    2.1. Specify that your package is a react-native package and be published by bhoos publish as such. To do this, add a field in the package.json:

  "bhoos": {
	"pkg-type": "react-native"
  },

2.2. Specify the root react-native directory (default: './') relative to package.json and the location of react native entry file (default: './index.js') relative to the root directory. E.g.

	"bhoos" : {
	   //...
	   "react-native" : {
		   "root" : "./",
		   "entry-file" : "./index.js"
	   }
	}

2.3. Add a setup script to package.json that runs the fixResolveAssetSource.js (See at doc/) script. This script patches the react-native package to fit our needs.

  "scripts" : {
	// ...
	"setup" : "node fixResolveAssetSource.js"
  }
2.1.1

21 days ago

2.1.0

24 days ago

2.0.17

3 months ago

2.0.15

1 year ago

2.0.16

1 year ago

2.0.13

1 year ago

2.0.14

1 year ago

2.0.12

1 year ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.1

2 years ago

1.0.44

2 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.39

3 years ago

1.0.40

3 years ago

1.0.41

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.22

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.27

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago