From 4a9a3eae4df50483f139502d33872c2ef6d9e0d7 Mon Sep 17 00:00:00 2001 From: Mintu Gogoi <127925465+utnim2@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:59:54 +0530 Subject: [PATCH] feat: add scripts that on release will publish transpiled template to npm (#575) --- package.json | 6 +++++- scripts/transpile.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 scripts/transpile.js diff --git a/package.json b/package.json index b9fcdc736..aa69f52a6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ ], "author": "Fran Mendez (fmvilas.com)", "license": "Apache-2.0", + "files": [ + "__transpiled" + ], "repository": { "type": "git", "url": "git+https://github.com/asyncapi/html-template.git" @@ -30,7 +33,8 @@ "generate:readme:toc": "markdown-toc -i README.md", "bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION", "copy:sources": "node ./scripts/copy-sources.js", - "prepublishOnly": "npm run generate:assets", + "prepublishOnly": "npm run generate:assets && npm run transpile", + "transpile": "node ./scripts/transpile.js", "test": "npm run test:library && npm run test:generator" }, "publishConfig": { diff --git a/scripts/transpile.js b/scripts/transpile.js new file mode 100644 index 000000000..371c72d79 --- /dev/null +++ b/scripts/transpile.js @@ -0,0 +1,16 @@ +const { transpileFiles } = require("@asyncapi/generator-react-sdk"); +const path = require("path"); + +async function transpileTemplate() { + try { + const templateContentDir = path.join(__dirname, "../template"); + console.log("Template content directory:", templateContentDir); + const outputDir = path.join(__dirname, "../__transpiled"); + console.log("Output directory for transpiled files:", outputDir); + await transpileFiles(templateContentDir, outputDir, { recursive: true }); + } catch (error) { + console.log("Error during template transpilation:", err) + } +} + +transpileTemplate();