"use strict";var e=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))((function(n,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function l(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,l)}s((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateCmd=void 0;const t=require("../core/install"),o=require("../common/message"),r=require("../util"),n=require("../common/GlobalState"),a=require("../core/install/common/definitions"),i=require("../core/install/common/OptionValid"),l=require("../config"),s=require("../core/parameter"),c=require("../common/Constants"),u=require("../tools/filelock");exports.updateCmd=function(m,f){return e(this,void 0,void 0,(function*(){n.GlobalState.command=n.CommandType.UPDATE,f.experimentalConcurrentlySafe=f.experimentalConcurrentlySafe||a.defaultInstallOptions.experimentalConcurrentlySafe,f.experimentalConcurrentlySafe&&n.GlobalState.installMode.push(n.ExperimentalOption.CONCURRENTLY_SAFE_INSTALL);try{if(yield u.filelock.lock(),yield s.ParameterizationManager.getInstance().isParameterFileConfiged())throw new Error((0,o.format)(o.Messages.Parameterization.ForbiddenUpdateError,{configName:"parameterFile",ohPkgName:c.Constants.MyPackageJson}));for(const e of m){const t=r.PackageUtil.parse(e);if(t.version)throw new Error((0,o.format)(o.Messages.Update.HasVersion,{version:t.version}))}(0,i.validUpdateOptions)(n.GlobalState.command,f),yield(0,t.updateSymlink)(m,l.config.getRootDir(),f)}finally{u.filelock.unlock()}}))};