ecto 5.0.0 → 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 CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Cacheable, CacheableMemory } from "cacheable";
2
2
  import { Hookified, HookifiedOptions } from "hookified";
3
-
4
3
  //#region src/engine-interface.d.ts
5
4
  type EngineInterface = {
6
5
  names: string[];
package/dist/ecto.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import fs from "node:fs";
2
- import path from "node:path";
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";
@@ -526,7 +526,7 @@ var Ecto = class extends Hookified {
526
526
  async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
527
527
  let result = "";
528
528
  engineName ??= this.getEngineByFilePath(filePath);
529
- const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
529
+ const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
530
530
  const source = await fs.promises.readFile(filePath, "utf8");
531
531
  result = await this.render(source, data, engineName, templateRootPath, filePathOutput);
532
532
  return result;
@@ -545,7 +545,7 @@ var Ecto = class extends Hookified {
545
545
  renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
546
546
  let result = "";
547
547
  engineName ??= this.getEngineByFilePath(filePath);
548
- const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
548
+ const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
549
549
  const source = fs.readFileSync(filePath, "utf8");
550
550
  result = this.renderSync(source, data, engineName, templateRootPath, filePathOutput);
551
551
  return result;
@@ -558,10 +558,9 @@ var Ecto = class extends Hookified {
558
558
  * await ecto.ensureFilePath('/path/to/file.txt');
559
559
  */
560
560
  async ensureFilePath(path) {
561
- const pathList = path.split("/");
562
- pathList.pop();
563
- const directory = pathList.join("/");
564
- 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 });
565
564
  }
566
565
  /**
567
566
  * Synchronously ensure that the directory path for a file exists, creating it if necessary
@@ -571,10 +570,9 @@ var Ecto = class extends Hookified {
571
570
  * ecto.ensureFilePathSync('/path/to/file.txt');
572
571
  */
573
572
  ensureFilePathSync(path) {
574
- const pathList = path.split("/");
575
- pathList.pop();
576
- const directory = pathList.join("/");
577
- 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 });
578
576
  }
579
577
  /**
580
578
  * Determine the appropriate template engine based on a file's extension
@@ -586,7 +584,8 @@ var Ecto = class extends Hookified {
586
584
  getEngineByFilePath(filePath) {
587
585
  let result = this._defaultEngine;
588
586
  if (filePath !== void 0) {
589
- const extension = filePath.includes(".") ? filePath.slice(filePath.lastIndexOf(".") + 1) : "";
587
+ const { ext } = nodePath.parse(filePath);
588
+ const extension = ext.startsWith(".") ? ext.slice(1) : ext;
590
589
  const engExtension = this._mapping.getName(extension);
591
590
  if (engExtension !== void 0) result = engExtension;
592
591
  }
@@ -604,7 +603,7 @@ var Ecto = class extends Hookified {
604
603
  let result = "";
605
604
  const files = await fs.promises.readdir(path);
606
605
  for (const file of files) if (file.startsWith(`${templateName}.`)) {
607
- result = `${path}/${file}`;
606
+ result = nodePath.join(path, file);
608
607
  break;
609
608
  }
610
609
  return result;
@@ -621,7 +620,7 @@ var Ecto = class extends Hookified {
621
620
  let result = "";
622
621
  const files = fs.readdirSync(path);
623
622
  for (const file of files) if (file.startsWith(`${templateName}.`)) {
624
- result = `${path}/${file}`;
623
+ result = nodePath.join(path, file);
625
624
  break;
626
625
  }
627
626
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecto",
3
- "version": "5.0.0",
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",
@@ -42,30 +42,30 @@
42
42
  "liquidjs"
43
43
  ],
44
44
  "dependencies": {
45
- "@jaredwray/fumanchu": "^4.7.0",
46
- "cacheable": "^2.3.5",
45
+ "@jaredwray/fumanchu": "^4.7.2",
46
+ "cacheable": "^2.5.0",
47
47
  "ejs": "^6.0.1",
48
- "hookified": "^3.0.0",
49
- "liquidjs": "^10.27.0",
48
+ "hookified": "^3.0.2",
49
+ "liquidjs": "^10.29.0",
50
50
  "nunjucks": "^3.2.4",
51
51
  "pug": "^3.0.4",
52
- "writr": "^6.1.2"
52
+ "writr": "^6.1.5"
53
53
  },
54
54
  "devDependencies": {
55
- "@biomejs/biome": "^2.5.0",
56
- "@faker-js/faker": "^10.5.0",
55
+ "@biomejs/biome": "^2.5.9",
56
+ "@faker-js/faker": "^10.6.0",
57
57
  "@types/ejs": "^3.1.5",
58
- "@types/node": "^24.12.4",
58
+ "@types/node": "^24.13.3",
59
59
  "@types/nunjucks": "^3.2.6",
60
60
  "@types/pug": "^2.0.10",
61
- "@vitest/coverage-v8": "^4.1.9",
62
- "docula": "^2.0.0",
61
+ "@vitest/coverage-v8": "^4.1.11",
62
+ "docula": "^3.0.0",
63
63
  "rimraf": "^6.1.3",
64
- "tsdown": "^0.22.0",
65
- "typescript": "^6.0.3",
66
- "vite": "^8.0.16",
67
- "vitest": "^4.1.9",
68
- "wrangler": "^4.102.0"
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"
69
69
  },
70
70
  "files": [
71
71
  "dist",