@promptbook/cli 0.72.0-31 → 0.72.0-33
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/esm/index.es.js +34 -17
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -0
- package/esm/typings/src/utils/execCommand/{execCommandNormalizeOptions.d.ts → $execCommandNormalizeOptions.d.ts} +3 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -0
- package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +27 -1
- package/package.json +1 -1
- package/umd/index.umd.js +34 -17
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ import { Converter } from 'showdown';
|
|
|
27
27
|
/**
|
|
28
28
|
* The version of the Promptbook library
|
|
29
29
|
*/
|
|
30
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
30
|
+
var PROMPTBOOK_VERSION = '0.72.0-32';
|
|
31
31
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
32
32
|
|
|
33
33
|
/*! *****************************************************************************
|
|
@@ -421,6 +421,7 @@ var LOOP_LIMIT = 1000;
|
|
|
421
421
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
422
422
|
*/
|
|
423
423
|
var CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
424
|
+
// <- TODO: [⏳] Standartize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
|
|
424
425
|
/**
|
|
425
426
|
* How many times to retry the connections
|
|
426
427
|
*
|
|
@@ -13132,22 +13133,26 @@ var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssist
|
|
|
13132
13133
|
/**
|
|
13133
13134
|
* Normalize options for `execCommand` and `execCommands`
|
|
13134
13135
|
*
|
|
13136
|
+
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
13137
|
+
*
|
|
13135
13138
|
* @private internal utility of `execCommand` and `execCommands`
|
|
13136
13139
|
*/
|
|
13137
|
-
function execCommandNormalizeOptions(options) {
|
|
13140
|
+
function $execCommandNormalizeOptions(options) {
|
|
13138
13141
|
var _a;
|
|
13139
|
-
var _b, _c, _d;
|
|
13142
|
+
var _b, _c, _d, _e;
|
|
13140
13143
|
var command;
|
|
13141
13144
|
var cwd;
|
|
13142
13145
|
var crashOnError;
|
|
13143
13146
|
var args = [];
|
|
13144
13147
|
var timeout;
|
|
13148
|
+
var isVerbose;
|
|
13145
13149
|
if (typeof options === 'string') {
|
|
13146
13150
|
// TODO: [1] DRY default values
|
|
13147
13151
|
command = options;
|
|
13148
13152
|
cwd = process.cwd();
|
|
13149
13153
|
crashOnError = true;
|
|
13150
|
-
timeout = Infinity;
|
|
13154
|
+
timeout = Infinity; // <- TODO: [⏳]
|
|
13155
|
+
isVerbose = DEFAULT_IS_VERBOSE;
|
|
13151
13156
|
}
|
|
13152
13157
|
else {
|
|
13153
13158
|
/*
|
|
@@ -13163,6 +13168,7 @@ function execCommandNormalizeOptions(options) {
|
|
|
13163
13168
|
cwd = (_b = options.cwd) !== null && _b !== void 0 ? _b : process.cwd();
|
|
13164
13169
|
crashOnError = (_c = options.crashOnError) !== null && _c !== void 0 ? _c : true;
|
|
13165
13170
|
timeout = (_d = options.timeout) !== null && _d !== void 0 ? _d : Infinity;
|
|
13171
|
+
isVerbose = (_e = options.isVerbose) !== null && _e !== void 0 ? _e : DEFAULT_IS_VERBOSE;
|
|
13166
13172
|
}
|
|
13167
13173
|
// TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
|
|
13168
13174
|
var _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
|
|
@@ -13184,16 +13190,21 @@ function execCommandNormalizeOptions(options) {
|
|
|
13184
13190
|
if (['ts-node'].includes(humanReadableCommand)) {
|
|
13185
13191
|
humanReadableCommand += " ".concat(args[1]);
|
|
13186
13192
|
}
|
|
13187
|
-
|
|
13193
|
+
if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
|
|
13194
|
+
command = "".concat(command, ".cmd");
|
|
13195
|
+
}
|
|
13196
|
+
return { command: command, humanReadableCommand: humanReadableCommand, args: args, cwd: cwd, crashOnError: crashOnError, timeout: timeout, isVerbose: isVerbose };
|
|
13188
13197
|
}
|
|
13189
13198
|
// TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
|
|
13190
13199
|
|
|
13191
13200
|
/**
|
|
13192
13201
|
* Run one command in a shell
|
|
13193
13202
|
*
|
|
13203
|
+
*
|
|
13194
13204
|
* Note: There are 2 similar functions in the codebase:
|
|
13195
13205
|
* - `$execCommand` which runs a single command
|
|
13196
13206
|
* - `$execCommands` which runs multiple commands
|
|
13207
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
13197
13208
|
*
|
|
13198
13209
|
* @public exported from `@promptbook/node`
|
|
13199
13210
|
*/
|
|
@@ -13203,7 +13214,7 @@ function $execCommand(options) {
|
|
|
13203
13214
|
}
|
|
13204
13215
|
return new Promise(function (resolve, reject) {
|
|
13205
13216
|
// eslint-disable-next-line prefer-const
|
|
13206
|
-
var _a = execCommandNormalizeOptions(options), command = _a.command, humanReadableCommand = _a.humanReadableCommand, args = _a.args, cwd = _a.cwd, crashOnError = _a.crashOnError, timeout = _a.timeout;
|
|
13217
|
+
var _a = $execCommandNormalizeOptions(options), command = _a.command, humanReadableCommand = _a.humanReadableCommand, args = _a.args, cwd = _a.cwd, crashOnError = _a.crashOnError, timeout = _a.timeout, _b = _a.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
13207
13218
|
if (timeout !== Infinity) {
|
|
13208
13219
|
// TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
|
|
13209
13220
|
forTime(timeout).then(function () {
|
|
@@ -13216,24 +13227,26 @@ function $execCommand(options) {
|
|
|
13216
13227
|
}
|
|
13217
13228
|
});
|
|
13218
13229
|
}
|
|
13219
|
-
if (
|
|
13220
|
-
|
|
13230
|
+
if (isVerbose) {
|
|
13231
|
+
console.info(colors.yellow(cwd) + ' ' + colors.green(command) + ' ' + colors.blue(args.join(' ')));
|
|
13221
13232
|
}
|
|
13222
|
-
// !!!!!! Verbose mode - to all consoles
|
|
13223
|
-
console.info(colors.yellow(cwd) + ' ' + colors.green(command) + ' ' + colors.blue(args.join(' ')));
|
|
13224
13233
|
try {
|
|
13225
13234
|
var commandProcess = spawn(command, args, { cwd: cwd, shell: true });
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
|
|
13235
|
+
if (isVerbose) {
|
|
13236
|
+
commandProcess.on('message', function (message) {
|
|
13237
|
+
console.info({ message: message });
|
|
13238
|
+
});
|
|
13239
|
+
}
|
|
13229
13240
|
var output_1 = [];
|
|
13230
13241
|
commandProcess.stdout.on('data', function (stdout) {
|
|
13231
13242
|
output_1.push(stdout.toString());
|
|
13232
|
-
|
|
13243
|
+
if (isVerbose) {
|
|
13244
|
+
console.info(stdout.toString());
|
|
13245
|
+
}
|
|
13233
13246
|
});
|
|
13234
13247
|
commandProcess.stderr.on('data', function (stderr) {
|
|
13235
13248
|
output_1.push(stderr.toString());
|
|
13236
|
-
if (stderr.toString().trim()) {
|
|
13249
|
+
if (isVerbose && stderr.toString().trim()) {
|
|
13237
13250
|
console.warn(stderr.toString());
|
|
13238
13251
|
}
|
|
13239
13252
|
});
|
|
@@ -13244,7 +13257,9 @@ function $execCommand(options) {
|
|
|
13244
13257
|
"Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code)));
|
|
13245
13258
|
}
|
|
13246
13259
|
else {
|
|
13247
|
-
|
|
13260
|
+
if (isVerbose) {
|
|
13261
|
+
console.warn("Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code));
|
|
13262
|
+
}
|
|
13248
13263
|
resolve(spaceTrim(output_1.join('\n')));
|
|
13249
13264
|
}
|
|
13250
13265
|
}
|
|
@@ -13263,7 +13278,9 @@ function $execCommand(options) {
|
|
|
13263
13278
|
reject(new Error("Command \"".concat(humanReadableCommand, "\" failed: \n").concat(error.message)));
|
|
13264
13279
|
}
|
|
13265
13280
|
else {
|
|
13266
|
-
|
|
13281
|
+
if (isVerbose) {
|
|
13282
|
+
console.warn(error);
|
|
13283
|
+
}
|
|
13267
13284
|
resolve(spaceTrim(output_1.join('\n')));
|
|
13268
13285
|
}
|
|
13269
13286
|
});
|