license-kit
Version:
Aggregate license notes of OSS libraries used in your Node.js project, analyze & visualize OSS licenses with AI-turbocharged tooling
53 lines (52 loc) • 3.36 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.curryCommonScanOptions = curryCommonScanOptions;
exports.curryReportOptions = curryReportOptions;
exports.validateCommonScanOptions = validateCommonScanOptions;
exports.validateCommonReportOptions = validateCommonReportOptions;
const node_process_1 = __importDefault(require("node:process"));
const constants_1 = require("../constants");
const DevDepsMode_1 = require("../types/DevDepsMode");
const Format_1 = require("../types/Format");
const TransitiveDepsMode_1 = require("../types/TransitiveDepsMode");
function curryCommonScanOptions(command) {
return command
.option('--tm, --transitive-deps-mode [mode]', 'Controls, which transitive dependencies are included:' +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'all',` +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'from-external-only' (only transitive dependencies of direct dependencies specified by non-workspace:... specifiers),` +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'from-workspace-only' (only transitive dependencies of direct dependencies specified by \`workspace:\` specifier),` +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'none'` +
'\n', // newline for auto-description of the default value
'all')
.option('--dm, --dev-deps-mode [mode]', 'Controls, whether and how development dependencies are included:' +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'root-only' (only direct devDependencies from the scanned project's root package.json)` +
`\n${constants_1.NON_TAB_HELP_LISTING_SUBLIST_OFFSET}- 'none'` +
'\n', // newline for auto-description of the default value
'root-only')
.option('--od, --include-optional-deps [include]', 'Whether to include optionalDependencies in the scan; other flags apply', (value) => value === 'true' || value === '1', true);
}
function curryReportOptions(command) {
return command
.option('--root [path]', 'Path to the root of your project', '.')
.option('--format [type]', "Output format: 'json', 'about-json', 'text', 'markdown'", 'json')
.option('--output [path]', "Where to write the output: 'stdout' or a file path", 'stdout');
}
function validateCommonScanOptions(options) {
if (!DevDepsMode_1.validDevDepsModes.includes(options.devDepsMode)) {
console.error(`Invalid development dependencies scan mode: ${options.devDepsMode}. Supported modes: ${DevDepsMode_1.validDevDepsModes.join(', ')}`);
node_process_1.default.exit(1);
}
if (!TransitiveDepsMode_1.validTransitiveDepsModes.includes(options.transitiveDepsMode)) {
console.error(`Invalid transitive dependencies scan mode: ${options.transitiveDepsMode}. Supported modes: ${TransitiveDepsMode_1.validTransitiveDepsModes.join(', ')}`);
node_process_1.default.exit(1);
}
}
function validateCommonReportOptions(options) {
if (!Format_1.validFormats.includes(options.format)) {
console.error(`Invalid format: ${options.format}. Supported formats: ${Format_1.validFormats.join(', ')}`);
node_process_1.default.exit(1);
}
}