@san-siva/blogkit-md-cli 0.1.19 → 0.1.21
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/diagnostics/route-bundle-stats.json +4 -4
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/[...slug]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/ssr/_0lv77ha._.js +1 -1
- package/.next/server/chunks/ssr/_0lv77ha._.js.map +1 -1
- package/.next/server/chunks/ssr/_0z4n825._.js +1 -1
- package/.next/server/chunks/ssr/_0z4n825._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/07f5bg23~zyn-.css +1 -0
- package/.next/static/chunks/{0mr~5~notxy69.js → 0bgomtoptb4q7.js} +1 -1
- package/.next/static/chunks/{15yu-awv-.t~z.js → 10t4l336soqlc.js} +1 -1
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/README.md +37 -2
- package/bin/blogkit-md.js +389 -46
- package/package.json +21 -6
- package/.next/static/chunks/0qlnhpdra7.h4.css +0 -1
- /package/.next/static/{m7wm4BjeEBuAMzrKArK94 → N6e_l60Njhp5bsxU4aIBS}/_buildManifest.js +0 -0
- /package/.next/static/{m7wm4BjeEBuAMzrKArK94 → N6e_l60Njhp5bsxU4aIBS}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{m7wm4BjeEBuAMzrKArK94 → N6e_l60Njhp5bsxU4aIBS}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,74578,e=>{"use strict";e.s(["default",0,{"margin-top--1":"CodeBlock-module_margin-top--1__mApFz","margin-bottom--2":"CodeBlock-module_margin-bottom--2__fz9IX","code-block":"CodeBlock-module_code-block__ah1AG","code-block__wrapper":"CodeBlock-module_code-block__wrapper__-IUGO","code-block__header":"CodeBlock-module_code-block__header__93VEU","code-block__header__title":"CodeBlock-module_code-block__header__title__xxZgC","code-block__header__actions":"CodeBlock-module_code-block__header__actions__vClnL","code-block__header__expand":"CodeBlock-module_code-block__header__expand__PBJlP","code-block__header__expand--collapse":"CodeBlock-module_code-block__header__expand--collapse__93Kth","code-block__header__copy":"CodeBlock-module_code-block__header__copy__NCWSg","code-block__header__copy--active":"CodeBlock-module_code-block__header__copy--active__5ByAp","code-block__modal":"CodeBlock-module_code-block__modal__nNvcI","code-block__modal__content":"CodeBlock-module_code-block__modal__content__qWuic","code-block__modal__wrapper":"CodeBlock-module_code-block__modal__wrapper__me6hC","code-block--static":"CodeBlock-module_code-block--static__1gBzz"}])},54316,e=>{"use strict";var l=e.i(71645);let o=e=>null==e||"boolean"==typeof e?"":"string"==typeof e||"number"==typeof e?String(e):(0,l.isValidElement)(e)?o(e.props.children):Array.isArray(e)?e.map(o).join(""):"";e.s(["extractTextFromReactNode",0,o,"generateIdForBlogTitle",0,e=>e.toLowerCase().replace(/[^\w\d]/g,"-"),"generateSectionHref",0,e=>`?section=${e}`,"generateUrlForBlogTitle",0,e=>encodeURIComponent(e.replace(/[^\w]+/g,"-").toLowerCase())])},32553,e=>{"use strict";e.s(["default",0,{"blog-link":"BlogLink-module_blog-link__X09yI","blog-link__title":"BlogLink-module_blog-link__title__mXr5D","blog-link__description":"BlogLink-module_blog-link__description__Ctack","blog-link__read-more":"BlogLink-module_blog-link__read-more__N1OuD"}])},45705,e=>{"use strict";e.s(["default",0,{"margin-bottom--3":"Blog-module_margin-bottom--3__ir35O",category__header:"Blog-module_category__header__F1K0V",blog:"Blog-module_blog__Lpv6Z",blog__content:"Blog-module_blog__content__RMDiY",blog__sidebar:"Blog-module_blog__sidebar__uSu3l"}])},98336,e=>{"use strict";e.s(["default",0,{"blog-section":"BlogSection-module_blog-section__NTDM4","blog-section__title":"BlogSection-module_blog-section__title__5-4Oy","blog-section__title--empty":"BlogSection-module_blog-section__title--empty__-di-F","blog-section__title-link":"BlogSection-module_blog-section__title-link__Q4R5T"}])},3994,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(45705);let c=({children:e,jsonLd:o})=>(0,l.jsxs)("div",{className:t.default.blog,children:[o&&(0,l.jsx)("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(o)}}),(0,l.jsx)("div",{className:t.default.blog__content,children:e})]}),a=(0,o.lazy)(()=>e.A(30717));e.s(["default",0,({children:e,title:t="In this article",jsonLd:s})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(c,{jsonLd:s,children:e}),children:(0,l.jsx)(a,{title:t,jsonLd:s,children:e})})],3994)},46720,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(98336),c=e.i(54316);let a=({title:e="",category:o="",children:a=null})=>{let s="string"==typeof e?e:(0,c.extractTextFromReactNode)(e),_=o?`${o} - ${s}`:s,i=(0,c.generateIdForBlogTitle)(_);return(0,l.jsxs)("div",{className:t.default["blog-section"],"data-title":s,"data-id":i,children:[e?(0,l.jsx)("h3",{className:t.default["blog-section__title"],children:e}):null,a]})},s=(0,o.lazy)(()=>e.A(51011)),_=(0,o.forwardRef)(({title:e="",category:t="",children:c=null},_)=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(a,{title:e,category:t,children:c}),children:(0,l.jsx)(s,{ref:_,title:e,category:t,children:c})}));_.displayName="BlogSection",e.s(["default",0,_],46720)},83854,e=>{"use strict";var l=e.i(43476),o=e.i(74578);e.s(["default",0,({language:e="javascript",code:t="",hasMarginUp:c=!1,hasMarginDown:a=!1})=>(0,l.jsxs)("div",{className:`${o.default["code-block"]} ${c?o.default["margin-top--1"]:""} ${a?o.default["margin-bottom--2"]:""} ${o.default["code-block--static"]}`,children:[(0,l.jsx)("div",{className:o.default["code-block__header"],children:(0,l.jsx)("div",{className:o.default["code-block__header__title"],children:e})}),(0,l.jsx)("div",{className:o.default["code-block__wrapper"],children:(0,l.jsx)("pre",{children:(0,l.jsx)("code",{children:t})})})]})])},40419,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(83854);let c=(0,o.lazy)(()=>e.A(68272));e.s(["default",0,({language:e="javascript",code:a="",hasMarginUp:s=!1,hasMarginDown:_=!1})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(t.default,{language:e,code:a,hasMarginUp:s,hasMarginDown:_}),children:(0,l.jsx)(c,{language:e,code:a,hasMarginUp:s,hasMarginDown:_})})])},3659,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(83854);let c=({code:e="",id:o="",hasMarginUp:c=!1,hasMarginDown:a=!1})=>(0,l.jsx)(t.default,{language:"mermaid",code:e,hasMarginUp:c,hasMarginDown:a}),a=(0,o.lazy)(()=>e.A(5654));e.s(["default",0,({code:e="",id:t="",hasMarginUp:s=!1,hasMarginDown:_=!1})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(c,{code:e,id:t,hasMarginUp:s,hasMarginDown:_}),children:(0,l.jsx)(a,{code:e,id:t,hasMarginUp:s,hasMarginDown:_})})],3659)},59760,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(32553),c=e.i(54316);let a=({title:e="",desc:o="",isInProgress:a=!1,href:s})=>{let _=s||`/blog/${(0,c.generateUrlForBlogTitle)(e)}`;return a?null:(0,l.jsxs)("a",{className:t.default["blog-link"],href:_,rel:"noopener noreferrer",children:[(0,l.jsx)("h6",{className:t.default["blog-link__title"],children:e}),(0,l.jsx)("p",{className:t.default["blog-link__description"],children:o}),(0,l.jsxs)("div",{className:t.default["blog-link__read-more"],children:[(0,l.jsx)("p",{children:"Read More"}),(0,l.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",stroke:"transparent",children:[(0,l.jsx)("line",{x1:"5",y1:"12",y2:"12",x2:"18"}),(0,l.jsx)("polyline",{points:"12 5, 19 12, 12 19"})]})]})]})},s=(0,o.lazy)(()=>e.A(51594));e.s(["default",0,({title:e="",desc:t="",isInProgress:c=!1,href:_})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(a,{title:e,desc:t,isInProgress:c,href:_}),children:(0,l.jsx)(s,{title:e,desc:t,isInProgress:c,href:_})})],59760)},18566,(e,l,o)=>{l.exports=e.r(76562)},48753,e=>{"use strict";var l=e.i(71645),o=e.i(18566);e.s(["LiveReload",0,()=>{let e=(0,o.useRouter)();return(0,l.useEffect)(()=>{let l=0,o=new EventSource("/api/sse");return o.
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,74578,e=>{"use strict";e.s(["default",0,{"margin-top--1":"CodeBlock-module_margin-top--1__mApFz","margin-bottom--2":"CodeBlock-module_margin-bottom--2__fz9IX","code-block":"CodeBlock-module_code-block__ah1AG","code-block__wrapper":"CodeBlock-module_code-block__wrapper__-IUGO","code-block__header":"CodeBlock-module_code-block__header__93VEU","code-block__header__title":"CodeBlock-module_code-block__header__title__xxZgC","code-block__header__actions":"CodeBlock-module_code-block__header__actions__vClnL","code-block__header__expand":"CodeBlock-module_code-block__header__expand__PBJlP","code-block__header__expand--collapse":"CodeBlock-module_code-block__header__expand--collapse__93Kth","code-block__header__copy":"CodeBlock-module_code-block__header__copy__NCWSg","code-block__header__copy--active":"CodeBlock-module_code-block__header__copy--active__5ByAp","code-block__modal":"CodeBlock-module_code-block__modal__nNvcI","code-block__modal__content":"CodeBlock-module_code-block__modal__content__qWuic","code-block__modal__wrapper":"CodeBlock-module_code-block__modal__wrapper__me6hC","code-block--static":"CodeBlock-module_code-block--static__1gBzz"}])},54316,e=>{"use strict";var l=e.i(71645);let o=e=>null==e||"boolean"==typeof e?"":"string"==typeof e||"number"==typeof e?String(e):(0,l.isValidElement)(e)?o(e.props.children):Array.isArray(e)?e.map(o).join(""):"";e.s(["extractTextFromReactNode",0,o,"generateIdForBlogTitle",0,e=>e.toLowerCase().replace(/[^\w\d]/g,"-"),"generateSectionHref",0,e=>`?section=${e}`,"generateUrlForBlogTitle",0,e=>encodeURIComponent(e.replace(/[^\w]+/g,"-").toLowerCase())])},32553,e=>{"use strict";e.s(["default",0,{"blog-link":"BlogLink-module_blog-link__X09yI","blog-link__title":"BlogLink-module_blog-link__title__mXr5D","blog-link__description":"BlogLink-module_blog-link__description__Ctack","blog-link__read-more":"BlogLink-module_blog-link__read-more__N1OuD"}])},45705,e=>{"use strict";e.s(["default",0,{"margin-bottom--3":"Blog-module_margin-bottom--3__ir35O",category__header:"Blog-module_category__header__F1K0V",blog:"Blog-module_blog__Lpv6Z",blog__content:"Blog-module_blog__content__RMDiY",blog__sidebar:"Blog-module_blog__sidebar__uSu3l"}])},98336,e=>{"use strict";e.s(["default",0,{"blog-section":"BlogSection-module_blog-section__NTDM4","blog-section__title":"BlogSection-module_blog-section__title__5-4Oy","blog-section__title--empty":"BlogSection-module_blog-section__title--empty__-di-F","blog-section__title-link":"BlogSection-module_blog-section__title-link__Q4R5T"}])},3994,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(45705);let c=({children:e,jsonLd:o})=>(0,l.jsxs)("div",{className:t.default.blog,children:[o&&(0,l.jsx)("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(o)}}),(0,l.jsx)("div",{className:t.default.blog__content,children:e})]}),a=(0,o.lazy)(()=>e.A(30717));e.s(["default",0,({children:e,title:t="In this article",jsonLd:s})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(c,{jsonLd:s,children:e}),children:(0,l.jsx)(a,{title:t,jsonLd:s,children:e})})],3994)},46720,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(98336),c=e.i(54316);let a=({title:e="",category:o="",children:a=null})=>{let s="string"==typeof e?e:(0,c.extractTextFromReactNode)(e),_=o?`${o} - ${s}`:s,i=(0,c.generateIdForBlogTitle)(_);return(0,l.jsxs)("div",{className:t.default["blog-section"],"data-title":s,"data-id":i,children:[e?(0,l.jsx)("h3",{className:t.default["blog-section__title"],children:e}):null,a]})},s=(0,o.lazy)(()=>e.A(51011)),_=(0,o.forwardRef)(({title:e="",category:t="",children:c=null},_)=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(a,{title:e,category:t,children:c}),children:(0,l.jsx)(s,{ref:_,title:e,category:t,children:c})}));_.displayName="BlogSection",e.s(["default",0,_],46720)},83854,e=>{"use strict";var l=e.i(43476),o=e.i(74578);e.s(["default",0,({language:e="javascript",code:t="",hasMarginUp:c=!1,hasMarginDown:a=!1})=>(0,l.jsxs)("div",{className:`${o.default["code-block"]} ${c?o.default["margin-top--1"]:""} ${a?o.default["margin-bottom--2"]:""} ${o.default["code-block--static"]}`,children:[(0,l.jsx)("div",{className:o.default["code-block__header"],children:(0,l.jsx)("div",{className:o.default["code-block__header__title"],children:e})}),(0,l.jsx)("div",{className:o.default["code-block__wrapper"],children:(0,l.jsx)("pre",{children:(0,l.jsx)("code",{children:t})})})]})])},40419,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(83854);let c=(0,o.lazy)(()=>e.A(68272));e.s(["default",0,({language:e="javascript",code:a="",hasMarginUp:s=!1,hasMarginDown:_=!1})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(t.default,{language:e,code:a,hasMarginUp:s,hasMarginDown:_}),children:(0,l.jsx)(c,{language:e,code:a,hasMarginUp:s,hasMarginDown:_})})])},3659,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(83854);let c=({code:e="",id:o="",hasMarginUp:c=!1,hasMarginDown:a=!1})=>(0,l.jsx)(t.default,{language:"mermaid",code:e,hasMarginUp:c,hasMarginDown:a}),a=(0,o.lazy)(()=>e.A(5654));e.s(["default",0,({code:e="",id:t="",hasMarginUp:s=!1,hasMarginDown:_=!1})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(c,{code:e,id:t,hasMarginUp:s,hasMarginDown:_}),children:(0,l.jsx)(a,{code:e,id:t,hasMarginUp:s,hasMarginDown:_})})],3659)},59760,e=>{"use strict";var l=e.i(43476),o=e.i(71645),t=e.i(32553),c=e.i(54316);let a=({title:e="",desc:o="",isInProgress:a=!1,href:s})=>{let _=s||`/blog/${(0,c.generateUrlForBlogTitle)(e)}`;return a?null:(0,l.jsxs)("a",{className:t.default["blog-link"],href:_,rel:"noopener noreferrer",children:[(0,l.jsx)("h6",{className:t.default["blog-link__title"],children:e}),(0,l.jsx)("p",{className:t.default["blog-link__description"],children:o}),(0,l.jsxs)("div",{className:t.default["blog-link__read-more"],children:[(0,l.jsx)("p",{children:"Read More"}),(0,l.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",stroke:"transparent",children:[(0,l.jsx)("line",{x1:"5",y1:"12",y2:"12",x2:"18"}),(0,l.jsx)("polyline",{points:"12 5, 19 12, 12 19"})]})]})]})},s=(0,o.lazy)(()=>e.A(51594));e.s(["default",0,({title:e="",desc:t="",isInProgress:c=!1,href:_})=>(0,l.jsx)(o.Suspense,{fallback:(0,l.jsx)(a,{title:e,desc:t,isInProgress:c,href:_}),children:(0,l.jsx)(s,{title:e,desc:t,isInProgress:c,href:_})})],59760)},18566,(e,l,o)=>{l.exports=e.r(76562)},48753,e=>{"use strict";var l=e.i(71645),o=e.i(18566);e.s(["LiveReload",0,()=>{let e=(0,o.useRouter)();return(0,l.useEffect)(()=>{let l=0,o=new EventSource("/api/sse");return o.addEventListener("message",()=>e.refresh()),o.addEventListener("error",()=>{++l>=5&&o.close()}),()=>o.close()},[e]),null}])},30717,e=>{e.v(l=>Promise.all(["static/chunks/0jzkkq0_apnpz.js","static/chunks/0o-12r~dnkh_q.js"].map(l=>e.l(l))).then(()=>l(21613)))},51011,e=>{e.v(l=>Promise.all(["static/chunks/0293yz9lzw.y1.js"].map(l=>e.l(l))).then(()=>l(840)))},68272,e=>{e.v(l=>Promise.all(["static/chunks/10p7z219t13oj.js","static/chunks/059hf5gl4p3c..css"].map(l=>e.l(l))).then(()=>l(19591)))},5654,e=>{e.v(l=>Promise.all(["static/chunks/0qc7zyk9rgkk5.js","static/chunks/0_o1-srxg1yey.js"].map(l=>e.l(l))).then(()=>l(71488)))},51594,e=>{e.v(l=>Promise.all(["static/chunks/0mobuv_zc1g6~.js","static/chunks/0o-12r~dnkh_q.js"].map(l=>e.l(l))).then(()=>l(55178)))}]);
|
package/.next/trace
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"generate-buildid","duration":
|
|
1
|
+
[{"name":"generate-buildid","duration":187,"timestamp":923583174454,"id":4,"parentId":1,"tags":{},"startTime":1780903906226,"traceId":"fbb771c88713c2ca"},{"name":"load-custom-routes","duration":305,"timestamp":923583174723,"id":5,"parentId":1,"tags":{},"startTime":1780903906227,"traceId":"fbb771c88713c2ca"},{"name":"create-dist-dir","duration":229,"timestamp":923583175048,"id":6,"parentId":1,"tags":{},"startTime":1780903906227,"traceId":"fbb771c88713c2ca"},{"name":"clean","duration":195,"timestamp":923583175935,"id":7,"parentId":1,"tags":{},"startTime":1780903906228,"traceId":"fbb771c88713c2ca"},{"name":"discover-routes","duration":2141,"timestamp":923583184717,"id":8,"parentId":1,"tags":{},"startTime":1780903906237,"traceId":"fbb771c88713c2ca"},{"name":"create-root-mapping","duration":32,"timestamp":923583186883,"id":9,"parentId":1,"tags":{},"startTime":1780903906239,"traceId":"fbb771c88713c2ca"},{"name":"generate-route-types","duration":9905,"timestamp":923583187368,"id":10,"parentId":1,"tags":{},"startTime":1780903906239,"traceId":"fbb771c88713c2ca"},{"name":"public-dir-conflict-check","duration":48,"timestamp":923583197309,"id":11,"parentId":1,"tags":{},"startTime":1780903906249,"traceId":"fbb771c88713c2ca"},{"name":"generate-routes-manifest","duration":984,"timestamp":923583197403,"id":12,"parentId":1,"tags":{},"startTime":1780903906249,"traceId":"fbb771c88713c2ca"},{"name":"run-turbopack","duration":5725848,"timestamp":923583199937,"id":14,"parentId":1,"tags":{},"startTime":1780903906252,"traceId":"fbb771c88713c2ca"},{"name":"turbopack-build-events","duration":33,"timestamp":923583280498,"id":15,"parentId":1,"tags":{},"startTime":1780903906332,"traceId":"fbb771c88713c2ca"},{"name":"run-typescript","duration":786480,"timestamp":923588944931,"id":16,"parentId":1,"tags":{},"startTime":1780903911997,"traceId":"fbb771c88713c2ca"},{"name":"generate-required-server-files","duration":376,"timestamp":923589732239,"id":18,"parentId":1,"tags":{},"startTime":1780903912784,"traceId":"fbb771c88713c2ca"},{"name":"check-static-error-page","duration":2796,"timestamp":923589737254,"id":20,"parentId":19,"tags":{},"startTime":1780903912789,"traceId":"fbb771c88713c2ca"},{"name":"is-page-static","duration":98326,"timestamp":923589740233,"id":27,"parentId":22,"tags":{},"startTime":1780903912792,"traceId":"fbb771c88713c2ca"},{"name":"check-page","duration":100305,"timestamp":923589738304,"id":22,"parentId":19,"tags":{"page":"/_global-error"},"startTime":1780903912790,"traceId":"fbb771c88713c2ca"},{"name":"is-page-static","duration":120451,"timestamp":923589740123,"id":26,"parentId":21,"tags":{},"startTime":1780903912792,"traceId":"fbb771c88713c2ca"},{"name":"check-page","duration":122977,"timestamp":923589737627,"id":21,"parentId":19,"tags":{"page":"/_not-found"},"startTime":1780903912789,"traceId":"fbb771c88713c2ca"},{"name":"is-page-static","duration":121439,"timestamp":923589741268,"id":28,"parentId":24,"tags":{},"startTime":1780903912793,"traceId":"fbb771c88713c2ca"},{"name":"check-page","duration":122926,"timestamp":923589739799,"id":24,"parentId":19,"tags":{"page":"/api/sse"},"startTime":1780903912792,"traceId":"fbb771c88713c2ca"},{"name":"is-page-static","duration":137392,"timestamp":923589742199,"id":30,"parentId":25,"tags":{},"startTime":1780903912794,"traceId":"fbb771c88713c2ca"},{"name":"check-page","duration":139680,"timestamp":923589739938,"id":25,"parentId":19,"tags":{"page":"/"},"startTime":1780903912792,"traceId":"fbb771c88713c2ca"},{"name":"is-page-static","duration":138187,"timestamp":923589742162,"id":29,"parentId":23,"tags":{},"startTime":1780903912794,"traceId":"fbb771c88713c2ca"},{"name":"check-page","duration":141919,"timestamp":923589738442,"id":23,"parentId":19,"tags":{"page":"/[...slug]"},"startTime":1780903912790,"traceId":"fbb771c88713c2ca"},{"name":"static-check","duration":143344,"timestamp":923589737030,"id":19,"parentId":1,"tags":{},"startTime":1780903912789,"traceId":"fbb771c88713c2ca"},{"name":"write-routes-manifest","duration":351,"timestamp":923589881186,"id":32,"parentId":1,"tags":{},"startTime":1780903912933,"traceId":"fbb771c88713c2ca"},{"name":"load-dotenv","duration":9,"timestamp":923589886019,"id":35,"parentId":34,"tags":{},"startTime":1780903912938,"traceId":"fbb771c88713c2ca"},{"name":"run-export-path-map","duration":135,"timestamp":923589886967,"id":36,"parentId":34,"tags":{},"startTime":1780903912939,"traceId":"fbb771c88713c2ca"},{"name":"next-export","duration":121416,"timestamp":923589885664,"id":34,"parentId":1,"tags":{},"startTime":1780903912937,"traceId":"fbb771c88713c2ca"},{"name":"move-exported-app-not-found-","duration":330,"timestamp":923590007558,"id":37,"parentId":33,"tags":{},"startTime":1780903913059,"traceId":"fbb771c88713c2ca"},{"name":"move-exported-app-global-error-","duration":243,"timestamp":923590007917,"id":38,"parentId":33,"tags":{},"startTime":1780903913060,"traceId":"fbb771c88713c2ca"},{"name":"static-generation","duration":125911,"timestamp":923589882933,"id":33,"parentId":1,"tags":{},"startTime":1780903912935,"traceId":"fbb771c88713c2ca"},{"name":"write-routes-manifest","duration":130,"timestamp":923590008885,"id":39,"parentId":1,"tags":{},"startTime":1780903913061,"traceId":"fbb771c88713c2ca"},{"name":"print-tree-view","duration":876,"timestamp":923590011107,"id":40,"parentId":1,"tags":{},"startTime":1780903913063,"traceId":"fbb771c88713c2ca"},{"name":"write-route-bundle-stats","duration":2519,"timestamp":923590011994,"id":41,"parentId":1,"tags":{},"startTime":1780903913064,"traceId":"fbb771c88713c2ca"},{"name":"telemetry-flush","duration":496935,"timestamp":923590014523,"id":42,"parentId":1,"tags":{},"startTime":1780903913066,"traceId":"fbb771c88713c2ca"},{"name":"next-build","duration":8475764,"timestamp":923582035758,"id":1,"tags":{"buildMode":"default","version":"16.2.1","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1780903905088,"traceId":"fbb771c88713c2ca"}]
|
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-turbopack","duration":
|
|
1
|
+
[{"name":"run-turbopack","duration":5725848,"timestamp":923583199937,"id":14,"parentId":1,"tags":{},"startTime":1780903906252,"traceId":"fbb771c88713c2ca"},{"name":"turbopack-build-events","duration":33,"timestamp":923583280498,"id":15,"parentId":1,"tags":{},"startTime":1780903906332,"traceId":"fbb771c88713c2ca"},{"name":"run-typescript","duration":786480,"timestamp":923588944931,"id":16,"parentId":1,"tags":{},"startTime":1780903911997,"traceId":"fbb771c88713c2ca"},{"name":"static-check","duration":143344,"timestamp":923589737030,"id":19,"parentId":1,"tags":{},"startTime":1780903912789,"traceId":"fbb771c88713c2ca"},{"name":"static-generation","duration":125911,"timestamp":923589882933,"id":33,"parentId":1,"tags":{},"startTime":1780903912935,"traceId":"fbb771c88713c2ca"},{"name":"telemetry-flush","duration":496935,"timestamp":923590014523,"id":42,"parentId":1,"tags":{},"startTime":1780903913066,"traceId":"fbb771c88713c2ca"},{"name":"next-build","duration":8475764,"timestamp":923582035758,"id":1,"tags":{"buildMode":"default","version":"16.2.1","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1780903905088,"traceId":"fbb771c88713c2ca"}]
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install -g @san-siva/blogkit-md-cli
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
blogkit-md <path-to-markdown-file-or-directory> [
|
|
19
|
+
blogkit-md <path-to-markdown-file-or-directory> [options]
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
### Arguments
|
|
@@ -24,7 +24,19 @@ blogkit-md <path-to-markdown-file-or-directory> [--port=<port>]
|
|
|
24
24
|
| Argument | Description |
|
|
25
25
|
| --------------- | ------------------------------------------------------------------------------------------ |
|
|
26
26
|
| `<path>` | Path to a markdown file, or a directory containing markdown files (scanned recursively) |
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
### Options
|
|
29
|
+
|
|
30
|
+
| Option | Description |
|
|
31
|
+
| ---------------------- | ---------------------------------------------------------------------------------------- |
|
|
32
|
+
| `--port=<port>` | Port to run the preview server on (default: random free port) |
|
|
33
|
+
| `-b`, `--background` | Run the preview server detached in the background |
|
|
34
|
+
| `-r`, `--reuse` | If this path is already being served, just open it in the browser instead of starting |
|
|
35
|
+
| `-l`, `--list` | Interactively list running instances and stop any of them |
|
|
36
|
+
| `-h`, `--help` | Show help |
|
|
37
|
+
|
|
38
|
+
If you try to preview a path that already has a running instance, you'll be
|
|
39
|
+
prompted to stop the existing one (or pass `--reuse` to just open it).
|
|
28
40
|
|
|
29
41
|
### Examples
|
|
30
42
|
|
|
@@ -37,10 +49,33 @@ blogkit-md ./posts
|
|
|
37
49
|
|
|
38
50
|
# Preview on a specific port
|
|
39
51
|
blogkit-md ./posts/my-post.md --port=3001
|
|
52
|
+
|
|
53
|
+
# Run detached in the background
|
|
54
|
+
blogkit-md ./posts --background
|
|
55
|
+
|
|
56
|
+
# Re-open a path that's already being served
|
|
57
|
+
blogkit-md ./posts --reuse
|
|
58
|
+
|
|
59
|
+
# List running instances and stop one interactively
|
|
60
|
+
blogkit-md --list
|
|
40
61
|
```
|
|
41
62
|
|
|
42
63
|
The browser will open automatically once the server is ready. The preview reloads whenever you save changes to the markdown file (or any markdown file under the directory).
|
|
43
64
|
|
|
65
|
+
### Managing background instances
|
|
66
|
+
|
|
67
|
+
Running instances are tracked in `~/.blogkit-md/instances.json` (background logs
|
|
68
|
+
live under `~/.blogkit-md/logs/`). Use `blogkit-md --list` to see what's running
|
|
69
|
+
and select an instance to stop it:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
blogkit-md · running instances
|
|
73
|
+
|
|
74
|
+
❯ localhost:3001 📁 ~/posts pid 12345 · 4m bg
|
|
75
|
+
|
|
76
|
+
↑/↓ move ⏎ stop selected q quit
|
|
77
|
+
```
|
|
78
|
+
|
|
44
79
|
## Requirements
|
|
45
80
|
|
|
46
81
|
- Node.js >= 18.0.0
|
package/bin/blogkit-md.js
CHANGED
|
@@ -22,64 +22,360 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
|
|
25
|
-
// scripts/
|
|
26
|
-
var import_node_http = require("http");
|
|
25
|
+
// scripts/cli.ts
|
|
27
26
|
var import_node_child_process = require("child_process");
|
|
28
27
|
var import_node_fs = require("fs");
|
|
28
|
+
var import_node_http = require("http");
|
|
29
|
+
var import_node_os = __toESM(require("os"));
|
|
29
30
|
var import_node_path = __toESM(require("path"));
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
var import_node_readline = __toESM(require("readline"));
|
|
32
|
+
var useColor = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
33
|
+
var paint = (code) => (s) => useColor ? `\x1B[${code}m${s}\x1B[0m` : s;
|
|
34
|
+
var c = {
|
|
35
|
+
bold: paint("1"),
|
|
36
|
+
dim: paint("2"),
|
|
37
|
+
red: paint("31"),
|
|
38
|
+
green: paint("32"),
|
|
39
|
+
yellow: paint("33"),
|
|
40
|
+
blue: paint("34"),
|
|
41
|
+
magenta: paint("35"),
|
|
42
|
+
cyan: paint("36"),
|
|
43
|
+
gray: paint("90")
|
|
44
|
+
};
|
|
45
|
+
var INDENT = " ".repeat(3);
|
|
46
|
+
var line = (s = "") => console.log(INDENT + s);
|
|
47
|
+
var tree = (s = "") => console.log(c.gray(INDENT + "\u2502 ") + s);
|
|
48
|
+
var bannerShown = false;
|
|
49
|
+
function banner() {
|
|
50
|
+
if (bannerShown) return;
|
|
51
|
+
bannerShown = true;
|
|
52
|
+
line();
|
|
53
|
+
line(c.bold(c.blue("blogkit-md")));
|
|
54
|
+
line(c.gray("preview markdown as blogkit blog posts"));
|
|
55
|
+
line();
|
|
37
56
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
var tilde = (p) => {
|
|
58
|
+
const home = import_node_os.default.homedir();
|
|
59
|
+
return p.startsWith(home) ? "~" + p.slice(home.length) : p;
|
|
60
|
+
};
|
|
61
|
+
function humanAge(iso) {
|
|
62
|
+
const start = Date.parse(iso);
|
|
63
|
+
if (Number.isNaN(start)) return "\u2014";
|
|
64
|
+
const secs = Math.max(0, Math.floor((Date.now() - start) / 1e3));
|
|
65
|
+
if (secs < 60) return `${secs}s`;
|
|
66
|
+
if (secs < 3600) return `${Math.floor(secs / 60)}m`;
|
|
67
|
+
if (secs < 86400) return `${Math.floor(secs / 3600)}h`;
|
|
68
|
+
return `${Math.floor(secs / 86400)}d`;
|
|
69
|
+
}
|
|
70
|
+
function openBrowser(url) {
|
|
71
|
+
if (process.env.BLOGKIT_MD_NO_OPEN) return;
|
|
72
|
+
try {
|
|
73
|
+
(0, import_node_child_process.exec)(`open ${url}`);
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
var registryDir = () => process.env.BLOGKIT_MD_DIR || import_node_path.default.join(import_node_os.default.homedir(), ".blogkit-md");
|
|
78
|
+
var registryFile = () => import_node_path.default.join(registryDir(), "instances.json");
|
|
79
|
+
var logDir = () => import_node_path.default.join(registryDir(), "logs");
|
|
80
|
+
var isAlive = (pid) => {
|
|
81
|
+
try {
|
|
82
|
+
process.kill(pid, 0);
|
|
83
|
+
return true;
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function readRegistry() {
|
|
89
|
+
try {
|
|
90
|
+
const raw = JSON.parse((0, import_node_fs.readFileSync)(registryFile(), "utf8"));
|
|
91
|
+
return Array.isArray(raw) ? raw : [];
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function writeRegistry(list) {
|
|
97
|
+
try {
|
|
98
|
+
(0, import_node_fs.mkdirSync)(registryDir(), { recursive: true });
|
|
99
|
+
(0, import_node_fs.writeFileSync)(registryFile(), JSON.stringify(list, null, 2));
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function pruneRegistry() {
|
|
104
|
+
const all = readRegistry();
|
|
105
|
+
const live = all.filter((index) => isAlive(index.pid));
|
|
106
|
+
if (live.length !== all.length) writeRegistry(live);
|
|
107
|
+
return live;
|
|
108
|
+
}
|
|
109
|
+
function addInstance(inst) {
|
|
110
|
+
const list = pruneRegistry().filter((index) => index.pid !== inst.pid);
|
|
111
|
+
list.push(inst);
|
|
112
|
+
writeRegistry(list);
|
|
113
|
+
}
|
|
114
|
+
function removeInstance(pid) {
|
|
115
|
+
writeRegistry(readRegistry().filter((index) => index.pid !== pid));
|
|
116
|
+
}
|
|
117
|
+
function findByDir(dir) {
|
|
118
|
+
return pruneRegistry().find((index) => index.dir === dir);
|
|
119
|
+
}
|
|
120
|
+
function killInstance(inst) {
|
|
121
|
+
try {
|
|
122
|
+
process.kill(inst.pid, "SIGTERM");
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
removeInstance(inst.pid);
|
|
126
|
+
}
|
|
127
|
+
function instanceLabel(inst) {
|
|
128
|
+
const kind = inst.isDirectory ? "\u{1F4C1}" : "\u{1F4C4}";
|
|
129
|
+
const mode = inst.background ? c.magenta("bg") : c.gray("fg");
|
|
130
|
+
return `${c.green("localhost:" + inst.port)} ${kind} ${tilde(inst.dir)} ${c.gray("pid " + inst.pid)} ${c.gray("\xB7 " + humanAge(inst.startedAt))} ${mode}`;
|
|
131
|
+
}
|
|
132
|
+
function printPlainList(instances) {
|
|
133
|
+
banner();
|
|
134
|
+
line(c.bold("Running instances"));
|
|
135
|
+
instances.forEach((index) => tree(instanceLabel(index)));
|
|
136
|
+
line();
|
|
137
|
+
}
|
|
138
|
+
async function listInstancesInteractive() {
|
|
139
|
+
let instances = pruneRegistry();
|
|
140
|
+
if (instances.length === 0) {
|
|
141
|
+
banner();
|
|
142
|
+
line(c.yellow("No running blogkit-md instances."));
|
|
143
|
+
line();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (!process.stdin.isTTY) {
|
|
147
|
+
printPlainList(instances);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
await new Promise((resolve) => {
|
|
151
|
+
let index = 0;
|
|
152
|
+
const stdin = process.stdin;
|
|
153
|
+
try {
|
|
154
|
+
import_node_readline.default.emitKeypressEvents(stdin);
|
|
155
|
+
stdin.setRawMode(true);
|
|
156
|
+
stdin.resume();
|
|
157
|
+
} catch {
|
|
158
|
+
printPlainList(instances);
|
|
159
|
+
resolve();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const render = (footer) => {
|
|
163
|
+
const out = [
|
|
164
|
+
"",
|
|
165
|
+
INDENT + c.bold(c.blue("blogkit-md")) + c.gray(" \xB7 running instances"),
|
|
166
|
+
"",
|
|
167
|
+
...instances.map((inst, rowIndex) => {
|
|
168
|
+
const selected = rowIndex === index;
|
|
169
|
+
const pointer = selected ? c.blue("\u276F ") : " ";
|
|
170
|
+
const label = selected ? instanceLabel(inst) : c.dim(instanceLabel(inst));
|
|
171
|
+
return INDENT + pointer + label;
|
|
172
|
+
}),
|
|
173
|
+
"",
|
|
174
|
+
footer ?? c.gray(INDENT + "\u2191/\u2193 move \u23CE stop selected q quit"),
|
|
175
|
+
""
|
|
176
|
+
];
|
|
177
|
+
process.stdout.write("\x1B[2J\x1B[H" + out.join("\n") + "\n");
|
|
178
|
+
};
|
|
179
|
+
const finish = () => {
|
|
180
|
+
stdin.setRawMode(false);
|
|
181
|
+
stdin.removeAllListeners("keypress");
|
|
182
|
+
stdin.pause();
|
|
183
|
+
resolve();
|
|
184
|
+
};
|
|
185
|
+
const onKey = (_string, key) => {
|
|
186
|
+
if (!key) return;
|
|
187
|
+
switch (key.name) {
|
|
188
|
+
case "up":
|
|
189
|
+
case "k": {
|
|
190
|
+
index = (index - 1 + instances.length) % instances.length;
|
|
191
|
+
render();
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case "down":
|
|
195
|
+
case "j": {
|
|
196
|
+
index = (index + 1) % instances.length;
|
|
197
|
+
render();
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "return": {
|
|
201
|
+
const target = instances[index];
|
|
202
|
+
killInstance(target);
|
|
203
|
+
instances = pruneRegistry();
|
|
204
|
+
if (instances.length === 0) {
|
|
205
|
+
render(c.green(INDENT + `\u2713 Stopped localhost:${target.port}. No instances left.`));
|
|
206
|
+
finish();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
index = Math.min(index, instances.length - 1);
|
|
210
|
+
render(c.green(INDENT + `\u2713 Stopped localhost:${target.port}.`));
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
default: {
|
|
214
|
+
if (key.name === "q" || key.name === "escape" || key.ctrl && key.name === "c") {
|
|
215
|
+
render(c.gray(INDENT + "Bye \u{1F44B}"));
|
|
216
|
+
finish();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
stdin.on("keypress", onKey);
|
|
222
|
+
render();
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function parseArgs(argv) {
|
|
226
|
+
const isFlag = (a) => a.startsWith("-");
|
|
227
|
+
const flagNames = new Set(argv.filter(isFlag).map((a) => a.split("=", 1)[0]));
|
|
228
|
+
const inputArgument = argv.find((a) => !isFlag(a));
|
|
229
|
+
const portArgument = argv.find((a) => a.startsWith("--port="));
|
|
230
|
+
const requestedPort = portArgument ? Number.parseInt(portArgument.split("=", 2)[1], 10) || 0 : 0;
|
|
231
|
+
return {
|
|
232
|
+
inputArg: inputArgument,
|
|
233
|
+
requestedPort,
|
|
234
|
+
wantBackground: flagNames.has("--background") || flagNames.has("-b"),
|
|
235
|
+
wantList: flagNames.has("--list") || flagNames.has("-l") || flagNames.has("--list-instances"),
|
|
236
|
+
// legacy alias
|
|
237
|
+
wantTear: flagNames.has("--tear") || flagNames.has("-t"),
|
|
238
|
+
isDetachedChild: flagNames.has("--__detached"),
|
|
239
|
+
// internal use only
|
|
240
|
+
wantHelp: flagNames.has("--help") || flagNames.has("-h")
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function printHelp() {
|
|
244
|
+
banner();
|
|
245
|
+
line(c.bold("Usage"));
|
|
246
|
+
tree("blogkit-md <file-or-directory> [options]");
|
|
247
|
+
line();
|
|
248
|
+
line(c.bold("Options"));
|
|
249
|
+
tree(`${c.green("--port=<port>")} run on a specific port (default: random free port)`);
|
|
250
|
+
tree(`${c.green("-b, --background")} run the preview server detached in the background`);
|
|
251
|
+
tree(`${c.green("-t, --tear")} stop the instance already serving this path, then start fresh`);
|
|
252
|
+
tree(`${c.green("-l, --list")} interactively list & stop running instances`);
|
|
253
|
+
tree(`${c.green("-h, --help")} show this help`);
|
|
254
|
+
line();
|
|
255
|
+
line(c.gray("If a path is already being served, running it again just reopens it."));
|
|
256
|
+
line();
|
|
257
|
+
}
|
|
258
|
+
async function run(argv) {
|
|
259
|
+
const parsed = parseArgs(argv);
|
|
260
|
+
if (parsed.wantHelp) {
|
|
261
|
+
printHelp();
|
|
262
|
+
process.exit(0);
|
|
263
|
+
}
|
|
264
|
+
if (parsed.wantList) {
|
|
265
|
+
await listInstancesInteractive();
|
|
266
|
+
process.exit(0);
|
|
267
|
+
}
|
|
268
|
+
if (!parsed.inputArg) {
|
|
269
|
+
printHelp();
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
const inputPath = import_node_path.default.resolve(process.cwd(), parsed.inputArg);
|
|
273
|
+
let inputStat;
|
|
274
|
+
try {
|
|
275
|
+
inputStat = (0, import_node_fs.statSync)(inputPath);
|
|
276
|
+
} catch {
|
|
277
|
+
banner();
|
|
278
|
+
line(c.red("\u2717 Path does not exist"));
|
|
279
|
+
tree(c.dim(inputPath));
|
|
280
|
+
line();
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
const isDirectory = inputStat.isDirectory();
|
|
284
|
+
if (!parsed.isDetachedChild) {
|
|
285
|
+
const existing = findByDir(inputPath);
|
|
286
|
+
if (existing) {
|
|
287
|
+
if (parsed.wantTear) {
|
|
288
|
+
banner();
|
|
289
|
+
line(c.yellow("\u25B8 Tearing down the running instance"));
|
|
290
|
+
tree(
|
|
291
|
+
`${c.green("localhost:" + existing.port)} ${c.gray("pid " + existing.pid)} ${existing.background ? c.magenta("background") : c.gray("foreground")}`
|
|
292
|
+
);
|
|
293
|
+
killInstance(existing);
|
|
294
|
+
line(c.green(`\u2713 Stopped localhost:${existing.port}`));
|
|
295
|
+
line();
|
|
296
|
+
await new Promise((r) => setTimeout(r, 400));
|
|
297
|
+
} else {
|
|
298
|
+
const url = `http://localhost:${existing.port}`;
|
|
299
|
+
banner();
|
|
300
|
+
line(c.green("\u25B8 Already running \u2014 opening it in the browser"));
|
|
301
|
+
tree(`${c.bold("URL")} ${c.blue(url)}`);
|
|
302
|
+
tree(`${c.bold("Path")} ${c.dim(tilde(existing.dir))}`);
|
|
303
|
+
line();
|
|
304
|
+
line(c.gray("Restart it with ") + c.blue("--tear") + c.gray(", or list with ") + c.blue("--list"));
|
|
305
|
+
line();
|
|
306
|
+
openBrowser(url);
|
|
307
|
+
process.exit(0);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const scriptPath = process.argv[1];
|
|
312
|
+
const packageRoot = import_node_path.default.dirname(import_node_path.default.dirname(scriptPath));
|
|
313
|
+
const nextBin = import_node_path.default.join(packageRoot, "node_modules/.bin/next");
|
|
314
|
+
if (parsed.wantBackground && !parsed.isDetachedChild) {
|
|
315
|
+
try {
|
|
316
|
+
const port = parsed.requestedPort || await getFreePort();
|
|
317
|
+
(0, import_node_fs.mkdirSync)(logDir(), { recursive: true });
|
|
318
|
+
const logFile = import_node_path.default.join(logDir(), `${port}.log`);
|
|
319
|
+
const out = (0, import_node_fs.openSync)(logFile, "a");
|
|
320
|
+
const child = (0, import_node_child_process.spawn)(
|
|
321
|
+
process.execPath,
|
|
322
|
+
[scriptPath, inputPath, `--port=${port}`, "--__detached"],
|
|
323
|
+
{ detached: true, stdio: ["ignore", out, out] }
|
|
324
|
+
);
|
|
325
|
+
child.unref();
|
|
326
|
+
banner();
|
|
327
|
+
line(c.green("\u25B8 Started in the background"));
|
|
328
|
+
tree(`${c.bold("URL")} ${c.blue("http://localhost:" + port)}`);
|
|
329
|
+
tree(`${c.bold("Path")} ${c.dim(tilde(inputPath))}`);
|
|
330
|
+
tree(`${c.bold("PID")} ${c.dim(String(child.pid))}`);
|
|
331
|
+
tree(`${c.bold("Log")} ${c.dim(tilde(logFile))}`);
|
|
332
|
+
line();
|
|
333
|
+
line(c.gray("Stop it with: ") + c.blue("blogkit-md --list"));
|
|
334
|
+
line();
|
|
335
|
+
} catch (error) {
|
|
336
|
+
banner();
|
|
337
|
+
line(c.red("\u2717 Failed to start in the background"));
|
|
338
|
+
tree(c.dim(String(error)));
|
|
339
|
+
line();
|
|
340
|
+
process.exit(1);
|
|
341
|
+
}
|
|
342
|
+
process.exit(0);
|
|
343
|
+
}
|
|
344
|
+
await startServer(inputPath, isDirectory, parsed, { nextBin, packageRoot });
|
|
47
345
|
}
|
|
48
|
-
var isDirectory = inputStat.isDirectory();
|
|
49
|
-
var clients = /* @__PURE__ */ new Set();
|
|
50
346
|
function getFreePort() {
|
|
51
347
|
return new Promise((resolve, reject) => {
|
|
52
348
|
const s = (0, import_node_http.createServer)();
|
|
53
349
|
s.listen(0, () => {
|
|
54
350
|
const port = s.address().port;
|
|
55
|
-
s.close((
|
|
351
|
+
s.close((error) => error ? reject(error) : resolve(port));
|
|
56
352
|
});
|
|
57
353
|
s.on("error", reject);
|
|
58
354
|
});
|
|
59
355
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
356
|
+
async function startServer(inputPath, isDirectory, parsed, paths) {
|
|
357
|
+
const clients = /* @__PURE__ */ new Set();
|
|
358
|
+
const sseServer = (0, import_node_http.createServer)((request, res) => {
|
|
359
|
+
res.writeHead(200, {
|
|
360
|
+
"Content-Type": "text/event-stream",
|
|
361
|
+
"Cache-Control": "no-cache",
|
|
362
|
+
"Connection": "keep-alive",
|
|
363
|
+
"Access-Control-Allow-Origin": "*"
|
|
364
|
+
});
|
|
365
|
+
res.write("data: connected\n\n");
|
|
366
|
+
clients.add(res);
|
|
367
|
+
request.on("close", () => clients.delete(res));
|
|
66
368
|
});
|
|
67
|
-
|
|
68
|
-
clients.add(res);
|
|
69
|
-
req.on("close", () => clients.delete(res));
|
|
70
|
-
});
|
|
71
|
-
sseServer.listen(0, async () => {
|
|
369
|
+
await new Promise((resolve) => sseServer.listen(0, resolve));
|
|
72
370
|
const ssePort = sseServer.address().port;
|
|
73
|
-
const nextPort = requestedPort || await getFreePort();
|
|
74
|
-
const
|
|
371
|
+
const nextPort = parsed.requestedPort || await getFreePort();
|
|
372
|
+
const nextEnvironment = {
|
|
75
373
|
...process.env,
|
|
76
374
|
...isDirectory ? { MARKDOWN_DIR: inputPath } : { MARKDOWN_FILE: inputPath },
|
|
77
375
|
SSE_PORT: String(ssePort)
|
|
78
376
|
};
|
|
79
377
|
const broadcastReload = () => {
|
|
80
|
-
for (const client of clients)
|
|
81
|
-
client.write("data: reload\n\n");
|
|
82
|
-
}
|
|
378
|
+
for (const client of clients) client.write("data: reload\n\n");
|
|
83
379
|
};
|
|
84
380
|
if (isDirectory) {
|
|
85
381
|
(0, import_node_fs.watch)(inputPath, { recursive: true }, (_, filename) => {
|
|
@@ -91,24 +387,71 @@ sseServer.listen(0, async () => {
|
|
|
91
387
|
if (filename === markdownFilename) broadcastReload();
|
|
92
388
|
});
|
|
93
389
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
390
|
+
const me = {
|
|
391
|
+
pid: process.pid,
|
|
392
|
+
port: nextPort,
|
|
393
|
+
ssePort,
|
|
394
|
+
dir: inputPath,
|
|
395
|
+
isDirectory,
|
|
396
|
+
background: parsed.isDetachedChild,
|
|
397
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
398
|
+
};
|
|
399
|
+
addInstance(me);
|
|
400
|
+
if (!parsed.isDetachedChild) {
|
|
401
|
+
banner();
|
|
402
|
+
line(c.gray("starting preview server for ") + c.blue(tilde(inputPath)) + c.gray(" \u2026"));
|
|
403
|
+
}
|
|
404
|
+
const child = (0, import_node_child_process.spawn)(paths.nextBin, ["start", "--port", String(nextPort)], {
|
|
405
|
+
cwd: paths.packageRoot,
|
|
406
|
+
env: nextEnvironment,
|
|
97
407
|
stdio: ["inherit", "pipe", "inherit"]
|
|
98
408
|
});
|
|
99
|
-
|
|
409
|
+
const shutdown = () => {
|
|
410
|
+
try {
|
|
411
|
+
child.kill("SIGTERM");
|
|
412
|
+
} catch {
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
sseServer.close();
|
|
416
|
+
} catch {
|
|
417
|
+
}
|
|
418
|
+
removeInstance(process.pid);
|
|
419
|
+
};
|
|
420
|
+
process.on("exit", shutdown);
|
|
421
|
+
process.on("SIGINT", () => process.exit(0));
|
|
422
|
+
process.on("SIGTERM", () => process.exit(0));
|
|
423
|
+
let ready = false;
|
|
100
424
|
child.stdout?.on("data", (chunk) => {
|
|
101
|
-
|
|
102
|
-
if (!browserOpened) {
|
|
425
|
+
if (!ready) {
|
|
103
426
|
const match = chunk.toString().match(/http:\/\/localhost:\d+/);
|
|
104
427
|
if (match) {
|
|
105
|
-
|
|
106
|
-
|
|
428
|
+
ready = true;
|
|
429
|
+
const url = `http://localhost:${nextPort}`;
|
|
430
|
+
if (!parsed.isDetachedChild) {
|
|
431
|
+
line();
|
|
432
|
+
line(c.green("\u2713 Ready"));
|
|
433
|
+
tree(`${c.bold("URL")} ${c.blue(url)}`);
|
|
434
|
+
tree(`${c.bold("Path")} ${c.dim(tilde(inputPath))}`);
|
|
435
|
+
line();
|
|
436
|
+
line(c.gray("live reload on save \xB7 Ctrl-C to stop"));
|
|
437
|
+
line();
|
|
438
|
+
}
|
|
439
|
+
openBrowser(url);
|
|
107
440
|
}
|
|
108
441
|
}
|
|
109
442
|
});
|
|
110
443
|
child.on("exit", (code) => {
|
|
111
|
-
|
|
444
|
+
try {
|
|
445
|
+
sseServer.close();
|
|
446
|
+
} catch {
|
|
447
|
+
}
|
|
448
|
+
removeInstance(process.pid);
|
|
112
449
|
process.exit(code ?? 0);
|
|
113
450
|
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// scripts/blogkit-md.ts
|
|
454
|
+
run(process.argv.slice(2)).catch((error) => {
|
|
455
|
+
console.error(error);
|
|
456
|
+
process.exit(1);
|
|
114
457
|
});
|