@moneko/core 3.26.10 → 3.26.12

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.
@@ -1,2 +1,2 @@
1
- import{relative as s}from"node:path";import{argv as e}from"node:process";import{ink as t,print as r}from"@moneko/utils";import o from"stylelint";import{cachePath as i,cwd as c,parseBraced as l}from"./utils/config.mjs";export default async function n(){let n=t("stylelint","cyan");r(`${n}: ${t("Runing...","yellow")}`,!0);let a=e[3],f=e.slice(4),m=f.includes("--fix"),p=await o.lint({files:l(a).map(e=>s(c,`${e}/**/**/**/**/*.{css,scss,sass,less,ts,tsx,js,jsx}`)),fix:m,cache:!f.includes("--cache=false"),cacheLocation:`${i}/.stylelintcache`,formatter:"string"}),u=p.errored;p.report&&process.stdout.write(p.report),r(`${n}: ${t(`✨ ${u?"Error":"Successfully"}!
1
+ import{relative as e}from"node:path";import{argv as s}from"node:process";import{ink as t,print as r}from"@moneko/utils";import o from"stylelint";import{cachePath as i,cwd as c,parseBraced as l}from"./utils/config.mjs";export default async function n(){let n=t("stylelint","cyan");r(`${n}: ${t("Runing...","yellow")}`,!0);let a=s[3],f=s.slice(4),m=f.includes("--fix"),p=await o.lint({files:l(a).map(s=>e(c,`${s}/**/*.{css,scss,sass,less,ts,tsx,js,jsx}`).replace(/\\/g,"/")),fix:m,cache:!f.includes("--cache=false"),cacheLocation:`${i}/.stylelintcache`,formatter:"string"}),u=p.errored;p.report&&process.stdout.write(p.report),r(`${n}: ${t(`✨ ${u?"Error":"Successfully"}!
2
2
  `,u?"red":"green")}`,!0),u&&process.exit(1)}
package/lib/dev.mjs CHANGED
@@ -1 +1 @@
1
- let e;import{exec as t,spawn as o}from"node:child_process";import{watchFile as s}from"node:fs";import{createServer as i}from"node:https";import{join as r}from"node:path";import{directoryExists as n,ink as l,loadFile as a,print as m,println as c,progressBar as p}from"@moneko/utils";import d from"express";import u from"multer";import h from"webpack";import f from"webpack-dev-middleware";import x from"webpack-hot-middleware";import{merge as g}from"webpack-merge";import{diffObject as y}from"./commom/diff-object.mjs";import w from"./commom/has-pkg.mjs";import v,{config_files as k}from"./commom/paths.mjs";import $ from"./commom/sigint-exit.mjs";import{devLog as C,PORT as P}from"./dev/config.mjs";import b from"./dev/mock.mjs";import j,{updateProxy as S}from"./dev/proxy.mjs";import A from"./options/reslove.mjs";import{empty as T,resolveProgram as E}from"./utils/index.mjs";import{commonConfig as I}from"./common.mjs";import{CONFIG as M,getConfig as O,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as H,isReact as q,refresh as z}from"./process-env.mjs";let B=!1!==M.stylelint&&w("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=!1!==M.eslint&&w("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,G=q&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,U=["js","jsx","ts","tsx","json","html","vue"],L=U.join(","),N=["css","scss","sass","less","ts","tsx","js","jsx"],W=N.join(","),F=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],K=`${_.endsWith("/")?"":"/"}__hmr__`,X=new URLSearchParams({name:"client",path:K,dynamicPublicPath:!0,timeout:2e3,reload:!z,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),J=I.output.path,Q=M.bar.name||"Build",V=g(I,{entry:{main:[`${A.hotMiddlewareClient}?${X}`]},output:{path:J},module:R(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new h.HotModuleReplacementPlugin,new h.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),G&&new G,D&&new D({fix:!0,threads:!0,files:[`${M.alias["@"]}/**/*.{${L}}`,H&&`${M.alias["@pkg"]}/**/*.{${L}}`].filter(Boolean),extensions:U,exclude:F,cache:!0,cacheLocation:`${v.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"}),B&&new B({fix:!0,threads:!0,files:[`${M.alias["@"]}/**/*.{${W}}`,H&&`${M.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:N,exclude:F,cache:!0,cacheLocation:`${v.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!M.bar&&new h.ProgressPlugin({handler(e,t,...o){p(e||0,1,Q,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),Y=h(V);Y.hooks.done.tap("client-log",e=>{C(null,e)});let Z=d(),ee=u(),et={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...M.devServer.headers},eo=f(Y,{writeToDisk:!1,index:"index.html",headers:e=>({...et,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:V.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),es=x(Y,{log:!1,path:K,heartbeat:2e3});Z.use(d.static(r(v.programPath,"./public"))).use(eo).use(K,es),n(v.mockPath)&&Z.use(ee.any(),b(v.mockPath)),M.proxy&&j(Z,M.proxy);let ei=`${V.output.path}/index.html`;if(Z.use((e,t,o)=>{if("GET"===e.method){let s=e.get("Accept");if(s?.includes("text/html")){let e=eo.context.outputFileSystem,o=e?.readFileSync?.(ei);t.headersSent||(t.setHeader("Content-Type","text/html"),t.send(o))}else if("text/event-stream"===s&&e.url.endsWith(K))return e.url=K,es(e,t,o);else return o()}else{if("OPTIONS"!==e.method)return o();t.sendStatus(200)}}),M.devServer.https){let[t,o]=await Promise.all([a(M.devServer.https.key),a(M.devServer.https.cert)]);t||(c(l(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${M.devServer.https.key}`,"red")),process.exit(1)),o||(c(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${M.devServer.https.cert}`,"red")),process.exit(1)),e=i({key:t,cert:o},Z)}let er=(e||Z).listen(P,"0.0.0.0",()=>{});function en(){process.exit(0)}let el=await Promise.all(k.map(O)),ea=g(el[0]||{},el[1]||{});k.forEach(function(e){s(e,async function(){let[o,s]=await Promise.all(k.map(O)),i=g(o||{},s||{}),r=y(ea,i);1===Object.keys(r).length&&"proxy"in r?(m(l(`代理更新中...`,"yellow"),!0),S(Z,i.proxy),m(l(`代理更新完成...`,"green"),!0),M.proxy=i.proxy,ea.proxy=i.proxy,ea=i):(ea=i,c(l(`检测到工程配置${l(`[${e}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),t("win32"===process.platform?`netstat -ano | findstr :${P}`:`lsof -i :${P} -t`,(e,t)=>{if(e){c(l(`查找端口 ${P} 时发生错误: ${e.message}`,"red")),c(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),s=em?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!s){c(l(`未找到占用端口 ${P} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(s),"SIGHUP")}catch(e){c(l(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let em="win32"===process.platform;process.on("SIGHUP",function(){eo.close(T),er.close(T),er.closeAllConnections(),function(){let e=o(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",en)}()}),process.on("exit",function(){eo.close(T),er.close(T),er.closeAllConnections()}),$(en);
1
+ let e;import{exec as t,spawn as o}from"node:child_process";import{watchFile as s}from"node:fs";import{createServer as i}from"node:https";import{join as r}from"node:path";import{directoryExists as n,ink as l,loadFile as a,print as m,println as c,progressBar as p}from"@moneko/utils";import d from"express";import u from"multer";import h from"webpack";import f from"webpack-dev-middleware";import x from"webpack-hot-middleware";import{merge as g}from"webpack-merge";import{diffObject as y}from"./commom/diff-object.mjs";import w from"./commom/has-pkg.mjs";import v,{config_files as k}from"./commom/paths.mjs";import $ from"./commom/sigint-exit.mjs";import{devLog as C,PORT as P}from"./dev/config.mjs";import b from"./dev/mock.mjs";import j,{updateProxy as S}from"./dev/proxy.mjs";import A from"./options/reslove.mjs";import{empty as T,resolveProgram as E}from"./utils/index.mjs";import{commonConfig as I}from"./common.mjs";import{CONFIG as M,getConfig as O,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as H,isReact as q,refresh as z}from"./process-env.mjs";let B=!1!==M.stylelint&&w("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,D=!1!==M.eslint&&w("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,G=q&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,U=["js","jsx","ts","tsx","json","html","vue"],L=U.join(","),N=["css","scss","sass","less","ts","tsx","js","jsx"],W=N.join(","),F=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],K=`${_.endsWith("/")?"":"/"}__hmr__`,X=new URLSearchParams({name:"client",path:K,dynamicPublicPath:!0,timeout:2e3,reload:!z,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),J=I.output.path,Q=M.bar.name||"Build",V=g(I,{entry:{main:[`${A.hotMiddlewareClient}?${X}`]},output:{path:J},module:R(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new h.HotModuleReplacementPlugin,new h.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),G&&new G,D&&new D({fix:!0,threads:!0,files:[`${M.alias["@"]}/**/*.{${L}}`,H&&`${M.alias["@pkg"]}/**/*.{${L}}`].filter(Boolean),extensions:U,exclude:F,cache:!0,cacheLocation:`${v.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"}),B&&new B({fix:!0,threads:!0,files:[`${M.alias["@"]}/**/*.{${W}}`,H&&`${M.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:N,exclude:F,cache:!0,cacheLocation:`${v.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!M.bar&&new h.ProgressPlugin({handler(e,t,...o){p(e||0,1,Q,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),Y=h(V);Y.hooks.done.tap("client-log",e=>{C(null,e)});let Z=d(),ee=u(),et={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...M.devServer.headers},eo=f(Y,{writeToDisk:!1,index:"index.html",headers:e=>({...et,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:V.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),es=x(Y,{log:!1,path:K,heartbeat:2e3});Z.use(d.static(r(v.programPath,"./public"))).use(eo).use(K,es),n(v.mockPath)&&Z.use(ee.any(),b(v.mockPath)),M.proxy&&j(Z,M.proxy);let ei=`${V.output.path}/index.html`;if(Z.use((e,t,o)=>{if("GET"===e.method){let s=e.get("Accept");if(s?.includes("text/html")){let e=eo.context.outputFileSystem,o=e?.readFileSync?.(ei);t.headersSent||(t.setHeader("Content-Type","text/html"),t.send(o))}else if("text/event-stream"===s&&e.url.endsWith(K))return e.url=K,es(e,t,o);else return o()}else{if("OPTIONS"!==e.method)return o();t.sendStatus(200)}}),M.devServer.https){let[t,o]=await Promise.all([a(M.devServer.https.key),a(M.devServer.https.cert)]);t||(c(l(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${M.devServer.https.key}`,"red")),process.exit(1)),o||(c(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${M.devServer.https.cert}`,"red")),process.exit(1)),e=i({key:t,cert:o},Z)}let er=(e||Z).listen(P,"0.0.0.0",()=>{});function en(){process.exit(0)}let el=await Promise.all(k.map(O)),ea=g(el[0]||{},el[1]||{});k.forEach(function(e){s(e,async function(){let[o,s]=await Promise.all(k.map(O)),i=g(o||{},s||{}),r=y(ea,i);1===Object.keys(r).length&&"proxy"in r?(m(l(`代理更新中...`,"yellow"),!0),S(Z,i.proxy),m(l(`代理更新完成...`,"green"),!0),M.proxy=i.proxy,ea.proxy=i.proxy,ea=i):(ea=i,c(l(`检测到工程配置${l(`[${e}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),t("win32"===process.platform?`netstat -ano | findstr :${P}`:`lsof -i :${P} -t`,(e,t)=>{if(e){c(l(`查找端口 ${P} 时发生错误: ${e.message}`,"red")),c(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),s=em?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!s){c(l(`未找到占用端口 ${P} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(s),"SIGHUP")}catch(e){c(l(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let em="win32"===process.platform;process.on("SIGHUP",function(){eo.close(T),er.close(T),er.closeAllConnections?.(),function(){let e=o(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",en)}()}),process.on("exit",function(){eo.close(T),er.close(T),er.closeAllConnections?.()}),$(en);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.26.10",
3
+ "version": "3.26.12",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",