mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-03 09:28:33 +00:00
Compare commits
24 Commits
feature/su
...
v0.12.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b85e7ebcc | ||
|
|
49b0f3a322 | ||
|
|
45ca5ded96 | ||
|
|
b6528062f0 | ||
|
|
86094cc054 | ||
|
|
8e0bc68ada | ||
|
|
c36c7b44a6 | ||
|
|
0ac27dee56 | ||
|
|
ede122ab09 | ||
|
|
96e368cb18 | ||
|
|
942b75861c | ||
|
|
c1711ea01b | ||
|
|
dedfefbc9a | ||
|
|
65dd5df87e | ||
|
|
78d2393686 | ||
|
|
0b65c4580e | ||
|
|
9cc1bf1e2f | ||
|
|
b96e3d0f23 | ||
|
|
11c99d55dc | ||
|
|
d054dc4c78 | ||
|
|
9014dc5769 | ||
|
|
d346970241 | ||
|
|
bdb3051c2b | ||
|
|
f8325b22b3 |
12
.github/workflows/bump-homebrew-cask.yml
vendored
Normal file
12
.github/workflows/bump-homebrew-cask.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: Bump Homebrew Cask
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
runs-on: macos-10.15
|
||||
steps:
|
||||
- name: Bump Homebrew Cask
|
||||
run: brew bump-cask-pr bruno --version "${GITHUB_REF_NAME#v}"
|
||||
BIN
assets/images/cli-demo.png
Normal file
BIN
assets/images/cli-demo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
assets/images/run-anywhere.png
Normal file
BIN
assets/images/run-anywhere.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
BIN
assets/images/version-control.png
Normal file
BIN
assets/images/version-control.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
@@ -27,6 +27,10 @@ const Wrapper = styled.div`
|
||||
&:nth-child(4) {
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
select {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ const Sidebar = () => {
|
||||
</GitHubButton>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-grow items-center justify-end text-xs mr-2">v0.10.2</div>
|
||||
<div className="flex flex-grow items-center justify-end text-xs mr-2">v0.12.1</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -122,6 +122,12 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
||||
response: null
|
||||
})
|
||||
);
|
||||
|
||||
if(err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") {
|
||||
console.log('>> request cancelled');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('>> sending request failed');
|
||||
console.log(err);
|
||||
toast.error(err ? err.message : 'Something went wrong!');
|
||||
|
||||
@@ -49,3 +49,15 @@ export const safeStringifyJSON = (obj, indent=false) => {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any characters that are not alphanumeric, spaces, hyphens, or underscores
|
||||
export const normalizeFileName = (name) => {
|
||||
if (!name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const validChars = /[^\w\s-]/g;
|
||||
const formattedName = name.replace(validChars, '-');
|
||||
|
||||
return formattedName;
|
||||
}
|
||||
|
||||
19
packages/bruno-app/src/utils/common/index.spec.js
Normal file
19
packages/bruno-app/src/utils/common/index.spec.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { describe, it, expect } = require("@jest/globals");
|
||||
|
||||
import { normalizeFileName } from './index';
|
||||
|
||||
describe("common utils", () => {
|
||||
describe("normalizeFileName", () => {
|
||||
it("should remove special characters", () => {
|
||||
expect(normalizeFileName("hello world")).toBe("hello world");
|
||||
expect(normalizeFileName("hello-world")).toBe("hello-world");
|
||||
expect(normalizeFileName("hello_world")).toBe("hello_world");
|
||||
expect(normalizeFileName("hello_world-")).toBe("hello_world-");
|
||||
expect(normalizeFileName("hello_world-123")).toBe("hello_world-123");
|
||||
expect(normalizeFileName("hello_world-123!@#$%^&*()")).toBe("hello_world-123----------");
|
||||
expect(normalizeFileName("hello_world?")).toBe("hello_world-");
|
||||
expect(normalizeFileName("foo/bar/")).toBe("foo-bar-");
|
||||
expect(normalizeFileName("foo\\bar\\")).toBe("foo-bar-");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import each from 'lodash/each';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import { uuid } from 'utils/common';
|
||||
import { uuid, normalizeFileName } from 'utils/common';
|
||||
import { isItemARequest } from 'utils/collections';
|
||||
import { collectionSchema } from '@usebruno/schema';
|
||||
import { BrunoError } from 'utils/common/error';
|
||||
@@ -63,6 +63,8 @@ export const updateUidsInCollection = (_collection) => {
|
||||
export const transformItemsInCollection = (collection) => {
|
||||
const transformItems = (items = []) => {
|
||||
each(items, (item) => {
|
||||
item.name = normalizeFileName(item.name);
|
||||
|
||||
if (['http', 'graphql'].includes(item.type)) {
|
||||
item.type = `${item.type}-request`;
|
||||
if(item.request.query) {
|
||||
|
||||
BIN
packages/bruno-cli/assets/images/cli-demo.png
Normal file
BIN
packages/bruno-cli/assets/images/cli-demo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
22
packages/bruno-cli/license.md
Normal file
22
packages/bruno-cli/license.md
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Anoop M D, Anusree P S and Contributors
|
||||
|
||||
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.
|
||||
@@ -1,18 +1,26 @@
|
||||
{
|
||||
"name": "@usebruno/cli",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.4",
|
||||
"main": "src/index.js",
|
||||
"bin": {
|
||||
"bru": "./bin/bru.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/usebruno/bruno/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/usebruno/bruno.git"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"bin",
|
||||
"readme.md",
|
||||
"package.json"
|
||||
],
|
||||
"dependencies": {
|
||||
"@usebruno/js": "0.2.0",
|
||||
"@usebruno/lang": "0.2.2",
|
||||
"@usebruno/js": "0.3.0",
|
||||
"@usebruno/lang": "0.3.0",
|
||||
"axios": "^1.3.2",
|
||||
"chai": "^4.3.7",
|
||||
"chalk": "^3.0.0",
|
||||
|
||||
@@ -1,8 +1,44 @@
|
||||
# bruno-cli
|
||||
|
||||
Bru CLI
|
||||
With Bruno CLI, you can now run your API collections with ease using simple command line commands.
|
||||
|
||||
### Publish to Npm Registry
|
||||
This makes it easier to test your APIs in different environments, automate your testing process, and integrate your API tests with your continuous integration and deployment workflows.
|
||||
|
||||
## Installation
|
||||
To install the Bruno CLI, use the node package manager of your choice, such as NPM:
|
||||
```bash
|
||||
npm publish --access=public
|
||||
```
|
||||
npm install -g @usebruno/cli
|
||||
```
|
||||
|
||||
## Getting started
|
||||
Navigate to the directory where your API collection resides, and then run:
|
||||
```bash
|
||||
bru run
|
||||
```
|
||||
This command will run all the requests in your collection. You can also run a single request by specifying its filename:
|
||||
|
||||
```bash
|
||||
bru run request.bru
|
||||
```
|
||||
|
||||
Or run all requests in a folder:
|
||||
```bash
|
||||
bru run folder
|
||||
```
|
||||
|
||||
If you need to use an environment, you can specify it with the --env option:
|
||||
```bash
|
||||
bru run folder --env Local
|
||||
```
|
||||
|
||||
## Demo
|
||||

