Verified Commit 52685fb1 authored by Aral Balkan's avatar Aral Balkan
Browse files

No longer necessary to run Chrome manually for inquiry

parent 75c1b42a
......@@ -21,6 +21,8 @@ path = require 'path-extra'
moment = require 'moment'
Spinner = require('cli-spinner').Spinner
puppeteer = require 'puppeteer'
exec = (require 'child_process').exec
goGoGadgetASCII = require('./logo')
......@@ -312,61 +314,64 @@ prepareInspections = if isLocalInquiry then prepareInspectionsForLocalInquiry()
# reporting incorrect values when concurrency > 1, however (looks like ~double for 2, triple for 3)…
# TODO: look into this.
#
prepareInspections.then (inspections) ->
Promise.mapSeries(inspections, ((inspection) -> return inspection().reflect()), {concurrency: 1})
.then (inspection) ->
_ " ┴"
_ "\nResults:\n"
inspection
.each (inspection) ->
if inspection.isFulfilled()
_ " ✅ #{inspection.value()}"
else
_ " ❌ #{inspection.reason().message}"
.then ->
#
# Save the global statistics (which will be used by Builder)
#
statisticsFilePath = path.join path.homedir(), 'better.fyi', '.private', 'statistics.json'
fs.writeFileAsync statisticsFilePath, globalStatistics.json()
.then =>
#
# Display statistics
#
_ "\nStatistics"
_ "==========\n"
_ " · Domains analysed: #{inquiryStatistics.domainsAnalysed}"
_ " · Successes: #{inquiryStatistics.successes}"
_ " · Failures: #{inquiryStatistics.failures}"
_ " · Average task duration: #{moment.duration(inquiryStatistics.taskDurations.reduce((prev, current) -> (prev + current))/inquiryStatistics.taskDurations.length).asSeconds().toFixed(2)}s"
_ " · Total task duration: #{moment.duration(inquiryStatistics.taskDurations.reduce((prev, current) -> prev + current)).asSeconds().toFixed(2)}s"
_ "\n"
#
# Display found domains
#
if args.find?
domainsSearchTermWasFoundOn = Object.keys foundThirdPartyRequests
if domainsSearchTermWasFoundOn.length > 0
underline = Array(args.find.length+1).join '='
_ "Found requests containing ‘#{args.find}’"
_ "============================#{underline}\n"
for domain in domainsSearchTermWasFoundOn
matchingThirdPartyRequestsOnDomain = foundThirdPartyRequests[domain]
_ " · #{domain}"
for request in matchingThirdPartyRequestsOnDomain
_ " · #{request}"
_ "\n"
else
_ "Could not find requests containing ‘#{args.find}’."
(puppeteer.launch args: ['--remote-debugging-port=9222']).then (browser) ->
prepareInspections.then (inspections) ->
Promise.mapSeries(inspections, ((inspection) -> return inspection().reflect()), {concurrency: 1})
.then (inspection) ->
_ " ┴"
_ "\nResults:\n"
inspection
.each (inspection) ->
if inspection.isFulfilled()
_ " ✅ #{inspection.value()}"
else
_ " ❌ #{inspection.reason().message}"
.then ->
#
# Save the global statistics (which will be used by Builder)
#
.catch (error) =>
_ "\nError saving global statistics: #{error}\n"
statisticsFilePath = path.join path.homedir(), 'better.fyi', '.private', 'statistics.json'
fs.writeFileAsync statisticsFilePath, globalStatistics.json()
.then =>
#
# Display statistics
#
_ "\nStatistics"
_ "==========\n"
_ " · Domains analysed: #{inquiryStatistics.domainsAnalysed}"
_ " · Successes: #{inquiryStatistics.successes}"
_ " · Failures: #{inquiryStatistics.failures}"
_ " · Average task duration: #{moment.duration(inquiryStatistics.taskDurations.reduce((prev, current) -> (prev + current))/inquiryStatistics.taskDurations.length).asSeconds().toFixed(2)}s"
_ " · Total task duration: #{moment.duration(inquiryStatistics.taskDurations.reduce((prev, current) -> prev + current)).asSeconds().toFixed(2)}s"
_ "\n"
#
# Display found domains
#
if args.find?
domainsSearchTermWasFoundOn = Object.keys foundThirdPartyRequests
if domainsSearchTermWasFoundOn.length > 0
underline = Array(args.find.length+1).join '='
_ "Found requests containing ‘#{args.find}’"
_ "============================#{underline}\n"
for domain in domainsSearchTermWasFoundOn
matchingThirdPartyRequestsOnDomain = foundThirdPartyRequests[domain]
_ " · #{domain}"
for request in matchingThirdPartyRequestsOnDomain
_ " · #{request}"
_ "\n"
else
_ "Could not find requests containing ‘#{args.find}’."
.catch (error) =>
_ "\nError saving global statistics: #{error}\n"
.catch (error) ->
console.log ("Could not launch browser " + error)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment