Skip to content
This repository has been archived by the owner on Nov 14, 2019. It is now read-only.

Process hash #144

Merged
merged 4 commits into from
Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 106 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g mesg-cli
$ mesg-cli COMMAND
running command...
$ mesg-cli (-v|--version|version)
mesg-cli/1.2.0 darwin-x64 node-v10.16.0
mesg-cli/1.2.0 darwin-x64 node-v10.16.3
$ mesg-cli --help [COMMAND]
USAGE
$ mesg-cli COMMAND
Expand All @@ -42,6 +42,11 @@ USAGE
* [`mesg-cli marketplace:create-offer SID`](#mesg-cli-marketplacecreate-offer-sid)
* [`mesg-cli marketplace:publish SERVICE_PATH`](#mesg-cli-marketplacepublish-service_path)
* [`mesg-cli marketplace:purchase SID OFFER_ID`](#mesg-cli-marketplacepurchase-sid-offer_id)
* [`mesg-cli process:compile [PROCESS_FILE]`](#mesg-cli-processcompile-process_file)
* [`mesg-cli process:create DEFINITION`](#mesg-cli-processcreate-definition)
* [`mesg-cli process:delete PROCESS_HASH...`](#mesg-cli-processdelete-process_hash)
* [`mesg-cli process:detail PROCESS_HASH`](#mesg-cli-processdetail-process_hash)
* [`mesg-cli process:list`](#mesg-cli-processlist)
* [`mesg-cli service:compile [SERVICE]`](#mesg-cli-servicecompile-service)
* [`mesg-cli service:create DEFINITION`](#mesg-cli-servicecreate-definition)
* [`mesg-cli service:delete SERVICE_HASH...`](#mesg-cli-servicedelete-service_hash)
Expand All @@ -54,11 +59,6 @@ USAGE
* [`mesg-cli service:logs INSTANCE_HASH`](#mesg-cli-servicelogs-instance_hash)
* [`mesg-cli service:start SERVICE_HASH`](#mesg-cli-servicestart-service_hash)
* [`mesg-cli service:stop INSTANCE_HASH...`](#mesg-cli-servicestop-instance_hash)
* [`mesg-cli workflow:compile [WORKFLOW_FILE]`](#mesg-cli-workflowcompile-workflow_file)
* [`mesg-cli workflow:create DEFINITION`](#mesg-cli-workflowcreate-definition)
* [`mesg-cli workflow:delete WORKFLOW_HASH...`](#mesg-cli-workflowdelete-workflow_hash)
* [`mesg-cli workflow:detail WORKFLOW_HASH`](#mesg-cli-workflowdetail-workflow_hash)
* [`mesg-cli workflow:list`](#mesg-cli-workflowlist)

## `mesg-cli account:create`

Expand Down Expand Up @@ -347,6 +347,106 @@ OPTIONS

_See code: [src/commands/marketplace/purchase.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/marketplace/purchase.ts)_

## `mesg-cli process:compile [PROCESS_FILE]`

Compile a process

```
USAGE
$ mesg-cli process:compile [PROCESS_FILE]

ARGUMENTS
PROCESS_FILE Path of a process file

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--dev compile the process and automatically deploy and start all the services
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/process/compile.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/process/compile.ts)_

## `mesg-cli process:create DEFINITION`

Create a process

```
USAGE
$ mesg-cli process:create DEFINITION

ARGUMENTS
DEFINITION Process's definition. Use process:compile first to build process definition

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/process/create.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/process/create.ts)_

## `mesg-cli process:delete PROCESS_HASH...`

Delete one or many processes

```
USAGE
$ mesg-cli process:delete PROCESS_HASH...

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--confirm Confirm deletion
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/process/delete.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/process/delete.ts)_

## `mesg-cli process:detail PROCESS_HASH`

Display detailed information on a process

```
USAGE
$ mesg-cli process:detail PROCESS_HASH

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/process/detail.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/process/detail.ts)_

## `mesg-cli process:list`

List processes

```
USAGE
$ mesg-cli process:list

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format
--filter=filter filter property by partial string matching, ex: name=foo
--host=host [default: localhost] Host to access the MESG engine
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--sort=sort property to sort by (prepend '-' for descending)
```

_See code: [src/commands/process/list.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/process/list.ts)_

## `mesg-cli service:compile [SERVICE]`

Compile a service and upload its source to IPFS server
Expand Down Expand Up @@ -593,104 +693,4 @@ OPTIONS
```

_See code: [src/commands/service/stop.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/service/stop.ts)_

## `mesg-cli workflow:compile [WORKFLOW_FILE]`

Compile a workflow

```
USAGE
$ mesg-cli workflow:compile [WORKFLOW_FILE]

ARGUMENTS
WORKFLOW_FILE Path of a workflow file

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--dev compile the workflow and automatically deploy and start all the services
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/workflow/compile.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/workflow/compile.ts)_

## `mesg-cli workflow:create DEFINITION`

Create a workflow

```
USAGE
$ mesg-cli workflow:create DEFINITION

ARGUMENTS
DEFINITION Workflow's definition. Use workflow:compile first to build workflow definition

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/workflow/create.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/workflow/create.ts)_

## `mesg-cli workflow:delete WORKFLOW_HASH...`

Delete one or many workflows

```
USAGE
$ mesg-cli workflow:delete WORKFLOW_HASH...

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--confirm Confirm deletion
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/workflow/delete.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/workflow/delete.ts)_

## `mesg-cli workflow:detail WORKFLOW_HASH`

Display detailed information on a workflow

```
USAGE
$ mesg-cli workflow:detail WORKFLOW_HASH

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
--host=host [default: localhost] Host to access the MESG engine
```

_See code: [src/commands/workflow/detail.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/workflow/detail.ts)_

## `mesg-cli workflow:list`

List workflows

```
USAGE
$ mesg-cli workflow:list

OPTIONS
-h, --help show CLI help
-p, --port=port [default: 50052] Port to access the MESG engine
-q, --quiet Display only essential information
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format
--filter=filter filter property by partial string matching, ex: name=foo
--host=host [default: localhost] Host to access the MESG engine
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--sort=sort property to sort by (prepend '-' for descending)
```

_See code: [src/commands/workflow/list.ts](https://github.com/mesg-foundation/cli/blob/v1.2.0/src/commands/workflow/list.ts)_
<!-- commandsstop -->
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"is-git-url": "^1.0.0",
"js-yaml": "^3.13.1",
"lodash.pick": "^4.4.0",
"mesg-js": "^4.3.0-beta.1",
"mesg-js": "^4.3.0-beta.2",
"node-docker-api": "^1.1.22",
"rimraf": "^2.6.3",
"tar": "^4.4.8",
Expand Down Expand Up @@ -88,8 +88,8 @@
"service": {
"description": "Manage services"
},
"workflow": {
"description": "Manage workflows"
"process": {
"description": "Manage processes"
},
"daemon": {
"description": "Manage the Engine"
Expand All @@ -113,4 +113,4 @@
"lint": "tslint -p ./ -t stylish --fix"
},
"types": "lib/index.d.ts"
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import {flags} from '@oclif/command'
import {existsSync, readFileSync} from 'fs'
import {hash} from 'mesg-js/lib/api/types'
import {dirname, join} from 'path'

import Command from '../../root-command'
import * as compile from '../../utils/compiler'
import {IsAlreadyExistsError} from '../../utils/error'
import ServiceCompile from '../service/compile'
import { hash } from 'mesg-js/lib/api/types';

export default class WorkflowCompile extends Command {
static description = 'Compile a workflow'
export default class ProcessCompile extends Command {
static description = 'Compile a process'

static flags = {
...Command.flags,
dev: flags.boolean({description: 'compile the workflow and automatically deploy and start all the services'})
dev: flags.boolean({description: 'compile the process and automatically deploy and start all the services'})
}

static args = [{
name: 'WORKFLOW_FILE',
description: 'Path of a workflow file'
name: 'PROCESS_FILE',
description: 'Path of a process file'
}]

async run(): Promise<any> {
const {args, flags} = this.parse(WorkflowCompile)
const definition = await compile.workflow(readFileSync(args.WORKFLOW_FILE), async (instanceObject: any) => {
const {args, flags} = this.parse(ProcessCompile)
const definition = await compile.process(readFileSync(args.PROCESS_FILE), async (instanceObject: any) => {
if (instanceObject.instanceHash) {
return instanceObject.instanceHash
}
if (!flags.dev) {
throw new Error('"instanceHash" should be present in your workflow. Use `--dev` to be able to use "service" or "src" attributes.')
throw new Error('"instanceHash" should be present in your process. Use `--dev` to be able to use "service" or "src" attributes.')
}
if (instanceObject.service) {
return this.serviceToInstance(instanceObject.service)
}
if (instanceObject.src) {
return this.sourceToInstance(args.WORKFLOW_FILE, instanceObject.src)
return this.sourceToInstance(args.PROCESS_FILE, instanceObject.src)
}
throw new Error('at least one of the following parameter should be set: "instanceHash", "service" or "src"')
})
Expand Down
32 changes: 32 additions & 0 deletions src/commands/process/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {ProcessCreateOutputs} from 'mesg-js/lib/api'
import * as base58 from 'mesg-js/lib/util/base58'

import Command from '../../root-command'

export default class ProcessCreate extends Command {
static description = 'Create a process'

static flags = {
...Command.flags
}

static args = [{
name: 'DEFINITION',
required: true,
description: 'Process\'s definition. Use process:compile first to build process definition'
}]

async run(): ProcessCreateOutputs {
const {args} = this.parse(ProcessCreate)
this.spinner.start('Create process')
const definition = JSON.parse(args.DEFINITION, function (this: any, key: string, value: any): any {
return key && key.match(/hash$/i) && value && typeof value === 'string'
? base58.decode(value)
: value
})
const resp = await this.api.process.create(definition)
if (!resp.hash) { throw new Error('invalid response') }
this.spinner.stop(base58.encode(resp.hash))
return resp
}
}
Loading