@beforesemicolon/builder 1.6.5 → 1.7.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/dist/cjs/docs/run.js +1 -1
- package/dist/esm/docs/run.js +1 -1
- package/dist/types/docs/run.d.ts +4 -3
- package/package.json +4 -4
package/dist/cjs/docs/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var z=Object.create;var h=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var v=(t,r)=>h(t,"name",{value:r,configurable:!0});var q=(t,r)=>{for(var o in r)h(t,o,{get:r[o],enumerable:!0})},O=(t,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of H(r))!Q.call(t,a)&&a!==o&&h(t,a,{get:()=>r[a],enumerable:!(s=G(r,a))||s.enumerable});return t};var u=(t,r,o)=>(o=t!=null?z(J(t)):{},O(r||!t||!t.__esModule?h(o,"default",{value:t,enumerable:!0}):o,t)),I=t=>O(h({},"__esModule",{value:!0}),t);var X={};q(X,{buildDocs:()=>V});module.exports=I(X);var A=require("marked"),n=require("fs/promises"),c=u(require("path"),1),F=u(require("front-matter"),1),E=u(require("isomorphic-dompurify"),1),T=require("marked-highlight"),S=u(require("highlight.js"),1),W=u(require("./templates/default.template.js"),1),B=u(require("./renderer/index.js"),1),L=u(require("clean-css"),1),N=u(require("html-minifier"),1),K=u(require("@putout/minify"),1);const U=new L.default({inline:["none"]}),M=new Map;M.set("default",W.default);let D;const w=new A.Marked((0,T.markedHighlight)({langPrefix:"hljs language-",highlight(t,r){const o=S.default.getLanguage(r)?r:"plaintext";return S.default.highlight(t,{language:o}).value}}));w.use({renderer:B.default});const d=v(async t=>{const r=await(0,n.readdir)(t),o=[];for(const s of r){const a=c.default.extname(s);/^[._]/.test(s)||(a?o.push(c.default.join(t,s)):/(stylesheets|assets|scripts)/.test(s)||o.push(...await d(c.default.join(t,s))))}return o},"traverseDirectory");w.use({hooks:{postprocess(t){const{layout:r="default",...o}=D.attributes;t=E.default.sanitize(t);const s=[...t.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(a=>({path:a[2],label:a[3],level:a[1]}));return M.get(r)?.({...o,content:t,siteMap:D.siteMap,tableOfContent:s})||t}}});const V=v(async({srcDir:t,publicDir:r,markedOptions:o}={})=>{o&&w.use(o);const s=t??c.default.resolve(process.cwd(),"docs"),a=r??c.default.resolve(process.cwd(),"website"),R=c.default.resolve(s,"_layouts"),P=c.default.resolve(s,"assets"),C=c.default.resolve(s,"stylesheets"),x=c.default.resolve(s,"scripts");await(0,n.mkdir)(a,{recursive:!0});try{await(0,n.cp)(P,P.replace(s,a),{recursive:!0})}catch(e){console.warn(e)}try{const e=await d(C);e.length&&await(0,n.mkdir)(C.replace(s,a),{recursive:!0});for(const i of e){const l=await(0,n.readFile)(i,"utf-8"),p=U.minify(l);p.errors.length&&p.errors.forEach(console.error),await(0,n.writeFile)(i.replace(s,a),p.styles??l)}}catch(e){console.error(e)}try{const e=await d(x);e.length&&await(0,n.mkdir)(x.replace(s,a),{recursive:!0});for(const i of e)try{const l=await(0,n.readFile)(i,"utf-8");await(0,n.writeFile)(i.replace(s,a),K.minify(l))}catch(l){console.error(l)}}catch(e){console.warn(e)}try{const e=await d(R);for(const i of e)if(/\.(j|t)s$/.test(i)){const l=c.default.basename(i).replace(c.default.extname(i),""),p=await import(i);M.set(l,p.default)}}catch(e){console.error("Template import failed",e)}const _=await d(s),j=new Map;(await Promise.all(_.filter(e=>e.endsWith(".md")).map(async e=>{const i=await(0,n.readFile)(e,"utf-8");return{filePath:e,...(0,F.default)(i)}}))).sort((e,i)=>e.attributes.order-i.attributes.order).map(({attributes:e,body:i,filePath:l})=>{const p=l.replace(s,"").replace(/\.md/,".html"),f=l.replace(s,a).replace(".md",".html"),y=f.replace(c.default.basename(f),""),g=c.default.basename(p)||"/",$=p.replace(g,"").replace(/\/$/,"");let m=j;$.split("/").filter(Boolean).forEach(b=>{m.has(b)||m.set(b,new Map),m=m.get(b)});const k={...e,path:p};return m.has(g)||m.set(g,k),{attributes:k,fileWebsitePath:f,fileDirWebsitePath:y,body:i,siteMap:j}}).forEach(async({attributes:e,body:i,fileDirWebsitePath:l,fileWebsitePath:p,siteMap:f})=>{D={attributes:e,siteMap:f};const y=await w.parse(i);await(0,n.mkdir)(l,{recursive:!0}),await(0,n.writeFile)(p,N.default.minify(y,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})},"buildDocs");0&&(module.exports={buildDocs});
|
package/dist/esm/docs/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var g=(r,c)=>E(r,"name",{value:c,configurable:!0});import{Marked as T}from"marked";import{cp as W,mkdir as f,readdir as B,readFile as b,writeFile as v}from"fs/promises";import i from"path";import L from"front-matter";import N from"isomorphic-dompurify";import{markedHighlight as R}from"marked-highlight";import k from"highlight.js";import _ from"./templates/default.template.js";import $ from"./renderer/index.js";import z from"clean-css";import G from"html-minifier";import*as H from"@putout/minify";const J=new z({inline:["none"]}),M=new Map;M.set("default",_);let D;const h=new T(R({langPrefix:"hljs language-",highlight(r,c){const l=k.getLanguage(c)?c:"plaintext";return k.highlight(r,{language:l}).value}}));h.use({renderer:$});const m=g(async r=>{const c=await B(r),l=[];for(const e of c){const o=i.extname(e);/^[._]/.test(e)||(o?l.push(i.join(r,e)):/(stylesheets|assets|scripts)/.test(e)||l.push(...await m(i.join(r,e))))}return l},"traverseDirectory");h.use({hooks:{postprocess(r){const{layout:c="default",...l}=D.attributes;r=N.sanitize(r);const e=[...r.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(o=>({path:o[2],label:o[3],level:o[1]}));return M.get(c)?.({...l,content:r,siteMap:D.siteMap,tableOfContent:e})||r}}});const ct=g(async({srcDir:r,publicDir:c,markedOptions:l}={})=>{l&&h.use(l);const e=r??i.resolve(process.cwd(),"docs"),o=c??i.resolve(process.cwd(),"website"),O=i.resolve(e,"_layouts"),S=i.resolve(e,"assets"),P=i.resolve(e,"stylesheets"),C=i.resolve(e,"scripts");await f(o,{recursive:!0});try{await W(S,S.replace(e,o),{recursive:!0})}catch(t){console.warn(t)}try{const t=await m(P);t.length&&await f(P.replace(e,o),{recursive:!0});for(const s of t){const a=await b(s,"utf-8"),n=J.minify(a);n.errors.length&&n.errors.forEach(console.error),await v(s.replace(e,o),n.styles??a)}}catch(t){console.error(t)}try{const t=await m(C);t.length&&await f(C.replace(e,o),{recursive:!0});for(const s of t)try{const a=await b(s,"utf-8");await v(s.replace(e,o),H.minify(a))}catch(a){console.error(a)}}catch(t){console.warn(t)}try{const t=await m(O);for(const s of t)if(/\.(j|t)s$/.test(s)){const a=i.basename(s).replace(i.extname(s),""),n=await import(s);M.set(a,n.default)}}catch(t){console.error("Template import failed",t)}const A=await m(e),x=new Map;(await Promise.all(A.filter(t=>t.endsWith(".md")).map(async t=>{const s=await b(t,"utf-8");return{filePath:t,...L(s)}}))).sort((t,s)=>t.attributes.order-s.attributes.order).map(({attributes:t,body:s,filePath:a})=>{const n=a.replace(e,"").replace(/\.md/,".html"),u=a.replace(e,o).replace(".md",".html"),d=u.replace(i.basename(u),""),w=i.basename(n)||"/",F=n.replace(w,"").replace(/\/$/,"");let p=x;F.split("/").filter(Boolean).forEach(y=>{p.has(y)||p.set(y,new Map),p=p.get(y)});const j={...t,path:n};return p.has(w)||p.set(w,j),{attributes:j,fileWebsitePath:u,fileDirWebsitePath:d,body:s,siteMap:x}}).forEach(async({attributes:t,body:s,fileDirWebsitePath:a,fileWebsitePath:n,siteMap:u})=>{D={attributes:t,siteMap:u};const d=await h.parse(s);await f(a,{recursive:!0}),await v(n,G.minify(d,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})},"buildDocs");export{ct as buildDocs};
|
package/dist/types/docs/run.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { MarkedExtension } from 'marked';
|
|
2
|
+
export interface BuildDocsOptions {
|
|
2
3
|
publicDir?: string;
|
|
3
4
|
srcDir?: string;
|
|
5
|
+
markedOptions?: MarkedExtension;
|
|
4
6
|
}
|
|
5
|
-
export declare const buildDocs: ({ srcDir, publicDir, }?: BuildDocsOptions) => Promise<void>;
|
|
6
|
-
export {};
|
|
7
|
+
export declare const buildDocs: ({ srcDir, publicDir, markedOptions }?: BuildDocsOptions) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beforesemicolon/builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Utilities to build npm packages and documentation website",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"type": "github"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gjsify/esbuild-plugin-transform-ext": "0.
|
|
42
|
+
"@gjsify/esbuild-plugin-transform-ext": "0.3.13",
|
|
43
43
|
"@putout/minify": "^4.7.2",
|
|
44
44
|
"clean-css": "^5.3.3",
|
|
45
45
|
"core-js": "^3.34.0",
|
|
46
|
-
"esbuild": "^0.
|
|
46
|
+
"esbuild": "^0.28.0",
|
|
47
47
|
"esbuild-plugin-text-replace": "^1.3.0",
|
|
48
48
|
"front-matter": "^4.0.2",
|
|
49
49
|
"global-jsdom": "^9.2.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"eslint-plugin-promise": "^6.1.1",
|
|
74
74
|
"nodemon": "^3.1.7",
|
|
75
75
|
"npm-run-all": "^4.1.5",
|
|
76
|
-
"prettier": "3.
|
|
76
|
+
"prettier": "3.8.3",
|
|
77
77
|
"tinybench": "^2.8.0",
|
|
78
78
|
"ts-jest": "^29.1.1",
|
|
79
79
|
"tsx": "^4.7.0",
|