@moneko/core 3.37.0 → 3.38.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/lib/bin/pure-lint.d.mts +4 -2
- package/lib/bin/pure-lint.mjs +1 -1
- package/lib/bin/utils/bundle-app.d.mts +1 -0
- package/lib/bin/utils/bundle-app.mjs +1 -1
- package/lib/commom/log.d.mts +1 -1
- package/lib/commom/log.mjs +3 -2
- package/lib/commom/open.d.mts +5 -0
- package/lib/commom/open.mjs +1 -0
- package/lib/commom/timer.d.mts +12 -0
- package/lib/commom/timer.mjs +1 -0
- package/lib/config.mjs +1 -1
- package/lib/dev/config.d.mts +1 -1
- package/lib/dev/config.mjs +3 -3
- package/lib/dev.d.mts +2 -1
- package/lib/dev.mjs +2 -2
- package/lib/index.d.mts +2 -0
- package/lib/index.mjs +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +4 -0
package/lib/bin/pure-lint.d.mts
CHANGED
|
@@ -3,9 +3,11 @@ import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { argv } from 'node:process';
|
|
5
5
|
import { ESLint } from '@moneko/eslint';
|
|
6
|
-
import { stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
|
-
import { loadFile } from '@moneko/utils';
|
|
6
|
+
import { LinterResult, stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
|
+
import { ink, loadFile, println } from '@moneko/utils';
|
|
8
|
+
import log from '../commom/log.mjs';
|
|
8
9
|
import parseArgs from '../commom/parse-args.mjs';
|
|
10
|
+
import timer from '../commom/timer.mjs';
|
|
9
11
|
type Args = {
|
|
10
12
|
fix?: boolean;
|
|
11
13
|
cache?: boolean;
|
package/lib/bin/pure-lint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o}from"node:process";import{ESLint as i}from"@moneko/eslint";import{stylelint as
|
|
2
|
+
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o}from"node:process";import{ESLint as i}from"@moneko/eslint";import{stylelint as r}from"@moneko/stylelint";import{ink as n,loadFile as s,println as l}from"@moneko/utils";import m from"../commom/log.mjs";import a from"../commom/parse-args.mjs";import c from"../commom/timer.mjs";let d=a(o.slice(2)),f=d.fix,p=d.cache||!0,y=e(process.cwd(),"node_modules/.cache"),u={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACMR"]},h=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,w=/.*(?<!\.d)\.vue$/,g=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,S=t("git",u[d.mode||"ci"]||u.ci).stdout.toString().trim().split("\n");async function $(){let t=n("ESLint","cyan");l(`${t}: ${n("runing...","yellow")}`,!0);try{c.start("ESLint");let t=S.filter(t=>h.test(t)||w.test(t));if(0===t.length){c.end("ESLint");return}let e=new i({cache:p,cacheLocation:`${y}/.eslintcache`,fix:f}),o=await e.lintFiles(t),r=await e.loadFormatter("stylish"),n=await r.format(o);f&&await i.outputFixes(o),n&&process.stdout.write(n);let s=o.some(t=>t.errorCount>0);c.end("ESLint"),s&&process.exit(1)}catch(t){m(t)}}let E=S.filter(t=>g.test(t)||w.test(t));async function j(){let t=n("Stylelint","cyan");if(l(`${t}: ${n("runing...","yellow")}`,!0),c.start("Stylelint"),0===E.length){c.end("Stylelint");return}let e=await Promise.all(E.map(async t=>{let e=await s(t);return await r.lint({codeFilename:t,code:e,cache:p,cacheLocation:`${y}/.stylelintcache`,fix:f,formatter:"string"}).catch(m)})),o=!1;e.forEach(t=>{t&&(t.report&&process.stdout.write(t.report),t.errored&&(o=!!t.errored))}),c.end("Stylelint"),o&&process.exit(1)}await Promise.all([$(),j()]);
|
|
@@ -2,5 +2,6 @@ import { execSync } from 'node:child_process';
|
|
|
2
2
|
import { renameSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { bundleIpa, createDir, ink, print } from '@moneko/utils';
|
|
5
|
+
import timer from '../../commom/timer.mjs';
|
|
5
6
|
export declare function bundleApk(outputPath: string, outputBundleDir: string, type?: string);
|
|
6
7
|
export declare function bundleIOS(outputPath: string, outputBundleDir: string, type?: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execSync as e}from"node:child_process";import{renameSync as o}from"node:fs";import{join as n}from"node:path";import{bundleIpa as p,createDir as
|
|
1
|
+
import{execSync as e}from"node:child_process";import{renameSync as o}from"node:fs";import{join as n}from"node:path";import{bundleIpa as p,createDir as t,ink as a,print as r}from"@moneko/utils";import l from"../../commom/timer.mjs";export function bundleApk(p,i,u="-release"){r(a("正在编译 apk...","yellow"),!0),l.start(`bundle apk ${u}`),e(`flutter build apk -${u}`),l.end(`bundle apk ${u}`),t(i),o(n(p,`build/app/outputs/flutter-apk/app${u}.apk`),i),r(`✨ ${a("Apk 编译","cyan")}: ${a("完成","cyan")}`,!0)}export function bundleIOS(i,u,d="-release"){r(a("正在编译 ipa...","yellow"),!0),l.start(`bundle ipa ${d}`);let m=n(u,"Runner/Payload");e(`flutter build ios -${d} --no-codesign`),t(m),o(n(i,"build/ios/iphoneos/Runner.app"),m),p(n(u,"Runner"),u,d),l.end(`bundle ipa ${d}`),r(`✨ ${a("ipa 编译","cyan")}: ${a("完成","cyan")}`,!0)}
|
package/lib/commom/log.d.mts
CHANGED
|
@@ -2,5 +2,5 @@ import { appendToFile } from '@moneko/utils';
|
|
|
2
2
|
declare const startDate: Date;
|
|
3
3
|
declare const startHrTime: [number, number];
|
|
4
4
|
declare function getCurrentTime(): string;
|
|
5
|
-
declare function log(message:
|
|
5
|
+
declare function log(message: Error | string): void;
|
|
6
6
|
export default log;
|
package/lib/commom/log.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{appendToFile as t}from"@moneko/utils";let e=new Date,r=process.hrtime();export default function(
|
|
1
|
+
import{appendToFile as t}from"@moneko/utils";let e=new Date,r=process.hrtime();export default function(a){let n=function(){let t=process.hrtime(r),a=t[0],n=t[1],i=new Date(e.getTime()+1e3*a+Math.floor(n/1e6)),o=i.getFullYear(),g=String(i.getMonth()+1).padStart(2,"0"),$=String(i.getDate()).padStart(2,"0"),s=String(i.getHours()).padStart(2,"0"),S=String(i.getMinutes()).padStart(2,"0"),l=String(i.getSeconds()).padStart(2,"0"),p=String(Math.floor(n%1e6/1e3)).padStart(3,"0"),d=String(n%1e3).padStart(3,"0");return`${o}-${g}-${$} ${s}:${S}:${l}.${p}${d}`}(),i=(a instanceof Error?`${a.message}
|
|
2
|
+
${a.stack||""}`:String(a)).split("\n"),o=`[${n}] ${i[0]}`,g=" ".repeat(`[${n}] `.length),$=i.slice(1).map(t=>`${g}${t}`).join("\n"),s=`${o}${$?`
|
|
2
3
|
${$}`:""}
|
|
3
|
-
`;t(`logs/${
|
|
4
|
+
`;t(`logs/${n.substring(0,16)}.log`,s)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";import{platform as o}from"node:process";import{empty as r}from"../utils/index.mjs";export default function(t){let n,d;"win32"===o?(n="cmd.exe",d=["/c","start",'""',"/b",t.replace(/&/g,"^&")]):(n="darwin"===o?"open":"xdg-open",d=[t]);let i=e(n,d,{detached:!0,stdio:"ignore"});i.on("error",r),i.unref()}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hrtime } from 'node:process';
|
|
2
|
+
import { ink, println } from '@moneko/utils';
|
|
3
|
+
interface Timer {
|
|
4
|
+
start(label: string): void;
|
|
5
|
+
end(label: string): {
|
|
6
|
+
nanoseconds: bigint;
|
|
7
|
+
milliseconds: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare const timers: Map<string, bigint>;
|
|
11
|
+
declare const timer: Timer;
|
|
12
|
+
export default timer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hrtime as e}from"node:process";import{ink as t,println as r}from"@moneko/utils";let o=new Map;export default{start(t){o.set(t,e.bigint())},end(i){let l=o.get(i);if(!l)throw Error(`No timer found for label: ${i}`);let n=e.bigint()-l,m=Number(n)/1e6;return o.delete(i),r(`⚡ ${t(i,"cyan",{bold:!0})}: ${t(`${m} ms`,"90")}`,!0),{nanoseconds:n,milliseconds:m}}};
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{fileExists as o}from"@moneko/utils";import{merge as t}from"webpack-merge";import r from"./commom/paths.mjs";import s from"./commom/require.mjs";import n from"./commom/setup-env.mjs";import i from"./options/jsx-dom-expressions.mjs";import a from"./options/split-chunk.mjs";import{isFunction as m,node_modules as l,resolveProgram as p}from"./utils/index.mjs";import{APPTYPE as c,FRAMEWORK as u,frameworkVersion as d,isCI as f,isDev as h,isLibrary as g,isMobile as x,isReact as j,jsxImportSource as v,mainDirectory as P,NODE_ENV as C,PACKAGENAME as b}from"./process-env.mjs";let k=["@app","@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export function getConfig(e){return delete s.cache[e],new Promise(t=>{if(o(e)){let o=s(e).default;return t(m(o)?o(process):o)}return t({})})}let w=await Promise.all([n(C,c,u,[]),getConfig(r.configPath),getConfig(r.customConfigPath)]),y=w[0],O=w[1],M=w[2],I={strict:!1,devtool:h?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:y,basename:"/",publicPath:"/",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":p(P)},j&&d<18?{"react/package.json":l("react/package.json"),"react/jsx-runtime":l("react/jsx-runtime.js"),"react/jsx-dev-runtime":l("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{"@moneko/common":{transform:"esm/${member}"},lodash:{transform:"${member}"}},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{title:b.toLocaleUpperCase(),favicon:e(r.programPath,`${r.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:a,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:k,js:k,media:k,font:k,wasm:[]},mdx:{jsx:!1,development:h,jsxImportSource:v,providerImportSource:`@moneko/${u}/mdx`},jsxDomExpressions:i,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:f},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==u,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1}};g&&(I.alias=Object.assign(I.alias,{"@pkg":r.componentsPath,[b]:r.componentsPath}));let z=I;(!1===(z=t(z,O,M)).devtool||!1===z.sourceMap)&&(z.sourceMap=!1,z.devtool=!1),z.fixBrowserRouter&&z.htmlPluginOption&&(z.htmlPluginOption.tags||(z.htmlPluginOption.tags=[]),z.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=z;export const PUBLICPATH=CONFIG.publicPath;
|
|
1
|
+
import{relative as e}from"node:path";import{fileExists as o}from"@moneko/utils";import{merge as t}from"webpack-merge";import r from"./commom/paths.mjs";import s from"./commom/require.mjs";import n from"./commom/setup-env.mjs";import i from"./options/jsx-dom-expressions.mjs";import a from"./options/split-chunk.mjs";import{isFunction as m,node_modules as l,resolveProgram as p}from"./utils/index.mjs";import{APPTYPE as c,FRAMEWORK as u,frameworkVersion as d,isCI as f,isDev as h,isLibrary as g,isMobile as x,isReact as j,jsxImportSource as v,mainDirectory as P,NODE_ENV as C,PACKAGENAME as b}from"./process-env.mjs";let k=["@app","@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export function getConfig(e){return delete s.cache[e],new Promise(t=>{if(o(e)){let o=s(e).default;return t(m(o)?o(process):o)}return t({})})}let w=await Promise.all([n(C,c,u,[]),getConfig(r.configPath),getConfig(r.customConfigPath)]),y=w[0],O=w[1],M=w[2],I={strict:!1,devtool:h?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:y,basename:"/",publicPath:"/",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":p(P)},j&&d<18?{"react/package.json":l("react/package.json"),"react/jsx-runtime":l("react/jsx-runtime.js"),"react/jsx-dev-runtime":l("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{"@moneko/common":{transform:"esm/${member}"},lodash:{transform:"${member}"}},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:b.toLocaleUpperCase(),favicon:e(r.programPath,`${r.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:a,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:k,js:k,media:k,font:k,wasm:[]},mdx:{jsx:!1,development:h,jsxImportSource:v,providerImportSource:`@moneko/${u}/mdx`},jsxDomExpressions:i,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:f},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==u,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1}};g&&(I.alias=Object.assign(I.alias,{"@pkg":r.componentsPath,[b]:r.componentsPath}));let z=I;(!1===(z=t(z,O,M)).devtool||!1===z.sourceMap)&&(z.sourceMap=!1,z.devtool=!1),z.fixBrowserRouter&&z.htmlPluginOption&&(z.htmlPluginOption.tags||(z.htmlPluginOption.tags=[]),z.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=z;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/dev/config.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const PORT: number;
|
|
|
7
7
|
declare const initRouteBase: boolean;
|
|
8
8
|
declare const routeBase: string;
|
|
9
9
|
declare const skipPortMsg: string | false;
|
|
10
|
-
declare function getServerAddress(type: 'local' | 'net');
|
|
10
|
+
export declare function getServerAddress(type: 'local' | 'net');
|
|
11
11
|
declare const welcomeMsg: string;
|
|
12
12
|
declare const serverSuccessMsg: string;
|
|
13
13
|
export declare function devLog(err?: Error | null, stats?: webpack.Stats);
|
package/lib/dev/config.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{ink as e,println as
|
|
2
|
-
`,"245");function
|
|
3
|
-
${e(" Network ","231",{bg:"29"})} ${e(
|
|
1
|
+
import{ink as e,println as r,termClear as o}from"@moneko/utils";import{getIPv4 as t,getPort as s}from"../commom/net.mjs";import{CONFIG as n}from"../config.mjs";let i=n.devServer.port||3e3;export const PORT=await s(i);n.devServer.port=PORT;let m="/"===n.basename?"":n.basename,a=i!==PORT&&e(`Port ${e(`${i}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
|
|
2
|
+
`,"245");export function getServerAddress(e){return`${n.devServer.https?"https":"http"}://${"local"===e?n.devServer.host:t()}:${PORT}${m}`}let l=e("You application is running here:","245"),g=`${e(" Local ","231",{bg:"blue"})} ${e(getServerAddress("local"),"75")}
|
|
3
|
+
${e(" Network ","231",{bg:"29"})} ${e(getServerAddress("net"),"green")}`;export function devLog(t,s){s&&(o(3),r([l,"",g,"",e(`Compiled successfully in ${e(`${s.endTime-s.startTime}ms`,"green")}`,"245"),""].join("\n"),!0),a&&r(a),s.compilation.warnings.forEach(e=>{r(e.message)}),s.compilation.errors.forEach(e=>{r(e.message)})),t&&r(t.message)}
|
package/lib/dev.d.mts
CHANGED
|
@@ -8,9 +8,10 @@ import webpackHotMiddleware, { type ClientOptions } from 'webpack-hot-middleware
|
|
|
8
8
|
import { merge } from 'webpack-merge';
|
|
9
9
|
import { diffObject } from './commom/diff-object.mjs';
|
|
10
10
|
import mime from './commom/mime.mjs';
|
|
11
|
+
import open from './commom/open.mjs';
|
|
11
12
|
import paths, { config_files } from './commom/paths.mjs';
|
|
12
13
|
import sigintExit from './commom/sigint-exit.mjs';
|
|
13
|
-
import { devLog, PORT } from './dev/config.mjs';
|
|
14
|
+
import { devLog, getServerAddress, PORT } from './dev/config.mjs';
|
|
14
15
|
import setupMock from './dev/mock.mjs';
|
|
15
16
|
import { type ProxyConfig, setupProxy } from './dev/proxy.mjs';
|
|
16
17
|
import reslove from './options/reslove.mjs';
|
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 s,sep as i}from"node:path";import{ink as n,loadFile as l,print as a,println as c,progressBar as m}from"@moneko/utils";import p from"fastify";import d from"webpack";import
|
|
2
|
-
`):(m(o||0,1,{msg:i,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K"))}}))}let
|
|
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 i}from"node:path";import{ink as n,loadFile as l,print as a,println as c,progressBar as m}from"@moneko/utils";import p from"fastify";import d from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as g}from"./commom/diff-object.mjs";import u from"./commom/mime.mjs";import y from"./commom/open.mjs";import w,{config_files as v}from"./commom/paths.mjs";import x from"./commom/sigint-exit.mjs";import{devLog as $,getServerAddress as b,PORT as k}from"./dev/config.mjs";import C from"./dev/mock.mjs";import{setupProxy as j}from"./dev/proxy.mjs";import P from"./options/reslove.mjs";import S from"./plugin/eslint.mjs";import _ from"./plugin/stylelint.mjs";import{empty as A}from"./utils/index.mjs";import{commonConfig as z}from"./common.mjs";import{CONFIG as T,getConfig as E,PUBLICPATH as I}from"./config.mjs";import{outputFileSystem as O}from"./file-system.mjs";import H from"./module.config.mjs";import{isLibrary as B,isReact as M,refresh as R}from"./process-env.mjs";let q=`${I.endsWith("/")?"":"/"}__hmr__`,U=new URLSearchParams({name:"client",path:q,dynamicPublicPath:!0,timeout:2e3,reload:!R,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),F=h(z,{watchOptions:{ignored:/node_modules\/(?!(@app|@moneko)).+/},entry:{main:[`${P.hotMiddlewareClient}?${U}`]},module:H(!1),plugins:[new d.HotModuleReplacementPlugin,new d.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(F.plugins||(F.plugins=[]),M){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;F.plugins.push(new e({overlay:!1}))}function L(e){let t=e.join(","),o=[s(w.programPath,`${T.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(s(w.programPath,`${T.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}T.eslint&&F.plugins.push(new S({fix:!0,cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:L(["js","jsx","ts","tsx","json","html","vue"]),...T.eslint})),T.stylelint&&F.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`,files:L(["css","scss","sass","less","ts","tsx","js","jsx"]),...T.stylelint}));let N=!1,D="/____progress____",G={percentage:0,info:""};if(T.bar){let e=T.bar,t=e.name||"Build";F.plugins.push(new d.ProgressPlugin({handler(o,r,...s){let i=s.length?`[${r}] ${s.join(" ")}`:" ";N||(G.info=i,G.percentage=o,N=1===o),e.quiet?process.stdout.write(`${i}
|
|
2
|
+
`):(m(o||0,1,{msg:i,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K"))}}))}let W=d(F);W.outputFileSystem=O;let K=W.watch(W.options.watchOptions,$);W.hooks.done.tap("client-log",e=>{$(null,e)});let X={};if(T.devServer.https){let[e,t]=await Promise.all([l(T.devServer.https.key),l(T.devServer.https.cert)]);e||(c(n(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.key}`,"red")),process.exit(1)),t||(c(n(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.cert}`,"red")),process.exit(1)),X.http2=!0,X.https={key:e,cert:t}}let Y=f(W,{log:!1,path:q,heartbeat:2e3}),J=p({logger:!1,...X});C(J,{directory:w.mockPath}),j(J,T.proxy);let Q={"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",...T.devServer.headers||{}};function V(e,t,o){t.headers(Q),e.headers.origin&&t.header("Access-Control-Allow-Origin",e.headers.origin);let s=W.outputFileSystem,i=e.headers["accept-encoding"],n=i?.includes("gzip"),l=s.existsSync?.(`${o}.gz`);n&&l&&t.header("content-encoding","gzip");let a=s.createReadStream?.(n&&l?`${o}.gz`:o,{autoClose:!0});a?.on("error",e=>{if(a.destroy(),!t.sent)return t.code(404).type("text/html").send(`File not found: ${e.message}`)});let c=u[r(o)];return c&&t.header("content-type",c),t.send(a)}function Z(){process.exit(0)}J.get(D,(e,t)=>{t.headers(Q),t.send(G)}),J.get(`/${q}`.replace("//","/"),async(e,t)=>{if("text/event-stream"===e.headers.accept){e.raw.url=q,Y(e.raw,t.raw,()=>{t.raw.writableEnded&&(t.sent=!0)});return}}),J.addHook("onRequest",(e,t,o)=>{if(e.url===D)return o();if(!N)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('${D}').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, 50);}});}checkProgress();</script></body></html>`}(G)),o();let r=decodeURIComponent(`${W.options.output.path}${i}${"/"===e.url?"index.html":e.url}`);return W.outputFileSystem?.existsSync?.(r)?V(e,t,r):o()}),J.setNotFoundHandler((e,t)=>V(e,t,`${W.options.output.path}${i}index.html`)),J.addHook("onClose",()=>{K.close(A),J.server.close(A)}),J.listen({port:k}),T.devServer.open&&y(b("local"));let ee=await Promise.all(v.map(E)),et=h(ee[0]||{},ee[1]||{});v.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(v.map(E)),s=h(o||{},r||{}),i=g(et,s);1===Object.keys(i).length&&"proxy"in i?(a(n(`代理更新中...`,"yellow"),!0),await j(J,s.proxy),a(n(`代理更新完成...`,"green"),!0),T.proxy=s.proxy,et.proxy=s.proxy,et=s):(et=s,c(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(eo?`netstat -ano | findstr :${k}`:`lsof -i :${k} -t`,(e,t)=>{if(e){c(n(`查找端口 ${k} 时发生错误: ${e.message}`,"red")),c(n("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=eo?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){c(n(`未找到占用端口 ${k} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){c(n(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let eo="win32"===process.platform;process.on("SIGHUP",function(){J.close(A),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Z)}()}),process.on("exit",function(){J.close(A)}),x(Z);
|
package/lib/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type * from '../typings/global.js';
|
|
2
2
|
export { default as hasPkg } from './commom/has-pkg.mjs';
|
|
3
3
|
export { getIPv4, getPort } from './commom/net.mjs';
|
|
4
|
+
export { default as open } from './commom/open.mjs';
|
|
4
5
|
export { CUSTOMCONFIG, default as paths, routeDir, yarnArgv } from './commom/paths.mjs';
|
|
5
6
|
export { default as require } from './commom/require.mjs';
|
|
6
7
|
export { default as Rule } from './commom/rule.mjs';
|
|
8
|
+
export { default as timer } from './commom/timer.mjs';
|
|
7
9
|
export { type MockConfiguration, type ProxyFuncType, type RequestFormData, yApiMock, type YApiOption, type YApiOptionBySchema, yApiSchemaMock } from './dev/mock.mjs';
|
|
8
10
|
export type { ProxyConfig } from './dev/proxy.mjs';
|
|
9
11
|
export type { CssInJsMinifyOption } from './loader/css-in-js-minify.cjs';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as require}from"./commom/require.mjs";export{default as Rule}from"./commom/rule.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{APPTYPE,coreName,FRAMEWORK,isCI,isDev,isLibrary,isMicro,mainDirectory,packageJson,PACKAGENAME}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";
|
|
1
|
+
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{default as open}from"./commom/open.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as require}from"./commom/require.mjs";export{default as Rule}from"./commom/rule.mjs";export{default as timer}from"./commom/timer.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{APPTYPE,coreName,FRAMEWORK,isCI,isDev,isLibrary,isMicro,mainDirectory,packageJson,PACKAGENAME}from"./process-env.mjs";export{resolveProgram,toCamelCase}from"./utils/index.mjs";
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED