@moneko/core 3.55.2 → 3.55.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 -0
- package/lib/bin/build.d.mts +2 -0
- package/lib/bin/build.mjs +1 -1
- package/lib/bin/changelog.d.mts +1 -0
- package/lib/bin/commit-lint.d.mts +2 -0
- package/lib/bin/eslint.d.mts +1 -0
- package/lib/bin/file.d.mts +2 -0
- package/lib/bin/git-hooks.d.mts +1 -0
- package/lib/bin/help.d.mts +2 -0
- package/lib/bin/index.d.mts +2 -0
- package/lib/bin/lessc.d.mts +1 -0
- package/lib/bin/lessc.mjs +1 -1
- package/lib/bin/pin.d.mts +6 -0
- package/lib/bin/pin.mjs +1 -1
- package/lib/bin/pure-lint.d.mts +2 -0
- package/lib/bin/pure-lint.mjs +1 -1
- package/lib/bin/server.d.mts +2 -0
- package/lib/bin/setup.d.mts +2 -0
- package/lib/bin/start.d.mts +2 -0
- package/lib/bin/stylelint.d.mts +2 -0
- package/lib/bin/tsc.d.mts +2 -0
- package/lib/bin/utils/bundle-app.d.mts +2 -0
- package/lib/bin/utils/config.d.mts +6 -0
- package/lib/bin/utils/convert-react.d.mts +1 -0
- package/lib/bin/utils/get-commit-files.d.mts +2 -0
- package/lib/bin/utils/setup-swcrc.d.mts +2 -0
- package/lib/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/build/common.d.mts +3 -0
- package/lib/build/server.d.mts +3 -0
- package/lib/build.d.mts +1 -0
- package/lib/commom/ca.d.mts +8 -0
- package/lib/commom/ca.mjs +1 -1
- package/lib/commom/check-npm.d.mts +4 -0
- package/lib/commom/corepack.d.mts +11 -0
- package/lib/commom/diff-object.d.mts +2 -0
- package/lib/commom/esm.d.mts +2 -0
- package/lib/commom/has-pkg.d.mts +2 -0
- package/lib/commom/host.d.mts +1 -0
- package/lib/commom/is-ci-environment.d.mts +6 -0
- package/lib/commom/log.d.mts +2 -0
- package/lib/commom/match-path.d.mts +22 -0
- package/lib/commom/mime.d.mts +2 -0
- package/lib/commom/module-resolve.d.mts +2 -0
- package/lib/commom/net.d.mts +2 -0
- package/lib/commom/open.d.mts +2 -0
- package/lib/commom/parse-args.d.mts +2 -0
- package/lib/commom/parse-module-meta.d.mts +9 -0
- package/lib/commom/paths.d.mts +52 -0
- package/lib/commom/print-log.d.mts +15 -0
- package/lib/commom/reactive-object.d.mts +10 -0
- package/lib/commom/require.d.mts +2 -0
- package/lib/commom/rule.d.mts +26 -0
- package/lib/commom/setup-env.d.mts +6 -0
- package/lib/commom/sigint-exit.d.mts +2 -0
- package/lib/commom/timer.d.mts +12 -0
- package/lib/commom/transfer-import-on-demand.d.mts +78 -0
- package/lib/commom/transfer-import-on-demand.mjs +1 -0
- package/lib/commom/transform-solid-js.d.mts +18 -0
- package/lib/common.d.mts +3 -0
- package/lib/config.d.mts +4 -0
- package/lib/dev/config.d.mts +4 -0
- package/lib/dev/generate-progress-html.d.mts +6 -0
- package/lib/dev/get-cert.d.mts +8 -0
- package/lib/dev/json-schema.d.mts +70 -0
- package/lib/dev/mock.d.mts +67 -0
- package/lib/dev/proxy.d.mts +15 -0
- package/lib/dev/server.d.mts +26 -0
- package/lib/dev.d.mts +1 -0
- package/lib/file-system.d.mts +2 -0
- package/lib/index.d.mts +24 -0
- package/lib/lint/eslint/base.d.mts +2 -0
- package/lib/lint/eslint/index.d.mts +2 -0
- package/lib/lint/eslint/react.d.mts +2 -0
- package/lib/lint/eslint/solid.d.mts +2 -0
- package/lib/lint/eslint/vue.d.mts +2 -0
- package/lib/lint/stylelint/config.d.mts +2 -0
- package/lib/lint/stylelint/index.d.mts +1 -0
- package/lib/loader/css-in-js-minify.d.cts +14 -0
- package/lib/loader/lightning-css/codegen.d.cts +35 -0
- package/lib/loader/lightning-css/loader.d.cts +29 -0
- package/lib/loader/lightning-css/runtime/api.d.cts +1 -0
- package/lib/loader/lightning-css/runtime/get-url.d.cts +1 -0
- package/lib/loader/lightning-css/utils.d.cts +16 -0
- package/lib/loader/mdx.d.cts +3 -0
- package/lib/loader/react-compiler.cjs +1 -1
- package/lib/loader/react-compiler.d.cts +29 -0
- package/lib/loader/solid.cjs +1 -1
- package/lib/loader/solid.d.cts +6 -0
- package/lib/loader/ts-doc.d.cts +7 -0
- package/lib/module.config.d.mts +3 -0
- package/lib/options/css-extract.d.mts +3 -0
- package/lib/options/jsx-dom-expressions.d.mts +10 -0
- package/lib/options/md-to-html.d.mts +2 -0
- package/lib/options/modify-vars.d.mts +2 -0
- package/lib/options/reslove.d.mts +10 -0
- package/lib/options/reslove.mjs +1 -1
- package/lib/options/split-chunk.d.mts +4 -0
- package/lib/options/swcrc.d.mts +10 -0
- package/lib/options/swcrc.mjs +1 -1
- package/lib/plugin/compression.d.mts +15 -0
- package/lib/plugin/compression.mjs +1 -1
- package/lib/plugin/copy.d.mts +30 -0
- package/lib/plugin/copy.mjs +1 -1
- package/lib/plugin/done.d.mts +11 -0
- package/lib/plugin/eslint.d.mts +14 -0
- package/lib/plugin/exposes-declararion.d.mts +15 -0
- package/lib/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugin/external-remotes.d.mts +4 -0
- package/lib/plugin/html-plugin.d.mts +60 -0
- package/lib/plugin/lightningcss-plugin.d.mts +20 -0
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/manifest.d.mts +46 -0
- package/lib/plugin/module-federation.d.mts +3 -0
- package/lib/plugin/override-resolve.d.mts +25 -0
- package/lib/plugin/stylelint.d.mts +13 -0
- package/lib/plugin/swc-minify-plugin.d.mts +8 -0
- package/lib/plugin/swc-minify-plugin.mjs +1 -1
- package/lib/plugin/virtual-module.d.mts +12 -0
- package/lib/plugins.config.d.mts +3 -0
- package/lib/polyfills/polyfills.d.mts +3 -0
- package/lib/polyfills/replace-children.d.mts +1 -0
- package/lib/polyfills/targets.d.mts +3 -0
- package/lib/process-env.d.mts +26 -0
- package/lib/utils/compile-dts.d.mts +23 -0
- package/lib/utils/create-types.d.mts +2 -0
- package/lib/utils/dts.d.mts +14 -0
- package/lib/utils/fetch-module-federation-dts.d.mts +2 -0
- package/lib/utils/index.d.mts +35 -0
- package/lib/utils/run.d.mts +2 -0
- package/lib/utils/seo.d.mts +2 -0
- package/lib/utils/svg-to-data-uri.d.mts +2 -0
- package/lib/utils/vts.d.mts +18 -0
- package/lib/vm/coverage.d.mts +2 -0
- package/lib/vm/docs.d.mts +7 -0
- package/lib/vm/example.d.mts +4 -0
- package/lib/vm/generate-doc.d.mts +1 -0
- package/lib/vm/info.d.mts +2 -0
- package/lib/vm/locales.d.mts +5 -0
- package/lib/vm/locales.mjs +1 -1
- package/lib/vm/modules.d.mts +2 -0
- package/lib/vm/render-app.d.mts +2 -0
- package/lib/vm/routes.d.mts +8 -0
- package/lib/vm/utils.d.mts +1 -0
- package/lib/worker/dts.d.mts +1 -0
- package/lib/worker/eslint.d.mts +1 -0
- package/lib/worker/react-compiler.d.mts +1 -0
- package/lib/worker/solid.d.mts +1 -0
- package/lib/worker/stylelint.d.mts +1 -0
- package/lib/worker/swc-minify.d.mts +1 -0
- package/package.json +5 -5
- package/typings/global.d.ts +13 -85
|
@@ -0,0 +1,16 @@
|
|
|
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.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as o}from"node:path";import{argv as t,exit as e}from"node:process";import{ink as s,println as i,removeDir as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";import{cwd as n,swcCachePath as l}from"./utils/config.mjs";import{getSwcOption as p}from"./utils/setup-swcrc.mjs";import{lesscCommonjs as c}from"./lessc.mjs";import d from"./tsc.mjs";async function a(){let a=t[3],j=t[4],u=t.slice(5);a||(i(s(`type: 无效值 ${s(a,"245")}`,"red")),e(1));let f=!u.includes("no-docs"),x=!u.includes("no-lib"),y=!u.includes("no-es"),_=!u.includes("no-dts"),g=u.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await m("production",a,j,g),"library"===a){let t="solid"===j?await import("@moneko/convert/solid"):await import("@moneko/convert"),{CONFIG:e}=await import("../config.mjs"),s="swc"===e.dts,i=[x&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},y&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let m=0,a=i.length;m<a;m++){if(r(o(n,`./${i[m].dir}`)),"react"===j){let o=p();"es6"===i[m].type&&(o.jsc.target="es2015"),o.jsc.experimental.emitIsolatedDts=_&&s,o.jsc.experimental.cacheRoot=l,o.module.type=i[m].type,t.convert({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}else if("solid"===j){let o={jsxOptions:e.jsxDomExpressions,presetEnvOption:{modules:"commonjs"}};"es6"===i[m].type&&(o.presetEnvOption.modules=!1),t.convertSolid({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}"commonjs"===i[m].type&&c(),_&&!s&&d(i[m].dir)}}if("library"!==a||f&&"library"===a)try{await import("../build.mjs")}catch(o){i(s(Error(o).message,"red")),e(1)}}export default a;
|
|
1
|
+
import{join as o}from"node:path";import{argv as t,exit as e}from"node:process";import{ink as s,println as i,removeDir as r}from"@moneko/utils";import m from"../commom/setup-env.mjs";import{cwd as n,swcCachePath as l}from"./utils/config.mjs";import{getSwcOption as p}from"./utils/setup-swcrc.mjs";import{lesscCommonjs as c}from"./lessc.mjs";import d from"./tsc.mjs";async function a(){let a=t[3],j=t[4],u=t.slice(5);a||(i(s(`type: 无效值 ${s(a,"245")}`,"red")),e(1));let f=!u.includes("no-docs"),x=!u.includes("no-lib"),y=!u.includes("no-es"),_=!u.includes("no-dts"),g=u.filter(o=>!["no-docs","no-es","no-lib"].includes(o));if(await m("production",a,j,g),"library"===a){let t="solid"===j?await import("@moneko/convert/solid"):await import("@moneko/convert"),{CONFIG:e}=await import("../config.mjs"),s="swc"===e.dts,i=[x&&{type:"commonjs",dir:"lib",msg:"Convert to CommonJS"},y&&{type:"es6",dir:"es",msg:"Convert to ES Module"}].filter(Boolean);for(let m=0,a=i.length;m<a;m++){if(r(o(n,`./${i[m].dir}`)),"react"===j){let o=await p();"es6"===i[m].type&&(o.jsc.target="es2015"),o.jsc.experimental.emitIsolatedDts=_&&s,o.jsc.experimental.cacheRoot=l,o.module.type=i[m].type,t.convert({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}else if("solid"===j){let o={jsxOptions:e.jsxDomExpressions,presetEnvOption:{modules:"commonjs"}};"es6"===i[m].type&&(o.presetEnvOption.modules=!1),t.convertSolid({outDir:i[m].dir,inputDir:"components",ignore:[/^.*\/__*__\//,/\.test\.(js|ts)x?$/,/\.DS_Store/,/\.mdx?$/,/^.*\/examples\//,/\.d\.(cj|mj|j|t|ct|mt)sx?$/],options:o})}"commonjs"===i[m].type&&c(),_&&!s&&d(i[m].dir)}}if("library"!==a||f&&"library"===a)try{await import("../build.mjs")}catch(o){i(s(Error(o).message,"red")),e(1)}}export default a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function changelog(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function eslint(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function githooks(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lesscCommonjs(): Promise<void>;
|
package/lib/bin/lessc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 l}from"@moneko/utils";import r from"../commom/require.mjs";import{runtimePath as i}from"./utils/config.mjs";let m="";function n(s){let t=o(r.resolve("less"),"../bin/lessc");return new Promise((o,l)=>{e(`${i} ${t} --js ${m} ${s} > ${s.replace(/\.less$/g,".css")}`,function(e){if(e)return l(e);o(!0)})})}let a=/\*?\.less/g;async function c(e){let o=await s(e);o&&a.test(o)&&await t(e,o.replace(a,".css"))}export async function lesscCommonjs(){let e=l("lib",["\\.less$"]),o=(await import("../options/modify-vars.mjs")).default;for(let e in o)Object.hasOwnProperty.call(o,e)&&(m+=`--modify-var="${e}=${o[e]}" `);Promise.allSettled(e.map(n)),e.length&&Promise.allSettled(l("lib",["\\.js$"]).map(c))}
|
package/lib/bin/pin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{fileExists as n,ink as a,println as r,progressBar as o,updateFile as l}from"@moneko/utils";import s from"../commom/parse-args.mjs";import c from"../commom/paths.mjs";import i from"../commom/require.mjs";let p=i.resolve(`${process.cwd()}/package.json`);async function m(t){return new Promise(n=>{let a=e("npm",["view",t,"version"],{shell:!0}),r="";a.stdout.on("data",e=>{r+=e}),a.stderr.on("data",e=>{let t=e.toString().split("\n").filter(e=>e.includes("GET http")).map(e=>e.split(" - ")[0].trim());t.length&&(r+=`Err: ${t[0]}`.trim())}),a.on("close",async()=>{n(r.trim())})})}async function d(e,t){let n={...e};return o(t.done.length,t.total,{name:"Checking"}),await Promise.
|
|
1
|
+
import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{fileExists as n,ink as a,println as r,progressBar as o,updateFile as l}from"@moneko/utils";import s from"../commom/parse-args.mjs";import c from"../commom/paths.mjs";import i from"../commom/require.mjs";let p=i.resolve(`${process.cwd()}/package.json`);async function m(t){return new Promise(n=>{let a=e("npm",["view",t,"version"],{shell:!0}),r="";a.stdout.on("data",e=>{r+=e}),a.stderr.on("data",e=>{let t=e.toString().split("\n").filter(e=>e.includes("GET http")).map(e=>e.split(" - ")[0].trim());t.length&&(r+=`Err: ${t[0]}`.trim())}),a.on("close",async()=>{n(r.trim())})})}async function d(e,t){let n={...e};return o(t.done.length,t.total,{name:"Checking"}),await Promise.allSettled(Object.keys(n).map(async e=>{let a=await m(e);t.done.includes(e)||t.done.push(e),o(t.done.length,t.total,{name:"Checking",msg:`${t.done.length} / ${t.total}`}),n[e]=a})),n}let u={major:"red",minor:"yellow",patch:"cyan",equal:"white"};async function h(e,t,n,a){if(e[t]){var r;let o=await d(e[t],a),l=(r=e[t],Object.keys(o).filter(e=>{let t=$(r[e]);return r[e]!==`${t[0]}${o[e]}`}).map(e=>{let t=$(r[e]),n=o[e].includes("Err:"),a=n?"red":u[function(e,t){let n=e.split("."),a=t.split(".");return n[0]!==a[0]?"major":n[1]!==a[1]?"minor":n[2]!==a[2]?"patch":"equal"}(t[1],o[e])];return{name:e,wanted:r[e],latest:`${t[0]}${o[e].replace("Err:","")}`,color:a,err:n?o[e]:void 0}}));l.length&&(n[t]=l)}}function g(e,t,n){return e.reduce((e,a)=>Math.max(e,t[a].reduce((e,t)=>Math.max(e,t[n]?.length??0),0)),0)}function $(e){let t=e.match(/^([^\d]*)(.*)$/);return t?[t[1],t[2]]:["",e]}async function f(){let e=s(process.argv),o=(delete i.cache[p],i(p)),m={done:[],total:Object.keys({...o.peerDependencies||{},...o.optionalDependencies||{},...o.devDependencies||{},...o.dependencies||{}}).length},d={};if(r(""),await Promise.allSettled([h(o,"peerDependencies",d,m),h(o,"optionalDependencies",d,m),h(o,"devDependencies",d,m),h(o,"dependencies",d,m)]),r(""),Object.keys(d)?.length>0){var u;let s=(u=o.packageManager)?u.split("@")[0]:n(`${c.programPath}/pnpm-lock.yaml`)?"pnpm":n(`${c.programPath}/yarn.lock`)?"yarn":n(`${c.programPath}/bun.lockb`)?"bun":n(`${c.programPath}/deno.lock`)?"deno":"npm",i=Object.keys(d),m="".padEnd(3," ");r(""),r(a("⚡ Updates available for:","magenta",{bold:!0})),r("");let h=g(i,d,"name"),$=g(i,d,"latest"),f=g(i,d,"wanted");i.forEach(e=>{r(a(`${e}:`,"145")),d[e].forEach(t=>{r(`${a(t.name.padEnd(h," "),t.color,{bold:!0})}${m}${t.wanted.padStart(f," ")}${m}${a("→",t.color)}${m}${a(t.latest.padStart($," "),t.color)}`),t.err||(o[e][t.name]=t.latest)}),r("")}),e["-u"]?(await l(p,JSON.stringify(o,null,2)),r(`✅ ${a(t(c.programPath,p),"yellow")} upgrade completed successfully.`),r(`⏳ Run ${a(`${s} install`,"blue")} to install new versions.`)):r(`⏳ Run ${a("mo pin -u","blue")} to upgrade package.json`)}else r(""),r("🎉 All dependencies match the latest package versions");r("")}export default f;
|
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,cwd as i,exit as r,stdout as
|
|
2
|
+
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o,cwd as i,exit as r,stdout as l}from"node:process";import{ESLint as n}from"@moneko/eslint";import{stylelint as a}from"@moneko/stylelint";import{ink as m,loadFile as s,println as c}from"@moneko/utils";import d from"../commom/log.mjs";import f from"../commom/parse-args.mjs";import u from"../commom/timer.mjs";let p=f(o.slice(2)),y=p.fix,h=p.cache||!0,w=e(i(),"node_modules/.cache"),S={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACM"]},g=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,v=/.*(?<!\.d)\.vue$/,$=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,E=t("git",S[p.mode||"ci"]||S.ci).stdout.toString().trim().split("\n");async function j(){let t=m("ESLint","cyan");c(`${t}: ${m("runing...","yellow")}`,!0);try{u.start("ESLint");let t=E.filter(t=>g.test(t)||v.test(t));if(0===t.length)return void u.end("ESLint");let e=new n({cache:h,cacheLocation:`${w}/.eslintcache`,fix:y}),o=await e.lintFiles(t),i=await e.loadFormatter("stylish"),a=await i.format(o);y&&await n.outputFixes(o),a&&l.write(a);let m=o.some(t=>t.errorCount>0);u.end("ESLint"),m&&r(1)}catch(t){d(t)}}let L=E.filter(t=>$.test(t)||v.test(t));async function k(){let t=m("Stylelint","cyan");if(c(`${t}: ${m("runing...","yellow")}`,!0),u.start("Stylelint"),0===L.length)return void u.end("Stylelint");let e=await Promise.allSettled(L.map(async t=>{let e=await s(t);return await a.lint({codeFilename:t,code:e,cache:h,cacheLocation:`${w}/.stylelintcache`,fix:y,formatter:"string"}).catch(d)})),o=!1;e.forEach(t=>{"fulfilled"===t.status?t.value&&(t.value.report&&l.write(t.value.report),t.value.errored&&(o=!!t.value.errored)):t.reason&&(l.write(t.reason),o=!1)}),u.end("Stylelint"),o&&r(1)}await Promise.allSettled([j(),k()]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e
|
|
1
|
+
import{swcImportOnDemandConfig as e}from"../../commom/transfer-import-on-demand.mjs";import o from"../../options/reslove.mjs";import{cwd as r}from"./config.mjs";export async function getSwcOption(){let{CONFIG:t}=await import("../../config.mjs");return{module:{type:"es6"},minify:!0,jsc:{minify:{format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:!1,development:!1}},experimental:{plugins:[[o.rawImport,{rootDir:r}],[o.transformImports,e(t.importOnDemand||{})]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]}}
|
package/lib/build.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ChildProcess } from 'node:child_process';
|
|
2
|
+
import { type CertificateResult } from '@moneko/utils';
|
|
3
|
+
/**
|
|
4
|
+
* 安装本地根 CA 到用户证书存储区(开发时信任 HTTPS 证书)
|
|
5
|
+
* @param certPath 本地 CA 证书路径
|
|
6
|
+
*/
|
|
7
|
+
export declare function installCA(certPath: string): ChildProcess | void;
|
|
8
|
+
export declare function setupCert(domain?: string, install?: boolean): Promise<CertificateResult>;
|
package/lib/commom/ca.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exec as t}from"node:child_process";import{join as e,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as
|
|
1
|
+
import{exec as t}from"node:child_process";import{join as e,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as l,loadFile as n,normalCertificateAuthority as c,println as s,saveFile as m}from"@moneko/utils";import u from"./log.mjs";import{getIPv4 as d}from"./net.mjs";import f from"./paths.mjs";let p=i(t);async function y(t){try{if("darwin"===o){let{stdout:e}=await p(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===o){let{stdout:e}=await p(`certutil -store -user Root | findstr /C:"${t}"`);return e.length>0}}catch(t){u(t)}return!1}function h(t,e,r){if(t&&!r.includes("already exists"))return void u(t)}export function installCA(e){return"darwin"===o?t(`sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "${e}"`,h):"win32"===o?t(`certutil -addstore -user "Root" "${e}"`,h):void s(`⚠️ 暂不支持自动安装 CA 的平台: ${o}`)}export async function setupCert(t="localhost",o=!0){let i=r(f.programPath,`${f.corePath}/cert/cert.pem`),s=r(f.programPath,`${f.corePath}/cert/key.pem`),u=!a(i)||!a(s);if(u){let t=c();await Promise.allSettled([m(i,t.cert),m(s,t.key)])}o&&(!await y("Local Root Certificate Authority - Moneko")||u)&&installCA(i);let p=e(f.CA_DIR,`${t}_cert.pem`),h=e(f.CA_DIR,`${t}_key.pem`);if(u||!a(p)||!a(h)){let e=await Promise.all([n(i),n(s)]),r=l(e[0],e[1],[...new Set([t,"localhost","127.0.0.1",d()].filter(Boolean))]);await Promise.allSettled([m(p,r.cert),m(h,r.key)])}let w=await Promise.all([n(p),n(h)]);return{cert:w[0],key:w[1]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hostHelp(domain: string): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type MatchPath = {
|
|
2
|
+
path: string;
|
|
3
|
+
params: Record<string, unknown>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* RESTful 风格api
|
|
7
|
+
* @param {String} pattern pattern
|
|
8
|
+
* @param {String} path paths
|
|
9
|
+
* @example
|
|
10
|
+
* const pattern = '/users/:id';
|
|
11
|
+
* const pathToMatch = '/users/123';
|
|
12
|
+
* const result = matchPath(pattern, pathToMatch);
|
|
13
|
+
* if (result) {
|
|
14
|
+
* console.log('Match found:', result);
|
|
15
|
+
* console.log('Params:', result.params);
|
|
16
|
+
* } else {
|
|
17
|
+
* console.log('No match found.');
|
|
18
|
+
* }
|
|
19
|
+
* @returns {MatchPath|null} MatchPath
|
|
20
|
+
*/
|
|
21
|
+
declare function matchPath(pattern: string, path: string): MatchPath | null;
|
|
22
|
+
export default matchPath;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** 当前文件所在目录的绝对路径 */
|
|
2
|
+
export declare const __dirname: string;
|
|
3
|
+
/** yarn 命令行参数对象,包含配置选项 */
|
|
4
|
+
export declare const yarnArgv: Record<string, string> & {
|
|
5
|
+
config?: string;
|
|
6
|
+
};
|
|
7
|
+
/** 附加启动配置名称
|
|
8
|
+
* @example
|
|
9
|
+
* 当通过以下命令启动时, 此时 CUSTOMCONFIG 为 test
|
|
10
|
+
* ```sh
|
|
11
|
+
* npm run start --config=test
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const CUSTOMCONFIG: string | undefined;
|
|
15
|
+
export declare const TMP_DIR: string;
|
|
16
|
+
declare const paths: {
|
|
17
|
+
/** node_modules 目录路径 */
|
|
18
|
+
nodeModules: string;
|
|
19
|
+
/** pnpm node_modules 目录路径 */
|
|
20
|
+
pnpmNodeModules: string;
|
|
21
|
+
/** deno node_modules 目录路径 */
|
|
22
|
+
denoNodeModules: string;
|
|
23
|
+
/** 核心代码路径 */
|
|
24
|
+
corePath: string;
|
|
25
|
+
/** 项目根目录路径 */
|
|
26
|
+
programPath: string;
|
|
27
|
+
/** CA 目录路径 */
|
|
28
|
+
CA_DIR: string;
|
|
29
|
+
/** webpack 缓存目录路径 */
|
|
30
|
+
webpackCachePath: string;
|
|
31
|
+
/** 代码检查工具(ESLint、Stylelint等)的缓存目录路径 */
|
|
32
|
+
lintCachePath: string;
|
|
33
|
+
/** HTTP 远程模块缓存路径 */
|
|
34
|
+
httpCachePath: string;
|
|
35
|
+
/** SWC 缓存目录路径 */
|
|
36
|
+
swcCachePath: string;
|
|
37
|
+
/** 默认配置文件路径 */
|
|
38
|
+
configPath: string;
|
|
39
|
+
/** 自定义配置文件路径 */
|
|
40
|
+
customConfigPath: string;
|
|
41
|
+
/** 测试覆盖率报告路径 */
|
|
42
|
+
coveragePath: string;
|
|
43
|
+
/** 页面目录路径 */
|
|
44
|
+
pagesPath: string;
|
|
45
|
+
/** 组件目录路径 */
|
|
46
|
+
componentsPath: string;
|
|
47
|
+
/** Mock 数据目录路径 */
|
|
48
|
+
mockPath: string;
|
|
49
|
+
};
|
|
50
|
+
export declare const config_files: string[];
|
|
51
|
+
export declare const routeDir: string;
|
|
52
|
+
export default paths;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const METHOD_COLOR: Record<string, {
|
|
2
|
+
fg: string;
|
|
3
|
+
bg: string;
|
|
4
|
+
}>;
|
|
5
|
+
interface PrintLogOption {
|
|
6
|
+
note?: string;
|
|
7
|
+
timestamp?: boolean;
|
|
8
|
+
labelAlign?: 'left' | 'right' | 'center';
|
|
9
|
+
labelLen?: number;
|
|
10
|
+
labelForegroundColor?: string;
|
|
11
|
+
labelBackgroundColor?: string;
|
|
12
|
+
noteForegroundColor?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function printLog(label: string, url: string, option?: PrintLogOption): void;
|
|
15
|
+
export default printLog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import EventEmitter from 'node:events';
|
|
2
|
+
declare class ReactiveObject<T extends object = Record<string, string | undefined>> extends EventEmitter {
|
|
3
|
+
readonly data: T;
|
|
4
|
+
constructor(props?: T);
|
|
5
|
+
setData(key: keyof T, value: T[keyof T]): void;
|
|
6
|
+
getData(key: keyof T): T[keyof T];
|
|
7
|
+
removeData(key: keyof T): void;
|
|
8
|
+
[Symbol.iterator](): Iterator<[keyof T, T[keyof T]]>;
|
|
9
|
+
}
|
|
10
|
+
export default ReactiveObject;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const Rule: {
|
|
2
|
+
js: RegExp;
|
|
3
|
+
css: RegExp;
|
|
4
|
+
less: RegExp;
|
|
5
|
+
scss: RegExp;
|
|
6
|
+
wasm: RegExp;
|
|
7
|
+
txt: RegExp;
|
|
8
|
+
image: RegExp;
|
|
9
|
+
video: RegExp;
|
|
10
|
+
font: RegExp;
|
|
11
|
+
markdown: RegExp;
|
|
12
|
+
tsdoc: RegExp;
|
|
13
|
+
css_module: RegExp;
|
|
14
|
+
node_modules_css_module: RegExp;
|
|
15
|
+
node_modules: RegExp;
|
|
16
|
+
__tests__: RegExp;
|
|
17
|
+
dev_watch_ignored: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* 提取函数字符串
|
|
20
|
+
* @example
|
|
21
|
+
* // () => import('@app')
|
|
22
|
+
* "rr(() => import('@app'))rr".replace(Rule.extract_func, '$1')
|
|
23
|
+
* */
|
|
24
|
+
extract_func: RegExp;
|
|
25
|
+
};
|
|
26
|
+
export default Rule;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export type MemberTransformer =
|
|
2
|
+
/** 帕斯卡拼写法(大驼峰): 所有单词的首字母大写,然后直接连接起来,单词之间没有连接符 */
|
|
3
|
+
'pascal_case'
|
|
4
|
+
/** 骆驼拼写法(小驼峰): 第一个单词的首字母小写, 后续所有单词的首字母大写,然后直接连接起来,单词之间没有连接符 */
|
|
5
|
+
| 'camel_case'
|
|
6
|
+
/** 连字符拼写法: 各个单词或缩写之间以`-`做间隔 */
|
|
7
|
+
| 'kebab_case'
|
|
8
|
+
/** 破折号式: 每个单词全小写或全大写,多单词使用`-`隔开 */
|
|
9
|
+
| 'dashed_case'
|
|
10
|
+
/** 蛇形命名: 每个单词全小写或全大写,多单词使用`_`隔开 */
|
|
11
|
+
| 'snake_case'
|
|
12
|
+
/** 大写 */
|
|
13
|
+
| 'upper_case'
|
|
14
|
+
/** 最后大写 */
|
|
15
|
+
| 'upper_first'
|
|
16
|
+
/** 小写 */
|
|
17
|
+
| 'lower_case'
|
|
18
|
+
/** 最后小写 */
|
|
19
|
+
| 'lower_first';
|
|
20
|
+
export interface TransformerOption {
|
|
21
|
+
/**
|
|
22
|
+
* 要使用的库名称,而不是导入语句中指定的库名称。`${member}` 是替换的成员
|
|
23
|
+
*/
|
|
24
|
+
transform: string;
|
|
25
|
+
/**
|
|
26
|
+
* 设置转换时需要单独导入的样式,`${member}` 是替换的成员
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
style?: string | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 当设置为true时,将保留 `import { Button }` 语法,而不是转换为 `import Button`
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
skipDefaultConversion?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 当遇到会导致导入整个模块时,是否抛出
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
preventFullImport?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* `${member}` 成员转换规则
|
|
42
|
+
* @default []
|
|
43
|
+
*/
|
|
44
|
+
memberTransformers?: MemberTransformer[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 引入语法转换
|
|
48
|
+
* @example
|
|
49
|
+
* ```javascript
|
|
50
|
+
* // 案例
|
|
51
|
+
* const conf = {
|
|
52
|
+
* importOnDemand: {
|
|
53
|
+
* antd: {
|
|
54
|
+
* transform: 'antd/lib/${member}',
|
|
55
|
+
* skipDefaultConversion: false,
|
|
56
|
+
* preventFullImport: true,
|
|
57
|
+
* style: 'antd/lib/${member}/style',
|
|
58
|
+
* memberTransformers: ['dashed_case'],
|
|
59
|
+
* },
|
|
60
|
+
* lodash: {
|
|
61
|
+
* transform: 'lodash/${member}',
|
|
62
|
+
* preventFullImport: true,
|
|
63
|
+
* },
|
|
64
|
+
* },
|
|
65
|
+
* };
|
|
66
|
+
* // 以下代码将会按照预期进行转换
|
|
67
|
+
* import { Button as MyButton, BackTop } from "antd";
|
|
68
|
+
* import { merge } from "lodash";
|
|
69
|
+
* // to
|
|
70
|
+
* import MyButton from "antd/lib/button";
|
|
71
|
+
* import BackTop from "antd/lib/back-top";
|
|
72
|
+
* import "antd/lib/back-top/style";
|
|
73
|
+
* import "antd/lib/button/style";
|
|
74
|
+
* import merge from "lodash/merge";
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export type SwcImportOnDemandTransform = Record<string, TransformerOption | false>;
|
|
78
|
+
export declare function swcImportOnDemandConfig(config: SwcImportOnDemandTransform): SwcImportOnDemandTransform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function swcImportOnDemandConfig(e){for(let t=0,n=Object.keys(e),r=n.length;t<r;t++)e[n[t]]?(e[n[t]].transform=`${n[t]}/${e[n[t]].transform}`,e[n[t]].style&&(e[n[t]].style=`${n[t]}/${e[n[t]].style}`)):delete e[n[t]];return e}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BabelFileMetadata } from '@moneko/eslint/babel-core';
|
|
2
|
+
import type { JSDocNullableType } from 'typescript';
|
|
3
|
+
export interface BabelFileResult {
|
|
4
|
+
ast?: unknown;
|
|
5
|
+
code?: string | JSDocNullableType;
|
|
6
|
+
ignored?: boolean;
|
|
7
|
+
map?: {
|
|
8
|
+
version: number;
|
|
9
|
+
sources: string[];
|
|
10
|
+
names: string[];
|
|
11
|
+
sourceRoot?: string;
|
|
12
|
+
sourcesContent?: string[];
|
|
13
|
+
mappings: string;
|
|
14
|
+
file: string;
|
|
15
|
+
} | null;
|
|
16
|
+
metadata?: BabelFileMetadata;
|
|
17
|
+
}
|
|
18
|
+
export * from '@moneko/convert/solid';
|
package/lib/common.d.mts
ADDED
package/lib/config.d.mts
ADDED