Comparing version 7.2.3-dev.7e728f6 to 7.2.3-dev.b02fd52
@@ -32,3 +32,2 @@ #!/usr/bin/env node | ||
--install, -i install dependencies | ||
--experimental enable experimental features | ||
--version, -v print current zx version | ||
@@ -41,3 +40,3 @@ --help, -h print help | ||
string: ["shell", "prefix", "eval"], | ||
boolean: ["version", "help", "quiet", "install", "repl", "experimental"], | ||
boolean: ["version", "help", "quiet", "verbose", "install", "repl"], | ||
alias: { e: "eval", i: "install", v: "version", h: "help" }, | ||
@@ -49,2 +48,4 @@ stopEarly: true | ||
await import(globals); | ||
if (argv.verbose) | ||
$.verbose = true; | ||
if (argv.quiet) | ||
@@ -56,5 +57,2 @@ $.verbose = false; | ||
$.prefix = argv.prefix; | ||
if (argv.experimental) { | ||
Object.assign(global, await import("./experimental.js")); | ||
} | ||
if (argv.version) { | ||
@@ -61,0 +59,0 @@ console.log(getVersion()); |
@@ -1,2 +0,2 @@ | ||
import { ChildProcess, spawn, StdioNull, StdioPipe } from 'node:child_process'; | ||
import { spawn, spawnSync, StdioNull, StdioPipe } from 'node:child_process'; | ||
import { Readable, Writable } from 'node:stream'; | ||
@@ -6,14 +6,30 @@ import { inspect } from 'node:util'; | ||
import { Duration, noop, quote } from './util.js'; | ||
export type Shell = (pieces: TemplateStringsArray, ...args: any[]) => ProcessPromise; | ||
export interface Shell { | ||
(pieces: TemplateStringsArray, ...args: any[]): ProcessPromise; | ||
(opts: Partial<Options>): Shell; | ||
sync: { | ||
(pieces: TemplateStringsArray, ...args: any[]): ProcessOutput; | ||
(opts: Partial<Options>): Shell; | ||
}; | ||
} | ||
declare const processCwd: unique symbol; | ||
declare const syncExec: unique symbol; | ||
export interface Options { | ||
[processCwd]: string; | ||
[syncExec]: boolean; | ||
cwd?: string; | ||
ac?: AbortController; | ||
input?: string | Buffer | Readable | ProcessOutput | ProcessPromise; | ||
verbose: boolean; | ||
sync: boolean; | ||
env: NodeJS.ProcessEnv; | ||
shell: string | boolean; | ||
nothrow: boolean; | ||
prefix: string; | ||
quote: typeof quote; | ||
quiet: boolean; | ||
spawn: typeof spawn; | ||
spawnSync: typeof spawnSync; | ||
log: typeof log; | ||
kill: typeof kill; | ||
} | ||
@@ -25,3 +41,2 @@ export declare const defaults: Options; | ||
export declare class ProcessPromise extends Promise<ProcessOutput> { | ||
child?: ChildProcess; | ||
private _command; | ||
@@ -33,9 +48,11 @@ private _from; | ||
private _stdio; | ||
private _nothrow; | ||
private _quiet; | ||
private _nothrow?; | ||
private _quiet?; | ||
private _timeout?; | ||
private _timeoutSignal?; | ||
private _timeoutSignal; | ||
private _resolved; | ||
private _halted; | ||
private _piped; | ||
private _zurk; | ||
private _output; | ||
_prerun: typeof noop; | ||
@@ -45,2 +62,3 @@ _postrun: typeof noop; | ||
run(): ProcessPromise; | ||
get child(): import("child_process").ChildProcess | undefined; | ||
get stdin(): Writable; | ||
@@ -53,2 +71,3 @@ get stdout(): Readable; | ||
pipe(dest: Writable | ProcessPromise): ProcessPromise; | ||
abort(reason?: string): void; | ||
kill(signal?: string): Promise<void>; | ||
@@ -58,5 +77,8 @@ stdio(stdin: IO, stdout?: IO, stderr?: IO): ProcessPromise; | ||
quiet(): ProcessPromise; | ||
isQuiet(): boolean; | ||
isVerbose(): boolean; | ||
timeout(d: Duration, signal?: string): ProcessPromise; | ||
halt(): ProcessPromise; | ||
get isHalted(): boolean; | ||
get output(): ProcessOutput | null; | ||
} | ||
@@ -71,2 +93,3 @@ export declare class ProcessOutput extends Error { | ||
toString(): string; | ||
valueOf(): string; | ||
get stdout(): string; | ||
@@ -76,2 +99,4 @@ get stderr(): string; | ||
get signal(): NodeJS.Signals | null; | ||
static getExitMessage(code: number | null, signal: NodeJS.Signals | null, stderr: string, from: string): string; | ||
static getErrorMessage(err: NodeJS.ErrnoException, from: string): string; | ||
[inspect.custom](): string; | ||
@@ -81,2 +106,3 @@ } | ||
export declare function cd(dir: string | ProcessOutput): void; | ||
export declare function kill(pid: number, signal?: string): Promise<void>; | ||
export type LogEntry = { | ||
@@ -83,0 +109,0 @@ kind: 'cmd'; |
// src/core.ts | ||
import assert from "node:assert"; | ||
import { spawn } from "node:child_process"; | ||
import { spawn, spawnSync } from "node:child_process"; | ||
import { AsyncLocalStorage, createHook } from "node:async_hooks"; | ||
import { inspect } from "node:util"; | ||
import { | ||
exec, | ||
buildCmd, | ||
chalk, | ||
which | ||
which, | ||
ps | ||
} from "./vendor.js"; | ||
@@ -16,3 +19,2 @@ import { | ||
parseDuration, | ||
psTree, | ||
quote, | ||
@@ -22,2 +24,3 @@ quotePowerShell | ||
var processCwd = Symbol("processCwd"); | ||
var syncExec = Symbol("syncExec"); | ||
var storage = new AsyncLocalStorage(); | ||
@@ -34,5 +37,9 @@ var hook = createHook({ | ||
[processCwd]: process.cwd(), | ||
verbose: true, | ||
[syncExec]: false, | ||
verbose: false, | ||
env: process.env, | ||
sync: false, | ||
shell: true, | ||
nothrow: false, | ||
quiet: false, | ||
prefix: "", | ||
@@ -43,4 +50,7 @@ quote: () => { | ||
spawn, | ||
log | ||
spawnSync, | ||
log, | ||
kill | ||
}; | ||
var isWin = process.platform == "win32"; | ||
try { | ||
@@ -51,3 +61,3 @@ defaults.shell = which.sync("bash"); | ||
} catch (err) { | ||
if (process.platform == "win32") { | ||
if (isWin) { | ||
try { | ||
@@ -65,2 +75,10 @@ defaults.shell = which.sync("powershell.exe"); | ||
function(pieces, ...args) { | ||
if (!Array.isArray(pieces)) { | ||
return function(...args2) { | ||
const self = this; | ||
return within(() => { | ||
return Object.assign($, pieces).apply(self, args2); | ||
}); | ||
}; | ||
} | ||
const from = new Error().stack.split(/^\s*at\s/m)[2].trim(); | ||
@@ -72,15 +90,23 @@ if (pieces.some((p) => p == void 0)) { | ||
const promise = new ProcessPromise((...args2) => [resolve, reject] = args2); | ||
let cmd = pieces[0], i = 0; | ||
while (i < args.length) { | ||
let s; | ||
if (Array.isArray(args[i])) { | ||
s = args[i].map((x) => $.quote(substitute(x))).join(" "); | ||
} else { | ||
s = $.quote(substitute(args[i])); | ||
} | ||
cmd += s + pieces[++i]; | ||
} | ||
promise._bind(cmd, from, resolve, reject, getStore()); | ||
setImmediate(() => promise.isHalted || promise.run()); | ||
return promise; | ||
const cmd = buildCmd( | ||
$.quote, | ||
pieces, | ||
args | ||
); | ||
const snapshot = getStore(); | ||
const sync = snapshot[syncExec]; | ||
const callback = () => promise.isHalted || promise.run(); | ||
promise._bind( | ||
cmd, | ||
from, | ||
resolve, | ||
(v) => { | ||
reject(v); | ||
if (sync) | ||
throw v; | ||
}, | ||
snapshot | ||
); | ||
sync ? callback() : setImmediate(callback); | ||
return sync ? promise.output : promise; | ||
}, | ||
@@ -90,6 +116,8 @@ { | ||
const target = key in Function.prototype ? _ : getStore(); | ||
Reflect.set(target, key, value); | ||
Reflect.set(target, key === "sync" ? syncExec : key, value); | ||
return true; | ||
}, | ||
get(_, key) { | ||
if (key === "sync") | ||
return $({ sync: true }); | ||
const target = key in Function.prototype ? _ : getStore(); | ||
@@ -100,8 +128,2 @@ return Reflect.get(target, key); | ||
); | ||
function substitute(arg) { | ||
if (arg?.stdout) { | ||
return arg.stdout.replace(/\n$/, ""); | ||
} | ||
return `${arg}`; | ||
} | ||
var ProcessPromise = class _ProcessPromise extends Promise { | ||
@@ -116,7 +138,8 @@ constructor() { | ||
this._stdio = ["inherit", "pipe", "pipe"]; | ||
this._nothrow = false; | ||
this._quiet = false; | ||
this._timeoutSignal = "SIGTERM"; | ||
this._resolved = false; | ||
this._halted = false; | ||
this._piped = false; | ||
this._zurk = null; | ||
this._output = null; | ||
this._prerun = noop; | ||
@@ -133,75 +156,91 @@ this._postrun = noop; | ||
run() { | ||
const $2 = this._snapshot; | ||
if (this.child) | ||
return this; | ||
this._prerun(); | ||
const $2 = this._snapshot; | ||
const self = this; | ||
const input = $2.input?.stdout ?? $2.input; | ||
if (input) | ||
this.stdio("pipe"); | ||
$2.log({ | ||
kind: "cmd", | ||
cmd: this._command, | ||
verbose: $2.verbose && !this._quiet | ||
verbose: self.isVerbose() | ||
}); | ||
this.child = $2.spawn($2.prefix + this._command, { | ||
this._zurk = exec({ | ||
input, | ||
cmd: $2.prefix + this._command, | ||
cwd: $2.cwd ?? $2[processCwd], | ||
ac: $2.ac, | ||
shell: typeof $2.shell === "string" ? $2.shell : true, | ||
env: $2.env, | ||
spawn: $2.spawn, | ||
spawnSync: $2.spawnSync, | ||
stdio: this._stdio, | ||
windowsHide: true, | ||
env: $2.env | ||
}); | ||
this.child.on("close", (code, signal) => { | ||
let message = `exit code: ${code}`; | ||
if (code != 0 || signal != null) { | ||
message = `${stderr || "\n"} at ${this._from}`; | ||
message += ` | ||
exit code: ${code}${exitCodeInfo(code) ? " (" + exitCodeInfo(code) + ")" : ""}`; | ||
if (signal != null) { | ||
message += ` | ||
signal: ${signal}`; | ||
sync: $2[syncExec], | ||
detached: !isWin, | ||
run: (cb) => cb(), | ||
on: { | ||
start: () => { | ||
if (self._timeout) { | ||
const t = setTimeout( | ||
() => self.kill(self._timeoutSignal), | ||
self._timeout | ||
); | ||
self.finally(() => clearTimeout(t)).catch(noop); | ||
} | ||
}, | ||
stdout: (data) => { | ||
if (self._piped) | ||
return; | ||
$2.log({ kind: "stdout", data, verbose: self.isVerbose() }); | ||
}, | ||
stderr: (data) => { | ||
$2.log({ kind: "stderr", data, verbose: !self.isQuiet() }); | ||
}, | ||
end: ({ error, stdout, stderr, stdall, status, signal }) => { | ||
self._resolved = true; | ||
if (error) { | ||
const message = ProcessOutput.getErrorMessage(error, self._from); | ||
const output = new ProcessOutput( | ||
null, | ||
null, | ||
stdout, | ||
stderr, | ||
stdall, | ||
message | ||
); | ||
self._output = output; | ||
self._reject(output); | ||
} else { | ||
const message = ProcessOutput.getExitMessage( | ||
status, | ||
signal, | ||
stderr, | ||
self._from | ||
); | ||
const output = new ProcessOutput( | ||
status, | ||
signal, | ||
stdout, | ||
stderr, | ||
stdall, | ||
message | ||
); | ||
self._output = output; | ||
if (status === 0 || (self._nothrow ?? $2.nothrow)) { | ||
self._resolve(output); | ||
} else { | ||
self._reject(output); | ||
} | ||
} | ||
} | ||
} | ||
let output = new ProcessOutput( | ||
code, | ||
signal, | ||
stdout, | ||
stderr, | ||
combined, | ||
message | ||
); | ||
if (code === 0 || this._nothrow) { | ||
this._resolve(output); | ||
} else { | ||
this._reject(output); | ||
} | ||
this._resolved = true; | ||
}); | ||
this.child.on("error", (err) => { | ||
const message = `${err.message} | ||
errno: ${err.errno} (${errnoMessage(err.errno)}) | ||
code: ${err.code} | ||
at ${this._from}`; | ||
this._reject( | ||
new ProcessOutput(null, null, stdout, stderr, combined, message) | ||
); | ||
this._resolved = true; | ||
}); | ||
let stdout = "", stderr = "", combined = ""; | ||
let onStdout = (data) => { | ||
$2.log({ kind: "stdout", data, verbose: $2.verbose && !this._quiet }); | ||
stdout += data; | ||
combined += data; | ||
}; | ||
let onStderr = (data) => { | ||
$2.log({ kind: "stderr", data, verbose: $2.verbose && !this._quiet }); | ||
stderr += data; | ||
combined += data; | ||
}; | ||
if (!this._piped) | ||
this.child.stdout?.on("data", onStdout); | ||
this.child.stderr?.on("data", onStderr); | ||
this._postrun(); | ||
if (this._timeout && this._timeoutSignal) { | ||
const t = setTimeout(() => this.kill(this._timeoutSignal), this._timeout); | ||
this.finally(() => clearTimeout(t)).catch(noop); | ||
} | ||
return this; | ||
} | ||
get child() { | ||
return this._zurk?.child; | ||
} | ||
get stdin() { | ||
@@ -271,2 +310,7 @@ this.stdio("pipe"); | ||
} | ||
abort(reason) { | ||
if (!this.child) | ||
throw new Error("Trying to abort a process without creating one."); | ||
this._zurk?.ac.abort(reason); | ||
} | ||
async kill(signal = "SIGTERM") { | ||
@@ -277,13 +321,3 @@ if (!this.child) | ||
throw new Error("The process pid is undefined."); | ||
let children = await psTree(this.child.pid); | ||
for (const p of children) { | ||
try { | ||
process.kill(+p.PID, signal); | ||
} catch (e) { | ||
} | ||
} | ||
try { | ||
process.kill(this.child.pid, signal); | ||
} catch (e) { | ||
} | ||
return $.kill(this.child.pid, signal); | ||
} | ||
@@ -302,2 +336,8 @@ stdio(stdin, stdout = "pipe", stderr = "pipe") { | ||
} | ||
isQuiet() { | ||
return this._quiet ?? this._snapshot.quiet; | ||
} | ||
isVerbose() { | ||
return this._snapshot.verbose && !this.isQuiet(); | ||
} | ||
timeout(d, signal = "SIGTERM") { | ||
@@ -315,2 +355,5 @@ this._timeout = parseDuration(d); | ||
} | ||
get output() { | ||
return this._output; | ||
} | ||
}; | ||
@@ -329,2 +372,5 @@ var ProcessOutput = class extends Error { | ||
} | ||
valueOf() { | ||
return this._combined.trim(); | ||
} | ||
get stdout() { | ||
@@ -342,2 +388,21 @@ return this._stdout; | ||
} | ||
static getExitMessage(code, signal, stderr, from) { | ||
let message = `exit code: ${code}`; | ||
if (code != 0 || signal != null) { | ||
message = `${stderr || "\n"} at ${from}`; | ||
message += ` | ||
exit code: ${code}${exitCodeInfo(code) ? " (" + exitCodeInfo(code) + ")" : ""}`; | ||
if (signal != null) { | ||
message += ` | ||
signal: ${signal}`; | ||
} | ||
} | ||
return message; | ||
} | ||
static getErrorMessage(err, from) { | ||
return `${err.message} | ||
errno: ${err.errno} (${errnoMessage(err.errno)}) | ||
code: ${err.code} | ||
at ${from}`; | ||
} | ||
[inspect.custom]() { | ||
@@ -368,2 +433,15 @@ let stringify = (s, c) => s.length === 0 ? "''" : c(inspect(s)); | ||
} | ||
async function kill(pid, signal) { | ||
let children = await ps.tree({ pid, recursive: true }); | ||
for (const p of children) { | ||
try { | ||
process.kill(+p.pid, signal); | ||
} catch (e) { | ||
} | ||
} | ||
try { | ||
process.kill(-pid, signal); | ||
} catch (e) { | ||
} | ||
} | ||
function log(entry) { | ||
@@ -409,4 +487,5 @@ switch (entry.kind) { | ||
defaults, | ||
kill, | ||
log, | ||
within | ||
}; |
// src/deps.ts | ||
import { $ } from "./core.js"; | ||
import { spinner } from "./experimental.js"; | ||
import { spinner } from "./goods.js"; | ||
import { depseek } from "./vendor.js"; | ||
async function installDeps(dependencies, prefix) { | ||
@@ -74,30 +75,16 @@ const packages = Object.entries(dependencies).map( | ||
]); | ||
var importRe = [ | ||
/\bimport\s+['"](?<path>[^'"]+)['"]/, | ||
/\bimport\(['"](?<path>[^'"]+)['"]\)/, | ||
/\brequire\(['"](?<path>[^'"]+)['"]\)/, | ||
/\bfrom\s+['"](?<path>[^'"]+)['"]/ | ||
]; | ||
var nameRe = /^(?<name>(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*)\/?.*$/i; | ||
var versionRe = /(\/\/|\/\*)\s*@(?<version>[~^]?(v?[\dx*]+([-.][\d*a-z-]+)*))/i; | ||
var versionRe = /^@(?<version>[~^]?(v?[\dx*]+([-.][\d*a-z-]+)*))/i; | ||
function parseDeps(content) { | ||
const deps = {}; | ||
const lines = content.toString().split("\n"); | ||
for (let line of lines) { | ||
const tuple = parseImports(line); | ||
if (tuple) { | ||
deps[tuple.name] = tuple.version; | ||
return depseek(content.toString() + "\n", { comments: true }).reduce((m, { type, value }, i, list) => { | ||
if (type === "dep") { | ||
const meta = list[i + 1]; | ||
const name = parsePackageName(value); | ||
const version = meta?.type === "comment" && parseVersion(meta?.value.trim()) || "latest"; | ||
if (name) | ||
m[name] = version; | ||
} | ||
} | ||
return deps; | ||
return m; | ||
}, {}); | ||
} | ||
function parseImports(line) { | ||
for (let re of importRe) { | ||
const name = parsePackageName(re.exec(line)?.groups?.path); | ||
const version = parseVersion(line); | ||
if (name) { | ||
return { name, version }; | ||
} | ||
} | ||
} | ||
function parsePackageName(path) { | ||
@@ -104,0 +91,0 @@ if (!path) |
@@ -28,3 +28,2 @@ import * as _ from './index.js'; | ||
var spinner: typeof _.spinner; | ||
var ssh: typeof _.ssh; | ||
var stdin: typeof _.stdin; | ||
@@ -31,0 +30,0 @@ var which: typeof _.which; |
@@ -19,8 +19,5 @@ // src/goods.ts | ||
} | ||
var globby = Object.assign( | ||
function globby2(patterns, options) { | ||
return globbyModule.globby(patterns, options); | ||
}, | ||
globbyModule | ||
); | ||
var globby = Object.assign(function globby2(patterns, options) { | ||
return globbyModule.globby(patterns, options); | ||
}, globbyModule); | ||
var glob = globby; | ||
@@ -27,0 +24,0 @@ function sleep(duration) { |
import { ProcessPromise } from './core.js'; | ||
export * from './core.js'; | ||
export * from './goods.js'; | ||
export { minimist, chalk, fs, which, YAML, ssh } from './vendor.js'; | ||
export { minimist, chalk, fs, which, YAML, ps } from './vendor.js'; | ||
export { type Duration, quote, quotePowerShell } from './util.js'; | ||
/** | ||
* @deprecated Use $.nothrow() instead. | ||
* @deprecated Use $`cmd`.nothrow() instead. | ||
*/ | ||
export declare function nothrow(promise: ProcessPromise): ProcessPromise; | ||
/** | ||
* @deprecated Use $.quiet() instead. | ||
* @deprecated Use $`cmd`.quiet() instead. | ||
*/ | ||
export declare function quiet(promise: ProcessPromise): ProcessPromise; |
// src/index.ts | ||
export * from "./core.js"; | ||
export * from "./goods.js"; | ||
import { minimist, chalk, fs, which, YAML, ssh } from "./vendor.js"; | ||
import { minimist, chalk, fs, which, YAML, ps } from "./vendor.js"; | ||
import { quote, quotePowerShell } from "./util.js"; | ||
@@ -18,7 +18,7 @@ function nothrow(promise) { | ||
nothrow, | ||
ps, | ||
quiet, | ||
quote, | ||
quotePowerShell, | ||
ssh, | ||
which | ||
}; |
@@ -1,3 +0,1 @@ | ||
import { psTreeModule } from './vendor.js'; | ||
export declare const psTree: (arg1: number) => Promise<readonly psTreeModule.PS[]>; | ||
export declare function noop(): void; | ||
@@ -10,4 +8,4 @@ export declare function randomId(): string; | ||
export declare function errnoMessage(errno: number | undefined): string; | ||
export type Duration = number | `${number}s` | `${number}ms`; | ||
export type Duration = number | `${number}m` | `${number}s` | `${number}ms`; | ||
export declare function parseDuration(d: Duration): number; | ||
export declare function formatCmd(cmd?: string): string; |
// src/util.ts | ||
import { promisify } from "node:util"; | ||
import { chalk, psTreeModule } from "./vendor.js"; | ||
var psTree = promisify(psTreeModule); | ||
import { chalk } from "./vendor.js"; | ||
function noop() { | ||
@@ -196,2 +194,4 @@ } | ||
return +d.slice(0, -2); | ||
} else if (/\d+m/.test(d)) { | ||
return +d.slice(0, -1) * 1e3 * 60; | ||
} | ||
@@ -331,3 +331,2 @@ throw new Error(`Unknown duration: "${d}".`); | ||
parseDuration, | ||
psTree, | ||
quote, | ||
@@ -334,0 +333,0 @@ quotePowerShell, |
@@ -6,2 +6,5 @@ // Generated by dts-bundle-generator v9.3.1 | ||
import * as fs from 'fs'; | ||
import * as cp from 'node:child_process'; | ||
import EventEmitter from 'node:events'; | ||
import { Readable, Stream, Writable } from 'node:stream'; | ||
@@ -313,2 +316,77 @@ declare type ErrnoException = NodeJS.ErrnoException; | ||
declare const fetch$1: typeof globalThis.fetch; | ||
type TQuote = (input: string) => string; | ||
export declare const buildCmd: (quote: TQuote, pieces: TemplateStringsArray, args: any[], subs?: TSubstitute) => string | Promise<string>; | ||
type TSubstitute = (arg: any) => string; | ||
type TSpawnError = any; | ||
type TSpawnResult = { | ||
stderr: string; | ||
stdout: string; | ||
stdall: string; | ||
stdio: [ | ||
Readable | Writable, | ||
Writable, | ||
Writable | ||
]; | ||
status: number | null; | ||
signal: NodeJS.Signals | null; | ||
duration: number; | ||
ctx: TSpawnCtxNormalized; | ||
error?: TSpawnError; | ||
child?: TChild; | ||
}; | ||
type TSpawnListeners = { | ||
start: (data: TChild, ctx: TSpawnCtxNormalized) => void; | ||
stdout: (data: Buffer, ctx: TSpawnCtxNormalized) => void; | ||
stderr: (data: Buffer, ctx: TSpawnCtxNormalized) => void; | ||
abort: (error: Event, ctx: TSpawnCtxNormalized) => void; | ||
err: (error: Error, ctx: TSpawnCtxNormalized) => void; | ||
end: (result: TSpawnResult, ctx: TSpawnCtxNormalized) => void; | ||
}; | ||
type TSpawnCtx = Partial<Omit<TSpawnCtxNormalized, "child">>; | ||
type TChild = ReturnType<typeof cp.spawn>; | ||
type TInput = string | Buffer | Stream; | ||
interface TSpawnCtxNormalized { | ||
id: string; | ||
cwd: string; | ||
cmd: string; | ||
sync: boolean; | ||
args: ReadonlyArray<string>; | ||
input: TInput | null; | ||
stdio: [ | ||
"pipe", | ||
"pipe", | ||
"pipe" | ||
]; | ||
detached: boolean; | ||
env: Record<string, string | undefined>; | ||
ee: EventEmitter; | ||
on: Partial<TSpawnListeners>; | ||
ac: AbortController; | ||
shell: string | true | undefined; | ||
spawn: typeof cp.spawn; | ||
spawnSync: typeof cp.spawnSync; | ||
spawnOpts: Record<string, any>; | ||
callback: (err: TSpawnError, result: TSpawnResult) => void; | ||
stdin: Readable; | ||
stdout: Writable; | ||
stderr: Writable; | ||
child?: TChild; | ||
fulfilled?: TSpawnResult; | ||
error?: any; | ||
run: (cb: () => void, ctx: TSpawnCtxNormalized) => void; | ||
} | ||
export declare const exec: (ctx: TSpawnCtx) => TSpawnCtxNormalized; | ||
type TCodeRef = { | ||
type: string; | ||
value: string; | ||
index: number; | ||
}; | ||
type TOptsNormalized = { | ||
comments: boolean; | ||
bufferSize: number; | ||
re: RegExp; | ||
offset: number; | ||
}; | ||
type TOpts = Partial<TOptsNormalized>; | ||
declare const depseekSync: (input: string | Buffer, opts?: TOpts) => TCodeRef[]; | ||
type ColorSupportLevel = 0 | 1 | 2 | 3; | ||
@@ -618,32 +696,31 @@ export interface ChalkInstance { | ||
} | ||
declare namespace ps_tree$1 { | ||
interface PS { | ||
COMMAND: string; | ||
PPID: string; | ||
PID: string; | ||
STAT: string; | ||
} | ||
const prototype: {}; | ||
} | ||
declare function ps_tree$1(pid: number, callback: (error: Error | null, children: readonly ps_tree$1.PS[]) => void): void; | ||
type RemoteShell = ((pieces: TemplateStringsArray, ...values: any[]) => Promise<Result>) & { | ||
exit: () => void; | ||
type TPsLookupCallback = (err: any, processList?: TPsLookupEntry[]) => void; | ||
type TPsLookupEntry = { | ||
pid: string; | ||
ppid?: string; | ||
command: string; | ||
arguments: string[]; | ||
}; | ||
type Options$2 = { | ||
port?: number | string; | ||
forwardAgent?: boolean; | ||
shell?: string; | ||
options?: (SshOption | `${SshOption}=${string}`)[]; | ||
type TPsLookupQuery = { | ||
pid?: number | string | (string | number)[]; | ||
command?: string; | ||
arguments?: string; | ||
ppid?: number | string; | ||
psargs?: string | string[]; | ||
}; | ||
export declare function ssh(host: string, options?: Options$2): RemoteShell; | ||
declare class Result extends String { | ||
readonly source: string; | ||
readonly stdout: string; | ||
readonly stderr: string; | ||
readonly exitCode: number | null; | ||
readonly error?: Error; | ||
constructor(source: string, exitCode: number | null, stdout: string, stderr: string, combined: string, error?: Error); | ||
} | ||
type SshOption = "AddKeysToAgent" | "AddressFamily" | "BatchMode" | "BindAddress" | "CanonicalDomains" | "CanonicalizeFallbackLocal" | "CanonicalizeHostname" | "CanonicalizeMaxDots" | "CanonicalizePermittedCNAMEs" | "CASignatureAlgorithms" | "CertificateFile" | "ChallengeResponseAuthentication" | "CheckHostIP" | "Ciphers" | "ClearAllForwardings" | "Compression" | "ConnectionAttempts" | "ConnectTimeout" | "ControlMaster" | "ControlPath" | "ControlPersist" | "DynamicForward" | "EscapeChar" | "ExitOnForwardFailure" | "FingerprintHash" | "ForwardAgent" | "ForwardX11" | "ForwardX11Timeout" | "ForwardX11Trusted" | "GatewayPorts" | "GlobalKnownHostsFile" | "GSSAPIAuthentication" | "GSSAPIDelegateCredentials" | "HashKnownHosts" | "Host" | "HostbasedAcceptedAlgorithms" | "HostbasedAuthentication" | "HostKeyAlgorithms" | "HostKeyAlias" | "Hostname" | "IdentitiesOnly" | "IdentityAgent" | "IdentityFile" | "IPQoS" | "KbdInteractiveAuthentication" | "KbdInteractiveDevices" | "KexAlgorithms" | "KnownHostsCommand" | "LocalCommand" | "LocalForward" | "LogLevel" | "MACs" | "Match" | "NoHostAuthenticationForLocalhost" | "NumberOfPasswordPrompts" | "PasswordAuthentication" | "PermitLocalCommand" | "PermitRemoteOpen" | "PKCS11Provider" | "Port" | "PreferredAuthentications" | "ProxyCommand" | "ProxyJump" | "ProxyUseFdpass" | "PubkeyAcceptedAlgorithms" | "PubkeyAuthentication" | "RekeyLimit" | "RemoteCommand" | "RemoteForward" | "RequestTTY" | "SendEnv" | "ServerAliveInterval" | "ServerAliveCountMax" | "SetEnv" | "StreamLocalBindMask" | "StreamLocalBindUnlink" | "StrictHostKeyChecking" | "TCPKeepAlive" | "Tunnel" | "TunnelDevice" | "UpdateHostKeys" | "UseKeychain" | "User" | "UserKnownHostsFile" | "VerifyHostKeyDNS" | "VisualHostKey" | "XAuthLocation"; | ||
type RequestInfo$1 = Parameters<typeof fetch$1>[0]; | ||
type TPsKillOptions = { | ||
timeout?: number; | ||
signal?: string | number | NodeJS.Signals; | ||
}; | ||
type TPsNext = (err?: any, data?: any) => void; | ||
type TPsTreeOpts = { | ||
pid: string | number; | ||
recursive?: boolean; | ||
}; | ||
declare const _default: { | ||
lookup: (query?: TPsLookupQuery, cb?: TPsLookupCallback) => Promise<TPsLookupEntry[]>; | ||
kill: (pid: string | number, opts?: string | number | TPsKillOptions | TPsNext | undefined, next?: TPsNext | undefined) => Promise<void>; | ||
tree: (opts: string | number | TPsTreeOpts, cb?: TPsLookupCallback) => Promise<TPsLookupEntry[]>; | ||
}; | ||
export type RequestInfo = Parameters<typeof fetch$1>[0]; | ||
type RequestInit$1 = Parameters<typeof fetch$1>[1]; | ||
@@ -668,9 +745,9 @@ export declare const globbyModule: { | ||
Options$1 as GlobbyOptions, | ||
RequestInfo$1 as RequestInfo, | ||
RequestInit$1 as RequestInit, | ||
_default as ps, | ||
depseekSync as depseek, | ||
fetch$1 as nodeFetch, | ||
fs$1 as fs, | ||
ps_tree$1 as psTreeModule, | ||
}; | ||
export {}; |
{ | ||
"name": "zx", | ||
"version": "7.2.3-dev.7e728f6", | ||
"version": "7.2.3-dev.b02fd52", | ||
"description": "A tool for writing better scripts", | ||
@@ -16,5 +16,2 @@ "type": "module", | ||
], | ||
"experimental": [ | ||
"./build/experimental.d.ts" | ||
], | ||
"cli": [ | ||
@@ -31,3 +28,2 @@ "./build/cli.d.ts" | ||
"./globals": "./build/globals.js", | ||
"./experimental": "./build/experimental.js", | ||
"./cli": "./build/cli.js", | ||
@@ -51,3 +47,4 @@ "./core": "./build/core.js", | ||
"build:dts": "tsc --project tsconfig.prod.json && node scripts/build-dts.mjs", | ||
"test": "npm run build && node ./test/all.test.js", | ||
"test": "npm run build && npm run test:unit && npm run test:types", | ||
"test:unit": "node ./test/all.test.js", | ||
"test:types": "tsd", | ||
@@ -61,3 +58,3 @@ "coverage": "c8 -x build/vendor.js -x 'test/**' -x scripts --check-coverage npm test", | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/node": ">=20.11.19" | ||
"@types/node": ">=20.11.30" | ||
}, | ||
@@ -68,11 +65,12 @@ "devDependencies": { | ||
"@types/minimist": "^1.2.5", | ||
"@types/node": ">=20.11.19", | ||
"@types/ps-tree": "^1.1.6", | ||
"@types/node": ">=20.11.30", | ||
"@types/which": "^3.0.3", | ||
"c8": "^7.13.0", | ||
"@webpod/ps": "^0.0.0-beta.2", | ||
"c8": "^9.1.0", | ||
"chalk": "^5.3.0", | ||
"depseek": "^0.4.1", | ||
"dts-bundle-generator": "^9.3.1", | ||
"esbuild": "^0.20.1", | ||
"esbuild": "^0.20.2", | ||
"esbuild-node-externals": "^1.13.0", | ||
"esbuild-plugin-entry-chunks": "^0.1.8", | ||
"esbuild-plugin-entry-chunks": "^0.1.11", | ||
"fs-extra": "^11.2.0", | ||
@@ -83,10 +81,9 @@ "fx": "*", | ||
"minimist": "^1.2.8", | ||
"node-fetch-native": "^1.6.2", | ||
"prettier": "^2.8.8", | ||
"ps-tree": "^1.2.0", | ||
"tsd": "^0.28.1", | ||
"typescript": "^5.0.4", | ||
"webpod": "^0", | ||
"which": "^3.0.0", | ||
"yaml": "^2.3.4" | ||
"node-fetch-native": "^1.6.4", | ||
"prettier": "^3.2.5", | ||
"tsd": "^0.30.7", | ||
"typescript": "^5.4.3", | ||
"which": "^4.0.0", | ||
"yaml": "^2.4.1", | ||
"zurk": "^0.0.32" | ||
}, | ||
@@ -103,3 +100,4 @@ "publishConfig": { | ||
"singleQuote": true, | ||
"endOfLine": "lf" | ||
"endOfLine": "lf", | ||
"trailingComma": "es5" | ||
}, | ||
@@ -106,0 +104,0 @@ "repository": "google/zx", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
844386
21
23532
18