mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-23 07:09:01 +01:00
Merge branch 'main' of https://github.com/usebruno/bruno into main
This commit is contained in:
commit
0866d33858
@ -117,7 +117,7 @@ const Sidebar = () => {
|
||||
</GitHubButton>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-grow items-center justify-end text-xs mr-2">v0.12.0</div>
|
||||
<div className="flex flex-grow items-center justify-end text-xs mr-2">v0.12.2</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@usebruno/cli",
|
||||
"version": "0.4.4",
|
||||
"version": "0.5.1",
|
||||
"main": "src/index.js",
|
||||
"bin": {
|
||||
"bru": "./bin/bru.js"
|
||||
|
@ -35,6 +35,15 @@ const printRunSummary = (assertionResults, testResults) => {
|
||||
|
||||
console.log("\n" + chalk.bold(assertSummary));
|
||||
console.log(chalk.bold(testSummary));
|
||||
|
||||
return {
|
||||
totalAssertions,
|
||||
passedAssertions,
|
||||
failedAssertions,
|
||||
totalTests,
|
||||
passedTests,
|
||||
failedTests
|
||||
}
|
||||
};
|
||||
|
||||
const getBruFilesRecursively = (dir) => {
|
||||
@ -45,6 +54,10 @@ const getBruFilesRecursively = (dir) => {
|
||||
|
||||
const traverse = (currentPath) => {
|
||||
const filesInCurrentDir = fs.readdirSync(currentPath);
|
||||
|
||||
if (currentPath.includes('node_modules')) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of filesInCurrentDir) {
|
||||
const filePath = path.join(currentPath, file);
|
||||
@ -170,8 +183,14 @@ const handler = async function (argv) {
|
||||
testResults
|
||||
} = result;
|
||||
|
||||
printRunSummary(assertionResults, testResults);
|
||||
const summary = printRunSummary(assertionResults, testResults);
|
||||
console.log(chalk.dim(chalk.grey('Done.')));
|
||||
|
||||
if(summary.failedAssertions > 0 || summary.failedTests > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,12 +245,17 @@ const handler = async function (argv) {
|
||||
}
|
||||
}
|
||||
|
||||
printRunSummary(assertionResults, testResults);
|
||||
const summary = printRunSummary(assertionResults, testResults);
|
||||
console.log(chalk.dim(chalk.grey('Ran all requests.')));
|
||||
|
||||
if(summary.failedAssertions > 0 || summary.failedTests > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("Something went wrong");
|
||||
console.error(chalk.red(err.message));
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,6 +42,15 @@ 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);
|
||||
}
|
||||
|
@ -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.12.0",
|
||||
"version": "0.12.2",
|
||||
"name": "bruno",
|
||||
"description": "Opensource API Client",
|
||||
"homepage": "https://www.usebruno.com",
|
||||
|
@ -1,3 +1,4 @@
|
||||
const qs = require('qs');
|
||||
const axios = require('axios');
|
||||
const Mustache = require('mustache');
|
||||
const FormData = require('form-data');
|
||||
@ -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))
|
||||
|
@ -42,6 +42,15 @@ 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);
|
||||
}
|
||||
|
@ -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') {
|
||||
|
Loading…
Reference in New Issue
Block a user