UNPKG

@tianyio/quality-helper

Version:

A comprehensive quality helper tool for project scaffolding and management

3 lines (2 loc) 2.43 kB
"use strict";const e=require("path"),n=require("ora"),t=require("chalk"),c=require("./utils-CuBC1baf.cjs"),o=require("./core-file-ops-CkY4H0C_.cjs"),a=require("./core-discovery-DoUt3gJ3.cjs"),s=require("./services-BHKno3F_.cjs");exports.checkDependencies=async function(){const{projectPath:e}=await a.Discovery.findProjectRoot();if(!e)throw new Error("未找到项目根目录(package.json)");await async function(e){const t=n("正在检查依赖状态...").start();try{const n=c.createDependencyManager(),o=await n.analyzeDependencies(e);t.stop(),n.generateReport(o),n.checkCompatibility(o),console.log('\n提示: 运行 "quality-helper update-deps" 更新依赖')}catch(o){throw t.fail("依赖状态检查失败"),o}}(e)},exports.updateDependencies=async function(){const{projectPath:i}=await a.Discovery.findProjectRoot();if(!i)throw new Error("未找到项目根目录(package.json)");const r=new s.UIService,l=await r.selectDependencyFile(i);await async function(a,s){const i=n("正在更新依赖到推荐版本...").start();try{let n=c.createDependencyManager();if(s){i.text="正在验证依赖列表文件...";const e=c.createDependencyValidator(),o=await e.validateDependencyFile(s);if(o.isValid){i.succeed("依赖列表文件验证通过"),e.printValidationResult(o,s);const t={};o.dependencies&&(t.customDependencies=o.dependencies),o.devDependencies&&(t.customDevDependencies=o.devDependencies),n=c.createDependencyManager(t)}else i.fail("依赖列表文件验证失败"),e.printValidationResult(o,s),console.log(t.yellow("\n⚠️ 将使用项目默认依赖列表")),n=c.createDependencyManager()}i.text="正在分析依赖配置...";const r=await n.updateToRecommendedVersions(a);if(i.stop(),!r)return void console.log(t.green("✅ 所有依赖已是最新版本"));await o.FileOperations.exists(e.join(a,"node_modules"))&&(i.start("正在清理现有依赖..."),await c.cleanDependencies(a),i.stop()),i.start("正在安装依赖..."),await c.installProjectDependencies(a),i.succeed("依赖更新完成")}catch(r){throw i.fail("依赖更新失败"),r.message?.includes("ERR_PNPM_INCLUDED_DEPS_CONFLICT")&&(console.log("\n💡 解决建议:"),console.log("1. 手动删除 node_modules 目录和 pnpm-lock.yaml 文件"),console.log('2. 运行 "pnpm install" 重新安装依赖'),console.log('3. 或者选择 "清理并重新安装" 选项')),r}}(i,l)}; //# sourceMappingURL=update-dependencies-Dk3dz_G3.cjs.map