Skip to content

Instantly share code, notes, and snippets.

@JanVoracek
Last active April 28, 2021 14:03
Show Gist options
  • Save JanVoracek/48a3fe7ac17e7ecc9b9ac545836ff85d to your computer and use it in GitHub Desktop.
Save JanVoracek/48a3fe7ac17e7ecc9b9ac545836ff85d to your computer and use it in GitHub Desktop.
/* eslint-disable */
module.exports = {
name: "@yarnpkg/plugin-entrypoint-lockfiles",
factory: function (require) {
var plugin;(()=>{var e={490:e=>{const t="win32"===process.platform,n=t?"\\\\+":"\\/",i=t?"\\\\":"/",o=`((?:[^${i}]*(?:${i}|$))*)`,r=`([^${i}]*)`;e.exports=function(e,{extended:t=!1,globstar:i=!1,strict:s=!1,filepath:l=!1,flags:a=""}={}){let c="",f="",p={regex:"",segments:[]},u=!1,g=!1;const d=[];function w(e,{split:t,last:i,only:o}={}){"path"!==o&&(c+=e),l&&"regex"!==o&&(p.regex+="\\/"===e?n:e,t?(i&&(f+=e),""!==f&&(a.includes("g")||(f=`^${f}$`),p.segments.push(new RegExp(f,a))),f=""):f+=e)}let y,x;for(let n=0;n<e.length;n++)if(y=e[n],x=e[n+1],["\\","$","^",".","="].includes(y))w("\\"+y);else if("/"!==y)if("("!==y)if(")"!==y)if("|"!==y)if("+"!==y)if("@"===y&&t&&"("===x)d.push(y);else if("!"!==y)if("?"!==y)if("["!==y)if("]"!==y)if("{"!==y)if("}"!==y)if(","!==y)if("*"!==y)w(y);else{if("("===x&&t){d.push(y);continue}let s=e[n-1],l=1;for(;"*"===e[n+1];)l++,n++;let a=e[n+1];if(i){l>1&&("/"===s||void 0===s)&&("/"===a||void 0===a)?(w("((?:[^/]*(?:/|$))*)",{only:"regex"}),w(o,{only:"path",last:!0,split:!0}),n++):(w("([^/]*)",{only:"regex"}),w(r,{only:"path"}))}else w(".*")}else{if(u){w("|");continue}w("\\"+y)}else{if(t){u=!1,w(")");continue}w("\\"+y)}else{if(t){u=!0,w("(");continue}w("\\"+y)}else{if(t){g=!1,w(y);continue}w("\\"+y)}else{if(g&&":"===x){n++;let t="";for(;":"!==e[++n];)t+=e[n];"alnum"===t?w("(\\w|\\d)"):"space"===t?w("\\s"):"digit"===t&&w("\\d"),n++;continue}if(t){g=!0,w(y);continue}w("\\"+y)}else{if(t){"("===x?d.push(y):w(".");continue}w("\\"+y)}else{if(t){if(g){w("^");continue}if("("===x){d.push(y),w("(?!"),n++;continue}w("\\"+y);continue}w("\\"+y)}else{if("("===x&&t){d.push(y);continue}w("\\"+y)}else{if(d.length){w(y);continue}w("\\"+y)}else{if(d.length){w(y);let e=d.pop();w("@"===e?"{1}":"!"===e?"([^/]*)":e);continue}w("\\"+y)}else{if(d.length){w(y);continue}w("\\"+y)}else w("\\"+y,{split:!0}),"/"!==x||s||(c+="?");a.includes("g")||(c=`^${c}$`,f=`^${f}$`,l&&(p.regex=`^${p.regex}$`));const h={regex:new RegExp(c,a)};return l&&(p.segments.push(new RegExp(f,a)),p.regex=new RegExp(p.regex,a),p.globstar=new RegExp(a.includes("g")?o:`^${o}$`,a),h.path=p),h}}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{default:()=>r});const e=require("@yarnpkg/core"),t=require("@yarnpkg/fslib");var o=n(490);const r={hooks:{afterAllInstalled:async(n,i)=>{await i.report.startTimerPromise("Entrypoint lockfiles",()=>async function(n,i,r){const s=await e.Cache.find(n,{immutable:!0}),l=await async function(e){var t;const n=e.workspacesByCwd.get(e.cwd),i=((null===(t=n.manifest.raw.workspaces)||void 0===t?void 0:t.entrypoints)||[]).map(e=>o(e,{globstar:!0,extended:!0}).regex);return e.workspaces.filter(e=>i.some(t=>t.test(e.relativeCwd)))}(i);await Promise.all(l.map(async o=>{const l=`yarn.${e.structUtils.slugifyIdent(o.locator)}.lock`,a=t.ppath.join(i.cwd,l),c=await async function(t,n,i){const{project:o,workspace:r}=await e.Project.find(t,n);return o.workspaces=[r],await o.resolveEverything({cache:i,report:new e.ThrowReport}),o.generateLockfile()}(n,o.cwd,s);await t.xfs.writeFilePromise(a,c),r.reportInfo(null,`${e.structUtils.stringifyIdent(o.locator)} => ${l}`)}))}(n.configuration,n,i.report))}}}})(),plugin=i})();
return plugin;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment