@moneko/core 3.17.1 → 3.17.3
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/lib/build.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/utils/progress.d.mts +1 -1
- package/lib/utils/progress.mjs +1 -1
- package/package.json +1 -1
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as t}from"webpack-merge";import m from"./build/common.mjs";import e from"./build/server.mjs";import{CONFIG as i}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import
|
|
1
|
+
import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as t}from"webpack-merge";import m from"./build/common.mjs";import e from"./build/server.mjs";import{CONFIG as i}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import g from"chalk";let{ProgressPlugin:u}=r,h=!!i.bar,d=t(m,{module:s(!1),plugins:[i.done&&new l({done:i.done}),new u({handler(o,r,...t){let m=i.bar||{};c({showBar:h,percentage:o,title:m.name||"Build",color:m.color,info:t.length?`[${r}] ${t.join(" ")}`:"",output:d.output?.path})}})].filter(Boolean)}),j=[d];a&&j.push(t(m,e));let w=r(j);async function b(){await new Promise(o=>{w.run((r,t)=>{if(r)throw r;if(t&&(t.hasErrors()||t.hasWarnings()))for(let o=0,r=t.stats.length;o<r;o++){let r=t.stats[o];for(let o=0,t=r.compilation.warnings.length;o<t;o++)p(g.yellowBright(r.compilation.warnings[o].message));for(let o=0,t=r.compilation.errors.length;o<t;o++)p(g.redBright(r.compilation.errors[o].message))}o(r)})}),i.seo&&f()}await b(),process.on("exit",function(){o(n.cachePath),o(n.vfsDtsPath)});
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{directoryExists as e,fileExists as t,loadFileSync as o,removeDirAll as i}from"@moneko/mdx";import s from"express";import r from"multer";import l from"webpack";import n from"webpack-dev-middleware";import m from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import c from"./build/server.mjs";import{commonConfig as p}from"./common.mjs";import{CONFIG as f}from"./config.mjs";import{PORT as u,devLog as d,headers as h}from"./dev/config.mjs";import g from"./dev/mock.mjs";import w from"./dev/proxy.mjs";import x from"./module.config.mjs";import j,{CUSTOMCONFIG as $}from"./paths.mjs";import{SSR as k,isLibrary as y,isReact as b}from"./process-env.mjs";import v from"./utils/has-pkg.mjs";import{empty as P,resolveProgram as _}from"./utils/index.mjs";import S from"./utils/progress.mjs";import C from"./utils/sigint-exit.mjs";import B from"./options/reslove.mjs";import{watchFile as D}from"fs";import{spawn as M,exec as G}from"child_process";import I from"./utils/log.mjs";import L from"chalk";let{HotModuleReplacementPlugin:U,ProgressPlugin:A,WatchIgnorePlugin:F}=l,H=v("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,O=v("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,R=b&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,T=["js","jsx","ts","tsx","json","html","vue"],q=T.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],N=E.join(","),z=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],J=new URLSearchParams({timeout:2e3,reload:!(v("solid-refresh")||v("react-refresh")),quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),K=p.output.path;k&&(K=_(`${y?"docs":"dist"}/client`));let Q=!!f.bar,V=a(p,{entry:{main:[`${B.hotMiddlewareClient}?name=client&path=//localhost:${u}/__hmr__&${J}`]},output:{path:K},module:x(!1),plugins:[new U,new F({paths:[/\.d\.ts$/]}),R&&new R,O&&new O({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${q}}`,y&&`${f.alias["@pkg"]}/**/*.{${q}}`].filter(Boolean),extensions:T,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),H&&new H({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${N}}`,y&&`${f.alias["@pkg"]}/**/*.{${N}}`].filter(Boolean),extensions:E,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),new A({handler(e,t,...o){let i=f.bar||{};S({
|
|
1
|
+
import{directoryExists as e,fileExists as t,loadFileSync as o,removeDirAll as i}from"@moneko/mdx";import s from"express";import r from"multer";import l from"webpack";import n from"webpack-dev-middleware";import m from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import c from"./build/server.mjs";import{commonConfig as p}from"./common.mjs";import{CONFIG as f}from"./config.mjs";import{PORT as u,devLog as d,headers as h}from"./dev/config.mjs";import g from"./dev/mock.mjs";import w from"./dev/proxy.mjs";import x from"./module.config.mjs";import j,{CUSTOMCONFIG as $}from"./paths.mjs";import{SSR as k,isLibrary as y,isReact as b}from"./process-env.mjs";import v from"./utils/has-pkg.mjs";import{empty as P,resolveProgram as _}from"./utils/index.mjs";import S from"./utils/progress.mjs";import C from"./utils/sigint-exit.mjs";import B from"./options/reslove.mjs";import{watchFile as D}from"fs";import{spawn as M,exec as G}from"child_process";import I from"./utils/log.mjs";import L from"chalk";let{HotModuleReplacementPlugin:U,ProgressPlugin:A,WatchIgnorePlugin:F}=l,H=v("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,O=v("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,R=b&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,T=["js","jsx","ts","tsx","json","html","vue"],q=T.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],N=E.join(","),z=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],J=new URLSearchParams({timeout:2e3,reload:!(v("solid-refresh")||v("react-refresh")),quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),K=p.output.path;k&&(K=_(`${y?"docs":"dist"}/client`));let Q=!!f.bar,V=a(p,{entry:{main:[`${B.hotMiddlewareClient}?name=client&path=//localhost:${u}/__hmr__&${J}`]},output:{path:K},module:x(!1),plugins:[new U,new F({paths:[/\.d\.ts$/]}),R&&new R,O&&new O({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${q}}`,y&&`${f.alias["@pkg"]}/**/*.{${q}}`].filter(Boolean),extensions:T,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),H&&new H({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${N}}`,y&&`${f.alias["@pkg"]}/**/*.{${N}}`].filter(Boolean),extensions:E,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),new A({handler(e,t,...o){let i=f.bar||{};S({showBar:Q,percentage:e,title:i.name||"Build",color:i.color,info:o.length?`[${t}] ${o.join(" ")}`:"",output:V.output?.path})}})].filter(Boolean)}),W=[V];k&&W.push(a(p,c));let X=l(W);X.compilers[0].hooks.done.tap("client-log",e=>{d(null,e)});let Y=s(),Z=r(),ee=n(X,{writeToDisk:!1,index:"index.html",headers:()=>h,serverSideRender:k,lastModified:!0});if(Y.use(ee),Y.use(m(X,{log:!1,path:"/__hmr__",heartbeat:2e3})),f.proxy&&w(Y,f.proxy),e(j.mockPath)){let e=g(j.mockPath);Y.use(e)}let et=`${V.output.path}/index.html`;Y.all("/*",Z.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=ee.context.outputFileSystem,o=e?.readFileSync?.(et);t.end(o)}});let eo=Y.listen(u,()=>{});function ei(){process.exit(0)}function es(e,i){if(i&&t(e)){let t=(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"");D(e,async function(){t!==(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"")?(I(L.yellow(`检测到工程配置${L.blue(`[${i}]`)}变更, 程序即将重启...`)),G("win32"===process.platform?`netstat -ano | findstr :${u}`:`lsof -i :${u}`,(e,t,o)=>{let i=er?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];i?process.kill(Number(i),"SIGHUP"):I(`未找到占用端口 ${u} 的进程`)})):I(L.gray(`未变更`))})}}es(j.configPath,"index"),es(j.customConfigPath,$);let er="win32"===process.platform;process.on("SIGHUP",function(){ee.close(P),eo.close(P),eo.closeAllConnections(),function(){let e=M(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",ei)}()}),process.on("exit",function(){ee.close(P),eo.close(P),eo.closeAllConnections(),i(j.cachePath),i(j.vfsDtsPath)}),C(ei);
|
package/lib/utils/progress.d.mts
CHANGED
package/lib/utils/progress.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cursorTo as t,clearScreenDown as o}from"readline";import{relative as
|
|
1
|
+
import{cursorTo as t,clearScreenDown as o}from"readline";import{relative as s}from"path";import e from"chalk";import r from"../paths.mjs";import{isDev as i}from"../process-env.mjs";let{blue:p,bgBlue:c,grey:d,green:u,yellow:n,red:l}=e,m={};export default function(a){let f=a.percentage||0,w=process.stdout.rows-2,h=Math.fround(24*f),$=a.color?[e.hex(a.color),e.bgHex(a.color)]:[p,c],g=$[0](`${a.title}:`),x=d(`${(100*f).toFixed()}%`),B=$[1](" ".repeat(h))+$[1].inverse(" ".repeat(24-h));if(0===f&&(m[a.title]=process.hrtime(),a.showBar&&process.stdout.write("\n\n")),a.showBar&&(t(process.stdout,0,w),o(process.stdout),process.stdout.write(`${g} ${B} ${x}`),process.stdout.write("\n"),process.stdout.write(d(a.info.length>80?`${a.info.substring(0,80)}...`:a.info))),1===f){if(!i){let t=process.hrtime(m[a.title]),o=t[0]+t[1]/1e9,e=u;o<10?e=u:o<20?e=n:o<40&&(e=l),process.stdout.write("\n"),process.stdout.write(d(`Build completed ${u("successfully")}!`)),process.stdout.write("\n"),process.stdout.write(d(`Output files are located in the ${p(`${s(r.programPath,a.output||"dist/")}/`)} directory.`)),process.stdout.write("\n"),process.stdout.write(d(`Build took ${e(o.toFixed(2))} seconds.`)),process.stdout.write("\n\n")}t(process.stdout,0,w),o(process.stdout)}}
|