@moneko/core 3.39.0-beta.8 → 3.39.1
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/dev.mjs +2 -2
- package/package.json +3 -3
- package/lib/bin/lint-stage-git.d.mts +0 -29
- package/lib/bin/lint-stage-git.mjs +0 -1
- package/lib/plugin/worker/eslint.d.mts +0 -5
- package/lib/plugin/worker/eslint.mjs +0 -1
- package/lib/plugin/worker/stylelint.d.mts +0 -5
- package/lib/plugin/worker/stylelint.mjs +0 -1
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{extname as r,relative as
|
|
2
|
-
`):(m(o||0,1,{msg:n,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K"))}}))}let Y=f(L);Y.outputFileSystem=
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{extname as r,relative as s,sep as n}from"node:path";import{ink as i,loadFile as l,print as a,println as c,progressBar as m}from"@moneko/utils";import p from"fastify";import{createCA as d,createCert as h}from"mkcert";import f from"webpack";import u from"webpack-hot-middleware";import{merge as g}from"webpack-merge";import{diffObject as y}from"./commom/diff-object.mjs";import v from"./commom/mime.mjs";import{getIPv4 as w}from"./commom/net.mjs";import x from"./commom/open.mjs";import b,{config_files as k}from"./commom/paths.mjs";import $ from"./commom/sigint-exit.mjs";import{devLog as C,getServerAddress as j,PORT as S}from"./dev/config.mjs";import P from"./dev/mock.mjs";import{setupProxy as A}from"./dev/proxy.mjs";import _ from"./options/reslove.mjs";import z from"./plugin/eslint.mjs";import T from"./plugin/stylelint.mjs";import{empty as E}from"./utils/index.mjs";import{commonConfig as H}from"./common.mjs";import{CONFIG as I,getConfig as M,PUBLICPATH as O}from"./config.mjs";import{outputFileSystem as B}from"./file-system.mjs";import R from"./module.config.mjs";import{isLibrary as q,isReact as U,refresh as D}from"./process-env.mjs";let F=`${O.endsWith("/")?"":"/"}__hmr__`,N=new URLSearchParams({name:"client",path:F,dynamicPublicPath:!0,timeout:2e3,reload:!D,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),L=g(H,{watchOptions:{ignored:/node_modules\/(?!(@app|@moneko)).+/},entry:{main:[`${_.hotMiddlewareClient}?${N}`]},module:R(!1),plugins:[new f.HotModuleReplacementPlugin,new f.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(L.plugins||(L.plugins=[]),U){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;L.plugins.push(new e({overlay:!1}))}function G(e){let t=e.join(","),o=[s(b.programPath,`${I.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return q&&o.push(s(b.programPath,`${I.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}I.eslint&&L.plugins.push(new z({fix:!0,cache:!0,cacheLocation:`${b.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:G(["js","jsx","ts","tsx","json","html","vue"]),...I.eslint})),I.stylelint&&L.plugins.push(new T({fix:!0,cache:!0,cacheLocation:`${b.lintCachePath}/.stylelintcache`,files:G(["css","scss","sass","less","ts","tsx","js","jsx"]),...I.stylelint}));let W=!1,K="/____progress____",X={percentage:0,info:""};if(I.bar){let e=I.bar,t=e.name||"Build";L.plugins.push(new f.ProgressPlugin({handler(o,r,...s){let n=s.length?`[${r}] ${s.join(" ")}`:" ";W||(X.info=n,X.percentage=o,W=1===o),e.quiet?process.stdout.write(`${n}
|
|
2
|
+
`):(m(o||0,1,{msg:n,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K"))}}))}let Y=f(L);Y.outputFileSystem=B;let J=Y.watch(Y.options.watchOptions,C);Y.hooks.done.tap("client-log",e=>{C(null,e)});let Q={};async function V(){if("object"==typeof I.devServer.https&&I.devServer.https.key&&I.devServer.https.cert){let e=await Promise.all([l(I.devServer.https.key),l(I.devServer.https.cert)]);return e[0]||(c(i(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.key}`,"red")),process.exit(1)),e[1]||(c(i(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.cert}`,"red")),process.exit(1)),{key:e[0],cert:e[1]}}let e=await d({organization:"Moneko Dev CA",countryCode:"CN",state:"Hunan",locality:"Changsha",validity:365});return await h({ca:{key:e.key,cert:e.cert},organization:"Moneko Dev CA",domains:[...new Set([I.devServer.host,"localhost","127.0.0.1",w()].filter(Boolean))],validity:365})}if(I.devServer.https){let e=await V();Q.http2=!0,Q.https={key:e.key,cert:e.cert}}let Z=u(Y,{log:!1,path:F,heartbeat:2e3}),ee=p({logger:!1,...Q});P(ee,{directory:b.mockPath}),A(ee,I.proxy);let et={"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","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0",...I.devServer.headers||{}};function eo(e,t,o){t.headers(et),e.headers.origin&&t.header("Access-Control-Allow-Origin",e.headers.origin);let s=Y.outputFileSystem,n=e.headers["accept-encoding"],i=n?.includes("br"),l=`${o}.${i?"br":"gz"}`,a=s.existsSync?.(l);a&&t.header("content-encoding",i?"br":"gzip");let c=s.createReadStream?.(a?l:o,{autoClose:!0});c?.on("error",e=>{if(c.destroy(),!t.sent)return t.code(404).type("text/html").send(`File not found: ${e.message}`)});let m=v[r(o)];return m&&t.header("content-type",m),t.send(c)}function er(){process.exit(0)}ee.get(K,(e,t)=>{t.headers(et),t.send(X)}),ee.get(`/${F}`.replace("//","/"),async(e,t)=>{if("text/event-stream"===e.headers.accept){e.raw.url=F,Z(e.raw,t.raw,()=>{t.raw.writableEnded&&(t.sent=!0)});return}}),ee.addHook("onRequest",(e,t,o)=>{if(e.url===K)return o();if(!W)return t.type("text/html").send(function(e){let t=Math.floor(100*e.percentage);return`<!DOCTYPE html><html><head><title>Building...</title><link rel="image/x-icon" href="/favicon.ico"><style>html{ display:flex; justify-content:center; align-items:center; block-size:100vb;}.progress-container{ position:relative; overflow:hidden; margin:1rem auto; border:0.0625rem solid #ccc; border-radius:0.625rem; inline-size:18.75rem; block-size:1.25rem;}.progress-bar{ block-size:100%; background:#4caf50; inline-size:0%; transition:inline-size 0.5s ease;}#progress-text{ position:absolute; margin:auto; font-size:0.875rem; font-family:sans-serif; font-weight:600; text-align:center; color:#fff; text-shadow:0 0 0.0625rem black; inset-inline:0; inset-block:0; line-height:1.25rem;}#progress-info{ font-size:small; font-family:sans-serif; font-weight:100; text-align:center; opacity:0.5; margin-block-start:0.625rem;}</style></head><body><div class="progress-container"><div class="progress-bar"></div><div id="progress-text">${t}%</div></div><div id="progress-info">${e.info}</div><script>function checkProgress() {fetch('${K}').then(r => r.json()) .then(data => {const percentage = Math.floor(data.percentage * 100);document.querySelector('.progress-bar').style.width = percentage + '%';document.getElementById('progress-text').textContent = percentage + '%';document.getElementById('progress-info').textContent = data.info;if (percentage === 100) {window.location.reload();} else {setTimeout(checkProgress, 500);}});}checkProgress();</script></body></html>`}(X)),o();let r=decodeURIComponent(`${Y.options.output.path}${n}${"/"===e.url?"index.html":e.url}`);return Y.outputFileSystem?.existsSync?.(r)?eo(e,t,r):o()}),ee.setNotFoundHandler((e,t)=>eo(e,t,`${Y.options.output.path}${n}index.html`)),ee.addHook("onClose",()=>{J.close(E),ee.server.close(E)}),ee.listen({port:S}),I.devServer.open&&x(j("local"));let es=await Promise.all(k.map(M)),en=g(es[0]||{},es[1]||{});k.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(k.map(M)),s=g(o||{},r||{}),n=y(en,s);1===Object.keys(n).length&&"proxy"in n?(a(i(`代理更新中...`,"yellow"),!0),await A(ee,s.proxy),a(i(`代理更新完成...`,"green"),!0),I.proxy=s.proxy,en.proxy=s.proxy,en=s):(en=s,c(i(`检测到工程配置${i(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(ei?`netstat -ano | findstr :${S}`:`lsof -i :${S} -t`,(e,t)=>{if(e){c(i(`查找端口 ${S} 时发生错误: ${e.message}`,"red")),c(i("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=ei?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){c(i(`未找到占用端口 ${S} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){c(i(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ei="win32"===process.platform;process.on("SIGHUP",function(){ee.close(E),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",er)}()}),process.on("exit",function(){ee.close(E)}),$(er);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.39.
|
|
3
|
+
"version": "3.39.1",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fastify/http-proxy": "9.5.0",
|
|
23
|
-
"@moneko/convert": "1.0.
|
|
23
|
+
"@moneko/convert": "1.0.1",
|
|
24
24
|
"@moneko/eslint": "1.3.0",
|
|
25
25
|
"@moneko/mdx": "0.1.44",
|
|
26
26
|
"@moneko/raw-import": "0.0.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"style-loader": "4.0.0",
|
|
44
44
|
"swc-loader": "0.2.6",
|
|
45
45
|
"typescript": "5.8.3",
|
|
46
|
-
"webpack": "5.99.
|
|
46
|
+
"webpack": "5.99.3",
|
|
47
47
|
"webpack-hot-middleware": "2.26.1",
|
|
48
48
|
"webpack-merge": "6.0.1",
|
|
49
49
|
"webpack-virtual-modules": "0.6.2"
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { argv } from 'node:process';
|
|
5
|
-
import { ESLint } from '@moneko/eslint';
|
|
6
|
-
import { stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
|
-
declare function parseArgs<T>(args: string[]): T;
|
|
8
|
-
type Args = {
|
|
9
|
-
fix?: boolean;
|
|
10
|
-
cache?: boolean;
|
|
11
|
-
mode?: 'ci' | 'commit';
|
|
12
|
-
};
|
|
13
|
-
declare const args: Args;
|
|
14
|
-
declare const fix: boolean | undefined;
|
|
15
|
-
declare const cache: boolean;
|
|
16
|
-
declare const cwd: string;
|
|
17
|
-
declare const cachePath: string;
|
|
18
|
-
declare const cmd: {
|
|
19
|
-
readonly ci: readonly ['diff', '--name-only', 'HEAD^', 'HEAD'];
|
|
20
|
-
readonly commit: readonly ['diff', '--cached', '--name-only', '--diff-filter=ACMR'];
|
|
21
|
-
};
|
|
22
|
-
declare const scriptRegExp: RegExp;
|
|
23
|
-
declare const vueRegExp: RegExp;
|
|
24
|
-
declare const styleRegExp: RegExp;
|
|
25
|
-
declare const child: SpawnSyncReturns<Buffer>;
|
|
26
|
-
declare const lintFiles: string[];
|
|
27
|
-
export declare async function eslint();
|
|
28
|
-
declare const styleFiles: string[];
|
|
29
|
-
export declare async function stylelint();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{spawnSync as t}from"node:child_process";import{readFile as e}from"node:fs/promises";import{join as o}from"node:path";import{argv as i}from"node:process";import{ESLint as r}from"@moneko/eslint";import{stylelint as s}from"@moneko/stylelint";let n=Object.fromEntries(i.slice(2).map(function(t){let e=t.split("="),o=e[1];return void 0===o||"true"===o?o=!0:"false"===o?o=!1:/-?\d+(\.\d+)?([eE][+-]?\d+)?/.test(o)&&(o=parseFloat(o)),[e[0].replace(/^--/,""),o]})),c=n.fix,l=n.cache||!0,a=o(process.cwd(),"node_modules/.cache"),m={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACMR"]},d=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,f=/.*(?<!\.d)\.vue$/,p=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,u=t("git",m[n.mode||"ci"]||m.ci).stdout.toString().trim().split("\n");export async function eslint(){console.log("ESLint runing...");try{console.time("ESLint");let t=new r({cache:l,cacheLocation:`${a}/.eslintcache`,fix:c}),e=u.filter(t=>d.test(t)||f.test(t)),o=await t.lintFiles(e),i=await t.loadFormatter("stylish"),s=await i.format(o);c&&await r.outputFixes(o),s&&process.stdout.write(s);let n=o.some(t=>t.errorCount>0);console.timeEnd("ESLint"),n&&process.exit(1)}catch(t){console.error(t)}}let y=u.filter(t=>p.test(t)||f.test(t));export async function stylelint(){console.log("Stylelint runing..."),console.time("Stylelint");let t=await Promise.all(y.map(async t=>{let o=await e(t,{encoding:"utf-8"});return await s.lint({codeFilename:t,code:o,cache:l,cacheLocation:`${a}/.stylelintcache`,fix:c,formatter:"string"}).catch(console.log)})),o=!1;t.forEach(t=>{t&&(t.report&&process.stdout.write(t.report),t.errored&&(o=!!t.errored))}),console.timeEnd("Stylelint"),o&&process.exit(1)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e,a;import{ESLint as t}from"@moneko/eslint";import{parentPort as r}from"worker_threads";if(!r)throw Error("This file must be run as a worker");let o=null;r.on("message",async({options:i})=>{o&&clearTimeout(o),o=setTimeout(async()=>{o&&(clearTimeout(o),o=null);try{e||(e=new t({cache:i.cache,cacheLocation:i.cacheLocation,cacheStrategy:i.cacheStrategy,fix:i.fix}),a=await e.loadFormatter("stylish"));let o=i.files.map(e=>e.replace(/\\/g,"/")),c=await e.lintFiles(o),s=[],l=[];i.fix&&await t.outputFixes(c),c.forEach(e=>{e.errorCount?l.push(e):e.warningCount&&s.push(e)});let n=await Promise.all([a.format(s),a.format(l)]);r.postMessage(n.map(e=>e.replace(/[^\r\n]*(\r?\n)*$/,"")))}catch(e){r.postMessage(e)}},4)}),r.on("close",()=>{o&&clearTimeout(o)});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Formatter, type LinterResult, type LintResult, stylelint, type Warning } from '@moneko/stylelint';
|
|
2
|
-
import { parentPort } from 'worker_threads';
|
|
3
|
-
export type StylelintWorkerMessage = [warnings: string, errors: string];
|
|
4
|
-
declare let timer: NodeJS.Timeout | null;
|
|
5
|
-
declare const formatter: Formatter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{stylelint as e}from"@moneko/stylelint";import{parentPort as r}from"worker_threads";if(!r)throw Error("This file must be run as a worker");let t=null,a=await e.formatters.string;r.on("message",async({options:i})=>{t&&clearTimeout(t),t=setTimeout(async()=>{t&&(clearTimeout(t),t=null);try{let t=await e.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files.map(e=>e.replace(/\\/g,"/")),quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete t.output;let n=[],s=[];t.results.forEach(e=>{if(!e.ignored&&(e.errored||e.parseErrors.length||e.invalidOptionWarnings.length||e.deprecations.length)){let r=[],t=[];e.warnings.forEach(e=>{"error"===e.severity?r.push(e):"warning"===e.severity&&t.push(e)}),r.length>0&&n.push({...e,warnings:r}),t.length>0&&s.push({...e,warnings:t})}});let o=[a(s,t),a(n,t)];r.postMessage(o.map(e=>e.replace(/[^\r\n]*(\r?\n)*$/,"")))}catch(e){r.postMessage(e)}},4)}),r.on("close",()=>{t&&clearTimeout(t)});
|