Next release of setup-bun

This commit is contained in:
Ashcon Partovi 2023-02-22 17:47:24 -08:00
parent ed9eb0969c
commit 9c14b74b45
1082 changed files with 242557 additions and 173810 deletions

View file

@ -36,10 +36,12 @@ function deserializeState(serializedState) {
}
}
function setStateError(inputs) {
const { state, stateProxy } = inputs;
const { state, stateProxy, isOperationError } = inputs;
return (error) => {
stateProxy.setError(state, error);
stateProxy.setFailed(state);
if (isOperationError(error)) {
stateProxy.setError(state, error);
stateProxy.setFailed(state);
}
throw error;
};
}
@ -94,10 +96,11 @@ async function initOperation(inputs) {
return state;
}
async function pollOperationHelper(inputs) {
const { poll, state, stateProxy, operationLocation, getOperationStatus, getResourceLocation, options, } = inputs;
const { poll, state, stateProxy, operationLocation, getOperationStatus, getResourceLocation, isOperationError, options, } = inputs;
const response = await poll(operationLocation, options).catch(setStateError({
state,
stateProxy,
isOperationError,
}));
const status = getOperationStatus(response, state);
logger.verbose(`LRO: Status:\n\tPolling from: ${state.config.operationLocation}\n\tOperation status: ${status}\n\tPolling status: ${terminalStates.includes(status) ? "Stopped" : "Running"}`);
@ -105,7 +108,7 @@ async function pollOperationHelper(inputs) {
const resourceLocation = getResourceLocation(response, state);
if (resourceLocation !== undefined) {
return {
response: await poll(resourceLocation).catch(setStateError({ state, stateProxy })),
response: await poll(resourceLocation).catch(setStateError({ state, stateProxy, isOperationError })),
status,
};
}
@ -114,7 +117,7 @@ async function pollOperationHelper(inputs) {
}
/** Polls the long-running operation. */
async function pollOperation(inputs) {
const { poll, state, stateProxy, options, getOperationStatus, getResourceLocation, getOperationLocation, withOperationLocation, getPollingInterval, processResult, updateState, setDelay, isDone, setErrorAsResult, } = inputs;
const { poll, state, stateProxy, options, getOperationStatus, getResourceLocation, getOperationLocation, isOperationError, withOperationLocation, getPollingInterval, processResult, updateState, setDelay, isDone, setErrorAsResult, } = inputs;
const { operationLocation } = state.config;
if (operationLocation !== undefined) {
const { response, status } = await pollOperationHelper({
@ -124,6 +127,7 @@ async function pollOperation(inputs) {
stateProxy,
operationLocation,
getResourceLocation,
isOperationError,
options,
});
processOperationStatus({
@ -380,6 +384,9 @@ function getResourceLocation({ flatResponse }, state) {
}
return state.config.resourceLocation;
}
function isOperationError(e) {
return e.name === "RestError";
}
/** Polls the long-running operation. */
async function pollHttpOperation(inputs) {
const { lro, stateProxy, options, processResult, updateState, setDelay, state, setErrorAsResult, } = inputs;
@ -394,6 +401,7 @@ async function pollHttpOperation(inputs) {
getPollingInterval: parseRetryAfter,
getOperationLocation,
getOperationStatus,
isOperationError,
getResourceLocation,
options,
/**
@ -482,7 +490,7 @@ const createStateProxy$1 = () => ({
* Returns a poller factory.
*/
function buildCreatePoller(inputs) {
const { getOperationLocation, getStatusFromInitialResponse, getStatusFromPollResponse, getResourceLocation, getPollingInterval, resolveOnUnsuccessful, } = inputs;
const { getOperationLocation, getStatusFromInitialResponse, getStatusFromPollResponse, isOperationError, getResourceLocation, getPollingInterval, resolveOnUnsuccessful, } = inputs;
return async ({ init, poll }, options) => {
const { processResult, updateState, withOperationLocation: withOperationLocationCallback, intervalInMs = POLL_INTERVAL_IN_MS, restoreFrom, } = options || {};
const stateProxy = createStateProxy$1();
@ -513,6 +521,7 @@ function buildCreatePoller(inputs) {
const abortController$1 = new abortController.AbortController();
const handlers = new Map();
const handleProgressEvents = async () => handlers.forEach((h) => h(state));
const cancelErrMsg = "Operation was canceled";
let currentPollIntervalInMs = intervalInMs;
const poller = {
getOperationState: () => state,
@ -545,35 +554,46 @@ function buildCreatePoller(inputs) {
await poller.poll({ abortSignal });
}
}
switch (state.status) {
case "succeeded": {
return poller.getResult();
}
case "canceled": {
if (!resolveOnUnsuccessful)
throw new Error("Operation was canceled");
return poller.getResult();
}
case "failed": {
if (!resolveOnUnsuccessful)
if (resolveOnUnsuccessful) {
return poller.getResult();
}
else {
switch (state.status) {
case "succeeded":
return poller.getResult();
case "canceled":
throw new Error(cancelErrMsg);
case "failed":
throw state.error;
return poller.getResult();
}
case "notStarted":
case "running": {
// Unreachable
throw new Error(`polling completed without succeeding or failing`);
case "notStarted":
case "running":
throw new Error(`Polling completed without succeeding or failing`);
}
}
})().finally(() => {
resultPromise = undefined;
}))),
async poll(pollOptions) {
if (resolveOnUnsuccessful) {
if (poller.isDone())
return;
}
else {
switch (state.status) {
case "succeeded":
return;
case "canceled":
throw new Error(cancelErrMsg);
case "failed":
throw state.error;
}
}
await pollOperation({
poll,
state,
stateProxy,
getOperationLocation,
isOperationError,
withOperationLocation,
getPollingInterval,
getOperationStatus: getStatusFromPollResponse,
@ -587,11 +607,13 @@ function buildCreatePoller(inputs) {
setErrorAsResult: !resolveOnUnsuccessful,
});
await handleProgressEvents();
if (state.status === "canceled" && !resolveOnUnsuccessful) {
throw new Error("Operation was canceled");
}
if (state.status === "failed" && !resolveOnUnsuccessful) {
throw state.error;
if (!resolveOnUnsuccessful) {
switch (state.status) {
case "canceled":
throw new Error(cancelErrMsg);
case "failed":
throw state.error;
}
}
},
};
@ -611,6 +633,7 @@ async function createHttpPoller(lro, options) {
return buildCreatePoller({
getStatusFromInitialResponse,
getStatusFromPollResponse: getOperationStatus,
isOperationError,
getOperationLocation,
getResourceLocation,
getPollingInterval: parseRetryAfter,