@moneko/core 3.26.1 → 3.26.3-beta.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/bin/build-app.d.mts +16 -1
- package/lib/bin/build-app.mjs +1 -1
- package/lib/bin/build.d.mts +2 -1
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/changelog.d.mts +1 -1
- package/lib/bin/changelog.mjs +3 -3
- package/lib/bin/eslint.d.mts +1 -1
- package/lib/bin/eslint.mjs +1 -1
- package/lib/bin/file.d.mts +0 -15
- package/lib/bin/file.mjs +1 -1
- package/lib/bin/git-hooks.d.mts +1 -1
- package/lib/bin/git-hooks.mjs +1 -1
- package/lib/bin/help.d.mts +2 -0
- package/lib/bin/help.mjs +36 -0
- package/lib/bin/index.d.mts +1 -8
- package/lib/bin/index.mjs +1 -1
- package/lib/bin/lessc.mjs +1 -1
- package/lib/bin/runlint.d.mts +1 -1
- package/lib/bin/runlint.mjs +2 -2
- package/lib/bin/start.d.mts +2 -1
- package/lib/bin/start.mjs +1 -1
- package/lib/bin/stylelint.d.mts +1 -1
- package/lib/bin/stylelint.mjs +1 -1
- package/lib/bin/utils/bundle-app.mjs +1 -1
- package/lib/bin/utils/config.d.mts +0 -1
- package/lib/bin/utils/config.mjs +1 -1
- package/lib/bin/utils/setup-swcrc.d.mts +1 -1
- package/lib/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/build/server.mjs +1 -1
- package/lib/build.mjs +1 -1
- package/lib/{utils → commom}/has-pkg.mjs +1 -1
- package/lib/commom/net.mjs +1 -0
- package/lib/commom/os-tmp-dir.mjs +1 -0
- package/lib/commom/parse-module-meta.mjs +1 -0
- package/lib/{paths.d.mts → commom/paths.d.mts} +2 -4
- package/lib/commom/paths.mjs +1 -0
- package/lib/{utils → commom}/reactive-object.d.mts +1 -1
- package/lib/commom/reactive-object.mjs +1 -0
- package/lib/commom/require.mjs +1 -0
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev/config.mjs +3 -3
- package/lib/dev/json-schema.d.mts +3 -0
- package/lib/dev/json-schema.mjs +1 -0
- package/lib/dev/mock.mjs +1 -1
- package/lib/dev/proxy.d.mts +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/index.d.mts +14 -14
- package/lib/index.mjs +1 -1
- package/lib/loader/css-in-js-minify.cjs +1 -1
- package/lib/loader/css-in-js-minify.d.cts +1 -0
- package/lib/loader/lightning-css/codegen.cjs +20 -0
- package/lib/loader/lightning-css/codegen.d.cts +35 -0
- package/lib/loader/lightning-css/loader.cjs +1 -0
- package/lib/loader/lightning-css/loader.d.cts +29 -0
- package/lib/loader/lightning-css/runtime/api.cjs +1 -0
- package/lib/loader/lightning-css/runtime/get-url.cjs +1 -0
- package/lib/loader/lightning-css/runtime/get-url.d.cts +1 -0
- package/lib/loader/lightning-css/utils.cjs +1 -0
- package/lib/loader/lightning-css/utils.d.cts +16 -0
- package/lib/loader/mdx.cjs +1 -1
- package/lib/loader/react-compiler.cjs +1 -1
- package/lib/loader/solid.d.cts +1 -1
- package/lib/loader/ts-doc.cjs +1 -1
- package/lib/loader/ts-doc.d.cts +1 -1
- package/lib/module.config.mjs +2 -1
- package/lib/options/css-extract.mjs +1 -1
- package/lib/options/html-plugin-option.mjs +1 -1
- package/lib/options/modify-vars.d.mts +1 -1
- package/lib/options/modify-vars.mjs +1 -1
- package/lib/options/reslove.d.mts +0 -1
- package/lib/options/reslove.mjs +1 -1
- package/lib/options/swcrc.mjs +1 -1
- package/lib/plugin/copy.mjs +1 -1
- package/lib/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/module-federation.mjs +1 -1
- package/lib/plugin/override-resolve.mjs +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/plugins.config.mjs +1 -1
- package/lib/polyfills/polyfills.mjs +1 -1
- package/lib/polyfills/targets.mjs +1 -1
- package/lib/process-env.d.mts +1 -1
- package/lib/process-env.mjs +1 -1
- package/lib/utils/create-types.mjs +1 -1
- package/lib/utils/dts.mjs +1 -1
- package/lib/utils/fetch-module-federation-dts.mjs +1 -1
- package/lib/utils/index.d.mts +1 -1
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/run.mjs +1 -1
- package/lib/utils/seo.mjs +2 -2
- package/lib/utils/vts.mjs +1 -1
- package/lib/vm/coverage.mjs +1 -1
- package/lib/vm/docs.d.mts +1 -1
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/example.d.mts +1 -1
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/generate-doc.mjs +1 -1
- package/lib/vm/info.mjs +1 -1
- package/lib/vm/locales.d.mts +1 -1
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/lib/vm/routes.d.mts +1 -1
- package/lib/vm/routes.mjs +1 -1
- package/lib/vm/utils.mjs +1 -1
- package/package.json +3 -4
- package/typings/global.d.ts +21 -21
- package/lib/bin/version.mjs +0 -1
- package/lib/dev/net.mjs +0 -1
- package/lib/loader/lightningcss.cjs +0 -1
- package/lib/loader/lightningcss.d.cts +0 -7
- package/lib/paths.mjs +0 -1
- package/lib/utils/os-tmp-dir.mjs +0 -1
- package/lib/utils/parse-module-meta.mjs +0 -1
- package/lib/utils/print.d.mts +0 -2
- package/lib/utils/print.mjs +0 -2
- package/lib/utils/reactive-object.mjs +0 -1
- package/lib/utils/require.mjs +0 -1
- package/lib/utils/setup-env.d.mts +0 -6
- package/lib/utils/setup-env.mjs +0 -1
- /package/lib/{utils → commom}/diff-object.d.mts +0 -0
- /package/lib/{utils → commom}/diff-object.mjs +0 -0
- /package/lib/{utils → commom}/esm.d.mts +0 -0
- /package/lib/{utils → commom}/esm.mjs +0 -0
- /package/lib/{utils → commom}/get-current-time.d.mts +0 -0
- /package/lib/{utils → commom}/get-current-time.mjs +0 -0
- /package/lib/{utils → commom}/has-pkg.d.mts +0 -0
- /package/lib/{utils → commom}/log.d.mts +0 -0
- /package/lib/{utils → commom}/log.mjs +0 -0
- /package/lib/{utils → commom}/match-path.d.mts +0 -0
- /package/lib/{utils → commom}/match-path.mjs +0 -0
- /package/lib/{dev → commom}/net.d.mts +0 -0
- /package/lib/{utils → commom}/os-tmp-dir.d.mts +0 -0
- /package/lib/{utils → commom}/parse-module-meta.d.mts +0 -0
- /package/lib/{utils → commom}/require.d.mts +0 -0
- /package/lib/{rule.d.mts → commom/rule.d.mts} +0 -0
- /package/lib/{rule.mjs → commom/rule.mjs} +0 -0
- /package/lib/{bin/utils → commom}/setup-env.d.mts +0 -0
- /package/lib/{bin/utils → commom}/setup-env.mjs +0 -0
- /package/lib/{utils → commom}/sigint-exit.d.mts +0 -0
- /package/lib/{utils → commom}/sigint-exit.mjs +0 -0
- /package/lib/{bin/version.d.mts → loader/lightning-css/runtime/api.d.cts} +0 -0
package/lib/bin/build-app.d.mts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 拷贝文件
|
|
3
|
+
* @param {String} source 源文件
|
|
4
|
+
* @param {String} target 目标文件
|
|
5
|
+
* @constructor
|
|
6
|
+
* */
|
|
7
|
+
export declare function copyFileSync(source: string, target: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 拷贝文件夹
|
|
10
|
+
* @param {String} source 源文件夹
|
|
11
|
+
* @param {String} target 目标文件夹
|
|
12
|
+
* @param {String} sun 是否子文件夹
|
|
13
|
+
* @constructor
|
|
14
|
+
* */
|
|
15
|
+
export declare function copyFolderRecursiveSync(source: string, target: string, sun?: boolean): void;
|
|
16
|
+
export default function createApp(): Promise<void>;
|
package/lib/bin/build-app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execSync as e}from"child_process";import i from"fs";import
|
|
1
|
+
import{execSync as e}from"node:child_process";import{existsSync as i,readdirSync as n,statSync as o}from"node:fs";import s from"node:path";import{argv as r}from"node:process";import{buildPlist as t,buildXml as l,createDir as a,ink as c,jsonToYaml as d,loadFileSync as p,parsePlist as m,parseXml as u,parseYaml as f,print as y,println as S,removeDir as $,saveFile as b,saveFileSync as j}from"@moneko/utils";import{bundleApk as _,bundleIOS as g}from"./utils/bundle-app.mjs";import{corePkg as w,cwd as k}from"./utils/config.mjs";import{__dirname as O}from"./file.mjs";export function copyFileSync(e,i){let n=p(e);if(null!==n){let r=i;o(i).isDirectory()&&(r=s.join(i,s.basename(e))),j(r,n)}}export function copyFolderRecursiveSync(e,i,r){let t=i;r&&(t=s.join(i,s.basename(e))),o(e).isDirectory()&&n(e).forEach(function(i){let n=s.join(e,i);o(n).isDirectory()?copyFolderRecursiveSync(n,t,!0):copyFileSync(n,t)})}export default async function A(){r.slice(3).forEach(e=>{let[i,n]=e.replace(/^--/,"").split("=");process.env[`__args__${i}__`]=n});let{CONFIG:j}=await import(`${w}/lib/config.mjs`),A=j.bundleId;A||(S(c("请配置 bundleId","red")),process.exit(1)),/(^com\.)([a-zA-Z_][a-zA-Z0-9_]*[.])*([a-zA-Z_][a-zA-Z0-9_]*)$/.test(A)&&3===A.split(".").length||(S(c("软件包名不合法","red")),process.exit(1));let N=j.bundles;N&&0!==N.length||(S(c("请配置 bundles (打包类型)","red")),process.exit(1));let x=A.split(".").splice(-1,1).join(""),h=s.join(k,"/dist"),E=`flutter create -t app --org ${A} -i swift -a kotlin ${x}`,R=s.join(k,`/${x}`),T=s.join(R,"assets/web/");e(E,{encoding:"utf-8"}),a(T),y(c("正在注册资产...","yellow"),!0),copyFolderRecursiveSync(h,T);let V=s.join(R,"pubspec.yaml"),v=JSON.parse(await f(V)||"{}"),I=[],J=(e,i="assets/web")=>{let s=n(e);!function n(r){r!=s.length&&(o(`${e}/${s[r]}`).isDirectory()&&(I.push(`${i}/${s[r]}/`),J(`${e}/${s[r]}`,`${i}/${s[r]}`)),n(r+1))}(0)};if(J(h),v.dependencies.webview_flutter_plus="^0.2.3",v.flutter.assets=["assets/web/",...I],b(V,await d(JSON.stringify(v))),y(`${c("注册资产","cyan")}: ${c("完成","cyan")}`,!0),N.includes("apk -release")||N.includes("apk -debug")){y(c("正在配置安卓权限...","yellow"),!0);let e=s.join(R,"android/app/src/main/AndroidManifest.xml"),i=JSON.parse(u(e));i.manifest.application.$["android:usesCleartextTraffic"]="true",i.manifest["uses-permission"]=[{$:{"android:name":"android.permission.INTERNET"}},{$:{"android:name":"android.permission.ACCESS_NETWORK_STATE"}},{$:{"android:name":"android.permission.WAKE_LOCK"}}],b(e,l(JSON.stringify(i)));let n=s.join(R,"android/app/build.gradle"),o=p(n)||"",r="minSdkVersion flutter.minSdkVersion";if(o?.includes(r))o=o.replace(r,"minSdkVersion 20");else{let e=o.indexOf("minSdkVersion "),i=o.substring(e,e+16);o=o.replace(i,"minSdkVersion 20")}let t="compileSdkVersion flutter.compileSdkVersion";o.includes(t)&&(o=o.replace(t,"compileSdkVersion 32")),b(n,o),y(`${c("安卓权限配置","cyan")}: ${c("完成","cyan")}`,!0)}if(N.includes("ios -release")||N.includes("ios -debug")){y(c("开始配置IOS权限","yellow"),!0);let e=s.join(R,"ios/Runner/Info.plist"),i=Object.assign(JSON.parse(await m(e)),{NSAppTransportSecurity:{NSAllowsArbitraryLoads:!0},"io.flutter.embedded_views_preview":!0});b(e,await t(JSON.stringify(i))),y(`${c("IOS权限配置","cyan")}: ${c("完成","cyan")}`,!0)}b(s.join(R,"lib/main.dart"),p(s.join(O,"./conf/bootstrap"))||"");let D=s.join(k,"./bundle/");a(D),setTimeout(()=>{N.forEach(e=>{let i=e.split(" ");"apk"===i[0]&&_(R,D,i[1]),"ios"===i[0]&&g(R,D,i[1])}),$(R),i(s.join(D,"Runner"))&&$(s.join(D,"Runner")),y(`✨ ${c("Done","green")}`,!0),process.exit(0)},1e3)}
|
package/lib/bin/build.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare function build(): Promise<void>;
|
|
2
|
+
export default build;
|
package/lib/bin/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as
|
|
1
|
+
import{spawn as o}from"node:child_process";import{join as e,relative as s}from"node:path";import{argv as t}from"node:process";import{deleteEmptyDirs as i,ink as r,println as n,removeDir as m,removeFile as l,scanFolderSync as c,updateFileSync as p}from"@moneko/utils";import d from"../commom/require.mjs";import f from"../commom/setup-env.mjs";import{corePkg as u,cwd as a,runtimePath as j,swcCachePath as $}from"./utils/config.mjs";import y from"./utils/setup-swcrc.mjs";import{__dirname as _}from"./file.mjs";import{lesscCommonjs as g}from"./lessc.mjs";let b={stdio:"inherit",shell:!0};async function h(){let h=t[3],x=t[4],v=t.slice(5);h||(n(r(`type: 无效值 ${r(h,"245")}`,"red")),process.exit(1));let C=!v.includes("no-docs"),w=!v.includes("no-lib"),E=!v.includes("no-es"),D=v.filter(o=>!["no-docs","no-es","no-lib"].includes(o));await f("production",h,x,D);let S=`${j} ${d.resolve(`${u}/lib/build.mjs`)}`;if("library"===h){let t=y(x),r=d.resolve("typescript/bin/tsc"),n=d.resolve("@swc/cli/bin/swc.js"),f=[w&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},E&&{type:"es6 -C jsc.target=es2015",dir:"es",msg:"Convert to ES Module"}].filter(Boolean),u=e(_,".types.json");f.length&&p(u,JSON.stringify({extends:s(_,e(a,"tsconfig.json")),include:[s(_,e(a,"components")),s(_,e(a,"typings"))],exclude:[s(_,e(a,"components/**/examples/*")),s(_,e(a,"components/**/__tests__/*")),s(_,e(a,"components/**/__mocks__/*"))]}));for(let s=0,p=f.length;s<p;s++){let p=e(a,`./${f[s].dir}`);m(p),o(`${j} ${n} components -d ${f[s].dir} -q --strip-leading-paths --config-file ${t} -C jsc.experimental.cacheRoot=${$} -C module.type=${f[s].type} -D --ignore "**/*.test.(js|ts)x?$"`,b).on("close",function(o){0===o&&(c(p,["README.mdx","examples","__*__"]).forEach(l),i(p),"commonjs"===f[s].type&&g())}),o(`${j} ${r} --project ${u} --outDir ${f[s].dir}`,b)}}("library"!==h||C&&"library"===h)&&o(S,b)}export default h;
|
package/lib/bin/changelog.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function changelog(): void;
|
package/lib/bin/changelog.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{execSync as t}from"child_process";import{join as e}from"path";import{
|
|
2
|
-
${t.title}`),t.logs)Object.prototype.hasOwnProperty.call(t.logs,e)&&(
|
|
1
|
+
import{execSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o}from"node:process";import{updateFileSync as r}from"@moneko/utils";import s from"../commom/log.mjs";import{cwd as i}from"./utils/config.mjs";let n={feat:"✨ Features",fix:"🐛 Bug Fixes",docs:"📚 Documentation",style:"💎 Styles",refactor:"📦 Code Refactoring",perf:"🚀 Performance Improvements",test:"🚨 Tests",build:"🛠 Builds",ci:"⚙️ Continuous Integrations",chore:"♻️ Chores",revert:"🗑 Reverts"};function a(e,o){return function(t){let e=[];for(let o of t.trim().split("\n")){let[t,r,s,i,a]=o.split("|");if(a){let o=a.split(": "),l=n[o[0]];e.push({commitId:t,author:r,email:s,date:new Date(i).toLocaleString().replace(/\//g,"-"),message:l?o.slice(1).join(":"):a,type:l})}}return e}(t(`git log ${e?`${e}..`:""}${o||""} --format='%H|%an|%ae|%ad|%s'`,{encoding:"utf-8"}))}export default function l(){let n=o[3],l=["# Change log"];try{t('git show-ref --quiet --verify "refs/heads/$(git rev-parse --abbrev-ref HEAD)";');let e=t('git config --get remote.origin.url | sed "s/\\.git$//"').toString().trim(),o=function(e){let o=t("git for-each-ref --sort='v:refname' --format '%(objectname) %(refname:short) %(creatordate:iso8601)' refs/tags",{encoding:"utf-8"}),r=[],s=o.trim().split("\n");return s.forEach((t,o)=>{let[i,n,a]=t.split(" "),l=s[o-1]?.split(" ")[1],m=`## ${n}`;l&&(m=`## [${n}](${e}/compare/${l}...${n}) (${new Date(a).toLocaleDateString().replace(/\//g,"-")})`),r.push({commitId:i,tag:n,date:a,title:m,logs:{}})}),r}(e);o.forEach((t,r)=>{if(r&&a(o[r-1].tag,t.tag).forEach(t=>{if(t.type){let s=o[r].logs[t.type]||[];s.push(`- ${t.message} ([${t.commitId.substring(0,7)}](${e}/commit/${t.commitId}))`),Object.assign(o[r].logs,{[t.type]:s})}}),r===o.length-1){let s=a(t.tag);s.length&&o.push({title:"## Last",logs:{}}),s.forEach(t=>{if(t.type){let s=o[r+1].logs[t.type]||[];s.push(`- ${t.message} ([${t.commitId.substring(0,7)}](${e}/commit/${t.commitId}))`),Object.assign(o[r+1].logs,{[t.type]:s})}})}}),o.reverse().forEach(t=>{for(let e in l.push(`
|
|
2
|
+
${t.title}`),t.logs)Object.prototype.hasOwnProperty.call(t.logs,e)&&(l.push(`
|
|
3
3
|
### ${e}
|
|
4
|
-
`),t.logs[e].forEach(t=>
|
|
4
|
+
`),t.logs[e].forEach(t=>l.push(t)))})}catch(t){l.push("\n当前分支尚无任何提交\n"),s(t)}r(e(i,n),l.join("\n"))}
|
package/lib/bin/eslint.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function eslint(): void;
|
package/lib/bin/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o,relative as i}from"path";import{
|
|
1
|
+
import{join as o,relative as i}from"node:path";import{argv as e}from"node:process";import t from"../commom/require.mjs";import{cachePath as m,cwd as n,runtimePath as r}from"./utils/config.mjs";import{runLint as s}from"./runlint.mjs";export default function c(){let c=e[3],l=e.slice(4),f=o(t.resolve("eslint"),"../../bin/eslint.js");s(`${r} ${f} ${i(n,c)} --config ${i(n,"eslint.config.mjs")} ${l.join(" ")} --cache --cache-location "${m}/.eslintcache"`,"eslint")}
|
package/lib/bin/file.d.mts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
1
|
export declare const __filename: string;
|
|
2
2
|
export declare const __dirname: string;
|
|
3
|
-
/**
|
|
4
|
-
* 拷贝文件
|
|
5
|
-
* @param {String} source 源文件
|
|
6
|
-
* @param {String} target 目标文件
|
|
7
|
-
* @constructor
|
|
8
|
-
* */
|
|
9
|
-
export declare function copyFileSync(source: string, target: string): void;
|
|
10
|
-
/**
|
|
11
|
-
* 拷贝文件夹
|
|
12
|
-
* @param {String} source 源文件夹
|
|
13
|
-
* @param {String} target 目标文件夹
|
|
14
|
-
* @param {String} sun 是否子文件夹
|
|
15
|
-
* @constructor
|
|
16
|
-
* */
|
|
17
|
-
export declare function copyFolderRecursiveSync(source: string, target: string, sun?: boolean): void;
|
package/lib/bin/file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"node:path";import o from"node:url";export const __filename=o.fileURLToPath(import.meta.url);export const __dirname=e.dirname(__filename);
|
package/lib/bin/git-hooks.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function githooks(): void;
|
package/lib/bin/git-hooks.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{argv as o}from"node:process";import{runLint as t}from"./runlint.mjs";export default function e(){let e="node_modules/.husky",i=o.slice(3).map(o=>{let t=o.split("=");return`echo "${t[1]}" > ${e}/${t[0]}`}).join(" && ");t(`git init && husky ${e} && ${i}`,"githooks",[null])}
|
package/lib/bin/help.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{ink as e,println as $}from"@moneko/utils";export default function(){let l="react | solid | vue",r="backstage | library | site | micro | mobile";$(`
|
|
2
|
+
${e("使用方法:","white")} ${e("mo","blue")} ${e("<命令>","green")} ${e("<必选参数>","208")} ${e("[可选参数]","yellow")}
|
|
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("githooks","green")} 配置 Git 钩子以自动化工作流
|
|
20
|
+
|
|
21
|
+
${e("buildApp","green")} 创建新的应用程序脚手架
|
|
22
|
+
|
|
23
|
+
${e("changelog","green")} ${e("<filename>","208")} 生成项目变更日志
|
|
24
|
+
${e("filename: ","245",{bold:!0})}${e("输出的文件名","245",{italic:!0})}
|
|
25
|
+
|
|
26
|
+
${e("选项:","white")}
|
|
27
|
+
${e("-v, --version","yellow")} 显示版本信息
|
|
28
|
+
${e("-h, --help","yellow")} 显示帮助信息
|
|
29
|
+
|
|
30
|
+
${e("示例:","white")}
|
|
31
|
+
${e("mo","blue")} ${e("start","green")} ${e("library react","208")} ${e("# 启动开发服务器","245")}
|
|
32
|
+
${e("mo","blue")} ${e("build","green")} ${e("library react","208")} ${e("# 构建生产版本","245")}
|
|
33
|
+
${e("mo","blue")} ${e("eslint","green")} ${e("components","208")} ${e("# 检查并修复代码","245")}
|
|
34
|
+
${e("mo","blue")} ${e("stylelint","green")} ${e("src","208")} ${e("# 检查样式文件","245")}
|
|
35
|
+
${e("mo","blue")} ${e("changelog","green")} ${e("CHANGELOG.md","208")} ${e("# 生成变更日志","245")}
|
|
36
|
+
`)}
|
package/lib/bin/index.d.mts
CHANGED
package/lib/bin/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{argv as a}from"node:process";import{ink as t,println as e}from"@moneko/utils";import i from"../commom/require.mjs";import s from"../commom/sigint-exit.mjs";import{corePkg as o}from"./utils/config.mjs";switch(a[2]){case"-v":case"--version":e(`${t(o,"blue")}: ${i(`${o}/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;default:(await import("./help.mjs")).default()}s(()=>{process.exit(0)});
|
package/lib/bin/lessc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{exec as e}from"node:child_process";import{join as o}from"node:path";import{loadFile as s,saveFile as t,scanFolderSync as i}from"@moneko/utils";import r from"../commom/require.mjs";import{corePkg as l,runtimePath as m}from"./utils/config.mjs";let n="";function a(s){let t=o(r.resolve("less"),"../bin/lessc");return new Promise((o,i)=>{e(`${m} ${t} --js ${n} ${s} > ${s.replace(/\.less$/g,".css")}`,function(e){if(e)return i(e);o(!0)})})}let c=/\*?\.less/g;async function f(e){let o=await s(e);o&&c.test(o)&&await t(e,o.replace(c,".css"))}export async function lesscCommonjs(){let e=i("lib",["\\.less$"]),o=(await import(`${l}/lib/options/modify-vars.mjs`)).default;for(let e in o)Object.hasOwnProperty.call(o,e)&&(n+=`--modify-var="${e}=${o[e]}" `);Promise.all(e.map(a)),e.length&&Promise.all(i("lib",["\\.js$"]).map(f))}
|
package/lib/bin/runlint.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StdioOptions } from 'child_process';
|
|
1
|
+
import { StdioOptions } from 'node:child_process';
|
|
2
2
|
export declare const runLint: (shellSrc: string, pluginName: string, stdio?: StdioOptions) => never;
|
package/lib/bin/runlint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,0!==n.status?"red":"green")
|
|
1
|
+
import{spawnSync as t}from"node:child_process";import{ink as s,print as e}from"@moneko/utils";export const runLint=(o,r,i="inherit")=>{let l=s(r,"cyan");e(`${l}: ${s("Runing...","yellow")}`,!0);let n=t(o,{stdio:i,shell:!0}),u=s(`✨ ${0!==n.status?"Error":"Successfully"}!
|
|
2
|
+
`,0!==n.status?"red":"green");e(`${l}: ${u}`,!0),process.exit(n.status||0)};
|
package/lib/bin/start.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare function start(): Promise<void>;
|
|
2
|
+
export default start;
|
package/lib/bin/start.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as
|
|
1
|
+
import{spawn as o}from"node:child_process";import{argv as e}from"node:process";import{ink as m,println as i}from"@moneko/utils";import r from"../commom/require.mjs";import t from"../commom/setup-env.mjs";import{corePkg as s,runtimePath as p}from"./utils/config.mjs";async function l(){let l=e[3],n=e[4],c=e.slice(5);l||(i(m(`type: 无效值 ${m(l,"245")}`,"red")),process.exit(1));let f=c.indexOf("no-verify");-1!==f&&c.splice(f,1),await t("development",l,n,c),o(`${p} ${r.resolve(`${s}/lib/dev.mjs`)}`,{stdio:"inherit",shell:!0})}export default l;
|
package/lib/bin/stylelint.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function stylelint(): void;
|
package/lib/bin/stylelint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{join as s,relative as t}from"node:path";import{argv as e}from"node:process";import o from"../commom/require.mjs";import{cachePath as i,cwd as l,runtimePath as m}from"./utils/config.mjs";import{runLint as r}from"./runlint.mjs";export default function c(){let c=e[3],n=e.slice(4),a=s(o.resolve("stylelint"),"../../bin/stylelint.mjs");r(`${m} ${a} ${t(l,c)}/**/**/**/**/*.{less,css,scss,sass,style.ts,style.js} ${n.join(" ")} --cache --cache-location "${i}/.stylelintcache" --aei`,"stylelint")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
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 l,ink as i,print as t}from"@moneko/utils";export function bundleApk(p,a,u="-release"){t(i("正在编译 apk...","yellow"),!0),console.time(`bundle apk ${u}`),e(`flutter build apk -${u}`),console.timeEnd(`bundle apk ${u}`),l(a),o(n(p,`build/app/outputs/flutter-apk/app${u}.apk`),a),t(`✨ ${i("Apk 编译","cyan")}: ${i("完成","cyan")}`,!0)}export function bundleIOS(a,u,r="-release"){t(i("正在编译 ipa...","yellow"),!0),console.time(`bundle ipa ${r}`);let d=n(u,"Runner/Payload");e(`flutter build ios -${r} --no-codesign`),l(d),o(n(a,"build/ios/iphoneos/Runner.app"),d),p(n(u,"Runner"),u,r),console.timeEnd(`bundle ipa ${r}`),t(`✨ ${i("ipa 编译","cyan")}: ${i("完成","cyan")}`,!0)}
|
package/lib/bin/utils/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{dirname as e,join as o}from"node:path";let c="undefined"!=typeof Deno?"deno":"undefined"!=typeof Bun?"bun":"node",t=e(process.execPath);"win32"===process.platform&&t.includes(" ")&&(t=`"${t}"`);export const runtimePath=o(t,c);export const corePkg="@moneko/core";export const cwd=process.cwd();export const cachePath=o(cwd,"node_modules/.cache");export const swcCachePath=o(cachePath,".swc");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function setupSwcRc(framework:
|
|
1
|
+
declare function setupSwcRc(framework: string): string;
|
|
2
2
|
export default setupSwcRc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"path";import{
|
|
1
|
+
import{join as e}from"node:path";import{updateFileSync as o}from"@moneko/utils";import r from"../../commom/require.mjs";import{__dirname as s}from"../file.mjs";let m=e(s,".swcrc");export default function(e){let s="solid"===e;return o(m,JSON.stringify({$schema:"https://json.schemastore.org/swcrc",module:{type:"es6"},minify:!0,jsc:{minify:{mangle:!0,compress:!0,format:{comments:"some"}},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:"react"===e,development:!1,importSource:s?"solid-js/h":void 0}},experimental:{plugins:[[r.resolve("@moneko/transform-imports"),{"@moneko/common":{transform:"@moneko/common/lib/${member}"},lodash:{transform:"lodash/${member}"},"@ant-design/icons":{transform:"es/icons/${member}"},antd:{transform:"es/${member}",memberTransformers:["dashed_case"]},"neko-ui":{transform:"es/${member}",memberTransformers:["dashed_case"]}}],s&&[r.resolve("@moneko/jsx-dom-expressions"),{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]})),m}
|
package/lib/build/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e
|
|
1
|
+
import{CUSTOMCONFIG as e}from"../commom/paths.mjs";import s from"../module.config.mjs";import{isLibrary as m}from"../process-env.mjs";import{resolveProgram as o}from"../utils/index.mjs";let t={name:"server",target:"node",dependencies:["client"],entry:{main:o("site/ssr.tsx")},output:{path:o(`${m?"docs":"dist"}/server`),library:{type:"commonjs2",umdNamedDefine:!1},filename:"[name].cjs",chunkFilename:"[chunkhash].cjs",globalObject:"global"},cache:{type:"filesystem",name:[e,process.env.NODE_ENV,"server"].filter(Boolean).join("-")},externalsPresets:{node:!0},externals:[],module:s(!0)};export default t;
|
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{analyzeBundleSize as
|
|
1
|
+
import{relative as o}from"node:path";import{analyzeBundleSize as m,completedInfo as r,ink as t,println as i,progressBar as e}from"@moneko/utils";import n from"webpack";import{merge as s}from"webpack-merge";import a from"./build/common.mjs";import p from"./commom/paths.mjs";import l from"./plugin/done.mjs";import{empty as c}from"./utils/index.mjs";import f from"./utils/seo.mjs";import{CONFIG as u}from"./config.mjs";import d from"./module.config.mjs";let h=u.bar.name||"Build",{ProgressPlugin:g}=n,w=n(s(a,{module:d(!1),plugins:[u.done&&new l({done:u.done}),!!u.bar&&new g({handler(o,m,...r){e(o||0,1,h,r.length?`[${m}] ${r.join(" ")}`:""),1===o&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}));async function j(){let e=await new Promise((o,m)=>{w.run((r,t)=>{r&&m(r),t?o(t):m(Error("编译过程中没有生成统计信息"))})});(e.hasErrors()||e.hasWarnings())&&function(o){let{warnings:m,errors:r}=o.compilation;m.forEach(o=>{i(t(o.message,"178"))}),r.forEach(o=>{i(t(o.message,"red"))})}(e),await new Promise(n=>{e.compilation.compiler.cache.shutdown(s=>{s&&i(t(s.toString(),"red")),m(e.compilation.outputOptions.path,["\\.js$"]),r(~~((e.endTime-e.startTime)/10)/100,o(p.programPath,e.compilation.outputOptions.path)),n()})}),u.seo&&f()}process.on("exit",c),await j();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./require.mjs";export default function(e){try{return r.resolve(e)}catch
|
|
1
|
+
import r from"./require.mjs";export default function(e){try{return r.resolve(e)}catch{return!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createConnection as e}from"node:net";import{networkInterfaces as t}from"node:os";export function getIPv4(){let e=t(),o=null,r=Object.keys(e);for(let t=0,n=r.length;t<n;t++){let n=e[r[t]]||[];for(let e=0,t=n.length;e<t;e++){let t=n[e];"IPv4"!==t.family||t.internal||(o=t.address)}}return o}export function getPort(t,o="0.0.0.0"){return new Promise((r,n)=>{if("number"!=typeof t)r(t);else{let l=e(t,o);l.on("connect",()=>{l.destroy(),r(getPort(t+1,o))}),l.on("error",e=>{l.destroy(e),"ECONNREFUSED"===e.code?r(t):n(e)})}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function(){let e;let s="win32"===process.platform;return e=s?process.env.TEMP||process.env.TMP||`${process.env.SystemRoot||process.env.windir}\\temp`:process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",(s?/[^:]\\$/:/.\/$/).test(e)&&(e=e.slice(0,-1)),e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import n from"./paths.mjs";export default function(a,o=1){let t=a.replace(/^\/|\/$/g,"").replace(/\\/g,"/"),i=t,m="index.ts",d=t.match(/(.+)\/index\.([^/]+)$/),r=t.match(/(.+)\.([^/]+)$/);return d?(i=d[1],m=`index.${d[2]}`):r&&(i=r[1],m=`index.${r[2]}`),{name:i,main:m,pkg:e(n.nodeModules,i,"package.json"),file:e(n.nodeModules,i,m),meta:`{"name":"${i}","main":"${m}","version":"0.0.${o}","description": ""}`}}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** 当前文件的绝对路径 */
|
|
2
|
-
export declare const __filename: string;
|
|
3
1
|
/** 当前文件所在目录的绝对路径 */
|
|
4
2
|
export declare const __dirname: string;
|
|
5
3
|
/** yarn 命令行参数对象,包含配置选项 */
|
|
@@ -15,12 +13,12 @@ export declare const yarnArgv: Record<string, string> & {
|
|
|
15
13
|
*/
|
|
16
14
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
17
15
|
declare const paths: {
|
|
18
|
-
__dirname: string;
|
|
19
|
-
__filename: string;
|
|
20
16
|
/** node_modules 目录路径 */
|
|
21
17
|
nodeModules: string;
|
|
22
18
|
/** pnpm node_modules 目录路径 */
|
|
23
19
|
pnpmNodeModules: string;
|
|
20
|
+
/** deno node_modules 目录路径 */
|
|
21
|
+
denoNodeModules: string;
|
|
24
22
|
/** 核心代码路径 */
|
|
25
23
|
corePath: string;
|
|
26
24
|
/** 项目根目录路径 */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as o}from"node:path";import e from"node:url";import{fileExists as t}from"@moneko/utils";let n=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __dirname=e.fileURLToPath(new URL("..",import.meta.url));export const yarnArgv={};for(let o=0,e=n.length;o<e;o++){let e=n[o].split("=");Object.assign(yarnArgv,{[e[0]]:e[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config||process.env.__args__config__;let c=process.cwd(),a=o(c,"./node_modules"),r={nodeModules:a,pnpmNodeModules:o(a,"./.pnpm/node_modules"),denoNodeModules:o(a,"./.deno"),corePath:__dirname,programPath:c,webpackCachePath:o(a,"./.cache"),lintCachePath:o(a,"./.cache"),httpCachePath:o(a,"./.cache/http"),swcCachePath:o(a,"./.cache/.swc"),configPath:o(c,"./config/index.ts"),customConfigPath:o(c,`./config/${CUSTOMCONFIG}.ts`),coveragePath:o(c,"./coverage/clover.xml"),pagesPath:o(c,"./src/pages"),componentsPath:o(c,"./components"),mockPath:o(c,"./mock")};export const config_files=[t(r.configPath)&&r.configPath,t(r.customConfigPath)&&r.customConfigPath].filter(Boolean);export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"node:events";class e extends t{constructor(t={}){super(),this.data=t}setData(t,e){this.data[t]!==e&&(this.data[t]=e,this.emit("change",t,e))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{transformFileSync as o}from"@swc/core";let t=e(import.meta.url),s={sourceMaps:!1,module:{type:"commonjs"},jsc:{parser:{syntax:"typescript"}}};function r(e,t){return e._compile(o(t,s).code,t)}t.extensions[".ts"]=r,t.extensions[".mts"]=r,t.extensions[".mjs"]=r;export default t;
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{extname as e,join as t,resolve as o}from"node:path";import a,{config_files as n,CUSTOMCONFIG as s}from"./commom/paths.mjs";import i from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as r,resolveProgram as m}from"./utils/index.mjs";import{exampleModuleName as p}from"./vm/example.mjs";import c from"./vm/info.mjs";import{CONFIG as u,PUBLICPATH as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isDev as f,isLibrary as g,NODE_ENV as b,PACKAGENAME as y,PACKAGEVERSION as j}from"./process-env.mjs";export const outputConfig={path:m(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${f?"name":"contenthash"}].js`,assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[name][hash][ext]`},library:{name:`${c.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:f,clean:!0,publicPath:d,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[u.polyfill&&t(a.corePath,"./polyfills/replace-children.mjs"),r("@app/entry")].filter(Boolean)};u.entry&&("string"==typeof u.entry?v={main:[u.entry]}:Object.keys(u.entry)&&(v=Object.assign(v,u.entry))),"string"==typeof v.main&&(v.main=[v.main]),u.output&&("string"==typeof u.output?outputConfig.path=u.output:Object.keys(u.output)&&Object.assign(outputConfig,u.output));let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[s,b].filter(Boolean).join("-")}`,version:`${j}`,buildDependencies:{config:n}};!1===u.cache?C=!1:l(u.cache)&&(C=Object.assign(C,u.cache));let k=Object.assign({original:u.alias["@"],override:s&&m(s)},u.overrideResolve);export const commonConfig={name:"client",target:"web",devtool:u.devtool,entry:v,mode:f?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:u.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:u.lazyCompilation&&f&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(r(p))||t.startsWith(r("@app/comment"))||t.startsWith(a.pagesPath)||t.startsWith(a.componentsPath)))}},buildHttp:l(u.buildHttp)?{allowedUris:[],lockfileLocation:o(a.httpCachePath,"http.lock"),cacheLocation:o(a.httpCachePath,"data"),upgrade:!0,...u.buildHttp}:u.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:u.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[u.overrideResolve&&new i(k),...u.resolvePlugins].filter(Boolean),preferAbsolute:!0,cache:!0,fallback:{}},externals:u.externals,output:outputConfig};
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fileExists as e}from"@moneko/utils";import{merge as o}from"webpack-merge";import t from"./commom/paths.mjs";import n from"./commom/require.mjs";import s from"./commom/setup-env.mjs";import i from"./options/jsx-dom-expressions.mjs";import r from"./options/split-chunk.mjs";import{isFunction as l,resolveProgram as a}from"./utils/index.mjs";import{APPTYPE as m,FRAMEWORK as p,isDev as c,isLibrary as u,isMobile as d,jsxImportSource as f,mainDirectory as h,NODE_ENV as g,PACKAGENAME as x}from"./process-env.mjs";let v=["@app","@moneko","neko-ui",".cache/http/data","@ant-design","@antv","@antv/x6","@antv/x6-react-components","@element-plus","ant-design-vue","antd","antd-mini","antd-mobile","antd-mobile-icons","element-plus","element-ui","ng-zorro-antd","@antv","@mui","@du","ahooks","rc-queue-anim","umi","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design"];export function getConfig(o){return delete n.cache[o],new Promise(t=>{if(e(o)){let e=n(o).default;return t(l(e)?e(process):e)}return t({})})}let[P,b,w]=await Promise.all([s(g,m,p,[]),getConfig(t.configPath),getConfig(t.customConfigPath)]),C={devtool:c?"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:P,basename:"/",publicPath:"/",rem:{designSize:d?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":a(h)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:r,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:v,js:v,media:v,font:v,wasm:[]},mdx:{jsx:!1,development:c,jsxImportSource:f,providerImportSource:`@moneko/${p}/mdx`},jsxDomExpressions:i,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==p,bundleId:"com.moneko.bid",bundles:[]};u&&(C.alias=Object.assign(C.alias,{"@pkg":t.componentsPath,[x]:t.componentsPath}));let j=C;(!1===(j=o(j,b,w)).devtool||!1===j.sourceMap)&&(j.sourceMap=!1,j.devtool=!1),j.fixBrowserRouter&&j.htmlPluginOption&&(j.htmlPluginOption.tags||(j.htmlPluginOption.tags=[]),j.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=j;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/dev/config.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,"245");function
|
|
3
|
-
${
|
|
1
|
+
import{ink as e,print as t,println as o,termClear as r}from"@moneko/utils";import{getIPv4 as n,getPort as i}from"../commom/net.mjs";import{CONFIG as m}from"../config.mjs";let s=m.devServer.port||3e3;export const PORT=await i(s);m.devServer.port=PORT;let l="/"===m.basename?"":m.basename,$=s!==PORT&&e(`Port ${e(`${s}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
|
|
2
|
+
`,"245");function a(e){return`${m.devServer.https?"https":"http"}://${"local"===e?m.devServer.host:n()}:${PORT}${l}`}let p=e("You application is running here:","245"),c=`${e(" Local ","231",{bg:"blue"})} ${e(a("local"),"75")}
|
|
3
|
+
${e(" Network ","231",{bg:"29"})} ${e(a("net"),"green")}`;export function devLog(n,i){!n&&i&&(r(3),t([p,"",c,"",e(`Compiled successfully in ${e(`${i.endTime-i.startTime}ms`,"green")}`,"245")].join("\n"),!0),$&&o($))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,m){return Math.min(Math.max(e,t),m)}export function jsonSchema(t){if(void 0!==(t=function e(t){return t.allOf&&t.allOf[0]&&(t=t.allOf.reduce((t,m)=>Object.assign({},t,e(m)),t)),t}(t)).example)return t.example;if(void 0!==t.default)return t.default;if(t.oneOf&&t.oneOf[0])return jsonSchema(t.oneOf[0]);if(t.anyOf&&t.anyOf[0])return jsonSchema(t.anyOf[0]);let m=Array.isArray(t)?t[0].type:t.type;if("object"===m){let{properties:e}=t;return e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,jsonSchema(t)])):{}}if("array"===m){let e=t,m=e.items;if(!m)return[];let n=[],i=m.oneOf&&m.oneOf[0]||m;if(m.anyOf)for(let e of m.anyOf)i=e,n.push(jsonSchema(i));let r=e.minItems||1;for(;n.length<r;)n.push(jsonSchema(i));return e.maxItems?function(e,t=1){return e.slice(0,t)}(n,e.maxItems):n}if(Array.isArray(t.enum))return t.enum[0];if("string"===m){let{format:m}=t,n={email:"user@example.com",hostname:"example.com",ipv4:"8.8.8.8",ipv6:"2001:4860:4860::8888",uri:"https://example.com/path","uri-reference":"/path#anchor","uri-template":"/path/{param}","json-pointer":"/foo/bar","date-time":new Date("1970-01-01").toJSON(),uuid:"3fa85f64-5717-4562-b3fc-2c963f66afa6",_default:"string"},i=n[m]||n._default,r=t.minLength?t.minLength:0,u=t.maxLength?t.maxLength:i.length;return i===n._default&&i.length<r?i.padEnd(r,i):i.substring(0,e(i.length,r,u))}if("number"===m){let m=t.minimum?t.minimum:-Number.MAX_VALUE,n=t.maximum?t.maximum:Number.MAX_VALUE;return t.multipleOf&&(m=Math.ceil(m/t.multipleOf)*t.multipleOf,n=Math.floor(n/t.multipleOf)*t.multipleOf),e(0,m,n)}if("integer"===m){let m=t.minimum&&t.exclusiveMinimum?t.minimum+1:t.minimum,n=t.maximum&&t.exclusiveMaximum?t.maximum-1:t.maximum,i=m||Number.MIN_SAFE_INTEGER,r=n||Number.MAX_SAFE_INTEGER;return t.multipleOf&&(i=Math.ceil(i/t.multipleOf)*t.multipleOf,r=Math.floor(r/t.multipleOf)*t.multipleOf),e(0,i,r)}return"null"===m?null:"boolean"===m||{}}
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"http";import{
|
|
1
|
+
import e from"node:http";import{print as t}from"@moneko/utils";import{watch as o}from"chokidar";import r from"express";import{merge as a}from"webpack-merge";import n from"../commom/log.mjs";import s from"../commom/match-path.mjs";import c from"../commom/require.mjs";import{jsonSchema as i}from"./json-schema.mjs";function m(e,t,o){if(delete c.cache[t],o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&(e[r]=null,delete e[r]);o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise(r=>{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),n=i(t);void 0!==o?r(a(n,o)):r(n)}}catch(e){n(e)}})})});export const yApiMock=(t,o)=>new Promise((r,a)=>{let s=new URL(o.host),c={hostname:s.hostname,port:s.port,path:t.path.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:t.method,headers:t.headers,query:t.query},i=e.request(c,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{r(JSON.parse(t))}catch(e){n(e)}})});i.on("error",e=>{a(e.message)}),i.write(JSON.stringify(t.body)),i.end()});export default(e=>{let a={},i={};return o(e).on("all",async function(e,o){switch(t("Updating mock...",!0),e){case"add":case"change":try{m(i,o,a);let e=c(o).default;a[o]=e,i=Object.assign(i,e)}catch(e){n(e)}break;case"unlink":m(i,o,a)}t("Mock update successful",!0)}),function(e,t,o){let a=`${e.method} ${e.path}`,n=Object.keys(i).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(a)});if(!i[a]&&(!n||!(n.length>0)))return o();{let c;let m=e.get("Content-Type");switch(m){case"text/plain":c=r.raw({type:"text/plain"});break;case"text/html":c=r.text({type:"text/html"});break;case"application/x-www-form-urlencoded":c=r.urlencoded({extended:!1});break;default:c=r.json()}m?.startsWith("multipart/form-data;")&&(c=r.static("./public")),c(e,t,function(){let r=i[a]||i[n[0]];if("function"==typeof r){let a=s(n[0].split(" ")[1],e.url);a&&Object.assign(e.params,a.params),r(e,t,o)}else t.json(r)})}}});
|
package/lib/dev/proxy.d.mts
CHANGED
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import t from"
|
|
1
|
+
let e;import{exec as t,spawn as o}from"node:child_process";import{watchFile as r}from"node:fs";import s from"node:https";import{join as i}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 y}from"webpack-merge";import{diffObject as w}from"./commom/diff-object.mjs";import g 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 b}from"./dev/config.mjs";import j from"./dev/mock.mjs";import P,{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 O}from"./common.mjs";import{CONFIG as I,getConfig as M,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as q,isReact as z,refresh as B}from"./process-env.mjs";let{HotModuleReplacementPlugin:D,ProgressPlugin:G,WatchIgnorePlugin:H}=h,U=!1!==I.stylelint&&g("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,L=!1!==I.eslint&&g("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,N=z&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,F=["js","jsx","ts","tsx","json","html","vue"],W=F.join(","),K=["css","scss","sass","less","ts","tsx","js","jsx"],X=K.join(","),J=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Q=`${_.endsWith("/")?"":"/"}__hmr__`,V=new URLSearchParams({name:"client",path:Q,dynamicPublicPath:!0,timeout:2e3,reload:!B,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),Y=O.output.path,Z=I.bar.name||"Build",ee=y(O,{entry:{main:[`${A.hotMiddlewareClient}?${V}`]},output:{path:Y},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 D,new H({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]}),N&&new N,L&&new L({fix:!0,threads:!0,files:[`${I.alias["@"]}/**/*.{${W}}`,q&&`${I.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:F,exclude:J,cache:!0,cacheLocation:`${v.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"}),U&&new U({fix:!0,threads:!0,files:[`${I.alias["@"]}/**/*.{${X}}`,q&&`${I.alias["@pkg"]}/**/*.{${X}}`].filter(Boolean),extensions:K,exclude:J,cache:!0,cacheLocation:`${v.lintCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!I.bar&&new G({handler(e,t,...o){p(e||0,1,Z,o.length?`[${t}] ${o.join(" ")}`:""),1===e&&process.stdout.write("\r\x1b[2K")}})].filter(Boolean)}),et=h(ee);et.hooks.done.tap("client-log",e=>{C(null,e)});let eo=d(),er=u(),es={"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",...I.devServer.headers},ei=f(et,{writeToDisk:!1,index:"index.html",headers:e=>({...es,"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:ee.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),en=x(et,{log:!1,path:Q,heartbeat:2e3});eo.use(d.static(i(v.programPath,"./public"))).use(ei).use(Q,en),n(v.mockPath)&&eo.use(er.any(),j(v.mockPath)),I.proxy&&P(eo,I.proxy);let el=`${ee.output.path}/index.html`;if(eo.use((e,t,o)=>{if("GET"===e.method){let r=e.get("Accept");if(r?.includes("text/html")){let e=ei.context.outputFileSystem,o=e?.readFileSync?.(el);t.headersSent||(t.setHeader("Content-Type","text/html"),t.send(o))}else if("text/event-stream"===r&&e.url.endsWith(Q))return e.url=Q,en(e,t,o);else return o()}else{if("OPTIONS"!==e.method)return o();t.sendStatus(200)}}),I.devServer.https){let[t,o]=await Promise.all([a(I.devServer.https.key),a(I.devServer.https.cert)]);t||(c(l(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.key}`,"red")),process.exit(1)),o||(c(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.cert}`,"red")),process.exit(1)),e=s.createServer({key:t,cert:o},eo)}let ea=(e||eo).listen(b,"0.0.0.0",()=>{});function em(){process.exit(0)}let ec=await Promise.all(k.map(M)),ep=y(ec[0]||{},ec[1]||{});k.forEach(function(e){r(e,async function(){let[o,r]=await Promise.all(k.map(M)),s=y(o||{},r||{}),i=w(ep,s);1===Object.keys(i).length&&"proxy"in i?(m(l(`代理更新中...`,"yellow"),!0),S(eo,s.proxy),m(l(`代理更新完成...`,"green"),!0),I.proxy=s.proxy,ep.proxy=s.proxy,ep=s):(ep=s,c(l(`检测到工程配置${l(`[${e}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),t("win32"===process.platform?`netstat -ano | findstr :${b}`:`lsof -i :${b} -t`,(e,t)=>{if(e){c(l(`查找端口 ${b} 时发生错误: ${e.message}`,"red")),c(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=ed?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){c(l(`未找到占用端口 ${b} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){c(l(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ed="win32"===process.platform;process.on("SIGHUP",function(){ei.close(T),ea.close(T),ea.closeAllConnections(),function(){let e=o(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",em)}()}),process.on("exit",function(){ei.close(T),ea.close(T),ea.closeAllConnections()}),$(em);
|
package/lib/index.d.mts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as require } from './
|
|
7
|
-
export
|
|
8
|
-
export type
|
|
9
|
-
export { type YApiOption, type YApiOptionBySchema, yApiMock, yApiSchemaMock, type RequestFormData, type ProxyFuncType, type MockConfiguration, } from './dev/mock.mjs';
|
|
1
|
+
export type * from '../typings/global.js';
|
|
2
|
+
export { default as hasPkg } from './commom/has-pkg.mjs';
|
|
3
|
+
export { getIPv4, getPort } from './commom/net.mjs';
|
|
4
|
+
export { default as osTmpDir } from './commom/os-tmp-dir.mjs';
|
|
5
|
+
export { CUSTOMCONFIG, default as paths, routeDir, yarnArgv } from './commom/paths.mjs';
|
|
6
|
+
export { default as require } from './commom/require.mjs';
|
|
7
|
+
export { default as Rule } from './commom/rule.mjs';
|
|
8
|
+
export { type MockConfiguration, type ProxyFuncType, type RequestFormData, yApiMock, type YApiOption, type YApiOptionBySchema, yApiSchemaMock, } from './dev/mock.mjs';
|
|
10
9
|
export type { ProxyConfig } from './dev/proxy.mjs';
|
|
11
|
-
export {
|
|
12
|
-
export { default as
|
|
13
|
-
export {
|
|
14
|
-
export { default as Rule } from './rule.mjs';
|
|
10
|
+
export { type JsxDomExpressions, default as jsxDomExpressions, } from './options/jsx-dom-expressions.mjs';
|
|
11
|
+
export { type OptimizationSplitChunksOptions, default as splitChunk, } from './options/split-chunk.mjs';
|
|
12
|
+
export type { OverrideResolverOption } from './plugin/override-resolve.mjs';
|
|
15
13
|
export type { VirtualModulePluginOption } from './plugin/virtual-module.mjs';
|
|
16
|
-
export
|
|
14
|
+
export { APPTYPE, coreName, FRAMEWORK, isDev, isLibrary, isMicro, mainDirectory, PACKAGENAME, PACKAGEVERSION, } from './process-env.mjs';
|
|
15
|
+
export { resolveProgram, toCamelCase } from './utils/index.mjs';
|
|
16
|
+
export type { MdxOptions } from '@moneko/mdx';
|