@longzai-intelligence-dependencies/core 0.0.8 → 0.0.10
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 +85 -20
- package/dist/index.js +8 -7
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
-
import { HoistingConfig, LziDependenciesConfig, LziDependenciesConfig as LziDependenciesConfig$1, OverridesConfig, UpgradeConfig } from "@longzai-intelligence-dependencies/config";
|
|
2
|
+
import { HoistingConfig, LziDependenciesConfig, LziDependenciesConfig as LziDependenciesConfig$1, OverridesConfig, RootManifestConfig, UpgradeConfig } from "@longzai-intelligence-dependencies/config";
|
|
3
3
|
import { Command } from "@longzai-intelligence-cli/core";
|
|
4
|
-
//#region src/commands/hoisting-check.usecase.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* hoisting check 命令实现
|
|
7
6
|
* 扫描 workspace 全部 package.json,按 ADR 0036 判定子包 devDependencies
|
|
@@ -18,8 +17,6 @@ import { Command } from "@longzai-intelligence-cli/core";
|
|
|
18
17
|
* 发现重复声明时打印明细并以退出码 1 收口
|
|
19
18
|
*/
|
|
20
19
|
declare const hoistingCheckCommand: () => Promise<void>;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/commands/overrides-check.usecase.d.ts
|
|
23
20
|
/**
|
|
24
21
|
* overrides check 命令实现
|
|
25
22
|
* 扫描仓库全部 package.json,按 ADR 0153 判定 `overrides`、`pnpm.overrides`、
|
|
@@ -36,8 +33,6 @@ declare const hoistingCheckCommand: () => Promise<void>;
|
|
|
36
33
|
* 打印明细并以退出码 1 收口
|
|
37
34
|
*/
|
|
38
35
|
declare const overridesCheckCommand: () => Promise<void>;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/commands/register.commands.d.ts
|
|
41
36
|
/**
|
|
42
37
|
* upgrade 域:依赖版本升级(2026-10-07 双仓分工裁定后自 version 前缀升为顶层命令)
|
|
43
38
|
*
|
|
@@ -66,16 +61,95 @@ declare function registerHoisting(program: Command): void;
|
|
|
66
61
|
* @param program - 待挂载子命令的 commander 根程序实例
|
|
67
62
|
*/
|
|
68
63
|
declare function registerOverrides(program: Command): void;
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
/**
|
|
65
|
+
* 工作区根清单依赖准入检查的规则常量
|
|
66
|
+
*
|
|
67
|
+
* 白名单收录允许出现在 workspace 根清单的 Longzai Intelligence 工具链
|
|
68
|
+
* scope,正本在本文件单一样本维护,判定口径与立法背景见 ADR 0182。
|
|
69
|
+
* 运行时库与平台仓不入本集合,其偶发工具形态消费经 `rootManifest.allowlist`
|
|
70
|
+
* 精确依赖名登记豁免
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* 工作区根清单允许的 Longzai Intelligence 工具链 scope 集合
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* 条目为完整 scope 形态如 `@longzai-intelligence-builder`,分组依据为
|
|
77
|
+
* 2026-10-24 全群仓证尽调即各仓 package 描述与 README 自述及 ADR 可
|
|
78
|
+
* 考性。准入语义是工具消费形态即开发期工具、治理引擎、注册表、文档
|
|
79
|
+
* 族、数据仓工具与私有轨。业务包如 error 与 logger 一族运行时库经
|
|
80
|
+
* 用户裁定不入本集合,shared-kernel 与 event-bus 等运行时库仓经仓证
|
|
81
|
+
* 同判。新增 scope 须附自述或 ADR 依据补入对应分组
|
|
82
|
+
*/
|
|
83
|
+
declare const ROOT_MANIFEST_TOOLCHAIN_SCOPES: ReadonlySet<string>;
|
|
84
|
+
/**
|
|
85
|
+
* 工作区根清单依赖准入检测
|
|
86
|
+
*
|
|
87
|
+
* 纯函数判定 workspace 根清单的 Longzai Intelligence 依赖是否越出工具
|
|
88
|
+
* 链 scope 白名单,业务包出现在根清单即违例,辖域判定与立法背景见
|
|
89
|
+
* ADR 0182
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* 参与准入判定的根清单形态
|
|
93
|
+
*/
|
|
94
|
+
type RootManifestForAdmission = {
|
|
95
|
+
/**
|
|
96
|
+
* workspaces 字段,存在即认定该清单为 workspace 根清单
|
|
97
|
+
*/
|
|
98
|
+
workspaces?: unknown;
|
|
99
|
+
/**
|
|
100
|
+
* 运行时依赖映射,缺省为无
|
|
101
|
+
*/
|
|
102
|
+
dependencies?: Record<string, string>;
|
|
103
|
+
/**
|
|
104
|
+
* 开发依赖映射,缺省为无
|
|
105
|
+
*/
|
|
106
|
+
devDependencies?: Record<string, string>;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* 单条业务依赖违例
|
|
110
|
+
*/
|
|
111
|
+
type RootManifestAdmissionViolation = {
|
|
112
|
+
/**
|
|
113
|
+
* 违例的依赖名
|
|
114
|
+
*/
|
|
115
|
+
dependency: string;
|
|
116
|
+
/**
|
|
117
|
+
* 依赖所在的清单字段名
|
|
118
|
+
*/
|
|
119
|
+
field: 'dependencies' | 'devDependencies';
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* 准入检测结果
|
|
123
|
+
*/
|
|
124
|
+
type RootManifestAdmissionResult = {
|
|
125
|
+
/**
|
|
126
|
+
* 是否处于准入辖域,根清单声明 workspaces 字段即辖域
|
|
127
|
+
*/
|
|
128
|
+
inScope: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 违例条目列表,辖域外恒为空
|
|
131
|
+
*/
|
|
132
|
+
violations: RootManifestAdmissionViolation[];
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* 检测工作区根清单的业务依赖违例
|
|
136
|
+
*
|
|
137
|
+
* 根清单未声明 workspaces 字段即不辖域,辖域内逐字段核对 Longzai
|
|
138
|
+
* Intelligence 依赖的 scope 白名单资格,业务包出现在根清单即违例
|
|
139
|
+
*
|
|
140
|
+
* @param manifest - 解析后的根清单对象
|
|
141
|
+
* @param allowlist - 豁免依赖名集合,命中精确依赖名不计违例
|
|
142
|
+
* @returns 准入检测结果,辖域外返回 inScope 为假且零违例
|
|
143
|
+
*/
|
|
144
|
+
declare const detectRootManifestAdmission: (manifest: RootManifestForAdmission, allowlist: ReadonlySet<string>) => RootManifestAdmissionResult;
|
|
71
145
|
/**
|
|
72
146
|
* 子命令选项
|
|
73
147
|
*/
|
|
74
148
|
type UpgradeAcrossOptions = {
|
|
75
149
|
/**
|
|
76
|
-
*
|
|
150
|
+
* 显式圈定的项目范围 id(缺省经 cwd 上溯结构锚点取当前 edition 范围)
|
|
77
151
|
*/
|
|
78
|
-
|
|
152
|
+
projectScope?: string;
|
|
79
153
|
/**
|
|
80
154
|
* 要升级的依赖 scope,如 '@longzai-intelligence-builder'
|
|
81
155
|
*
|
|
@@ -105,16 +179,12 @@ type UpgradeAcrossOptions = {
|
|
|
105
179
|
*/
|
|
106
180
|
dryRun: boolean;
|
|
107
181
|
};
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/commands/upgrade-across.d.ts
|
|
110
182
|
/**
|
|
111
183
|
* 执行 version upgrade-across 命令
|
|
112
184
|
*
|
|
113
185
|
* @param options - 命令选项
|
|
114
186
|
*/
|
|
115
187
|
declare const upgradeAcrossCommand: (options: UpgradeAcrossOptions) => Promise<void>;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/commands/upgrade.usecase.d.ts
|
|
118
188
|
/**
|
|
119
189
|
* 依赖版本升级命令
|
|
120
190
|
*
|
|
@@ -151,8 +221,6 @@ type UpgradeCommandOptions = {
|
|
|
151
221
|
* @param options - 命令选项
|
|
152
222
|
*/
|
|
153
223
|
declare const upgradeCommand: (options: UpgradeCommandOptions) => Promise<void>;
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/config/config-loader.utils.d.ts
|
|
156
224
|
/**
|
|
157
225
|
* 查找配置文件路径
|
|
158
226
|
*
|
|
@@ -177,8 +245,6 @@ declare const loadConfig: () => Promise<LziDependenciesConfig$1>;
|
|
|
177
245
|
* @returns 配置文件路径,如果找不到项目根目录则返回 null
|
|
178
246
|
*/
|
|
179
247
|
declare const getConfigFilePath: () => string | null;
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/utils/cli-output.utils.d.ts
|
|
182
248
|
/**
|
|
183
249
|
* CLI 输出工具
|
|
184
250
|
*
|
|
@@ -207,5 +273,4 @@ declare function stdout(...args: readonly unknown[]): void;
|
|
|
207
273
|
* @param args - 任意参数列表
|
|
208
274
|
*/
|
|
209
275
|
declare function stderr(...args: readonly unknown[]): void;
|
|
210
|
-
|
|
211
|
-
export { COLORS, type HoistingConfig, type LziDependenciesConfig, type OverridesConfig, type UpgradeConfig, findConfigFile, getConfigFilePath, hoistingCheckCommand, loadConfig, overridesCheckCommand, registerHoisting, registerOverrides, registerVersion, stderr, stdout, upgradeAcrossCommand, upgradeCommand };
|
|
276
|
+
export { COLORS, type HoistingConfig, type LziDependenciesConfig, type OverridesConfig, ROOT_MANIFEST_TOOLCHAIN_SCOPES, type RootManifestAdmissionResult, type RootManifestAdmissionViolation, type RootManifestConfig, type RootManifestForAdmission, type UpgradeConfig, detectRootManifestAdmission, findConfigFile, getConfigFilePath, hoistingCheckCommand, loadConfig, overridesCheckCommand, registerHoisting, registerOverrides, registerVersion, stderr, stdout, upgradeAcrossCommand, upgradeCommand };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{
|
|
2
|
-
以下子包重复声明根已有的开发依赖:`);for(let e of u){let t=e.drifted?` 版本漂移`:``;
|
|
3
|
-
以下清单声明了未豁免的 overrides 族强制版本字段:`);for(let e of l)
|
|
4
|
-
--- 检查结果 ---`);let
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{basename as e,join as t,relative as n}from"node:path";import{glob as r}from"tinyglobby";import*as i from"zod";import{findDependenciesConfigFile as a,loadDependenciesConfig as o}from"@longzai-intelligence-dependencies/config";import{existsSync as s}from"node:fs";import{defineCommand as c}from"@longzai-intelligence-cli/core";import{CheckPackages as l,getPackageData as u}from"@longzai-intelligence-dependencies/version-upgrade";import{resolveProjects as d}from"@longzai-intelligence-project-registry/core";const f={RED:`\x1B[0;31m`,GREEN:`\x1B[0;32m`,YELLOW:`\x1B[1;33m`,BLUE:`\x1B[0;34m`,RESET:`\x1B[0m`};function p(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function m(...e){process.stdout.write(`${p(e)}\n`)}function h(...e){process.stderr.write(`${p(e)}\n`)}const g=()=>a(),_=async()=>{let e=await o();return e?(e.source===`legacy-dev-tools`&&m(`提示: 经 lzi-dev.config.ts 共享读取依赖工具配置,建议补建 lzi-dependencies.config.ts`),e.config):(m(`提示: 未找到配置文件 lzi-dependencies.config.ts,使用默认配置`),{})},v=()=>{let e=process.cwd();for(;e!==`/`;){if(s(t(e,`package.json`)))return t(e,`lzi-dependencies.config.ts`);e=t(e,`..`)}return null},y=[`**/node_modules/**`,`**/oh_modules/**`,`**/target/**`,`**/dist/**`,`**/build/**`,`**/.turbo/**`],b=e=>!e||e.length===0?y:[...y,...e],x=i.object({name:i.string().optional(),workspaces:i.unknown().optional(),devDependencies:i.record(i.string(),i.string()).optional()}),S=async()=>{let e=process.cwd();m(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=x.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&(m(`未找到可解析的 workspace 根 package.json,请在仓库根目录执行本命令`),process.exit(1));let i=await _(),a=b(i.hoisting?.ignorePaths),o=new Set(i.hoisting?.allowlist??[]),s=t.devDependencies??{},c=await r(`**/package.json`,{cwd:e,ignore:a,onlyFiles:!0,dot:!1}),l=0,u=[];for(let t of c){if(t===`package.json`)continue;let r=null;try{let n=x.safeParse(await Bun.file(`${e}/${t}`).json());r=n.success?n.data:null}catch{r=null}if(r===null||r.workspaces!==void 0)continue;let i=r.devDependencies??{};if(Object.keys(i).length!==0){l+=1;for(let[a,c]of Object.entries(i)){let i=s[a];i===void 0||o.has(a)||u.push({packageName:r.name??t,relPath:n(e,`${e}/${t}`),dependency:a,subRange:c,rootRange:i,drifted:c!==i})}}}if(m(`找到 ${l} 个子包,根声明开发依赖 ${Object.keys(s).length} 项`),u.length===0)m(`所有子包均未重复声明根已有的开发依赖`);else{m(`
|
|
2
|
+
以下子包重复声明根已有的开发依赖:`);for(let e of u){let t=e.drifted?` 版本漂移`:``;m(` ${e.packageName} ${e.relPath}`),m(` ${e.dependency} 子声明 ${e.subRange} 根声明 ${e.rootRange}${t}`)}m(`共 ${u.length} 处重复声明,处置口径见 ADR 0036`),process.exit(1)}},C=i.object({name:i.string().optional(),overrides:i.record(i.string(),i.unknown()).optional(),pnpm:i.object({overrides:i.record(i.string(),i.unknown()).optional()}).optional(),resolutions:i.record(i.string(),i.unknown()).optional()}),w=e=>typeof e==`string`?e:`嵌套对象`,T=async()=>{let e=process.cwd();m(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=C.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&(m(`未找到可解析的仓库根 package.json,请在仓库根目录执行本命令`),process.exit(1));let i=await _(),a=b(i.overrides?.ignorePaths),o=new Set(i.overrides?.allowlist??[]),s=await r(`**/package.json`,{cwd:e,ignore:a,onlyFiles:!0,dot:!1}),c=0,l=[];for(let t of s){let r=null;try{let n=C.safeParse(await Bun.file(`${e}/${t}`).json());r=n.success?n.data:null}catch{r=null}if(r===null)continue;c+=1;let i=[[`overrides`,r.overrides??{}],[`pnpm.overrides`,r.pnpm?.overrides??{}],[`resolutions`,r.resolutions??{}]];for(let[a,s]of i)for(let[i,c]of Object.entries(s))o.has(i)||l.push({packageName:r.name??t,relPath:n(e,`${e}/${t}`),field:a,entry:i,value:w(c)})}if(m(`扫描到 ${c} 个清单,登记豁免条目 ${o.size} 项`),l.length===0)m(`全部清单均未声明未豁免的 overrides 族强制版本字段`);else{m(`
|
|
3
|
+
以下清单声明了未豁免的 overrides 族强制版本字段:`);for(let e of l)m(` ${e.packageName} ${e.relPath}`),m(` ${e.field} ${e.entry} ${e.value}`);m(`共 ${l.length} 处强制版本条目,处置口径见 ADR 0153,豁免须经特别申请登记于 lzi-dependencies.config.ts 的 overrides.allowlist`),process.exit(1)}},E=/* @__PURE__ */ new Set(/* @__PURE__ */ `@longzai-intelligence-agent-tools.@longzai-intelligence-api.@longzai-intelligence-builder.@longzai-intelligence-bun.@longzai-intelligence-changelog.@longzai-intelligence-decision.@longzai-intelligence-dependencies.@longzai-intelligence-dev-tools.@longzai-intelligence-env.@longzai-intelligence-features.@longzai-intelligence-git.@longzai-intelligence-issues.@longzai-intelligence-ledger.@longzai-intelligence-markdown.@longzai-intelligence-oxfmt.@longzai-intelligence-oxlint.@longzai-intelligence-release.@longzai-intelligence-screenshots.@longzai-intelligence-shared-config.@longzai-intelligence-standards.@longzai-intelligence-taro.@longzai-intelligence-tsconfig.@longzai-intelligence-tsgo.@longzai-intelligence-typescript.@longzai-intelligence-version.@longzai-intelligence-vitest.@longzai-intelligence-vscode.@longzai-intelligence-changeset.@longzai-intelligence-cli.@longzai-intelligence-config.@longzai-intelligence-deploy.@longzai-intelligence-dimensions.@longzai-intelligence-docs.@longzai-intelligence-findings.@longzai-intelligence-git-commit.@longzai-intelligence-git-swarm.@longzai-intelligence-lint.@longzai-intelligence-mechanisms.@longzai-intelligence-npm-registry.@longzai-intelligence-pitfalls.@longzai-intelligence-port.@longzai-intelligence-prettier.@longzai-intelligence-project-registry.@longzai-intelligence-readme.@longzai-intelligence-records.@longzai-intelligence-reflections.@longzai-intelligence-remote-machine.@longzai-intelligence-runtime.@longzai-intelligence-runtime-registry.@longzai-intelligence-scripts.@longzai-intelligence-specs.@longzai-intelligence-testing.@longzai-intelligence-toolchain.@longzai-intelligence-tsdoc.@longzai-intelligence-vite.@longzai-intelligence-wifi.@longzai-intelligence-growth.@longzai-intelligence-inbox.@longzai-intelligence-kol.@longzai-intelligence-one-digest.@longzai-intelligence-code-report.@longzai-intelligence-competition-registry.@longzai-intelligence-journals.@longzai-intelligence-music-video.@longzai-intelligence-nation.@longzai-intelligence-paper-report.@longzai-intelligence-closed-loop-markdown.@longzai-intelligence-crossref-markdown.@longzai-intelligence-disk-space-markdown.@longzai-intelligence-github-trending-markdown.@longzai-intelligence-input-markdown.@longzai-intelligence-journals-markdown.@longzai-intelligence-kol-markdown.@longzai-intelligence-knowledge-markdown.@longzai-intelligence-okr-markdown.@longzai-intelligence-open-router-markdown.@longzai-intelligence-philosophy-markdown.@longzai-intelligence-project-markdown.@longzai-intelligence-roadmap-markdown.@longzai-intelligence-rss-markdown.@longzai-intelligence-schedule-markdown.@longzai-intelligence-task-markdown.@longzai-intelligence-workflow-markdown.@longzai-intelligence-bilibili-markdown-private.@longzai-intelligence-douyin-markdown-private.@longzai-intelligence-law-markdown-private.@longzai-intelligence-release-workflow-private.@longzai-intelligence-research-report-markdown-private.@longzai-intelligence-research-report-private.@longzai-intelligence-runtime-registry-private.@longzai-intelligence-strategy-consulting-markdown-private.@longzai-intelligence-twitter-markdown-private.@longzai-intelligence-xiaohongshu-markdown-private.@longzai-intelligence-youtube-markdown-private.@longzai-intelligence-youtube-private`.split(`.`)),D=[`dependencies`,`devDependencies`],O=e=>{if(!e.startsWith(`@longzai-intelligence-`))return null;let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)},k=(e,t)=>{if(e.workspaces===void 0)return{inScope:!1,violations:[]};let n=[];for(let r of D){let i=e[r]??{};for(let[e]of Object.entries(i)){let i=O(e);i===null||t.has(e)||E.has(i)||n.push({dependency:e,field:r})}}return{inScope:!0,violations:n}},A=`@longzai-intelligence`,j=i.object({workspaces:i.unknown().optional(),dependencies:i.record(i.string(),i.string()).optional(),devDependencies:i.record(i.string(),i.string()).optional()}),M=async()=>{let e=await N(),t=process.env.npm_config_registry;process.env.npm_config_registry=`https://registry.npmjs.org/`;let n;try{n=await P(void 0)}finally{t===void 0?delete process.env.npm_config_registry:process.env.npm_config_registry=t}let r=F(n);m(`
|
|
4
|
+
--- 检查结果 ---`);let i=0;if(i+=I(n,new Set(r),!1),r.length>0){m(`\n回退基线:${r.length} 个内部包在 npm 无记录,按本机 registry 配置复查`);let e=await P(r);i+=I(e,new Set(r),!0)}i===0?m(`全部 Longzai Intelligence 包依赖均为最新版`):h(`\n共 ${i} 个内部包依赖非最新版,修复指引: 在仓根执行 lzi-dependencies upgrade --write 或 bun run version:upgrade`);let a=e+i;a!==0&&process.exit(Math.min(a,255))},N=async()=>{let e=null;try{let t=j.safeParse(await Bun.file(`${process.cwd()}/package.json`).json());e=t.success?t.data:null}catch{e=null}if(e===null)return 0;let t=k(e,await ee());if(!t.inScope)return 0;if(m(`
|
|
5
|
+
--- 根清单依赖准入 ---`),t.violations.length===0)return m(`工作区根清单未发现业务依赖`),0;for(let e of t.violations)m(` ${e.dependency} ${e.field}`);return m(`共 ${t.violations.length} 处业务依赖出现在工作区根清单,业务依赖应下沉到实际使用的子包,处置口径见 ADR 0182`),t.violations.length},ee=async()=>{let e=await _();return new Set(e.rootManifest?.allowlist??[])},P=async e=>{let t=(await _()).upgrade??{},n={cwd:process.cwd(),mode:`latest`,write:!1,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:e===void 0?t.include??[]:[...e],depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`silent`,silent:!0,failOnOutdated:!1},{packages:r}=await l(n,{afterPackagesLoaded:e=>{m(`扫描到 ${e.length} 个包,正在校验 Longzai Intelligence 依赖新鲜度...`)}});return r},F=e=>{let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.resolved)e.name.startsWith(A)&&e.resolveError!=null&&t.add(e.name);return[...t]},I=(e,t,n)=>{let r=0;for(let i of e){let e=i.resolved.filter(e=>!e.update||!e.name.startsWith(A)?!1:n?t.has(e.name):!t.has(e.name));if(e.length!==0){r+=e.length,m(`\n${i.name||i.relative}:`);for(let t of e){let e=t.diff??``,r=n?`,回退基线`:``;m(` ${t.name}: ${t.currentVersion} -> ${t.targetVersion} ${e}${r}`)}}}return r};function L(e){let n=e;for(;;){if(s(t(n,`longzai-intelligence-globals`))||s(t(n,`lzi-architecture.yaml`)))return n;let e=t(n,`..`);if(e===n)return;n=e}}function R(e){return e.filter(e=>s(t(e.path,`package.json`))).map(e=>({name:e.project,dir:e.path}))}async function z(n){if(n.projectScope!==void 0){let e=await d({scopeIds:[n.projectScope]});return e.ok||(h(`错误: 项目范围解析失败: ${e.error.message}`),h(`提示: 请确认 .env 配置 LZI_PROJECT_REGISTRY_ROOT 与 LZI_PROJECT_SCOPE_ROOTS`),process.exit(1)),{registryRoot:e.value.registryRoot,scopeId:n.projectScope,projects:R(e.value.projects),source:`env`}}let r=L(n.cwd??process.cwd());r===void 0&&(h(`错误: 未定位产品群聚合根(一级子目录应存在 longzai-intelligence-globals 仓)`),h(`提示: 请自产品群内任意仓库运行,或使用 --project-scope <id> 显式圈定范围`),process.exit(1));let i=e(r),a=t(r,`longzai-intelligence-project-registry`);s(t(a,`scopes`))||(h(`错误: registry 声明域缺失: ${t(a,`scopes`)}`),h(`提示: 请确认 longzai-intelligence-project-registry 仓已在聚合根就位`),process.exit(1));let o=await d({registryRoot:a,scopeIds:[i],scopeRoots:/* @__PURE__ */ new Map([[i,r]])});return o.ok||(h(`错误: 项目范围解析失败: ${o.error.message}`),process.exit(1)),{registryRoot:a,scopeId:i,projects:R(o.value.projects),source:`structure`}}const B=(e,t)=>Bun.spawnSync([`git`,`diff`,`--quiet`,`HEAD`,`--`,t],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,V=e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`("${t}/[^"]+":\\s*")[^"]*(")`,`g`)},H=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),U=e=>/^[~^]?\d/.test(e),W=(e,t)=>`${/^[~^]/.exec(e)?.[0]??``}${t}`,G=e=>{let n=Bun.spawnSync([`git`,`ls-files`,`--`,`*/package.json`],{cwd:e,stdout:`pipe`,stderr:`pipe`});return n.exitCode===0?[`package.json`,...(n.stdout?.toString()??``).trim().split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0).filter(n=>s(t(e,n)))]:[`package.json`]},K=(e,t,n)=>Bun.spawnSync([`git`,`commit`,...t,`-m`,n],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,q=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[],o=[],s;for(t.lastIndex=0;(s=t.exec(r))!==null;){let e=s[0],t=s[1]??``,r=s[2]??``,i=/^"([^"]+)"/.exec(t)?.[1]??``,a=e.slice(t.length,e.length-r.length),c=n(i,a);a!==c&&U(a)&&o.push({name:i,oldVersion:a,targetVersion:c,prefix:t,suffix:r})}if(o.length===0)return{matchedPackages:i,changes:a};let c=r;for(let e of o){let t=RegExp(`("${H(e.name)}":\\s*")[^"]*(")`);c=c.replace(t,`$1${e.targetVersion}$2`),i.push(e.name),a.push({name:e.name,from:e.oldVersion,to:e.targetVersion})}return await Bun.write(e,c),{matchedPackages:i,changes:a}},J=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[];t.lastIndex=0;let o;for(;(o=t.exec(r))!==null;){let e=o[0],t=o[1]??``,r=o[2]??``,s=/^"([^"]+)"/.exec(t)?.[1]??``,c=e.slice(t.length,e.length-r.length),l=n(s,c);c!==l&&U(c)&&(i.push(s),a.push({name:s,from:c,to:l}))}return{matchedPackages:i,changes:a}},Y=async(e,n,r,i,a)=>{let{name:o,dir:s}=e,c=G(s),l=[],u=[],d=[],f=[];for(let e of c){let i=t(s,e),o=await J(i,n,r);if(o.matchedPackages.length!==0){if(!B(s,e))d.push(e);else{if(a)l.push(...o.matchedPackages),u.push(...o.changes);else{let e=await q(i,n,r);l.push(...e.matchedPackages),u.push(...e.changes)}f.push(e)}}}return f.length===0?d.length>0?{name:o,dir:s,matchedPackages:l,changes:u,skippedFiles:d,status:`skipped-dirty`,reason:`package.json 已有未提交改动:${d.join(`,`)}`}:{name:o,dir:s,matchedPackages:l,changes:u,status:`skipped-nochange`,reason:`无匹配 scope 或已是目标版本`}:a||K(s,f,i)?{name:o,dir:s,matchedPackages:l,changes:u,skippedFiles:d,status:`success`}:{name:o,dir:s,matchedPackages:l,changes:u,skippedFiles:d,status:`failed`,reason:`git commit 失败,文件已修改,需人工介入`}},X=async(e,n)=>{let r=/* @__PURE__ */ new Set;for(let i of e){let e=G(i.dir);for(let a of e){let e=t(i.dir,a),o=await Bun.file(e).text();n.lastIndex=0;let s;for(;(s=n.exec(o))!==null;){let e=s[1]??``,t=/^"([^"]+)"/.exec(e)?.[1];t&&r.add(t)}}}return[...r]},Z=async(e,t)=>{let n=/* @__PURE__ */ new Map,r=[],i=0,a=async e=>{let t=await u(e),i=t.tags?.latest;if(i===void 0){let n=t.error instanceof Error?t.error.message:t.error??`未找到 dist-tags.latest`;r.push({name:e,reason:n})}else n.set(e,i)},o=async()=>{for(;i<e.length;){let t=e[i];i++,t!==void 0&&await a(t)}},s=Array.from({length:Math.min(t,e.length)},()=>o());if(await Promise.all(s),r.length>0){h(`${f.RED}错误: 部分包查询 npm latest 失败,已中止(0 文件改动、0 提交)${f.RESET}`);for(let e of r)h(` ${e.name}: ${e.reason}`);process.exit(1)}return n},Q=async e=>{let{scope:t,version:n,message:r,dryRun:i}=e,a=e.concurrency??10,o=await z({projectScope:e.projectScope}),s=n===void 0,c=s?`latest(各自 npm 最新)`:n,l=r??(s?`chore: bump ${t} deps to latest`:`chore: bump ${t} deps to ${n.replace(/^[~^]/,``)}`),u=V(t);m(`${f.BLUE}═══ version upgrade-across ═══${f.RESET}`),m(`项目获取来源: ${o.source===`structure`?`结构锚点(cwd 上溯聚合根)`:`显式圈定(--project-scope)`}`),m(`registry: ${o.registryRoot}`),m(`项目范围: ${o.scopeId}`),m(`升级范围: ${t} 下的所有包 -> ${c}`),m(`并发数: ${a}`),i&&m(`${f.YELLOW}[dry-run] 预览模式,不写文件、不提交${f.RESET}`),m(``);let d=o.projects;m(`发现 ${d.length} 个子项目,并发处理(并发 ${a})...`),m(``);let p;if(s){let e=await X(d,u);if(e.length===0){m(`${f.YELLOW}未匹配到任何 ${t} 下的包,结束${f.RESET}`);return}m(`匹配到 ${e.length} 个 ${t} 下的包,查询 npm latest...`);let n=await Z(e,a);p=(e,t)=>W(t,n.get(e)??``)}else{let e=n??``;p=()=>e}let h=[],g=0,_=d.length;await(async(e,t)=>{let n=0,r=async()=>{for(;n<e.length;){let t=e[n];if(n++,t===void 0)break;let r=await Y(t,u,p,l,i);h.push(r),g++;let a=r.status===`success`?`${f.GREEN}✓${f.RESET}`:r.status===`failed`?`${f.RED}✗${f.RESET}`:`·`;m(` [${g}/${_}] ${a} ${t.name}`)}},a=Array.from({length:Math.min(t,e.length)},()=>r());await Promise.all(a)})(d,a),m(``),te(h,i)},te=(e,t)=>{let n=e.filter(e=>e.status===`success`),r=e.filter(e=>e.status===`skipped-dirty`),i=e.filter(e=>e.status===`skipped-nochange`),a=e.filter(e=>e.status===`failed`);m(`${f.BLUE}═══ 处理结果 ═══${f.RESET}`);let o=t?`将提交`:`已提交`;m(`${f.GREEN}✓ ${o}: ${n.length}${f.RESET}`);for(let e of n){let t=e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `);m(` ${e.name}`),m(` ${t}`),e.skippedFiles!==void 0&&e.skippedFiles.length>0&&m(` ⚠ 脏文件跳过:${e.skippedFiles.join(`,`)}`)}if(r.length>0){m(``),m(`${f.YELLOW}⚠ 跳过(文件已改动): ${r.length}${f.RESET}`);for(let e of r)m(` ${e.name}: ${e.reason}`)}if(i.length>0&&(m(``),m(`跳过(无匹配/已是目标版本): ${i.length}`)),a.length>0){m(``),m(`${f.RED}✗ 失败(需人工介入): ${a.length}${f.RESET}`);for(let e of a)m(` ${e.name}: ${e.reason}`),m(` ${e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `)}`)}m(``),m(`${f.BLUE}汇总: ${n.length} ${o} / ${r.length} 跳过(dirty) / ${i.length} 跳过(无变更) / ${a.length} 失败${f.RESET}`),!t&&n.length>0&&(m(``),m(`下一步:推送到远程`),m(` bun push-all`)),a.length>0&&(process.exitCode=1)},ne=i.enum([`default`,`major`,`minor`,`patch`,`latest`,`newest`]).default(`default`),$=async e=>{let t=(await _()).upgrade??{},n=e.mode||t.mode||`default`,r=ne.safeParse(n),i=r.success?r.data:`default`,a=[...e.scope?[`${e.scope}/*`]:[],...t.include??[]],o={cwd:process.cwd(),mode:i,write:!e.dryRun&&e.write,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:a,depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.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},{packages:s}=await l(o,{afterPackagesLoaded:e=>{m(`扫描到 ${e.length} 个包,正在检查依赖更新...`)},beforePackageStart:e=>{m(`正在检查 ${e.name||e.relative}...`)},afterPackageEnd:e=>{let t=e.resolved.filter(e=>e.update).length;m(t>0?` ✓ ${e.name||e.relative}: 发现 ${t} 个可更新依赖`:` ✓ ${e.name||e.relative}: 所有依赖已是最新`)},afterPackageWrite:e=>{m(` 📝 已写入 ${e.name||e.relative}`)}}),c=0;m(`
|
|
7
|
+
--- 检查结果 ---`);for(let e of s){let t=e.resolved.filter(e=>e.update);if(t.length>0){c+=t.length,m(`\n${e.name||e.relative}:`);for(let e of t){let t=e.diff??``;m(` ${e.name}: ${e.currentVersion} -> ${e.targetVersion} (${t})`)}}}c===0?m(`所有依赖已是最新版本`):(m(`\n共发现 ${c} 个可更新依赖`),e.write?m(`已写入 package.json`):m(`使用 --write 参数写入 package.json`))};function re(e){c(e,{name:`upgrade`,description:`检查依赖版本更新`,arguments:[{signature:`[mode]`,description:`升级模式(major/minor/patch/latest/newest)`},{signature:`[scope]`,description:`可选。仅升级指定 scope 下的依赖(如 @longzai-intelligence-oxlint),内部展开为 include @scope/*`}],options:[{flags:`--write`,description:`将更新写入 package.json`},{flags:`--dry-run`,description:`仅预览`}],schema:i.looseObject({write:i.boolean().optional(),dryRun:i.boolean().optional()}),action:async(e,t)=>{let n=t[0],r=t[1];await $({mode:n,write:e.write===!0,dryRun:e.dryRun===!0,scope:r})}}),c(e,{name:`upgrade-across`,description:`跨产品群批量升级依赖(项目清单经 project-registry 声明域获取)`,options:[{flags:`--scope <scope>`,description:`依赖 scope(必填,如 @longzai-intelligence-builder)`},{flags:`--target <version>`,description:`目标版本号(可选,如 ^0.0.8。省略时自动取每个匹配包的 npm latest)`},{flags:`-m, --message <message>`,description:`自定义提交信息`},{flags:`--project-scope <id>`,description:`显式圈定项目范围(缺省自动取当前 edition 范围)`},{flags:`--concurrency <n>`,description:`并发数(默认 10)`},{flags:`--dry-run`,description:`仅预览(不写文件、不提交)`}],schema:i.looseObject({scope:i.string().optional(),target:i.string().optional(),message:i.string().optional(),config:i.string().optional(),concurrency:i.coerce.number().int().positive().optional(),projectScope:i.string().optional(),dryRun:i.boolean().optional()}),action:async e=>{e.scope||(process.stderr.write(`错误: upgrade-across 需要指定 --scope <@scope>
|
|
7
8
|
`),process.stderr.write(`示例: --scope @longzai-intelligence-builder
|
|
8
|
-
`),process.exit(1)),await Q({scope:e.scope,version:e.target,message:e.message,
|
|
9
|
+
`),process.exit(1)),await Q({scope:e.scope,version:e.target,message:e.message,projectScope:e.projectScope,concurrency:e.concurrency,dryRun:e.dryRun===!0})}}),c(e,{name:`check`,description:`校验全部 Longzai Intelligence 包依赖是否为 registry 最新版`,schema:i.looseObject({}),action:async()=>{await M()}})}function ie(e){c(e,{name:`hoisting check`,description:`检查子包开发依赖是否重复声明 workspace 根已有依赖`,schema:i.looseObject({}),action:async()=>{await S()}})}function ae(e){c(e,{name:`overrides check`,description:`检查 package.json 是否声明未豁免的强制版本字段`,schema:i.looseObject({}),action:async()=>{await T()}})}export{f as COLORS,E as ROOT_MANIFEST_TOOLCHAIN_SCOPES,k as detectRootManifestAdmission,g as findConfigFile,v as getConfigFilePath,S as hoistingCheckCommand,_ as loadConfig,T as overridesCheckCommand,ie as registerHoisting,ae as registerOverrides,re as registerVersion,h as stderr,m as stdout,Q as upgradeAcrossCommand,$ as upgradeCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-dependencies/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Longzai Intelligence 依赖版本管理命令用例族(version 命令域与配置装载)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -39,13 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@longzai-intelligence-cli/core": "^0.0.12",
|
|
42
|
-
"@longzai-intelligence-dependencies/config": "0.0.
|
|
43
|
-
"@longzai-intelligence-dependencies/version-upgrade": "0.0.
|
|
42
|
+
"@longzai-intelligence-dependencies/config": "0.0.10",
|
|
43
|
+
"@longzai-intelligence-dependencies/version-upgrade": "0.0.10",
|
|
44
|
+
"@longzai-intelligence-project-registry/core": "^0.0.1",
|
|
44
45
|
"@longzai-intelligence-shared-config/core": "^0.0.7",
|
|
45
46
|
"tinyglobby": "^0.2.17",
|
|
46
47
|
"zod": "^4.4.3"
|
|
47
48
|
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@longzai-intelligence-architecture/config": "0.0.2"
|
|
50
|
-
}
|
|
49
|
+
"devDependencies": {}
|
|
51
50
|
}
|