@promptbook/cli 0.72.0-32 → 0.72.0-34
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/README.md +3 -3
- package/esm/index.es.js +68 -50
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +1 -1
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +1 -1
- package/esm/typings/src/executables/locateApp.d.ts +1 -1
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +2 -2
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +1 -1
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +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 +68 -50
- package/umd/index.umd.js.map +1 -1
|
@@ -4,7 +4,7 @@ import type { string_executable_path } from '../../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @private within the repository
|
|
6
6
|
*/
|
|
7
|
-
export declare function locateLibreoffice(): Promise<string_executable_path>;
|
|
7
|
+
export declare function locateLibreoffice(): Promise<string_executable_path | null>;
|
|
8
8
|
/**
|
|
9
9
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
10
10
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -4,7 +4,7 @@ import type { string_executable_path } from '../../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @private within the repository
|
|
6
6
|
*/
|
|
7
|
-
export declare function locatePandoc(): Promise<string_executable_path>;
|
|
7
|
+
export declare function locatePandoc(): Promise<string_executable_path | null>;
|
|
8
8
|
/**
|
|
9
9
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
10
10
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -26,7 +26,7 @@ export interface LocateAppOptions {
|
|
|
26
26
|
*
|
|
27
27
|
* @private within the repository
|
|
28
28
|
*/
|
|
29
|
-
export declare function locateApp(options: RequireAtLeastOne<LocateAppOptions, 'linuxWhich' | 'windowsSuffix' | 'macOsName'>): Promise<string_executable_path>;
|
|
29
|
+
export declare function locateApp(options: RequireAtLeastOne<LocateAppOptions, 'linuxWhich' | 'windowsSuffix' | 'macOsName'>): Promise<string_executable_path | null>;
|
|
30
30
|
/**
|
|
31
31
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
32
32
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { LocateAppOptions } from '../locateApp';
|
|
2
1
|
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
3
3
|
/**
|
|
4
4
|
* @@@
|
|
5
5
|
*
|
|
6
6
|
* @private within the repository
|
|
7
7
|
*/
|
|
8
|
-
export declare function locateAppOnLinux({ appName, linuxWhich, }: Pick<Required<LocateAppOptions>, 'appName' | 'linuxWhich'>): Promise<string_executable_path>;
|
|
8
|
+
export declare function locateAppOnLinux({ appName, linuxWhich, }: Pick<Required<LocateAppOptions>, 'appName' | 'linuxWhich'>): Promise<string_executable_path | null>;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
11
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -5,7 +5,7 @@ import type { LocateAppOptions } from '../locateApp';
|
|
|
5
5
|
*
|
|
6
6
|
* @private within the repository
|
|
7
7
|
*/
|
|
8
|
-
export declare function locateAppOnMacOs({ appName, macOsName, }: Pick<Required<LocateAppOptions>, 'appName' | 'macOsName'>): Promise<string_executable_path>;
|
|
8
|
+
export declare function locateAppOnMacOs({ appName, macOsName, }: Pick<Required<LocateAppOptions>, 'appName' | 'macOsName'>): Promise<string_executable_path | null>;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
11
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -5,7 +5,7 @@ import type { LocateAppOptions } from '../locateApp';
|
|
|
5
5
|
*
|
|
6
6
|
* @private within the repository
|
|
7
7
|
*/
|
|
8
|
-
export declare function locateAppOnWindows({ appName, windowsSuffix, }: Pick<Required<LocateAppOptions>, 'appName' | 'windowsSuffix'>): Promise<string_executable_path>;
|
|
8
|
+
export declare function locateAppOnWindows({ appName, windowsSuffix, }: Pick<Required<LocateAppOptions>, 'appName' | 'windowsSuffix'>): Promise<string_executable_path | null>;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
11
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
@@ -2,9 +2,11 @@ import type { ExecCommandOptions } from './ExecCommandOptions';
|
|
|
2
2
|
/**
|
|
3
3
|
* Run one command in a shell
|
|
4
4
|
*
|
|
5
|
+
*
|
|
5
6
|
* Note: There are 2 similar functions in the codebase:
|
|
6
7
|
* - `$execCommand` which runs a single command
|
|
7
8
|
* - `$execCommands` which runs multiple commands
|
|
9
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
8
10
|
*
|
|
9
11
|
* @public exported from `@promptbook/node`
|
|
10
12
|
*/
|
|
@@ -3,8 +3,10 @@ import type { ExecCommandOptionsAdvanced } from './ExecCommandOptions';
|
|
|
3
3
|
/**
|
|
4
4
|
* Normalize options for `execCommand` and `execCommands`
|
|
5
5
|
*
|
|
6
|
+
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
7
|
+
*
|
|
6
8
|
* @private internal utility of `execCommand` and `execCommands`
|
|
7
9
|
*/
|
|
8
|
-
export declare function execCommandNormalizeOptions(options: ExecCommandOptions): Pick<ExecCommandOptionsAdvanced, 'command' | 'args' | 'cwd' | 'crashOnError' | 'timeout'> & {
|
|
10
|
+
export declare function $execCommandNormalizeOptions(options: ExecCommandOptions): Pick<ExecCommandOptionsAdvanced, 'command' | 'args' | 'cwd' | 'crashOnError' | 'timeout' | 'isVerbose'> & {
|
|
9
11
|
humanReadableCommand: string;
|
|
10
12
|
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Note: There are 2 similar functions in the codebase:
|
|
5
5
|
* - `$execCommand` which runs a single command
|
|
6
6
|
* - `$execCommands` which runs multiple commands
|
|
7
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a commands in a shell
|
|
7
8
|
*
|
|
8
9
|
* @public exported from `@promptbook/node`
|
|
9
10
|
*/
|
|
@@ -5,15 +5,41 @@ type RequiredAndOptional<TBase, TRequired extends keyof TBase, TOptional extends
|
|
|
5
5
|
/**
|
|
6
6
|
* Simple options for `execCommand`
|
|
7
7
|
*/
|
|
8
|
-
export type ExecCommandOptions = string | RequiredAndOptional<ExecCommandOptionsAdvanced, 'command', 'args' | 'cwd' | 'crashOnError' | 'timeout'>;
|
|
8
|
+
export type ExecCommandOptions = string | RequiredAndOptional<ExecCommandOptionsAdvanced, 'command', 'args' | 'cwd' | 'crashOnError' | 'timeout' | 'isVerbose'>;
|
|
9
9
|
/**
|
|
10
10
|
* Advanced options for `execCommand`
|
|
11
11
|
*/
|
|
12
12
|
export type ExecCommandOptionsAdvanced = {
|
|
13
|
+
/**
|
|
14
|
+
* Command to run
|
|
15
|
+
*/
|
|
13
16
|
readonly command: string;
|
|
17
|
+
/**
|
|
18
|
+
* Arguments for the command
|
|
19
|
+
*/
|
|
14
20
|
readonly args: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Current working directory
|
|
23
|
+
*
|
|
24
|
+
* @default process.cwd()
|
|
25
|
+
*/
|
|
15
26
|
readonly cwd: string;
|
|
27
|
+
/**
|
|
28
|
+
* If `true` then the command will throw an error if the return code is not `0`
|
|
29
|
+
*/
|
|
16
30
|
readonly crashOnError: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Timeout in milliseconds
|
|
33
|
+
*/
|
|
17
34
|
readonly timeout: number;
|
|
35
|
+
/**
|
|
36
|
+
* If `true` then the command and entire CLI output will be logged to the console
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
readonly isVerbose?: boolean;
|
|
18
41
|
};
|
|
19
42
|
export {};
|
|
43
|
+
/**
|
|
44
|
+
* TODO: [⏳] Make DEFAULT_TIMEOUT_MS as global constant
|
|
45
|
+
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.72.0-33';
|
|
43
43
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -433,6 +433,7 @@
|
|
|
433
433
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
434
434
|
*/
|
|
435
435
|
var CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
436
|
+
// <- TODO: [⏳] Standartize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
|
|
436
437
|
/**
|
|
437
438
|
* How many times to retry the connections
|
|
438
439
|
*
|
|
@@ -8392,16 +8393,25 @@
|
|
|
8392
8393
|
function locateAppOnLinux(_a) {
|
|
8393
8394
|
var appName = _a.appName, linuxWhich = _a.linuxWhich;
|
|
8394
8395
|
return __awaiter(this, void 0, void 0, function () {
|
|
8395
|
-
var _b, stderr, stdout;
|
|
8396
|
+
var _b, stderr, stdout, error_1;
|
|
8396
8397
|
return __generator(this, function (_c) {
|
|
8397
8398
|
switch (_c.label) {
|
|
8398
|
-
case 0:
|
|
8399
|
+
case 0:
|
|
8400
|
+
_c.trys.push([0, 2, , 3]);
|
|
8401
|
+
return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
|
|
8399
8402
|
case 1:
|
|
8400
8403
|
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8401
8404
|
if (!stderr && stdout) {
|
|
8402
8405
|
return [2 /*return*/, stdout.trim()];
|
|
8403
8406
|
}
|
|
8404
8407
|
throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
|
|
8408
|
+
case 2:
|
|
8409
|
+
error_1 = _c.sent();
|
|
8410
|
+
if (!(error_1 instanceof Error)) {
|
|
8411
|
+
throw error_1;
|
|
8412
|
+
}
|
|
8413
|
+
return [2 /*return*/, null];
|
|
8414
|
+
case 3: return [2 /*return*/];
|
|
8405
8415
|
}
|
|
8406
8416
|
});
|
|
8407
8417
|
});
|
|
@@ -8477,10 +8487,11 @@
|
|
|
8477
8487
|
function locateAppOnMacOs(_a) {
|
|
8478
8488
|
var appName = _a.appName, macOsName = _a.macOsName;
|
|
8479
8489
|
return __awaiter(this, void 0, void 0, function () {
|
|
8480
|
-
var toExec, regPath, altPath, _b, stderr, stdout;
|
|
8490
|
+
var toExec, regPath, altPath, _b, stderr, stdout, error_1;
|
|
8481
8491
|
return __generator(this, function (_c) {
|
|
8482
8492
|
switch (_c.label) {
|
|
8483
8493
|
case 0:
|
|
8494
|
+
_c.trys.push([0, 6, , 7]);
|
|
8484
8495
|
toExec = "/Contents/MacOS/".concat(macOsName);
|
|
8485
8496
|
regPath = "/Applications/".concat(macOsName, ".app") + toExec;
|
|
8486
8497
|
altPath = userhome(regPath.slice(1));
|
|
@@ -8501,6 +8512,13 @@
|
|
|
8501
8512
|
return [2 /*return*/, stdout.trim() + toExec];
|
|
8502
8513
|
}
|
|
8503
8514
|
throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
|
|
8515
|
+
case 6:
|
|
8516
|
+
error_1 = _c.sent();
|
|
8517
|
+
if (!(error_1 instanceof Error)) {
|
|
8518
|
+
throw error_1;
|
|
8519
|
+
}
|
|
8520
|
+
return [2 /*return*/, null];
|
|
8521
|
+
case 7: return [2 /*return*/];
|
|
8504
8522
|
}
|
|
8505
8523
|
});
|
|
8506
8524
|
});
|
|
@@ -8518,11 +8536,12 @@
|
|
|
8518
8536
|
function locateAppOnWindows(_a) {
|
|
8519
8537
|
var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
|
|
8520
8538
|
return __awaiter(this, void 0, void 0, function () {
|
|
8521
|
-
var prefixes, prefixes_1, prefixes_1_1, prefix, path$1, e_1_1;
|
|
8539
|
+
var prefixes, prefixes_1, prefixes_1_1, prefix, path$1, e_1_1, error_1;
|
|
8522
8540
|
var e_1, _b;
|
|
8523
8541
|
return __generator(this, function (_c) {
|
|
8524
8542
|
switch (_c.label) {
|
|
8525
8543
|
case 0:
|
|
8544
|
+
_c.trys.push([0, 9, , 10]);
|
|
8526
8545
|
prefixes = [
|
|
8527
8546
|
process.env.LOCALAPPDATA,
|
|
8528
8547
|
path.join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
@@ -8559,6 +8578,13 @@
|
|
|
8559
8578
|
finally { if (e_1) throw e_1.error; }
|
|
8560
8579
|
return [7 /*endfinally*/];
|
|
8561
8580
|
case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
|
|
8581
|
+
case 9:
|
|
8582
|
+
error_1 = _c.sent();
|
|
8583
|
+
if (!(error_1 instanceof Error)) {
|
|
8584
|
+
throw error_1;
|
|
8585
|
+
}
|
|
8586
|
+
return [2 /*return*/, null];
|
|
8587
|
+
case 10: return [2 /*return*/];
|
|
8562
8588
|
}
|
|
8563
8589
|
});
|
|
8564
8590
|
});
|
|
@@ -8665,9 +8691,9 @@
|
|
|
8665
8691
|
_d = {};
|
|
8666
8692
|
return [4 /*yield*/, locatePandoc()];
|
|
8667
8693
|
case 1:
|
|
8668
|
-
_d.pandocPath = _e.sent();
|
|
8694
|
+
_d.pandocPath = (_e.sent()) || undefined;
|
|
8669
8695
|
return [4 /*yield*/, locateLibreoffice()];
|
|
8670
|
-
case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
|
|
8696
|
+
case 2: return [2 /*return*/, (_d.libreOfficePath = (_e.sent()) || undefined,
|
|
8671
8697
|
_d)];
|
|
8672
8698
|
}
|
|
8673
8699
|
});
|
|
@@ -12987,11 +13013,11 @@
|
|
|
12987
13013
|
assistant_id: this.assistantId,
|
|
12988
13014
|
thread: {
|
|
12989
13015
|
messages: [
|
|
12990
|
-
// TODO: [🗯]
|
|
13016
|
+
// TODO: [🗯] !! Allow threads to be passed
|
|
12991
13017
|
{ role: 'user', content: rawPromptContent },
|
|
12992
13018
|
],
|
|
12993
13019
|
},
|
|
12994
|
-
//
|
|
13020
|
+
// <- TODO: Add user identification here> user: this.options.user,
|
|
12995
13021
|
};
|
|
12996
13022
|
start = getCurrentIsoDate();
|
|
12997
13023
|
if (this.options.isVerbose) {
|
|
@@ -13042,7 +13068,7 @@
|
|
|
13042
13068
|
throw new PipelineExecutionError("There is NOT 'text' BUT ".concat((_b = rawResponse[0].content[0]) === null || _b === void 0 ? void 0 : _b.type, " finalMessages content type from OpenAI"));
|
|
13043
13069
|
}
|
|
13044
13070
|
resultContent = (_c = rawResponse[0].content[0]) === null || _c === void 0 ? void 0 : _c.text.value;
|
|
13045
|
-
// <- TODO:
|
|
13071
|
+
// <- TODO: [🧠] There are also annotations, maybe use them
|
|
13046
13072
|
// eslint-disable-next-line prefer-const
|
|
13047
13073
|
complete = getCurrentIsoDate();
|
|
13048
13074
|
usage = UNCERTAIN_USAGE;
|
|
@@ -13144,22 +13170,26 @@
|
|
|
13144
13170
|
/**
|
|
13145
13171
|
* Normalize options for `execCommand` and `execCommands`
|
|
13146
13172
|
*
|
|
13173
|
+
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
13174
|
+
*
|
|
13147
13175
|
* @private internal utility of `execCommand` and `execCommands`
|
|
13148
13176
|
*/
|
|
13149
|
-
function execCommandNormalizeOptions(options) {
|
|
13177
|
+
function $execCommandNormalizeOptions(options) {
|
|
13150
13178
|
var _a;
|
|
13151
|
-
var _b, _c, _d;
|
|
13179
|
+
var _b, _c, _d, _e;
|
|
13152
13180
|
var command;
|
|
13153
13181
|
var cwd;
|
|
13154
13182
|
var crashOnError;
|
|
13155
13183
|
var args = [];
|
|
13156
13184
|
var timeout;
|
|
13185
|
+
var isVerbose;
|
|
13157
13186
|
if (typeof options === 'string') {
|
|
13158
13187
|
// TODO: [1] DRY default values
|
|
13159
13188
|
command = options;
|
|
13160
13189
|
cwd = process.cwd();
|
|
13161
13190
|
crashOnError = true;
|
|
13162
|
-
timeout = Infinity;
|
|
13191
|
+
timeout = Infinity; // <- TODO: [⏳]
|
|
13192
|
+
isVerbose = DEFAULT_IS_VERBOSE;
|
|
13163
13193
|
}
|
|
13164
13194
|
else {
|
|
13165
13195
|
/*
|
|
@@ -13175,6 +13205,7 @@
|
|
|
13175
13205
|
cwd = (_b = options.cwd) !== null && _b !== void 0 ? _b : process.cwd();
|
|
13176
13206
|
crashOnError = (_c = options.crashOnError) !== null && _c !== void 0 ? _c : true;
|
|
13177
13207
|
timeout = (_d = options.timeout) !== null && _d !== void 0 ? _d : Infinity;
|
|
13208
|
+
isVerbose = (_e = options.isVerbose) !== null && _e !== void 0 ? _e : DEFAULT_IS_VERBOSE;
|
|
13178
13209
|
}
|
|
13179
13210
|
// TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
|
|
13180
13211
|
var _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
|
|
@@ -13196,16 +13227,21 @@
|
|
|
13196
13227
|
if (['ts-node'].includes(humanReadableCommand)) {
|
|
13197
13228
|
humanReadableCommand += " ".concat(args[1]);
|
|
13198
13229
|
}
|
|
13199
|
-
|
|
13230
|
+
if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
|
|
13231
|
+
command = "".concat(command, ".cmd");
|
|
13232
|
+
}
|
|
13233
|
+
return { command: command, humanReadableCommand: humanReadableCommand, args: args, cwd: cwd, crashOnError: crashOnError, timeout: timeout, isVerbose: isVerbose };
|
|
13200
13234
|
}
|
|
13201
13235
|
// TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
|
|
13202
13236
|
|
|
13203
13237
|
/**
|
|
13204
13238
|
* Run one command in a shell
|
|
13205
13239
|
*
|
|
13240
|
+
*
|
|
13206
13241
|
* Note: There are 2 similar functions in the codebase:
|
|
13207
13242
|
* - `$execCommand` which runs a single command
|
|
13208
13243
|
* - `$execCommands` which runs multiple commands
|
|
13244
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
13209
13245
|
*
|
|
13210
13246
|
* @public exported from `@promptbook/node`
|
|
13211
13247
|
*/
|
|
@@ -13215,7 +13251,7 @@
|
|
|
13215
13251
|
}
|
|
13216
13252
|
return new Promise(function (resolve, reject) {
|
|
13217
13253
|
// eslint-disable-next-line prefer-const
|
|
13218
|
-
var _a = execCommandNormalizeOptions(options), command = _a.command, humanReadableCommand = _a.humanReadableCommand, args = _a.args, cwd = _a.cwd, crashOnError = _a.crashOnError, timeout = _a.timeout;
|
|
13254
|
+
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;
|
|
13219
13255
|
if (timeout !== Infinity) {
|
|
13220
13256
|
// TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
|
|
13221
13257
|
waitasecond.forTime(timeout).then(function () {
|
|
@@ -13228,24 +13264,26 @@
|
|
|
13228
13264
|
}
|
|
13229
13265
|
});
|
|
13230
13266
|
}
|
|
13231
|
-
if (
|
|
13232
|
-
|
|
13267
|
+
if (isVerbose) {
|
|
13268
|
+
console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
|
|
13233
13269
|
}
|
|
13234
|
-
// !!!!!! Verbose mode - to all consoles
|
|
13235
|
-
console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
|
|
13236
13270
|
try {
|
|
13237
13271
|
var commandProcess = child_process.spawn(command, args, { cwd: cwd, shell: true });
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13272
|
+
if (isVerbose) {
|
|
13273
|
+
commandProcess.on('message', function (message) {
|
|
13274
|
+
console.info({ message: message });
|
|
13275
|
+
});
|
|
13276
|
+
}
|
|
13241
13277
|
var output_1 = [];
|
|
13242
13278
|
commandProcess.stdout.on('data', function (stdout) {
|
|
13243
13279
|
output_1.push(stdout.toString());
|
|
13244
|
-
|
|
13280
|
+
if (isVerbose) {
|
|
13281
|
+
console.info(stdout.toString());
|
|
13282
|
+
}
|
|
13245
13283
|
});
|
|
13246
13284
|
commandProcess.stderr.on('data', function (stderr) {
|
|
13247
13285
|
output_1.push(stderr.toString());
|
|
13248
|
-
if (stderr.toString().trim()) {
|
|
13286
|
+
if (isVerbose && stderr.toString().trim()) {
|
|
13249
13287
|
console.warn(stderr.toString());
|
|
13250
13288
|
}
|
|
13251
13289
|
});
|
|
@@ -13256,7 +13294,9 @@
|
|
|
13256
13294
|
"Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code)));
|
|
13257
13295
|
}
|
|
13258
13296
|
else {
|
|
13259
|
-
|
|
13297
|
+
if (isVerbose) {
|
|
13298
|
+
console.warn("Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code));
|
|
13299
|
+
}
|
|
13260
13300
|
resolve(spaceTrim.spaceTrim(output_1.join('\n')));
|
|
13261
13301
|
}
|
|
13262
13302
|
}
|
|
@@ -13275,7 +13315,9 @@
|
|
|
13275
13315
|
reject(new Error("Command \"".concat(humanReadableCommand, "\" failed: \n").concat(error.message)));
|
|
13276
13316
|
}
|
|
13277
13317
|
else {
|
|
13278
|
-
|
|
13318
|
+
if (isVerbose) {
|
|
13319
|
+
console.warn(error);
|
|
13320
|
+
}
|
|
13279
13321
|
resolve(spaceTrim.spaceTrim(output_1.join('\n')));
|
|
13280
13322
|
}
|
|
13281
13323
|
});
|
|
@@ -14134,25 +14176,6 @@
|
|
|
14134
14176
|
this.options = options;
|
|
14135
14177
|
this.markdownScraper = new MarkdownScraper(tools, options);
|
|
14136
14178
|
this.showdownConverter = createShowdownConverter();
|
|
14137
|
-
/**/
|
|
14138
|
-
// TODO: [🏄] !!!!!! Remove or describe why it is here
|
|
14139
|
-
TODO_USE(readability.Readability);
|
|
14140
|
-
TODO_USE(showdown.Converter);
|
|
14141
|
-
TODO_USE(jsdom.JSDOM);
|
|
14142
|
-
TODO_USE(createShowdownConverter);
|
|
14143
|
-
/**/
|
|
14144
|
-
/**/
|
|
14145
|
-
var jsdom$1 = new jsdom.JSDOM();
|
|
14146
|
-
var reader = new readability.Readability(jsdom$1.window.document);
|
|
14147
|
-
keepUnused(reader);
|
|
14148
|
-
/**/
|
|
14149
|
-
/**/
|
|
14150
|
-
keepUnused(DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_VERBOSE, DEFAULT_SCRAPE_CACHE_DIRNAME);
|
|
14151
|
-
keepUnused(EnvironmentMismatchError);
|
|
14152
|
-
keepUnused(KnowledgeScrapeError);
|
|
14153
|
-
keepUnused(getScraperIntermediateSource);
|
|
14154
|
-
keepUnused();
|
|
14155
|
-
/**/
|
|
14156
14179
|
}
|
|
14157
14180
|
Object.defineProperty(WebsiteScraper.prototype, "metadata", {
|
|
14158
14181
|
/**
|
|
@@ -14178,8 +14201,6 @@
|
|
|
14178
14201
|
switch (_g.label) {
|
|
14179
14202
|
case 0:
|
|
14180
14203
|
_a = this.options, _b = _a.rootDirname, rootDirname = _b === void 0 ? process.cwd() : _b, _c = _a.cacheDirname, cacheDirname = _c === void 0 ? DEFAULT_SCRAPE_CACHE_DIRNAME : _c, _d = _a.intermediateFilesStrategy, intermediateFilesStrategy = _d === void 0 ? DEFAULT_INTERMEDIATE_FILES_STRATEGY : _d, _e = _a.isVerbose, isVerbose = _e === void 0 ? DEFAULT_IS_VERBOSE : _e;
|
|
14181
|
-
// [🏄] !!!!!!!
|
|
14182
|
-
keepUnused(rootDirname, cacheDirname, intermediateFilesStrategy, isVerbose);
|
|
14183
14204
|
if (source.url === null) {
|
|
14184
14205
|
throw new KnowledgeScrapeError('Website scraper requires URL');
|
|
14185
14206
|
}
|
|
@@ -14190,11 +14211,8 @@
|
|
|
14190
14211
|
return [4 /*yield*/, source.asText()];
|
|
14191
14212
|
case 1:
|
|
14192
14213
|
jsdom$1 = new (_f.apply(jsdom.JSDOM, [void 0, _g.sent(), {
|
|
14193
|
-
// <- TODO: !!!!!!! Problem with build is probbably in `new JSDOM();`
|
|
14194
14214
|
url: source.url,
|
|
14195
14215
|
}]))();
|
|
14196
|
-
// [🏄] !!!!!!!
|
|
14197
|
-
keepUnused(jsdom$1);
|
|
14198
14216
|
reader = new readability.Readability(jsdom$1.window.document);
|
|
14199
14217
|
article = reader.parse();
|
|
14200
14218
|
html = (article === null || article === void 0 ? void 0 : article.content) || (article === null || article === void 0 ? void 0 : article.textContent) || jsdom$1.window.document.body.innerHTML;
|