cf-worker-prune-routes
Version:
Prune unused cloudflare worker routes
43 lines (39 loc) • 1.11 kB
JavaScript
#!/usr/bin/env node
import path from 'path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { cfWorkerPruneRoutes } from '../index.js';
const { argv } = yargs(hideBin(process.argv))
.options('config', {
alias: 'c',
description: 'path to your wrangler.toml config',
default: path.resolve(process.cwd(), 'wrangler.toml'),
string: true,
})
.options('env', {
description: 'The env for the worker routes you want to prune',
alias: 'e',
demandOption: true,
string: true,
})
.options('execute', {
description: 'Execute route pruning',
alias: 'p',
boolean: true,
})
.options('fail', {
description: 'Throw an error if there are any unpruned routes',
alias: 'f',
boolean: true,
})
.options('verbose', {
description: 'Show extra logs',
alias: 'v',
boolean: true,
})
.command(
'$0 [options..]',
"Reads your wrangler.toml config, queries cloudflare for your existing routes, and removes any routes that aren't currently configured for your worker"
)
.help();
cfWorkerPruneRoutes(argv);