@promptbook/core 0.52.0-15 → 0.52.0-16
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 +62 -38
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/core.index.d.ts +4 -2
- package/esm/typings/library/constructors/justTestFsImport.d.ts +4 -0
- package/package.json +2 -1
- package/umd/index.umd.js +67 -41
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/core.index.d.ts +4 -2
- package/umd/typings/library/constructors/justTestFsImport.d.ts +4 -0
package/umd/index.umd.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('glob-promise'), require('moment')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'glob-promise', 'moment'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.glob, global.moment));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, glob, moment) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
10
10
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
11
|
+
var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
|
|
11
12
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
12
13
|
|
|
13
14
|
/*! *****************************************************************************
|
|
@@ -454,7 +455,7 @@
|
|
|
454
455
|
/**
|
|
455
456
|
* The version of the Promptbook library
|
|
456
457
|
*/
|
|
457
|
-
var PROMPTBOOK_VERSION = '0.52.0-
|
|
458
|
+
var PROMPTBOOK_VERSION = '0.52.0-15';
|
|
458
459
|
|
|
459
460
|
/**
|
|
460
461
|
* Parses the template and returns the list of all parameter names
|
|
@@ -3175,23 +3176,6 @@
|
|
|
3175
3176
|
*/
|
|
3176
3177
|
new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
|
|
3177
3178
|
|
|
3178
|
-
/**
|
|
3179
|
-
* Returns the same value that is passed as argument.
|
|
3180
|
-
* No side effects.
|
|
3181
|
-
*
|
|
3182
|
-
* Note: It can be usefull for leveling indentation
|
|
3183
|
-
*
|
|
3184
|
-
* @param value any values
|
|
3185
|
-
* @returns the same values
|
|
3186
|
-
*/
|
|
3187
|
-
function just(value) {
|
|
3188
|
-
if (value === undefined) {
|
|
3189
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3190
|
-
return undefined;
|
|
3191
|
-
}
|
|
3192
|
-
return value;
|
|
3193
|
-
}
|
|
3194
|
-
|
|
3195
3179
|
/**
|
|
3196
3180
|
* This error indicates that promptbook not found in the library
|
|
3197
3181
|
*/
|
|
@@ -3430,32 +3414,34 @@
|
|
|
3430
3414
|
* @param options - Misc options for the library
|
|
3431
3415
|
* @returns PromptbookLibrary
|
|
3432
3416
|
*/
|
|
3433
|
-
function createPromptbookLibraryFromDirectory(path
|
|
3417
|
+
function createPromptbookLibraryFromDirectory(path, options) {
|
|
3434
3418
|
var _this = this;
|
|
3435
3419
|
if (!isRunningInNode()) {
|
|
3436
3420
|
throw new Error('Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
|
|
3437
3421
|
}
|
|
3438
3422
|
var _a = (options || {}).isRecursive, isRecursive = _a === void 0 ? true : _a;
|
|
3439
3423
|
return createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3440
|
-
var justR_equire, readdir, dirents, fileNames;
|
|
3441
3424
|
return __generator(this, function (_a) {
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3425
|
+
/*
|
|
3426
|
+
const justR_equire = require; /* <- Note: [1] * /
|
|
3427
|
+
const readdir = justR_equire(just('fs/promises') /* <- Note: [2] * /).readdir as typeof readdirType;
|
|
3428
|
+
|
|
3429
|
+
// TODO: !!!! Implement recursive reading
|
|
3430
|
+
// TODO: !!!!! readAllFiles util
|
|
3431
|
+
|
|
3432
|
+
const dirents = await readdir(path, {
|
|
3433
|
+
withFileTypes: true /* Note: This is not working: recursive: isRecursive * /,
|
|
3434
|
+
});
|
|
3435
|
+
const fileNames = dirents.filter((dirent) => dirent.isFile()).map(({ name }) => join(name, path));
|
|
3436
|
+
|
|
3437
|
+
// TODO: !!! Implement
|
|
3438
|
+
|
|
3439
|
+
console.info('createPromptbookLibraryFromDirectory', { path, isRecursive, fileNames });
|
|
3440
|
+
throw new Error('Not implemented yet');
|
|
3441
|
+
|
|
3442
|
+
*/
|
|
3443
|
+
console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive });
|
|
3444
|
+
return [2 /*return*/, []];
|
|
3459
3445
|
});
|
|
3460
3446
|
}); });
|
|
3461
3447
|
}
|
|
@@ -3567,6 +3553,28 @@
|
|
|
3567
3553
|
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
|
|
3568
3554
|
*/
|
|
3569
3555
|
|
|
3556
|
+
/**
|
|
3557
|
+
* Just testing imports and compatibility
|
|
3558
|
+
*/
|
|
3559
|
+
function justTestFsImport() {
|
|
3560
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3561
|
+
var files;
|
|
3562
|
+
return __generator(this, function (_a) {
|
|
3563
|
+
switch (_a.label) {
|
|
3564
|
+
case 0:
|
|
3565
|
+
if (!isRunningInNode()) {
|
|
3566
|
+
throw new Error('Function `testFiles` can only be run in Node.js environment because it reads the file system.');
|
|
3567
|
+
}
|
|
3568
|
+
return [4 /*yield*/, glob__default["default"]('/**/*')];
|
|
3569
|
+
case 1:
|
|
3570
|
+
files = _a.sent();
|
|
3571
|
+
console.info('testFiles', { files: files });
|
|
3572
|
+
return [2 /*return*/];
|
|
3573
|
+
}
|
|
3574
|
+
});
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
|
|
3570
3578
|
/**
|
|
3571
3579
|
* Format either small or big number
|
|
3572
3580
|
*
|
|
@@ -3587,6 +3595,23 @@
|
|
|
3587
3595
|
return value.toString();
|
|
3588
3596
|
}
|
|
3589
3597
|
|
|
3598
|
+
/**
|
|
3599
|
+
* Returns the same value that is passed as argument.
|
|
3600
|
+
* No side effects.
|
|
3601
|
+
*
|
|
3602
|
+
* Note: It can be usefull for leveling indentation
|
|
3603
|
+
*
|
|
3604
|
+
* @param value any values
|
|
3605
|
+
* @returns the same values
|
|
3606
|
+
*/
|
|
3607
|
+
function just(value) {
|
|
3608
|
+
if (value === undefined) {
|
|
3609
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3610
|
+
return undefined;
|
|
3611
|
+
}
|
|
3612
|
+
return value;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3590
3615
|
/**
|
|
3591
3616
|
* Create a markdown table from a 2D array of strings
|
|
3592
3617
|
*
|
|
@@ -3884,6 +3909,7 @@
|
|
|
3884
3909
|
exports.createPromptbookSublibrary = createPromptbookSublibrary;
|
|
3885
3910
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
3886
3911
|
exports.isPassingExpectations = isPassingExpectations;
|
|
3912
|
+
exports.justTestFsImport = justTestFsImport;
|
|
3887
3913
|
exports.prettifyPromptbookString = prettifyPromptbookString;
|
|
3888
3914
|
exports.promptbookJsonToString = promptbookJsonToString;
|
|
3889
3915
|
exports.promptbookStringToJson = promptbookStringToJson;
|