Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lighthouse-flows-generator

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lighthouse-flows-generator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

bin/cli.js

9

package.json
{
"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. */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc