@moneko/core 3.49.0 → 3.50.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/help.d.mts +82 -0
- package/lib/bin/help.mjs +7 -33
- package/lib/bin/index.mjs +1 -1
- package/lib/bin/setup.d.mts +5 -0
- package/lib/bin/setup.mjs +1 -0
- package/lib/commom/check-npm.d.mts +4 -0
- package/lib/commom/check-npm.mjs +1 -0
- package/lib/commom/corepack.d.mts +13 -0
- package/lib/commom/corepack.mjs +1 -0
- package/lib/config.mjs +1 -1
- package/lib/dev/mock.d.mts +8 -1
- package/lib/dev/mock.mjs +1 -1
- package/lib/dev/server.d.mts +1 -1
- package/lib/dev/server.mjs +1 -1
- package/lib/module.config.d.mts +1 -1
- package/package.json +3 -2
- package/typings/global.d.ts +4 -0
package/lib/bin/help.d.mts
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
1
|
import { ink, println } from '@moneko/utils';
|
|
2
|
+
declare const commands: readonly [{
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly args: string;
|
|
6
|
+
readonly arguments: readonly [{
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly description: string;
|
|
12
|
+
}];
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly args: string;
|
|
17
|
+
readonly arguments: readonly [{
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly description: string;
|
|
23
|
+
}];
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly args: string;
|
|
28
|
+
readonly arguments: readonly [{
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly description: string;
|
|
31
|
+
}];
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly args: string;
|
|
36
|
+
readonly arguments: readonly [{
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly description: string;
|
|
39
|
+
}];
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly description: string;
|
|
43
|
+
readonly args: string;
|
|
44
|
+
readonly arguments: readonly [{
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly description: string;
|
|
47
|
+
}];
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly description: string;
|
|
51
|
+
readonly args: string;
|
|
52
|
+
readonly arguments: readonly [{
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly description: string;
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly description: string;
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly description: string;
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly description: string;
|
|
64
|
+
}];
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly description: string;
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly description: string;
|
|
71
|
+
readonly args: string;
|
|
72
|
+
readonly arguments: readonly [{
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly description: string;
|
|
75
|
+
}];
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly description: string;
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly description: string;
|
|
82
|
+
}];
|
|
83
|
+
declare const examples: readonly [readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string], readonly [string, string, string, string]];
|
|
2
84
|
declare function printHelp();
|
|
3
85
|
export default printHelp;
|
package/lib/bin/help.mjs
CHANGED
|
@@ -1,39 +1,13 @@
|
|
|
1
|
-
import{ink as e,println as
|
|
2
|
-
${e("
|
|
3
|
-
|
|
4
|
-
${e("命令列表:","white")}
|
|
5
|
-
${e("start","green")} ${e("<type> <framework>","208")} 启动开发服务器
|
|
6
|
-
${e("type: ","245",{bold:!0})}${e(r,"245",{italic:!0})}
|
|
7
|
-
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
8
|
-
|
|
9
|
-
${e("build","green")} ${e("<type> <framework>","208")} 构建生产环境应用
|
|
10
|
-
${e("type: ","245",{bold:!0})}${e(r,"245")}
|
|
11
|
-
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
12
|
-
|
|
13
|
-
${e("eslint","green")} ${e("<source_path>","208")} 执行代码规范检查
|
|
14
|
-
${e("source_path: ","245",{bold:!0})}${e("要检查的文件或目录路径","245",{italic:!0})}
|
|
15
|
-
|
|
16
|
-
${e("stylelint","green")} ${e("<source_path>","208")} 执行样式规范检查
|
|
17
|
-
${e("source_path: ","245",{bold:!0})}${e("要检查的文件或目录路径","245",{italic:!0})}
|
|
18
|
-
|
|
19
|
-
${e("pin","green")} ${e("[-u]","208")} 检查过时依赖
|
|
20
|
-
${e("-u: ","245",{bold:!0})}${e("写入更新到 package.json 中","245",{italic:!0})}
|
|
21
|
-
|
|
22
|
-
${e("githooks","green")} 配置 Git 钩子以自动化工作流
|
|
23
|
-
|
|
24
|
-
${e("buildApp","green")} 将资产打包成App
|
|
25
|
-
|
|
26
|
-
${e("changelog","green")} ${e("<filename>","208")} 生成项目变更日志
|
|
27
|
-
${e("filename: ","245",{bold:!0})}${e("输出的文件名","245",{italic:!0})}
|
|
1
|
+
import{ink as e,println as t}from"@moneko/utils";let n=[{name:"start",description:"启动开发服务器",args:"<type> <framework>",arguments:[{name:"type",description:"backstage | library | site | micro | mobile"},{name:"framework",description:"react | solid | vue"}]},{name:"build",description:"构建生产环境应用",args:"<type> <framework>",arguments:[{name:"type",description:"backstage | library | site | micro | mobile"},{name:"framework",description:"react | solid | vue"}]},{name:"eslint",description:"执行代码规范检查",args:"<source_path>",arguments:[{name:"source_path",description:"要检查的文件或目录路径"}]},{name:"stylelint",description:"执行样式规范检查",args:"<source_path>",arguments:[{name:"source_path",description:"要检查的文件或目录路径"}]},{name:"changelog",description:"生成项目变更日志",args:"<filename>",arguments:[{name:"filename",description:"输出的文件名"}]},{name:"server",description:"启动静态资源服务器",args:"[port] [root_dir] [https] [host]",arguments:[{name:"port",description:"number"},{name:"root_dir",description:"string"},{name:"https",description:"boolean"},{name:"host",description:"string"}]},{name:"setup",description:"设置一些默认行为; 比如开启 corepack、支持npm执行pre、post脚本等"},{name:"pin",description:"检查过时依赖",args:"[-u]",arguments:[{name:"-u",description:"写入更新到 package.json 中"}]},{name:"githooks",description:"配置 Git 钩子以自动化工作流"},{name:"buildApp",description:"将资产打包成App"}],r=[["mo","start","library react","# 启动开发服务器"],["mo","build","library react","# 构建生产版本"],["mo","eslint","components --fix","# 检查并修复components目录下的代码"],["mo","stylelint","src","# 检查src目录下的样式文件"],["mo","changelog","CHANGELOG.md","# 生成变更日志,输出到 CHANGELOG.md"],["mo","server","port=8080 root_dir=./dist","# 启动静态资源服务器,端口8080,根目录为./dist"],["mo","setup","","# 设置默认行为"],["mo","pin","-u","# 检查过时依赖并更新 package.json"],["mo","githooks",'pre-commit="npm run lint:commit" commit-msg="commit-lint"',"# 配置 Git 钩子,如 pre-commit 和 commit-msg"],["mo","buildApp","","# 打包应用"]];export default function(){let i=n.reduce((e,t)=>Math.max(e,t.name.length),0)+4,o=n.reduce((e,t)=>Math.max(e,t.args?.length||0),0)+4,a=n.map(t=>[" ",e(t.name.padEnd(i),"green"),e(`${t.args||""}`.padEnd(o),"208"),t.description,...(t.arguments||[]).map(t=>`
|
|
2
|
+
${" ".repeat(2+i+o)}${e(`${t.name}: `,"245",{bold:!0})}${e(t.description,"245",{italic:!0})}`),"\n"].join("")).join("\n"),m=r.reduce((e,t)=>Math.max(e,t[0].length+t[1].length+t[2].length),0),s=r.map(t=>` ${e(t[0],"blue")} ${e(t[1],"green")} ${e(t[2],"208")}${" ".padEnd(m-t[0].length-t[1].length-t[2].length+4)} ${e(t[3]||"","245")}`).join("\n");t(`
|
|
3
|
+
使用方法: ${e("mo","blue")} ${e("<命令>","green")} ${e("<必选参数>","208")} ${e("[可选参数]","yellow")}
|
|
28
4
|
|
|
5
|
+
命令列表:
|
|
6
|
+
${a}
|
|
29
7
|
${e("选项:","white")}
|
|
30
8
|
${e("-v, --version","yellow")} 显示版本信息
|
|
31
9
|
${e("-h, --help","yellow")} 显示帮助信息
|
|
32
10
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
${e("mo","blue")} ${e("build","green")} ${e("library react","208")} ${e("# 构建生产版本","245")}
|
|
36
|
-
${e("mo","blue")} ${e("eslint","green")} ${e("components","208")} ${e("# 检查并修复代码","245")}
|
|
37
|
-
${e("mo","blue")} ${e("stylelint","green")} ${e("src","208")} ${e("# 检查样式文件","245")}
|
|
38
|
-
${e("mo","blue")} ${e("changelog","green")} ${e("CHANGELOG.md","208")} ${e("# 生成变更日志","245")}
|
|
11
|
+
示例:
|
|
12
|
+
${s}
|
|
39
13
|
`)}
|
package/lib/bin/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{argv as a,exit as e}from"node:process";import{ink as t,println as i}from"@moneko/utils";import s from"../commom/require.mjs";import r from"../commom/sigint-exit.mjs";import{corePkg as m}from"./utils/config.mjs";switch(a[2]){case"-v":case"--version":i(`${t(m,"blue")}: ${s(`${m}/package.json`).version}`,!0);break;case"start":(await import("./start.mjs")).default();break;case"build":(await import("./build.mjs")).default();break;case"eslint":(await import("./eslint.mjs")).default();break;case"stylelint":(await import("./stylelint.mjs")).default();break;case"githooks":(await import("./git-hooks.mjs")).default();break;case"buildApp":(await import("./build-app.mjs")).default();break;case"changelog":(await import("./changelog.mjs")).default();break;case"server":(await import("./server.mjs")).default();break;case"pin":(await import("./pin.mjs")).default();break;default:(await import("./help.mjs")).default()}r(()=>{e(0)});
|
|
2
|
+
import{argv as a,exit as e}from"node:process";import{ink as t,println as i}from"@moneko/utils";import s from"../commom/require.mjs";import r from"../commom/sigint-exit.mjs";import{corePkg as m}from"./utils/config.mjs";switch(a[2]){case"-v":case"--version":i(`${t(m,"blue")}: ${s(`${m}/package.json`).version}`,!0);break;case"start":(await import("./start.mjs")).default();break;case"build":(await import("./build.mjs")).default();break;case"eslint":(await import("./eslint.mjs")).default();break;case"stylelint":(await import("./stylelint.mjs")).default();break;case"githooks":(await import("./git-hooks.mjs")).default();break;case"buildApp":(await import("./build-app.mjs")).default();break;case"changelog":(await import("./changelog.mjs")).default();break;case"server":(await import("./server.mjs")).default();break;case"pin":(await import("./pin.mjs")).default();break;case"setup":(await import("./setup.mjs")).default();break;default:(await import("./help.mjs")).default()}r(()=>{e(0)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import m from"../commom/check-npm.mjs";import{corepack as o}from"../commom/corepack.mjs";import{CONFIG as c}from"../config.mjs";export default function(){o(c.corepack),m()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as t}from"node:child_process";export default function(){t("npm",["-v"],{stdio:"pipe",shell:!0}).stdout.on("data",e=>{e.toString().split(".")[0]<9&&t("npm",["config","get","enable-pre-post-scripts"],{stdio:"pipe",shell:!0}).stdout.on("data",e=>{"true"!==e.toString().trim()&&t("npm",["config","set","enable-pre-post-scripts","true","-L","project"],{stdio:"ignore",shell:!0})})})}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { spawn, type SpawnOptions } from 'node:child_process';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { execPath, platform, versions } from 'node:process';
|
|
4
|
+
import { ink, loadFile, println, saveFile } from '@moneko/utils';
|
|
5
|
+
import log from './log.mjs';
|
|
6
|
+
import require from './require.mjs';
|
|
7
|
+
declare const packageJsonPath: string;
|
|
8
|
+
export declare const packageJson: typeof import('package.json');
|
|
9
|
+
declare const shim: string;
|
|
10
|
+
declare const spawnOptions: SpawnOptions;
|
|
11
|
+
declare function getManagerVersion(): string;
|
|
12
|
+
declare function corepackInstalled(): Promise<boolean>;
|
|
13
|
+
export declare function corepack(enable?: boolean);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";import{dirname as a,join as o}from"node:path";import{execPath as n,platform as r,versions as p}from"node:process";import{ink as c,loadFile as t,println as s,saveFile as i}from"@moneko/utils";import m from"./log.mjs";import g from"./require.mjs";let l=`${process.cwd()}/package.json`;export const packageJson=g(l);let k=c("corepack","magenta"),d={stdio:"ignore",shell:!0};export function corepack(g){new Promise(p=>{if(packageJson.packageManager){let c=e("corepack",["-v"],d);c.on("error",e=>{m(e),p(!1)}),c.on("exit",e=>{0!==e&&p(!1);let c=packageJson.packageManager.split("@")[0],s="win32"===r?`${c}.cmd`:c;t(o(a(n),s)).then(e=>{p(e.includes("corepack"))}).catch(e=>{m(e),p(!1)})})}else p(!1)}).then(a=>{if(g){if(packageJson.packageManager||(packageJson.packageManager=function(){let e=Number(p.node.split(".")[0]);return e<16?"pnpm@7.33.7":e<18?"pnpm@8.15.9":"pnpm@10.14.0"}(),i(l,JSON.stringify(packageJson,null,2))),a)return;e("corepack",["enable"],d);return}a?s(`${k} is ${c("enabled","green")} ${c(`(${packageJson.name})`,"245")}`):s(`${k} is ${c("disabled","yellow")} ${c(`(${packageJson.name})`,"245")}`)}).catch(e=>{m(e)})}
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as o}from"node:path";import t from"node:process";import{fileExists as r}from"@moneko/utils";import{merge as n}from"webpack-merge";import s from"./commom/paths.mjs";import a from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import l from"./options/jsx-dom-expressions.mjs";import m from"./options/split-chunk.mjs";import{isFunction as p,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{APPTYPE as d,FRAMEWORK as f,frameworkVersion as h,isCI as g,isDev as v,isLibrary as x,isMobile as P,isReact as j,jsxImportSource as C,mainDirectory as b,NODE_ENV as k,PACKAGENAME as w}from"./process-env.mjs";let O=["@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 a.cache[e],new Promise(o=>{if(r(e)){let r=a(e).default;return o(p(r)?r(t):r)}return o({})})}let y=await Promise.all([i(k,d,f,[]),getConfig(s.configPath),getConfig(s.customConfigPath)]),S=y[0],M=y[1],I=y[2],z={strict:!1,devtool:v?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:w,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:S,basename:"/",publicPath:"/",rem:{designSize:P?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":u(b)},j&&h<18?{"react/package.json":c("react/package.json"),"react/jsx-runtime":c("react/jsx-runtime.js"),"react/jsx-dev-runtime":c("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:w.toLocaleUpperCase(),favicon:o(s.programPath,`${s.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:m,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:O,js:O,media:O,font:O,wasm:[]},mdx:{jsx:!1,development:v,jsxImportSource:C,providerImportSource:`@moneko/${f}/mdx`},jsxDomExpressions:l,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:g},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==f,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:v,manifest:{filename:"manifest.json"}};x&&(z.alias=Object.assign(z.alias,{"@pkg":s.componentsPath,[w]:s.componentsPath}));let F=z;(!1===(F=n(F,M,I)).devtool||!1===F.sourceMap)&&(F.sourceMap=!1,F.devtool=!1),F.htmlPluginOption&&(F.htmlPluginOption.tags||(F.htmlPluginOption.tags=[]),F.fixBrowserRouter&&F.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))"}),F.manifest&&F.htmlPluginOption.tags.push({href:e("auto"===F.publicPath?"":F.publicPath,F.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})),"true"===t.env.CODESPACES&&(F.devServer.https=!1),!1===F.devServer.https&&"darwin"===t.platform&&(F.devServer.open=!1);export const CONFIG=F;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;
|
|
1
|
+
import{join as e,relative as o}from"node:path";import t from"node:process";import{fileExists as r}from"@moneko/utils";import{merge as n}from"webpack-merge";import s from"./commom/paths.mjs";import a from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import l from"./options/jsx-dom-expressions.mjs";import m from"./options/split-chunk.mjs";import{isFunction as p,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{APPTYPE as d,FRAMEWORK as f,frameworkVersion as h,isCI as g,isDev as v,isLibrary as x,isMobile as P,isReact as j,jsxImportSource as C,mainDirectory as b,NODE_ENV as k,PACKAGENAME as w}from"./process-env.mjs";let O=["@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 a.cache[e],new Promise(o=>{if(r(e)){let r=a(e).default;return o(p(r)?r(t):r)}return o({})})}let y=await Promise.all([i(k,d,f,[]),getConfig(s.configPath),getConfig(s.customConfigPath)]),S=y[0],M=y[1],I=y[2],z={strict:!1,devtool:v?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:w,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:S,basename:"/",publicPath:"/",rem:{designSize:P?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":u(b)},j&&h<18?{"react/package.json":c("react/package.json"),"react/jsx-runtime":c("react/jsx-runtime.js"),"react/jsx-dev-runtime":c("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:w.toLocaleUpperCase(),favicon:o(s.programPath,`${s.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:m,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:O,js:O,media:O,font:O,wasm:[]},mdx:{jsx:!1,development:v,jsxImportSource:C,providerImportSource:`@moneko/${f}/mdx`},jsxDomExpressions:l,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:g},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==f,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:v,manifest:{filename:"manifest.json"},corepack:!0};x&&(z.alias=Object.assign(z.alias,{"@pkg":s.componentsPath,[w]:s.componentsPath}));let F=z;(!1===(F=n(F,M,I)).devtool||!1===F.sourceMap)&&(F.sourceMap=!1,F.devtool=!1),F.htmlPluginOption&&(F.htmlPluginOption.tags||(F.htmlPluginOption.tags=[]),F.fixBrowserRouter&&F.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))"}),F.manifest&&F.htmlPluginOption.tags.push({href:e("auto"===F.publicPath?"":F.publicPath,F.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})),"true"===t.env.CODESPACES&&(F.devServer.https=!1),!1===F.devServer.https&&"darwin"===t.platform&&(F.devServer.open=!1);export const CONFIG=F;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;
|
package/lib/dev/mock.d.mts
CHANGED
|
@@ -10,7 +10,14 @@ import printLog, { METHOD_COLOR } from '../commom/print-log.mjs';
|
|
|
10
10
|
import require from '../commom/require.mjs';
|
|
11
11
|
import { jsonSchema } from './json-schema.mjs';
|
|
12
12
|
declare function shouldHaveBody(req: IncomingMessage);
|
|
13
|
-
declare function
|
|
13
|
+
export declare function cacheBody(req: RequestFormData & {
|
|
14
|
+
_bodyCached?: boolean;
|
|
15
|
+
_dataChunks?: Uint8Array[];
|
|
16
|
+
});
|
|
17
|
+
declare function parseBody(chunks: Uint8Array[], contentType: string);
|
|
18
|
+
declare async function getRequestBody(req: IncomingMessage & {
|
|
19
|
+
_dataChunks?: Uint8Array[];
|
|
20
|
+
});
|
|
14
21
|
export interface RequestFormData extends IncomingMessage {
|
|
15
22
|
files?: {
|
|
16
23
|
fieldname: string;
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:http";import{StringDecoder as t}from"node:string_decoder";import{URL as
|
|
1
|
+
import e from"node:http";import{StringDecoder as t}from"node:string_decoder";import{URL as r}from"node:url";import{directoryExists as n,ink as o,print as a}from"@moneko/utils";import{watch as c}from"chokidar";import{merge as i}from"webpack-merge";import s from"../commom/log.mjs";import d from"../commom/match-path.mjs";import l,{METHOD_COLOR as m}from"../commom/print-log.mjs";import u from"../commom/require.mjs";import{jsonSchema as p}from"./json-schema.mjs";function f(e){return!["GET","HEAD","OPTIONS"].includes(e.method?.toUpperCase()||"")}export function cacheBody(e){if(!e._bodyCached&&f(e)&&!e.readableEnded){e._bodyCached=!0;try{let t=[],r=e.on.bind(e),n=e.emit.bind(e),o=!1;e.on=function(e,n){return"data"!==e||o||(o=!0,r("data",e=>{t.push(e)})),r(e,n)};let a=!1;e.emit=function(r,...o){return"end"===r&&!a&&(a=!0,t.length>0&&(e._dataChunks=t)),n.call(this,r,...o)}}catch(e){s(e)}}}function h(e,r){try{let n=Buffer.concat(e);if(r.includes("application/json")){let e=new t("utf-8").write(n);return JSON.parse(e)}if(r.includes("application/octet-stream")||r.startsWith("image/"));else if(r.includes("text/"))return n.toString("utf-8");else if(r.includes("application/x-www-form-urlencoded"))return Object.fromEntries(new URLSearchParams(n.toString("utf8")));return n}catch(e){return s(e),null}}async function g(e){return new Promise(t=>{if(!f(e)){t(null);return}let r=e.headers["content-type"]||"",n=e.headers["content-length"],o=e.headers["transfer-encoding"],a=[];if(void 0!==e._dataChunks){t(h(e._dataChunks,r));return}if(!n&&!o){t(null);return}e.on("data",e=>{a.push(e)}),e.on("end",()=>{t(h(a,r))}),e.on("error",e=>{t(null),s(e)})})}function y(e,t,r){if(delete u.cache[t],r[t]){for(let n in r[t])Object.prototype.hasOwnProperty.call(r[t],n)&&(e[n]=null,delete e[n]);r[t]=null,delete r[t]}}export const yApiSchemaMock=(t,r)=>new Promise(n=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),o=p(t);void 0!==r?n(i(o,r)):n(o)}}catch(e){s(e)}})})});export const yApiMock=(t,n)=>new Promise((o,a)=>{let c=new r(n.host),i={hostname:c.hostname,port:c.port,path:t.url?.replace(new RegExp(n.pathRewrite),`/mock/${n.projectId}/`),method:t.method,headers:t.headers,query:Object.fromEntries(c.searchParams)},d=e.request(i,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{o(JSON.parse(t))}catch(e){s(e)}})});d.on("error",e=>{a(e.message)}),d.write(JSON.stringify(t.body)),d.end()});export const oldMock={};export let nextMock={};export function containMockUrl(e){return Object.keys(nextMock).find(t=>RegExp(`^${t.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(e))}export default(e=>{if(!n(e.directory))return;let t=!0;return c(e.directory).on("all",async function(e,r){if("string"==typeof r){switch(a(o("Updating mock...","245"),!0),e){case"add":case"change":try{y(nextMock,r,oldMock);let e=u(r).default;oldMock[r]=e,nextMock=Object.assign(nextMock,e)}catch(e){s(e)}break;case"unlink":y(nextMock,r,oldMock)}t?t=!1:a(o("Mock update successful","245"),!0)}}),(e,t)=>{if(t.writableEnded)return t;let n=new r(`http://localhost:3000${e.url}`),o=e.method||"GET",a=`${o} ${n.pathname}`,c=containMockUrl(a)||a,i=nextMock[c];if(i){if(l(o,n.pathname,{note:"MOCK",labelAlign:"center",labelLen:8,labelForegroundColor:m[o].fg,labelBackgroundColor:m[o].bg}),t.send=e=>t.end("string"==typeof e?e:JSON.stringify(e)),t.writeHead(200,{"Content-Type":e.headers["content-type"]}),"function"==typeof i){let r=d(c.split(" ")[1],n.pathname);n.searchParams&&Object.assign(e,{query:Object.fromEntries(n.searchParams)}),r&&Object.assign(e,{params:r.params}),e.body=g(e);try{i(e,t)}catch(e){s(e)}return!0}return t.end("string"==typeof i?i:JSON.stringify(i)),!0}return!1}});
|
package/lib/dev/server.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import paths from '../commom/paths.mjs';
|
|
|
9
9
|
import { CONFIG } from '../config.mjs';
|
|
10
10
|
import getCert, { type CertOption } from '../dev/get-cert.mjs';
|
|
11
11
|
import { setupProxy } from '../dev/proxy.mjs';
|
|
12
|
-
import setupMock from './mock.mjs';
|
|
12
|
+
import setupMock, { cacheBody } from './mock.mjs';
|
|
13
13
|
export type FileSystem = OutputFileSystem & {
|
|
14
14
|
existsSync: typeof existsSync;
|
|
15
15
|
createReadStream: typeof createReadStream;
|
package/lib/dev/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{extname as o,join as r}from"node:path";import n from"../commom/mime.mjs";import i from"../commom/open.mjs";import s from"../commom/paths.mjs";import{CONFIG as a}from"../config.mjs";import m from"../dev/get-cert.mjs";import{setupProxy as c}from"../dev/proxy.mjs";import l from"./mock.mjs";let
|
|
1
|
+
import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{extname as o,join as r}from"node:path";import n from"../commom/mime.mjs";import i from"../commom/open.mjs";import s from"../commom/paths.mjs";import{CONFIG as a}from"../config.mjs";import m from"../dev/get-cert.mjs";import{setupProxy as c}from"../dev/proxy.mjs";import l,{cacheBody as p}from"./mock.mjs";let d={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"Authorization, Content-Type, Accept, X-Requested-With, Origin, DNT, User-Agent, Cache-Control, X-CSRF-Token, X-API-Key, X-Client-Version, X-Device-ID, Content-Language, Accept-Language, X-Custom-Header, X-Mx-ReqToken, Keep-Alive, If-Modified-Since","Access-Control-Allow-Methods":"GET, DELETE, HEAD, OPTIONS, POST, PUT, PATCH, PURGE, LINK, UNLINK, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, REPORT, SEARCH, CONNECT, TRACE","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"};async function C(C){let h=r(C.root_dir,"index.html"),f=l({directory:s.mockPath});function u(e,t,r){let i=e.headers["accept-encoding"],s=i?.includes("br"),a=`${r}.${s?"br":"gz"}`,m=C.fileSystem.existsSync(a);m&&t.setHeader("Content-Encoding",s?"br":"gzip");let c=C.fileSystem.createReadStream(m?a:r,{autoClose:!0});c.on("open",()=>{t.writeHead(200,Object.assign({},d,C.headers,{"Access-Control-Allow-Origin":e.headers.origin??"*","Content-Type":n[o(r)]||"application/octet-stream"}))}),c.on("error",e=>{switch(c.destroy(),e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),c.pipe(t)}async function A(e,t){if(p(e),!(C.onRequest&&C.onRequest(e,t))&&(a.proxy&&await c(e,t,a.proxy),!(f&&f(e,t))&&!t.writableEnded)){if("GET"===e.method){let o="/"===e.url?h:decodeURIComponent(r(C.root_dir,e.url.replace(C.basename??"/","/")));if(C.fileSystem.existsSync(o))return u(e,t,o)}if(e.headers.accept?.includes("text/html"))return u(e,t,h);t.writeHead(404,{"Content-Type":"text/plain"}),t.end("File Not Found")}}let E=C.https?t(await m(C.host,!0===C.https?{install:!0}:C.https),A):e(A);return E.listen(C.port),C.open&&i(`${C.https?"https:":"http:"}//${C.host}:${C.port}${"/"===C.basename?"":C.basename}`),E}export default C;
|
package/lib/module.config.d.mts
CHANGED
|
@@ -32,7 +32,7 @@ declare const includeJs: string[];
|
|
|
32
32
|
declare const includeMedia: string[];
|
|
33
33
|
declare const includeWasm: string[];
|
|
34
34
|
declare const includeFont: string[];
|
|
35
|
-
declare let sassLoader: RuleSetRule |
|
|
35
|
+
declare let sassLoader: RuleSetRule | void;
|
|
36
36
|
declare const docLoader: false | RuleSetRule;
|
|
37
37
|
declare const IS_UMD: boolean;
|
|
38
38
|
declare const commonOneOf: RuleSetRule[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.50.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -154,5 +154,6 @@
|
|
|
154
154
|
"files": [
|
|
155
155
|
"lib",
|
|
156
156
|
"typings"
|
|
157
|
-
]
|
|
157
|
+
],
|
|
158
|
+
"packageManager": "pnpm@10.14.0"
|
|
158
159
|
}
|
package/typings/global.d.ts
CHANGED