@amagaki/amagaki 3.1.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -62
- package/dist/src/ansi.d.ts +10 -0
- package/dist/src/ansi.js +17 -0
- package/dist/src/builder.d.ts +4 -4
- package/dist/src/builder.js +51 -43
- package/dist/src/cli.js +24 -10
- package/dist/src/collection.js +27 -16
- package/dist/src/commands/global.js +1 -2
- package/dist/src/commands/serve.js +5 -5
- package/dist/src/concurrency.d.ts +9 -0
- package/dist/src/concurrency.js +27 -0
- package/dist/src/deepWalk.d.ts +8 -0
- package/dist/src/deepWalk.js +30 -0
- package/dist/src/document.d.ts +2 -3
- package/dist/src/document.js +29 -18
- package/dist/src/gitData.js +23 -10
- package/dist/src/index.js +5 -1
- package/dist/src/locale.d.ts +2 -2
- package/dist/src/plugins/builder.d.ts +2 -2
- package/dist/src/plugins/index.js +5 -1
- package/dist/src/plugins/nunjucks.js +23 -9
- package/dist/src/plugins/server.d.ts +1 -1
- package/dist/src/plugins/yaml.js +22 -8
- package/dist/src/pod.d.ts +38 -1
- package/dist/src/pod.js +135 -21
- package/dist/src/profile.d.ts +1 -1
- package/dist/src/profile.js +3 -3
- package/dist/src/progress.d.ts +19 -0
- package/dist/src/progress.js +64 -0
- package/dist/src/router.d.ts +1 -1
- package/dist/src/router.js +25 -11
- package/dist/src/server.d.ts +5 -3
- package/dist/src/server.js +33 -12
- package/dist/src/table.d.ts +16 -0
- package/dist/src/table.js +62 -0
- package/dist/src/url.js +22 -8
- package/dist/src/utils.d.ts +5 -6
- package/dist/src/utils.js +31 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -61
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ProgressBarPayload {
|
|
2
|
+
customDuration?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Minimal TTY progress bar replacing `cli-progress`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ProgressBar {
|
|
8
|
+
private readonly isTTY;
|
|
9
|
+
private readonly label;
|
|
10
|
+
private active;
|
|
11
|
+
private total;
|
|
12
|
+
private value;
|
|
13
|
+
constructor(label: string);
|
|
14
|
+
start(total: number, startValue?: number, payload?: ProgressBarPayload): void;
|
|
15
|
+
increment(deltaOrPayload?: number | ProgressBarPayload, payload?: ProgressBarPayload): void;
|
|
16
|
+
update(value: number, payload?: ProgressBarPayload): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
private render;
|
|
19
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProgressBar = void 0;
|
|
7
|
+
const ansi_1 = __importDefault(require("./ansi"));
|
|
8
|
+
/**
|
|
9
|
+
* Minimal TTY progress bar replacing `cli-progress`.
|
|
10
|
+
*/
|
|
11
|
+
class ProgressBar {
|
|
12
|
+
constructor(label) {
|
|
13
|
+
this.active = false;
|
|
14
|
+
this.total = 0;
|
|
15
|
+
this.value = 0;
|
|
16
|
+
this.label = label;
|
|
17
|
+
this.isTTY = Boolean(process.env.TERM !== 'dumb' && process.stdout.isTTY);
|
|
18
|
+
}
|
|
19
|
+
start(total, startValue = 0, payload) {
|
|
20
|
+
this.total = total;
|
|
21
|
+
this.value = startValue;
|
|
22
|
+
this.active = true;
|
|
23
|
+
this.render(payload);
|
|
24
|
+
}
|
|
25
|
+
increment(deltaOrPayload, payload) {
|
|
26
|
+
if (typeof deltaOrPayload === 'number') {
|
|
27
|
+
this.value += deltaOrPayload;
|
|
28
|
+
this.render(payload);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.value += 1;
|
|
32
|
+
this.render(deltaOrPayload);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
update(value, payload) {
|
|
36
|
+
this.value = value;
|
|
37
|
+
this.render(payload);
|
|
38
|
+
}
|
|
39
|
+
stop() {
|
|
40
|
+
if (!this.active) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.active = false;
|
|
44
|
+
if (this.isTTY) {
|
|
45
|
+
process.stdout.write('\n');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
render(payload) {
|
|
49
|
+
if (!this.active || !this.isTTY) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const width = 32;
|
|
53
|
+
const ratio = this.total > 0 ? Math.min(1, Math.max(0, this.value / this.total)) : 1;
|
|
54
|
+
const filled = Math.round(ratio * width);
|
|
55
|
+
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(width - filled);
|
|
56
|
+
const duration = payload?.customDuration
|
|
57
|
+
? ` Total: ${payload.customDuration}`
|
|
58
|
+
: '';
|
|
59
|
+
const line = ansi_1.default.green(`${this.label} (${this.value}/${this.total}): `) +
|
|
60
|
+
`${bar}${duration}`;
|
|
61
|
+
process.stdout.write(`\r${line}\x1b[K`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ProgressBar = ProgressBar;
|
package/dist/src/router.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface RouteOptions {
|
|
|
21
21
|
/** Fields to store on the route. */
|
|
22
22
|
fields?: Record<string, any>;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type RouteBuilder = (provider: RouteProvider) => Promise<void>;
|
|
25
25
|
export declare class Router {
|
|
26
26
|
pod: Pod;
|
|
27
27
|
providers: Record<string, RouteProvider[]>;
|
package/dist/src/router.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
36
|
exports.StaticRoute = exports.DocumentRoute = exports.Route = exports.StaticDirectoryRouteProvider = exports.CollectionRouteProvider = exports.DocumentRouteProvider = exports.RouteProvider = exports.Router = void 0;
|
|
23
37
|
const fsPath = __importStar(require("path"));
|
|
@@ -197,11 +211,11 @@ class CollectionRouteProvider extends RouteProvider {
|
|
|
197
211
|
if (!document_1.Document.isServable(doc.podPath)) {
|
|
198
212
|
return;
|
|
199
213
|
}
|
|
200
|
-
// Add base doc.
|
|
201
|
-
addRoute(doc.podPath);
|
|
214
|
+
// Add base doc using its effective default locale.
|
|
215
|
+
addRoute(doc.podPath, doc.defaultLocale);
|
|
202
216
|
// Add localized docs.
|
|
203
217
|
doc.locales.forEach((locale) => {
|
|
204
|
-
if (locale !== doc.defaultLocale) {
|
|
218
|
+
if (locale.id !== doc.defaultLocale.id) {
|
|
205
219
|
addRoute(doc.podPath, locale);
|
|
206
220
|
}
|
|
207
221
|
});
|
package/dist/src/server.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as chokidar from 'chokidar';
|
|
3
1
|
import * as events from 'events';
|
|
4
2
|
import * as http from 'http';
|
|
5
3
|
import { Pod } from './pod';
|
|
@@ -11,11 +9,15 @@ export interface ServerListeningEvent {
|
|
|
11
9
|
app: http.Server;
|
|
12
10
|
server: Server;
|
|
13
11
|
}
|
|
12
|
+
export interface ServerWatcher {
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
on(event: string, listener: (...args: any[]) => void): any;
|
|
15
|
+
}
|
|
14
16
|
export declare class Server extends events.EventEmitter {
|
|
15
17
|
private pod;
|
|
16
18
|
private httpServer?;
|
|
17
19
|
port: number;
|
|
18
|
-
watcher?:
|
|
20
|
+
watcher?: ServerWatcher;
|
|
19
21
|
static AUTORELOAD_PATHS_REGEX: RegExp;
|
|
20
22
|
static CLEAR_MODULE_CACHE_PATH_REGEX: RegExp;
|
|
21
23
|
static PLUGINS_PATH: string;
|
package/dist/src/server.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
37
|
};
|
|
@@ -30,7 +44,7 @@ const nunjucks = __importStar(require("nunjucks"));
|
|
|
30
44
|
const pod_1 = require("./pod");
|
|
31
45
|
const utils_1 = require("./utils");
|
|
32
46
|
const express = require("express");
|
|
33
|
-
const
|
|
47
|
+
const ansi_1 = __importDefault(require("./ansi"));
|
|
34
48
|
const compression_1 = __importDefault(require("compression"));
|
|
35
49
|
class Server extends events.EventEmitter {
|
|
36
50
|
constructor(pod, options) {
|
|
@@ -50,7 +64,7 @@ class Server extends events.EventEmitter {
|
|
|
50
64
|
autoescape: true,
|
|
51
65
|
express: app,
|
|
52
66
|
});
|
|
53
|
-
app.
|
|
67
|
+
app.use(async (req, res) => {
|
|
54
68
|
try {
|
|
55
69
|
const route = await this.pod.router.resolve(req.path);
|
|
56
70
|
if (!route) {
|
|
@@ -110,7 +124,7 @@ class Server extends events.EventEmitter {
|
|
|
110
124
|
// that was opened. Server reloading may be triggered several times in a
|
|
111
125
|
// row.
|
|
112
126
|
if (options?.incrementPort) {
|
|
113
|
-
console.warn(
|
|
127
|
+
console.warn(ansi_1.default.yellow(`Warning: Port ${this.port} is in use, trying ${this.port + 1} instead`));
|
|
114
128
|
this.port += 1;
|
|
115
129
|
retryCount += 1;
|
|
116
130
|
this.httpServer = app.listen(this.port, () => this.onListen());
|
|
@@ -158,7 +172,7 @@ class Server extends events.EventEmitter {
|
|
|
158
172
|
watch() {
|
|
159
173
|
this.watcher = chokidar.watch(this.pod.root, {
|
|
160
174
|
cwd: this.pod.root,
|
|
161
|
-
ignored: [
|
|
175
|
+
ignored: (filePath) => /(^|[\\/])(node_modules|\.git|dist|build)([\\/]|$)/.test(filePath),
|
|
162
176
|
ignoreInitial: true,
|
|
163
177
|
});
|
|
164
178
|
// Reload the server or reset the cache when necessary.
|
|
@@ -209,6 +223,13 @@ class Server extends events.EventEmitter {
|
|
|
209
223
|
}
|
|
210
224
|
/** Stops the web server. */
|
|
211
225
|
async stop() {
|
|
226
|
+
if (this.watcher) {
|
|
227
|
+
await this.watcher.close();
|
|
228
|
+
this.watcher = undefined;
|
|
229
|
+
}
|
|
230
|
+
if (!this.httpServer) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
212
233
|
return new Promise((resolve, reject) => {
|
|
213
234
|
this.httpServer?.close(err => {
|
|
214
235
|
err ? reject(err) : resolve();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SimpleTableOptions {
|
|
2
|
+
head?: string[];
|
|
3
|
+
colAligns?: Array<'left' | 'right' | 'middle'>;
|
|
4
|
+
chars?: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight column-aligned ASCII table replacing `cli-table`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SimpleTable {
|
|
10
|
+
private readonly head;
|
|
11
|
+
private readonly colAligns;
|
|
12
|
+
private readonly rows;
|
|
13
|
+
constructor(options?: SimpleTableOptions);
|
|
14
|
+
push(row: Array<unknown>): number;
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleTable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight column-aligned ASCII table replacing `cli-table`.
|
|
6
|
+
*/
|
|
7
|
+
class SimpleTable {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.rows = [];
|
|
10
|
+
this.head = options.head ?? [];
|
|
11
|
+
this.colAligns = options.colAligns ?? [];
|
|
12
|
+
}
|
|
13
|
+
push(row) {
|
|
14
|
+
return this.rows.push(row.map(cell => String(cell ?? '')));
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
const colCount = Math.max(this.head.length, ...this.rows.map(row => row.length), 0);
|
|
18
|
+
if (colCount === 0) {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
const widths = new Array(colCount).fill(0);
|
|
22
|
+
const updateWidths = (row) => {
|
|
23
|
+
for (let i = 0; i < row.length; i++) {
|
|
24
|
+
widths[i] = Math.max(widths[i], row[i].length);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if (this.head.length) {
|
|
28
|
+
updateWidths(this.head);
|
|
29
|
+
}
|
|
30
|
+
for (const row of this.rows) {
|
|
31
|
+
updateWidths(row);
|
|
32
|
+
}
|
|
33
|
+
const formatCell = (text, idx) => {
|
|
34
|
+
const width = widths[idx] ?? 0;
|
|
35
|
+
const align = this.colAligns[idx] ?? 'left';
|
|
36
|
+
if (align === 'right') {
|
|
37
|
+
return text.padStart(width, ' ');
|
|
38
|
+
}
|
|
39
|
+
if (align === 'middle') {
|
|
40
|
+
const pad = Math.max(0, width - text.length);
|
|
41
|
+
const left = Math.floor(pad / 2);
|
|
42
|
+
return ' '.repeat(left) + text + ' '.repeat(pad - left);
|
|
43
|
+
}
|
|
44
|
+
return text.padEnd(width, ' ');
|
|
45
|
+
};
|
|
46
|
+
const border = (left, mid, right) => `${left}${widths.map(w => '─'.repeat(w + 2)).join(mid)}${right}`;
|
|
47
|
+
const formatRow = (row) => `│ ${widths
|
|
48
|
+
.map((_, i) => formatCell(row[i] ?? '', i))
|
|
49
|
+
.join(' │ ')} │`;
|
|
50
|
+
const lines = [border('┌', '┬', '┐')];
|
|
51
|
+
if (this.head.length) {
|
|
52
|
+
lines.push(formatRow(this.head));
|
|
53
|
+
lines.push(border('├', '┼', '┤'));
|
|
54
|
+
}
|
|
55
|
+
for (const row of this.rows) {
|
|
56
|
+
lines.push(formatRow(row));
|
|
57
|
+
}
|
|
58
|
+
lines.push(border('└', '┴', '┘'));
|
|
59
|
+
return lines.join('\n');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SimpleTable = SimpleTable;
|
package/dist/src/url.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
36
|
exports.Url = void 0;
|
|
23
37
|
const fsPath = __importStar(require("path"));
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Locale } from './locale';
|
|
3
2
|
import { Pod } from './pod';
|
|
4
3
|
export interface FrontMatterResult {
|
|
@@ -7,10 +6,10 @@ export interface FrontMatterResult {
|
|
|
7
6
|
}
|
|
8
7
|
export declare class DataType {
|
|
9
8
|
static isArray(value: any): boolean;
|
|
10
|
-
static isBoolean(value: any): boolean;
|
|
9
|
+
static isBoolean(value: any): value is boolean;
|
|
11
10
|
static isInstance(value: any): boolean;
|
|
12
11
|
static isCollection(value: any): boolean;
|
|
13
|
-
static isDate(value: any):
|
|
12
|
+
static isDate(value: any): value is Date;
|
|
14
13
|
static isDocument(value: any): boolean;
|
|
15
14
|
static isFunction(value: any): boolean;
|
|
16
15
|
static isNumber(value: any): boolean;
|
|
@@ -18,9 +17,9 @@ export declare class DataType {
|
|
|
18
17
|
static isObject(value: any): boolean;
|
|
19
18
|
static isRegExp(value: any): boolean;
|
|
20
19
|
static isStaticFile(value: any): boolean;
|
|
21
|
-
static isString(value: any):
|
|
22
|
-
static isSymbol(value: any):
|
|
23
|
-
static isUndefined(value: any):
|
|
20
|
+
static isString(value: any): value is string | String;
|
|
21
|
+
static isSymbol(value: any): value is symbol;
|
|
22
|
+
static isUndefined(value: any): value is undefined;
|
|
24
23
|
}
|
|
25
24
|
export declare function basename(path: string): string;
|
|
26
25
|
export declare function formatBytes(bytes: number): string;
|
package/dist/src/utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,15 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
36
|
+
exports.DataType = void 0;
|
|
37
|
+
exports.basename = basename;
|
|
38
|
+
exports.formatBytes = formatBytes;
|
|
39
|
+
exports.interpolate = interpolate;
|
|
40
|
+
exports.localizeData = localizeData;
|
|
41
|
+
exports.splitFrontMatter = splitFrontMatter;
|
|
42
|
+
exports.walk = walk;
|
|
43
|
+
exports.queryObject = queryObject;
|
|
44
|
+
exports.debounce = debounce;
|
|
23
45
|
const fs = __importStar(require("fs"));
|
|
24
46
|
const fsPath = __importStar(require("path"));
|
|
25
47
|
class DataType {
|
|
@@ -80,7 +102,6 @@ exports.DataType = DataType;
|
|
|
80
102
|
function basename(path) {
|
|
81
103
|
return path.split('/').reverse()[0];
|
|
82
104
|
}
|
|
83
|
-
exports.basename = basename;
|
|
84
105
|
function formatBytes(bytes) {
|
|
85
106
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
86
107
|
if (bytes === 0) {
|
|
@@ -89,7 +110,6 @@ function formatBytes(bytes) {
|
|
|
89
110
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
90
111
|
return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i];
|
|
91
112
|
}
|
|
92
|
-
exports.formatBytes = formatBytes;
|
|
93
113
|
/**
|
|
94
114
|
* Applies string interpolation to a given string. For example, if a given
|
|
95
115
|
* string is `Hello ${name}` and the params are `{string: 'World'}`, the result
|
|
@@ -116,7 +136,6 @@ function interpolate(pod, string, params) {
|
|
|
116
136
|
pod.cache.interpolations[key] = func;
|
|
117
137
|
return func(...vals);
|
|
118
138
|
}
|
|
119
|
-
exports.interpolate = interpolate;
|
|
120
139
|
function localizeData(data, locale) {
|
|
121
140
|
if (!data) {
|
|
122
141
|
return data;
|
|
@@ -140,7 +159,6 @@ function localizeData(data, locale) {
|
|
|
140
159
|
}
|
|
141
160
|
return data;
|
|
142
161
|
}
|
|
143
|
-
exports.localizeData = localizeData;
|
|
144
162
|
function splitFrontMatter(content) {
|
|
145
163
|
if (!content) {
|
|
146
164
|
return {};
|
|
@@ -167,7 +185,6 @@ function splitFrontMatter(content) {
|
|
|
167
185
|
body: content.slice(closingIndex + closingPart.length).trim(),
|
|
168
186
|
};
|
|
169
187
|
}
|
|
170
|
-
exports.splitFrontMatter = splitFrontMatter;
|
|
171
188
|
function walk(path, newFiles, removePrefix) {
|
|
172
189
|
let files = newFiles || [];
|
|
173
190
|
fs.readdirSync(path).forEach(file => {
|
|
@@ -181,7 +198,6 @@ function walk(path, newFiles, removePrefix) {
|
|
|
181
198
|
});
|
|
182
199
|
return files;
|
|
183
200
|
}
|
|
184
|
-
exports.walk = walk;
|
|
185
201
|
/**
|
|
186
202
|
* Returns data queried from a YAML file. Use by specifying a query, such as
|
|
187
203
|
* 'foo.bar'. This will return the value nested under the keys: `{foo: {bar:
|
|
@@ -205,7 +221,6 @@ function queryObject(query, data) {
|
|
|
205
221
|
}
|
|
206
222
|
return result;
|
|
207
223
|
}
|
|
208
|
-
exports.queryObject = queryObject;
|
|
209
224
|
/** Debounces a function so that it's only called once within a window. Adopted
|
|
210
225
|
* from https://github.com/hayes/just-debounce. */
|
|
211
226
|
function debounce(fn, delay, immediate = false) {
|
|
@@ -235,4 +250,3 @@ function debounce(fn, delay, immediate = false) {
|
|
|
235
250
|
}
|
|
236
251
|
};
|
|
237
252
|
}
|
|
238
|
-
exports.debounce = debounce;
|