google/zx (zx)
### [`v8.0.0`](https://togithub.com/google/zx/releases/tag/8.0.0)
[Compare Source](https://togithub.com/google/zx/compare/7.2.3...8.0.0)
We are thrilled to announce the release of `zx` v8.0.0! 🎉
![SCR-20240405-jhbw](https://togithub.com/google/zx/assets/141232/999b5d25-b001-44a3-b08f-9a4a24ca585f)
With this release, we have introduced a lot of new features, improvements, and bug fixes.
We have also made some breaking changes, so please read the following release notes carefully.
##### 🚀 New Shiny Features
Squashed deps: we use [esbuild](https://togithub.com/evanw/esbuild) with custom plugins to forge js bundles and [dts-bundle-generator](https://togithub.com/timocov/dts-bundle-generator) for typings [2acb0f](https://togithub.com/google/zx/commit/2acb0f2c786bcfe4f0ed1ac0dfc4c818d96d6c30), [#722](https://togithub.com/google/zx/pull/722)
More safety, more stability and significantly reduced installation time. Zx now is **~20x** smaller.
```bash
npx zx@8.0.0
npm install zx@8.0.0
```
Options presets are here. To implement this, we have also completely refactored the `zx` core, and now it's available as a separate package – [zurk](https://togithub.com/webpod/zurk)\ [aeec7a](https://togithub.com/google/zx/commit/aeec7ae84b814d7134f88b3455e144b39429d8b6), [#733](https://togithub.com/google/zx/pull/733), [#600](https://togithub.com/google/zx/pull/600)
```ts
const $$ = $({quiet: true})
await $$`echo foo`
$({nothrow: true})`exit 1`
```
We have introduced `$.sync()` API\ [1f8c8b](https://togithub.com/google/zx/commit/1f8c8b85d301607faedf0ba820a742a53c6e41b2), [#738](https://togithub.com/google/zx/pull/738), [#681](https://togithub.com/google/zx/pull/681), [1d8aa9](https://togithub.com/google/zx/commit/1d8aa9356968d8e7f523f3cddac10e8b457c0ecc), [#739](https://togithub.com/google/zx/pull/739)
```ts
import {$} from 'zx'
const { output } = $.sync`echo foo` // foo
```
You can also override the internal API to implement pools, test mocking, etc.
```ts
$.spawnSync = () => {} // defaults to `child_process.spawnSync`
```
The `input` option is now available to pass data to the command.\ [b38972](https://togithub.com/google/zx/commit/b38972e8001782f88a04feabeb89271523654e3f), [#736](https://togithub.com/google/zx/pull/736)
```ts
const p1 = $({ input: 'foo' })`cat`
const p2 = $({ input: Readable.from('bar') })`cat`
const p3 = $({ input: Buffer.from('baz') })`cat`
const p4 = $({ input: p3 })`cat`
const p5 = $({ input: await p3 })`cat`
```
`AbortController` has been introduced to abort the command execution. It's available via the `ac` option.\ [fa4a7b](https://togithub.com/google/zx/commit/fa4a7b404b34986b51ad9a941c1a17ac473d0d7d), [#734](https://togithub.com/google/zx/pull/734), [#527](https://togithub.com/google/zx/pull/527)
```ts
const ac = new AbortController()
const p = $({ ac })`sleep 9999`
setTimeout(() => ac.abort(), 100)
```
If not specified, the default instance will be used. Abortion trigger is also available via `PromiseResponse`:
```ts
const p = $`sleep 9999`
setTimeout(() => p.abort(), 100)
```
`kill` method is exposed now. To terminate any (not only zx starter) process:
```ts
import { kill } from 'zx'
await kill(123)
await kill(123, 'SIGKILL')
```
Btw, we have replaced `ps-tree` with [@webpod/ps](https://togithub.com/webpod/ps) & [@webpod/ingrid](https://togithub.com/webpod/ingrid), and exposed `ps` util:
```ts
import {ps} from 'zx'
const children = await ps.tree(123)
/**
[
{pid: 124, ppid: 123},
{pid: 125, ppid: 123}
]
*/
const children2 = await ps.tree({pid: 123, recursive: true})
/**
[
{pid: 124, ppid: 123},
{pid: 125, ppid: 123},
{pid: 126, ppid: 124},
{pid: 127, ppid: 124},
{pid: 128, ppid: 124},
{pid: 129, ppid: 125},
{pid: 130, ppid: 125},
]
*/
```
Introduced `$.postfix` option. It's like a `$.prefix`, but for the end of the command. [fb9554](https://togithub.com/google/zx/commit/fb9554f322d5b1fa013ee27fe21ab92558a7ed4b), [#756](https://togithub.com/google/zx/pull/756), [#536](https://togithub.com/google/zx/pull/#536)
```ts
import {$} from 'zx'
$.postfix = '; exit $LastExitCode' // for PowerShell compatibility
```
`minimist` API exposed\ [#661](https://togithub.com/google/zx/pull/661)
```ts
import { minimist } from 'zx'
const argv = minimist(process.argv.slice(2), {})
```
Fixed npm package name pattern on `--install` mode [956dcc](https://togithub.com/google/zx/commit/956dcc3bbdd349ac4c41f8db51add4efa2f58456), [#659](https://togithub.com/google/zx/pull/659), [#660](https://togithub.com/google/zx/pull/660), [#663](https://togithub.com/google/zx/pull/663)
```ts
import '@qux/pkg' // valid
import '@qux/pkg/entry' // was invalid before and valid now
```
##### ⚠️ Breaking changes
> We've tried our best to avoid them, but it was necessary.
1. `$.verbose` is set to `false` by default, but errors are still printed to `stderr`. Set `$.quiet = true` to suppress all output.\ [cafb90](https://togithub.com/google/zx/commit/cafb90dafe30a12dda9ff6b9b9e0ff9550e1272b), [#745](https://togithub.com/google/zx/pull/745), [#569](https://togithub.com/google/zx/pull/569)
```ts
$.verbose = true // everything works like in v7
$.quite = true // to completelly turn off logging
```
2. `ssh` API was dropped. Install [webpod](https://togithub.com/webpod/webpod) package instead.\ [8925a1](https://togithub.com/google/zx/commit/8925a127e4bcf7e9a2e0cf5e443076f4473eedd0), [#750](https://togithub.com/google/zx/pull/750)
```ts
// import {ssh} from 'zx' ↓
import {ssh} from 'webpod'
const remote = ssh('user@host')
await remote`echo foo`
```
3. zx is not looking for `powershell` anymore, on Windows by default. If you still need it, use the `usePowerShell` helper:\ [24dcf3](https://togithub.com/google/zx/commit/24dcf3a2953777b70cc54effe2989621a9133886), [#757](https://togithub.com/google/zx/pull/757)
```ts
import { usePowerShell, useBash } from 'zx'
usePowerShell() // to enable powershell
useBash() // switch to bash, the default
```
4. Process cwd synchronization between `$` invocations is disabled by default. This functionality is provided via an async hook and can now be controlled directly.\ [d79a63](https://togithub.com/google/zx/commit/d79a63888352eda47a30c018c9734fb9a3347746), [#765](https://togithub.com/google/zx/pull/765)
```ts
import { syncProcessCwd } from 'zx'
syncProcessCwd() // restores legacy v7 behaviour
```
##### 🧰 Other Improvements
- added dev (snapshot publish) releases [0c97b9](https://togithub.com/google/zx/commit/0c97b9f1752b8cf9fdd8178e5798b70f6440d8e4) [#723](https://togithub.com/google/zx/issues/723)
- tsconfig: dropped `lib DOM` [fe0356](https://togithub.com/google/zx/commit/fe0356fd14ee8d448c74d9bba2412e70b7644ad2) [#735](https://togithub.com/google/zx/issues/735), [#619](https://togithub.com/google/zx/issues/619), [#722](https://togithub.com/google/zx/issues/722))
- implemented `ProcessPromise.valueOf()` to simplify value comparisons [0640b8](https://togithub.com/google/zx/commit/0640b80c978ba7c5c1fcb57b42f774de79181721), [#737](https://togithub.com/google/zx/issues/737), [#690](https://togithub.com/google/zx/issues/690)
- enhanced `--install` API: use [depkeek](https://togithub.com/antongolub/misc/tree/master/packages/dep/depseek) for deps extraction [1a03a6](https://togithub.com/google/zx/commit/1a03a62cd17565eb181527aa2dec5b9c1d308d81)
- removed `--experimental` toggle, all APIs are available by default [8a7a8f](https://togithub.com/google/zx/commit/8a7a8feb829c71ad623195f2c8391c3203c7a58e), [#751](https://togithub.com/google/zx/issues/751)
- added minute support in duration [b02fd5](https://togithub.com/google/zx/commit/b02fd5279e79af44b83eb0e20d53bb9ee57c988d), [#703](https://togithub.com/google/zx/issues/703), [#704](https://togithub.com/google/zx/issues/704)
- enhanced stack extraction to support bun [2026d4](https://togithub.com/google/zx/commit/2026d4a4451f963064b0b340cd8ff91cf2a5d8fd), [#752](https://togithub.com/google/zx/issues/752)
- fixed `spinner` issue on weird TTY [1124e3](https://togithub.com/google/zx/commit/1124e31c9cb9f2b087aa26e019f49caebcc2aa0e), [#755](https://togithub.com/google/zx/issues/755), [#607](https://togithub.com/google/zx/issues/607)
- migrated tests to native `node:test` [cd1835](https://togithub.com/google/zx/commit/cd18352320de3873a1d1473c037632212557757a)
Configuration
📅 Schedule: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
^7.2.3
->^8.0.0
Release Notes
google/zx (zx)
### [`v8.0.0`](https://togithub.com/google/zx/releases/tag/8.0.0) [Compare Source](https://togithub.com/google/zx/compare/7.2.3...8.0.0) We are thrilled to announce the release of `zx` v8.0.0! 🎉 ![SCR-20240405-jhbw](https://togithub.com/google/zx/assets/141232/999b5d25-b001-44a3-b08f-9a4a24ca585f) With this release, we have introduced a lot of new features, improvements, and bug fixes. We have also made some breaking changes, so please read the following release notes carefully. ##### 🚀 New Shiny Features Squashed deps: we use [esbuild](https://togithub.com/evanw/esbuild) with custom plugins to forge js bundles and [dts-bundle-generator](https://togithub.com/timocov/dts-bundle-generator) for typings [2acb0f](https://togithub.com/google/zx/commit/2acb0f2c786bcfe4f0ed1ac0dfc4c818d96d6c30), [#722](https://togithub.com/google/zx/pull/722) More safety, more stability and significantly reduced installation time. Zx now is **~20x** smaller. ```bash npx zx@8.0.0 npm install zx@8.0.0 ``` Options presets are here. To implement this, we have also completely refactored the `zx` core, and now it's available as a separate package – [zurk](https://togithub.com/webpod/zurk)\ [aeec7a](https://togithub.com/google/zx/commit/aeec7ae84b814d7134f88b3455e144b39429d8b6), [#733](https://togithub.com/google/zx/pull/733), [#600](https://togithub.com/google/zx/pull/600) ```ts const $$ = $({quiet: true}) await $$`echo foo` $({nothrow: true})`exit 1` ``` We have introduced `$.sync()` API\ [1f8c8b](https://togithub.com/google/zx/commit/1f8c8b85d301607faedf0ba820a742a53c6e41b2), [#738](https://togithub.com/google/zx/pull/738), [#681](https://togithub.com/google/zx/pull/681), [1d8aa9](https://togithub.com/google/zx/commit/1d8aa9356968d8e7f523f3cddac10e8b457c0ecc), [#739](https://togithub.com/google/zx/pull/739) ```ts import {$} from 'zx' const { output } = $.sync`echo foo` // foo ``` You can also override the internal API to implement pools, test mocking, etc. ```ts $.spawnSync = () => {} // defaults to `child_process.spawnSync` ``` The `input` option is now available to pass data to the command.\ [b38972](https://togithub.com/google/zx/commit/b38972e8001782f88a04feabeb89271523654e3f), [#736](https://togithub.com/google/zx/pull/736) ```ts const p1 = $({ input: 'foo' })`cat` const p2 = $({ input: Readable.from('bar') })`cat` const p3 = $({ input: Buffer.from('baz') })`cat` const p4 = $({ input: p3 })`cat` const p5 = $({ input: await p3 })`cat` ``` `AbortController` has been introduced to abort the command execution. It's available via the `ac` option.\ [fa4a7b](https://togithub.com/google/zx/commit/fa4a7b404b34986b51ad9a941c1a17ac473d0d7d), [#734](https://togithub.com/google/zx/pull/734), [#527](https://togithub.com/google/zx/pull/527) ```ts const ac = new AbortController() const p = $({ ac })`sleep 9999` setTimeout(() => ac.abort(), 100) ``` If not specified, the default instance will be used. Abortion trigger is also available via `PromiseResponse`: ```ts const p = $`sleep 9999` setTimeout(() => p.abort(), 100) ``` `kill` method is exposed now. To terminate any (not only zx starter) process: ```ts import { kill } from 'zx' await kill(123) await kill(123, 'SIGKILL') ``` Btw, we have replaced `ps-tree` with [@webpod/ps](https://togithub.com/webpod/ps) & [@webpod/ingrid](https://togithub.com/webpod/ingrid), and exposed `ps` util: ```ts import {ps} from 'zx' const children = await ps.tree(123) /** [ {pid: 124, ppid: 123}, {pid: 125, ppid: 123} ] */ const children2 = await ps.tree({pid: 123, recursive: true}) /** [ {pid: 124, ppid: 123}, {pid: 125, ppid: 123}, {pid: 126, ppid: 124}, {pid: 127, ppid: 124}, {pid: 128, ppid: 124}, {pid: 129, ppid: 125}, {pid: 130, ppid: 125}, ] */ ``` Introduced `$.postfix` option. It's like a `$.prefix`, but for the end of the command. [fb9554](https://togithub.com/google/zx/commit/fb9554f322d5b1fa013ee27fe21ab92558a7ed4b), [#756](https://togithub.com/google/zx/pull/756), [#536](https://togithub.com/google/zx/pull/#536) ```ts import {$} from 'zx' $.postfix = '; exit $LastExitCode' // for PowerShell compatibility ``` `minimist` API exposed\ [#661](https://togithub.com/google/zx/pull/661) ```ts import { minimist } from 'zx' const argv = minimist(process.argv.slice(2), {}) ``` Fixed npm package name pattern on `--install` mode [956dcc](https://togithub.com/google/zx/commit/956dcc3bbdd349ac4c41f8db51add4efa2f58456), [#659](https://togithub.com/google/zx/pull/659), [#660](https://togithub.com/google/zx/pull/660), [#663](https://togithub.com/google/zx/pull/663) ```ts import '@qux/pkg' // valid import '@qux/pkg/entry' // was invalid before and valid now ``` ##### ⚠️ Breaking changes > We've tried our best to avoid them, but it was necessary. 1. `$.verbose` is set to `false` by default, but errors are still printed to `stderr`. Set `$.quiet = true` to suppress all output.\ [cafb90](https://togithub.com/google/zx/commit/cafb90dafe30a12dda9ff6b9b9e0ff9550e1272b), [#745](https://togithub.com/google/zx/pull/745), [#569](https://togithub.com/google/zx/pull/569) ```ts $.verbose = true // everything works like in v7 $.quite = true // to completelly turn off logging ``` 2. `ssh` API was dropped. Install [webpod](https://togithub.com/webpod/webpod) package instead.\ [8925a1](https://togithub.com/google/zx/commit/8925a127e4bcf7e9a2e0cf5e443076f4473eedd0), [#750](https://togithub.com/google/zx/pull/750) ```ts // import {ssh} from 'zx' ↓ import {ssh} from 'webpod' const remote = ssh('user@host') await remote`echo foo` ``` 3. zx is not looking for `powershell` anymore, on Windows by default. If you still need it, use the `usePowerShell` helper:\ [24dcf3](https://togithub.com/google/zx/commit/24dcf3a2953777b70cc54effe2989621a9133886), [#757](https://togithub.com/google/zx/pull/757) ```ts import { usePowerShell, useBash } from 'zx' usePowerShell() // to enable powershell useBash() // switch to bash, the default ``` 4. Process cwd synchronization between `$` invocations is disabled by default. This functionality is provided via an async hook and can now be controlled directly.\ [d79a63](https://togithub.com/google/zx/commit/d79a63888352eda47a30c018c9734fb9a3347746), [#765](https://togithub.com/google/zx/pull/765) ```ts import { syncProcessCwd } from 'zx' syncProcessCwd() // restores legacy v7 behaviour ``` ##### 🧰 Other Improvements - added dev (snapshot publish) releases [0c97b9](https://togithub.com/google/zx/commit/0c97b9f1752b8cf9fdd8178e5798b70f6440d8e4) [#723](https://togithub.com/google/zx/issues/723) - tsconfig: dropped `lib DOM` [fe0356](https://togithub.com/google/zx/commit/fe0356fd14ee8d448c74d9bba2412e70b7644ad2) [#735](https://togithub.com/google/zx/issues/735), [#619](https://togithub.com/google/zx/issues/619), [#722](https://togithub.com/google/zx/issues/722)) - implemented `ProcessPromise.valueOf()` to simplify value comparisons [0640b8](https://togithub.com/google/zx/commit/0640b80c978ba7c5c1fcb57b42f774de79181721), [#737](https://togithub.com/google/zx/issues/737), [#690](https://togithub.com/google/zx/issues/690) - enhanced `--install` API: use [depkeek](https://togithub.com/antongolub/misc/tree/master/packages/dep/depseek) for deps extraction [1a03a6](https://togithub.com/google/zx/commit/1a03a62cd17565eb181527aa2dec5b9c1d308d81) - removed `--experimental` toggle, all APIs are available by default [8a7a8f](https://togithub.com/google/zx/commit/8a7a8feb829c71ad623195f2c8391c3203c7a58e), [#751](https://togithub.com/google/zx/issues/751) - added minute support in duration [b02fd5](https://togithub.com/google/zx/commit/b02fd5279e79af44b83eb0e20d53bb9ee57c988d), [#703](https://togithub.com/google/zx/issues/703), [#704](https://togithub.com/google/zx/issues/704) - enhanced stack extraction to support bun [2026d4](https://togithub.com/google/zx/commit/2026d4a4451f963064b0b340cd8ff91cf2a5d8fd), [#752](https://togithub.com/google/zx/issues/752) - fixed `spinner` issue on weird TTY [1124e3](https://togithub.com/google/zx/commit/1124e31c9cb9f2b087aa26e019f49caebcc2aa0e), [#755](https://togithub.com/google/zx/issues/755), [#607](https://togithub.com/google/zx/issues/607) - migrated tests to native `node:test` [cd1835](https://togithub.com/google/zx/commit/cd18352320de3873a1d1473c037632212557757a)Configuration
📅 Schedule: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.