oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.37k stars 2.78k forks source link

Do not elide lines with `bun run` with workspaces #12431

Open spiffytech opened 4 months ago

spiffytech commented 4 months ago

What is the problem this feature would solve?

My DB migration library prints out what's wrong with my SQL, but running bun run migrate from my project top-level omits the most important lines from the error: the SQL error message.

$ bun run migrate
$ bun run --filter server --env-file .env migrate
server migrate $ bunx pg-migrations apply --directory migrations && bunx @databases/pg-schema-cli --directory __generated__
│ [8 lines elided]
│     at handleError (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:394:29)
│     at executeQueryInternal (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:369:9)
│     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
│     at async PgDriver._executeQuery (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:199:29)
│     at async PgDriver.executeAndReturnLast (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:226:16)
│     at async Transaction.query (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/shared/lib/BaseTransaction.js:59:24)
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:19:25
│     at async Object.applyMigration (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:137:21)
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/migrations-base/lib/methods/applyOperations.js:43:29
│     at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:54:20
└─ Exited with code 1
error: script "migrate" exited with code 1

If I cd into packages/server and run the same command manually I get the full error:

$ bun run --env-file ../../.env migrate
$ bunx pg-migrations apply --directory migrations && bunx @databases/pg-schema-cli --directory __generated__
Applying 0003-lifts-order.sql
error: column lifts.id does not exist

  16 |   ) as subquery
  17 | where
> 18 |   lifts.id = subquery.id
     |   ^

    at handleError (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:394:29)
    at executeQueryInternal (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:369:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PgDriver._executeQuery (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:199:29)
    at async PgDriver.executeAndReturnLast (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg/lib/Driver.js:226:16)
    at async Transaction.query (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/shared/lib/BaseTransaction.js:59:24)
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:19:25
    at async Object.applyMigration (/home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:137:21)
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/migrations-base/lib/methods/applyOperations.js:43:29
    at async /home/spiffytech/Documents/bootspoon/barbellbasics/node_modules/@databases/pg-migrations/lib/PostgresDatabaseEngine.js:54:20
error: script "migrate" exited with code 1

What is the feature you are proposing to solve the problem?

A way for bun run to print the entire, unabridged output from workspace scripts. Maybe by default, maybe with a flag.

What alternatives have you considered?

Just not using top-level package.json scripts if they're not gonna show me complete output, but then I have to specify the .env file for every command

ChristopherHaws commented 3 months ago

I wouldn't mind it not being the default, but I would love to be able to stream the output. PNPM has a flag for this:

--stream   : Stream output from child processes immediately, prefixed with the originating package directory. This allows output from different packages to be interleaved.
chneau commented 2 months ago

One I have a good user experience with is by using concurrently npm package with the --names to add prefix names, the --prefix-colors=auto for auto coloration.

Here is an example, left is bun run --filter '*' start, right isconcurrently --names=client,server --prefix-colors=auto 'bun run start:client' 'bun run start:server'

image

nikitavoloboev commented 1 month ago

I hope bun team looks into this, it's quite an annoying blocker of using this feature with bun.

erik-reges commented 3 weeks ago

please provide us a with a way of running bun applications that actually shows terminal output as a whole and not just the 5 latest lines

gokaygurcan commented 2 weeks ago

I think I have two issues in one:

$ bun --filter="./packages/database" db:push --force                                                                                                                                                  
@project/database db:push $ drizzle-kit push --config=drizzle.config.ts
│ [15 lines elided]                                                                  <--- first issue here
[⣽] Pulling schema from database...
[⣷] Pulling schema from database...
[⣯] Pulling schema from database...
[⣟] Pulling schema from database...
[⡿] Pulling schema from database...
[✓] Pulling schema from database...
│ 
│ Is customer_id column in subscriptions table created or renamed from another column?
│ ❯ + customer_id              create column                                         <--- second issue here
│   ~ customerId › customer_id rename column
└─ Done in 12.82 s

Any luck with the first part? How can we see the full output instead of last few lines? And, anyone having a similar problem with blocked inputs?