vercel 60.1.1 → 61.0.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/dist/chunks/{add-D6D2J6ID.js → add-I5N2DAIP.js} +1 -1
- package/dist/chunks/{add-QBCRXMR3.js → add-KKZS2KRG.js} +1 -1
- package/dist/chunks/{add-JKIDAH7K.js → add-NLTAYU5Z.js} +1 -1
- package/dist/chunks/{build-PP4JOW2C.js → build-V6DQKDOO.js} +1 -1
- package/dist/chunks/chunk-23NBYS6R.js +36 -0
- package/dist/chunks/{chunk-C6QYMZ3S.js → chunk-2JRC4QJO.js} +1 -1
- package/dist/chunks/{chunk-H4IUDU5W.js → chunk-2VAKGA3F.js} +1 -1
- package/dist/chunks/{chunk-77WAICTF.js → chunk-2XUWYQ5P.js} +1 -1
- package/dist/chunks/{chunk-YMLWTVT5.js → chunk-4GA73K74.js} +1 -1
- package/dist/chunks/{chunk-3KQRJYBJ.js → chunk-4KJZA5JH.js} +1 -1
- package/dist/chunks/{chunk-LNOX5GIA.js → chunk-57DOAKMY.js} +1 -1
- package/dist/chunks/{chunk-CD4FLZED.js → chunk-5BQ25PMQ.js} +1 -1
- package/dist/chunks/{chunk-KOOED3TJ.js → chunk-6FHZ2IVO.js} +2 -2
- package/dist/chunks/{chunk-YG6LPJFT.js → chunk-7QVVD3WT.js} +1 -1
- package/dist/chunks/{chunk-2TBUMUHF.js → chunk-BFHLAM7O.js} +1 -1
- package/dist/chunks/{chunk-VVWALKUM.js → chunk-BN3XAVPG.js} +1 -1
- package/dist/chunks/{chunk-JMNAVONO.js → chunk-DT3EUC6S.js} +2 -2
- package/dist/chunks/{chunk-WUH5HYCX.js → chunk-EMDAZAWN.js} +1 -1
- package/dist/chunks/{chunk-KTB75ID3.js → chunk-FYRK4GX7.js} +1 -1
- package/dist/chunks/{chunk-ZWYU5SBC.js → chunk-GBWSLOL5.js} +1 -1
- package/dist/chunks/chunk-GIIG5KNF.js +7 -0
- package/dist/chunks/{chunk-SGU7YIY3.js → chunk-HQZXUIZY.js} +1 -1
- package/dist/chunks/chunk-IMN3Z3VV.js +9 -0
- package/dist/chunks/{chunk-STO2JRII.js → chunk-JS5WLQ6E.js} +1 -1
- package/dist/chunks/{chunk-7JAKGIQ6.js → chunk-KEVHEKQZ.js} +1 -1
- package/dist/chunks/{chunk-RB3NPNPD.js → chunk-KRQNSFGI.js} +1 -1
- package/dist/chunks/{chunk-M6UYGRPW.js → chunk-OEICO6OI.js} +1 -1
- package/dist/chunks/{chunk-IXN5A5WZ.js → chunk-OTP26MC7.js} +1 -1
- package/dist/chunks/{chunk-Q5VLP2LY.js → chunk-OVOQNHSJ.js} +1 -1
- package/dist/chunks/{chunk-G77TCKNI.js → chunk-P33CQ5CD.js} +1 -1
- package/dist/chunks/{chunk-TTMLSKF7.js → chunk-Q5CKKVCX.js} +1 -1
- package/dist/chunks/{chunk-LUVIR6F2.js → chunk-QFXHS36S.js} +1 -1
- package/dist/chunks/{chunk-URI72S7J.js → chunk-RAQCLWCR.js} +1 -1
- package/dist/chunks/{chunk-GK5C5TE5.js → chunk-RBJ4IMRF.js} +1 -1
- package/dist/chunks/{chunk-4OKKSZVX.js → chunk-ROQLVSZT.js} +1 -1
- package/dist/chunks/{chunk-3CQQXHDI.js → chunk-S3ZJ6ZBN.js} +1 -1
- package/dist/chunks/{chunk-GZBSABCA.js → chunk-SCNNUBUE.js} +1 -1
- package/dist/chunks/{chunk-7HT5KIFA.js → chunk-SIRSBEOT.js} +1 -1
- package/dist/chunks/{chunk-4S6WFNRF.js → chunk-SZJLH6TE.js} +2 -2
- package/dist/chunks/{chunk-MSLHCYBD.js → chunk-TB4CAJ7K.js} +2 -2
- package/dist/chunks/{chunk-6A6LV2S2.js → chunk-TDR4D3EL.js} +3 -3
- package/dist/chunks/{chunk-RLCFE3MK.js → chunk-TKNV5ONT.js} +3 -3
- package/dist/chunks/{chunk-H4FTGLWV.js → chunk-USSZAG2L.js} +1 -1
- package/dist/chunks/chunk-W26LLGQV.js +7 -0
- package/dist/chunks/{chunk-WH6M54KF.js → chunk-WOFE2X43.js} +3 -3
- package/dist/chunks/{chunk-HMB4MZOB.js → chunk-XF4GWZT2.js} +1 -1
- package/dist/chunks/{chunk-2ZIWDSUX.js → chunk-Y7TY3VO2.js} +3 -3
- package/dist/chunks/{chunk-CVKB54WW.js → chunk-YBXO6YRZ.js} +1 -1
- package/dist/chunks/{chunk-DPH3CQXE.js → chunk-YTUFUBDL.js} +7 -5
- package/dist/chunks/{clear-TQFWNYKK.js → clear-FP53TC7K.js} +1 -1
- package/dist/chunks/{compile-vercel-config-YY3CODZP.js → compile-vercel-config-EVBLB7VS.js} +1 -1
- package/dist/chunks/{config-4FCRR7C5.js → config-5Q37O5JW.js} +1 -1
- package/dist/chunks/{config-VZQLRHHA.js → config-L2HMQKZN.js} +1 -1
- package/dist/chunks/config-validator.mjs +1 -1
- package/dist/chunks/{delete-L45TA4WK.js → delete-F75LDVGB.js} +1 -1
- package/dist/chunks/{delete-MPLEIGYN.js → delete-UAJRL4OB.js} +1 -1
- package/dist/chunks/{detect-projects-3AFQ2AC5.js → detect-projects-325QE23N.js} +1 -1
- package/dist/chunks/{detect-services-7QL6RPKV.js → detect-services-XZEOFBIS.js} +1 -1
- package/dist/chunks/{disable-WY6N4R7I.js → disable-F22ULQBR.js} +1 -1
- package/dist/chunks/{discard-3VYFSUTH.js → discard-RTIHE562.js} +1 -1
- package/dist/chunks/{edit-FCPWK252.js → edit-A2YLMFJY.js} +1 -1
- package/dist/chunks/{edit-VOZ4IKZI.js → edit-OQYEMSTW.js} +1 -1
- package/dist/chunks/{enable-IJ7UEQ3G.js → enable-PQE7IYLJ.js} +1 -1
- package/dist/chunks/{export-L4D4GCJI.js → export-MXCHIXRP.js} +1 -1
- package/dist/chunks/{future-IGDV62BF.js → future-EJDVAUMH.js} +1 -1
- package/dist/chunks/{generate-cert-for-deploy-GSWBCLZX.js → generate-cert-for-deploy-CORREIMU.js} +1 -1
- package/dist/chunks/{image-ORGBK7MR.js → image-IWWMC6OL.js} +1 -1
- package/dist/chunks/{import-builders-N4XIYEW5.js → import-builders-ZBNF3EDI.js} +1 -1
- package/dist/chunks/{inspect-F4OENUQT.js → inspect-BRSK7FWE.js} +1 -1
- package/dist/chunks/{inspect-GTALMRKE.js → inspect-CQAFY6OA.js} +1 -1
- package/dist/chunks/{inspect-V6IX3MOJ.js → inspect-L6XPIN4I.js} +1 -1
- package/dist/chunks/{inspect-377IAEIY.js → inspect-PCDAOGYE.js} +1 -1
- package/dist/chunks/{inspect-2EMBEQHZ.js → inspect-QPEB2PYJ.js} +1 -1
- package/dist/chunks/{list-57XWFXDW.js → list-HBPNOZ36.js} +1 -1
- package/dist/chunks/{list-GKXJQRX6.js → list-MHFZCZLT.js} +1 -1
- package/dist/chunks/{list-5ZBTU324.js → list-UNOHMSYJ.js} +1 -1
- package/dist/chunks/{login-MQXAAFBP.js → login-4RTE52M4.js} +1 -1
- package/dist/chunks/{login-X3KPMMEP.js → login-GZEBYAAZ.js} +1 -1
- package/dist/chunks/{logs-ZYELN5F2.js → logs-OCIAVVYS.js} +1 -1
- package/dist/chunks/{ls-AAU7AKS7.js → ls-4IBSWNBN.js} +1 -1
- package/dist/chunks/{ls-LMHRMNKE.js → ls-CDMZQWTZ.js} +1 -1
- package/dist/chunks/{ls-POKSXYZU.js → ls-CR7MEDCH.js} +1 -1
- package/dist/chunks/{ls-ADATML6R.js → ls-GCIPXWXQ.js} +1 -1
- package/dist/chunks/{ls-VYEJT272.js → ls-KYR3NKYY.js} +1 -1
- package/dist/chunks/{ls-GD6LB7IE.js → ls-MZV54WLV.js} +1 -1
- package/dist/chunks/{ls-NX3EMRFH.js → ls-XI2PIZR4.js} +1 -1
- package/dist/chunks/{mutate-QMU5QHF3.js → mutate-KROV5RBJ.js} +1 -1
- package/dist/chunks/{notifications-OYUKYMU7.js → notifications-5CF5744G.js} +1 -1
- package/dist/chunks/{open-SNN3JPON.js → open-JSSJIIAC.js} +1 -1
- package/dist/chunks/{openapi-7JUPKBWV.js → openapi-SEMT6PBJ.js} +1 -1
- package/dist/chunks/{permissions-5LSKNTW7.js → permissions-OIMJWVL6.js} +1 -1
- package/dist/chunks/{prompt-missing-credentials-PPUSNDNC.js → prompt-missing-credentials-QCUYKCHH.js} +1 -1
- package/dist/chunks/{publish-FIHJARRJ.js → publish-LY3THAIP.js} +1 -1
- package/dist/chunks/{pull-2M2BJYAS.js → pull-CULSXHFY.js} +1 -1
- package/dist/chunks/{purchase-domain-if-available-VKWKDDUD.js → purchase-domain-if-available-FFNNBECE.js} +1 -1
- package/dist/chunks/{push-VN6BPT3B.js → push-YEQRRX7B.js} +1 -1
- package/dist/chunks/{query-P35ZTMXV.js → query-IRNHCI3O.js} +1 -1
- package/dist/chunks/{reauthenticate-DIFJZWC5.js → reauthenticate-7HYVS7DU.js} +1 -1
- package/dist/chunks/{reorder-L4L2V3MZ.js → reorder-DSBV4PC7.js} +1 -1
- package/dist/chunks/{reply-XIJ54B7U.js → reply-WEUR5QKT.js} +1 -1
- package/dist/chunks/{resolve-W2O6M4GH.js → resolve-KEPX7J5A.js} +1 -1
- package/dist/chunks/{resolve-deployment-framework-preset-XF3NJIDS.js → resolve-deployment-framework-preset-QEPJNWVF.js} +1 -1
- package/dist/chunks/{restore-OZPJHXTE.js → restore-YW2G6UVL.js} +1 -1
- package/dist/chunks/{rm-2YDLXDCB.js → rm-6TV3ABUA.js} +1 -1
- package/dist/chunks/{rm-OYSWVVSJ.js → rm-CYZTYWOW.js} +1 -1
- package/dist/chunks/{rm-HM7V26WX.js → rm-NUUHW6XI.js} +1 -1
- package/dist/chunks/{rm-4EUHQZ7U.js → rm-RJ7FOO54.js} +1 -1
- package/dist/chunks/{rm-IM7VAVCG.js → rm-TP5O3DFW.js} +1 -1
- package/dist/chunks/{rule-inspect-75RUPIVB.js → rule-inspect-OVUBNDW6.js} +1 -1
- package/dist/chunks/{rules-PKOTTFKG.js → rules-B2XF44SN.js} +1 -1
- package/dist/chunks/{schema-NJC47D5M.js → schema-5XTHUY2F.js} +1 -1
- package/dist/chunks/{schema-EPUGS3PX.js → schema-O7WKXTFS.js} +1 -1
- package/dist/chunks/{set-GESKJPQA.js → set-JQ5LDT2W.js} +1 -1
- package/dist/chunks/{setup-and-link-PM46H7GU.js → setup-and-link-NEEWO4NE.js} +1 -1
- package/dist/chunks/{tags-MBJR7IQW.js → tags-M6DJBEV4.js} +1 -1
- package/dist/chunks/{types-UYIFBCCL.js → types-F6SLL27E.js} +1 -1
- package/dist/chunks/{update-TNUYPCS3.js → update-YP44NRTW.js} +1 -1
- package/dist/chunks/vlt-builder-importer-W63QEXYX.js +11 -0
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/deploy/index.js +9 -9
- package/dist/commands/dev/index.js +5 -5
- package/dist/commands/env/index.js +1 -1
- package/dist/commands/link/index.js +1 -1
- package/dist/commands/list/index.js +1 -1
- package/dist/commands-bulk.js +41 -31
- package/dist/index.js +2 -2
- package/dist/version.mjs +1 -1
- package/package.json +59 -59
- package/dist/chunks/chunk-6PFC3KWQ.js +0 -7
- package/dist/chunks/chunk-KK4AJES5.js +0 -36
- package/dist/chunks/chunk-N5AIKGEO.js +0 -9
- package/dist/chunks/chunk-VHTNAYWA.js +0 -7
- package/dist/chunks/vlt-builder-importer-6DGKK72W.js +0 -11
|
@@ -4,5 +4,5 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import{printRuleMutationReceipt}from"./chunk-
|
|
7
|
+
import{printRuleMutationReceipt}from"./chunk-7QVVD3WT.js";import"./chunk-7PNYOSDU.js";import{emitRulesArgParseError,fetchRule,handleRulesApiError,outputRulesError,readRuleBody,resolveRulesProject,resolveRulesTeam,rulesItemPath}from"./chunk-KRQNSFGI.js";import"./chunk-RAQCLWCR.js";import"./chunk-W26LLGQV.js";import"./chunk-GZNDA6SV.js";import"./chunk-WRILLB46.js";import"./chunk-FA6O7FPC.js";import"./chunk-GHAY4PSD.js";import"./chunk-TDR4D3EL.js";import"./chunk-TRTEXGVN.js";import"./chunk-T3GQAMBJ.js";import"./chunk-MBL6TXEJ.js";import"./chunk-QTKJC2O5.js";import{validateJsonOutput}from"./chunk-D4MW3RDW.js";import"./chunk-P2O5DOYE.js";import"./chunk-EMDAZAWN.js";import{rulesUpdateSubcommand}from"./chunk-SW7MNF4H.js";import"./chunk-6TAQ6OWD.js";import"./chunk-WPS6JZF6.js";import"./chunk-ROQLVSZT.js";import"./chunk-JSKGZLE4.js";import"./chunk-RCTYVKM5.js";import"./chunk-GHM7V3GG.js";import"./chunk-5XJNPXQK.js";import{printError}from"./chunk-IMN3Z3VV.js";import{parseArguments}from"./chunk-WWB66KP5.js";import"./chunk-MY4MONOH.js";import"./chunk-TKNV5ONT.js";import"./chunk-F2ZWW2IO.js";import"./chunk-B4ATVYZW.js";import"./chunk-PPCFQQSU.js";import"./chunk-BRK4OB4B.js";import"./chunk-OSCCYU74.js";import"./chunk-KCARCOP5.js";import"./chunk-BKV35LVB.js";import{getFlagsSpecification}from"./chunk-JAJW3P42.js";import"./chunk-YMM3VY3J.js";import"./chunk-SM5JI6QM.js";import"./chunk-VOZEB6PD.js";import{isAPIError}from"./chunk-RINZXCDJ.js";import{packageName}from"./chunk-FI772UVH.js";import{output_manager_default}from"./chunk-EWWFNMPZ.js";import"./chunk-QGIQK47P.js";import"./chunk-AVSPFBLM.js";import"./chunk-XCJDGQO7.js";import"./chunk-YPTLSODC.js";import"./chunk-7HL2RPUO.js";import"./chunk-U7KCDTCH.js";import"./chunk-N3ZZ7FHQ.js";import"./chunk-GU6VIFR5.js";import"./chunk-6L236MNA.js";function sameScope(left,right){return JSON.stringify(left)===JSON.stringify(right)}function scopeForRule(client,type,scope,flags,jsonOutput){return flags["--project"]?type==="custom"?{type:"project",projectId:scope.projectId}:{type:"include",projectIds:[scope.projectId]}:type==="custom"?outputRulesError(client,jsonOutput,"INVALID_SCOPE","Custom alert rules must target one project. Use --project <name-or-id>."):{type:"all"}}async function resolveUpdateScope(client,flags,jsonOutput,ruleId){return flags["--project"]&&flags["--all"]?outputRulesError(client,jsonOutput,"MUTUAL_EXCLUSIVITY","Cannot specify both --all and --project. Use one or the other."):flags["--project"]?resolveRulesProject(client,flags["--project"],jsonOutput,`alerts rules update ${ruleId}`):resolveRulesTeam(client,jsonOutput)}function writeRuleResult(client,jsonOutput,action,rule){jsonOutput?client.stdout.write(`${JSON.stringify({rule},null,2)}
|
|
8
8
|
`):printRuleMutationReceipt(action,rule,client.argv)}async function update(client,argv){let parsedArgs;try{parsedArgs=parseArguments(argv,getFlagsSpecification(rulesUpdateSubcommand.options))}catch(error){return emitRulesArgParseError(client,error,"alerts rules update <rule-id> --project <name-or-id>"),printError(error),1}let flags=parsedArgs.flags,format=validateJsonOutput(flags);if(!format.valid)return outputRulesError(client,!1,"INVALID_ARGUMENTS",format.error);let ruleId=parsedArgs.args[0];if(!ruleId)return outputRulesError(client,format.jsonOutput,"MISSING_ARGUMENTS",`Missing rule ID. Example: ${packageName} alerts rules update <rule-id> --body <file>`);let hasScopeFlag=!!(flags["--project"]||flags["--all"]);if(!flags["--body"]&&!hasScopeFlag)return outputRulesError(client,format.jsonOutput,"MISSING_ARGUMENTS","Provide --body <PATH>, --project <name-or-id>, or --all.");let body=flags["--body"]?readRuleBody(client,flags["--body"],format.jsonOutput):{};if(typeof body=="number")return body;if(Object.hasOwn(body,"type")&&body.type!=="built-in"&&body.type!=="custom")return outputRulesError(client,format.jsonOutput,"INVALID_RULE_TYPE","When provided, update body type must be a supported rule type.");if(hasScopeFlag&&Object.hasOwn(body,"ruleScope"))return outputRulesError(client,format.jsonOutput,"SCOPE_CONFLICT","Specify rule scope either in the body or with --project/--all, not both.");let scope=await resolveUpdateScope(client,flags,format.jsonOutput,ruleId);if(typeof scope=="number")return scope;try{let existing;if(hasScopeFlag){output_manager_default.spinner("Fetching alert rule\u2026"),existing=await fetchRule(client,scope,ruleId);let desiredScope=scopeForRule(client,existing.type,scope,flags,format.jsonOutput);if(typeof desiredScope=="number")return desiredScope;if(!sameScope(existing.ruleScope,desiredScope))body.ruleScope=desiredScope;else if(Object.keys(body).length===0)return output_manager_default.stopSpinner(),writeRuleResult(client,format.jsonOutput,"Unchanged",existing),0}output_manager_default.spinner("Updating alert rule\u2026");let response=await client.fetch(rulesItemPath(scope.teamId,ruleId),{method:"PATCH",body});return writeRuleResult(client,format.jsonOutput,"Updated",response.rule),0}catch(error){if(isAPIError(error))return handleRulesApiError(client,error,format.jsonOutput);throw error}finally{output_manager_default.stopSpinner()}}export{update as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import{require_cli_config}from"./chunk-BRK4OB4B.js";import{__toESM}from"./chunk-6L236MNA.js";var import_cli_config=__toESM(require_cli_config(),1);import{createHash,randomBytes}from"node:crypto";import{link,lstat,mkdir,open,readFile,rename,rm,unlink,writeFile}from"node:fs/promises";import{join}from"node:path";import{install}from"@vltpkg/graph";import{PackageInfoClient}from"@vltpkg/package-info";import{PackageJson}from"@vltpkg/package-json";import{PathScurry}from"path-scurry";var LOCK_RETRY_MS=50,LOCK_WAIT_MS=5*60*1e3,LOCK_EMPTY_GRACE_MS=1e3,REMOVE_MAX_RETRIES=5,REMOVE_RETRY_DELAY_MS=100,activeInstallations=new Map;function compareKeys(a,b){return a<b?-1:a>b?1:0}function canonicalize(value){return Array.isArray(value)?value.map(canonicalize):value&&typeof value=="object"?Object.fromEntries(Object.entries(value).sort(([a],[b])=>compareKeys(a,b)).map(([key,child])=>[key,canonicalize(child)])):value}function validateGraph(graph){let{hash,...contents}=graph;if(createHash("sha256").update(JSON.stringify(canonicalize(contents))).digest("hex")!==hash)throw new Error(`The embedded vlt Builder graph for ${graph.name} is invalid.`)}async function wait(ms){await new Promise(resolve=>setTimeout(resolve,ms))}function hasErrorCode(error,code){return error instanceof Error&&"code"in error&&error.code===code}function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(error){return hasErrorCode(error,"EPERM")}}async function isLockHolderAlive(path){try{let pid=Number.parseInt((await readFile(path,"utf8")).trim(),10);return Number.isInteger(pid)&&pid>0&&isProcessAlive(pid)}catch{return!1}}async function tryStealStaleLock(path,emptyGraceMs){let first;try{first=await lstat(path)}catch{return!0}if(first.size===0&&Date.now()-first.mtimeMs<emptyGraceMs||await isLockHolderAlive(path))return!1;let second;try{second=await lstat(path)}catch{return!0}if(second.dev!==first.dev||second.ino!==first.ino||second.mtimeMs!==first.mtimeMs||second.size!==first.size)return!1;try{return await unlink(path),!0}catch{return!1}}async function acquireLock(path,{waitMs=LOCK_WAIT_MS,emptyGraceMs=LOCK_EMPTY_GRACE_MS}={}){await mkdir(join(path,".."),{recursive:!0});let startedAt=Date.now();for(;;){let tmp=`${path}.${process.pid}-${randomBytes(6).toString("hex")}`;await writeFile(tmp,`${process.pid}
|
|
8
|
+
`,{flag:"wx"});try{return await link(tmp,path),await unlink(tmp).catch(()=>{}),await open(path,"r")}catch(error){if(await unlink(tmp).catch(()=>{}),!hasErrorCode(error,"EEXIST"))throw error;if(await tryStealStaleLock(path,emptyGraceMs))continue;if(Date.now()-startedAt>waitMs)throw new Error(`Timed out waiting for vlt Builder lock "${path}".`);await wait(LOCK_RETRY_MS)}}}async function removeInstallation(path){await rm(path,{recursive:!0,force:!0,maxRetries:REMOVE_MAX_RETRIES,retryDelay:REMOVE_RETRY_DELAY_MS})}async function installationComplete(root,graph){try{return(await readFile(join(root,".vercel-builder-graph"),"utf8")).trim()===graph.hash}catch{return!1}}async function removePackageInfoCache(packageInfo,path){try{await(await packageInfo.getRegistryClient()).cache.promise()}catch{}await removeInstallation(path).catch(()=>{})}async function reifyGraph(root,graph,packageInfoFactory){let packageJson=new PackageJson,packageInfoCache=join(root,".vlt-package-info-cache"),packageInfo=packageInfoFactory({...graph.lockfile.options,projectRoot:root,packageJson,cache:packageInfoCache});try{await install({...graph.lockfile.options,projectRoot:root,packageJson,packageInfo,scurry:new PathScurry(root),allowScripts:":not(*)",frozenLockfile:!0,cleanInstall:!0})}finally{await removePackageInfoCache(packageInfo,packageInfoCache)}}async function ensureGraph(graph,cacheRoot,packageInfoFactory){validateGraph(graph);let root=join(cacheRoot,graph.hash),active=activeInstallations.get(root);if(active)return active;let installation=(async()=>{if(await installationComplete(root,graph))return root;let lockPath=join(cacheRoot,"locks",`${graph.hash}.lock`),lock=await acquireLock(lockPath),temporaryRoot;try{return await installationComplete(root,graph)||(await removeInstallation(root),temporaryRoot=process.platform==="win32"?root:join(cacheRoot,"tmp",`${graph.hash}-${process.pid}-${randomBytes(6).toString("hex")}`),await mkdir(temporaryRoot,{recursive:!0}),await writeFile(join(temporaryRoot,"package.json"),`${JSON.stringify(graph.manifest,null,2)}
|
|
9
|
+
`),await writeFile(join(temporaryRoot,"vlt-lock.json"),`${JSON.stringify(graph.lockfile,null,2)}
|
|
10
|
+
`),await reifyGraph(temporaryRoot,graph,packageInfoFactory),await writeFile(join(temporaryRoot,".vercel-builder-graph"),`${graph.hash}
|
|
11
|
+
`),temporaryRoot!==root&&(await mkdir(join(root,".."),{recursive:!0}),await rename(temporaryRoot,root)),temporaryRoot=void 0),root}finally{await lock.close(),await unlink(lockPath).catch(()=>{}),temporaryRoot&&await removeInstallation(temporaryRoot)}})();activeInstallations.set(root,installation);let clearInstallation=()=>{activeInstallations.get(root)===installation&&activeInstallations.delete(root)};return installation.then(clearInstallation,clearInstallation),installation}function createVltBuilderImporter({graphs,loadGraphs=async()=>graphs,require:require2,cacheRoot=join((0,import_cli_config.getCachePath)(),"builders-vlt"),packageInfoFactory=options=>new PackageInfoClient(options),debug=()=>{}}){return async function(specs){if(specs.size===0)return new Map;let loadedGraphs=await loadGraphs();if(loadedGraphs.schemaVersion!==1)throw new Error("The embedded vlt Builder graph index is invalid.");let builders=new Map;return await Promise.all([...specs].map(async([spec,name])=>{let graph=loadedGraphs.builders[name];if(!graph)throw new Error(`No pinned vlt graph exists for ${name}.`);let root=await ensureGraph(graph,cacheRoot,packageInfoFactory),pkgPath=require2.resolve(`${name}/package.json`,{paths:[root]}),pkg=JSON.parse(await readFile(pkgPath,"utf8"));if(pkg.name!==name||pkg.version!==graph.version)throw new Error(`The vlt Builder graph materialized ${String(pkg.name)}@${String(pkg.version)} instead of ${name}@${graph.version}.`);let path=require2.resolve(name,{paths:[root]});debug(`Resolved ${name}@${graph.version} with vlt from ${root}`),builders.set(spec,{path,pkgPath,pkg:{...pkg,name},builder:require2(path),dynamicallyInstalled:!0})})),builders}}export{acquireLock,createVltBuilderImporter,removePackageInfoCache};
|