link-checker-cli
Version:
CLI tool to check for broken links in a website or project
51 lines (50 loc) • 1.64 kB
JavaScript
import { command, string, run, boolean, number } from "@drizzle-team/brocli";
import { CliCommandProcessor } from "./services/siteCommandProcessor.js";
import { SitemapCommandProcessor } from "./services/sitemapCommandProcessor.js";
const defaultOptions = {
source: string().required().alias("-s").desc("Path to website"),
recursive: boolean().default(false).alias("-r"),
image: boolean()
.default(false)
.alias("-img")
.desc("Fetches all page images."),
style: boolean()
.default(true)
.alias("-css")
.desc("Add style links to response."),
external: boolean()
.default(false)
.alias("-e")
.desc("Add external links to response."),
userAgent: string(),
concurrencySize: number()
.default(10)
.alias("-c")
.desc("Number of requests running simultaneous.")
};
const inspect = command({
name: "inspect",
options: defaultOptions,
handler: async (opts) => {
const commandProcessor = new CliCommandProcessor(opts);
await commandProcessor.createResult();
},
});
const sitemapOptions = {
source: string().required().alias("-s").desc("Path to website"),
userAgent: string(),
concurrencySize: number()
.default(10)
.alias("-c")
.desc("Number of requests running simultaneous.")
};
const sitemap = command({
name: "sitemap",
options: sitemapOptions,
handler: async (opts) => {
const commandProcessor = new SitemapCommandProcessor(opts);
await commandProcessor.inspectSitemap();
},
});
run([inspect, sitemap]);