mirror of
https://github.com/pnpm/action-setup
synced 2026-11-07 13:07:57 +01:00
refactor: scope pm_on_fail override to the no-target-version branch
Only export `pnpm_config_pm_on_fail=download` when the action is relying on bootstrap pnpm's runtime switch. When the user passes an explicit `version:` input, self-update aligns the binary and we should not silently override their `devEngines.packageManager.onFail = "error"` policy.
This commit is contained in:
2 files changed
+7
-7
No files matched your search
Vendored
+1
-1
@@ -260,7 +260,7 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
||||
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
||||
`,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,r.start),i.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,i=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",s=[];if(i&&r.sep&&!r.value){let o=[];for(let a=0;a<r.sep.length;++a){let A=r.sep[a];switch(A.type){case"newline":o.push(a);break;case"space":break;case"comment":A.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(s=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||r.value?(s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):i||r.value?(s.push(this.sourceToken),e.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(NA(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(l9(r.key)&&!NA(r.sep,"newline")){let o=td(r.start),a=r.key,A=r.sep;A.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:A}]})}else s.length>0?r.sep=r.sep.concat(s,this.sourceToken):r.sep.push(this.sourceToken);else if(NA(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=td(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||i?e.items.push({start:s,key:null,sep:[this.sourceToken]}):NA(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);i||r.value?(e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){n&&o.type!=="block-seq"&&e.items.push({start:s}),this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,r.start),i.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||NA(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n&&n.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"singl
Line truncated
|
||||
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
||||
`,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=rB(e),n=td(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=rB(e),n=td(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};u9.Parser=g_});var m9=h(Rg=>{"use strict";var d9=r_(),fRe=Ig(),vg=bg(),hRe=eD(),gRe=qe(),mRe=h_(),f9=m_();function h9(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new mRe.LineCounter||null,prettyErrors:e}}function pRe(t,e={}){let{lineCounter:r,prettyErrors:n}=h9(e),i=new f9.Parser(r?.addNewLine),s=new d9.Composer(e),o=Array.from(s.compose(i.parse(t)));if(n&&r)for(let a of o)a.errors.forEach(vg.prettifyError(t,r)),a.warnings.forEach(vg.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function g9(t,e={}){let{lineCounter:r,prettyErrors:n}=h9(e),i=new f9.Parser(r?.addNewLine),s=new d9.Composer(e),o=null;for(let a of s.compose(i.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new vg.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(vg.prettifyError(t,r)),o.warnings.forEach(vg.prettifyError(t,r))),o}function yRe(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let i=g9(t,r);if(!i)return null;if(i.warnings.forEach(s=>hRe.warn(i.options.logLevel,s)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},r))}function ERe(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=r??e??{};if(!i)return}return gRe.isDocument(t)&&!n?t.toString(r):new fRe.Document(t,n,r).toString(r)}Rg.parse=yRe;Rg.parseAllDocuments=pRe;Rg.parseDocument=g9;Rg.stringify=ERe});var y_=h(et=>{"use strict";var CRe=r_(),IRe=Ig(),BRe=OD(),p_=bg(),QRe=ig(),ha=qe(),bRe=la(),NRe=er(),wRe=da(),xRe=fa(),SRe=eB(),vRe=d_(),RRe=h_(),DRe=m_(),nB=m9(),p9=eg();et.Composer=CRe.Composer;et.Document=IRe.Document;et.Schema=BRe.Schema;et.YAMLError=p_.YAMLError;et.YAMLParseError=p_.YAMLParseError;et.YAMLWarning=p_.YAMLWarning;et.Alias=QRe.Alias;et.isAlias=ha.isAlias;et.isCollection=ha.isCollection;et.isDocument=ha.isDocument;et.isMap=ha.isMap;et.isNode=ha.isNode;et.isPair=ha.isPair;et.isScalar=ha.isScalar;et.isSeq=ha.isSeq;et.Pair=bRe.Pair;et.Scalar=NRe.Scalar;et.YAMLMap=wRe.YAMLMap;et.YAMLSeq=xRe.YAMLSeq;et.CST=SRe;et.Lexer=vRe.Lexer;et.LineCounter=RRe.LineCounter;et.Parser=DRe.Parser;et.parse=nB.parse;et.parseAllDocuments=nB.parseAllDocuments;et.parseDocument=nB.parseDocument;et.stringify=nB.stringify;et.visit=p9.visit;et.visitAsync=p9.visitAsync});var hd=pt(ot());var g4=pt(ZC()),Gu=pt(ot());var l4=pt(ZC()),Ci=pt(ot()),u4=pt(rf()),d4=pt(c4()),f4=pt(require("os"));async function h4(t){let e=await WNe();(0,Ci.saveState)("cache_path",e);let r=await(0,d4.hashFiles)(t.cacheDependencyPath);if(!r)throw new Error("Some specified paths were not resolved, unable to cache dependencies.");let n=`pnpm-cache-${process.env.RUNNER_OS}-${f4.default.arch()}-${r}`;(0,Ci.debug)(`Primary key is ${n}`),(0,Ci.saveState)("cache_primary_key",n);let i=await(0,l4.restoreCache)([e],n);if((0,Ci.setOutput)("cache-hit",!!i),!i){(0,Ci.info)("Cache is not found");return}(0,Ci.saveState)("cache_restored_key",i),(0,Ci.info)(`Cache restored from key: ${i}`)}async function WNe(){let{stdout:t}=await(0,u4.getExecOutput)("pnpm store path --silent"),e=t.trim();return(0,Ci.debug)(`Cache folLine truncated
|
||||
`,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=rB(e),n=td(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=rB(e),n=td(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};u9.Parser=g_});var m9=h(Rg=>{"use strict";var d9=r_(),fRe=Ig(),vg=bg(),hRe=eD(),gRe=qe(),mRe=h_(),f9=m_();function h9(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new mRe.LineCounter||null,prettyErrors:e}}function pRe(t,e={}){let{lineCounter:r,prettyErrors:n}=h9(e),i=new f9.Parser(r?.addNewLine),s=new d9.Composer(e),o=Array.from(s.compose(i.parse(t)));if(n&&r)for(let a of o)a.errors.forEach(vg.prettifyError(t,r)),a.warnings.forEach(vg.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function g9(t,e={}){let{lineCounter:r,prettyErrors:n}=h9(e),i=new f9.Parser(r?.addNewLine),s=new d9.Composer(e),o=null;for(let a of s.compose(i.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new vg.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(vg.prettifyError(t,r)),o.warnings.forEach(vg.prettifyError(t,r))),o}function yRe(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let i=g9(t,r);if(!i)return null;if(i.warnings.forEach(s=>hRe.warn(i.options.logLevel,s)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},r))}function ERe(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=r??e??{};if(!i)return}return gRe.isDocument(t)&&!n?t.toString(r):new fRe.Document(t,n,r).toString(r)}Rg.parse=yRe;Rg.parseAllDocuments=pRe;Rg.parseDocument=g9;Rg.stringify=ERe});var y_=h(et=>{"use strict";var CRe=r_(),IRe=Ig(),BRe=OD(),p_=bg(),QRe=ig(),ha=qe(),bRe=la(),NRe=er(),wRe=da(),xRe=fa(),SRe=eB(),vRe=d_(),RRe=h_(),DRe=m_(),nB=m9(),p9=eg();et.Composer=CRe.Composer;et.Document=IRe.Document;et.Schema=BRe.Schema;et.YAMLError=p_.YAMLError;et.YAMLParseError=p_.YAMLParseError;et.YAMLWarning=p_.YAMLWarning;et.Alias=QRe.Alias;et.isAlias=ha.isAlias;et.isCollection=ha.isCollection;et.isDocument=ha.isDocument;et.isMap=ha.isMap;et.isNode=ha.isNode;et.isPair=ha.isPair;et.isScalar=ha.isScalar;et.isSeq=ha.isSeq;et.Pair=bRe.Pair;et.Scalar=NRe.Scalar;et.YAMLMap=wRe.YAMLMap;et.YAMLSeq=xRe.YAMLSeq;et.CST=SRe;et.Lexer=vRe.Lexer;et.LineCounter=RRe.LineCounter;et.Parser=DRe.Parser;et.parse=nB.parse;et.parseAllDocuments=nB.parseAllDocuments;et.parseDocument=nB.parseDocument;et.stringify=nB.stringify;et.visit=p9.visit;et.visitAsync=p9.visitAsync});var hd=pt(ot());var g4=pt(ZC()),Gu=pt(ot());var l4=pt(ZC()),Ci=pt(ot()),u4=pt(rf()),d4=pt(c4()),f4=pt(require("os"));async function h4(t){let e=await WNe();(0,Ci.saveState)("cache_path",e);let r=await(0,d4.hashFiles)(t.cacheDependencyPath);if(!r)throw new Error("Some specified paths were not resolved, unable to cache dependencies.");let n=`pnpm-cache-${process.env.RUNNER_OS}-${f4.default.arch()}-${r}`;(0,Ci.debug)(`Primary key is ${n}`),(0,Ci.saveState)("cache_primary_key",n);let i=await(0,l4.restoreCache)([e],n);if((0,Ci.setOutput)("cache-hit",!!i),!i){(0,Ci.info)("Cache is not found");return}(0,Ci.saveState)("cache_restored_key",i),(0,Ci.info)(`Cache restored from key: ${i}`)}async function WNe(){let{stdout:t}=await(0,u4.getExecOutput)("pnpm store path --silent"),e=t.trim();return(0,Ci.debug)(`Cache folLine truncated
|
||||
- version ${e} in the GitHub Action config with the key "version"
|
||||
- version ${i} in the package.json with the key "packageManager"
|
||||
Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION`);return e}if(!(typeof i=="string"&&i.startsWith("pnpm@"))&&!(s?.packageManager?.name==="pnpm"&&s.packageManager.version))throw n?new Error(`No pnpm version is specified.
|
||||
|
||||
@@ -67,11 +67,6 @@ export async function runSelfInstaller(inputs: Inputs): Promise<SelfInstallerRes
|
||||
addPath(pnpmHome)
|
||||
addPath(path.join(pnpmHome, 'bin'))
|
||||
exportVariable('PNPM_HOME', pnpmHome)
|
||||
// Force pnpm to honor manage-package-manager-versions even when the project
|
||||
// pins `devEngines.packageManager.onFail = "error"`. Without this override
|
||||
// the bootstrap pnpm errors with BAD_PM_VERSION instead of switching to the
|
||||
// requested version on the user's first invocation (issue #252).
|
||||
exportVariable('pnpm_config_pm_on_fail', 'download')
|
||||
|
||||
// Ensure pnpm bin link exists — npm ci sometimes doesn't create it
|
||||
if (process.platform !== 'win32') {
|
||||
@@ -107,7 +102,12 @@ export async function runSelfInstaller(inputs: Inputs): Promise<SelfInstallerRes
|
||||
}
|
||||
|
||||
// No explicit target version: rely on the bootstrap pnpm to switch to
|
||||
// the version declared in packageManager/devEngines at runtime.
|
||||
// the version declared in packageManager/devEngines at runtime. Force
|
||||
// `pmOnFail=download` so a project that pins
|
||||
// `devEngines.packageManager.onFail = "error"` doesn't trip BAD_PM_VERSION
|
||||
// before the switch can happen (issue #252). Scoped to this branch so users
|
||||
// who pass an explicit `version:` input keep strict onFail behavior.
|
||||
exportVariable('pnpm_config_pm_on_fail', 'download')
|
||||
return { exitCode: 0, binDest: pnpmHome }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user