Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plan for v8 #589

Open
12 of 28 tasks
antonmedv opened this issue Feb 27, 2023 · 8 comments
Open
12 of 28 tasks

Plan for v8 #589

antonmedv opened this issue Feb 27, 2023 · 8 comments
Labels

Comments

@antonmedv
Copy link
Collaborator

antonmedv commented Feb 27, 2023

Here is a plan of what I'm planning to do for the next v8 release. Feel free to join, by picking one on the objectives.

v8

  • Set $.verbose = false by default ∅
    • stderr should be echoed by default.
    • stdout should not be printed by default.
  • Refactor $ to support const $$ = $({...}) syntax.
    • AbortController support by $.
    • Split $ into a separate package with minimum dependencies. (probably)
      • Add zx/core.
    • Remove ps-tree dependency.
    • (probably) Deprecate within().
      • Refactor process.cwd() calls
    • Add trim to ProcessOutput::valueOf(): string
    • Add $.sync API.
  • Use bash by default on Windows (and fail if not found, with ZX_SHELL env config).
  • Use node18 by default (but allow zx to run on node16 too).
    • Remove node-fetch dependency (node18 already has fetch, this allows to drop DOM lib in ts).
  • Add some CI tests for deno.
  • Bundle deps.

Future

  • Better support for multiline commands.
  • Better support for dotenv.
  • $.log refactoring (probably)
    • todo
  • Remove fs-extra dependency (probably)
  • Add exit()
  • Add pool()
  • Add progressBar()
  • Improve retry()
  • Improve --install
  • Add API for plugins*

Note: Before submitting PR, discuss implementation and API.
Note: * - complex task.

@antonmedv antonmedv pinned this issue Sep 5, 2023
@google google deleted a comment from theothirteen Sep 5, 2023
@google google deleted a comment from theothirteen Sep 5, 2023
@google google deleted a comment from theothirteen Sep 5, 2023
@google google deleted a comment from kidonng Sep 5, 2023
@google google deleted a comment from kidonng Sep 5, 2023
@google google deleted a comment from kidonng Sep 5, 2023
@google google deleted a comment from theothirteen Sep 5, 2023
@stevage
Copy link

stevage commented Dec 19, 2023

Is this the place to discuss these plans?

If so: personally I am glad that fs-extra is included by default. It includes fs.readJsonSync() which is exactly the kind of convenience that is nice in zx.

It also isn't clear whether the above addresses #636. What I (and I think others) would like is a decoupling of:

  • whether the command is printed
  • whether stdout is printed
  • whether stderr is printed

@antonmedv
Copy link
Collaborator Author

My idea about new verbose mode for $:

  • Set $.verbose = false by default
  • stderr should be echoed by default.
  • stdout should not be printed by default.

I also was planning to drop fs-extra by default.

@stevage
Copy link

stevage commented Dec 19, 2023

IMHO the default behaviour should be similar to a Bash script:

  • command is not echoed
  • stdout is printed
  • stderr is printed

If you make stdout not printed by default it will be confusing in a case like:

$`echo Hello world`

which well then of course behave differently from

echo`Hello world`

What's the rationale?

@antonmedv
Copy link
Collaborator Author

JS equivalent of echo is console.log. The problem with outputting $ by default is what we cannot distinguishes how it used:

await $`some-command`

versus

const output = await $`some-command`

So the idea is to not output anything(defaul behavior), allow to override with $.verbose =true.

Or you can simple redirect stdout:

await $`some-command`.pipe(process.stdout)

@stevage
Copy link

stevage commented Dec 20, 2023

JS equivalent of echo is console.log.

Personally, I think of ZX as a replacement for Bash, so it's more important that it works, by default, similarly. Most of my scripts have the expectation of being a little bit noisy - running commands, and having the output go to the console, so the user can see what is happening while it is running.

Making it so that doesn't happen is the Bash equivalent of writing > /dev/null at the end of every line, which would, for me, be unusual.

I don't dispute that there are situations where it's preferable not to pass stdout to the command line, but I think the default should be around the other way. And of course, changing the default will change the behaviour of every existing script.

Perhaps you'd consider additional per-command flags in any case, which would also protect scripts against future changes to this default:

await $.noisy`some-command`

const output=$.quiet`some-command`

@antonmedv
Copy link
Collaborator Author

What is different between $.noisy and .pipe(process.stdout)?

@stevage
Copy link

stevage commented Dec 20, 2023

I don't know, because I haven't tried the pipe method, and it wouldn't necessarily occur to me either. Thus far in my usage of zx, have not had to use .pipe() or process.stdout.

@lawrenceching
Copy link
Contributor

Suggest to release the v8 document ASAP.

I take hours to find out why the default value changed for $.verbose.
npm install v8 for me by default, and I didn't aware of that. I kept checking the v7 document and feeling confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants