@usebruno/cli
Advanced tools
Comparing version 1.1.1 to 1.2.0
# Changelog | ||
## 1.2.0 | ||
- Support for `bru.setNextRequest()` | ||
## 1.1.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "@usebruno/cli", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -27,3 +27,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@usebruno/js": "0.9.2", | ||
"@usebruno/js": "0.9.3", | ||
"@usebruno/lang": "0.9.0", | ||
@@ -30,0 +30,0 @@ "axios": "^1.5.1", |
@@ -358,3 +358,6 @@ const fs = require('fs'); | ||
for (const iter of bruJsons) { | ||
let currentRequestIndex = 0; | ||
let nJumps = 0; // count the number of jumps to avoid infinite loops | ||
while (currentRequestIndex < bruJsons.length) { | ||
const iter = bruJsons[currentRequestIndex]; | ||
const { bruFilepath, bruJson } = iter; | ||
@@ -373,2 +376,24 @@ const result = await runSingleRequest( | ||
results.push(result); | ||
// determine next request | ||
const nextRequestName = result?.nextRequestName; | ||
if (nextRequestName !== undefined) { | ||
nJumps++; | ||
if (nJumps > 10000) { | ||
console.error(chalk.red(`Too many jumps, possible infinite loop`)); | ||
process.exit(1); | ||
} | ||
if (nextRequestName === null) { | ||
break; | ||
} | ||
const nextRequestIdx = bruJsons.findIndex((iter) => iter.bruJson.name === nextRequestName); | ||
if (nextRequestIdx >= 0) { | ||
currentRequestIndex = nextRequestIdx; | ||
} else { | ||
console.error("Could not find request with name '" + nextRequestName + "'"); | ||
currentRequestIndex++; | ||
} | ||
} else { | ||
currentRequestIndex++; | ||
} | ||
} | ||
@@ -375,0 +400,0 @@ |
@@ -6,3 +6,3 @@ const os = require('os'); | ||
const fs = require('fs'); | ||
const { forOwn, each, extend, get, compact } = require('lodash'); | ||
const { forOwn, isUndefined, isNull, each, extend, get, compact } = require('lodash'); | ||
const FormData = require('form-data'); | ||
@@ -21,2 +21,4 @@ const prepareRequest = require('./prepare-request'); | ||
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/; | ||
const runSingleRequest = async function ( | ||
@@ -34,2 +36,3 @@ filename, | ||
let request; | ||
let nextRequestName; | ||
@@ -72,3 +75,3 @@ request = prepareRequest(bruJson.request, collectionRoot); | ||
const scriptRuntime = new ScriptRuntime(); | ||
await scriptRuntime.runRequestScript( | ||
const result = await scriptRuntime.runRequestScript( | ||
decomment(requestScriptFile), | ||
@@ -83,2 +86,5 @@ request, | ||
); | ||
if (result?.nextRequestName !== undefined) { | ||
nextRequestName = result.nextRequestName; | ||
} | ||
} | ||
@@ -89,2 +95,6 @@ | ||
if (!protocolRegex.test(request.url)) { | ||
request.url = `http://${request.url}`; | ||
} | ||
const options = getOptions(); | ||
@@ -145,2 +155,3 @@ const insecure = get(options, 'insecure', false); | ||
let uriPort = isUndefined(proxyPort) || isNull(proxyPort) ? '' : `:${proxyPort}`; | ||
let proxyUri; | ||
@@ -151,5 +162,5 @@ if (proxyAuthEnabled) { | ||
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`; | ||
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}${uriPort}`; | ||
} else { | ||
proxyUri = `${proxyProtocol}://${proxyHostname}:${proxyPort}`; | ||
proxyUri = `${proxyProtocol}://${proxyHostname}${uriPort}`; | ||
} | ||
@@ -215,3 +226,4 @@ | ||
assertionResults: [], | ||
testResults: [] | ||
testResults: [], | ||
nextRequestName: nextRequestName | ||
}; | ||
@@ -221,2 +233,4 @@ } | ||
response.responseTime = responseTime; | ||
console.log( | ||
@@ -249,3 +263,3 @@ chalk.green(stripExtension(filename)) + | ||
const scriptRuntime = new ScriptRuntime(); | ||
await scriptRuntime.runResponseScript( | ||
const result = await scriptRuntime.runResponseScript( | ||
decomment(responseScriptFile), | ||
@@ -261,2 +275,5 @@ request, | ||
); | ||
if (result?.nextRequestName !== undefined) { | ||
nextRequestName = result.nextRequestName; | ||
} | ||
} | ||
@@ -333,3 +350,4 @@ | ||
assertionResults, | ||
testResults | ||
testResults, | ||
nextRequestName: nextRequestName | ||
}; | ||
@@ -336,0 +354,0 @@ } catch (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49108
1360
+ Added@usebruno/js@0.9.3(transitive)
- Removed@usebruno/js@0.9.2(transitive)
Updated@usebruno/js@0.9.3