@beforesemicolon/builder 1.1.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
package/dist/cjs/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
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}))})})();
|
File without changes
|
package/dist/esm/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var
|
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/dist/types/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
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.
|
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"
|
@@ -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",
|