109 lines
4.0 KiB
JavaScript
109 lines
4.0 KiB
JavaScript
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var validate_params_exports = {};
|
|
__export(validate_params_exports, {
|
|
validateParams: () => validateParams
|
|
});
|
|
module.exports = __toCommonJS(validate_params_exports);
|
|
var commands = __toESM(require("./commands"));
|
|
function validateParams(argv, argsParserOpts) {
|
|
const {
|
|
_: _commandList,
|
|
file,
|
|
source,
|
|
glob,
|
|
outFile,
|
|
outDir,
|
|
transformer,
|
|
config,
|
|
debug,
|
|
version,
|
|
...rest
|
|
} = argv;
|
|
const commandList = _commandList || [];
|
|
const commandName = commandList[0];
|
|
const command = commands.get(commandName);
|
|
const params = [file, source, glob, outFile, outDir, transformer].filter((item) => item !== void 0);
|
|
const commandAliases = Object.keys(argsParserOpts.alias).concat(...Object.values(argsParserOpts.alias));
|
|
const restParams = Object.keys(rest).filter((item) => commandAliases.includes(item) === false);
|
|
if (commandList.length > 1) {
|
|
throw new Error("More than one command passed.");
|
|
}
|
|
if (Object.keys(restParams).length > 0) {
|
|
throw new Error("Unknown parameters passed.");
|
|
}
|
|
if (version && commandName !== void 0) {
|
|
throw new Error("--version parameter cannot be passed to commands.");
|
|
}
|
|
if (version && (params.length > 0 || restParams.length > 0 || config || debug)) {
|
|
throw new Error("--version parameter cannot be used with other parameters.");
|
|
}
|
|
if (commandName === "") {
|
|
throw new Error("Command name is empty.");
|
|
}
|
|
if (commandName !== void 0 && typeof command !== "function") {
|
|
throw new Error(`Command not found: ${commandName}.`);
|
|
}
|
|
if (commandName === "info" && debug) {
|
|
throw new Error('--debug parameter cannot be passed to "info" command.');
|
|
}
|
|
if (commandName !== void 0 && config !== void 0) {
|
|
throw new Error("--config parameter cannot be passed to commands.");
|
|
}
|
|
if (config !== void 0 && params.length > 0) {
|
|
throw new Error("--config parameter cannot be used with other parameters.");
|
|
}
|
|
if (file === "" || Array.isArray(file) && file.length === 0) {
|
|
throw new Error("--file must not be empty.");
|
|
}
|
|
if (source === "") {
|
|
throw new Error("--source must not be empty.");
|
|
}
|
|
if (glob === "" || Array.isArray(glob) && glob.length === 0) {
|
|
throw new Error("--glob must not be empty.");
|
|
}
|
|
if (outFile === "") {
|
|
throw new Error("--outFile must not be empty.");
|
|
}
|
|
if (outDir === "") {
|
|
throw new Error("--outDir must not be empty.");
|
|
}
|
|
if (file !== void 0 && source !== void 0) {
|
|
throw new Error("--file and --source parameters cannot be used together.");
|
|
}
|
|
if (file !== void 0 && glob !== void 0) {
|
|
throw new Error("--file and --glob parameters cannot be used together.");
|
|
}
|
|
if (source !== void 0 && glob !== void 0) {
|
|
throw new Error("--source and --glob parameters cannot be used together.");
|
|
}
|
|
if (outFile !== void 0 && outDir !== void 0) {
|
|
throw new Error("--outFile and --outDir parameters cannot be used together.");
|
|
}
|
|
}
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
validateParams
|
|
});
|