From 704e27ba5631b310210cb88dd15022e4d11d385b Mon Sep 17 00:00:00 2001 From: akumar Date: Tue, 23 Apr 2024 16:23:07 +0200 Subject: [PATCH] fix: update handlebars helperized es module now and fix for file import issue --- package-lock.json | 36 ++++++++++++++++++------------------ package.json | 2 +- src/service.ts | 7 +++++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 030b6db..c6f574b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@restorecommerce/chassis-srv": "^1.6.0", "@restorecommerce/cluster-service": "^1.0.3", "@restorecommerce/grpc-client": "^2.2.1", - "@restorecommerce/handlebars-helperized": "^1.0.11", + "@restorecommerce/handlebars-helperized": "^1.3.0", "@restorecommerce/kafka-client": "^1.2.1", "@restorecommerce/logger": "^1.2.10", "@restorecommerce/service-config": "^1.0.12", @@ -2689,19 +2689,19 @@ } }, "node_modules/@restorecommerce/handlebars-helperized": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@restorecommerce/handlebars-helperized/-/handlebars-helperized-1.0.11.tgz", - "integrity": "sha512-DhTeWK5yYkI7H/WmtHWrjQ35N0cmo2hBM0H3dhGkV3pGPF9NB8tKYf6kF0lSiI3PoNV86KlRrgPi8ni5WHH+Og==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@restorecommerce/handlebars-helperized/-/handlebars-helperized-1.3.0.tgz", + "integrity": "sha512-IWuKz491VBroN/gSmlnEFiw4yaC+ZyA4/0kqrJyjJhFqnYCm/SDR+x6i0KyHurlwF5V+2wrKukxe/IbnuHF4+A==", "dependencies": { "handlebars": "^4.7.8", "handlebars-layouts": "^3.1.4", "juice": "^10.0.0", - "lodash.defaults": "4.2.0", + "lodash-es": "^4.17.21", "moment-timezone": "^0.5.45", - "numbro": "^2.4.0" + "numbro": "^2.5.0" }, "engines": { - "node": ">= 8.0.0" + "node": ">= 16.0.0" } }, "node_modules/@restorecommerce/kafka-client": { @@ -13312,9 +13312,9 @@ } }, "node_modules/numbro": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.4.0.tgz", - "integrity": "sha512-t6rVkO1CcKvffvOJJu/zMo70VIcQSR6w3AmIhfHGvmk4vHbNe6zHgomB0aWFAPZWM9JBVWBM0efJv9DBiRoSTA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.5.0.tgz", + "integrity": "sha512-xDcctDimhzko/e+y+Q2/8i3qNC9Svw1QgOkSkQoO0kIPI473tR9QRbo2KP88Ty9p8WbPy+3OpTaAIzehtuHq+A==", "dependencies": { "bignumber.js": "^8 || ^9" }, @@ -23416,16 +23416,16 @@ } }, "@restorecommerce/handlebars-helperized": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@restorecommerce/handlebars-helperized/-/handlebars-helperized-1.0.11.tgz", - "integrity": "sha512-DhTeWK5yYkI7H/WmtHWrjQ35N0cmo2hBM0H3dhGkV3pGPF9NB8tKYf6kF0lSiI3PoNV86KlRrgPi8ni5WHH+Og==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@restorecommerce/handlebars-helperized/-/handlebars-helperized-1.3.0.tgz", + "integrity": "sha512-IWuKz491VBroN/gSmlnEFiw4yaC+ZyA4/0kqrJyjJhFqnYCm/SDR+x6i0KyHurlwF5V+2wrKukxe/IbnuHF4+A==", "requires": { "handlebars": "^4.7.8", "handlebars-layouts": "^3.1.4", "juice": "^10.0.0", - "lodash.defaults": "4.2.0", + "lodash-es": "^4.17.21", "moment-timezone": "^0.5.45", - "numbro": "^2.4.0" + "numbro": "^2.5.0" } }, "@restorecommerce/kafka-client": { @@ -31480,9 +31480,9 @@ } }, "numbro": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.4.0.tgz", - "integrity": "sha512-t6rVkO1CcKvffvOJJu/zMo70VIcQSR6w3AmIhfHGvmk4vHbNe6zHgomB0aWFAPZWM9JBVWBM0efJv9DBiRoSTA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/numbro/-/numbro-2.5.0.tgz", + "integrity": "sha512-xDcctDimhzko/e+y+Q2/8i3qNC9Svw1QgOkSkQoO0kIPI473tR9QRbo2KP88Ty9p8WbPy+3OpTaAIzehtuHq+A==", "requires": { "bignumber.js": "^8 || ^9" } diff --git a/package.json b/package.json index e59141e..04652ca 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@restorecommerce/chassis-srv": "^1.6.0", "@restorecommerce/cluster-service": "^1.0.3", "@restorecommerce/grpc-client": "^2.2.1", - "@restorecommerce/handlebars-helperized": "^1.0.11", + "@restorecommerce/handlebars-helperized": "^1.3.0", "@restorecommerce/kafka-client": "^1.2.1", "@restorecommerce/logger": "^1.2.10", "@restorecommerce/service-config": "^1.0.12", diff --git a/src/service.ts b/src/service.ts index 1f0cc4b..4832f42 100644 --- a/src/service.ts +++ b/src/service.ts @@ -58,8 +58,10 @@ export class Service { // read all file names from the handlebars folder let absolutePath: string; for (let file of fs.readdirSync(HANDLEBARS_DIR)) { - absolutePath = CURR_DIR + REL_PATH_HANDLEBARS + file; - customHelpersList.push(absolutePath); + if (file.endsWith('.cjs')) { + absolutePath = CURR_DIR + REL_PATH_HANDLEBARS + file; + customHelpersList.push(absolutePath); + } } await this.subscribeTopics(); @@ -209,6 +211,7 @@ export class Service { } let rendered; try { + await tplRenderer?.waitLoad(); rendered = tplRenderer.render(data); // rendered HTML string } catch (err) { this.logger.error('Error while rendering template:', template);