|
||||
|
||||
## Support
|
||||
If you encounter any issues or have any feedback or suggestions, please raise them on our [GitHub repository](https://github.com/usebruno/bruno)
|
||||
|
||||
Thank you for using Bruno CLI!
|
||||
|
||||
|
||||
## License
|
||||
[MIT](license.md)
|
||||
@@ -42,6 +42,17 @@ const interpolateVars = (request, envVars = {}, collectionVariables ={}) => {
|
||||
request.data = interpolate(request.data);
|
||||
}
|
||||
}
|
||||
} else if(request.headers["content-type"] === "application/x-www-form-urlencoded") {
|
||||
if(typeof request.data === "object") {
|
||||
try {
|
||||
let parsed = JSON.stringify(request.data);
|
||||
parsed = interpolate(parsed);
|
||||
request.data = JSON.parse(parsed);
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
request.data = interpolate(request.data);
|
||||
}
|
||||
|
||||
each(request.params, (param) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { get, each, filter } = require('lodash');
|
||||
const qs = require('qs');
|
||||
|
||||
const prepareRequest = (request) => {
|
||||
const headers = {};
|
||||
@@ -41,7 +40,7 @@ const prepareRequest = (request) => {
|
||||
const params = {};
|
||||
const enabledParams = filter(request.body.formUrlEncoded, (p) => p.enabled);
|
||||
each(enabledParams, (p) => (params[p.name] = p.value));
|
||||
axiosRequest.data = qs.stringify(params);
|
||||
axiosRequest.data = params;
|
||||
}
|
||||
|
||||
if (request.body.mode === 'multipartForm') {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const qs = require('qs');
|
||||
const chalk = require('chalk');
|
||||
const { forOwn, each, extend, get } = require('lodash');
|
||||
const FormData = require('form-data');
|
||||
@@ -39,6 +40,11 @@ const runSingleRequest = async function (filename, bruJson, collectionPath, coll
|
||||
// interpolate variables inside request
|
||||
interpolateVars(request, envVariables, collectionVariables);
|
||||
|
||||
// stringify the request url encoded params
|
||||
if(request.headers['content-type'] = 'application/x-www-form-urlencoded') {
|
||||
request.data = qs.stringify(request.data);
|
||||
}
|
||||
|
||||
// run request
|
||||
const response = await axios(request);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.10.2",
|
||||
"version": "0.12.1",
|
||||
"name": "bruno",
|
||||
"description": "Opensource API Client",
|
||||
"homepage": "https://www.usebruno.com",
|
||||
@@ -13,8 +13,8 @@
|
||||
"pack": "electron-builder --dir"
|
||||
},
|
||||
"dependencies": {
|
||||
"@usebruno/js": "0.2.0",
|
||||
"@usebruno/lang": "0.2.2",
|
||||
"@usebruno/js": "0.3.0",
|
||||
"@usebruno/lang": "0.3.0",
|
||||
"@usebruno/schema": "0.3.1",
|
||||
"axios": "^0.26.0",
|
||||
"chai": "^4.3.7",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const qs = require('qs');
|
||||
const axios = require('axios');
|
||||
const Mustache = require('mustache');
|
||||
const FormData = require('form-data');
|
||||
@@ -113,7 +114,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
const requestScript = get(request, 'script.req');
|
||||
if(requestScript && requestScript.length) {
|
||||
const scriptRuntime = new ScriptRuntime();
|
||||
const result = scriptRuntime.runRequestScript(requestScript, request, envVars, collectionVariables, collectionPath);
|
||||
const result = await scriptRuntime.runRequestScript(requestScript, request, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: result.envVariables,
|
||||
@@ -124,6 +125,11 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
|
||||
interpolateVars(request, envVars, collectionVariables);
|
||||
|
||||
// stringify the request url encoded params
|
||||
if(request.headers['content-type'] = 'application/x-www-form-urlencoded') {
|
||||
request.data = qs.stringify(request.data);
|
||||
}
|
||||
|
||||
// todo:
|
||||
// i have no clue why electron can't send the request object
|
||||
// without safeParseJSON(safeStringifyJSON(request.data))
|
||||
@@ -158,7 +164,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
const responseScript = get(request, 'script.res');
|
||||
if(responseScript && responseScript.length) {
|
||||
const scriptRuntime = new ScriptRuntime();
|
||||
const result = scriptRuntime.runResponseScript(responseScript, request, response, envVars, collectionVariables, collectionPath);
|
||||
const result = await scriptRuntime.runResponseScript(responseScript, request, response, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: result.envVariables,
|
||||
@@ -179,17 +185,15 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
});
|
||||
|
||||
// run tests
|
||||
const testFile = get(item, 'request.tests');
|
||||
if(testFile && testFile.length) {
|
||||
const testRuntime = new TestRuntime();
|
||||
const result = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||
const testRuntime = new TestRuntime();
|
||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:test-results', {
|
||||
results: result.results,
|
||||
itemUid: item.uid,
|
||||
collectionUid
|
||||
});
|
||||
}
|
||||
mainWindow.webContents.send('main:test-results', {
|
||||
results: testResults.results,
|
||||
itemUid: item.uid,
|
||||
collectionUid
|
||||
});
|
||||
|
||||
deleteCancelToken(cancelTokenUid);
|
||||
|
||||
@@ -204,6 +208,12 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
// need to convey the error to the UI
|
||||
// and need not be always a network error
|
||||
deleteCancelToken(cancelTokenUid);
|
||||
|
||||
if (axios.isCancel(error)) {
|
||||
let error = new Error("Request cancelled");
|
||||
error.isCancel = true;
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
if(error.response) {
|
||||
return {
|
||||
@@ -335,7 +345,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
const requestScript = get(request, 'script.req');
|
||||
if(requestScript && requestScript.length) {
|
||||
const scriptRuntime = new ScriptRuntime();
|
||||
const result = scriptRuntime.runRequestScript(requestScript, request, envVars, collectionVariables, collectionPath);
|
||||
const result = await scriptRuntime.runRequestScript(requestScript, request, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: result.envVariables,
|
||||
@@ -383,7 +393,7 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
const responseScript = get(request, 'script.res');
|
||||
if(responseScript && responseScript.length) {
|
||||
const scriptRuntime = new ScriptRuntime();
|
||||
const result = scriptRuntime.runResponseScript(responseScript, request, response, envVars, collectionVariables, collectionPath);
|
||||
const result = await scriptRuntime.runResponseScript(responseScript, request, response, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:script-environment-update', {
|
||||
envVariables: result.envVariables,
|
||||
@@ -407,17 +417,15 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
}
|
||||
|
||||
// run tests
|
||||
const testFile = get(item, 'request.tests');
|
||||
if(testFile && testFile.length) {
|
||||
const testRuntime = new TestRuntime();
|
||||
const result = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
|
||||
const testRuntime = new TestRuntime();
|
||||
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
|
||||
|
||||
mainWindow.webContents.send('main:run-folder-event', {
|
||||
type: 'test-results',
|
||||
testResults: result.results,
|
||||
...eventData
|
||||
});
|
||||
}
|
||||
mainWindow.webContents.send('main:run-folder-event', {
|
||||
type: 'test-results',
|
||||
testResults: testResults.results,
|
||||
...eventData
|
||||
});
|
||||
|
||||
mainWindow.webContents.send('main:run-folder-event', {
|
||||
type: 'response-received',
|
||||
|
||||
@@ -42,6 +42,17 @@ const interpolateVars = (request, envVars = {}, collectionVariables ={}) => {
|
||||
request.data = interpolate(request.data);
|
||||
}
|
||||
}
|
||||
} else if(request.headers["content-type"] === "application/x-www-form-urlencoded") {
|
||||
if(typeof request.data === "object") {
|
||||
try {
|
||||
let parsed = JSON.stringify(request.data);
|
||||
parsed = interpolate(parsed);
|
||||
request.data = JSON.parse(parsed);
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
request.data = interpolate(request.data);
|
||||
}
|
||||
|
||||
each(request.params, (param) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { get, each, filter } = require('lodash');
|
||||
const qs = require('qs');
|
||||
|
||||
const prepareRequest = (request) => {
|
||||
const headers = {};
|
||||
@@ -39,7 +38,7 @@ const prepareRequest = (request) => {
|
||||
const params = {};
|
||||
const enabledParams = filter(request.body.formUrlEncoded, (p) => p.enabled);
|
||||
each(enabledParams, (p) => (params[p.name] = p.value));
|
||||
axiosRequest.data = qs.stringify(params);
|
||||
axiosRequest.data = params;
|
||||
}
|
||||
|
||||
if (request.body.mode === 'multipartForm') {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@usebruno/js",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"src",
|
||||
@@ -16,12 +16,14 @@
|
||||
"@usebruno/query": "0.1.0",
|
||||
"ajv": "^8.12.0",
|
||||
"atob": "^2.1.2",
|
||||
"axios": "^0.26.0",
|
||||
"btoa": "^1.2.1",
|
||||
"crypto-js": "^4.1.1",
|
||||
"json-query": "^2.2.2",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
"nanoid": "3.3.4",
|
||||
"node-fetch": "2.*",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
const { NodeVM } = require('vm2');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const stream = require('stream');
|
||||
const util = require('util');
|
||||
const zlib = require('zlib');
|
||||
const url = require('url');
|
||||
const punycode = require('punycode');
|
||||
const Bru = require('../bru');
|
||||
const BrunoRequest = require('../bruno-request');
|
||||
const BrunoResponse = require('../bruno-response');
|
||||
@@ -11,16 +18,17 @@ const lodash = require('lodash');
|
||||
const moment = require('moment');
|
||||
const uuid = require('uuid');
|
||||
const nanoid = require('nanoid');
|
||||
const axios = require('axios');
|
||||
const fetch = require('node-fetch');
|
||||
const CryptoJS = require('crypto-js');
|
||||
|
||||
class ScriptRuntime {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
runRequestScript(script, request, envVariables, collectionVariables, collectionPath) {
|
||||
async runRequestScript(script, request, envVariables, collectionVariables, collectionPath){
|
||||
const bru = new Bru(envVariables, collectionVariables);
|
||||
const req = new BrunoRequest(request);
|
||||
|
||||
const context = {
|
||||
bru,
|
||||
req
|
||||
@@ -32,19 +40,30 @@ class ScriptRuntime {
|
||||
external: true,
|
||||
root: [collectionPath],
|
||||
mock: {
|
||||
// node libs
|
||||
path,
|
||||
stream,
|
||||
util,
|
||||
url,
|
||||
http,
|
||||
https,
|
||||
punycode,
|
||||
zlib,
|
||||
// 3rd party libs
|
||||
atob,
|
||||
btoa,
|
||||
lodash,
|
||||
moment,
|
||||
uuid,
|
||||
nanoid,
|
||||
axios,
|
||||
'node-fetch': fetch,
|
||||
'crypto-js': CryptoJS
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.run(script, path.join(collectionPath, 'vm.js'));
|
||||
|
||||
const asyncVM = vm.run(`module.exports = async () => { ${script} }`, path.join(collectionPath, 'vm.js'));
|
||||
await asyncVM();
|
||||
return {
|
||||
request,
|
||||
envVariables,
|
||||
@@ -52,7 +71,7 @@ class ScriptRuntime {
|
||||
};
|
||||
}
|
||||
|
||||
runResponseScript(script, request, response, envVariables, collectionVariables, collectionPath) {
|
||||
async runResponseScript(script, request, response, envVariables, collectionVariables, collectionPath) {
|
||||
const bru = new Bru(envVariables, collectionVariables);
|
||||
const req = new BrunoRequest(request);
|
||||
const res = new BrunoResponse(response);
|
||||
@@ -75,12 +94,15 @@ class ScriptRuntime {
|
||||
moment,
|
||||
uuid,
|
||||
nanoid,
|
||||
axios,
|
||||
'node-fetch': fetch,
|
||||
'crypto-js': CryptoJS
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.run(script, path.join(collectionPath, 'vm.js'));
|
||||
const asyncVM = vm.run(`module.exports = async () => { ${script} }`, path.join(collectionPath, 'vm.js'));
|
||||
await asyncVM();
|
||||
|
||||
return {
|
||||
response,
|
||||
|
||||
@@ -28,6 +28,15 @@ class TestRuntime {
|
||||
const __brunoTestResults = new TestResults();
|
||||
const test = Test(__brunoTestResults, chai);
|
||||
|
||||
if(!testsFile || !testsFile.length) {
|
||||
return {
|
||||
request,
|
||||
envVariables,
|
||||
collectionVariables,
|
||||
results: __brunoTestResults.getResults()
|
||||
};
|
||||
}
|
||||
|
||||
const context = {
|
||||
test,
|
||||
bru,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@usebruno/lang",
|
||||
"version": "0.2.2",
|
||||
"version": "0.3.0",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"src",
|
||||
|
||||
@@ -20,6 +20,14 @@ You can use git or any version control of your choice to collaborate over your a
|
||||
|
||||
 <br /><br />
|
||||
|
||||
### Run across multiple platforms 🖥️
|
||||
 <br /><br />
|
||||
|
||||
### Collaborate via Git 👩💻🧑💻
|
||||
Or any version control system of your choice
|
||||
|
||||
 <br /><br />
|
||||
|
||||
### Website 📄
|
||||
Please visit [here](https://www.usebruno.com) to checkout our website and download the app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user