@moneko/core 3.48.0 → 3.48.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/help.mjs +4 -4
- package/lib/bin/index.mjs +1 -1
- package/lib/bin/pin.d.mts +38 -0
- package/lib/bin/pin.mjs +1 -0
- package/package.json +3 -3
- package/lib/bin/outdated.d.mts +0 -14
- package/lib/bin/outdated.mjs +0 -1
package/lib/bin/help.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{ink as e,println as $}from"@moneko/utils";export default function(){let l="react | solid | vue",
|
|
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
2
|
${e("使用方法:","white")} ${e("mo","blue")} ${e("<命令>","green")} ${e("<必选参数>","208")} ${e("[可选参数]","yellow")}
|
|
3
3
|
|
|
4
4
|
${e("命令列表:","white")}
|
|
5
5
|
${e("start","green")} ${e("<type> <framework>","208")} 启动开发服务器
|
|
6
|
-
${e("type: ","245",{bold:!0})}${e(
|
|
6
|
+
${e("type: ","245",{bold:!0})}${e(r,"245",{italic:!0})}
|
|
7
7
|
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
8
8
|
|
|
9
9
|
${e("build","green")} ${e("<type> <framework>","208")} 构建生产环境应用
|
|
10
|
-
${e("type: ","245",{bold:!0})}${e(
|
|
10
|
+
${e("type: ","245",{bold:!0})}${e(r,"245")}
|
|
11
11
|
${e("framework: ","245",{bold:!0})}${e(l,"245",{italic:!0})}
|
|
12
12
|
|
|
13
13
|
${e("eslint","green")} ${e("<source_path>","208")} 执行代码规范检查
|
|
@@ -16,7 +16,7 @@ ${e("命令列表:","white")}
|
|
|
16
16
|
${e("stylelint","green")} ${e("<source_path>","208")} 执行样式规范检查
|
|
17
17
|
${e("source_path: ","245",{bold:!0})}${e("要检查的文件或目录路径","245",{italic:!0})}
|
|
18
18
|
|
|
19
|
-
${e("
|
|
19
|
+
${e("pin","green")} ${e("[-u]","208")} 检查过时依赖
|
|
20
20
|
${e("-u: ","245",{bold:!0})}${e("写入更新到 package.json 中","245",{italic:!0})}
|
|
21
21
|
|
|
22
22
|
${e("githooks","green")} 配置 Git 钩子以自动化工作流
|
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
|
|
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)});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { relative } from 'node:path';
|
|
3
|
+
import { fileExists, ink, println, progressBar, updateFile } from '@moneko/utils';
|
|
4
|
+
import parseArgs from '../commom/parse-args.mjs';
|
|
5
|
+
import paths from '../commom/paths.mjs';
|
|
6
|
+
import require from '../commom/require.mjs';
|
|
7
|
+
declare const packageJsonPath: string;
|
|
8
|
+
declare function getPackageJson(): typeof import('package.json');
|
|
9
|
+
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'deno' | 'npm';
|
|
10
|
+
declare function getPackageManager(packageManager?: string): PackageManager;
|
|
11
|
+
type V = 'major' | 'minor' | 'patch' | 'equal';
|
|
12
|
+
declare function versionCompare(v1: string, v2: string): V;
|
|
13
|
+
declare async function getVersion(name: string);
|
|
14
|
+
declare async function checkDependencies(dependencies: Record<string, string>, progress: {
|
|
15
|
+
done: string[];
|
|
16
|
+
total: number;
|
|
17
|
+
});
|
|
18
|
+
interface DiffVersion {
|
|
19
|
+
name: string;
|
|
20
|
+
wanted: string;
|
|
21
|
+
latest: string;
|
|
22
|
+
color: string;
|
|
23
|
+
}
|
|
24
|
+
declare const levels: {
|
|
25
|
+
readonly major: string;
|
|
26
|
+
readonly minor: string;
|
|
27
|
+
readonly patch: string;
|
|
28
|
+
readonly equal: string;
|
|
29
|
+
};
|
|
30
|
+
declare function diff(prev: Record<string, string>, next: Record<string, string>): DiffVersion[];
|
|
31
|
+
declare async function checkUpdates(packageJson: typeof import('package.json'), key: 'peerDependencies' | 'optionalDependencies' | 'devDependencies' | 'dependencies', result: Record<string, DiffVersion[]>, progress: {
|
|
32
|
+
done: string[];
|
|
33
|
+
total: number;
|
|
34
|
+
});
|
|
35
|
+
declare function getMaxLength(pkgs: string[], result: Record<string, DiffVersion[]>, key: keyof DiffVersion);
|
|
36
|
+
declare function extractVersion(version: string): [optical: string, version: string];
|
|
37
|
+
declare async function pin(): Promise<void>;
|
|
38
|
+
export default pin;
|
package/lib/bin/pin.mjs
ADDED
|
@@ -0,0 +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 o,progressBar as r,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 m=i.resolve(`${process.cwd()}/package.json`);async function p(t){return new Promise(n=>{let a=e("npm",["view",t,"version"],{shell:!0}),o="";a.stdout.on("data",e=>{o+=e}),a.stderr.on("data",e=>{process.stdout.write(e)}),a.on("close",async()=>{n(o.trim())})})}async function d(e,t){let n={...e};return r(t.done.length,t.total,{name:"Checking"}),await Promise.all(Object.keys(n).map(async e=>{let a=await p(e);t.done.includes(e)||t.done.push(e),r(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 o;let r=await d(e[t],a),l=(o=e[t],Object.keys(r).filter(e=>o[e]!==r[e]).map(e=>{let t=function(e){let t=e.match(/^([^\d]*)(.*)$/);return t?[t[1],t[2]]:["",e]}(o[e]);return{name:e,wanted:o[e],latest:`${t[0]}${r[e]}`,color: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],r[e])]}}));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)}async function f(){let e=s(process.argv),r=(delete i.cache[m],i(m)),p={done:[],total:Object.keys({...r.peerDependencies||{},...r.optionalDependencies||{},...r.devDependencies||{},...r.dependencies||{}}).length},d={};if(o(""),await Promise.all([h(r,"peerDependencies",d,p),h(r,"optionalDependencies",d,p),h(r,"devDependencies",d,p),h(r,"dependencies",d,p)]),o(""),Object.keys(d)?.length>0){var u;let s=(u=r.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),p="".padEnd(3," ");o(""),o(a("⚡ Updates available for:","magenta",{bold:!0})),o("");let h=g(i,d,"name"),f=g(i,d,"latest"),$=g(i,d,"wanted");i.forEach(e=>{o(a(`${e}:`,"145")),d[e].forEach(t=>{o(`${a(t.name.padEnd(h," "),t.color,{bold:!0})}${p}${t.wanted.padStart($," ")}${p}${a("→",t.color)}${p}${a(t.latest.padStart(f," "),t.color)}`),r[e][t.name]=t.latest}),o("")}),e["-u"]?(await l(m,JSON.stringify(r,null,2)),o(`✅ ${a(t(c.programPath,m),"yellow")} upgrade completed successfully.`),o(`⏳ Run ${a(`${s} install`,"blue")} to install new versions.`)):o(`⏳ Run ${a("mo pin -u","blue")} to upgrade package.json`)}else o(""),o("🎉 All dependencies match the latest package versions");o("")}export default f;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.48.
|
|
3
|
+
"version": "3.48.1",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"@moneko/transform-imports": "0.6.1",
|
|
117
117
|
"@moneko/utils": "0.3.3",
|
|
118
118
|
"@swc/core": "1.6.13",
|
|
119
|
-
"browserslist": "4.25.1
|
|
119
|
+
"browserslist": "4.25.1",
|
|
120
120
|
"chokidar": "4.0.3",
|
|
121
121
|
"core-js": "3.43.0",
|
|
122
122
|
"core-js-compat": "3.43.0",
|
|
@@ -155,4 +155,4 @@
|
|
|
155
155
|
"lib",
|
|
156
156
|
"typings"
|
|
157
157
|
]
|
|
158
|
-
}
|
|
158
|
+
}
|
package/lib/bin/outdated.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { relative } from 'node:path';
|
|
3
|
-
import { fileExists, ink, println, updateFile } from '@moneko/utils';
|
|
4
|
-
import parseArgs from '../commom/parse-args.mjs';
|
|
5
|
-
import paths from '../commom/paths.mjs';
|
|
6
|
-
import require from '../commom/require.mjs';
|
|
7
|
-
declare const packageJsonPath: string;
|
|
8
|
-
declare function getPackageJson(): typeof import('package.json');
|
|
9
|
-
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'deno' | 'npm';
|
|
10
|
-
declare function getPackageManager(packageManager?: string): PackageManager;
|
|
11
|
-
type V = 'major' | 'minor' | 'patch' | 'equal';
|
|
12
|
-
declare function versionCompare(v1: string, v2: string): V;
|
|
13
|
-
declare async function outdated(): Promise<number | null>;
|
|
14
|
-
export default outdated;
|
package/lib/bin/outdated.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{fileExists as a,ink as o,println as n,updateFile as r}from"@moneko/utils";import l from"../commom/parse-args.mjs";import s from"../commom/paths.mjs";import c from"../commom/require.mjs";let p=c.resolve(`${process.cwd()}/package.json`);async function d(){let d=l(process.argv);return new Promise(l=>{let m=e("npm",["outdated","--depth=0","--json"],{shell:!0}),i="";m.stdout.on("data",e=>{i+=e.toString()}),m.stderr.on("data",e=>{process.stdout.write(e)}),m.on("close",async e=>{if(0===i.length&&0===e){n("🎉 All dependencies match the latest package versions"),l(e);return}let m=JSON.parse(i);if(Object.keys(m)?.length>0){var u;let e=(delete c.cache[p],c(p)),l=(u=e.packageManager)?u.split("@")[0]:a(`${s.programPath}/pnpm-lock.yaml`)?"pnpm":a(`${s.programPath}/yarn.lock`)?"yarn":a(`${s.programPath}/bun.lockb`)?"bun":a(`${s.programPath}/deno.lock`)?"deno":"npm",i=Object.keys(m),h={major:"red",minor:"yellow",patch:"green",equal:"white"};i.forEach(e=>{let t=!!m[e].current,a=t&&m[e].wanted!==m[e].current,o=t?[...new Set([m[e].wanted,m[e].current])]:[m[e].wanted];m[e]={...m[e],installed:t,now:t?o:[],maxSize:o.join("").length+2,color:t?h[function(e,t){let a=e.split("."),o=t.split(".");return a[0]!==o[0]?"major":a[1]!==o[1]?"minor":a[2]!==o[2]?"patch":"equal"}(a?m[e].current:m[e].wanted,m[e].latest)]:"green"}});let g="".padEnd(2," "),$=i.reduce((e,t)=>Math.max(e,t.length),0),f=i.reduce((e,t)=>Math.max(e,m[t].latest.length),0),w=i.reduce((e,t)=>Math.max(e,m[t].maxSize),0);for(let t in n(""),n(o("⚡ Updates available for:","magenta",{bold:!0})),n(""),m)if(Object.prototype.hasOwnProperty.call(m,t)){let a=m[t],r=a.now;n(`${o(t.padEnd($," "),a.color||"cyan",{bold:!0})}${g}${r[0]??""}${r[1]?o(`(${r[1]})`,"245"):""}${"".padEnd(w-(r.join("").length+2)," ")}${g}${o("→",a.color)}${g}${o(a.latest.padEnd(f," "),a.color)}`),e.dependencies?.[t]?e.dependencies[t]=a.latest:e.devDependencies?.[t]&&(e.devDependencies[t]=a.latest)}n(""),d["-u"]?(await r(p,JSON.stringify(e,null,2)),n(`✅ ${o(t(s.programPath,p),"yellow")} upgrade completed successfully.`),n(`⏳ Run ${o(`${l} install`,"blue")} to install new versions.`)):n(`⏳ Run ${o("mo outdated -u","blue")} to upgrade package.json`)}else n("🎉 All dependencies match the latest package versions");n(""),l(e)})})}export default d;
|