mirror of
https://github.com/deployphp/action.git
synced 2025-04-19 10:36:47 +00:00
Update deps
This commit is contained in:
parent
eed58e3496
commit
363bb1be96
126 changed files with 5743 additions and 2737 deletions
145
node_modules/zx/README.md
generated
vendored
145
node_modules/zx/README.md
generated
vendored
|
@ -35,10 +35,13 @@ npm i -g zx
|
|||
|
||||
## Goods
|
||||
|
||||
[$](#command-) · [cd()](#cd) · [fetch()](#fetch) · [question()](#question) · [sleep()](#sleep) · [echo()](#echo) · [stdin()](#stdin) · [within()](#within) ·
|
||||
[$](#command-) · [cd()](#cd) · [fetch()](#fetch) · [question()](#question) · [sleep()](#sleep) · [echo()](#echo) · [stdin()](#stdin) · [within()](#within) · [retry()](#retry) · [spinner()](#spinner) ·
|
||||
[chalk](#chalk-package) · [fs](#fs-package) · [os](#os-package) · [path](#path-package) · [glob](#globby-package) · [yaml](#yaml-package) · [minimist](#minimist-package) · [which](#which-package) ·
|
||||
[__filename](#__filename--__dirname) · [__dirname](#__filename--__dirname) · [require()](#require)
|
||||
|
||||
For running commands on remote hosts,
|
||||
see [webpod](https://github.com/webpod/webpod).
|
||||
|
||||
## Documentation
|
||||
|
||||
Write your scripts in a file with an `.mjs` extension in order to
|
||||
|
@ -46,11 +49,13 @@ use `await` at the top level. If you prefer the `.js` extension,
|
|||
wrap your scripts in something like `void async function () {...}()`.
|
||||
|
||||
Add the following shebang to the beginning of your `zx` scripts:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env zx
|
||||
```
|
||||
|
||||
Now you will be able to run your script like so:
|
||||
|
||||
```bash
|
||||
chmod +x ./script.mjs
|
||||
./script.mjs
|
||||
|
@ -117,9 +122,13 @@ class ProcessPromise extends Promise<ProcessOutput> {
|
|||
stdout: Readable
|
||||
stderr: Readable
|
||||
exitCode: Promise<number>
|
||||
|
||||
pipe(dest): ProcessPromise
|
||||
|
||||
kill(): Promise<void>
|
||||
|
||||
nothrow(): this
|
||||
|
||||
quiet(): this
|
||||
}
|
||||
```
|
||||
|
@ -134,11 +143,13 @@ class ProcessOutput {
|
|||
readonly stderr: string
|
||||
readonly signal: string
|
||||
readonly exitCode: number
|
||||
|
||||
toString(): string // Combined stdout & stderr.
|
||||
}
|
||||
```
|
||||
|
||||
The output of the process is captured as-is. Usually, programs print a new line `\n` at the end.
|
||||
The output of the process is captured as-is. Usually, programs print a new
|
||||
line `\n` at the end.
|
||||
If `ProcessOutput` is used as an argument to some other `$` process,
|
||||
**zx** will use stdout and trim the new line.
|
||||
|
||||
|
@ -160,7 +171,8 @@ await $`pwd` // => /tmp
|
|||
|
||||
### `fetch()`
|
||||
|
||||
A wrapper around the [node-fetch](https://www.npmjs.com/package/node-fetch) package.
|
||||
A wrapper around the [node-fetch](https://www.npmjs.com/package/node-fetch)
|
||||
package.
|
||||
|
||||
```js
|
||||
let resp = await fetch('https://medv.io')
|
||||
|
@ -228,6 +240,32 @@ let version = await within(async () => {
|
|||
})
|
||||
```
|
||||
|
||||
### `retry()`
|
||||
|
||||
Retries a callback for a few times. Will return after the first
|
||||
successful attempt, or will throw after specifies attempts count.
|
||||
|
||||
```js
|
||||
let p = await retry(10, () => $`curl https://medv.io`)
|
||||
|
||||
// With a specified delay between attempts.
|
||||
let p = await retry(20, '1s', () => $`curl https://medv.io`)
|
||||
|
||||
// With an exponential backoff.
|
||||
let p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
|
||||
```
|
||||
|
||||
### `spinner()`
|
||||
|
||||
Starts a simple CLI spinner.
|
||||
|
||||
```js
|
||||
await spinner(() => $`long-running command`)
|
||||
|
||||
// With a message.
|
||||
await spinner('working...', () => $`sleep 99`)
|
||||
```
|
||||
|
||||
## Packages
|
||||
|
||||
The following packages are available without importing inside scripts.
|
||||
|
@ -286,7 +324,9 @@ The [minimist](https://www.npmjs.com/package/minimist) package available
|
|||
as global const `argv`.
|
||||
|
||||
```js
|
||||
if( argv.someFlag ){ echo('yes') }
|
||||
if (argv.someFlag) {
|
||||
echo('yes')
|
||||
}
|
||||
```
|
||||
|
||||
### `which` package
|
||||
|
@ -372,7 +412,8 @@ $.log = (entry: LogEntry) => {
|
|||
### `__filename` & `__dirname`
|
||||
|
||||
In [ESM](https://nodejs.org/api/esm.html) modules, Node.js does not provide
|
||||
`__filename` and `__dirname` globals. As such globals are really handy in scripts,
|
||||
`__filename` and `__dirname` globals. As such globals are really handy in
|
||||
scripts,
|
||||
`zx` provides these for use in `.mjs` files (when using the `zx` executable).
|
||||
|
||||
### `require()`
|
||||
|
@ -386,42 +427,6 @@ files (when using `zx` executable).
|
|||
let {version} = require('./package.json')
|
||||
```
|
||||
|
||||
## Experimental
|
||||
|
||||
The zx provides a few experimental functions. Please leave feedback about
|
||||
those features in [the discussion](https://github.com/google/zx/discussions/299).
|
||||
To enable new features via CLI pass `--experimental` flag.
|
||||
|
||||
### `retry()`
|
||||
|
||||
Retries a callback for a few times. Will return after the first
|
||||
successful attempt, or will throw after specifies attempts count.
|
||||
|
||||
```js
|
||||
import { retry, expBackoff } from 'zx/experimental'
|
||||
|
||||
let p = await retry(10, () => $`curl https://medv.io`)
|
||||
|
||||
// With a specified delay between attempts.
|
||||
let p = await retry(20, '1s', () => $`curl https://medv.io`)
|
||||
|
||||
// With an exponential backoff.
|
||||
let p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
|
||||
```
|
||||
|
||||
### `spinner()`
|
||||
|
||||
Starts a simple CLI spinner.
|
||||
|
||||
```js
|
||||
import { spinner } from 'zx/experimental'
|
||||
|
||||
await spinner(() => $`long-running command`)
|
||||
|
||||
// With a message.
|
||||
await spinner('working...', () => $`sleep 99`)
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### Passing env variables
|
||||
|
@ -433,10 +438,12 @@ await $`echo $FOO`
|
|||
|
||||
### Passing array of values
|
||||
|
||||
When passing an array of values as an argument to `$`, items of the array will be escaped
|
||||
When passing an array of values as an argument to `$`, items of the array will
|
||||
be escaped
|
||||
individually and concatenated via space.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
let files = [...]
|
||||
await $`tar cz ${files}`
|
||||
|
@ -448,14 +455,16 @@ It is possible to make use of `$` and other functions via explicit imports:
|
|||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
import {$} from 'zx'
|
||||
import { $ } from 'zx'
|
||||
|
||||
await $`date`
|
||||
```
|
||||
|
||||
### Scripts without extensions
|
||||
|
||||
If script does not have a file extension (like `.git/hooks/pre-commit`), zx
|
||||
assumes that it is an [ESM](https://nodejs.org/api/modules.html#modules_module_createrequire_filename)
|
||||
assumes that it is
|
||||
an [ESM](https://nodejs.org/api/modules.html#modules_module_createrequire_filename)
|
||||
module.
|
||||
|
||||
### Markdown scripts
|
||||
|
@ -469,7 +478,7 @@ zx docs/markdown.md
|
|||
### TypeScript scripts
|
||||
|
||||
```ts
|
||||
import {$} from 'zx'
|
||||
import { $ } from 'zx'
|
||||
// Or
|
||||
import 'zx/globals'
|
||||
|
||||
|
@ -479,7 +488,8 @@ void async function () {
|
|||
```
|
||||
|
||||
Set [`"type": "module"`](https://nodejs.org/api/packages.html#packages_type)
|
||||
in **package.json** and [`"module": "ESNext"`](https://www.typescriptlang.org/tsconfig/#module)
|
||||
in **package.json**
|
||||
and [`"module": "ESNext"`](https://www.typescriptlang.org/tsconfig/#module)
|
||||
in **tsconfig.json**.
|
||||
|
||||
### Executing remote scripts
|
||||
|
@ -496,7 +506,7 @@ zx https://medv.io/game-of-life.js
|
|||
The `zx` supports executing scripts from stdin.
|
||||
|
||||
```js
|
||||
zx <<'EOF'
|
||||
zx << 'EOF'
|
||||
await $`pwd`
|
||||
EOF
|
||||
```
|
||||
|
@ -514,27 +524,41 @@ cat package.json | zx --eval 'let v = JSON.parse(await stdin()).version; echo(v)
|
|||
```js
|
||||
// script.mjs:
|
||||
import sh from 'tinysh'
|
||||
|
||||
sh.say('Hello, world!')
|
||||
```
|
||||
|
||||
Add `--install` flag to the `zx` command to install missing dependencies
|
||||
Add `--install` flag to the `zx` command to install missing dependencies
|
||||
automatically.
|
||||
|
||||
```bash
|
||||
zx --install script.mjs
|
||||
```
|
||||
|
||||
You can also specify needed version by adding comment with `@` after
|
||||
You can also specify needed version by adding comment with `@` after
|
||||
the import.
|
||||
|
||||
```js
|
||||
import sh from 'tinysh' // @^1
|
||||
```
|
||||
|
||||
### Executing commands on remote hosts
|
||||
|
||||
The `zx` uses [webpod](https://github.com/webpod/webpod) to execute commands on
|
||||
remote hosts.
|
||||
|
||||
```js
|
||||
import { ssh } from 'zx'
|
||||
|
||||
await ssh('user@host')`echo Hello, world!`
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Attaching a profile
|
||||
|
||||
By default `child_process` does not include aliases and bash functions.
|
||||
But you are still able to do it by hand. Just attach necessary directives
|
||||
But you are still able to do it by hand. Just attach necessary directives
|
||||
to the `$.prefix`.
|
||||
|
||||
```js
|
||||
|
@ -551,19 +575,22 @@ jobs:
|
|||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
run: |
|
||||
npx zx <<'EOF'
|
||||
await $`...`
|
||||
EOF
|
||||
- name: Build
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
run: |
|
||||
npx zx <<'EOF'
|
||||
await $`...`
|
||||
EOF
|
||||
```
|
||||
|
||||
### Canary / Beta / RC builds
|
||||
Impatient early adopters can try the experimental zx versions. But keep in mind: these builds are ⚠️️ __unstable__ in every sense.
|
||||
|
||||
Impatient early adopters can try the experimental zx versions.
|
||||
But keep in mind: these builds are ⚠️️__beta__ in every sense.
|
||||
|
||||
```bash
|
||||
npm i zx@dev
|
||||
npx zx@dev --install --quiet <<< 'import _ from "lodash" /* 4.17.15 */; console.log(_.VERSION)'
|
||||
|
|
19
node_modules/zx/build/cli.js
generated
vendored
19
node_modules/zx/build/cli.js
generated
vendored
|
@ -167,7 +167,11 @@ function transformMarkdown(buf) {
|
|||
const source = buf.toString();
|
||||
const output = [];
|
||||
let state = 'root';
|
||||
let codeBlockEnd = '';
|
||||
let prevLineIsEmpty = true;
|
||||
const jsCodeBlock = /^(```+|~~~+)(js|javascript)$/;
|
||||
const shCodeBlock = /^(```+|~~~+)(sh|bash)$/;
|
||||
const otherCodeBlock = /^(```+|~~~+)(.*)$/;
|
||||
for (let line of source.split('\n')) {
|
||||
switch (state) {
|
||||
case 'root':
|
||||
|
@ -175,17 +179,20 @@ function transformMarkdown(buf) {
|
|||
output.push(line);
|
||||
state = 'tab';
|
||||
}
|
||||
else if (/^```(js|javascript)$/.test(line)) {
|
||||
else if (jsCodeBlock.test(line)) {
|
||||
output.push('');
|
||||
state = 'js';
|
||||
codeBlockEnd = line.match(jsCodeBlock)[1];
|
||||
}
|
||||
else if (/^```(sh|bash)$/.test(line)) {
|
||||
else if (shCodeBlock.test(line)) {
|
||||
output.push('await $`');
|
||||
state = 'bash';
|
||||
codeBlockEnd = line.match(shCodeBlock)[1];
|
||||
}
|
||||
else if (/^```.*$/.test(line)) {
|
||||
else if (otherCodeBlock.test(line)) {
|
||||
output.push('');
|
||||
state = 'other';
|
||||
codeBlockEnd = line.match(otherCodeBlock)[1];
|
||||
}
|
||||
else {
|
||||
prevLineIsEmpty = line === '';
|
||||
|
@ -205,7 +212,7 @@ function transformMarkdown(buf) {
|
|||
}
|
||||
break;
|
||||
case 'js':
|
||||
if (/^```$/.test(line)) {
|
||||
if (line === codeBlockEnd) {
|
||||
output.push('');
|
||||
state = 'root';
|
||||
}
|
||||
|
@ -214,7 +221,7 @@ function transformMarkdown(buf) {
|
|||
}
|
||||
break;
|
||||
case 'bash':
|
||||
if (/^```$/.test(line)) {
|
||||
if (line === codeBlockEnd) {
|
||||
output.push('`');
|
||||
state = 'root';
|
||||
}
|
||||
|
@ -223,7 +230,7 @@ function transformMarkdown(buf) {
|
|||
}
|
||||
break;
|
||||
case 'other':
|
||||
if (/^```$/.test(line)) {
|
||||
if (line === codeBlockEnd) {
|
||||
output.push('');
|
||||
state = 'root';
|
||||
}
|
||||
|
|
10
node_modules/zx/build/core.d.ts
generated
vendored
10
node_modules/zx/build/core.d.ts
generated
vendored
|
@ -8,9 +8,9 @@ import { Readable, Writable } from 'node:stream';
|
|||
import { inspect } from 'node:util';
|
||||
import { RequestInfo, RequestInit } from 'node-fetch';
|
||||
import { Duration, noop, quote } from './util.js';
|
||||
export declare type Shell = (pieces: TemplateStringsArray, ...args: any[]) => ProcessPromise;
|
||||
export type Shell = (pieces: TemplateStringsArray, ...args: any[]) => ProcessPromise;
|
||||
declare const processCwd: unique symbol;
|
||||
export declare type Options = {
|
||||
export type Options = {
|
||||
[processCwd]: string;
|
||||
cwd?: string;
|
||||
verbose: boolean;
|
||||
|
@ -23,8 +23,8 @@ export declare type Options = {
|
|||
};
|
||||
export declare const defaults: Options;
|
||||
export declare const $: Shell & Options;
|
||||
declare type Resolve = (out: ProcessOutput) => void;
|
||||
declare type IO = StdioPipe | StdioNull;
|
||||
type Resolve = (out: ProcessOutput) => void;
|
||||
type IO = StdioPipe | StdioNull;
|
||||
export declare class ProcessPromise extends Promise<ProcessOutput> {
|
||||
child?: ChildProcess;
|
||||
private _command;
|
||||
|
@ -75,7 +75,7 @@ export declare class ProcessOutput extends Error {
|
|||
}
|
||||
export declare function within<R>(callback: () => R): R;
|
||||
export declare function cd(dir: string): void;
|
||||
export declare type LogEntry = {
|
||||
export type LogEntry = {
|
||||
kind: 'cmd';
|
||||
verbose: boolean;
|
||||
cmd: string;
|
||||
|
|
7
node_modules/zx/build/experimental.d.ts
generated
vendored
7
node_modules/zx/build/experimental.d.ts
generated
vendored
|
@ -1,6 +1 @@
|
|||
import { Duration } from './util.js';
|
||||
export declare function retry<T>(count: number, callback: () => T): Promise<T>;
|
||||
export declare function retry<T>(count: number, duration: Duration | Generator<number>, callback: () => T): Promise<T>;
|
||||
export declare function expBackoff(max?: Duration, rand?: Duration): Generator<number, void, unknown>;
|
||||
export declare function spinner<T>(callback: () => T): Promise<T>;
|
||||
export declare function spinner<T>(title: string, callback: () => T): Promise<T>;
|
||||
export { spinner, retry, expBackoff, echo } from './goods.js';
|
||||
|
|
83
node_modules/zx/build/experimental.js
generated
vendored
83
node_modules/zx/build/experimental.js
generated
vendored
|
@ -11,84 +11,5 @@
|
|||
// 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 chalk from 'chalk';
|
||||
import { $, within } from './core.js';
|
||||
import { sleep } from './goods.js';
|
||||
import { parseDuration } from './util.js';
|
||||
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;
|
||||
});
|
||||
}
|
||||
// TODO(antonmedv): Remove this export in next v8 release.
|
||||
export { spinner, retry, expBackoff, echo } from './goods.js';
|
||||
|
|
4
node_modules/zx/build/globals.d.ts
generated
vendored
4
node_modules/zx/build/globals.d.ts
generated
vendored
|
@ -13,6 +13,7 @@ declare global {
|
|||
var cd: typeof _.cd;
|
||||
var chalk: typeof _.chalk;
|
||||
var echo: typeof _.echo;
|
||||
var expBackoff: typeof _.expBackoff;
|
||||
var fs: typeof _.fs;
|
||||
var glob: typeof _.glob;
|
||||
var globby: typeof _.globby;
|
||||
|
@ -23,7 +24,10 @@ declare global {
|
|||
var quiet: typeof _.quiet;
|
||||
var quote: typeof _.quote;
|
||||
var quotePowerShell: typeof _.quotePowerShell;
|
||||
var retry: typeof _.retry;
|
||||
var sleep: typeof _.sleep;
|
||||
var spinner: typeof _.spinner;
|
||||
var ssh: typeof _.ssh;
|
||||
var stdin: typeof _.stdin;
|
||||
var which: typeof _.which;
|
||||
var within: typeof _.within;
|
||||
|
|
6
node_modules/zx/build/goods.d.ts
generated
vendored
6
node_modules/zx/build/goods.d.ts
generated
vendored
|
@ -8,6 +8,7 @@ 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 declare let argv: minimist.ParsedArgs;
|
||||
export declare function updateArgv(args: string[]): void;
|
||||
export declare const globby: ((patterns: string | readonly string[], options?: globbyModule.Options) => Promise<string[]>) & typeof globbyModule;
|
||||
|
@ -19,3 +20,8 @@ export declare function question(query?: string, options?: {
|
|||
choices: string[];
|
||||
}): Promise<string>;
|
||||
export declare function stdin(): Promise<string>;
|
||||
export declare function retry<T>(count: number, callback: () => T): Promise<T>;
|
||||
export declare function retry<T>(count: number, duration: Duration | Generator<number>, callback: () => T): Promise<T>;
|
||||
export declare function expBackoff(max?: Duration, rand?: Duration): Generator<number, void, unknown>;
|
||||
export declare function spinner<T>(callback: () => T): Promise<T>;
|
||||
export declare function spinner<T>(title: string, callback: () => T): Promise<T>;
|
||||
|
|
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;
|
||||
});
|
||||
}
|
||||
|
|
4
node_modules/zx/build/index.d.ts
generated
vendored
4
node_modules/zx/build/index.d.ts
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
import { ProcessPromise } from './core.js';
|
||||
export { $, Shell, Options, ProcessPromise, ProcessOutput, within, cd, log, LogEntry, } from './core.js';
|
||||
export { argv, chalk, echo, fetch, fs, glob, globby, os, path, question, sleep, stdin, which, YAML, } from './goods.js';
|
||||
export * from './core.js';
|
||||
export * from './goods.js';
|
||||
export { Duration, quote, quotePowerShell } from './util.js';
|
||||
/**
|
||||
* @deprecated Use $.nothrow() instead.
|
||||
|
|
4
node_modules/zx/build/index.js
generated
vendored
4
node_modules/zx/build/index.js
generated
vendored
|
@ -11,8 +11,8 @@
|
|||
// 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.
|
||||
export { $, ProcessPromise, ProcessOutput, within, cd, log, } from './core.js';
|
||||
export { argv, chalk, echo, fetch, fs, glob, globby, os, path, question, sleep, stdin, which, YAML, } from './goods.js';
|
||||
export * from './core.js';
|
||||
export * from './goods.js';
|
||||
export { quote, quotePowerShell } from './util.js';
|
||||
/**
|
||||
* @deprecated Use $.nothrow() instead.
|
||||
|
|
2
node_modules/zx/build/util.d.ts
generated
vendored
2
node_modules/zx/build/util.d.ts
generated
vendored
|
@ -7,6 +7,6 @@ export declare function quote(arg: string): string;
|
|||
export declare function quotePowerShell(arg: string): string;
|
||||
export declare function exitCodeInfo(exitCode: number | null): string | undefined;
|
||||
export declare function errnoMessage(errno: number | undefined): string;
|
||||
export declare type Duration = number | `${number}s` | `${number}ms`;
|
||||
export type Duration = number | `${number}s` | `${number}ms`;
|
||||
export declare function parseDuration(d: Duration): number;
|
||||
export declare function formatCmd(cmd?: string): string;
|
||||
|
|
33
node_modules/zx/package.json
generated
vendored
33
node_modules/zx/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "zx",
|
||||
"version": "7.1.1",
|
||||
"version": "7.2.1",
|
||||
"description": "A tool for writing better scripts.",
|
||||
"type": "module",
|
||||
"main": "./build/index.js",
|
||||
|
@ -50,27 +50,28 @@
|
|||
"circular": "madge --circular src/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/fs-extra": "^11.0.1",
|
||||
"@types/minimist": "^1.2.2",
|
||||
"@types/node": "^18.7.20",
|
||||
"@types/node": "^18.14.2",
|
||||
"@types/ps-tree": "^1.1.2",
|
||||
"@types/which": "^2.0.1",
|
||||
"chalk": "^5.0.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"globby": "^13.1.2",
|
||||
"minimist": "^1.2.6",
|
||||
"@types/which": "^2.0.2",
|
||||
"chalk": "^5.2.0",
|
||||
"fs-extra": "^11.1.0",
|
||||
"globby": "^13.1.3",
|
||||
"minimist": "^1.2.8",
|
||||
"node-fetch": "3.2.10",
|
||||
"ps-tree": "^1.2.0",
|
||||
"which": "^2.0.2",
|
||||
"yaml": "^2.1.1"
|
||||
"webpod": "^0",
|
||||
"which": "^3.0.0",
|
||||
"yaml": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stryker-mutator/core": "^6.2.2",
|
||||
"c8": "^7.12.0",
|
||||
"madge": "^5.0.1",
|
||||
"prettier": "^2.7.1",
|
||||
"tsd": "^0.24.1",
|
||||
"typescript": "^4.8.3",
|
||||
"@stryker-mutator/core": "^6.4.1",
|
||||
"c8": "^7.13.0",
|
||||
"madge": "^6.0.0",
|
||||
"prettier": "^2.8.4",
|
||||
"tsd": "^0.25.0",
|
||||
"typescript": "^4.9.5",
|
||||
"uvu": "^0.5.6"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue