@beforesemicolon/builder 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1 +1 @@
1
- "use strict";var L=Object.create;var w=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var P=(e,r)=>w(e,"name",{value:r,configurable:!0});var z=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of T(r))!$.call(e,a)&&a!==t&&w(e,a,{get:()=>r[a],enumerable:!(s=N(r,a))||s.enumerable});return e};var p=(e,r,t)=>(t=e!=null?L(_(e)):{},z(r||!e||!e.__esModule?w(t,"default",{value:e,enumerable:!0}):t,e));var k=require("marked"),i=require("fs/promises"),o=p(require("path"),1),x=p(require("front-matter"),1),C=p(require("isomorphic-dompurify"),1),F=require("marked-highlight"),v=p(require("highlight.js"),1),W=p(require("./templates/default.template.js"),1),A=p(require("./renderer/index.js"),1);const g=new Map;g.set("default",W.default);let y;const M=new k.Marked((0,F.markedHighlight)({langPrefix:"hljs language-",highlight(e,r){const t=v.default.getLanguage(r)?r:"plaintext";return v.default.highlight(e,{language:t}).value}}));M.use({renderer:A.default});const l=o.default.resolve(process.cwd(),"docs"),m=o.default.resolve(process.cwd(),"website"),B=o.default.resolve(process.cwd(),"docs/_layouts"),S=o.default.resolve(process.cwd(),"docs/assets"),O=o.default.resolve(process.cwd(),"docs/stylesheets"),j=o.default.resolve(process.cwd(),"docs/scripts"),b=P(async e=>{const r=await(0,i.readdir)(e),t=[];for(const s of r){const a=o.default.extname(s);/^[._]/.test(s)||(a?t.push(o.default.join(e,s)):/(stylesheets|assets|scripts)/.test(s)||t.push(...await b(o.default.join(e,s))))}return t},"traverseDirectory");M.use({hooks:{postprocess(e){const{layout:r="default",...t}=y.attributes;e=C.default.sanitize(e);const s=[...e.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(a=>({path:a[2],label:a[3],level:a[1]}));return g.get(r)?.({...t,content:e,siteMap:y.siteMap,tableOfContent:s})||e}}}),(async()=>{await(0,i.mkdir)(m,{recursive:!0});try{await(0,i.cp)(S,S.replace(l,m),{recursive:!0})}catch(t){console.warn(t)}try{await(0,i.cp)(O,O.replace(l,m),{recursive:!0})}catch(t){console.warn(t)}try{await(0,i.cp)(j,j.replace(l,m),{recursive:!0})}catch(t){console.warn(t)}try{const t=await b(B);for(const s of t)if(/\.(j|t)s$/.test(s)){const a=o.default.basename(s).replace(o.default.extname(s),""),c=await import(s);g.set(a,c.default)}}catch(t){console.error("Template import failed",t)}const e=await b(l),r=new Map;(await Promise.all(e.filter(t=>t.endsWith(".md")).map(async t=>{const s=await(0,i.readFile)(t,"utf-8");return{filePath:t,...(0,x.default)(s)}}))).sort((t,s)=>t.attributes.order-s.attributes.order).map(({attributes:t,body:s,filePath:a})=>{const c=a.replace(l,"").replace(/\.md/,".html"),u=a.replace(l,m).replace(".md",".html"),f=u.replace(o.default.basename(u),""),d=o.default.basename(c)||"/",E=c.replace(d,"").replace(/\/$/,"");let n=r;E.split("/").filter(Boolean).forEach(h=>{n.has(h)||n.set(h,new Map),n=n.get(h)});const D={...t,path:c};return n.has(d)||n.set(d,D),{attributes:D,fileWebsitePath:u,fileDirWebsitePath:f,body:s,siteMap:r}}).forEach(async({attributes:t,body:s,fileDirWebsitePath:a,fileWebsitePath:c,siteMap:u})=>{y={attributes:t,siteMap:u};const f=await M.parse(s);await(0,i.mkdir)(a,{recursive:!0}),await(0,i.writeFile)(c,f)})})();
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}))})})();
File without changes
@@ -1 +1 @@
1
- var k=Object.defineProperty;var b=(s,o)=>k(s,"name",{value:o,configurable:!0});import{Marked as x}from"marked";import{cp as d,mkdir as v,readdir as C,readFile as F,writeFile as W}from"fs/promises";import r from"path";import A from"front-matter";import E from"isomorphic-dompurify";import{markedHighlight as L}from"marked-highlight";import D from"highlight.js";import N from"./templates/default.template.js";import T from"./renderer/index.js";const h=new Map;h.set("default",N);let w;const g=new x(L({langPrefix:"hljs language-",highlight(s,o){const t=D.getLanguage(o)?o:"plaintext";return D.highlight(s,{language:t}).value}}));g.use({renderer:T});const n=r.resolve(process.cwd(),"docs"),l=r.resolve(process.cwd(),"website"),_=r.resolve(process.cwd(),"docs/_layouts"),P=r.resolve(process.cwd(),"docs/assets"),S=r.resolve(process.cwd(),"docs/stylesheets"),O=r.resolve(process.cwd(),"docs/scripts"),y=b(async s=>{const o=await C(s),t=[];for(const e of o){const a=r.extname(e);/^[._]/.test(e)||(a?t.push(r.join(s,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await y(r.join(s,e))))}return t},"traverseDirectory");g.use({hooks:{postprocess(s){const{layout:o="default",...t}=w.attributes;s=E.sanitize(s);const e=[...s.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(a=>({path:a[2],label:a[3],level:a[1]}));return h.get(o)?.({...t,content:s,siteMap:w.siteMap,tableOfContent:e})||s}}}),(async()=>{await v(l,{recursive:!0});try{await d(P,P.replace(n,l),{recursive:!0})}catch(t){console.warn(t)}try{await d(S,S.replace(n,l),{recursive:!0})}catch(t){console.warn(t)}try{await d(O,O.replace(n,l),{recursive:!0})}catch(t){console.warn(t)}try{const t=await y(_);for(const e of t)if(/\.(j|t)s$/.test(e)){const a=r.basename(e).replace(r.extname(e),""),i=await import(e);h.set(a,i.default)}}catch(t){console.error("Template import failed",t)}const s=await y(n),o=new Map;(await Promise.all(s.filter(t=>t.endsWith(".md")).map(async t=>{const e=await F(t,"utf-8");return{filePath:t,...A(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:a})=>{const i=a.replace(n,"").replace(/\.md/,".html"),p=a.replace(n,l).replace(".md",".html"),u=p.replace(r.basename(p),""),m=r.basename(i)||"/",j=i.replace(m,"").replace(/\/$/,"");let c=o;j.split("/").filter(Boolean).forEach(f=>{c.has(f)||c.set(f,new Map),c=c.get(f)});const M={...t,path:i};return c.has(m)||c.set(m,M),{attributes:M,fileWebsitePath:p,fileDirWebsitePath:u,body:e,siteMap:o}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:a,fileWebsitePath:i,siteMap:p})=>{w={attributes:t,siteMap:p};const u=await g.parse(e);await v(a,{recursive:!0}),await W(i,u)})})();
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,3 +1,3 @@
1
- export * from "./build-modules.ts";
2
- export * from "./build-browser.ts";
3
- export * from "./docs/run.ts";
1
+ export * from './build-modules.ts';
2
+ export * from './build-browser.ts';
3
+ export * from './docs/run.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beforesemicolon/builder",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Utilities to build npm packages and documentation website",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
@@ -29,18 +29,23 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@gjsify/esbuild-plugin-transform-ext": "0.0.4",
32
+ "@putout/minify": "^4.7.2",
33
+ "clean-css": "^5.3.3",
32
34
  "core-js": "^3.34.0",
33
35
  "esbuild": "^0.19.10",
34
36
  "esbuild-plugin-text-replace": "^1.3.0",
35
37
  "front-matter": "^4.0.2",
36
38
  "global-jsdom": "^9.2.0",
37
39
  "highlight.js": "^11.10.0",
40
+ "html-minifier": "^4.0.0",
38
41
  "isomorphic-dompurify": "^2.16.0",
39
42
  "jsdom": "^23.0.1",
40
43
  "marked": "^14.1.2",
41
44
  "marked-highlight": "^2.1.4"
42
45
  },
43
46
  "devDependencies": {
47
+ "@types/clean-css": "^4.2.11",
48
+ "@types/html-minifier": "^4.0.5",
44
49
  "@types/jest": "^29.5.11",
45
50
  "@types/jsdom": "^21.1.6",
46
51
  "@types/jsdom-global": "^3.0.7",
@@ -55,9 +60,9 @@
55
60
  "eslint-plugin-n": "^16.5.0",
56
61
  "eslint-plugin-prettier": "^5.1.2",
57
62
  "eslint-plugin-promise": "^6.1.1",
63
+ "nodemon": "^3.1.7",
58
64
  "npm-run-all": "^4.1.5",
59
65
  "prettier": "3.1.1",
60
- "nodemon": "^3.1.7",
61
66
  "tinybench": "^2.8.0",
62
67
  "ts-jest": "^29.1.1",
63
68
  "tsx": "^4.7.0",