drizzle-kit 0.24.0-bb966f7 → 0.24.0-bddd952
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.cjs +598 -213
- package/package.json +4 -4
package/bin.cjs
CHANGED
@@ -81484,7 +81484,7 @@ var init_studio2 = __esm({
|
|
81484
81484
|
}
|
81485
81485
|
});
|
81486
81486
|
|
81487
|
-
// ../node_modules/.pnpm/@drizzle-team+brocli@0.
|
81487
|
+
// ../node_modules/.pnpm/@drizzle-team+brocli@0.10.1/node_modules/@drizzle-team/brocli/index.js
|
81488
81488
|
var __create2 = Object.create;
|
81489
81489
|
var __defProp2 = Object.defineProperty;
|
81490
81490
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
@@ -81931,130 +81931,299 @@ var require_shell_quote = __commonJS2({
|
|
81931
81931
|
}
|
81932
81932
|
});
|
81933
81933
|
var BroCliError = class extends Error {
|
81934
|
-
constructor(message) {
|
81934
|
+
constructor(message, event) {
|
81935
81935
|
const errPrefix = "BroCli error: ";
|
81936
81936
|
super(message === void 0 ? message : `${errPrefix}${message}`);
|
81937
|
+
this.event = event;
|
81937
81938
|
}
|
81938
81939
|
};
|
81939
81940
|
var import_clone = __toESM2(require_clone(), 1);
|
81940
|
-
var
|
81941
|
-
|
81942
|
-
|
81943
|
-
|
81944
|
-
|
81945
|
-
|
81946
|
-
|
81947
|
-
|
81948
|
-
|
81949
|
-
|
81950
|
-
|
81951
|
-
|
81952
|
-
|
81953
|
-
|
81954
|
-
|
81955
|
-
|
81956
|
-
|
81957
|
-
|
81958
|
-
|
81959
|
-
|
81960
|
-
|
81961
|
-
|
81962
|
-
|
81963
|
-
|
81964
|
-
|
81965
|
-
}
|
81966
|
-
|
81967
|
-
|
81968
|
-
|
81969
|
-
|
81970
|
-
|
81971
|
-
|
81972
|
-
|
81973
|
-
|
81941
|
+
var getOptionTypeText = (option) => {
|
81942
|
+
let result = "";
|
81943
|
+
switch (option.type) {
|
81944
|
+
case "boolean":
|
81945
|
+
result = "";
|
81946
|
+
break;
|
81947
|
+
case "number": {
|
81948
|
+
if ((option.minVal ?? option.maxVal) !== void 0) {
|
81949
|
+
let text = "";
|
81950
|
+
if (option.isInt)
|
81951
|
+
text = text + `integer `;
|
81952
|
+
if (option.minVal !== void 0)
|
81953
|
+
text = text + `[${option.minVal};`;
|
81954
|
+
else
|
81955
|
+
text = text + `(\u221E;`;
|
81956
|
+
if (option.maxVal !== void 0)
|
81957
|
+
text = text + `${option.maxVal}]`;
|
81958
|
+
else
|
81959
|
+
text = text + `\u221E)`;
|
81960
|
+
result = text;
|
81961
|
+
break;
|
81962
|
+
}
|
81963
|
+
if (option.isInt) {
|
81964
|
+
result = "integer";
|
81965
|
+
break;
|
81966
|
+
}
|
81967
|
+
result = "number";
|
81968
|
+
break;
|
81969
|
+
}
|
81970
|
+
case "string": {
|
81971
|
+
if (option.enumVals) {
|
81972
|
+
result = "[ " + option.enumVals.join(" | ") + " ]";
|
81973
|
+
break;
|
81974
|
+
}
|
81975
|
+
result = "string";
|
81976
|
+
break;
|
81977
|
+
}
|
81978
|
+
case "positional": {
|
81979
|
+
result = `${option.isRequired ? "<" : "["}${option.enumVals ? option.enumVals.join("|") : option.name}${option.isRequired ? ">" : "]"}`;
|
81980
|
+
break;
|
81981
|
+
}
|
81982
|
+
}
|
81983
|
+
if (option.isRequired && option.type !== "positional")
|
81984
|
+
result = "!" + result.length ? " " : "" + result;
|
81985
|
+
return result;
|
81986
|
+
};
|
81987
|
+
var defaultEventHandler = async (event) => {
|
81988
|
+
var _a;
|
81989
|
+
switch (event.type) {
|
81990
|
+
case "command_help": {
|
81991
|
+
const command2 = event.command;
|
81992
|
+
const commandName = getCommandNameWithParents(command2);
|
81993
|
+
const cliName = event.name;
|
81994
|
+
const desc = command2.desc ?? command2.shortDesc;
|
81995
|
+
const subs = (_a = command2.subcommands) == null ? void 0 : _a.filter((s2) => !s2.hidden);
|
81996
|
+
const subcommands = subs && subs.length ? subs : void 0;
|
81997
|
+
if (desc !== void 0) {
|
81998
|
+
console.log(`
|
81999
|
+
${desc}`);
|
82000
|
+
}
|
82001
|
+
const opts = Object.values(command2.options ?? {}).filter(
|
82002
|
+
(opt) => !opt.config.isHidden
|
82003
|
+
);
|
82004
|
+
const positionals = opts.filter((opt) => opt.config.type === "positional");
|
82005
|
+
const options = opts.filter((opt) => opt.config.type !== "positional");
|
82006
|
+
console.log("\nUsage:");
|
82007
|
+
if (command2.handler) {
|
82008
|
+
console.log(
|
82009
|
+
` ${cliName ? cliName + " " : ""}${commandName}${positionals.length ? " " + positionals.map(({ config: p2 }) => getOptionTypeText(p2)).join(" ") : ""} [flags]`
|
82010
|
+
);
|
82011
|
+
} else
|
82012
|
+
console.log(` ${cliName ? cliName + " " : ""}${commandName} [command]`);
|
82013
|
+
if (command2.aliases) {
|
82014
|
+
console.log(`
|
82015
|
+
Aliases:`);
|
82016
|
+
console.log(` ${[command2.name, ...command2.aliases].join(", ")}`);
|
82017
|
+
}
|
82018
|
+
if (subcommands) {
|
82019
|
+
console.log("\nAvailable Commands:");
|
82020
|
+
const padding = 3;
|
82021
|
+
const maxLength = subcommands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
|
82022
|
+
const paddedLength = maxLength + padding;
|
82023
|
+
const preDescPad = 2 + paddedLength;
|
82024
|
+
const data = subcommands.map(
|
82025
|
+
(s2) => ` ${s2.name.padEnd(paddedLength)}${(() => {
|
82026
|
+
const description = s2.shortDesc ?? s2.desc;
|
82027
|
+
if (!(description == null ? void 0 : description.length))
|
82028
|
+
return "";
|
82029
|
+
const split = description.split("\n");
|
82030
|
+
const first = split.shift();
|
82031
|
+
const final = [first, ...split.map((s22) => "".padEnd(preDescPad) + s22)].join("\n");
|
82032
|
+
return final;
|
82033
|
+
})()}`
|
82034
|
+
).join("\n");
|
82035
|
+
console.log(data);
|
82036
|
+
}
|
82037
|
+
if (options.length) {
|
82038
|
+
const aliasLength = options.reduce((p2, e2) => {
|
82039
|
+
const currentLength = e2.config.aliases.reduce((pa, a) => pa + a.length, 0) + (e2.config.aliases.length - 1) * 2 + 1;
|
82040
|
+
return currentLength > p2 ? currentLength : p2;
|
82041
|
+
}, 0);
|
82042
|
+
const paddedAliasLength = aliasLength > 0 ? aliasLength + 1 : 0;
|
82043
|
+
const nameLength = options.reduce((p2, e2) => {
|
82044
|
+
const typeLen = getOptionTypeText(e2.config).length;
|
82045
|
+
const length = typeLen > 0 ? e2.config.name.length + 1 + typeLen : e2.config.name.length;
|
82046
|
+
return length > p2 ? length : p2;
|
82047
|
+
}, 0) + 3;
|
82048
|
+
const preDescPad = paddedAliasLength + nameLength + 2;
|
82049
|
+
const data = options.map(
|
82050
|
+
({ config: opt }) => ` ${`${opt.aliases.length ? opt.aliases.join(", ") + "," : ""}`.padEnd(paddedAliasLength)}${`${opt.name}${(() => {
|
82051
|
+
const typeText = getOptionTypeText(opt);
|
82052
|
+
return typeText.length ? " " + typeText : "";
|
82053
|
+
})()}`.padEnd(nameLength)}${(() => {
|
82054
|
+
var _a2;
|
82055
|
+
if (!((_a2 = opt.description) == null ? void 0 : _a2.length)) {
|
82056
|
+
return opt.default !== void 0 ? `default: ${JSON.stringify(opt.default)}` : "";
|
82057
|
+
}
|
82058
|
+
const split = opt.description.split("\n");
|
82059
|
+
const first = split.shift();
|
82060
|
+
const def = opt.default !== void 0 ? ` (default: ${JSON.stringify(opt.default)})` : "";
|
82061
|
+
const final = [first, ...split.map((s2) => "".padEnd(preDescPad) + s2)].join("\n") + def;
|
82062
|
+
return final;
|
82063
|
+
})()}`
|
82064
|
+
).join("\n");
|
82065
|
+
console.log("\nFlags:");
|
82066
|
+
console.log(data);
|
82067
|
+
}
|
82068
|
+
console.log("\nGlobal flags:");
|
82069
|
+
console.log(` -h, --help help for ${commandName}`);
|
82070
|
+
console.log(` -v, --version version${cliName ? ` for ${cliName}` : ""}`);
|
82071
|
+
if (subcommands) {
|
82072
|
+
console.log(
|
82073
|
+
`
|
82074
|
+
Use "${cliName ? cliName + " " : ""}${commandName} [command] --help" for more information about a command.
|
82075
|
+
`
|
82076
|
+
);
|
82077
|
+
}
|
82078
|
+
return true;
|
82079
|
+
}
|
82080
|
+
case "global_help": {
|
82081
|
+
const cliName = event.name;
|
82082
|
+
const desc = event.description;
|
82083
|
+
const commands = event.commands.filter((c) => !c.hidden);
|
82084
|
+
if (desc !== void 0) {
|
82085
|
+
console.log(`${desc}
|
82086
|
+
`);
|
82087
|
+
}
|
82088
|
+
console.log("Usage:");
|
82089
|
+
console.log(` ${cliName ? cliName + " " : ""}[command]`);
|
82090
|
+
if (commands.length) {
|
82091
|
+
console.log("\nAvailable Commands:");
|
82092
|
+
const padding = 3;
|
82093
|
+
const maxLength = commands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
|
82094
|
+
const paddedLength = maxLength + padding;
|
82095
|
+
const data = commands.map(
|
82096
|
+
(\u0441) => ` ${\u0441.name.padEnd(paddedLength)}${(() => {
|
82097
|
+
const desc2 = \u0441.shortDesc ?? \u0441.desc;
|
82098
|
+
if (!(desc2 == null ? void 0 : desc2.length))
|
82099
|
+
return "";
|
82100
|
+
const split = desc2.split("\n");
|
82101
|
+
const first = split.shift();
|
82102
|
+
const final = [first, ...split.map((s2) => "".padEnd(paddedLength + 2) + s2)].join("\n");
|
82103
|
+
return final;
|
82104
|
+
})()}`
|
82105
|
+
).join("\n");
|
82106
|
+
console.log(data);
|
82107
|
+
} else {
|
82108
|
+
console.log("\nNo available commands.");
|
82109
|
+
}
|
82110
|
+
console.log("\nFlags:");
|
82111
|
+
console.log(` -h, --help help${cliName ? ` for ${cliName}` : ""}`);
|
82112
|
+
console.log(` -v, --version version${cliName ? ` for ${cliName}` : ""}`);
|
82113
|
+
console.log("\n");
|
82114
|
+
return true;
|
82115
|
+
}
|
82116
|
+
case "version": {
|
82117
|
+
return true;
|
82118
|
+
}
|
82119
|
+
case "error": {
|
82120
|
+
let msg;
|
82121
|
+
switch (event.violation) {
|
82122
|
+
case "above_max": {
|
82123
|
+
const matchedName = event.offender.namePart;
|
82124
|
+
const data = event.offender.dataPart;
|
82125
|
+
const option = event.option;
|
82126
|
+
const max = option.maxVal;
|
82127
|
+
msg = `Invalid value: number type argument '${matchedName}' expects maximal value of ${max} as an input, got: ${data}`;
|
82128
|
+
break;
|
82129
|
+
}
|
82130
|
+
case "below_min": {
|
82131
|
+
const matchedName = event.offender.namePart;
|
82132
|
+
const data = event.offender.dataPart;
|
82133
|
+
const option = event.option;
|
82134
|
+
const min = option.minVal;
|
82135
|
+
msg = `Invalid value: number type argument '${matchedName}' expects minimal value of ${min} as an input, got: ${data}`;
|
82136
|
+
break;
|
82137
|
+
}
|
82138
|
+
case "expected_int": {
|
82139
|
+
const matchedName = event.offender.namePart;
|
82140
|
+
const data = event.offender.dataPart;
|
82141
|
+
msg = `Invalid value: number type argument '${matchedName}' expects an integer as an input, got: ${data}`;
|
82142
|
+
break;
|
82143
|
+
}
|
82144
|
+
case "invalid_boolean_syntax": {
|
82145
|
+
const matchedName = event.offender.namePart;
|
82146
|
+
const data = event.offender.dataPart;
|
82147
|
+
msg = `Invalid syntax: boolean type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value> | ${matchedName}.
|
82148
|
+
Allowed values: true, false, 0, 1`;
|
82149
|
+
break;
|
82150
|
+
}
|
82151
|
+
case "invalid_string_syntax": {
|
82152
|
+
const matchedName = event.offender.namePart;
|
82153
|
+
msg = `Invalid syntax: string type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`;
|
82154
|
+
break;
|
82155
|
+
}
|
82156
|
+
case "invalid_number_syntax": {
|
82157
|
+
const matchedName = event.offender.namePart;
|
82158
|
+
msg = `Invalid syntax: number type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`;
|
82159
|
+
break;
|
82160
|
+
}
|
82161
|
+
case "invalid_number_value": {
|
82162
|
+
const matchedName = event.offender.namePart;
|
82163
|
+
const data = event.offender.dataPart;
|
82164
|
+
msg = `Invalid value: number type argument '${matchedName}' expects a number as an input, got: ${data}`;
|
82165
|
+
break;
|
82166
|
+
}
|
82167
|
+
case "enum_violation": {
|
82168
|
+
const matchedName = event.offender.namePart;
|
82169
|
+
const data = event.offender.dataPart;
|
82170
|
+
const option = event.option;
|
82171
|
+
const values = option.enumVals;
|
82172
|
+
msg = option.type === "positional" ? `Invalid value: value for the positional argument '${option.name}' must be either one of the following: ${values.join(", ")}; Received: ${data}` : `Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`;
|
82173
|
+
break;
|
82174
|
+
}
|
82175
|
+
case "unknown_command_error": {
|
82176
|
+
const msg2 = `Unknown command: '${event.offender}'.
|
82177
|
+
Type '--help' to get help on the cli.`;
|
82178
|
+
console.error(msg2);
|
82179
|
+
return true;
|
82180
|
+
}
|
82181
|
+
case "unknown_subcommand_error": {
|
82182
|
+
const cName = getCommandNameWithParents(event.command);
|
82183
|
+
const msg2 = `Unknown command: ${cName} ${event.offender}.
|
82184
|
+
Type '${cName} --help' to get the help on command.`;
|
82185
|
+
console.error(msg2);
|
82186
|
+
return true;
|
82187
|
+
}
|
82188
|
+
case "missing_args_error": {
|
82189
|
+
const missingOpts = event.missing;
|
82190
|
+
msg = `Command '${command.name}' is missing following required options: ${missingOpts.map((opt) => {
|
82191
|
+
const name = opt.shift();
|
82192
|
+
const aliases = opt;
|
82193
|
+
if (aliases.length)
|
82194
|
+
return `${name} [${aliases.join(", ")}]`;
|
82195
|
+
return name;
|
82196
|
+
}).join(", ")}`;
|
82197
|
+
break;
|
82198
|
+
}
|
82199
|
+
case "unrecognized_args_error": {
|
82200
|
+
const { command: command2, unrecognized } = event;
|
82201
|
+
msg = `Unrecognized options for command '${command2.name}': ${unrecognized.join(", ")}`;
|
82202
|
+
break;
|
82203
|
+
}
|
82204
|
+
case "unknown_error": {
|
82205
|
+
const e2 = event.error;
|
82206
|
+
console.error(typeof e2 === "object" && e2 !== null && "message" in e2 ? e2.message : e2);
|
82207
|
+
return true;
|
82208
|
+
}
|
82209
|
+
}
|
82210
|
+
console.error(msg);
|
82211
|
+
return true;
|
82212
|
+
}
|
81974
82213
|
}
|
82214
|
+
return false;
|
81975
82215
|
};
|
82216
|
+
var eventHandlerWrapper = (customEventHandler) => async (event) => await customEventHandler(event) ? true : await defaultEventHandler(event);
|
82217
|
+
var import_shell_quote = __toESM2(require_shell_quote(), 1);
|
81976
82218
|
function isInt(value) {
|
81977
82219
|
return value === Math.floor(value);
|
81978
82220
|
}
|
81979
|
-
var
|
81980
|
-
const msg = `Unknown command: '${caller}'.
|
81981
|
-
Type '--help' to get help on the cli.`;
|
81982
|
-
return new Error(msg);
|
81983
|
-
};
|
81984
|
-
var unknownSubcommand = (command2, caller) => {
|
81985
|
-
const name = getCommandNameRecursive(command2);
|
81986
|
-
const msg = `Unknown command: ${name} ${caller}.
|
81987
|
-
Type '${name} --help' to get the help on command.`;
|
81988
|
-
new Error(
|
81989
|
-
msg
|
81990
|
-
);
|
81991
|
-
return new Error(msg);
|
81992
|
-
};
|
81993
|
-
var missingRequired = (command2, missingOpts) => {
|
81994
|
-
const msg = `Command '${command2.name}' is missing following required options: ${missingOpts.map((opt) => {
|
81995
|
-
const name = opt.shift();
|
81996
|
-
const aliases = opt;
|
81997
|
-
if (aliases.length)
|
81998
|
-
return `${name} [${aliases.join(", ")}]`;
|
81999
|
-
return name;
|
82000
|
-
}).join(", ")}`;
|
82001
|
-
return new Error(msg);
|
82002
|
-
};
|
82003
|
-
var unrecognizedOptions = (command2, unrecognizedArgs) => {
|
82004
|
-
const msg = `Unrecognized options for command '${command2.name}': ${unrecognizedArgs.join(", ")}`;
|
82005
|
-
return new Error(msg);
|
82006
|
-
};
|
82007
|
-
var invalidBooleanSyntax = (matchedName) => {
|
82008
|
-
return new Error(
|
82009
|
-
`Invalid syntax: boolean type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value> | ${matchedName}.
|
82010
|
-
Allowed values: true, false, 0, 1`
|
82011
|
-
);
|
82012
|
-
};
|
82013
|
-
var invalidStringSyntax = (matchedName) => {
|
82014
|
-
return new Error(
|
82015
|
-
`Invalid syntax: string type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`
|
82016
|
-
);
|
82017
|
-
};
|
82018
|
-
var enumViolation = (matchedName, data, values) => {
|
82019
|
-
return new Error(
|
82020
|
-
`Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`
|
82021
|
-
);
|
82022
|
-
};
|
82023
|
-
var enumViolationPos = (matchedName, data, values) => {
|
82024
|
-
return new Error(
|
82025
|
-
`Invalid value: value for the argument '${matchedName}' must be either one of the following: ${values.join(", ")}; Received: ${data}`
|
82026
|
-
);
|
82027
|
-
};
|
82028
|
-
var invalidNumberSyntax = (matchedName) => {
|
82029
|
-
return new Error(
|
82030
|
-
`Invalid syntax: number type argument '${matchedName}' must have it's value passed in the following formats: ${matchedName}=<value> | ${matchedName} <value>`
|
82031
|
-
);
|
82032
|
-
};
|
82033
|
-
var invalidNumberValue = (matchedName, data) => {
|
82034
|
-
return new Error(
|
82035
|
-
`Invalid value: number type argument '${matchedName}' expects a number as an input, got: ${data}`
|
82036
|
-
);
|
82037
|
-
};
|
82038
|
-
var invalidInteger = (matchedName, data) => {
|
82039
|
-
return new Error(
|
82040
|
-
`Invalid value: number type argument '${matchedName}' expects an integer as an input, got: ${data}`
|
82041
|
-
);
|
82042
|
-
};
|
82043
|
-
var belowMin = (matchedName, data, min) => {
|
82044
|
-
return new Error(
|
82045
|
-
`Invalid value: number type argument '${matchedName}' expects minimal value of ${min} as an input, got: ${data}`
|
82046
|
-
);
|
82047
|
-
};
|
82048
|
-
var aboveMax = (matchedName, data, max) => {
|
82049
|
-
return new Error(
|
82050
|
-
`Invalid value: number type argument '${matchedName}' expects maximal value of ${max} as an input, got: ${data}`
|
82051
|
-
);
|
82052
|
-
};
|
82221
|
+
var executeOrLog = async (target) => typeof target === "string" ? console.log(target) : target ? await target() : void 0;
|
82053
82222
|
var generatePrefix = (name) => name.startsWith("-") ? name : name.length > 1 ? `--${name}` : `-${name}`;
|
82054
82223
|
var validateOptions = (config) => {
|
82055
82224
|
const cloned = (0, import_clone.default)(config);
|
82056
82225
|
const entries = [];
|
82057
|
-
const storedNames =
|
82226
|
+
const storedNames = [];
|
82058
82227
|
const cfgEntries = Object.entries(cloned);
|
82059
82228
|
for (const [key, value] of cfgEntries) {
|
82060
82229
|
const cfg = value._.config;
|
@@ -82064,13 +82233,13 @@ var validateOptions = (config) => {
|
|
82064
82233
|
continue;
|
82065
82234
|
if (cfg.name.includes("=")) {
|
82066
82235
|
throw new BroCliError(
|
82067
|
-
`Can't define option ${cfg.name} - option names and aliases cannot contain '='!`
|
82236
|
+
`Can't define option '${generatePrefix(cfg.name)}' - option names and aliases cannot contain '='!`
|
82068
82237
|
);
|
82069
82238
|
}
|
82070
82239
|
for (const alias of cfg.aliases) {
|
82071
82240
|
if (alias.includes("=")) {
|
82072
82241
|
throw new BroCliError(
|
82073
|
-
`Can't define option ${cfg.name} - option names and aliases cannot contain '='!`
|
82242
|
+
`Can't define option '${generatePrefix(cfg.name)}' - option names and aliases cannot contain '='!`
|
82074
82243
|
);
|
82075
82244
|
}
|
82076
82245
|
}
|
@@ -82088,33 +82257,33 @@ var validateOptions = (config) => {
|
|
82088
82257
|
for (const name of allNames) {
|
82089
82258
|
const match2 = reservedNames.find((n) => n === name);
|
82090
82259
|
if (match2)
|
82091
|
-
throw new BroCliError(`Can't define option ${cfg.name} - name '${match2}' is reserved!`);
|
82260
|
+
throw new BroCliError(`Can't define option '${cfg.name}' - name '${match2}' is reserved!`);
|
82092
82261
|
}
|
82093
|
-
const
|
82094
|
-
for (const storage2 of storageVals) {
|
82262
|
+
for (const storage2 of storedNames) {
|
82095
82263
|
const nameOccupier = storage2.find((e2) => e2 === cfg.name);
|
82096
82264
|
if (!nameOccupier)
|
82097
82265
|
continue;
|
82098
82266
|
throw new BroCliError(
|
82099
|
-
`Can't define option '${cfg.name}'
|
82267
|
+
`Can't define option '${cfg.name}' - name is already in use by option '${storage2[0]}'!`
|
82100
82268
|
);
|
82101
82269
|
}
|
82102
82270
|
for (const alias of cfg.aliases) {
|
82103
|
-
for (const storage2 of
|
82271
|
+
for (const storage2 of storedNames) {
|
82104
82272
|
const nameOccupier = storage2.find((e2) => e2 === alias);
|
82105
82273
|
if (!nameOccupier)
|
82106
82274
|
continue;
|
82107
82275
|
throw new BroCliError(
|
82108
|
-
`Can't define option '${cfg.name}'
|
82276
|
+
`Can't define option '${cfg.name}' - alias '${alias}' is already in use by option '${storage2[0]}'!`
|
82109
82277
|
);
|
82110
82278
|
}
|
82111
82279
|
}
|
82112
|
-
|
82113
|
-
storedNames
|
82114
|
-
|
82280
|
+
const currentNames = [cfg.name, ...cfg.aliases];
|
82281
|
+
storedNames.push(currentNames);
|
82282
|
+
currentNames.forEach((name, idx) => {
|
82283
|
+
if (currentNames.findIndex((e2) => e2 === name) === idx)
|
82115
82284
|
return;
|
82116
82285
|
throw new BroCliError(
|
82117
|
-
`Can't define option '${cfg.name}'
|
82286
|
+
`Can't define option '${cfg.name}' - duplicate alias '${name}'!`
|
82118
82287
|
);
|
82119
82288
|
});
|
82120
82289
|
entries.push([key, { config: cfg, $output: void 0 }]);
|
@@ -82135,14 +82304,17 @@ var command = (command2) => {
|
|
82135
82304
|
`Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`
|
82136
82305
|
);
|
82137
82306
|
}
|
82307
|
+
if (!command2.handler && !command2.subcommands) {
|
82308
|
+
throw new BroCliError(
|
82309
|
+
`Can't define command '${cmd.name}' - command without subcommands must have a handler present!`
|
82310
|
+
);
|
82311
|
+
}
|
82138
82312
|
const processedOptions = command2.options ? validateOptions(command2.options) : void 0;
|
82139
82313
|
cmd.options = processedOptions;
|
82140
82314
|
cmd.name = cmd.name ?? ((_a = cmd.aliases) == null ? void 0 : _a.shift());
|
82141
82315
|
if (!cmd.name)
|
82142
82316
|
throw new BroCliError(`Can't define command without name!`);
|
82143
82317
|
cmd.aliases = ((_b = cmd.aliases) == null ? void 0 : _b.length) ? cmd.aliases : void 0;
|
82144
|
-
if (!cmd.handler)
|
82145
|
-
throw new BroCliError(`Can't define command '${cmd.name}' - command must have a handler!`);
|
82146
82318
|
if (cmd.name.startsWith("-")) {
|
82147
82319
|
throw new BroCliError(`Can't define command '${cmd.name}' - command name can't start with '-'!`);
|
82148
82320
|
}
|
@@ -82172,7 +82344,7 @@ var command = (command2) => {
|
|
82172
82344
|
}
|
82173
82345
|
return cmd;
|
82174
82346
|
};
|
82175
|
-
var getCommandInner = (commands, candidates, args) => {
|
82347
|
+
var getCommandInner = (commands, candidates, args, cliName, cliDescription) => {
|
82176
82348
|
const { data: arg, originalIndex: index4 } = candidates.shift();
|
82177
82349
|
const command2 = commands.find((c) => {
|
82178
82350
|
const names = c.aliases ? [c.name, ...c.aliases] : [c.name];
|
@@ -82193,12 +82365,20 @@ var getCommandInner = (commands, candidates, args) => {
|
|
82193
82365
|
};
|
82194
82366
|
}
|
82195
82367
|
const newCandidates = candidates.map((c) => ({ data: c.data, originalIndex: c.originalIndex - 1 }));
|
82196
|
-
const subcommand = getCommandInner(command2.subcommands, newCandidates, newArgs);
|
82197
|
-
if (!subcommand.command)
|
82198
|
-
throw
|
82368
|
+
const subcommand = getCommandInner(command2.subcommands, newCandidates, newArgs, cliName, cliDescription);
|
82369
|
+
if (!subcommand.command) {
|
82370
|
+
throw new BroCliError(void 0, {
|
82371
|
+
type: "error",
|
82372
|
+
violation: "unknown_subcommand_error",
|
82373
|
+
name: cliName,
|
82374
|
+
description: cliDescription,
|
82375
|
+
command: command2,
|
82376
|
+
offender: candidates[0].data
|
82377
|
+
});
|
82378
|
+
}
|
82199
82379
|
return subcommand;
|
82200
82380
|
};
|
82201
|
-
var getCommand = (commands, args) => {
|
82381
|
+
var getCommand = (commands, args, cliName, cliDescription) => {
|
82202
82382
|
var _a;
|
82203
82383
|
const candidates = [];
|
82204
82384
|
for (let i2 = 0; i2 < args.length; ++i2) {
|
@@ -82232,15 +82412,23 @@ var getCommand = (commands, args) => {
|
|
82232
82412
|
args: removeByIndex(args, firstCandidate.originalIndex)
|
82233
82413
|
};
|
82234
82414
|
}
|
82235
|
-
const { command: command2, args: argsRes } = getCommandInner(commands, candidates, args);
|
82236
|
-
if (!command2)
|
82237
|
-
throw
|
82415
|
+
const { command: command2, args: argsRes } = getCommandInner(commands, candidates, args, cliName, cliDescription);
|
82416
|
+
if (!command2) {
|
82417
|
+
throw new BroCliError(void 0, {
|
82418
|
+
type: "error",
|
82419
|
+
violation: "unknown_command_error",
|
82420
|
+
commands,
|
82421
|
+
name: cliName,
|
82422
|
+
description: cliDescription,
|
82423
|
+
offender: firstCandidate.data
|
82424
|
+
});
|
82425
|
+
}
|
82238
82426
|
return {
|
82239
82427
|
command: command2,
|
82240
82428
|
args: argsRes
|
82241
82429
|
};
|
82242
82430
|
};
|
82243
|
-
var parseArg = (options, positionals, arg, nextArg) => {
|
82431
|
+
var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescription) => {
|
82244
82432
|
let data = void 0;
|
82245
82433
|
const argSplit = arg.split("=");
|
82246
82434
|
const hasEq = arg.includes("=");
|
@@ -82261,8 +82449,18 @@ var parseArg = (options, positionals, arg, nextArg) => {
|
|
82261
82449
|
if (!positionals.length)
|
82262
82450
|
return {};
|
82263
82451
|
const pos = positionals.shift();
|
82264
|
-
if (pos[1].enumVals && !pos[1].enumVals.find((val2) => val2 ===
|
82265
|
-
throw
|
82452
|
+
if (pos[1].enumVals && !pos[1].enumVals.find((val2) => val2 === arg)) {
|
82453
|
+
throw new BroCliError(void 0, {
|
82454
|
+
type: "error",
|
82455
|
+
name: cliName,
|
82456
|
+
description: cliDescription,
|
82457
|
+
violation: "enum_violation",
|
82458
|
+
command: command2,
|
82459
|
+
option: pos[1],
|
82460
|
+
offender: {
|
82461
|
+
dataPart: arg
|
82462
|
+
}
|
82463
|
+
});
|
82266
82464
|
}
|
82267
82465
|
data = arg;
|
82268
82466
|
return {
|
@@ -82297,32 +82495,126 @@ var parseArg = (options, positionals, arg, nextArg) => {
|
|
82297
82495
|
skipNext = false;
|
82298
82496
|
return true;
|
82299
82497
|
}
|
82300
|
-
throw
|
82498
|
+
throw new BroCliError(void 0, {
|
82499
|
+
type: "error",
|
82500
|
+
name: cliName,
|
82501
|
+
description: cliDescription,
|
82502
|
+
violation: "invalid_boolean_syntax",
|
82503
|
+
option: opt,
|
82504
|
+
command: command2,
|
82505
|
+
offender: {
|
82506
|
+
namePart,
|
82507
|
+
dataPart
|
82508
|
+
}
|
82509
|
+
});
|
82301
82510
|
} else {
|
82302
82511
|
const match2 = names.find((name) => name === namePart);
|
82303
82512
|
if (!match2)
|
82304
82513
|
return false;
|
82305
82514
|
if (opt.type === "string") {
|
82306
|
-
if (!hasEq && nextArg === void 0)
|
82307
|
-
throw
|
82515
|
+
if (!hasEq && nextArg === void 0) {
|
82516
|
+
throw new BroCliError(void 0, {
|
82517
|
+
type: "error",
|
82518
|
+
name: cliName,
|
82519
|
+
description: cliDescription,
|
82520
|
+
violation: "invalid_string_syntax",
|
82521
|
+
option: opt,
|
82522
|
+
command: command2,
|
82523
|
+
offender: {
|
82524
|
+
namePart,
|
82525
|
+
dataPart
|
82526
|
+
}
|
82527
|
+
});
|
82528
|
+
}
|
82308
82529
|
if (opt.enumVals && !opt.enumVals.find((val2) => val2 === dataPart)) {
|
82309
|
-
throw
|
82530
|
+
throw new BroCliError(void 0, {
|
82531
|
+
type: "error",
|
82532
|
+
name: cliName,
|
82533
|
+
description: cliDescription,
|
82534
|
+
violation: "enum_violation",
|
82535
|
+
option: opt,
|
82536
|
+
command: command2,
|
82537
|
+
offender: {
|
82538
|
+
namePart,
|
82539
|
+
dataPart
|
82540
|
+
}
|
82541
|
+
});
|
82310
82542
|
}
|
82311
82543
|
data = dataPart;
|
82312
82544
|
return true;
|
82313
82545
|
}
|
82314
|
-
if (!hasEq && nextArg === void 0)
|
82315
|
-
throw
|
82546
|
+
if (!hasEq && nextArg === void 0) {
|
82547
|
+
throw new BroCliError(void 0, {
|
82548
|
+
type: "error",
|
82549
|
+
name: cliName,
|
82550
|
+
description: cliDescription,
|
82551
|
+
violation: "invalid_number_syntax",
|
82552
|
+
option: opt,
|
82553
|
+
command: command2,
|
82554
|
+
offender: {
|
82555
|
+
namePart,
|
82556
|
+
dataPart
|
82557
|
+
}
|
82558
|
+
});
|
82559
|
+
}
|
82316
82560
|
const numData = Number(dataPart);
|
82317
|
-
if (isNaN(numData))
|
82318
|
-
throw
|
82319
|
-
|
82320
|
-
|
82321
|
-
|
82322
|
-
|
82323
|
-
|
82324
|
-
|
82325
|
-
|
82561
|
+
if (isNaN(numData)) {
|
82562
|
+
throw new BroCliError(void 0, {
|
82563
|
+
type: "error",
|
82564
|
+
name: cliName,
|
82565
|
+
description: cliDescription,
|
82566
|
+
violation: "invalid_number_value",
|
82567
|
+
option: opt,
|
82568
|
+
command: command2,
|
82569
|
+
offender: {
|
82570
|
+
namePart,
|
82571
|
+
dataPart
|
82572
|
+
}
|
82573
|
+
});
|
82574
|
+
}
|
82575
|
+
if (opt.isInt && !isInt(numData)) {
|
82576
|
+
throw new BroCliError(void 0, {
|
82577
|
+
type: "error",
|
82578
|
+
name: cliName,
|
82579
|
+
description: cliDescription,
|
82580
|
+
violation: "expected_int",
|
82581
|
+
option: opt,
|
82582
|
+
command: command2,
|
82583
|
+
offender: {
|
82584
|
+
namePart,
|
82585
|
+
dataPart
|
82586
|
+
}
|
82587
|
+
});
|
82588
|
+
}
|
82589
|
+
if (opt.minVal !== void 0 && numData < opt.minVal) {
|
82590
|
+
throw new BroCliError(void 0, {
|
82591
|
+
type: "error",
|
82592
|
+
name: cliName,
|
82593
|
+
description: cliDescription,
|
82594
|
+
violation: "below_min",
|
82595
|
+
option: opt,
|
82596
|
+
command: command2,
|
82597
|
+
offender: {
|
82598
|
+
namePart,
|
82599
|
+
dataPart
|
82600
|
+
}
|
82601
|
+
});
|
82602
|
+
}
|
82603
|
+
if (opt.maxVal !== void 0 && numData > opt.maxVal) {
|
82604
|
+
throw new BroCliError(void 0, {
|
82605
|
+
type: "error",
|
82606
|
+
name: cliName,
|
82607
|
+
description: cliDescription,
|
82608
|
+
violation: "above_max",
|
82609
|
+
option: opt,
|
82610
|
+
command: command2,
|
82611
|
+
offender: {
|
82612
|
+
namePart,
|
82613
|
+
dataPart
|
82614
|
+
}
|
82615
|
+
});
|
82616
|
+
}
|
82617
|
+
data = numData;
|
82326
82618
|
return true;
|
82327
82619
|
}
|
82328
82620
|
});
|
@@ -82333,7 +82625,7 @@ var parseArg = (options, positionals, arg, nextArg) => {
|
|
82333
82625
|
option: option == null ? void 0 : option[1]
|
82334
82626
|
};
|
82335
82627
|
};
|
82336
|
-
var parseOptions = (command2, args, omitKeysOfUndefinedOptions) => {
|
82628
|
+
var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefinedOptions) => {
|
82337
82629
|
const options = command2.options;
|
82338
82630
|
const optEntries = Object.entries(options ?? {}).map(
|
82339
82631
|
(opt) => [opt[0], opt[1].config]
|
@@ -82353,16 +82645,16 @@ var parseOptions = (command2, args, omitKeysOfUndefinedOptions) => {
|
|
82353
82645
|
skipNext,
|
82354
82646
|
isHelp,
|
82355
82647
|
isVersion
|
82356
|
-
} = parseArg(nonPositionalEntries, positionalEntries, arg, nextArg);
|
82648
|
+
} = parseArg(command2, nonPositionalEntries, positionalEntries, arg, nextArg, cliName, cliDescription);
|
82357
82649
|
if (!option)
|
82358
82650
|
unrecognizedArgsArr.push(arg.split("=")[0]);
|
82359
82651
|
if (skipNext)
|
82360
82652
|
++i2;
|
82361
|
-
result[name] = data;
|
82362
82653
|
if (isHelp)
|
82363
82654
|
return "help";
|
82364
82655
|
if (isVersion)
|
82365
82656
|
return "version";
|
82657
|
+
result[name] = data;
|
82366
82658
|
}
|
82367
82659
|
for (const [optKey, option] of optEntries) {
|
82368
82660
|
const data = result[optKey] ?? option.default;
|
@@ -82375,19 +82667,29 @@ var parseOptions = (command2, args, omitKeysOfUndefinedOptions) => {
|
|
82375
82667
|
if (option.isRequired && result[optKey] === void 0)
|
82376
82668
|
missingRequiredArr.push([option.name, ...option.aliases]);
|
82377
82669
|
}
|
82378
|
-
if (missingRequiredArr.length)
|
82379
|
-
throw
|
82380
|
-
|
82381
|
-
|
82382
|
-
|
82383
|
-
|
82384
|
-
|
82385
|
-
|
82386
|
-
|
82387
|
-
|
82388
|
-
|
82670
|
+
if (missingRequiredArr.length) {
|
82671
|
+
throw new BroCliError(void 0, {
|
82672
|
+
type: "error",
|
82673
|
+
violation: "missing_args_error",
|
82674
|
+
name: cliName,
|
82675
|
+
description: cliDescription,
|
82676
|
+
command: command2,
|
82677
|
+
missing: missingRequiredArr
|
82678
|
+
});
|
82679
|
+
}
|
82680
|
+
if (unrecognizedArgsArr.length) {
|
82681
|
+
throw new BroCliError(void 0, {
|
82682
|
+
type: "error",
|
82683
|
+
violation: "unrecognized_args_error",
|
82684
|
+
name: cliName,
|
82685
|
+
description: cliDescription,
|
82686
|
+
command: command2,
|
82687
|
+
unrecognized: unrecognizedArgsArr
|
82688
|
+
});
|
82689
|
+
}
|
82690
|
+
return Object.keys(result).length ? result : void 0;
|
82389
82691
|
};
|
82390
|
-
var
|
82692
|
+
var getCommandNameWithParents = (command2) => command2.parent ? `${getCommandNameWithParents(command2.parent)} ${command2.name}` : command2.name;
|
82391
82693
|
var validateCommands = (commands, parent) => {
|
82392
82694
|
const storedNames = {};
|
82393
82695
|
for (const cmd of commands) {
|
@@ -82396,8 +82698,8 @@ var validateCommands = (commands, parent) => {
|
|
82396
82698
|
const nameOccupier = storage2.find((e2) => e2 === cmd.name);
|
82397
82699
|
if (!nameOccupier)
|
82398
82700
|
continue;
|
82399
|
-
throw new
|
82400
|
-
`Can't define command '${
|
82701
|
+
throw new BroCliError(
|
82702
|
+
`Can't define command '${getCommandNameWithParents(cmd)}': name is already in use by command '${parent ? `${getCommandNameWithParents(parent)} ` : ""}${storage2[0]}'!`
|
82401
82703
|
);
|
82402
82704
|
}
|
82403
82705
|
if (cmd.aliases) {
|
@@ -82406,8 +82708,8 @@ var validateCommands = (commands, parent) => {
|
|
82406
82708
|
const nameOccupier = storage2.find((e2) => e2 === alias);
|
82407
82709
|
if (!nameOccupier)
|
82408
82710
|
continue;
|
82409
|
-
throw new
|
82410
|
-
`Can't define command '${
|
82711
|
+
throw new BroCliError(
|
82712
|
+
`Can't define command '${getCommandNameWithParents(cmd)}': alias '${alias}' is already in use by command '${parent ? `${getCommandNameWithParents(parent)} ` : ""}${storage2[0]}'!`
|
82411
82713
|
);
|
82412
82714
|
}
|
82413
82715
|
}
|
@@ -82419,53 +82721,135 @@ var validateCommands = (commands, parent) => {
|
|
82419
82721
|
return commands;
|
82420
82722
|
};
|
82421
82723
|
var removeByIndex = (arr, idx) => [...arr.slice(0, idx), ...arr.slice(idx + 1, arr.length)];
|
82422
|
-
var
|
82423
|
-
var rawCli = async (commands, config) => {
|
82724
|
+
var run = async (commands, config) => {
|
82424
82725
|
var _a, _b;
|
82425
|
-
const
|
82726
|
+
const eventHandler = (config == null ? void 0 : config.theme) ? eventHandlerWrapper(config.theme) : defaultEventHandler;
|
82426
82727
|
const argSource = (config == null ? void 0 : config.argSource) ?? process.argv;
|
82427
82728
|
const version3 = config == null ? void 0 : config.version;
|
82428
|
-
const
|
82729
|
+
const help = config == null ? void 0 : config.help;
|
82429
82730
|
const omitKeysOfUndefinedOptions = (config == null ? void 0 : config.omitKeysOfUndefinedOptions) ?? false;
|
82430
|
-
|
82431
|
-
|
82432
|
-
return await helpHandler(processedCmds);
|
82433
|
-
const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
|
82434
|
-
if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
|
82435
|
-
const command3 = getCommand(processedCmds, args).command;
|
82436
|
-
return help(command3, processedCmds, helpHandler);
|
82437
|
-
}
|
82438
|
-
const versionIndex = args.findIndex((arg) => arg === "--version" || arg === "-v");
|
82439
|
-
if (versionIndex !== -1 && (versionIndex > 0 ? ((_b = args[versionIndex - 1]) == null ? void 0 : _b.startsWith("-")) ? false : true : true)) {
|
82440
|
-
return await executeOrLog(version3);
|
82441
|
-
}
|
82442
|
-
const { command: command2, args: newArgs } = getCommand(processedCmds, args);
|
82443
|
-
if (!command2)
|
82444
|
-
return helpHandler(processedCmds);
|
82445
|
-
if (command2 === "help") {
|
82446
|
-
const { command: helpCommand } = getCommand(processedCmds, newArgs);
|
82447
|
-
return help(helpCommand, processedCmds, helpHandler);
|
82448
|
-
}
|
82449
|
-
const optionResult = parseOptions(command2, newArgs, omitKeysOfUndefinedOptions);
|
82450
|
-
if (optionResult === "help")
|
82451
|
-
return await help(command2, commands, helpHandler);
|
82452
|
-
if (optionResult === "version")
|
82453
|
-
return await executeOrLog(version3);
|
82454
|
-
if (optionResult) {
|
82455
|
-
if (config == null ? void 0 : config.hook)
|
82456
|
-
await config.hook("pre", command2);
|
82457
|
-
await command2.handler(command2.transform ? await command2.transform(optionResult) : optionResult);
|
82458
|
-
if (config == null ? void 0 : config.hook)
|
82459
|
-
await config.hook("post", command2);
|
82460
|
-
}
|
82461
|
-
return void 0;
|
82462
|
-
};
|
82463
|
-
var run = async (commands, config) => {
|
82731
|
+
const cliName = config == null ? void 0 : config.name;
|
82732
|
+
const cliDescription = config == null ? void 0 : config.description;
|
82464
82733
|
try {
|
82465
|
-
|
82734
|
+
const processedCmds = validateCommands(commands);
|
82735
|
+
let args = argSource.slice(2, argSource.length);
|
82736
|
+
if (!args.length) {
|
82737
|
+
return help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
82738
|
+
type: "global_help",
|
82739
|
+
description: cliDescription,
|
82740
|
+
name: cliName,
|
82741
|
+
commands: processedCmds
|
82742
|
+
});
|
82743
|
+
}
|
82744
|
+
const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
|
82745
|
+
if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
|
82746
|
+
const command3 = getCommand(processedCmds, args, cliName, cliDescription).command;
|
82747
|
+
if (typeof command3 === "object") {
|
82748
|
+
return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
|
82749
|
+
type: "command_help",
|
82750
|
+
description: cliDescription,
|
82751
|
+
name: cliName,
|
82752
|
+
command: command3
|
82753
|
+
});
|
82754
|
+
} else {
|
82755
|
+
return help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
82756
|
+
type: "global_help",
|
82757
|
+
description: cliDescription,
|
82758
|
+
name: cliName,
|
82759
|
+
commands: processedCmds
|
82760
|
+
});
|
82761
|
+
}
|
82762
|
+
}
|
82763
|
+
const versionIndex = args.findIndex((arg) => arg === "--version" || arg === "-v");
|
82764
|
+
if (versionIndex !== -1 && (versionIndex > 0 ? ((_b = args[versionIndex - 1]) == null ? void 0 : _b.startsWith("-")) ? false : true : true)) {
|
82765
|
+
return version3 !== void 0 ? await executeOrLog(version3) : await eventHandler({
|
82766
|
+
type: "version",
|
82767
|
+
name: cliName,
|
82768
|
+
description: cliDescription
|
82769
|
+
});
|
82770
|
+
}
|
82771
|
+
const { command: command2, args: newArgs } = getCommand(processedCmds, args, cliName, cliDescription);
|
82772
|
+
if (!command2) {
|
82773
|
+
return help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
82774
|
+
type: "global_help",
|
82775
|
+
description: cliDescription,
|
82776
|
+
name: cliName,
|
82777
|
+
commands: processedCmds
|
82778
|
+
});
|
82779
|
+
}
|
82780
|
+
if (command2 === "help") {
|
82781
|
+
let helpCommand;
|
82782
|
+
let newestArgs = newArgs;
|
82783
|
+
do {
|
82784
|
+
const res = getCommand(processedCmds, newestArgs, cliName, cliDescription);
|
82785
|
+
helpCommand = res.command;
|
82786
|
+
newestArgs = res.args;
|
82787
|
+
} while (helpCommand === "help");
|
82788
|
+
return helpCommand ? helpCommand.help !== void 0 ? await executeOrLog(helpCommand.help) : await eventHandler({
|
82789
|
+
type: "command_help",
|
82790
|
+
description: cliDescription,
|
82791
|
+
name: cliName,
|
82792
|
+
command: helpCommand
|
82793
|
+
}) : help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
82794
|
+
type: "global_help",
|
82795
|
+
description: cliDescription,
|
82796
|
+
name: cliName,
|
82797
|
+
commands: processedCmds
|
82798
|
+
});
|
82799
|
+
}
|
82800
|
+
const optionResult = parseOptions(command2, newArgs, cliName, cliDescription, omitKeysOfUndefinedOptions);
|
82801
|
+
if (optionResult === "help") {
|
82802
|
+
return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
|
82803
|
+
type: "command_help",
|
82804
|
+
description: cliDescription,
|
82805
|
+
name: cliName,
|
82806
|
+
command: command2
|
82807
|
+
});
|
82808
|
+
}
|
82809
|
+
if (optionResult === "version") {
|
82810
|
+
return version3 !== void 0 ? await executeOrLog(version3) : await eventHandler({
|
82811
|
+
type: "version",
|
82812
|
+
name: cliName,
|
82813
|
+
description: cliDescription
|
82814
|
+
});
|
82815
|
+
}
|
82816
|
+
if (command2.handler) {
|
82817
|
+
if (config == null ? void 0 : config.hook)
|
82818
|
+
await config.hook("before", command2);
|
82819
|
+
await command2.handler(command2.transform ? await command2.transform(optionResult) : optionResult);
|
82820
|
+
if (config == null ? void 0 : config.hook)
|
82821
|
+
await config.hook("after", command2);
|
82822
|
+
return;
|
82823
|
+
} else {
|
82824
|
+
return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
|
82825
|
+
type: "command_help",
|
82826
|
+
description: cliDescription,
|
82827
|
+
name: cliName,
|
82828
|
+
command: command2
|
82829
|
+
});
|
82830
|
+
}
|
82466
82831
|
} catch (e2) {
|
82467
|
-
|
82468
|
-
|
82832
|
+
if (e2 instanceof BroCliError) {
|
82833
|
+
if (e2.event)
|
82834
|
+
await eventHandler(e2.event);
|
82835
|
+
else {
|
82836
|
+
if (!(config == null ? void 0 : config.noExit))
|
82837
|
+
console.error(e2.message);
|
82838
|
+
else
|
82839
|
+
return e2.message;
|
82840
|
+
}
|
82841
|
+
} else {
|
82842
|
+
await eventHandler({
|
82843
|
+
type: "error",
|
82844
|
+
violation: "unknown_error",
|
82845
|
+
name: cliName,
|
82846
|
+
description: cliDescription,
|
82847
|
+
error: e2
|
82848
|
+
});
|
82849
|
+
}
|
82850
|
+
if (!(config == null ? void 0 : config.noExit))
|
82851
|
+
process.exit(1);
|
82852
|
+
return;
|
82469
82853
|
}
|
82470
82854
|
};
|
82471
82855
|
var OptionBuilderBase = class _OptionBuilderBase {
|
@@ -82543,7 +82927,7 @@ var OptionBuilderBase = class _OptionBuilderBase {
|
|
82543
82927
|
max(value) {
|
82544
82928
|
const config = this.config();
|
82545
82929
|
const minVal = config.minVal;
|
82546
|
-
if (minVal !== void 0 && minVal
|
82930
|
+
if (minVal !== void 0 && minVal > value) {
|
82547
82931
|
throw new BroCliError("Unable to define option's max value to be lower than min value!");
|
82548
82932
|
}
|
82549
82933
|
return new _OptionBuilderBase({ ...config, maxVal: value });
|
@@ -84377,7 +84761,7 @@ init_utils2();
|
|
84377
84761
|
var version2 = async () => {
|
84378
84762
|
const { npmVersion } = await ormCoreVersions();
|
84379
84763
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
84380
|
-
const envVersion = "0.24.0-
|
84764
|
+
const envVersion = "0.24.0-bddd952";
|
84381
84765
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
84382
84766
|
const versions = `drizzle-kit: ${kitVersion}
|
84383
84767
|
${ormVersion}`;
|
@@ -84412,6 +84796,7 @@ var legacy = [
|
|
84412
84796
|
legacyCommand("check:sqlite", "check")
|
84413
84797
|
];
|
84414
84798
|
run([generate, migrate, pull, push, studio, up, check, drop, ...legacy], {
|
84799
|
+
name: "drizzle-kit",
|
84415
84800
|
version: version2
|
84416
84801
|
});
|
84417
84802
|
/*! Bundled license information:
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "drizzle-kit",
|
3
|
-
"version": "0.24.0-
|
3
|
+
"version": "0.24.0-bddd952",
|
4
4
|
"homepage": "https://orm.drizzle.team",
|
5
5
|
"keywords": [
|
6
6
|
"drizzle",
|
@@ -38,11 +38,11 @@
|
|
38
38
|
"build": "rm -rf ./dist && tsx build.ts && cp package.json dist/ && attw --pack dist",
|
39
39
|
"build:dev": "rm -rf ./dist && tsx build.dev.ts && tsc -p tsconfig.cli-types.json && chmod +x ./dist/index.cjs",
|
40
40
|
"pack": "cp package.json README.md dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
|
41
|
-
"tsc": "tsc -p tsconfig.
|
41
|
+
"tsc": "tsc -p tsconfig.build.json",
|
42
42
|
"publish": "npm publish package.tgz"
|
43
43
|
},
|
44
44
|
"dependencies": {
|
45
|
-
"@drizzle-team/brocli": "^0.
|
45
|
+
"@drizzle-team/brocli": "^0.10.1",
|
46
46
|
"@esbuild-kit/esm-loader": "^2.5.5",
|
47
47
|
"esbuild": "^0.19.7",
|
48
48
|
"esbuild-register": "^3.5.0"
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"hono": "^4.1.5",
|
93
93
|
"json-diff": "1.0.6",
|
94
94
|
"minimatch": "^7.4.3",
|
95
|
-
"mysql2": "
|
95
|
+
"mysql2": "3.3.3",
|
96
96
|
"node-fetch": "^3.3.2",
|
97
97
|
"pg": "^8.11.5",
|
98
98
|
"pluralize": "^8.0.0",
|