lighthouse-flows-generator
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"bin": { | ||
"lighthouse-flows-generator": "./build/cli.js" | ||
"lighthouse-flows-generator": "./bin/cli.js" | ||
}, | ||
"name": "lighthouse-flows-generator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
"main": "./build/cli.js", | ||
"types": "./build/cli.d.ts", | ||
"main": "./dist/cli.js", | ||
"types": "./dist/cli.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc" | ||
@@ -13,0 +12,0 @@ }, |
import type { Arguments, CommandBuilder } from "yargs"; | ||
import puppeteer from "puppeteer"; | ||
import FlowResult from "lighthouse/types/lhr/flow"; | ||
@@ -7,5 +8,8 @@ import Result from "lighthouse/types/lhr/lhr"; | ||
import { generateFlowReportHtml } from "lighthouse/report/generator/report-generator"; | ||
// @ts-ignore | ||
import { startFlow } from "lighthouse/lighthouse-core/fraggle-rock/api.js"; | ||
type Options = { | ||
files: string[]; | ||
files?: string[]; | ||
urls?: string[]; | ||
}; | ||
@@ -15,21 +19,37 @@ | ||
yargs.options({ | ||
files: { array: true, string: true, required: true }, | ||
files: { array: true, string: true }, | ||
urls: { array: true, string: true }, | ||
}); | ||
export const handler = (argv: Arguments<Options>): void => { | ||
export const handler = async (argv: Arguments<Options>): Promise<void> => { | ||
const name = new Date().toString(); | ||
const flowResult: FlowResult = { | ||
name, | ||
steps: argv.files.map((file, index): FlowResult.Step => { | ||
const lhr: Result = JSON.parse(readFileSync(file, "utf8")); | ||
return { | ||
name: index.toString(), | ||
lhr, | ||
}; | ||
}), | ||
}; | ||
const report = generateFlowReportHtml(flowResult); | ||
writeFileSync(`${name}.html`, report); | ||
process.stdout.write("hello"); | ||
if (argv.files && argv.files.length > 0) { | ||
const flowResult: FlowResult = { | ||
name, | ||
steps: argv.files.map((file, index): FlowResult.Step => { | ||
const lhr: Result = JSON.parse(readFileSync(file, "utf8")); | ||
return { | ||
name: index.toString(), | ||
lhr, | ||
}; | ||
}), | ||
}; | ||
const report = generateFlowReportHtml(flowResult); | ||
writeFileSync(`${name}.html`, report); | ||
} else if (argv.urls && argv.urls.length > 0) { | ||
const browser = await puppeteer.launch({ headless: true }); | ||
const page = await browser.newPage(); | ||
const flow = await startFlow(page, { name }); | ||
for (const url of argv.urls) { | ||
await flow.navigate(url) | ||
} | ||
await browser.close(); | ||
const report = flow.generateReport(); | ||
writeFileSync(`${name}.html`, report); | ||
} | ||
process.exit(0); | ||
}; |
@@ -50,3 +50,3 @@ { | ||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ | ||
"outDir": "./build", /* Specify an output folder for all emitted files. */ | ||
"outDir": "./dist", /* Specify an output folder for all emitted files. */ | ||
// "removeComments": true, /* Disable emitting comments. */ | ||
@@ -53,0 +53,0 @@ // "noEmit": true, /* Disable emitting files from a compilation. */ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1
1
0
13407250
13
150