ecto 4.8.7 → 5.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/dist/ecto.d.mts +0 -1
- package/dist/ecto.mjs +15 -21
- package/package.json +20 -18
package/dist/ecto.d.mts
CHANGED
package/dist/ecto.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import
|
|
2
|
+
import nodePath from "node:path";
|
|
3
3
|
import { Cacheable, CacheableMemory } from "cacheable";
|
|
4
4
|
import { Hookified } from "hookified";
|
|
5
5
|
import { Writr } from "writr";
|
|
6
6
|
import ejs from "ejs";
|
|
7
7
|
import { fumanchu } from "@jaredwray/fumanchu";
|
|
8
|
-
import { decode } from "ent";
|
|
9
8
|
import { Liquid as Liquid$1 } from "liquidjs";
|
|
10
9
|
import * as nunjucks from "nunjucks";
|
|
11
10
|
import * as pug from "pug";
|
|
@@ -110,15 +109,11 @@ var Handlebars = class extends BaseEngine {
|
|
|
110
109
|
}
|
|
111
110
|
async render(source, data) {
|
|
112
111
|
if (this.rootTemplatePath) this.initPartials();
|
|
113
|
-
|
|
114
|
-
result = decode(result);
|
|
115
|
-
return result;
|
|
112
|
+
return this.engine.compile(source, this.opts)(data, this.opts);
|
|
116
113
|
}
|
|
117
114
|
renderSync(source, data) {
|
|
118
115
|
if (this.rootTemplatePath) this.initPartials();
|
|
119
|
-
|
|
120
|
-
result = decode(result);
|
|
121
|
-
return result;
|
|
116
|
+
return this.engine.compile(source, this.opts)(data, this.opts);
|
|
122
117
|
}
|
|
123
118
|
initPartials() {
|
|
124
119
|
for (const path of this.partialsPath) {
|
|
@@ -531,7 +526,7 @@ var Ecto = class extends Hookified {
|
|
|
531
526
|
async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
532
527
|
let result = "";
|
|
533
528
|
engineName ??= this.getEngineByFilePath(filePath);
|
|
534
|
-
const templateRootPath = rootTemplatePath ??
|
|
529
|
+
const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
|
|
535
530
|
const source = await fs.promises.readFile(filePath, "utf8");
|
|
536
531
|
result = await this.render(source, data, engineName, templateRootPath, filePathOutput);
|
|
537
532
|
return result;
|
|
@@ -550,7 +545,7 @@ var Ecto = class extends Hookified {
|
|
|
550
545
|
renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
551
546
|
let result = "";
|
|
552
547
|
engineName ??= this.getEngineByFilePath(filePath);
|
|
553
|
-
const templateRootPath = rootTemplatePath ??
|
|
548
|
+
const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
|
|
554
549
|
const source = fs.readFileSync(filePath, "utf8");
|
|
555
550
|
result = this.renderSync(source, data, engineName, templateRootPath, filePathOutput);
|
|
556
551
|
return result;
|
|
@@ -563,10 +558,9 @@ var Ecto = class extends Hookified {
|
|
|
563
558
|
* await ecto.ensureFilePath('/path/to/file.txt');
|
|
564
559
|
*/
|
|
565
560
|
async ensureFilePath(path) {
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (!fs.existsSync(directory)) fs.mkdirSync(directory, { recursive: true });
|
|
561
|
+
const normalizedPath = nodePath.normalize(path);
|
|
562
|
+
const directory = nodePath.dirname(normalizedPath);
|
|
563
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
570
564
|
}
|
|
571
565
|
/**
|
|
572
566
|
* Synchronously ensure that the directory path for a file exists, creating it if necessary
|
|
@@ -576,10 +570,9 @@ var Ecto = class extends Hookified {
|
|
|
576
570
|
* ecto.ensureFilePathSync('/path/to/file.txt');
|
|
577
571
|
*/
|
|
578
572
|
ensureFilePathSync(path) {
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (!fs.existsSync(directory)) fs.mkdirSync(directory, { recursive: true });
|
|
573
|
+
const normalizedPath = nodePath.normalize(path);
|
|
574
|
+
const directory = nodePath.dirname(normalizedPath);
|
|
575
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
583
576
|
}
|
|
584
577
|
/**
|
|
585
578
|
* Determine the appropriate template engine based on a file's extension
|
|
@@ -591,7 +584,8 @@ var Ecto = class extends Hookified {
|
|
|
591
584
|
getEngineByFilePath(filePath) {
|
|
592
585
|
let result = this._defaultEngine;
|
|
593
586
|
if (filePath !== void 0) {
|
|
594
|
-
const
|
|
587
|
+
const { ext } = nodePath.parse(filePath);
|
|
588
|
+
const extension = ext.startsWith(".") ? ext.slice(1) : ext;
|
|
595
589
|
const engExtension = this._mapping.getName(extension);
|
|
596
590
|
if (engExtension !== void 0) result = engExtension;
|
|
597
591
|
}
|
|
@@ -609,7 +603,7 @@ var Ecto = class extends Hookified {
|
|
|
609
603
|
let result = "";
|
|
610
604
|
const files = await fs.promises.readdir(path);
|
|
611
605
|
for (const file of files) if (file.startsWith(`${templateName}.`)) {
|
|
612
|
-
result =
|
|
606
|
+
result = nodePath.join(path, file);
|
|
613
607
|
break;
|
|
614
608
|
}
|
|
615
609
|
return result;
|
|
@@ -626,7 +620,7 @@ var Ecto = class extends Hookified {
|
|
|
626
620
|
let result = "";
|
|
627
621
|
const files = fs.readdirSync(path);
|
|
628
622
|
for (const file of files) if (file.startsWith(`${templateName}.`)) {
|
|
629
|
-
result =
|
|
623
|
+
result = nodePath.join(path, file);
|
|
630
624
|
break;
|
|
631
625
|
}
|
|
632
626
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Liquid, and Handlebars",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/ecto.mjs",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"author": "Jared Wray <me@jaredwray.com>",
|
|
20
20
|
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.18.0"
|
|
23
|
+
},
|
|
21
24
|
"keywords": [
|
|
22
25
|
"templates",
|
|
23
26
|
"generator",
|
|
@@ -39,31 +42,30 @@
|
|
|
39
42
|
"liquidjs"
|
|
40
43
|
],
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@jaredwray/fumanchu": "^4.7.
|
|
43
|
-
"cacheable": "^2.
|
|
44
|
-
"ejs": "^
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"liquidjs": "^10.27.0",
|
|
45
|
+
"@jaredwray/fumanchu": "^4.7.2",
|
|
46
|
+
"cacheable": "^2.5.0",
|
|
47
|
+
"ejs": "^6.0.1",
|
|
48
|
+
"hookified": "^3.0.2",
|
|
49
|
+
"liquidjs": "^10.29.0",
|
|
48
50
|
"nunjucks": "^3.2.4",
|
|
49
51
|
"pug": "^3.0.4",
|
|
50
|
-
"writr": "^6.1.
|
|
52
|
+
"writr": "^6.1.5"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@biomejs/biome": "^2.
|
|
54
|
-
"@faker-js/faker": "^10.
|
|
55
|
+
"@biomejs/biome": "^2.5.9",
|
|
56
|
+
"@faker-js/faker": "^10.6.0",
|
|
55
57
|
"@types/ejs": "^3.1.5",
|
|
56
|
-
"@types/
|
|
57
|
-
"@types/node": "^24.12.4",
|
|
58
|
+
"@types/node": "^24.13.3",
|
|
58
59
|
"@types/nunjucks": "^3.2.6",
|
|
59
60
|
"@types/pug": "^2.0.10",
|
|
60
|
-
"@vitest/coverage-v8": "^4.1.
|
|
61
|
-
"docula": "^
|
|
61
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
62
|
+
"docula": "^3.0.0",
|
|
62
63
|
"rimraf": "^6.1.3",
|
|
63
|
-
"tsdown": "^0.22.
|
|
64
|
-
"typescript": "^
|
|
65
|
-
"vite": "^8.
|
|
66
|
-
"vitest": "^4.1.
|
|
64
|
+
"tsdown": "^0.22.14",
|
|
65
|
+
"typescript": "^7.0.2",
|
|
66
|
+
"vite": "^8.2.1",
|
|
67
|
+
"vitest": "^4.1.11",
|
|
68
|
+
"wrangler": "^4.124.0"
|
|
67
69
|
},
|
|
68
70
|
"files": [
|
|
69
71
|
"dist",
|