deps-conflict-resolver 1.1.2 → 1.3.0

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/README.en.md CHANGED
@@ -137,6 +137,36 @@ The plugin supports automatic detection of the package manager and registry:
137
137
 
138
138
  An explicit `registry` option overrides this detection. The resolver uses it for remote version queries, and the package manager uses the same registry when installing aliases.
139
139
 
140
+ ## Command-Line Diagnostics and Preparation
141
+
142
+ Inspect conflicts, explicitly prepare aliases, and validate the installed environment offline in CI:
143
+
144
+ ```bash
145
+ pnpm exec deps-conflict-resolver doctor legacy-lib --json
146
+ pnpm exec deps-conflict-resolver prepare legacy-lib
147
+ pnpm exec deps-conflict-resolver doctor legacy-lib --offline --strict --json
148
+ ```
149
+
150
+ `doctor` never installs packages; without package names it scans runtime dependencies and installed optional dependencies. `prepare` requires package names and updates the manifest and lockfile through the project's package manager. `--json` emits structured diagnostics, aliases, and installation outcomes. Commit the resulting manifest and lockfile and use a frozen installation in CI.
151
+
152
+ ## Strict and Offline Resolution
153
+
154
+ `offline: true` reuses verified installed aliases without registry queries or installation. Setting `autoInstall: false` alone does not prevent version queries. `strict: true` reports unresolved required dependencies, installation failures, and ambiguous runtime resolutions. Both options default to `false`.
155
+
156
+ ```typescript
157
+ const resolver = await createResolver({
158
+ dependencies: ['legacy-lib'],
159
+ offline: true,
160
+ strict: true,
161
+ });
162
+
163
+ console.log(resolver.getDiagnostics());
164
+ console.log(resolver.getInstallResult());
165
+ console.log(resolver.explainResolution('vue', '/absolute/path/to/legacy-lib/index.js'));
166
+ ```
167
+
168
+ Diagnostics expose stable codes. A failed strict initialization throws the exported `ResolutionError`, which includes `diagnostics`.
169
+
140
170
  ## How It Works
141
171
 
142
172
  ### 1. Dependency Analysis
package/README.md CHANGED
@@ -137,6 +137,36 @@ const resolved = resolver.resolveModule('vue', '/path/to/importer.js');
137
137
 
138
138
  显式设置 `registry` 时会覆盖上述自动检测结果:解析器从该地址查询可用版本,包管理器安装别名时也使用同一地址。
139
139
 
140
+ ## 命令行诊断与准备
141
+
142
+ 可以先诊断依赖冲突,再显式安装需要的别名,并在 CI 中离线校验:
143
+
144
+ ```bash
145
+ pnpm exec deps-conflict-resolver doctor legacy-lib --json
146
+ pnpm exec deps-conflict-resolver prepare legacy-lib
147
+ pnpm exec deps-conflict-resolver doctor legacy-lib --offline --strict --json
148
+ ```
149
+
150
+ `doctor` 不执行安装;未指定包名时会检查项目的运行时依赖和已安装的可选依赖。`prepare` 需要指定包名,并通过项目包管理器更新依赖清单和锁文件。`--json` 输出包含诊断、别名和安装结果的结构化报告。建议提交准备过程产生的清单和锁文件,并在 CI 中先执行冻结安装。
151
+
152
+ ## 严格模式与离线解析
153
+
154
+ `offline: true` 只复用经过验证的已安装别名,不查询 registry,也不执行安装;单独设置 `autoInstall: false` 不会禁止版本查询。`strict: true` 会在必要依赖未解决、安装失败或实际解析存在歧义时报告错误。两者默认均为 `false`。
155
+
156
+ ```typescript
157
+ const resolver = await createResolver({
158
+ dependencies: ['legacy-lib'],
159
+ offline: true,
160
+ strict: true,
161
+ });
162
+
163
+ console.log(resolver.getDiagnostics());
164
+ console.log(resolver.getInstallResult());
165
+ console.log(resolver.explainResolution('vue', '/absolute/path/to/legacy-lib/index.js'));
166
+ ```
167
+
168
+ 诊断包含稳定的错误代码;严格模式初始化失败时可捕获导出的 `ResolutionError` 并读取其 `diagnostics`。
169
+
140
170
  ## 工作原理
141
171
 
142
172
  ### 1. 依赖分析