mirror of
https://github.com/deployphp/action.git
synced 2025-06-29 12:44:14 +00:00
Update deps
This commit is contained in:
parent
eed58e3496
commit
363bb1be96
126 changed files with 5743 additions and 2737 deletions
81
node_modules/zx/build/goods.js
generated
vendored
81
node_modules/zx/build/goods.js
generated
vendored
|
@ -11,18 +11,21 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
import assert from 'node:assert';
|
||||
import * as globbyModule from 'globby';
|
||||
import minimist from 'minimist';
|
||||
import nodeFetch from 'node-fetch';
|
||||
import { createInterface } from 'node:readline';
|
||||
import { $, ProcessOutput } from './core.js';
|
||||
import { $, within, ProcessOutput } from './core.js';
|
||||
import { isString, parseDuration } from './util.js';
|
||||
import chalk from 'chalk';
|
||||
export { default as chalk } from 'chalk';
|
||||
export { default as fs } from 'fs-extra';
|
||||
export { default as which } from 'which';
|
||||
export { default as YAML } from 'yaml';
|
||||
export { default as path } from 'node:path';
|
||||
export { default as os } from 'node:os';
|
||||
export { ssh } from 'webpod';
|
||||
export let argv = minimist(process.argv.slice(2));
|
||||
export function updateArgv(args) {
|
||||
argv = minimist(args);
|
||||
|
@ -90,3 +93,79 @@ export async function stdin() {
|
|||
}
|
||||
return buf;
|
||||
}
|
||||
export async function retry(count, a, b) {
|
||||
const total = count;
|
||||
let callback;
|
||||
let delayStatic = 0;
|
||||
let delayGen;
|
||||
if (typeof a == 'function') {
|
||||
callback = a;
|
||||
}
|
||||
else {
|
||||
if (typeof a == 'object') {
|
||||
delayGen = a;
|
||||
}
|
||||
else {
|
||||
delayStatic = parseDuration(a);
|
||||
}
|
||||
assert(b);
|
||||
callback = b;
|
||||
}
|
||||
let lastErr;
|
||||
let attempt = 0;
|
||||
while (count-- > 0) {
|
||||
attempt++;
|
||||
try {
|
||||
return await callback();
|
||||
}
|
||||
catch (err) {
|
||||
let delay = 0;
|
||||
if (delayStatic > 0)
|
||||
delay = delayStatic;
|
||||
if (delayGen)
|
||||
delay = delayGen.next().value;
|
||||
$.log({
|
||||
kind: 'retry',
|
||||
error: chalk.bgRed.white(' FAIL ') +
|
||||
` Attempt: ${attempt}${total == Infinity ? '' : `/${total}`}` +
|
||||
(delay > 0 ? `; next in ${delay}ms` : ''),
|
||||
});
|
||||
lastErr = err;
|
||||
if (count == 0)
|
||||
break;
|
||||
if (delay)
|
||||
await sleep(delay);
|
||||
}
|
||||
}
|
||||
throw lastErr;
|
||||
}
|
||||
export function* expBackoff(max = '60s', rand = '100ms') {
|
||||
const maxMs = parseDuration(max);
|
||||
const randMs = parseDuration(rand);
|
||||
let n = 1;
|
||||
while (true) {
|
||||
const ms = Math.floor(Math.random() * randMs);
|
||||
yield Math.min(2 ** n++, maxMs) + ms;
|
||||
}
|
||||
}
|
||||
export async function spinner(title, callback) {
|
||||
if (typeof title == 'function') {
|
||||
callback = title;
|
||||
title = '';
|
||||
}
|
||||
let i = 0;
|
||||
const spin = () => process.stderr.write(` ${'⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'[i++ % 10]} ${title}\r`);
|
||||
return within(async () => {
|
||||
$.verbose = false;
|
||||
const id = setInterval(spin, 100);
|
||||
let result;
|
||||
try {
|
||||
result = await callback();
|
||||
}
|
||||
finally {
|
||||
clearInterval(id);
|
||||
process.stderr.write(' '.repeat(process.stdout.columns - 1) + '\r');
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue