@amagaki/amagaki 4.0.0 → 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 +1 -1
- package/dist/src/pod.js +26 -12
- 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 -64
package/README.md
CHANGED
|
@@ -1,70 +1,74 @@
|
|
|
1
1
|
# Amagaki
|
|
2
2
|
|
|
3
|
-
[.
|
|
37
|
-
|
|
38
|
-
```shell
|
|
39
|
-
# Create a new Amagaki project interactively
|
|
40
|
-
npx create-amagaki
|
|
41
|
-
|
|
42
|
-
# Start the dev server
|
|
43
|
-
npm run dev
|
|
3
|
+
[](https://www.npmjs.com/package/@amagaki/amagaki)
|
|
4
|
+
[](https://github.com/blinkk/amagaki/actions/workflows/test-amagaki.yml)
|
|
5
|
+
[](https://github.com/blinkk/amagaki/blob/main/LICENSE.md)
|
|
6
|
+
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
> **Maintenance mode:** Amagaki is actively maintained for existing sites with bug fixes and dependency updates, but for new projects we recommend <img src="https://amagaki.dev/static/images/rootjs-beet.svg" width="13" height="19" alt="" align="absmiddle"> [**Root.js**](https://rootjs.dev) ([GitHub](https://github.com/blinkk/rootjs)) — our modern successor built with TypeScript, Preact/TSX, file routing, i18n, and a built-in CMS.
|
|
9
|
+
|
|
10
|
+
**Amagaki** is a TypeScript-based static site generator designed for hand-coding marketing and informational websites. It provides flexible URL routing, built-in localization, custom YAML types, an extensible plugin architecture, build profiling, and pluggable template engines.
|
|
11
|
+
|
|
12
|
+
Amagaki takes concepts from [Grow](https://grow.dev) and brings them to a TypeScript and Node.js ecosystem.
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
Read the full documentation and API reference at **[amagaki.dev](https://amagaki.dev)**.
|
|
17
|
+
|
|
18
|
+
## Key Features
|
|
19
|
+
|
|
20
|
+
- **TypeScript & Node.js**: Write site configuration, plugins, and custom routes in TypeScript with minimal core dependencies.
|
|
21
|
+
- **Data-driven content**: Author structured content in YAML and Markdown with built-in YAML constructors (`!pod.doc`, `!pod.collection`, `!pod.staticFile`, `!pod.string`, `!IfLocale`, `!IfEnvironment`).
|
|
22
|
+
- **Pluggable template engines**: Ships with Nunjucks out of the box and supports registering custom template engines (such as Preact/TSX).
|
|
23
|
+
- **On-demand dev server**: Renders pages on request during development instead of rebuilding the entire site on every edit.
|
|
24
|
+
- **Built-in localization (i18n)**: Manage translatable strings, locale-scoped fields, and localized URLs natively.
|
|
25
|
+
- **Extensible plugin system**: Hook into routing, YAML parsing, template engines, Express dev server middleware, and build lifecycle events.
|
|
26
|
+
- **Built-in profiling**: Inspect memory usage, build times, route counts, and missing translation reports on every build.
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- Node.js **20+**
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
Scaffold a new zero-bundler project from [`examples/starter/`](https://github.com/blinkk/amagaki/tree/main/examples/starter):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx create-amagaki my-site
|
|
38
|
+
cd my-site
|
|
39
|
+
npm run dev
|
|
47
40
|
```
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
Or install `@amagaki/amagaki` directly in an existing project:
|
|
50
43
|
|
|
51
|
-
```
|
|
52
|
-
# Install Amagaki
|
|
44
|
+
```bash
|
|
53
45
|
npm install --save @amagaki/amagaki
|
|
54
46
|
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
|
|
48
|
+
### Common Commands
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx amagaki serve # Start the local development server (default port 8080)
|
|
52
|
+
npx amagaki build # Build the static site to ./build/
|
|
53
|
+
npx amagaki --profile build # Build and print detailed profiling tables
|
|
54
|
+
npx amagaki export -o ./out # Export a build to another directory with diff summary
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
This monorepo uses npm workspaces, TypeScript, and AVA:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/blinkk/amagaki.git
|
|
63
|
+
cd amagaki
|
|
64
|
+
npm ci
|
|
65
|
+
npm run build -w packages/amagaki
|
|
66
|
+
npm run build -w packages/amagaki-plugin-page-builder
|
|
67
|
+
npm run build -w packages/amagaki-engine-preact
|
|
68
|
+
npm run build -w packages/create-amagaki
|
|
69
|
+
npm test --workspaces
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
[MIT](https://github.com/blinkk/amagaki/blob/main/LICENSE.md)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const ansi: {
|
|
2
|
+
blue: (text: string) => string;
|
|
3
|
+
cyan: (text: string) => string;
|
|
4
|
+
gray: (text: string) => string;
|
|
5
|
+
green: (text: string) => string;
|
|
6
|
+
greenBright: (text: string) => string;
|
|
7
|
+
red: (text: string) => string;
|
|
8
|
+
yellow: (text: string) => string;
|
|
9
|
+
};
|
|
10
|
+
export default ansi;
|
package/dist/src/ansi.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ansi = void 0;
|
|
4
|
+
const useColor = () => process.env.NO_COLOR === undefined &&
|
|
5
|
+
process.env.TERM !== 'dumb' &&
|
|
6
|
+
Boolean(process.stdout.isTTY);
|
|
7
|
+
const wrap = (code) => (text) => useColor() ? `\x1b[${code}m${text}\x1b[39m` : text;
|
|
8
|
+
exports.ansi = {
|
|
9
|
+
blue: wrap(34),
|
|
10
|
+
cyan: wrap(36),
|
|
11
|
+
gray: wrap(90),
|
|
12
|
+
green: wrap(32),
|
|
13
|
+
greenBright: wrap(92),
|
|
14
|
+
red: wrap(31),
|
|
15
|
+
yellow: wrap(33),
|
|
16
|
+
};
|
|
17
|
+
exports.default = exports.ansi;
|
package/dist/src/builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProgressBar } from './progress';
|
|
2
2
|
import { GitCommit } from './gitData';
|
|
3
3
|
import { Pod } from './pod';
|
|
4
4
|
import { TranslationString } from './string';
|
|
@@ -18,8 +18,8 @@ export interface BuildDiffPaths {
|
|
|
18
18
|
noChanges: Array<string>;
|
|
19
19
|
deletes: Array<string>;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
type LocalesToNumMissingTranslations = Record<string, number>;
|
|
22
|
+
type LocalesToMissingTranslations = Record<string, TranslationString[]>;
|
|
23
23
|
export interface BuildMetrics {
|
|
24
24
|
memoryUsage: number;
|
|
25
25
|
localesToNumMissingTranslations: LocalesToNumMissingTranslations;
|
|
@@ -69,7 +69,7 @@ export declare class Builder {
|
|
|
69
69
|
deleteOutputFiles(paths: Array<string>, outputRootDir: string): void;
|
|
70
70
|
getManifest(filePath: string): BuildManifest | null;
|
|
71
71
|
cleanOutputUsingManifests(existingManifest: BuildManifest | null, newManifest: BuildManifest, options?: BuildOptions): BuildDiffPaths;
|
|
72
|
-
static createProgressBar(label: string):
|
|
72
|
+
static createProgressBar(label: string): ProgressBar;
|
|
73
73
|
export(options: ExportOptions): Promise<BuildDiffPaths>;
|
|
74
74
|
build(options?: BuildOptions): Promise<BuildResult>;
|
|
75
75
|
logResult(buildDiff: BuildDiffPaths, buildMetrics: BuildMetrics, options?: BuildOptions): void;
|
package/dist/src/builder.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,20 +15,30 @@ 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
|
};
|
|
24
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
39
|
exports.Builder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const
|
|
40
|
+
const concurrency = __importStar(require("./concurrency"));
|
|
41
|
+
const progress_1 = require("./progress");
|
|
28
42
|
const crypto = __importStar(require("crypto"));
|
|
29
43
|
const fs = __importStar(require("fs"));
|
|
30
44
|
const fsPath = __importStar(require("path"));
|
|
@@ -32,8 +46,8 @@ const stream = __importStar(require("stream"));
|
|
|
32
46
|
const util = __importStar(require("util"));
|
|
33
47
|
const utils = __importStar(require("./utils"));
|
|
34
48
|
const gitData_1 = require("./gitData");
|
|
35
|
-
const
|
|
36
|
-
const minimatch_1 =
|
|
49
|
+
const ansi_1 = __importDefault(require("./ansi"));
|
|
50
|
+
const minimatch_1 = require("minimatch");
|
|
37
51
|
class Builder {
|
|
38
52
|
constructor(pod) {
|
|
39
53
|
this.pod = pod;
|
|
@@ -197,13 +211,7 @@ class Builder {
|
|
|
197
211
|
return buildDiffPaths;
|
|
198
212
|
}
|
|
199
213
|
static createProgressBar(label) {
|
|
200
|
-
|
|
201
|
-
const options = {
|
|
202
|
-
format: chalk_1.default.green(`${label} ({value}/{total}): `) +
|
|
203
|
-
'{bar} Total: {customDuration}',
|
|
204
|
-
noTTYOutput: isTTY,
|
|
205
|
-
};
|
|
206
|
-
return new cliProgress.SingleBar(options, cliProgress.Presets.shades_classic);
|
|
214
|
+
return new progress_1.ProgressBar(label);
|
|
207
215
|
}
|
|
208
216
|
async export(options) {
|
|
209
217
|
const buildDir = options.buildDir ?? this.pod.getAbsoluteFilePath(this.outputDirectoryPodPath);
|
|
@@ -257,14 +265,14 @@ class Builder {
|
|
|
257
265
|
}
|
|
258
266
|
}
|
|
259
267
|
if (exportManifest?.commit) {
|
|
260
|
-
console.log(
|
|
268
|
+
console.log(ansi_1.default.yellow(`Previous export:`), `${exportManifest.built} by ${exportManifest.commit.author.email} (${exportManifest.commit.sha.slice(0, 6)})`);
|
|
261
269
|
}
|
|
262
270
|
if (buildManifest?.commit) {
|
|
263
|
-
console.log(
|
|
271
|
+
console.log(ansi_1.default.yellow(` Current build:`), `${buildManifest.built} by ${buildManifest.commit.author.email} (${buildManifest.commit.sha.slice(0, 6)})`);
|
|
264
272
|
}
|
|
265
273
|
const numOperations = result.adds.length + result.edits.length + result.deletes.length;
|
|
266
274
|
if (numOperations === 0) {
|
|
267
|
-
console.log(
|
|
275
|
+
console.log(ansi_1.default.blue('No changes since last export: ') +
|
|
268
276
|
this.pod.getAbsoluteFilePath(options.exportDir));
|
|
269
277
|
return result;
|
|
270
278
|
}
|
|
@@ -278,7 +286,7 @@ class Builder {
|
|
|
278
286
|
}
|
|
279
287
|
// Copy adds and edits.
|
|
280
288
|
const moveFiles = [...result.adds, ...result.edits];
|
|
281
|
-
await
|
|
289
|
+
await concurrency.mapLimit(moveFiles, Builder.NumConcurrentCopies, async (filePath) => {
|
|
282
290
|
const relativePath = filePath.replace(/^\//, '');
|
|
283
291
|
const source = fsPath.join(buildDir, relativePath);
|
|
284
292
|
const destination = fsPath.join(options.exportDir, relativePath);
|
|
@@ -294,11 +302,11 @@ class Builder {
|
|
|
294
302
|
await Promise.all([
|
|
295
303
|
this.writeFileAsync(exportManifestPath, JSON.stringify(buildManifest, null, 2)),
|
|
296
304
|
]);
|
|
297
|
-
console.log(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
console.log(
|
|
305
|
+
console.log(ansi_1.default.blue('Changes: ') +
|
|
306
|
+
ansi_1.default.green(`${result.adds.length} adds, `) +
|
|
307
|
+
ansi_1.default.yellow(`${result.edits.length} edits, `) +
|
|
308
|
+
ansi_1.default.red(`${result.deletes.length} deletes`));
|
|
309
|
+
console.log(ansi_1.default.blue('Export complete: ') +
|
|
302
310
|
this.pod.getAbsoluteFilePath(options.exportDir));
|
|
303
311
|
return result;
|
|
304
312
|
}
|
|
@@ -332,7 +340,7 @@ class Builder {
|
|
|
332
340
|
// Only build routes matching patterns.
|
|
333
341
|
if (options?.patterns) {
|
|
334
342
|
routes = routes.filter(route => options.patterns?.some(pattern => route.podPath &&
|
|
335
|
-
(0, minimatch_1.
|
|
343
|
+
(0, minimatch_1.minimatch)(route.podPath.replace(/^\//, ''), pattern.replace(/^\//, ''), {
|
|
336
344
|
matchBase: true,
|
|
337
345
|
})));
|
|
338
346
|
}
|
|
@@ -358,7 +366,7 @@ class Builder {
|
|
|
358
366
|
// Copy all static files and build all other routes.
|
|
359
367
|
const errors = [];
|
|
360
368
|
const errorRoutes = [];
|
|
361
|
-
await
|
|
369
|
+
await concurrency.eachLimit(createdPaths, Builder.NumConcurrentBuilds, async (createdPath) => {
|
|
362
370
|
try {
|
|
363
371
|
// Copy the file, or build it if it's a dynamic route.
|
|
364
372
|
if (createdPath.route.provider.type === 'staticDir') {
|
|
@@ -385,11 +393,11 @@ class Builder {
|
|
|
385
393
|
}
|
|
386
394
|
if (errors.length) {
|
|
387
395
|
bar.stop();
|
|
388
|
-
console.error(
|
|
396
|
+
console.error(ansi_1.default.yellow(`\nFound ${errors.length} errors building the following routes.\n`));
|
|
389
397
|
errorRoutes.map(route => {
|
|
390
398
|
console.error(` ${route.urlPath}`);
|
|
391
399
|
});
|
|
392
|
-
console.error(
|
|
400
|
+
console.error(ansi_1.default.yellow('\nThe first error was:'));
|
|
393
401
|
if (errors[0].message) {
|
|
394
402
|
console.log(`\n${errors[0].message}\n`);
|
|
395
403
|
}
|
|
@@ -421,7 +429,7 @@ class Builder {
|
|
|
421
429
|
customDuration: Builder.formatProgressBarTime(0),
|
|
422
430
|
});
|
|
423
431
|
}
|
|
424
|
-
await
|
|
432
|
+
await concurrency.mapLimit(createdPaths, Builder.NumConcurrentCopies, async (createdPath) => {
|
|
425
433
|
// Start by building the manifest (and getting file shas).
|
|
426
434
|
buildManifest.files.push({
|
|
427
435
|
path: createdPath.normalPath,
|
|
@@ -495,32 +503,32 @@ class Builder {
|
|
|
495
503
|
return result;
|
|
496
504
|
}
|
|
497
505
|
logResult(buildDiff, buildMetrics, options) {
|
|
498
|
-
console.log(
|
|
506
|
+
console.log(ansi_1.default.blue('Memory usage: ') + utils.formatBytes(buildMetrics.memoryUsage));
|
|
499
507
|
if (buildMetrics.numDocumentRoutes) {
|
|
500
|
-
console.log(
|
|
508
|
+
console.log(ansi_1.default.blue('Documents: ') +
|
|
501
509
|
`${buildMetrics.numDocumentRoutes} (${utils.formatBytes(buildMetrics.outputSizeDocuments)}) ${options?.patterns ? '*incremental build' : ''}`);
|
|
502
510
|
}
|
|
503
511
|
if (buildMetrics.numStaticRoutes) {
|
|
504
|
-
console.log(
|
|
512
|
+
console.log(ansi_1.default.blue('Static files: ') +
|
|
505
513
|
`${buildMetrics.numStaticRoutes} (${utils.formatBytes(buildMetrics.outputSizeStaticFiles)})`);
|
|
506
514
|
}
|
|
507
515
|
if (buildMetrics.numMissingTranslations) {
|
|
508
|
-
console.log(
|
|
516
|
+
console.log(ansi_1.default.blue('Missing translations: ') +
|
|
509
517
|
Object.entries(buildMetrics.localesToNumMissingTranslations)
|
|
510
518
|
.map(([locale, numMissingTranslations]) => {
|
|
511
519
|
return `${locale} (${numMissingTranslations})`;
|
|
512
520
|
})
|
|
513
521
|
.join(', '));
|
|
514
522
|
if (options?.writeLocales) {
|
|
515
|
-
console.log(
|
|
523
|
+
console.log(ansi_1.default.blue('Saved locales: ') +
|
|
516
524
|
this.pod.getAbsoluteFilePath(this.missingTranslationsPodPath));
|
|
517
525
|
}
|
|
518
526
|
}
|
|
519
|
-
console.log(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
console.log(
|
|
527
|
+
console.log(ansi_1.default.blue('Changes: ') +
|
|
528
|
+
ansi_1.default.green(`${buildDiff.adds.length} adds, `) +
|
|
529
|
+
ansi_1.default.yellow(`${buildDiff.edits.length} edits, `) +
|
|
530
|
+
ansi_1.default.red(`${buildDiff.deletes.length} deletes`));
|
|
531
|
+
console.log(ansi_1.default.blue('Build complete: ') +
|
|
524
532
|
this.pod.getAbsoluteFilePath(this.outputDirectoryPodPath));
|
|
525
533
|
}
|
|
526
534
|
async writeLocales(localesToMissingTranslations) {
|
package/dist/src/cli.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
Object.
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
6
10
|
}) : (function(o, m, k, k2) {
|
|
7
11
|
if (k2 === undefined) k2 = k;
|
|
8
12
|
o[k2] = m[k];
|
|
@@ -12,15 +16,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
12
16
|
}) : function(o, v) {
|
|
13
17
|
o["default"] = v;
|
|
14
18
|
});
|
|
15
|
-
var __importStar = (this && this.__importStar) || function (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
22
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
37
|
+
exports.MIN_NODE_VERSION = exports.VERSION = void 0;
|
|
38
|
+
exports.isNodeVersionSupported = isNodeVersionSupported;
|
|
24
39
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
40
|
// @ts-ignore: File is located two directories down when packed.
|
|
26
41
|
const packageData = __importStar(require("../../package.json"));
|
|
@@ -83,4 +98,3 @@ function isNodeVersionSupported() {
|
|
|
83
98
|
}
|
|
84
99
|
return true;
|
|
85
100
|
}
|
|
86
|
-
exports.isNodeVersionSupported = isNodeVersionSupported;
|
package/dist/src/collection.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,23 +15,30 @@ 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
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
})();
|
|
24
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
36
|
exports.Collection = void 0;
|
|
26
37
|
const fs = __importStar(require("fs"));
|
|
27
38
|
const fsPath = __importStar(require("path"));
|
|
28
39
|
const document_1 = require("./document");
|
|
29
40
|
const locale_1 = require("./locale");
|
|
30
|
-
const glob_1 =
|
|
41
|
+
const glob_1 = require("glob");
|
|
31
42
|
/**
|
|
32
43
|
* Collections represent groups of documents. Collections allow documents to
|
|
33
44
|
* share things, such as locales, URL path formats, views, etc. A collection
|
|
@@ -76,13 +87,13 @@ class Collection {
|
|
|
76
87
|
`${pod.defaultContentPodPath}**/${Collection.ConfigFile}`,
|
|
77
88
|
];
|
|
78
89
|
patterns.forEach(pattern => {
|
|
79
|
-
glob_1.
|
|
80
|
-
.sync(pattern, {
|
|
90
|
+
(0, glob_1.globSync)(pattern, {
|
|
81
91
|
cwd: pod.root,
|
|
82
92
|
root: pod.root,
|
|
83
93
|
matchBase: false,
|
|
84
94
|
nodir: true,
|
|
85
95
|
})
|
|
96
|
+
.sort()
|
|
86
97
|
.forEach(path => {
|
|
87
98
|
paths.add(path);
|
|
88
99
|
});
|
|
@@ -120,12 +131,12 @@ class Collection {
|
|
|
120
131
|
*/
|
|
121
132
|
get subcollections() {
|
|
122
133
|
const pattern = fsPath.join(this.podPath, '**', Collection.ConfigFile);
|
|
123
|
-
return glob_1.
|
|
124
|
-
.sync(pattern, {
|
|
134
|
+
return (0, glob_1.globSync)(pattern, {
|
|
125
135
|
cwd: this.pod.root,
|
|
126
136
|
root: this.pod.root,
|
|
127
137
|
nodir: true,
|
|
128
138
|
})
|
|
139
|
+
.sort()
|
|
129
140
|
.map(path => {
|
|
130
141
|
// Convert absolute paths to pod paths.
|
|
131
142
|
return fsPath.dirname(path).replace(this.pod.root, '');
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPodWithEnvironment =
|
|
6
|
+
exports.getPodWithEnvironment = getPodWithEnvironment;
|
|
7
7
|
const __1 = require("..");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
function getPodWithEnvironment(path, globalOptions, env) {
|
|
@@ -14,4 +14,3 @@ function getPodWithEnvironment(path, globalOptions, env) {
|
|
|
14
14
|
}
|
|
15
15
|
return pod;
|
|
16
16
|
}
|
|
17
|
-
exports.getPodWithEnvironment = getPodWithEnvironment;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ServeCommand = void 0;
|
|
7
7
|
const global_1 = require("./global");
|
|
8
8
|
const server_1 = require("../server");
|
|
9
|
-
const
|
|
9
|
+
const ansi_1 = __importDefault(require("../ansi"));
|
|
10
10
|
class ServeCommand {
|
|
11
11
|
constructor(globalOptions, options) {
|
|
12
12
|
this.globalOptions = globalOptions;
|
|
@@ -25,12 +25,12 @@ class ServeCommand {
|
|
|
25
25
|
port: port,
|
|
26
26
|
});
|
|
27
27
|
server.on(server_1.Server.Events.RELOAD, (e) => {
|
|
28
|
-
console.log(
|
|
28
|
+
console.log(ansi_1.default.greenBright('Reloaded:'), `${pod.env.scheme}://${pod.env.host}:${e.server.port}/`);
|
|
29
29
|
});
|
|
30
30
|
server.once(server_1.Server.Events.LISTENING, (e) => {
|
|
31
|
-
console.log(
|
|
32
|
-
console.log(
|
|
33
|
-
console.log(
|
|
31
|
+
console.log(ansi_1.default.green('🍊 Pod:'), `${pod.root}`);
|
|
32
|
+
console.log(ansi_1.default.green('Server:'), `${pod.env.scheme}://${pod.env.host}:${e.server.port}/`);
|
|
33
|
+
console.log(ansi_1.default.green(' Ready. Press ctrl+c to quit.'));
|
|
34
34
|
});
|
|
35
35
|
await server.start();
|
|
36
36
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs an async iterator over `items` with at most `limit` concurrent executions.
|
|
3
|
+
*/
|
|
4
|
+
export declare function eachLimit<T>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<unknown>): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Maps an async iterator over `items` with at most `limit` concurrent executions,
|
|
7
|
+
* preserving result order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eachLimit = eachLimit;
|
|
4
|
+
exports.mapLimit = mapLimit;
|
|
5
|
+
/**
|
|
6
|
+
* Runs an async iterator over `items` with at most `limit` concurrent executions.
|
|
7
|
+
*/
|
|
8
|
+
async function eachLimit(items, limit, fn) {
|
|
9
|
+
await mapLimit(items, limit, fn);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Maps an async iterator over `items` with at most `limit` concurrent executions,
|
|
13
|
+
* preserving result order.
|
|
14
|
+
*/
|
|
15
|
+
async function mapLimit(items, limit, fn) {
|
|
16
|
+
const results = new Array(items.length);
|
|
17
|
+
const concurrency = Math.max(1, Math.min(limit, items.length || 1));
|
|
18
|
+
let nextIndex = 0;
|
|
19
|
+
const worker = async () => {
|
|
20
|
+
while (nextIndex < items.length) {
|
|
21
|
+
const current = nextIndex++;
|
|
22
|
+
results[current] = await fn(items[current], current);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
await Promise.all(Array.from({ length: concurrency }, () => worker()));
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively walks plain objects and arrays, transforming values via `callback`.
|
|
3
|
+
* Class instances and functions are passed directly to `callback` without recursing
|
|
4
|
+
* into their properties.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DeepWalk {
|
|
7
|
+
walk(value: any, callback: (value: any) => Promise<any> | any): Promise<any>;
|
|
8
|
+
}
|