Skip to content

Commit

Permalink
Merge pull request #133 from FlowTestAI/update-cli-pkg
Browse files Browse the repository at this point in the history
Add readme and license to cli package for publishing
  • Loading branch information
jsajal authored Jul 18, 2024
2 parents d27ecb7 + 28fe5d4 commit 4d1b528
Show file tree
Hide file tree
Showing 18 changed files with 674 additions and 7 deletions.
21 changes: 21 additions & 0 deletions packages/flowtest-cli/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sajal Jain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions packages/flowtest-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# flowtestai-cli

With FlowTestAI CLI, you can now run your end to end flows, constructed using FlowTestAI, directly from command line.

This makes it easier to run your tests in different environments, automate your testing process, and integrate your tests with your continuous integration and deployment workflows.

## Installation

To install the FlowTestAI CLI, use the node package manager of your choice, such as NPM:

```bash
npm install -g flowtestai
```

## Getting started

Navigate to the root directory of your collection, and then run:

```bash
flow run help
```

This command will give you various options you can use to run a flow. You can also run a single flow by specifying its filename with the `--file` or `-f` option:

```bash
flow run -f test.flow
```

Or run a requests inside a subfolder:

```bash
flow run -f folder/subfolder/test.flow
```

If you need to use an environment, you can specify it with the `--env` or `-e` option:

```bash
flow run -f test.flow -e environments/test.env
```

If you need to publish the results of your flow runs for further analysis, you can specify the `-s` option. Request your access key pairs from https://flowtest-ai.vercel.app/ and then run export $FLOWTEST_ACCESS_ID and $FLOWTEST_ACCESS_KEY before publishing:

```bash
flow run -f test.flow -e environments/test.env -s
```

## Demo

![demo1](assets/demo1.png)
![demo2](assets/demo2.png)

## Support

If you encounter any issues or have any feedback or suggestions, please raise them on our [GitHub repository](https://github.com/FlowTestAI/FlowTest)

Thank you for using FlowTestAI CLI!

## Changelog

See [https://github.com/FlowTestAI/FlowTest/releases](https://github.com/FlowTestAI/FlowTest/releases)

## License

[MIT](LICENSE.md)
Binary file added packages/flowtest-cli/assets/demo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/flowtest-cli/assets/demo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/flowtest-cli/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const chalk = require('chalk');
const readFile = require('../../flowtest-electron/src/utils/filemanager/readfile');
const { serialize } = require('../../flowtest-electron/src/utils/flowparser/parser');
const readFile = require('../utils/readfile');
const { serialize } = require('../utils/flowparser/parser');
const { Graph } = require('../graph/Graph');
const { cloneDeep } = require('lodash');
const dotenv = require('dotenv');
Expand Down
4 changes: 2 additions & 2 deletions packages/flowtest-cli/graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const requestNode = require('./compute/requestNode');
const setVarNode = require('./compute/setvarnode');
const chalk = require('chalk');
const path = require('path');
const readFile = require('../../flowtest-electron/src/utils/filemanager/readfile');
const { serialize } = require('../../flowtest-electron/src/utils/flowparser/parser');
const Node = require('./compute/node');
const { LogLevel } = require('./GraphLogger');
const readFile = require('../utils/readfile');
const { serialize } = require('../utils/flowparser/parser');

class nestedFlowNode extends Node {
constructor(nodes, edges, startTime, timeout, initialEnvVars, logger) {
Expand Down
13 changes: 10 additions & 3 deletions packages/flowtest-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"name": "flowtest-cli",
"version": "1.0.0",
"name": "flowtestai",
"version": "1.0.2",
"description": "CLI to run flow from command line",
"main": "bin/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"flow": "./bin/index.js"
"flow": "bin/index.js"
},
"bugs": {
"url": "https://github.com/FlowTestAI/FlowTest/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FlowTestAI/FlowTest.git"
},
"author": "Sajal Jain <jsajal1993@gmail.com>",
"license": "MIT",
Expand Down
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/AssertNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class AssertNode extends Node {
constructor() {
super('assertNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
AssertNode,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/AuthNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class AuthNode extends Node {
constructor() {
super('authNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
AuthNode,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/DelayNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class DelayNode extends Node {
constructor() {
super('delayNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
DelayNode,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/NestedFlowNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class NestedFlowNode extends Node {
constructor() {
super('flowNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
NestedFlowNode,
};
17 changes: 17 additions & 0 deletions packages/flowtest-cli/utils/flowparser/Node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Node {
constructor(type) {
this.type = type;
}

serialize(id, data, metadata) {
throw new Error('Serialize method must be implemented by subclasses');
}

deserialize(node) {
throw new Error('Deserialize method must be implemented by subclasses');
}
}

module.exports = {
Node,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/OutputNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class OutputNode extends Node {
constructor() {
super('outputNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const { ['output']: _, ...data } = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
OutputNode,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/RequestNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class RequestNode extends Node {
constructor() {
super('requestNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
RequestNode,
};
34 changes: 34 additions & 0 deletions packages/flowtest-cli/utils/flowparser/SetVarNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { Node } = require('./Node');

class SetVarNode extends Node {
constructor() {
super('setVarNode');
}

serialize(id, data, metadata) {
return {
id,
type: this.type,
data,
...metadata,
};
}

deserialize(node) {
const id = node.id;
const data = node.data;
delete node.id;
delete node.data;
const metadata = node;

return {
id,
data,
metadata,
};
}
}

module.exports = {
SetVarNode,
};
Loading

0 comments on commit 4d1b528

Please sign in to comment.