@longzai-intelligence-dependencies/repository-plugin 0.0.18 → 0.0.20
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/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -84,8 +84,8 @@ type DependenciesEnginePort = {
|
|
|
84
84
|
* @param callbacks - 事件回调集合
|
|
85
85
|
* @returns 包含所有包信息的对象
|
|
86
86
|
*/
|
|
87
|
-
checkPackages(options: CheckOptions
|
|
88
|
-
packages: PackageMeta
|
|
87
|
+
checkPackages(options: CheckOptions, callbacks?: CheckEventCallbacks): Promise<{
|
|
88
|
+
packages: PackageMeta[];
|
|
89
89
|
}>;
|
|
90
90
|
/**
|
|
91
91
|
* 将解析后的依赖变更写回包清单文件
|
|
@@ -93,7 +93,7 @@ type DependenciesEnginePort = {
|
|
|
93
93
|
* @param pkg - 包元信息
|
|
94
94
|
* @param options - 通用配置选项
|
|
95
95
|
*/
|
|
96
|
-
writePackage(pkg: PackageMeta
|
|
96
|
+
writePackage(pkg: PackageMeta, options: CheckOptions): Promise<void>;
|
|
97
97
|
};
|
|
98
98
|
/**
|
|
99
99
|
* 升级清单条目(呈现与勾选的最小单元)
|
|
@@ -327,7 +327,7 @@ type ChecklistBuildResult = {
|
|
|
327
327
|
* @param packages - 引擎 `CheckPackages` 返回的包列表
|
|
328
328
|
* @returns 清单条目数组与解析失败统计
|
|
329
329
|
*/
|
|
330
|
-
declare function buildChecklist(packages: readonly PackageMeta[]): ChecklistBuildResult;
|
|
330
|
+
declare function buildChecklist(packages: readonly PackageMeta$1[]): ChecklistBuildResult;
|
|
331
331
|
/**
|
|
332
332
|
* 把勾选子集应用回引擎包产物(未勾选条目 update 置假)并返回被触达的包
|
|
333
333
|
*
|
|
@@ -335,7 +335,7 @@ declare function buildChecklist(packages: readonly PackageMeta[]): ChecklistBuil
|
|
|
335
335
|
* @param selectedKeys - 勾选条目键集
|
|
336
336
|
* @returns 含勾选条目的包列表(仅这些包需要写入)
|
|
337
337
|
*/
|
|
338
|
-
declare function applySelectionToPackages(packages: readonly PackageMeta[], selectedKeys: ReadonlySet<string>): PackageMeta[];
|
|
338
|
+
declare function applySelectionToPackages(packages: readonly PackageMeta$1[], selectedKeys: ReadonlySet<string>): PackageMeta$1[];
|
|
339
339
|
/**
|
|
340
340
|
* 渲染清单条目的单行展示文本
|
|
341
341
|
*
|
|
@@ -351,7 +351,7 @@ declare function formatChecklistEntry(entry: DependenciesChecklistEntry): string
|
|
|
351
351
|
* @param options - 引擎检查选项(depFields 等写入过滤面沿用检查时配置)
|
|
352
352
|
* @returns 已写入的包名列表与逐包失败信息
|
|
353
353
|
*/
|
|
354
|
-
declare function writeSelectedPackages(engine: DependenciesEnginePort, touchedPackages: readonly PackageMeta[], options: CheckOptions): Promise<{
|
|
354
|
+
declare function writeSelectedPackages(engine: DependenciesEnginePort, touchedPackages: readonly PackageMeta$1[], options: CheckOptions$1): Promise<{
|
|
355
355
|
/**
|
|
356
356
|
* 已写入的包名列表
|
|
357
357
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import"./rolldown-runtime-BqT_7tdF.js";import*as e from"zod";import{confirm as t}from"@longzai-intelligence-cli/core";import{CheckPackages as n,writePackage as r}from"@longzai-intelligence-dependencies/version-upgrade";import{summarizeCheckReport as i}from"@longzai-intelligence-plugin/core";import{loadUnifiedConfig as a}from"@longzai-intelligence-shared-config/core";import{readFile as o}from"node:fs/promises";import{join as s}from"node:path";function c(e,t,n){return`${e}\n${t}\n${n}`}function l(e){return e.name||e.relative}function u(e){let t=[],n=[];for(let r of e){let e=l(r);for(let i of r.resolved){let r=i.resolveError;r!=null&&i.update===!1?n.push({packageName:e,name:i.name,reason:typeof r==`string`?r:r.message}):i.update===!0&&t.push({key:c(e,i.name,i.source),packageName:e,name:i.name,currentVersion:i.currentVersion,targetVersion:i.targetVersion,source:i.source,diff:i.diff})}}return{checklist:t,resolveFailures:n}}function d(e,t){let n=[];for(let r of e){let e=l(r),i=!1;for(let n of r.resolved)n.update===!0&&(t.has(c(e,n.name,n.source))?i=!0:n.update=!1);i&&n.push(r)}return n}function f(e){let t=e.diff??``;return`${e.name}: ${e.currentVersion} -> ${e.targetVersion} (${e.source}${t===``?``:` ${t}`})`}async function p(e,t,n){let r=[],i=[];for(let a of t)try{await e.writePackage(a,n),r.push(l(a))}catch(e){i.push({packageName:l(a),reason:e instanceof Error?e.message:String(e)})}return{writtenPackages:r,failures:i}}const m=`\x1B[2K\r`,h=e=>`\x1b[${e}A`;function g(e,t,n,r,i){if(t>0){e.stdout.write(`${h(t)}${m}`);for(let n=1;n<t;n+=1)e.stdout.write(`${m}\n`);e.stdout.write(h(t-1>0?t-1:0))}return n.forEach((t,n)=>{let a=n===i?`>`:` `,o=r[n]===!0?`[x]`:`[ ]`;e.stdout.write(`${m}${a} ${o} ${t}\n`)}),e.stdout.write(`${m}空格切换勾选,a 全选切换,回车确认,q 取消\n`),n.length+1}function _(e,t){return new Promise(n=>{let r=e.length;if(r===0){n([]);return}let i=e.map(()=>!0),a=0,o=0;if(typeof t.stdin.setRawMode!=`function`){t.stdout.write(`非交互环境无法勾选,已取消执行
|
|
2
2
|
`),n(null);return}let s=e=>{t.stdin.removeListener(`data`,c),t.stdin.setRawMode?.(!1),n(e)},c=n=>{let c=typeof n==`string`?n:n.toString(`utf8`);if(c===`\r`||c===`
|
|
3
|
-
`)s(i.map((e,t)=>e?t:-1).filter(e=>e>=0));else if(c===`q`||c===`\x1B`||c===``)s(null);else if(c===`j`||c===`\x1B[B`)a=(a+1)%r,o=g(t,o,e,i,a);else if(c===`k`||c===`\x1B[A`)a=(a-1+r)%r,o=g(t,o,e,i,a);else if(c===` `)i[a]=i[a]!==!0,o=g(t,o,e,i,a);else if(c===`a`){let n=i.some(e=>e!==!0);for(let e=0;e<r;e+=1)i[e]=n;o=g(t,o,e,i,a)}};t.stdin.setRawMode(!0),t.stdin.on(`data`,c),o=g(t,0,e,i,a)})}function v(){return process.stdin.isTTY===!0}const y=e.object({key:e.string().min(1),packageName:e.string().min(1),name:e.string().min(1),currentVersion:e.string(),targetVersion:e.string(),source:e.string(),diff:e.enum([`major`,`minor`,`patch`,`error`]).nullable()}),b=e.object({status:e.enum([`pass`,`fail`,`skip`]),summary:e.string(),outputExcerpt:e.string().optional()}),x=e.object({status:e.enum([`pass`,`fail`,`skip`]),summary:e.string(),outputExcerpt:e.string().optional()}),S=e.object({mode:e.enum([`default`,`major`,`minor`,`patch`,`latest`,`newest`]),checklist:e.array(y),selected:e.array(e.string()),writtenPackages:e.array(e.string()),versionCheck:b.nullable(),versionSync:x.nullable()});function C(e){let t={items:[...e.items],totals:i(e.items)};return{pluginId:`dependencies-repository-plugin`,commandId:`upgrade`,
|
|
3
|
+
`)s(i.map((e,t)=>e?t:-1).filter(e=>e>=0));else if(c===`q`||c===`\x1B`||c===``)s(null);else if(c===`j`||c===`\x1B[B`)a=(a+1)%r,o=g(t,o,e,i,a);else if(c===`k`||c===`\x1B[A`)a=(a-1+r)%r,o=g(t,o,e,i,a);else if(c===` `)i[a]=i[a]!==!0,o=g(t,o,e,i,a);else if(c===`a`){let n=i.some(e=>e!==!0);for(let e=0;e<r;e+=1)i[e]=n;o=g(t,o,e,i,a)}};t.stdin.setRawMode(!0),t.stdin.on(`data`,c),o=g(t,0,e,i,a)})}function v(){return process.stdin.isTTY===!0}const y=e.object({key:e.string().min(1),packageName:e.string().min(1),name:e.string().min(1),currentVersion:e.string(),targetVersion:e.string(),source:e.string(),diff:e.enum([`major`,`minor`,`patch`,`error`]).nullable()}),b=e.object({status:e.enum([`pass`,`fail`,`skip`]),summary:e.string(),outputExcerpt:e.string().optional()}),x=e.object({status:e.enum([`pass`,`fail`,`skip`]),summary:e.string(),outputExcerpt:e.string().optional()}),S=e.object({mode:e.enum([`default`,`major`,`minor`,`patch`,`latest`,`newest`]),checklist:e.array(y),selected:e.array(e.string()),writtenPackages:e.array(e.string()),versionCheck:b.nullable(),versionSync:x.nullable()});function C(e){let t={items:[...e.items],totals:i(e.items)};return{pluginId:`dependencies-repository-plugin`,commandId:`upgrade`,status:e.status,summary:e.summary,report:t,data:{mode:e.mode,checklist:e.checklist,selected:e.selected,writtenPackages:e.writtenPackages,versionCheck:e.versionCheck,versionSync:e.versionSync}}}async function w(e){let t=await a({cwd:e,standaloneFile:`lzi-dependencies.config.ts`,unifiedField:`dependencies`});if(t.success&&t.config.upgrade!==void 0)return t.config.upgrade;let n=await a({cwd:e,standaloneFile:`lzi-dev.config.ts`,unifiedField:`devTools`});return n.success?n.config.versionUpgrade??{}:{}}function T(e){return typeof e==`object`&&!!e}async function E(e){try{let t=JSON.parse(await o(s(e,`package.json`),`utf-8`));if(T(t)&&T(t.scripts)){let e={};for(let[n,r]of Object.entries(t.scripts))typeof r==`string`&&(e[n]=r);return e}}catch{return{}}return{}}async function D(e,t){return typeof(await E(e))[t]==`string`}async function O(e,t){if(!await D(t,`version:check`))return{status:`skip`,summary:"目标仓缺少 `version:check` 脚本,跳过一致性复核"};let n=e.exec.run({command:`bun`,args:[`run`,`version:check`],cwd:t}),r=n.stdoutExcerpt.trim()||n.stderrExcerpt.trim();return n.code===0&&r.includes(`所有包版本一致`)?{status:`pass`,summary:r}:r.includes(`版本号不一致`)||r.includes(`缺少 version 字段`)?{status:`fail`,summary:`版本一致性复核未通过`,outputExcerpt:r}:{status:`fail`,summary:`version:check 退出码 ${n.code}${n.timedOut?`(超时被终止)`:``}`,outputExcerpt:r}}async function k(e){try{let t=JSON.parse(await o(s(e,`package.json`),`utf-8`));return typeof t==`object`&&t&&`version`in t&&typeof t.version==`string`?t.version:null}catch{return null}}function A(e,t,n){let r=e.exec.run({command:`bun`,args:[`run`,`version:sync`,n],cwd:t}),i=r.stdoutExcerpt.trim()||r.stderrExcerpt.trim();return r.code===0?{status:`pass`,summary:`version:sync ${n} 执行成功`,outputExcerpt:i}:{status:`fail`,summary:`version:sync ${n} 退出码 ${r.code}${r.timedOut?`(超时被终止)`:``}`,outputExcerpt:i}}const j=[`default`,`major`,`minor`,`patch`,`latest`,`newest`],M=e.enum(j).default(`default`);function N(e){process.stdout.write(`${e}\n`)}const P={checkPackages:n,writePackage:r};function F(){return{afterPackagesLoaded:e=>{N(`扫描到 ${e.length} 个包,正在检查依赖更新...`)},beforePackageStart:e=>{N(`正在检查 ${e.name||e.relative}...`)}}}function I(e,t,n){return{cwd:e,mode:t,write:!1,recursive:n.recursive??!0,timeout:n.timeout??3e4,retries:n.retries??3,exclude:n.exclude??[],include:n.include??[],depFields:n.depFields,ignorePaths:n.ignorePaths??[],concurrency:n.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`info`,silent:!1,failOnOutdated:!1}}function L(e,t){N(`
|
|
4
4
|
--- 可升级清单 ---`);let n=/* @__PURE__ */ new Map;e.forEach((e,t)=>{let r=n.get(e.packageName)??[];r.push(t),n.set(e.packageName,r)});for(let[t,r]of n){N(`${t}:`);for(let t of r){let n=e.at(t);n!==void 0&&N(` ${f(n)}`)}}t>0&&N(`另有 ${t} 条依赖解析失败,已计入警告项`)}async function R(e,t){if(e.write)return N(`\n全量执行:${t.length} 条`),{keys:t.map(e=>e.key),rejected:!1};if(!v())return N(`
|
|
5
5
|
非交互环境无法勾选,写路径已拒绝(使用 --dry-run 预览或在交互终端执行)`),{keys:null,rejected:!0};let n=await _(t.map(e=>f(e)),{stdin:process.stdin,stdout:process.stdout});return n===null||n.length===0?(N(`
|
|
6
6
|
已取消执行,未写入任何变更`),{keys:null,rejected:!1}):{keys:n.flatMap(e=>{let n=t.at(e);return n===void 0?[]:[n.key]}),rejected:!1}}async function z(e,n,r,i){if(!e.sync)return null;let a=await k(r),o;return o=a===null?{status:`skip`,summary:`目标仓根 package.json 缺少 version 字段,跳过写回`}:await t(`确认执行 version:sync ${a} 写回全部包版本?`)?A(n,r,a):{status:`skip`,summary:`用户取消 version:sync 写回`},i.push({id:`version-sync`,label:`版本写回`,status:o.status,detail:o.summary,...o.outputExcerpt===void 0?{}:{outputExcerpt:o.outputExcerpt}}),o}async function B(e){let n=e.services.engine??P,r=M.safeParse(e.positionals[0]??void 0);if(!r.success)return C({mode:`default`,checklist:[],selected:[],items:[{id:`mode-validation`,label:`升级模式校验`,status:`fail`,detail:`非法升级模式:${String(e.positionals[0])}(合法值 ${j.join(` / `)})`}],versionCheck:null,versionSync:null,summary:`升级模式非法,命令未执行`,status:`fail`,writtenPackages:[]});let i=r.data,a={write:e.opts.write===!0&&e.opts.dryRun!==!0,dryRun:e.opts.dryRun===!0,sync:e.opts.sync===!0},o=[],s=await w(e.repoRoot),c=I(e.repoRoot,i,s),{packages:l}=await n.checkPackages(c,F()),{checklist:f,resolveFailures:m}=u(l);if(m.length>0&&o.push({id:`resolve-failures`,label:`依赖解析失败统计`,status:`warn`,detail:m.map(e=>`${e.packageName} 的 ${e.name}:${e.reason}`).join(`;`)}),f.length===0)return C({mode:i,checklist:f,selected:[],items:[...o,{id:`upgrade-result`,label:`依赖升级结果`,status:`pass`,detail:`所有依赖已是最新版本`}],versionCheck:null,versionSync:null,summary:`所有依赖已是最新版本`,status:m.length>0?`warn`:`ok`,writtenPackages:[]});if(L(f,m.length),a.dryRun)return N(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-dependencies/repository-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Longzai Intelligence dependencies 仓级插件(repository 场景的依赖升级流)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dependencies",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"build:prod": "NODE_ENV=production bun run build",
|
|
29
29
|
"prepublishOnly": "bun run build:prod",
|
|
30
30
|
"typecheck": "lzi-typecheck",
|
|
31
|
-
"lint": "
|
|
32
|
-
"lint:fix": "
|
|
31
|
+
"lint": "lzi-lint lint",
|
|
32
|
+
"lint:fix": "lzi-lint fix",
|
|
33
33
|
"test": "bun test",
|
|
34
34
|
"test:watch": "bun test --watch",
|
|
35
35
|
"test:coverage": "bun test --coverage",
|
|
36
|
-
"clean": "lzi-dev-
|
|
36
|
+
"clean": "lzi-dev-tools clean"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@longzai-intelligence-cli/core": "^0.0.
|
|
40
|
-
"@longzai-intelligence-dependencies/core": "0.0.
|
|
41
|
-
"@longzai-intelligence-dependencies/version-upgrade": "0.0.
|
|
42
|
-
"@longzai-intelligence-plugin/core": "^0.0.
|
|
43
|
-
"@longzai-intelligence-shared-config/core": "^0.0.
|
|
44
|
-
"zod": "^4.
|
|
39
|
+
"@longzai-intelligence-cli/core": "^0.0.18",
|
|
40
|
+
"@longzai-intelligence-dependencies/core": "0.0.20",
|
|
41
|
+
"@longzai-intelligence-dependencies/version-upgrade": "0.0.20",
|
|
42
|
+
"@longzai-intelligence-plugin/core": "^0.0.8",
|
|
43
|
+
"@longzai-intelligence-shared-config/core": "^0.0.10",
|
|
44
|
+
"zod": "^4.6.7"
|
|
45
45
|
}
|
|
46
46
|
}
|