@keycloakify/angular-email 1.0.9 → 1.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/bin/build.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{angularEsbuildPlugin as h}from"@keycloakify/angular-email/esbuild";import y from"esbuild";import{readdir as w,rm as d,writeFile as P}from"node:fs/promises";import{basename as v,join as g,resolve as u}from"node:path";import{cwd as c,exit as p}from"node:process";import{pathToFileURL as x}from"node:url";async function E(a,t,n,i=[]){const e=await y.build({entryPoints:a,bundle:!0,splitting:!0,outdir:n,absWorkingDir:t,platform:"node",sourcemap:!0,packages:"bundle",external:["juice",...i],format:"esm",outExtension:{".js":".mjs"},target:"node20",plugins:[h(t)],metafile:!0});return Object.entries(e.metafile.outputs).reduce((l,[o,r])=>(r.entryPoint&&(l[u(t,r.entryPoint)]=x(u(t,o)).toString()),l),{})}async function F(a,t){try{const n=async e=>{const l=await w(e,{withFileTypes:!0}),o=[];for(const r of l)r.isFile()?o.push(r):r.isDirectory()&&o.push(...await n(g(r.parentPath,r.name)));return o};return(await n(a)).map(e=>g(e.parentPath,e.name)).filter(e=>t?t(e):!0)}catch(n){throw console.error(`Error scanning directory: ${n.message}`),n}}const U=async(a,t="dist/emails",n=[])=>{a||(console.error("emailFilesPath is required!"),p(1));try{console.log(`building emails to ${t}...`);const i=g(c(),t,".tmp");await d(t,{recursive:!0,force:!0});const e=await F(u(c(),a),s=>s.endsWith(".ts"));e.length||(console.error("no templates found!"),p(1));const l=[...e],o=await E(l,c(),i,n),r=e.map(async s=>{const m=o[s]??o[u(c(),s)];if(!m)throw new Error(`Failed to locate bundled URL for "${s}". Ensure getTemplates() returns absolute paths and esbuild.metafile entryPoint mapping uses the same base.`);const b=await import(m);return console.log(`- ${s}`),{...b,file:s}}),f=await Promise.all(r);for(const s of f){const m=await s.renderToHtml();await P(`${t}/${v(s.file).split(".")[0]}.html`,m)}await d(i,{recursive:!0,force:!0}),console.log("\x1B[36m%s\x1B[0m","build complete!"),p(0)}catch(i){console.error(i),p(1)}};export{U as build};
package/bin/main.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{exit as o}from"node:process";import{termost as l}from"termost";import n from"../package.json"with{type:"json"};import{build as r}from"./build.js";const t=l({name:"keycloakify-angular-email",description:"Keycloakify CLI",version:n.version,onException:e=>{console.error(e),o(1)}});t.option({key:"emailFilesPath",name:{long:"emailFilesPath",short:"p"},description:"input directory for angular email components",defaultValue:""}),t.option({key:"outDir",name:{long:"outDir",short:"o"},description:"output directory for generated html",defaultValue:"dist/emails"}),t.option({key:"externals",name:{long:"externals",short:"e"},description:"Comma-separated packages to mark as external in esbuild (e.g. tailwindcss,postcss,postcss-calc)",defaultValue:""}),t.command({name:"build",description:"build angular components to html"}).input({key:"emailFilesPath",type:"text",defaultValue:void 0,label:"what's the path of your email components files?",skip(e){return!!e.emailFilesPath}}).input({key:"outDir",type:"text",defaultValue:"dist/emails",label:"where do you want to output html files?",skip(e){return!!e.outDir}}).input({key:"externals",type:"text",label:"any additional package to mark as external (comma separated)?",skip(){return!0}}).task({handler:async e=>{let a=[];e.externals&&(a=e.externals.split(",").map(i=>i.trim()).filter(Boolean)),await r(e.emailFilesPath,e.outDir,a)}});