fix
This commit is contained in:
24
book/node_modules/honkit/lib/utils/command.d.ts
generated
vendored
Normal file
24
book/node_modules/honkit/lib/utils/command.d.ts
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import childProcess from "child_process";
|
||||
/**
|
||||
Execute a command
|
||||
|
||||
@param {string} command
|
||||
@param {Object} options
|
||||
@return {Promise}
|
||||
*/
|
||||
declare function exec(command: string, options: {
|
||||
encoding?: "buffer";
|
||||
} & childProcess.ExecOptions): any;
|
||||
/**
|
||||
Transform a map of options into a command line arguments string
|
||||
|
||||
@param {Object} options
|
||||
@return {string}
|
||||
*/
|
||||
declare function optionsToShellArgs(options: any): string;
|
||||
declare const _default: {
|
||||
exec: typeof exec;
|
||||
optionsToShellArgs: typeof optionsToShellArgs;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=command.d.ts.map
|
1
book/node_modules/honkit/lib/utils/command.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/command.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/utils/command.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAC;AAGzC;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,YAAY,CAAC,WAAW,OAqBzF;AAmBD;;;;;GAKG;AACH,iBAAS,kBAAkB,CAAC,OAAO,KAAA,UAkBlC;;;;;AAED,wBAGE"}
|
72
book/node_modules/honkit/lib/utils/command.js
generated
vendored
Normal file
72
book/node_modules/honkit/lib/utils/command.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const child_process_1 = __importDefault(require("child_process"));
|
||||
const promise_1 = __importDefault(require("./promise"));
|
||||
/**
|
||||
Execute a command
|
||||
|
||||
@param {string} command
|
||||
@param {Object} options
|
||||
@return {Promise}
|
||||
*/
|
||||
function exec(command, options) {
|
||||
const d = promise_1.default.defer();
|
||||
const child = child_process_1.default.exec(command, options, (err, stdout, stderr) => {
|
||||
if (!err) {
|
||||
return d.resolve();
|
||||
}
|
||||
err.message = stdout.toString() + stderr.toString();
|
||||
d.reject(err);
|
||||
});
|
||||
child.stdout.on("data", (data) => {
|
||||
d.notify(data);
|
||||
});
|
||||
child.stderr.on("data", (data) => {
|
||||
d.notify(data);
|
||||
});
|
||||
return d.promise;
|
||||
}
|
||||
/**
|
||||
Transform an option object to a command line string
|
||||
|
||||
@param {String|number} value
|
||||
@param {string}
|
||||
*/
|
||||
function escapeShellArg(value) {
|
||||
if (is_1.default.number(value)) {
|
||||
return value;
|
||||
}
|
||||
value = String(value);
|
||||
value = value.replace(/"/g, '\\"');
|
||||
return `"${value}"`;
|
||||
}
|
||||
/**
|
||||
Transform a map of options into a command line arguments string
|
||||
|
||||
@param {Object} options
|
||||
@return {string}
|
||||
*/
|
||||
function optionsToShellArgs(options) {
|
||||
const result = [];
|
||||
for (const key in options) {
|
||||
const value = options[key];
|
||||
if (value === null || value === undefined || value === false) {
|
||||
continue;
|
||||
}
|
||||
if (typeof value === "boolean") {
|
||||
result.push(key);
|
||||
}
|
||||
else {
|
||||
result.push(`${key}=${escapeShellArg(value)}`);
|
||||
}
|
||||
}
|
||||
return result.join(" ");
|
||||
}
|
||||
exports.default = {
|
||||
exec: exec,
|
||||
optionsToShellArgs: optionsToShellArgs
|
||||
};
|
16
book/node_modules/honkit/lib/utils/error.d.ts
generated
vendored
Normal file
16
book/node_modules/honkit/lib/utils/error.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
declare function enforce(err: any): any;
|
||||
declare const _default: {
|
||||
enforce: typeof enforce;
|
||||
ParsingError: any;
|
||||
OutputError: any;
|
||||
RequireInstallError: any;
|
||||
FileNotParsableError: any;
|
||||
FileNotFoundError: any;
|
||||
FileOutOfScopeError: any;
|
||||
TemplateError: any;
|
||||
PluginError: any;
|
||||
ConfigurationError: any;
|
||||
EbookError: any;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=error.d.ts.map
|
1
book/node_modules/honkit/lib/utils/error.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/error.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAKA,iBAAS,OAAO,CAAC,GAAG,KAAA,OAKnB;;;;;;;;;;;;;;AAuED,wBAeE"}
|
88
book/node_modules/honkit/lib/utils/error.js
generated
vendored
Normal file
88
book/node_modules/honkit/lib/utils/error.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const typed_1 = __importDefault(require("error/typed"));
|
||||
const wrapped_1 = __importDefault(require("error/wrapped"));
|
||||
// Enforce as an Error object, and cleanup message
|
||||
function enforce(err) {
|
||||
if (is_1.default.string(err))
|
||||
err = new Error(err);
|
||||
err.message = err.message.replace(/^Error: /, "");
|
||||
return err;
|
||||
}
|
||||
// Random error wrappers during parsing/generation
|
||||
const ParsingError = (0, wrapped_1.default)({
|
||||
message: "Parsing Error: {origMessage}",
|
||||
type: "parse"
|
||||
});
|
||||
const OutputError = (0, wrapped_1.default)({
|
||||
message: "Output Error: {origMessage}",
|
||||
type: "generate"
|
||||
});
|
||||
// A file does not exists
|
||||
const FileNotFoundError = (0, typed_1.default)({
|
||||
type: "file.not-found",
|
||||
message: 'No "{filename}" file (or is ignored)',
|
||||
filename: null
|
||||
});
|
||||
// A file cannot be parsed
|
||||
const FileNotParsableError = (0, typed_1.default)({
|
||||
type: "file.not-parsable",
|
||||
message: '"{filename}" file cannot be parsed',
|
||||
filename: null
|
||||
});
|
||||
// A file is outside the scope
|
||||
const FileOutOfScopeError = (0, typed_1.default)({
|
||||
type: "file.out-of-scope",
|
||||
message: '"{filename}" not in "{root}"',
|
||||
filename: null,
|
||||
root: null,
|
||||
code: "EACCESS"
|
||||
});
|
||||
// A file is outside the scope
|
||||
const RequireInstallError = (0, typed_1.default)({
|
||||
type: "install.required",
|
||||
message: '"{cmd}" is not installed.\n{install}',
|
||||
cmd: null,
|
||||
code: "ENOENT",
|
||||
install: ""
|
||||
});
|
||||
// Error for nunjucks templates
|
||||
const TemplateError = (0, wrapped_1.default)({
|
||||
message: 'Error compiling template "{filename}": {origMessage}',
|
||||
type: "template",
|
||||
filename: null
|
||||
});
|
||||
// Error for nunjucks templates
|
||||
const PluginError = (0, wrapped_1.default)({
|
||||
message: 'Error with plugin "{plugin}": {origMessage}',
|
||||
type: "plugin",
|
||||
plugin: null
|
||||
});
|
||||
// Error with the book's configuration
|
||||
const ConfigurationError = (0, wrapped_1.default)({
|
||||
message: "Error with book's configuration: {origMessage}",
|
||||
type: "configuration"
|
||||
});
|
||||
// Error during ebook generation
|
||||
const EbookError = (0, wrapped_1.default)({
|
||||
message: "Error during ebook generation: {origMessage}\n{stdout}",
|
||||
type: "ebook",
|
||||
stdout: ""
|
||||
});
|
||||
exports.default = {
|
||||
enforce: enforce,
|
||||
ParsingError: ParsingError,
|
||||
OutputError: OutputError,
|
||||
RequireInstallError: RequireInstallError,
|
||||
FileNotParsableError: FileNotParsableError,
|
||||
FileNotFoundError: FileNotFoundError,
|
||||
FileOutOfScopeError: FileOutOfScopeError,
|
||||
TemplateError: TemplateError,
|
||||
PluginError: PluginError,
|
||||
ConfigurationError: ConfigurationError,
|
||||
EbookError: EbookError
|
||||
};
|
65
book/node_modules/honkit/lib/utils/fs.d.ts
generated
vendored
Normal file
65
book/node_modules/honkit/lib/utils/fs.d.ts
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import fs from "fs";
|
||||
declare function writeStream(filename: any, st: any): any;
|
||||
declare function fileExists(filename: any): any;
|
||||
declare function genTmpFile(opts: any): any;
|
||||
/**
|
||||
* Generate temporary dir
|
||||
* @deprecated use tmpdir.ts
|
||||
* @param opts
|
||||
*/
|
||||
declare function genTmpDir(opts: any): any;
|
||||
declare function download(uri: string, destFilePath: string): Promise<any>;
|
||||
declare function uniqueFilename(base: any, filename: any): any;
|
||||
declare function ensureFile(filename: any): any;
|
||||
declare function rmDir(base: any): any;
|
||||
/**
|
||||
Assert a file, if it doesn't exist, call "generator"
|
||||
|
||||
@param {string} filePath
|
||||
@param {Function} generator
|
||||
@return {Promise}
|
||||
*/
|
||||
declare function assertFile(filePath: any, generator: any): any;
|
||||
/**
|
||||
Pick a file, returns the absolute path if exists, undefined otherwise
|
||||
|
||||
@param {string} rootFolder
|
||||
@param {string} fileName
|
||||
@return {string}
|
||||
*/
|
||||
declare function pickFile(rootFolder: any, fileName: any): string;
|
||||
/**
|
||||
Ensure that a directory exists and is empty
|
||||
|
||||
@param {string} folder
|
||||
@return {Promise}
|
||||
*/
|
||||
declare function ensureFolder(rootFolder: any): any;
|
||||
declare const _default: {
|
||||
exists: typeof fileExists;
|
||||
existsSync: typeof fs.existsSync;
|
||||
mkdirp: any;
|
||||
readFile: any;
|
||||
writeFile: (filePath: any, content: any) => any;
|
||||
assertFile: typeof assertFile;
|
||||
pickFile: typeof pickFile;
|
||||
stat: any;
|
||||
statSync: fs.StatSyncFn;
|
||||
readdir: any;
|
||||
writeStream: typeof writeStream;
|
||||
readStream: typeof fs.createReadStream;
|
||||
copy: any;
|
||||
copyDir: any;
|
||||
tmpFile: typeof genTmpFile;
|
||||
/**
|
||||
* @deprecated use tmpdir.ts
|
||||
*/
|
||||
tmpDir: typeof genTmpDir;
|
||||
download: typeof download;
|
||||
uniqueFilename: typeof uniqueFilename;
|
||||
ensureFile: typeof ensureFile;
|
||||
ensureFolder: typeof ensureFolder;
|
||||
rmDir: typeof rmDir;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=fs.d.ts.map
|
1
book/node_modules/honkit/lib/utils/fs.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/fs.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAYpB,iBAAS,WAAW,CAAC,QAAQ,KAAA,EAAE,EAAE,KAAA,OA0BhC;AAGD,iBAAS,UAAU,CAAC,QAAQ,KAAA,OAY3B;AAGD,iBAAS,UAAU,CAAC,IAAI,KAAA,OAEvB;AAED;;;;GAIG;AACH,iBAAS,SAAS,CAAC,IAAI,KAAA,OAEtB;AA0BD,iBAAe,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAaxD;AAGD,iBAAS,cAAc,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA,OAcrC;AAGD,iBAAS,UAAU,CAAC,QAAQ,KAAA,OAI3B;AAGD,iBAAS,KAAK,CAAC,IAAI,KAAA,OAIlB;AAED;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,QAAQ,KAAA,EAAE,SAAS,KAAA,OAMtC;AAED;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,UAAU,KAAA,EAAE,QAAQ,KAAA,UAOrC;AAED;;;;;GAKG;AACH,iBAAS,YAAY,CAAC,UAAU,KAAA,OAQ/B;;;;;;;;;;;;;;;;;IAiCG;;OAEG;;;;;;;;AAjCP,wBAwCE"}
|
205
book/node_modules/honkit/lib/utils/fs.js
generated
vendored
Normal file
205
book/node_modules/honkit/lib/utils/fs.js
generated
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const mkdirp_1 = __importDefault(require("mkdirp"));
|
||||
const destroy_1 = __importDefault(require("destroy"));
|
||||
const tmp_1 = __importDefault(require("tmp"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const cp_1 = __importDefault(require("cp"));
|
||||
const cpr_1 = __importDefault(require("cpr"));
|
||||
const promise_1 = __importDefault(require("./promise"));
|
||||
const http_1 = __importDefault(require("http"));
|
||||
const https_1 = __importDefault(require("https"));
|
||||
// Write a stream to a file
|
||||
function writeStream(filename, st) {
|
||||
const d = promise_1.default.defer();
|
||||
const wstream = fs_1.default.createWriteStream(filename);
|
||||
const cleanup = function () {
|
||||
(0, destroy_1.default)(wstream);
|
||||
wstream.removeAllListeners();
|
||||
};
|
||||
wstream.on("finish", () => {
|
||||
cleanup();
|
||||
d.resolve();
|
||||
});
|
||||
wstream.on("error", (err) => {
|
||||
cleanup();
|
||||
d.reject(err);
|
||||
});
|
||||
st.on("error", (err) => {
|
||||
cleanup();
|
||||
d.reject(err);
|
||||
});
|
||||
st.pipe(wstream);
|
||||
return d.promise;
|
||||
}
|
||||
// Return a promise resolved with a boolean
|
||||
function fileExists(filename) {
|
||||
const d = promise_1.default.defer();
|
||||
fs_1.default.stat(filename, (error) => {
|
||||
if (error) {
|
||||
d.resolve(false);
|
||||
}
|
||||
else {
|
||||
d.resolve(true);
|
||||
}
|
||||
});
|
||||
return d.promise;
|
||||
}
|
||||
// Generate temporary file
|
||||
function genTmpFile(opts) {
|
||||
return promise_1.default.nfcall(tmp_1.default.file, opts).get(0);
|
||||
}
|
||||
/**
|
||||
* Generate temporary dir
|
||||
* @deprecated use tmpdir.ts
|
||||
* @param opts
|
||||
*/
|
||||
function genTmpDir(opts) {
|
||||
return promise_1.default.nfcall(tmp_1.default.dir, opts).get(0);
|
||||
}
|
||||
// https://stackoverflow.com/questions/11944932/how-to-download-a-file-with-node-js-without-using-third-party-libraries
|
||||
const downloadStream = (url, dest, cb) => {
|
||||
const file = fs_1.default.createWriteStream(dest);
|
||||
const protocol = url.startsWith("https") ? https_1.default : http_1.default;
|
||||
const request = protocol.get(url, (response) => {
|
||||
// check if response is success
|
||||
if (response.statusCode < 200 && response.statusCode > 300) {
|
||||
return cb(new Error("Response status was " + response.statusCode));
|
||||
}
|
||||
response.pipe(file);
|
||||
});
|
||||
// close() is async, call cb after close completes
|
||||
file.on("finish", () => file.close(() => cb(null)));
|
||||
// check for request error too
|
||||
request.on("error", (err) => {
|
||||
fs_1.default.unlink(dest, () => cb(err)); // delete the (partial) file and then return the error
|
||||
});
|
||||
file.on("error", (err) => {
|
||||
// Handle errors
|
||||
fs_1.default.unlink(dest, () => cb(err)); // delete the (partial) file and then return the error
|
||||
});
|
||||
};
|
||||
// Download an image
|
||||
async function download(uri, destFilePath) {
|
||||
// create dest dir if not exists
|
||||
const destDir = path_1.default.dirname(destFilePath);
|
||||
await fs_1.default.promises.mkdir(destDir, { recursive: true });
|
||||
const d = promise_1.default.defer();
|
||||
downloadStream(uri, destFilePath, (err) => {
|
||||
if (err) {
|
||||
d.reject(err);
|
||||
}
|
||||
else {
|
||||
d.resolve();
|
||||
}
|
||||
});
|
||||
return d.promise;
|
||||
}
|
||||
// Find a filename available in a folder
|
||||
function uniqueFilename(base, filename) {
|
||||
const ext = path_1.default.extname(filename);
|
||||
filename = path_1.default.resolve(base, filename);
|
||||
filename = path_1.default.join(path_1.default.dirname(filename), path_1.default.basename(filename, ext));
|
||||
let _filename = filename + ext;
|
||||
let i = 0;
|
||||
while (fs_1.default.existsSync(filename)) {
|
||||
_filename = `${filename}_${i}${ext}`;
|
||||
i = i + 1;
|
||||
}
|
||||
return (0, promise_1.default)(path_1.default.relative(base, _filename));
|
||||
}
|
||||
// Create all required folder to create a file
|
||||
function ensureFile(filename) {
|
||||
const base = path_1.default.dirname(filename);
|
||||
return (0, promise_1.default)((0, mkdirp_1.default)(base));
|
||||
}
|
||||
// Remove a folder
|
||||
function rmDir(base) {
|
||||
return promise_1.default.nfcall(fs_1.default.rm, base, {
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
/**
|
||||
Assert a file, if it doesn't exist, call "generator"
|
||||
|
||||
@param {string} filePath
|
||||
@param {Function} generator
|
||||
@return {Promise}
|
||||
*/
|
||||
function assertFile(filePath, generator) {
|
||||
return fileExists(filePath).then((exists) => {
|
||||
if (exists)
|
||||
return;
|
||||
return generator();
|
||||
});
|
||||
}
|
||||
/**
|
||||
Pick a file, returns the absolute path if exists, undefined otherwise
|
||||
|
||||
@param {string} rootFolder
|
||||
@param {string} fileName
|
||||
@return {string}
|
||||
*/
|
||||
function pickFile(rootFolder, fileName) {
|
||||
const result = path_1.default.join(rootFolder, fileName);
|
||||
if (fs_1.default.existsSync(result)) {
|
||||
return result;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
Ensure that a directory exists and is empty
|
||||
|
||||
@param {string} folder
|
||||
@return {Promise}
|
||||
*/
|
||||
function ensureFolder(rootFolder) {
|
||||
return rmDir(rootFolder)
|
||||
.fail(() => {
|
||||
return (0, promise_1.default)();
|
||||
})
|
||||
.then(() => {
|
||||
return (0, promise_1.default)((0, mkdirp_1.default)(rootFolder));
|
||||
});
|
||||
}
|
||||
exports.default = {
|
||||
exists: fileExists,
|
||||
existsSync: fs_1.default.existsSync,
|
||||
mkdirp: mkdirp_1.default,
|
||||
readFile: promise_1.default.nfbind(fs_1.default.readFile),
|
||||
writeFile: (filePath, content) => {
|
||||
const d = promise_1.default.defer();
|
||||
fs_1.default.writeFile(filePath, content, (error) => {
|
||||
if (error) {
|
||||
d.reject(error);
|
||||
}
|
||||
else {
|
||||
d.resolve();
|
||||
}
|
||||
});
|
||||
return d.promise;
|
||||
},
|
||||
assertFile: assertFile,
|
||||
pickFile: pickFile,
|
||||
stat: promise_1.default.nfbind(fs_1.default.lstat),
|
||||
statSync: fs_1.default.lstatSync,
|
||||
readdir: promise_1.default.nfbind(fs_1.default.readdir),
|
||||
writeStream: writeStream,
|
||||
readStream: fs_1.default.createReadStream,
|
||||
copy: promise_1.default.nfbind(cp_1.default),
|
||||
copyDir: promise_1.default.nfbind(cpr_1.default),
|
||||
tmpFile: genTmpFile,
|
||||
/**
|
||||
* @deprecated use tmpdir.ts
|
||||
*/
|
||||
tmpDir: genTmpDir,
|
||||
download: download,
|
||||
uniqueFilename: uniqueFilename,
|
||||
ensureFile: ensureFile,
|
||||
ensureFolder: ensureFolder,
|
||||
rmDir: rmDir
|
||||
};
|
3
book/node_modules/honkit/lib/utils/genKey.d.ts
generated
vendored
Normal file
3
book/node_modules/honkit/lib/utils/genKey.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare function generateKey(): string;
|
||||
export default generateKey;
|
||||
//# sourceMappingURL=genKey.d.ts.map
|
1
book/node_modules/honkit/lib/utils/genKey.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/genKey.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"genKey.d.ts","sourceRoot":"","sources":["../../src/utils/genKey.ts"],"names":[],"mappings":"AAMA,iBAAS,WAAW,WAInB;AAED,eAAe,WAAW,CAAC"}
|
13
book/node_modules/honkit/lib/utils/genKey.js
generated
vendored
Normal file
13
book/node_modules/honkit/lib/utils/genKey.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
let lastKey = 0;
|
||||
/*
|
||||
Generate a random key
|
||||
@return {string}
|
||||
*/
|
||||
function generateKey() {
|
||||
lastKey += 1;
|
||||
const str = lastKey.toString(16);
|
||||
return "00000".slice(str.length) + str;
|
||||
}
|
||||
exports.default = generateKey;
|
11
book/node_modules/honkit/lib/utils/git.d.ts
generated
vendored
Normal file
11
book/node_modules/honkit/lib/utils/git.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
declare function Git(): void;
|
||||
declare namespace Git {
|
||||
var isUrl: (giturl: any) => boolean;
|
||||
var parseUrl: (giturl: any) => {
|
||||
host: any;
|
||||
ref: any;
|
||||
filepath: any;
|
||||
};
|
||||
}
|
||||
export default Git;
|
||||
//# sourceMappingURL=git.d.ts.map
|
1
book/node_modules/honkit/lib/utils/git.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/git.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAWA,iBAAS,GAAG,SAGX;kBAHQ,GAAG;;;;;;;;AA4HZ,eAAe,GAAG,CAAC"}
|
116
book/node_modules/honkit/lib/utils/git.js
generated
vendored
Normal file
116
book/node_modules/honkit/lib/utils/git.js
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const crc_1 = __importDefault(require("crc"));
|
||||
const urijs_1 = __importDefault(require("urijs"));
|
||||
const path_2 = __importDefault(require("./path"));
|
||||
const promise_1 = __importDefault(require("./promise"));
|
||||
const command_1 = __importDefault(require("./command"));
|
||||
const fs_1 = __importDefault(require("./fs"));
|
||||
const GIT_PREFIX = "git+";
|
||||
function Git() {
|
||||
this.tmpDir;
|
||||
this.cloned = {};
|
||||
}
|
||||
// Return an unique ID for a combinaison host/ref
|
||||
Git.prototype.repoID = function (host, ref) {
|
||||
return crc_1.default.crc32(`${host}#${ref || ""}`).toString(16);
|
||||
};
|
||||
// Allocate a temporary folder for cloning repos in it
|
||||
Git.prototype.allocateDir = function () {
|
||||
const that = this;
|
||||
if (this.tmpDir)
|
||||
return (0, promise_1.default)();
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
|
||||
return fs_1.default.tmpDir().then((dir) => {
|
||||
that.tmpDir = dir;
|
||||
});
|
||||
};
|
||||
// Clone a git repository if non existant
|
||||
Git.prototype.clone = function (host, ref) {
|
||||
const that = this;
|
||||
return (this.allocateDir()
|
||||
// Return or clone the git repo
|
||||
.then(() => {
|
||||
// Unique ID for repo/ref combinaison
|
||||
const repoId = that.repoID(host, ref);
|
||||
// Absolute path to the folder
|
||||
const repoPath = path_1.default.join(that.tmpDir, repoId);
|
||||
if (that.cloned[repoId])
|
||||
return repoPath;
|
||||
// Clone repo
|
||||
return (command_1.default
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
||||
.exec(`git clone ${host} ${repoPath}`)
|
||||
// Checkout reference if specified
|
||||
.then(() => {
|
||||
that.cloned[repoId] = true;
|
||||
if (!ref)
|
||||
return;
|
||||
return command_1.default.exec(`git checkout ${ref}`, { cwd: repoPath });
|
||||
})
|
||||
.thenResolve(repoPath));
|
||||
}));
|
||||
};
|
||||
// Get file from a git repo
|
||||
Git.prototype.resolve = function (giturl) {
|
||||
// Path to a file in a git repo?
|
||||
if (!Git.isUrl(giturl)) {
|
||||
if (this.resolveRoot(giturl))
|
||||
return (0, promise_1.default)(giturl);
|
||||
return (0, promise_1.default)(null);
|
||||
}
|
||||
if (is_1.default.string(giturl))
|
||||
giturl = Git.parseUrl(giturl);
|
||||
if (!giturl)
|
||||
return (0, promise_1.default)(null);
|
||||
// Clone or get from cache
|
||||
return this.clone(giturl.host, giturl.ref).then((repo) => {
|
||||
return path_1.default.resolve(repo, giturl.filepath);
|
||||
});
|
||||
};
|
||||
// Return root of git repo from a filepath
|
||||
Git.prototype.resolveRoot = function (filepath) {
|
||||
// No git repo cloned, or file is not in a git repository
|
||||
if (!this.tmpDir || !path_2.default.isInRoot(this.tmpDir, filepath))
|
||||
return null;
|
||||
// Extract first directory (is the repo id)
|
||||
const relativeToGit = path_1.default.relative(this.tmpDir, filepath);
|
||||
const repoId = relativeToGit.split(path_1.default.sep)[0];
|
||||
if (!repoId) {
|
||||
return;
|
||||
}
|
||||
// Return an absolute file
|
||||
return path_1.default.resolve(this.tmpDir, repoId);
|
||||
};
|
||||
// Check if an url is a git dependency url
|
||||
Git.isUrl = function (giturl) {
|
||||
return giturl.indexOf(GIT_PREFIX) === 0;
|
||||
};
|
||||
// Parse and extract infos
|
||||
Git.parseUrl = function (giturl) {
|
||||
if (!Git.isUrl(giturl))
|
||||
return null;
|
||||
giturl = giturl.slice(GIT_PREFIX.length);
|
||||
const uri = new urijs_1.default(giturl);
|
||||
const ref = uri.fragment() || null;
|
||||
uri.fragment(null);
|
||||
// Extract file inside the repo (after the .git)
|
||||
const fileParts = uri.path().split(".git");
|
||||
let filepath = fileParts.length > 1 ? fileParts.slice(1).join(".git") : "";
|
||||
if (filepath[0] == "/") {
|
||||
filepath = filepath.slice(1);
|
||||
}
|
||||
// Recreate pathname without the real filename
|
||||
uri.path(`${fileParts[0]}.git`);
|
||||
return {
|
||||
host: uri.toString(),
|
||||
ref: ref,
|
||||
filepath: filepath
|
||||
};
|
||||
};
|
||||
exports.default = Git;
|
6
book/node_modules/honkit/lib/utils/images.d.ts
generated
vendored
Normal file
6
book/node_modules/honkit/lib/utils/images.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
declare function convertInlinePNG(source: any, dest: any): any;
|
||||
declare const _default: {
|
||||
convertInlinePNG: typeof convertInlinePNG;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=images.d.ts.map
|
1
book/node_modules/honkit/lib/utils/images.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/images.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/utils/images.ts"],"names":[],"mappings":"AAIA,iBAAS,gBAAgB,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,OAWrC;;;;AAED,wBAEE"}
|
22
book/node_modules/honkit/lib/utils/images.js
generated
vendored
Normal file
22
book/node_modules/honkit/lib/utils/images.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const promise_1 = __importDefault(require("./promise"));
|
||||
const fs_1 = __importDefault(require("./fs"));
|
||||
// Converts a inline data: to png file
|
||||
function convertInlinePNG(source, dest) {
|
||||
if (!/^data:image\/png/.test(source))
|
||||
return promise_1.default.reject(new Error("Source is not a PNG data-uri"));
|
||||
const base64data = source.split("data:image/png;base64,")[1];
|
||||
const buf = Buffer.from(base64data, "base64");
|
||||
return fs_1.default.writeFile(dest, buf).then(() => {
|
||||
if (fs_1.default.existsSync(dest))
|
||||
return;
|
||||
throw new Error(`Error converting ${source} into ${dest}`);
|
||||
});
|
||||
}
|
||||
exports.default = {
|
||||
convertInlinePNG: convertInlinePNG
|
||||
};
|
62
book/node_modules/honkit/lib/utils/location.d.ts
generated
vendored
Normal file
62
book/node_modules/honkit/lib/utils/location.d.ts
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
declare function isExternal(href: any): boolean;
|
||||
declare function isDataURI(href: any): boolean;
|
||||
declare function isRelative(href: any): boolean;
|
||||
declare function isAnchor(href: any): boolean;
|
||||
declare function normalize(s: any): string;
|
||||
/**
|
||||
* Flatten a path, it removes the leading "/"
|
||||
*
|
||||
* @param {string} href
|
||||
* @return {string}
|
||||
*/
|
||||
declare function flatten(href: any): any;
|
||||
/**
|
||||
* Convert a relative path to absolute
|
||||
*
|
||||
* @param {string} _href
|
||||
* @param {string} dir: directory parent of the file currently in rendering process
|
||||
* @param {string} outdir: directory parent from the html output
|
||||
* @return {string}
|
||||
*/
|
||||
declare function toAbsolute(_href: any, dir: any, outdir: any): any;
|
||||
/**
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {string} dir: current directory
|
||||
* @param {string} file: absolute path of file
|
||||
* @return {string}
|
||||
*/
|
||||
declare function relative(dir: any, file: any): string;
|
||||
/**
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/test.md', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {string} baseFile: current file
|
||||
* @param {string} file: absolute path of file
|
||||
* @return {string}
|
||||
*/
|
||||
declare function relativeForFile(baseFile: any, file: any): string;
|
||||
/**
|
||||
* Compare two paths, return true if they are identical
|
||||
* ('README.md', './README.md') -> true
|
||||
*
|
||||
* @param {string} p1: first path
|
||||
* @param {string} p2: second path
|
||||
* @return {boolean}
|
||||
*/
|
||||
declare function areIdenticalPaths(p1: any, p2: any): boolean;
|
||||
declare const _default: {
|
||||
areIdenticalPaths: typeof areIdenticalPaths;
|
||||
isDataURI: typeof isDataURI;
|
||||
isExternal: typeof isExternal;
|
||||
isRelative: typeof isRelative;
|
||||
isAnchor: typeof isAnchor;
|
||||
normalize: typeof normalize;
|
||||
toAbsolute: typeof toAbsolute;
|
||||
relative: typeof relative;
|
||||
relativeForFile: typeof relativeForFile;
|
||||
flatten: typeof flatten;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=location.d.ts.map
|
1
book/node_modules/honkit/lib/utils/location.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/location.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/utils/location.ts"],"names":[],"mappings":"AAIA,iBAAS,UAAU,CAAC,IAAI,KAAA,WAMvB;AAGD,iBAAS,SAAS,CAAC,IAAI,KAAA,WAMtB;AAGD,iBAAS,UAAU,CAAC,IAAI,KAAA,WAEvB;AAGD,iBAAS,QAAQ,CAAC,IAAI,KAAA,WAOrB;AAGD,iBAAS,SAAS,CAAC,CAAC,KAAA,UAEnB;AAED;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,IAAI,KAAA,OAOpB;AAED;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,KAAK,KAAA,EAAE,GAAG,KAAA,EAAE,MAAM,KAAA,OAwBrC;AAED;;;;;;;GAOG;AACH,iBAAS,QAAQ,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,UAG1B;AAED;;;;;;;GAOG;AACH,iBAAS,eAAe,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA,UAEtC;AAED;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAC,EAAE,KAAA,EAAE,EAAE,KAAA,WAEhC;;;;;;;;;;;;;AAED,wBAWE"}
|
129
book/node_modules/honkit/lib/utils/location.js
generated
vendored
Normal file
129
book/node_modules/honkit/lib/utils/location.js
generated
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const url_1 = __importDefault(require("url"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
// Is the url an external url
|
||||
function isExternal(href) {
|
||||
try {
|
||||
return Boolean(url_1.default.parse(href).protocol) && !isDataURI(href);
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Is the url an iniline data-uri
|
||||
function isDataURI(href) {
|
||||
try {
|
||||
return Boolean(url_1.default.parse(href).protocol) && url_1.default.parse(href).protocol === "data:";
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Inverse of isExternal
|
||||
function isRelative(href) {
|
||||
return !isExternal(href);
|
||||
}
|
||||
// Return true if the link is an achor
|
||||
function isAnchor(href) {
|
||||
try {
|
||||
const parsed = url_1.default.parse(href);
|
||||
return !!(!parsed.protocol && !parsed.path && parsed.hash);
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Normalize a path to be a link
|
||||
function normalize(s) {
|
||||
return path_1.default.normalize(s).replace(/\\/g, "/");
|
||||
}
|
||||
/**
|
||||
* Flatten a path, it removes the leading "/"
|
||||
*
|
||||
* @param {string} href
|
||||
* @return {string}
|
||||
*/
|
||||
function flatten(href) {
|
||||
href = normalize(href);
|
||||
if (href[0] == "/") {
|
||||
href = normalize(href.slice(1));
|
||||
}
|
||||
return href;
|
||||
}
|
||||
/**
|
||||
* Convert a relative path to absolute
|
||||
*
|
||||
* @param {string} _href
|
||||
* @param {string} dir: directory parent of the file currently in rendering process
|
||||
* @param {string} outdir: directory parent from the html output
|
||||
* @return {string}
|
||||
*/
|
||||
function toAbsolute(_href, dir, outdir) {
|
||||
if (isExternal(_href) || isDataURI(_href)) {
|
||||
return _href;
|
||||
}
|
||||
outdir = outdir == undefined ? dir : outdir;
|
||||
_href = normalize(_href);
|
||||
dir = normalize(dir);
|
||||
outdir = normalize(outdir);
|
||||
// Path "_href" inside the base folder
|
||||
let hrefInRoot = normalize(path_1.default.join(dir, _href));
|
||||
if (_href[0] == "/") {
|
||||
hrefInRoot = normalize(_href.slice(1));
|
||||
}
|
||||
// Make it relative to output
|
||||
_href = path_1.default.relative(outdir, hrefInRoot);
|
||||
// Normalize windows paths
|
||||
_href = normalize(_href);
|
||||
return _href;
|
||||
}
|
||||
/**
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {string} dir: current directory
|
||||
* @param {string} file: absolute path of file
|
||||
* @return {string}
|
||||
*/
|
||||
function relative(dir, file) {
|
||||
const isDirectory = file.slice(-1) === "/";
|
||||
return normalize(path_1.default.relative(dir, file)) + (isDirectory ? "/" : "");
|
||||
}
|
||||
/**
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/test.md', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {string} baseFile: current file
|
||||
* @param {string} file: absolute path of file
|
||||
* @return {string}
|
||||
*/
|
||||
function relativeForFile(baseFile, file) {
|
||||
return relative(path_1.default.dirname(baseFile), file);
|
||||
}
|
||||
/**
|
||||
* Compare two paths, return true if they are identical
|
||||
* ('README.md', './README.md') -> true
|
||||
*
|
||||
* @param {string} p1: first path
|
||||
* @param {string} p2: second path
|
||||
* @return {boolean}
|
||||
*/
|
||||
function areIdenticalPaths(p1, p2) {
|
||||
return normalize(p1) === normalize(p2);
|
||||
}
|
||||
exports.default = {
|
||||
areIdenticalPaths: areIdenticalPaths,
|
||||
isDataURI: isDataURI,
|
||||
isExternal: isExternal,
|
||||
isRelative: isRelative,
|
||||
isAnchor: isAnchor,
|
||||
normalize: normalize,
|
||||
toAbsolute: toAbsolute,
|
||||
relative: relative,
|
||||
relativeForFile: relativeForFile,
|
||||
flatten: flatten
|
||||
};
|
7
book/node_modules/honkit/lib/utils/logger.d.ts
generated
vendored
Normal file
7
book/node_modules/honkit/lib/utils/logger.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import Immutable from "immutable";
|
||||
declare function Logger(write: any, logLevel: any): any;
|
||||
declare namespace Logger {
|
||||
var LEVELS: Immutable.Map<string, number>;
|
||||
}
|
||||
export default Logger;
|
||||
//# sourceMappingURL=logger.d.ts.map
|
1
book/node_modules/honkit/lib/utils/logger.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/logger.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,MAAM,WAAW,CAAC;AAiBlC,iBAAS,MAAM,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAA,OA4B9B;kBA5BQ,MAAM;;;AA4Jf,eAAe,MAAM,CAAC"}
|
158
book/node_modules/honkit/lib/utils/logger.js
generated
vendored
Normal file
158
book/node_modules/honkit/lib/utils/logger.js
generated
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const util_1 = __importDefault(require("util"));
|
||||
const bash_color_1 = __importDefault(require("bash-color"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const LEVELS = immutable_1.default.Map({
|
||||
DEBUG: 0,
|
||||
INFO: 1,
|
||||
WARN: 2,
|
||||
ERROR: 3,
|
||||
DISABLED: 10
|
||||
});
|
||||
const COLORS = immutable_1.default.Map({
|
||||
DEBUG: bash_color_1.default.purple,
|
||||
INFO: bash_color_1.default.cyan,
|
||||
WARN: bash_color_1.default.yellow,
|
||||
ERROR: bash_color_1.default.red
|
||||
});
|
||||
function Logger(write, logLevel) {
|
||||
// @ts-expect-error ts-migrate(2350) FIXME: Only a void function can be called with the 'new' ... Remove this comment to see the full error message
|
||||
if (!(this instanceof Logger))
|
||||
return new Logger(write, logLevel);
|
||||
this._write =
|
||||
write ||
|
||||
function (msg) {
|
||||
if (process.stdout) {
|
||||
process.stdout.write(msg);
|
||||
}
|
||||
};
|
||||
this.lastChar = "\n";
|
||||
this.setLevel(logLevel || "info");
|
||||
// Create easy-to-use method like "logger.debug.ln('....')"
|
||||
LEVELS.forEach(function (level, levelKey) {
|
||||
if (levelKey === "DISABLED") {
|
||||
return;
|
||||
}
|
||||
levelKey = levelKey.toLowerCase();
|
||||
this[levelKey] = this.log.bind(this, level);
|
||||
this[levelKey].ln = this.logLn.bind(this, level);
|
||||
this[levelKey].ok = this.ok.bind(this, level);
|
||||
this[levelKey].fail = this.fail.bind(this, level);
|
||||
this[levelKey].promise = this.promise.bind(this, level);
|
||||
}, this);
|
||||
}
|
||||
/**
|
||||
Change minimum level
|
||||
|
||||
@param {string} logLevel
|
||||
*/
|
||||
Logger.prototype.setLevel = function (logLevel) {
|
||||
if (is_1.default.string(logLevel)) {
|
||||
logLevel = logLevel.toUpperCase();
|
||||
logLevel = LEVELS.get(logLevel);
|
||||
}
|
||||
this.logLevel = logLevel;
|
||||
};
|
||||
/**
|
||||
Return minimum logging level
|
||||
|
||||
@return {number}
|
||||
*/
|
||||
Logger.prototype.getLevel = function (logLevel) {
|
||||
return this.logLevel;
|
||||
};
|
||||
/**
|
||||
Print a simple string
|
||||
|
||||
@param {string}
|
||||
*/
|
||||
Logger.prototype.write = function (msg) {
|
||||
msg = msg.toString();
|
||||
this.lastChar = msg[msg.length - 1];
|
||||
return this._write(msg);
|
||||
};
|
||||
/**
|
||||
Format a string using the first argument as a printf-like format.
|
||||
*/
|
||||
Logger.prototype.format = function () {
|
||||
return util_1.default.format.apply(util_1.default, arguments);
|
||||
};
|
||||
/**
|
||||
Print a line
|
||||
|
||||
@param {string}
|
||||
*/
|
||||
Logger.prototype.writeLn = function (msg) {
|
||||
return this.write(`${msg || ""}\n`);
|
||||
};
|
||||
/**
|
||||
Log/Print a message if level is allowed
|
||||
|
||||
@param {number} level
|
||||
*/
|
||||
Logger.prototype.log = function (level) {
|
||||
if (level < this.logLevel)
|
||||
return;
|
||||
const levelKey = LEVELS.findKey((v) => {
|
||||
return v === level;
|
||||
});
|
||||
const args = Array.prototype.slice.apply(arguments, [1]);
|
||||
let msg = this.format.apply(this, args);
|
||||
if (this.lastChar == "\n") {
|
||||
msg = `${COLORS.get(levelKey)(`${levelKey.toLowerCase()}:`)} ${msg}`;
|
||||
}
|
||||
return this.write(msg);
|
||||
};
|
||||
/**
|
||||
Log/Print a line if level is allowed
|
||||
*/
|
||||
Logger.prototype.logLn = function () {
|
||||
if (this.lastChar != "\n")
|
||||
this.write("\n");
|
||||
const args = Array.prototype.slice.apply(arguments);
|
||||
args.push("\n");
|
||||
return this.log.apply(this, args);
|
||||
};
|
||||
/**
|
||||
Log a confirmation [OK]
|
||||
*/
|
||||
Logger.prototype.ok = function (level) {
|
||||
const args = Array.prototype.slice.apply(arguments, [1]);
|
||||
const msg = this.format.apply(this, args);
|
||||
if (arguments.length > 1) {
|
||||
this.logLn(level, bash_color_1.default.green(">> ") + msg.trim().replace(/\n/g, bash_color_1.default.green("\n>> ")));
|
||||
}
|
||||
else {
|
||||
this.log(level, bash_color_1.default.green("OK"), "\n");
|
||||
}
|
||||
};
|
||||
/**
|
||||
Log a "FAIL"
|
||||
*/
|
||||
Logger.prototype.fail = function (level) {
|
||||
return this.log(level, `${bash_color_1.default.red("ERROR")}\n`);
|
||||
};
|
||||
/**
|
||||
Log state of a promise
|
||||
|
||||
@param {number} level
|
||||
@param {Promise}
|
||||
@return {Promise}
|
||||
*/
|
||||
Logger.prototype.promise = function (level, p) {
|
||||
const that = this;
|
||||
return p.then((st) => {
|
||||
that.ok(level);
|
||||
return st;
|
||||
}, (err) => {
|
||||
that.fail(level);
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
Logger.LEVELS = LEVELS;
|
||||
exports.default = Logger;
|
9
book/node_modules/honkit/lib/utils/mergeDefaults.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/utils/mergeDefaults.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Merge
|
||||
* @param {Object|Map} obj
|
||||
* @param {Object|Map} src
|
||||
* @return {Object}
|
||||
*/
|
||||
declare function mergeDefaults(obj: any, src: any): any;
|
||||
export default mergeDefaults;
|
||||
//# sourceMappingURL=mergeDefaults.d.ts.map
|
1
book/node_modules/honkit/lib/utils/mergeDefaults.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/mergeDefaults.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeDefaults.d.ts","sourceRoot":"","sources":["../../src/utils/mergeDefaults.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,iBAAS,aAAa,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,OAK9B;AAED,eAAe,aAAa,CAAC"}
|
18
book/node_modules/honkit/lib/utils/mergeDefaults.js
generated
vendored
Normal file
18
book/node_modules/honkit/lib/utils/mergeDefaults.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
/**
|
||||
* Merge
|
||||
* @param {Object|Map} obj
|
||||
* @param {Object|Map} src
|
||||
* @return {Object}
|
||||
*/
|
||||
function mergeDefaults(obj, src) {
|
||||
const objValue = immutable_1.default.fromJS(obj);
|
||||
const srcValue = immutable_1.default.fromJS(src);
|
||||
return srcValue.mergeDeep(objValue).toJS();
|
||||
}
|
||||
exports.default = mergeDefaults;
|
14
book/node_modules/honkit/lib/utils/path.d.ts
generated
vendored
Normal file
14
book/node_modules/honkit/lib/utils/path.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
declare function normalizePath(filename: any): string;
|
||||
declare function isInRoot(root: any, filename: any): boolean;
|
||||
declare function resolveInRoot(root: any): string;
|
||||
declare function setExtension(filename: any, ext: any): string;
|
||||
declare function isPureRelative(filename: any): boolean;
|
||||
declare const _default: {
|
||||
isInRoot: typeof isInRoot;
|
||||
resolveInRoot: typeof resolveInRoot;
|
||||
normalize: typeof normalizePath;
|
||||
setExtension: typeof setExtension;
|
||||
isPureRelative: typeof isPureRelative;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=path.d.ts.map
|
1
book/node_modules/honkit/lib/utils/path.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/path.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAIA,iBAAS,aAAa,CAAC,QAAQ,KAAA,UAE9B;AAGD,iBAAS,QAAQ,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA,WAY/B;AAID,iBAAS,aAAa,CAAC,IAAI,KAAA,UAkB1B;AAGD,iBAAS,YAAY,CAAC,QAAQ,KAAA,EAAE,GAAG,KAAA,UAElC;AAQD,iBAAS,cAAc,CAAC,QAAQ,KAAA,WAE/B;;;;;;;;AAED,wBAME"}
|
62
book/node_modules/honkit/lib/utils/path.js
generated
vendored
Normal file
62
book/node_modules/honkit/lib/utils/path.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const error_1 = __importDefault(require("./error"));
|
||||
// Normalize a filename
|
||||
function normalizePath(filename) {
|
||||
return path_1.default.normalize(filename);
|
||||
}
|
||||
// Return true if file path is inside a folder
|
||||
function isInRoot(root, filename) {
|
||||
root = path_1.default.normalize(root);
|
||||
filename = path_1.default.normalize(filename);
|
||||
if (root === ".") {
|
||||
return true;
|
||||
}
|
||||
if (root[root.length - 1] != path_1.default.sep) {
|
||||
root = root + path_1.default.sep;
|
||||
}
|
||||
return filename.substr(0, root.length) === root;
|
||||
}
|
||||
// Resolve paths in a specific folder
|
||||
// Throw error if file is outside this folder
|
||||
function resolveInRoot(root) {
|
||||
const args = Array.prototype.slice.call(arguments, 1);
|
||||
const input = args.reduce((current, p) => {
|
||||
// Handle path relative to book root ("/README.md")
|
||||
if (p[0] == "/" || p[0] == "\\")
|
||||
return p.slice(1);
|
||||
return current ? path_1.default.join(current, p) : path_1.default.normalize(p);
|
||||
}, "");
|
||||
const result = path_1.default.resolve(root, input);
|
||||
if (!isInRoot(root, result)) {
|
||||
throw new error_1.default.FileOutOfScopeError({
|
||||
filename: result,
|
||||
root: root
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Chnage extension of a file
|
||||
function setExtension(filename, ext) {
|
||||
return path_1.default.join(path_1.default.dirname(filename), path_1.default.basename(filename, path_1.default.extname(filename)) + ext);
|
||||
}
|
||||
/*
|
||||
Return true if a filename is relative.
|
||||
|
||||
@param {string}
|
||||
@return {boolean}
|
||||
*/
|
||||
function isPureRelative(filename) {
|
||||
return filename.indexOf("./") === 0 || filename.indexOf("../") === 0;
|
||||
}
|
||||
exports.default = {
|
||||
isInRoot: isInRoot,
|
||||
resolveInRoot: resolveInRoot,
|
||||
normalize: normalizePath,
|
||||
setExtension: setExtension,
|
||||
isPureRelative: isPureRelative
|
||||
};
|
52
book/node_modules/honkit/lib/utils/promise.d.ts
generated
vendored
Normal file
52
book/node_modules/honkit/lib/utils/promise.d.ts
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import Q from "q";
|
||||
/**
|
||||
* Reduce an array to a promise
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)} iter
|
||||
* @param {Array|List} base
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
declare function reduce(arr: any, iter: any, base: any): any;
|
||||
/**
|
||||
* Iterate over an array using an async iter
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
declare function forEach(arr: any, iter: any): any;
|
||||
/**
|
||||
* Transform an array
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
declare function serie(arr: any, iter: any, base: any): any;
|
||||
/**
|
||||
* Iter over an array and return first result (not null)
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
declare function some(arr: any, iter: any): any;
|
||||
/**
|
||||
* Map an array or map
|
||||
*
|
||||
* @param {Array|List|Map|OrderedMap} arr
|
||||
* @param {Function(element, key)}
|
||||
* @return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
declare function map(arr: any, iter: any): any;
|
||||
/**
|
||||
* Wrap a function in a promise
|
||||
*
|
||||
* @param {Function} func
|
||||
* @return {Funciton}
|
||||
*/
|
||||
declare function wrap(func: Function): () => any;
|
||||
export default Q;
|
||||
export { forEach, reduce, map, serie, some, wrap };
|
||||
//# sourceMappingURL=promise.d.ts.map
|
1
book/node_modules/honkit/lib/utils/promise.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/promise.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/utils/promise.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,GAAG,CAAC;AAQlB;;;;;;;GAOG;AACH,iBAAS,MAAM,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,EAAE,IAAI,KAAA,OAQ9B;AAED;;;;;;GAMG;AACH,iBAAS,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,OAKzB;AAED;;;;;;GAMG;AACH,iBAAS,KAAK,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,EAAE,IAAI,KAAA,OAW7B;AAED;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,OAUtB;AAsBD;;;;;;GAMG;AACH,iBAAS,GAAG,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA,OAmBrB;AAED;;;;;GAKG;AACH,iBAAS,IAAI,CAAC,IAAI,EAAE,QAAQ,aAQ3B;AAQD,eAAe,CAAC,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC"}
|
141
book/node_modules/honkit/lib/utils/promise.js
generated
vendored
Normal file
141
book/node_modules/honkit/lib/utils/promise.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.forEach = forEach;
|
||||
exports.reduce = reduce;
|
||||
exports.map = map;
|
||||
exports.serie = serie;
|
||||
exports.some = some;
|
||||
exports.wrap = wrap;
|
||||
const q_1 = __importDefault(require("q"));
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
// Debugging for long stack traces
|
||||
if (process.env.DEBUG || process.env.CI) {
|
||||
q_1.default.longStackSupport = true;
|
||||
}
|
||||
/**
|
||||
* Reduce an array to a promise
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)} iter
|
||||
* @param {Array|List} base
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function reduce(arr, iter, base) {
|
||||
arr = immutable_1.default.Iterable.isIterable(arr) ? arr : immutable_1.default.List(arr);
|
||||
return arr.reduce((prev, elem, key) => {
|
||||
return prev.then((val) => {
|
||||
return iter(val, elem, key);
|
||||
});
|
||||
}, (0, q_1.default)(base));
|
||||
}
|
||||
/**
|
||||
* Iterate over an array using an async iter
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function forEach(arr, iter) {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
||||
return reduce(arr, (val, el, key) => {
|
||||
return iter(el, key);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Transform an array
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function serie(arr, iter, base) {
|
||||
return reduce(arr, (before, item, key) => {
|
||||
return (0, q_1.default)(iter(item, key)).then((r) => {
|
||||
before.push(r);
|
||||
return before;
|
||||
});
|
||||
}, []);
|
||||
}
|
||||
/**
|
||||
* Iter over an array and return first result (not null)
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function some(arr, iter) {
|
||||
arr = immutable_1.default.List(arr);
|
||||
return arr.reduce((prev, elem, i) => {
|
||||
return prev.then((val) => {
|
||||
if (val)
|
||||
return val;
|
||||
return iter(elem, i);
|
||||
});
|
||||
}, (0, q_1.default)());
|
||||
}
|
||||
/**
|
||||
* Map an array using an async (promised) iterator
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<List>}
|
||||
*/
|
||||
function mapAsList(arr, iter) {
|
||||
return reduce(arr, (prev, entry, i) => {
|
||||
return (0, q_1.default)(iter(entry, i)).then((out) => {
|
||||
prev.push(out);
|
||||
return prev;
|
||||
});
|
||||
}, []);
|
||||
}
|
||||
/**
|
||||
* Map an array or map
|
||||
*
|
||||
* @param {Array|List|Map|OrderedMap} arr
|
||||
* @param {Function(element, key)}
|
||||
* @return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
function map(arr, iter) {
|
||||
if (immutable_1.default.Map.isMap(arr)) {
|
||||
let type = "Map";
|
||||
if (immutable_1.default.OrderedMap.isOrderedMap(arr)) {
|
||||
type = "OrderedMap";
|
||||
}
|
||||
return mapAsList(arr, (value, key) => {
|
||||
return (0, q_1.default)(iter(value, key)).then((result) => {
|
||||
return [key, result];
|
||||
});
|
||||
}).then((result) => {
|
||||
return immutable_1.default[type](result);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return mapAsList(arr, iter).then((result) => {
|
||||
return immutable_1.default.List(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Wrap a function in a promise
|
||||
*
|
||||
* @param {Function} func
|
||||
* @return {Funciton}
|
||||
*/
|
||||
function wrap(func) {
|
||||
return function () {
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
return (0, q_1.default)().then(() => {
|
||||
return func.apply(null, args);
|
||||
});
|
||||
};
|
||||
}
|
||||
q_1.default.forEach = forEach;
|
||||
q_1.default.reduce = reduce;
|
||||
q_1.default.map = map;
|
||||
q_1.default.serie = serie;
|
||||
q_1.default.some = some;
|
||||
q_1.default.wrap = wrap;
|
||||
exports.default = q_1.default;
|
9
book/node_modules/honkit/lib/utils/reducedObject.d.ts
generated
vendored
Normal file
9
book/node_modules/honkit/lib/utils/reducedObject.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Reduce the difference between a map and its default version
|
||||
* @param {Map} defaultVersion
|
||||
* @param {Map} currentVersion
|
||||
* @return {Map} The properties of currentVersion that differs from defaultVersion
|
||||
*/
|
||||
declare function reducedObject(defaultVersion: any, currentVersion: any): any;
|
||||
export default reducedObject;
|
||||
//# sourceMappingURL=reducedObject.d.ts.map
|
1
book/node_modules/honkit/lib/utils/reducedObject.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/reducedObject.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reducedObject.d.ts","sourceRoot":"","sources":["../../src/utils/reducedObject.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,iBAAS,aAAa,CAAC,cAAc,KAAA,EAAE,cAAc,KAAA,OAsBpD;AAED,eAAe,aAAa,CAAC"}
|
31
book/node_modules/honkit/lib/utils/reducedObject.js
generated
vendored
Normal file
31
book/node_modules/honkit/lib/utils/reducedObject.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
/**
|
||||
* Reduce the difference between a map and its default version
|
||||
* @param {Map} defaultVersion
|
||||
* @param {Map} currentVersion
|
||||
* @return {Map} The properties of currentVersion that differs from defaultVersion
|
||||
*/
|
||||
function reducedObject(defaultVersion, currentVersion) {
|
||||
if (defaultVersion === undefined) {
|
||||
return currentVersion;
|
||||
}
|
||||
return currentVersion.reduce((result, value, key) => {
|
||||
const defaultValue = defaultVersion.get(key);
|
||||
if (immutable_1.default.Map.isMap(value)) {
|
||||
const diffs = reducedObject(defaultValue, value);
|
||||
if (diffs.size > 0) {
|
||||
return result.set(key, diffs);
|
||||
}
|
||||
}
|
||||
if (immutable_1.default.is(defaultValue, value)) {
|
||||
return result;
|
||||
}
|
||||
return result.set(key, value);
|
||||
}, immutable_1.default.Map());
|
||||
}
|
||||
exports.default = reducedObject;
|
20
book/node_modules/honkit/lib/utils/timing.d.ts
generated
vendored
Normal file
20
book/node_modules/honkit/lib/utils/timing.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
Mesure an operation
|
||||
|
||||
@parqm {string} type
|
||||
@param {Promise} p
|
||||
@return {Promise}
|
||||
*/
|
||||
declare function measure(type: any, p: any): any;
|
||||
/**
|
||||
Dump all timers to a logger
|
||||
|
||||
@param {Logger} logger
|
||||
*/
|
||||
declare function dump(logger: any): void;
|
||||
declare const _default: {
|
||||
measure: typeof measure;
|
||||
dump: typeof dump;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=timing.d.ts.map
|
1
book/node_modules/honkit/lib/utils/timing.d.ts.map
generated
vendored
Normal file
1
book/node_modules/honkit/lib/utils/timing.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/utils/timing.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,iBAAS,OAAO,CAAC,IAAI,KAAA,EAAE,CAAC,KAAA,OA0BvB;AAgBD;;;;GAIG;AACH,iBAAS,IAAI,CAAC,MAAM,KAAA,QAqCnB;;;;;AAED,wBAGE"}
|
90
book/node_modules/honkit/lib/utils/timing.js
generated
vendored
Normal file
90
book/node_modules/honkit/lib/utils/timing.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const immutable_1 = __importDefault(require("immutable"));
|
||||
const is_1 = __importDefault(require("is"));
|
||||
const timers = {};
|
||||
const startDate = Date.now();
|
||||
/**
|
||||
Mesure an operation
|
||||
|
||||
@parqm {string} type
|
||||
@param {Promise} p
|
||||
@return {Promise}
|
||||
*/
|
||||
function measure(type, p) {
|
||||
timers[type] = timers[type] || {
|
||||
type: type,
|
||||
count: 0,
|
||||
total: 0,
|
||||
min: undefined,
|
||||
max: 0
|
||||
};
|
||||
const start = Date.now();
|
||||
return p.fin(() => {
|
||||
const end = Date.now();
|
||||
const duration = end - start;
|
||||
timers[type].count++;
|
||||
timers[type].total += duration;
|
||||
if (is_1.default.undefined(timers[type].min)) {
|
||||
timers[type].min = duration;
|
||||
}
|
||||
else {
|
||||
timers[type].min = Math.min(timers[type].min, duration);
|
||||
}
|
||||
timers[type].max = Math.max(timers[type].max, duration);
|
||||
});
|
||||
}
|
||||
/**
|
||||
Return a milliseconds number as a second string
|
||||
|
||||
@param {number} ms
|
||||
@return {string}
|
||||
*/
|
||||
function time(ms) {
|
||||
if (ms < 1000) {
|
||||
return `${ms.toFixed(0)}ms`;
|
||||
}
|
||||
return `${(ms / 1000).toFixed(2)}s`;
|
||||
}
|
||||
/**
|
||||
Dump all timers to a logger
|
||||
|
||||
@param {Logger} logger
|
||||
*/
|
||||
function dump(logger) {
|
||||
const prefix = " > ";
|
||||
let measured = 0;
|
||||
const totalDuration = Date.now() - startDate;
|
||||
// Enable debug logging
|
||||
const logLevel = logger.getLevel();
|
||||
logger.setLevel("debug");
|
||||
immutable_1.default.Map(timers)
|
||||
.valueSeq()
|
||||
.sortBy((timer) => {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'total' does not exist on type 'unknown'.
|
||||
measured += timer.total;
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'total' does not exist on type 'unknown'.
|
||||
return timer.total;
|
||||
})
|
||||
.forEach((timer) => {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'total' does not exist on type 'unknown'.
|
||||
const percent = (timer.total * 100) / totalDuration;
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'type' does not exist on type 'unknown'.
|
||||
logger.debug.ln(`${percent.toFixed(1)}% of time spent in "${timer.type}" (${timer.count} times) :`);
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'total' does not exist on type 'unknown'.
|
||||
logger.debug.ln(`${prefix}Total: ${time(timer.total)} | Average: ${time(timer.total / timer.count)}`);
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'min' does not exist on type 'unknown'.
|
||||
logger.debug.ln(`${prefix}Min: ${time(timer.min)} | Max: ${time(timer.max)}`);
|
||||
logger.debug.ln("---------------------------");
|
||||
});
|
||||
logger.debug.ln(`${time(totalDuration - measured)} spent in non-mesured sections`);
|
||||
// Rollback to previous level
|
||||
logger.setLevel(logLevel);
|
||||
}
|
||||
exports.default = {
|
||||
measure: measure,
|
||||
dump: dump
|
||||
};
|
Reference in New Issue
Block a user