@beforesemicolon/builder 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- "use strict";var E=Object.create;var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var P=(s,a)=>y(s,"name",{value:a,configurable:!0});var G=(s,a,t,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of $(a))!B.call(s,r)&&r!==t&&y(s,r,{get:()=>a[r],enumerable:!(e=_(a,r))||e.enumerable});return s};var c=(s,a,t)=>(t=s!=null?E(z(s)):{},G(a||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s));var A=require("marked"),o=require("fs/promises"),i=c(require("path"),1),F=c(require("front-matter"),1),k=c(require("isomorphic-dompurify"),1),O=require("marked-highlight"),M=c(require("highlight.js"),1),x=c(require("./templates/default.template.js"),1),T=c(require("./renderer/index.js"),1),W=c(require("clean-css"),1),L=c(require("html-minifier"),1),H=c(require("@putout/minify"),1);const J=new W.default,g=new Map;g.set("default",x.default);let b;const v=new A.Marked((0,O.markedHighlight)({langPrefix:"hljs language-",highlight(s,a){const t=M.default.getLanguage(a)?a:"plaintext";return M.default.highlight(s,{language:t}).value}}));v.use({renderer:T.default});const n=i.default.resolve(process.cwd(),"docs"),p=i.default.resolve(process.cwd(),"website"),Q=i.default.resolve(process.cwd(),"docs/_layouts"),D=i.default.resolve(process.cwd(),"docs/assets"),C=i.default.resolve(process.cwd(),"docs/stylesheets"),j=i.default.resolve(process.cwd(),"docs/scripts"),f=P(async s=>{const a=await(0,o.readdir)(s),t=[];for(const e of a){const r=i.default.extname(e);/^[._]/.test(e)||(r?t.push(i.default.join(s,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await f(i.default.join(s,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(s){const{layout:a="default",...t}=b.attributes;s=k.default.sanitize(s);const e=[...s.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(r=>({path:r[2],label:r[3],level:r[1]}));return g.get(a)?.({...t,content:s,siteMap:b.siteMap,tableOfContent:e})||s}}}),(async()=>{await(0,o.mkdir)(p,{recursive:!0});try{await(0,o.cp)(D,D.replace(n,p),{recursive:!0})}catch(t){console.warn(t)}try{const t=await f(C);t.length&&await(0,o.mkdir)(C.replace(n,p),{recursive:!0});for(const e of t){const r=await(0,o.readFile)(e,"utf-8");await(0,o.writeFile)(e.replace(n,p),J.minify(r).styles??r)}}catch(t){console.error(t)}try{const t=await f(j);t.length&&await(0,o.mkdir)(j.replace(n,p),{recursive:!0});for(const e of t)try{const r=await(0,o.readFile)(e,"utf-8");await(0,o.writeFile)(e.replace(n,p),H.minify(r))}catch(r){console.error(r)}}catch(t){console.warn(t)}try{const t=await f(Q);for(const e of t)if(/\.(j|t)s$/.test(e)){const r=i.default.basename(e).replace(i.default.extname(e),""),l=await import(e);g.set(r,l.default)}}catch(t){console.error("Template import failed",t)}const s=await f(n),a=new Map;(await Promise.all(s.filter(t=>t.endsWith(".md")).map(async t=>{const e=await(0,o.readFile)(t,"utf-8");return{filePath:t,...(0,F.default)(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:r})=>{const l=r.replace(n,"").replace(/\.md/,".html"),m=r.replace(n,p).replace(".md",".html"),h=m.replace(i.default.basename(m),""),d=i.default.basename(l)||"/",N=l.replace(d,"").replace(/\/$/,"");let u=a;N.split("/").filter(Boolean).forEach(w=>{u.has(w)||u.set(w,new Map),u=u.get(w)});const S={...t,path:l};return u.has(d)||u.set(d,S),{attributes:S,fileWebsitePath:m,fileDirWebsitePath:h,body:e,siteMap:a}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:r,fileWebsitePath:l,siteMap:m})=>{b={attributes:t,siteMap:m};const h=await v.parse(e);await(0,o.mkdir)(r,{recursive:!0}),await(0,o.writeFile)(l,L.default.minify(h,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
1
+ "use strict";var N=Object.create;var y=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var P=(s,o)=>y(s,"name",{value:o,configurable:!0});var B=(s,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of _(o))!z.call(s,r)&&r!==t&&y(s,r,{get:()=>o[r],enumerable:!(e=R(o,r))||e.enumerable});return s};var n=(s,o,t)=>(t=s!=null?N($(s)):{},B(o||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s));var A=require("marked"),a=require("fs/promises"),i=n(require("path"),1),F=n(require("front-matter"),1),k=n(require("isomorphic-dompurify"),1),O=require("marked-highlight"),M=n(require("highlight.js"),1),x=n(require("./templates/default.template.js"),1),T=n(require("./renderer/index.js"),1),W=n(require("clean-css"),1),E=n(require("html-minifier"),1),G=n(require("@putout/minify"),1);const H=new W.default({inline:["none"]}),g=new Map;g.set("default",x.default);let b;const v=new A.Marked((0,O.markedHighlight)({langPrefix:"hljs language-",highlight(s,o){const t=M.default.getLanguage(o)?o:"plaintext";return M.default.highlight(s,{language:t}).value}}));v.use({renderer:T.default});const l=i.default.resolve(process.cwd(),"docs"),p=i.default.resolve(process.cwd(),"website"),J=i.default.resolve(process.cwd(),"docs/_layouts"),D=i.default.resolve(process.cwd(),"docs/assets"),C=i.default.resolve(process.cwd(),"docs/stylesheets"),j=i.default.resolve(process.cwd(),"docs/scripts"),f=P(async s=>{const o=await(0,a.readdir)(s),t=[];for(const e of o){const r=i.default.extname(e);/^[._]/.test(e)||(r?t.push(i.default.join(s,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await f(i.default.join(s,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(s){const{layout:o="default",...t}=b.attributes;s=k.default.sanitize(s);const e=[...s.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(r=>({path:r[2],label:r[3],level:r[1]}));return g.get(o)?.({...t,content:s,siteMap:b.siteMap,tableOfContent:e})||s}}}),(async()=>{await(0,a.mkdir)(p,{recursive:!0});try{await(0,a.cp)(D,D.replace(l,p),{recursive:!0})}catch(t){console.warn(t)}try{const t=await f(C);t.length&&await(0,a.mkdir)(C.replace(l,p),{recursive:!0});for(const e of t){const r=await(0,a.readFile)(e,"utf-8"),c=H.minify(r);c.errors.length&&c.errors.forEach(console.error),await(0,a.writeFile)(e.replace(l,p),c.styles??r)}}catch(t){console.error(t)}try{const t=await f(j);t.length&&await(0,a.mkdir)(j.replace(l,p),{recursive:!0});for(const e of t)try{const r=await(0,a.readFile)(e,"utf-8");await(0,a.writeFile)(e.replace(l,p),G.minify(r))}catch(r){console.error(r)}}catch(t){console.warn(t)}try{const t=await f(J);for(const e of t)if(/\.(j|t)s$/.test(e)){const r=i.default.basename(e).replace(i.default.extname(e),""),c=await import(e);g.set(r,c.default)}}catch(t){console.error("Template import failed",t)}const s=await f(l),o=new Map;(await Promise.all(s.filter(t=>t.endsWith(".md")).map(async t=>{const e=await(0,a.readFile)(t,"utf-8");return{filePath:t,...(0,F.default)(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:r})=>{const c=r.replace(l,"").replace(/\.md/,".html"),m=r.replace(l,p).replace(".md",".html"),h=m.replace(i.default.basename(m),""),d=i.default.basename(c)||"/",L=c.replace(d,"").replace(/\/$/,"");let u=o;L.split("/").filter(Boolean).forEach(w=>{u.has(w)||u.set(w,new Map),u=u.get(w)});const S={...t,path:c};return u.has(d)||u.set(d,S),{attributes:S,fileWebsitePath:m,fileDirWebsitePath:h,body:e,siteMap:o}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:r,fileWebsitePath:c,siteMap:m})=>{b={attributes:t,siteMap:m};const h=await v.parse(e);await(0,a.mkdir)(r,{recursive:!0}),await(0,a.writeFile)(c,E.default.minify(h,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
@@ -1 +1 @@
1
- var F=Object.defineProperty;var S=(r,o)=>F(r,"name",{value:o,configurable:!0});import{Marked as k}from"marked";import{cp as O,mkdir as m,readdir as x,readFile as w,writeFile as y}from"fs/promises";import a from"path";import T from"front-matter";import W from"isomorphic-dompurify";import{markedHighlight as L}from"marked-highlight";import P from"highlight.js";import N from"./templates/default.template.js";import E from"./renderer/index.js";import _ from"clean-css";import $ from"html-minifier";import*as z from"@putout/minify";const B=new _,g=new Map;g.set("default",N);let b;const v=new k(L({langPrefix:"hljs language-",highlight(r,o){const t=P.getLanguage(o)?o:"plaintext";return P.highlight(r,{language:t}).value}}));v.use({renderer:E});const i=a.resolve(process.cwd(),"docs"),n=a.resolve(process.cwd(),"website"),G=a.resolve(process.cwd(),"docs/_layouts"),D=a.resolve(process.cwd(),"docs/assets"),C=a.resolve(process.cwd(),"docs/stylesheets"),j=a.resolve(process.cwd(),"docs/scripts"),u=S(async r=>{const o=await x(r),t=[];for(const e of o){const s=a.extname(e);/^[._]/.test(e)||(s?t.push(a.join(r,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await u(a.join(r,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(r){const{layout:o="default",...t}=b.attributes;r=W.sanitize(r);const e=[...r.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(s=>({path:s[2],label:s[3],level:s[1]}));return g.get(o)?.({...t,content:r,siteMap:b.siteMap,tableOfContent:e})||r}}}),(async()=>{await m(n,{recursive:!0});try{await O(D,D.replace(i,n),{recursive:!0})}catch(t){console.warn(t)}try{const t=await u(C);t.length&&await m(C.replace(i,n),{recursive:!0});for(const e of t){const s=await w(e,"utf-8");await y(e.replace(i,n),B.minify(s).styles??s)}}catch(t){console.error(t)}try{const t=await u(j);t.length&&await m(j.replace(i,n),{recursive:!0});for(const e of t)try{const s=await w(e,"utf-8");await y(e.replace(i,n),z.minify(s))}catch(s){console.error(s)}}catch(t){console.warn(t)}try{const t=await u(G);for(const e of t)if(/\.(j|t)s$/.test(e)){const s=a.basename(e).replace(a.extname(e),""),c=await import(e);g.set(s,c.default)}}catch(t){console.error("Template import failed",t)}const r=await u(i),o=new Map;(await Promise.all(r.filter(t=>t.endsWith(".md")).map(async t=>{const e=await w(t,"utf-8");return{filePath:t,...T(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:s})=>{const c=s.replace(i,"").replace(/\.md/,".html"),p=s.replace(i,n).replace(".md",".html"),f=p.replace(a.basename(p),""),h=a.basename(c)||"/",A=c.replace(h,"").replace(/\/$/,"");let l=o;A.split("/").filter(Boolean).forEach(d=>{l.has(d)||l.set(d,new Map),l=l.get(d)});const M={...t,path:c};return l.has(h)||l.set(h,M),{attributes:M,fileWebsitePath:p,fileDirWebsitePath:f,body:e,siteMap:o}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:s,fileWebsitePath:c,siteMap:p})=>{b={attributes:t,siteMap:p};const f=await v.parse(e);await m(s,{recursive:!0}),await y(c,$.minify(f,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
1
+ var F=Object.defineProperty;var S=(r,a)=>F(r,"name",{value:a,configurable:!0});import{Marked as k}from"marked";import{cp as O,mkdir as m,readdir as x,readFile as w,writeFile as y}from"fs/promises";import o from"path";import T from"front-matter";import W from"isomorphic-dompurify";import{markedHighlight as E}from"marked-highlight";import P from"highlight.js";import L from"./templates/default.template.js";import N from"./renderer/index.js";import R from"clean-css";import _ from"html-minifier";import*as $ from"@putout/minify";const z=new R({inline:["none"]}),g=new Map;g.set("default",L);let b;const v=new k(E({langPrefix:"hljs language-",highlight(r,a){const t=P.getLanguage(a)?a:"plaintext";return P.highlight(r,{language:t}).value}}));v.use({renderer:N});const c=o.resolve(process.cwd(),"docs"),n=o.resolve(process.cwd(),"website"),B=o.resolve(process.cwd(),"docs/_layouts"),D=o.resolve(process.cwd(),"docs/assets"),C=o.resolve(process.cwd(),"docs/stylesheets"),j=o.resolve(process.cwd(),"docs/scripts"),u=S(async r=>{const a=await x(r),t=[];for(const e of a){const s=o.extname(e);/^[._]/.test(e)||(s?t.push(o.join(r,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await u(o.join(r,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(r){const{layout:a="default",...t}=b.attributes;r=W.sanitize(r);const e=[...r.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(s=>({path:s[2],label:s[3],level:s[1]}));return g.get(a)?.({...t,content:r,siteMap:b.siteMap,tableOfContent:e})||r}}}),(async()=>{await m(n,{recursive:!0});try{await O(D,D.replace(c,n),{recursive:!0})}catch(t){console.warn(t)}try{const t=await u(C);t.length&&await m(C.replace(c,n),{recursive:!0});for(const e of t){const s=await w(e,"utf-8"),i=z.minify(s);i.errors.length&&i.errors.forEach(console.error),await y(e.replace(c,n),i.styles??s)}}catch(t){console.error(t)}try{const t=await u(j);t.length&&await m(j.replace(c,n),{recursive:!0});for(const e of t)try{const s=await w(e,"utf-8");await y(e.replace(c,n),$.minify(s))}catch(s){console.error(s)}}catch(t){console.warn(t)}try{const t=await u(B);for(const e of t)if(/\.(j|t)s$/.test(e)){const s=o.basename(e).replace(o.extname(e),""),i=await import(e);g.set(s,i.default)}}catch(t){console.error("Template import failed",t)}const r=await u(c),a=new Map;(await Promise.all(r.filter(t=>t.endsWith(".md")).map(async t=>{const e=await w(t,"utf-8");return{filePath:t,...T(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:s})=>{const i=s.replace(c,"").replace(/\.md/,".html"),p=s.replace(c,n).replace(".md",".html"),f=p.replace(o.basename(p),""),h=o.basename(i)||"/",A=i.replace(h,"").replace(/\/$/,"");let l=a;A.split("/").filter(Boolean).forEach(d=>{l.has(d)||l.set(d,new Map),l=l.get(d)});const M={...t,path:i};return l.has(h)||l.set(h,M),{attributes:M,fileWebsitePath:p,fileDirWebsitePath:f,body:e,siteMap:a}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:s,fileWebsitePath:i,siteMap:p})=>{b={attributes:t,siteMap:p};const f=await v.parse(e);await m(s,{recursive:!0}),await y(i,_.minify(f,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beforesemicolon/builder",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Utilities to build npm packages and documentation website",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"