Skip to content

Commit 3552ce8

Browse files
chore(deps): bump eta from 2.2.0 to 4.0.1 (#1414)
* chore(deps): bump eta from 2.2.0 to 4.0.1 Bumps [eta](https://github.com/bgub/eta) from 2.2.0 to 4.0.1. - [Release notes](https://github.com/bgub/eta/releases) - [Changelog](https://github.com/bgub/eta/blob/main/CHANGELOG.md) - [Commits](bgub/eta@v2.2.0...eta-v4.0.1) --- updated-dependencies: - dependency-name: eta dependency-version: 4.0.1 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Update `renderTemplate` for eta v4 Signed-off-by: Sora Morimoto <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Sora Morimoto <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sora Morimoto <[email protected]>
1 parent 99524ff commit 3552ce8

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"c12": "^3.2.0",
5454
"citty": "^0.1.6",
5555
"consola": "^3.4.2",
56-
"eta": "^2.2.0",
56+
"eta": "^4.0.1",
5757
"js-yaml": "^4.1.0",
5858
"lodash": "^4.17.21",
5959
"nanoid": "^5.1.5",

src/templates-worker.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import * as module from "node:module";
22
import * as path from "node:path";
33
import * as url from "node:url";
44
import { consola } from "consola";
5-
import * as Eta from "eta";
5+
import { Eta } from "eta";
66
import lodash from "lodash";
77
import type { CodeGenProcess } from "./code-gen-process.js";
88
import type { CodeGenConfig } from "./configuration.js";
99
import type { FileSystem } from "./util/file-system.js";
1010

1111
const require = module.createRequire(import.meta.url);
1212

13+
const eta = new Eta({
14+
functionHeader: "const includeFile = options.includeFile;",
15+
});
16+
1317
export class TemplatesWorker {
1418
config: CodeGenConfig;
1519
fileSystem: FileSystem;
@@ -214,31 +218,20 @@ export class TemplatesWorker {
214218

215219
renderTemplate = (
216220
template: string,
217-
configuration: object,
218-
options: object = {},
221+
configuration: Record<string, unknown>,
219222
) => {
220223
if (!template) return "";
221224

222-
return Eta.render(
223-
template,
225+
return eta.render(
226+
eta.compile(template, { async: false }),
224227
{
225228
...this.getRenderTemplateData(),
226229
...configuration,
227230
},
228231
{
229-
async: false,
230-
...options,
231-
includeFile: (
232-
path: string,
233-
configuration: object,
234-
options: object = {},
235-
) => {
236-
return this.renderTemplate(
237-
this.getTemplateContent(path),
238-
configuration,
239-
options,
240-
);
241-
},
232+
// @ts-expect-error eta's meta options lack includeFile despite runtime support
233+
includeFile: (path: string, configuration: Record<string, string>) =>
234+
this.renderTemplate(this.getTemplateContent(path), configuration),
242235
},
243236
);
244237
};

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,10 +2060,10 @@ __metadata:
20602060
languageName: node
20612061
linkType: hard
20622062

2063-
"eta@npm:^2.2.0":
2064-
version: 2.2.0
2065-
resolution: "eta@npm:2.2.0"
2066-
checksum: 10c0/643b54d9539d2761bf6c5f4f48df1a5ea2d46c7f5a5fdc47a7d4802a8aa2b6262d4d61f724452e226c18cf82db02d48e65293fcc548f26a3f9d75a5ba7c3b859
2063+
"eta@npm:^4.0.1":
2064+
version: 4.0.1
2065+
resolution: "eta@npm:4.0.1"
2066+
checksum: 10c0/a7dc8641705a01373393aba6d0998f7571735c4f5444aa9c3375b2574a93ef3be80cfd5c7d1f8d6f0e56a83a14a7db451195ed3ceeab145f23492bb5b41d1ece
20672067
languageName: node
20682068
linkType: hard
20692069

@@ -3777,7 +3777,7 @@ __metadata:
37773777
c12: "npm:^3.2.0"
37783778
citty: "npm:^0.1.6"
37793779
consola: "npm:^3.4.2"
3780-
eta: "npm:^2.2.0"
3780+
eta: "npm:^4.0.1"
37813781
js-yaml: "npm:^4.1.0"
37823782
lodash: "npm:^4.17.21"
37833783
nanoid: "npm:^5.1.5"

0 commit comments

Comments
 (0)