@promptbook/cli 0.71.0-20 → 0.71.0-21
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 +298 -54
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locateLibreoffice.test.d.ts +1 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.test.d.ts +1 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/package.json +1 -1
- package/umd/index.umd.js +300 -57
- package/umd/index.umd.js.map +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
2
2
|
import { createCollectionFromDirectory } from '../collection/constructors/createCollectionFromDirectory';
|
|
3
|
+
import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
|
|
3
4
|
import { $provideExecutionToolsForNode } from '../execution/utils/$provideExecutionToolsForNode';
|
|
4
5
|
import { $provideLlmToolsConfigurationFromEnv } from '../llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv';
|
|
5
6
|
import { $provideLlmToolsFromEnv } from '../llm-providers/_common/register/$provideLlmToolsFromEnv';
|
|
6
|
-
import { $provideExecutablesForNode } from '../scrapers/_common/register/$provideExecutablesForNode';
|
|
7
7
|
import { $provideFilesystemForNode } from '../scrapers/_common/register/$provideFilesystemForNode';
|
|
8
8
|
import { $provideScrapersForNode } from '../scrapers/_common/register/$provideScrapersForNode';
|
|
9
9
|
import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage';
|
|
@@ -11,10 +11,10 @@ import { $execCommand } from '../utils/execCommand/$execCommand';
|
|
|
11
11
|
import { $execCommands } from '../utils/execCommand/$execCommands';
|
|
12
12
|
export { PROMPTBOOK_VERSION };
|
|
13
13
|
export { createCollectionFromDirectory };
|
|
14
|
+
export { $provideExecutablesForNode };
|
|
14
15
|
export { $provideExecutionToolsForNode };
|
|
15
16
|
export { $provideLlmToolsConfigurationFromEnv };
|
|
16
17
|
export { $provideLlmToolsFromEnv };
|
|
17
|
-
export { $provideExecutablesForNode };
|
|
18
18
|
export { $provideFilesystemForNode };
|
|
19
19
|
export { $provideScrapersForNode };
|
|
20
20
|
export { FileCacheStorage };
|
|
@@ -14,6 +14,7 @@ import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
|
|
|
14
14
|
import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
15
15
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
16
16
|
import type { ErrorJson } from '../errors/utils/ErrorJson';
|
|
17
|
+
import type { LocateAppOptions } from '../executables/locateApp';
|
|
17
18
|
import type { AvailableModel } from '../execution/AvailableModel';
|
|
18
19
|
import type { CommonToolsOptions } from '../execution/CommonToolsOptions';
|
|
19
20
|
import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
|
|
@@ -254,6 +255,7 @@ export type { PrettifyOptions };
|
|
|
254
255
|
export type { renderPipelineMermaidOptions };
|
|
255
256
|
export type { CallbackInterfaceToolsOptions };
|
|
256
257
|
export type { ErrorJson };
|
|
258
|
+
export type { LocateAppOptions };
|
|
257
259
|
export type { AvailableModel };
|
|
258
260
|
export type { CommonToolsOptions };
|
|
259
261
|
export type { CreatePipelineExecutorOptions };
|
package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Executables } from '
|
|
2
|
-
import type { PrepareAndScrapeOptions } from '
|
|
1
|
+
import type { Executables } from '../execution/Executables';
|
|
2
|
+
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
3
3
|
/**
|
|
4
4
|
* @@@
|
|
5
5
|
*
|
|
@@ -7,6 +7,6 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function $provideExecutablesForNode(options?: PrepareAndScrapeOptions): Promise<Executables>;
|
|
9
9
|
/**
|
|
10
|
-
* TODO: [🧠]
|
|
10
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
11
11
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
12
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function locateLibreoffice(): Promise<string_executable_path>;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
10
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function locatePandoc(): Promise<string_executable_path>;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
10
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
|
+
import type { string_executable_path } from '../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Options for locating any application
|
|
5
|
+
*/
|
|
6
|
+
export interface LocateAppOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the application
|
|
9
|
+
*/
|
|
10
|
+
appName: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the executable on Linux
|
|
13
|
+
*/
|
|
14
|
+
linuxWhich?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Path suffix on Windows
|
|
17
|
+
*/
|
|
18
|
+
windowsSuffix?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Name of the application on macOS
|
|
21
|
+
*/
|
|
22
|
+
macOsName?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Locates an application on the system
|
|
26
|
+
*
|
|
27
|
+
* @private within the repository
|
|
28
|
+
*/
|
|
29
|
+
export declare function locateApp(options: RequireAtLeastOne<LocateAppOptions, 'linuxWhich' | 'windowsSuffix' | 'macOsName'>): Promise<string_executable_path>;
|
|
30
|
+
/**
|
|
31
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
32
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
33
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
2
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnLinux({ appName, linuxWhich, }: Pick<Required<LocateAppOptions>, 'appName' | 'linuxWhich'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnMacOs({ appName, macOsName, }: Pick<Required<LocateAppOptions>, 'appName' | 'macOsName'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnWindows({ appName, windowsSuffix, }: Pick<Required<LocateAppOptions>, 'appName' | 'windowsSuffix'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the file is executable
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function isExecutable(path: string, fs: FilesystemTools): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
10
|
+
* TODO: [🖇] What about symlinks?
|
|
11
|
+
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('commander'), require('spacetrim'), require('colors'), require('waitasecond'), require('fs/promises'), require('path'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex'), require('mime-types'), require('dotenv'), require('crypto-js/sha256'), require('glob-promise'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('@azure/openai'), require('openai'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'commander', 'spacetrim', 'colors', 'waitasecond', 'fs/promises', 'path', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'crypto-js/enc-hex', 'mime-types', 'dotenv', 'crypto-js/sha256', 'glob-promise', 'socket.io-client', '@anthropic-ai/sdk', '@azure/openai', 'openai', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.commander, global.spaceTrim, global.colors, global.waitasecond, global.promises, global.path, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.hexEncoder, global.mimeTypes, global.dotenv, global.sha256, global.glob, global.socket_ioClient, global.Anthropic, global.openai, global.OpenAI, global.
|
|
5
|
-
})(this, (function (exports, commander, spaceTrim, colors, waitasecond, promises, path, prettier, parserHtml, papaparse, cryptoJs, hexEncoder, mimeTypes, dotenv, sha256, glob, socket_ioClient, Anthropic, openai, OpenAI,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('commander'), require('spacetrim'), require('colors'), require('waitasecond'), require('fs/promises'), require('path'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex'), require('mime-types'), require('child_process'), require('util'), require('dotenv'), require('crypto-js/sha256'), require('glob-promise'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'commander', 'spacetrim', 'colors', 'waitasecond', 'fs/promises', 'path', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'crypto-js/enc-hex', 'mime-types', 'child_process', 'util', 'dotenv', 'crypto-js/sha256', 'glob-promise', 'socket.io-client', '@anthropic-ai/sdk', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.commander, global.spaceTrim, global.colors, global.waitasecond, global.promises, global.path, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.hexEncoder, global.mimeTypes, global.child_process, global.util, global.dotenv, global.sha256, global.glob, global.socket_ioClient, global.Anthropic, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
+
})(this, (function (exports, commander, spaceTrim, colors, waitasecond, promises, path, prettier, parserHtml, papaparse, cryptoJs, hexEncoder, mimeTypes, child_process, util, dotenv, sha256, glob, socket_ioClient, Anthropic, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.71.0-20';
|
|
43
43
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -4913,7 +4913,6 @@
|
|
|
4913
4913
|
* TODO: [®] DRY Register logic
|
|
4914
4914
|
*/
|
|
4915
4915
|
|
|
4916
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
4917
4916
|
/**
|
|
4918
4917
|
* Creates a message with all registered scrapers
|
|
4919
4918
|
*
|
|
@@ -8358,6 +8357,301 @@
|
|
|
8358
8357
|
* TODO: [🧠] Should be in generated JSON file GENERATOR_WARNING
|
|
8359
8358
|
*/
|
|
8360
8359
|
|
|
8360
|
+
// Note: We want to use the `exec` as async function
|
|
8361
|
+
var exec$1 = util.promisify(child_process.exec);
|
|
8362
|
+
/**
|
|
8363
|
+
* @@@
|
|
8364
|
+
*
|
|
8365
|
+
* @private within the repository
|
|
8366
|
+
*/
|
|
8367
|
+
function locateAppOnLinux(_a) {
|
|
8368
|
+
var appName = _a.appName, linuxWhich = _a.linuxWhich;
|
|
8369
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8370
|
+
var _b, stderr, stdout;
|
|
8371
|
+
return __generator(this, function (_c) {
|
|
8372
|
+
switch (_c.label) {
|
|
8373
|
+
case 0: return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
|
|
8374
|
+
case 1:
|
|
8375
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8376
|
+
if (!stderr && stdout) {
|
|
8377
|
+
return [2 /*return*/, stdout.trim()];
|
|
8378
|
+
}
|
|
8379
|
+
throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
|
|
8380
|
+
}
|
|
8381
|
+
});
|
|
8382
|
+
});
|
|
8383
|
+
}
|
|
8384
|
+
/**
|
|
8385
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8386
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8387
|
+
*/
|
|
8388
|
+
|
|
8389
|
+
/**
|
|
8390
|
+
* @@@
|
|
8391
|
+
*
|
|
8392
|
+
* @public exported from `@promptbook/node`
|
|
8393
|
+
*/
|
|
8394
|
+
function $provideFilesystemForNode(options) {
|
|
8395
|
+
if (!$isRunningInNode()) {
|
|
8396
|
+
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8397
|
+
}
|
|
8398
|
+
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8399
|
+
TODO_USE(isVerbose);
|
|
8400
|
+
return {
|
|
8401
|
+
stat: promises.stat,
|
|
8402
|
+
access: promises.access,
|
|
8403
|
+
constants: promises.constants,
|
|
8404
|
+
readFile: promises.readFile,
|
|
8405
|
+
readdir: promises.readdir,
|
|
8406
|
+
};
|
|
8407
|
+
}
|
|
8408
|
+
/**
|
|
8409
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8410
|
+
*/
|
|
8411
|
+
|
|
8412
|
+
/**
|
|
8413
|
+
* Checks if the file is executable
|
|
8414
|
+
*
|
|
8415
|
+
* @private within the repository
|
|
8416
|
+
*/
|
|
8417
|
+
function isExecutable(path, fs) {
|
|
8418
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8419
|
+
return __generator(this, function (_a) {
|
|
8420
|
+
switch (_a.label) {
|
|
8421
|
+
case 0:
|
|
8422
|
+
_a.trys.push([0, 2, , 3]);
|
|
8423
|
+
return [4 /*yield*/, fs.access(path, fs.constants.X_OK)];
|
|
8424
|
+
case 1:
|
|
8425
|
+
_a.sent();
|
|
8426
|
+
return [2 /*return*/, true];
|
|
8427
|
+
case 2:
|
|
8428
|
+
_a.sent();
|
|
8429
|
+
return [2 /*return*/, false];
|
|
8430
|
+
case 3: return [2 /*return*/];
|
|
8431
|
+
}
|
|
8432
|
+
});
|
|
8433
|
+
});
|
|
8434
|
+
}
|
|
8435
|
+
/**
|
|
8436
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
8437
|
+
* TODO: [🖇] What about symlinks?
|
|
8438
|
+
*/
|
|
8439
|
+
|
|
8440
|
+
// Note: Module `userhome` has no types available, so it is imported using `require`
|
|
8441
|
+
// @see https://stackoverflow.com/questions/37000981/how-to-import-node-module-in-typescript-without-type-definitions
|
|
8442
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8443
|
+
var userhome = require('userhome');
|
|
8444
|
+
// Note: We want to use the `exec` as async function
|
|
8445
|
+
var exec = util.promisify(child_process.exec);
|
|
8446
|
+
/**
|
|
8447
|
+
* @@@
|
|
8448
|
+
*
|
|
8449
|
+
* @private within the repository
|
|
8450
|
+
*/
|
|
8451
|
+
function locateAppOnMacOs(_a) {
|
|
8452
|
+
var appName = _a.appName, macOsName = _a.macOsName;
|
|
8453
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8454
|
+
var toExec, regPath, altPath, _b, stderr, stdout;
|
|
8455
|
+
return __generator(this, function (_c) {
|
|
8456
|
+
switch (_c.label) {
|
|
8457
|
+
case 0:
|
|
8458
|
+
toExec = "/Contents/MacOS/".concat(macOsName);
|
|
8459
|
+
regPath = "/Applications/".concat(macOsName, ".app") + toExec;
|
|
8460
|
+
altPath = userhome(regPath.slice(1));
|
|
8461
|
+
return [4 /*yield*/, isExecutable(regPath, $provideFilesystemForNode())];
|
|
8462
|
+
case 1:
|
|
8463
|
+
if (!_c.sent()) return [3 /*break*/, 2];
|
|
8464
|
+
return [2 /*return*/, regPath];
|
|
8465
|
+
case 2: return [4 /*yield*/, isExecutable(altPath, $provideFilesystemForNode())];
|
|
8466
|
+
case 3:
|
|
8467
|
+
if (_c.sent()) {
|
|
8468
|
+
return [2 /*return*/, altPath];
|
|
8469
|
+
}
|
|
8470
|
+
_c.label = 4;
|
|
8471
|
+
case 4: return [4 /*yield*/, exec("mdfind 'kMDItemDisplayName == \"".concat(macOsName, "\" && kMDItemKind == Application'"))];
|
|
8472
|
+
case 5:
|
|
8473
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8474
|
+
if (!stderr && stdout) {
|
|
8475
|
+
return [2 /*return*/, stdout.trim() + toExec];
|
|
8476
|
+
}
|
|
8477
|
+
throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
|
|
8478
|
+
}
|
|
8479
|
+
});
|
|
8480
|
+
});
|
|
8481
|
+
}
|
|
8482
|
+
/**
|
|
8483
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8484
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8485
|
+
*/
|
|
8486
|
+
|
|
8487
|
+
/**
|
|
8488
|
+
* @@@
|
|
8489
|
+
*
|
|
8490
|
+
* @private within the repository
|
|
8491
|
+
*/
|
|
8492
|
+
function locateAppOnWindows(_a) {
|
|
8493
|
+
var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
|
|
8494
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8495
|
+
var prefixes, prefixes_1, prefixes_1_1, prefix, path$1, e_1_1;
|
|
8496
|
+
var e_1, _b;
|
|
8497
|
+
return __generator(this, function (_c) {
|
|
8498
|
+
switch (_c.label) {
|
|
8499
|
+
case 0:
|
|
8500
|
+
prefixes = [
|
|
8501
|
+
process.env.LOCALAPPDATA,
|
|
8502
|
+
path.join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
8503
|
+
process.env.PROGRAMFILES,
|
|
8504
|
+
process.env['PROGRAMFILES(X86)'],
|
|
8505
|
+
];
|
|
8506
|
+
_c.label = 1;
|
|
8507
|
+
case 1:
|
|
8508
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
8509
|
+
prefixes_1 = __values(prefixes), prefixes_1_1 = prefixes_1.next();
|
|
8510
|
+
_c.label = 2;
|
|
8511
|
+
case 2:
|
|
8512
|
+
if (!!prefixes_1_1.done) return [3 /*break*/, 5];
|
|
8513
|
+
prefix = prefixes_1_1.value;
|
|
8514
|
+
path$1 = prefix + windowsSuffix;
|
|
8515
|
+
return [4 /*yield*/, isExecutable(path$1, $provideFilesystemForNode())];
|
|
8516
|
+
case 3:
|
|
8517
|
+
if (_c.sent()) {
|
|
8518
|
+
return [2 /*return*/, path$1];
|
|
8519
|
+
}
|
|
8520
|
+
_c.label = 4;
|
|
8521
|
+
case 4:
|
|
8522
|
+
prefixes_1_1 = prefixes_1.next();
|
|
8523
|
+
return [3 /*break*/, 2];
|
|
8524
|
+
case 5: return [3 /*break*/, 8];
|
|
8525
|
+
case 6:
|
|
8526
|
+
e_1_1 = _c.sent();
|
|
8527
|
+
e_1 = { error: e_1_1 };
|
|
8528
|
+
return [3 /*break*/, 8];
|
|
8529
|
+
case 7:
|
|
8530
|
+
try {
|
|
8531
|
+
if (prefixes_1_1 && !prefixes_1_1.done && (_b = prefixes_1.return)) _b.call(prefixes_1);
|
|
8532
|
+
}
|
|
8533
|
+
finally { if (e_1) throw e_1.error; }
|
|
8534
|
+
return [7 /*endfinally*/];
|
|
8535
|
+
case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
|
|
8536
|
+
}
|
|
8537
|
+
});
|
|
8538
|
+
});
|
|
8539
|
+
}
|
|
8540
|
+
/**
|
|
8541
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8542
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8543
|
+
*/
|
|
8544
|
+
|
|
8545
|
+
/**
|
|
8546
|
+
* Locates an application on the system
|
|
8547
|
+
*
|
|
8548
|
+
* @private within the repository
|
|
8549
|
+
*/
|
|
8550
|
+
function locateApp(options) {
|
|
8551
|
+
if (!$isRunningInNode()) {
|
|
8552
|
+
throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
|
|
8553
|
+
}
|
|
8554
|
+
var appName = options.appName, linuxWhich = options.linuxWhich, windowsSuffix = options.windowsSuffix, macOsName = options.macOsName;
|
|
8555
|
+
if (process.platform === 'win32') {
|
|
8556
|
+
if (windowsSuffix) {
|
|
8557
|
+
return locateAppOnWindows({ appName: appName, windowsSuffix: windowsSuffix });
|
|
8558
|
+
}
|
|
8559
|
+
else {
|
|
8560
|
+
throw new Error("".concat(appName, " is not available on Windows."));
|
|
8561
|
+
}
|
|
8562
|
+
}
|
|
8563
|
+
else if (process.platform === 'darwin') {
|
|
8564
|
+
if (macOsName) {
|
|
8565
|
+
return locateAppOnMacOs({ appName: appName, macOsName: macOsName });
|
|
8566
|
+
}
|
|
8567
|
+
else {
|
|
8568
|
+
throw new Error("".concat(appName, " is not available on macOS."));
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
else {
|
|
8572
|
+
if (linuxWhich) {
|
|
8573
|
+
return locateAppOnLinux({ appName: appName, linuxWhich: linuxWhich });
|
|
8574
|
+
}
|
|
8575
|
+
else {
|
|
8576
|
+
throw new Error("".concat(appName, " is not available on Linux."));
|
|
8577
|
+
}
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
/**
|
|
8581
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8582
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8583
|
+
*/
|
|
8584
|
+
|
|
8585
|
+
/**
|
|
8586
|
+
* @@@
|
|
8587
|
+
*
|
|
8588
|
+
* @private within the repository
|
|
8589
|
+
*/
|
|
8590
|
+
function locateLibreoffice() {
|
|
8591
|
+
return locateApp({
|
|
8592
|
+
appName: 'Libreoffice',
|
|
8593
|
+
linuxWhich: 'libreoffice',
|
|
8594
|
+
windowsSuffix: '\\LibreOffice\\program\\soffice.exe',
|
|
8595
|
+
macOsName: 'LibreOffice',
|
|
8596
|
+
});
|
|
8597
|
+
}
|
|
8598
|
+
/**
|
|
8599
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
8600
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8601
|
+
*/
|
|
8602
|
+
|
|
8603
|
+
/**
|
|
8604
|
+
* @@@
|
|
8605
|
+
*
|
|
8606
|
+
* @private within the repository
|
|
8607
|
+
*/
|
|
8608
|
+
function locatePandoc() {
|
|
8609
|
+
return locateApp({
|
|
8610
|
+
appName: 'Pandoc',
|
|
8611
|
+
linuxWhich: 'pandoc',
|
|
8612
|
+
windowsSuffix: '\\Pandoc\\pandoc.exe',
|
|
8613
|
+
macOsName: 'Pandoc',
|
|
8614
|
+
});
|
|
8615
|
+
}
|
|
8616
|
+
/**
|
|
8617
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
8618
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8619
|
+
*/
|
|
8620
|
+
|
|
8621
|
+
/**
|
|
8622
|
+
* @@@
|
|
8623
|
+
*
|
|
8624
|
+
* @public exported from `@promptbook/node`
|
|
8625
|
+
*/
|
|
8626
|
+
function $provideExecutablesForNode(options) {
|
|
8627
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8628
|
+
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8629
|
+
var _d;
|
|
8630
|
+
return __generator(this, function (_e) {
|
|
8631
|
+
switch (_e.label) {
|
|
8632
|
+
case 0:
|
|
8633
|
+
if (!$isRunningInNode()) {
|
|
8634
|
+
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8635
|
+
}
|
|
8636
|
+
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8637
|
+
TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
|
|
8638
|
+
TODO_USE(isVerbose);
|
|
8639
|
+
_d = {};
|
|
8640
|
+
return [4 /*yield*/, locatePandoc()];
|
|
8641
|
+
case 1:
|
|
8642
|
+
_d.pandocPath = _e.sent();
|
|
8643
|
+
return [4 /*yield*/, locateLibreoffice()];
|
|
8644
|
+
case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
|
|
8645
|
+
_d)];
|
|
8646
|
+
}
|
|
8647
|
+
});
|
|
8648
|
+
});
|
|
8649
|
+
}
|
|
8650
|
+
/**
|
|
8651
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
8652
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8653
|
+
*/
|
|
8654
|
+
|
|
8361
8655
|
/**
|
|
8362
8656
|
* @@@
|
|
8363
8657
|
*
|
|
@@ -8588,57 +8882,6 @@
|
|
|
8588
8882
|
* TODO: [®] DRY Register logic
|
|
8589
8883
|
*/
|
|
8590
8884
|
|
|
8591
|
-
/**
|
|
8592
|
-
* @@@
|
|
8593
|
-
*
|
|
8594
|
-
* @public exported from `@promptbook/node`
|
|
8595
|
-
*/
|
|
8596
|
-
function $provideExecutablesForNode(options) {
|
|
8597
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8598
|
-
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8599
|
-
return __generator(this, function (_d) {
|
|
8600
|
-
if (!$isRunningInNode()) {
|
|
8601
|
-
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8602
|
-
}
|
|
8603
|
-
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8604
|
-
TODO_USE(isAutoInstalled);
|
|
8605
|
-
TODO_USE(isVerbose);
|
|
8606
|
-
return [2 /*return*/, {
|
|
8607
|
-
// TODO: !!!!!! use `locate-app` library here
|
|
8608
|
-
pandocPath: 'C:/Users/me/AppData/Local/Pandoc/pandoc.exe',
|
|
8609
|
-
libreOfficePath: 'C:/Program Files/LibreOffice/program/swriter.exe',
|
|
8610
|
-
}];
|
|
8611
|
-
});
|
|
8612
|
-
});
|
|
8613
|
-
}
|
|
8614
|
-
/**
|
|
8615
|
-
* TODO: [🧠] THis should be maybe in different folder
|
|
8616
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8617
|
-
*/
|
|
8618
|
-
|
|
8619
|
-
/**
|
|
8620
|
-
* @@@
|
|
8621
|
-
*
|
|
8622
|
-
* @public exported from `@promptbook/node`
|
|
8623
|
-
*/
|
|
8624
|
-
function $provideFilesystemForNode(options) {
|
|
8625
|
-
if (!$isRunningInNode()) {
|
|
8626
|
-
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8627
|
-
}
|
|
8628
|
-
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8629
|
-
TODO_USE(isVerbose);
|
|
8630
|
-
return {
|
|
8631
|
-
stat: promises.stat,
|
|
8632
|
-
access: promises.access,
|
|
8633
|
-
constants: promises.constants,
|
|
8634
|
-
readFile: promises.readFile,
|
|
8635
|
-
readdir: promises.readdir,
|
|
8636
|
-
};
|
|
8637
|
-
}
|
|
8638
|
-
/**
|
|
8639
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8640
|
-
*/
|
|
8641
|
-
|
|
8642
8885
|
/**
|
|
8643
8886
|
* @@@
|
|
8644
8887
|
*
|