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

feat(monorepo): prefix output with package name #1378

Merged
merged 15 commits into from
Dec 12, 2023
Merged

Conversation

wemeetagain
Copy link
Member

In the monorepo commands (exec, releaseRc, and run), prefix each line of output from each subpackage with the name of the package where the command is running.
This can be disabled by providing the --noPrefix cli arg.

  • prerequisite for Enable parallel script runs #1375
    • running scripts in parallel results in interleaved lines of output. So each line of output needs to be associated in some way with the package where it's running.

@wemeetagain
Copy link
Member Author

@achingbrain
Copy link
Member

I've opened bbc/typescript-docs-verifier#30

Quick fix: #1380

@achingbrain
Copy link
Member

This looks interesting, it should probably default to prefixing scripts run in monorepo projects and not prefixing tasks run in regular projects?

It could use some tests to verify this too.

@wemeetagain
Copy link
Member Author

Ah, so run, exec are monorepo-only, but releaseRc can be used in monorepo or non-monorepo.

@wemeetagain
Copy link
Member Author

It could use some tests to verify [that the prefix isn't added in non-monorepo contexts] too.

run and exec are monorepo-only.
releaseRc is implemented in monorepo and non-monorepo functions separately: releaseMonorepoRcs and releaseRc.

Not sure that a test is needed for this.

@wemeetagain
Copy link
Member Author

@achingbrain ready for re-review

src/utils.js Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I added some tests because I got bored of testing things manually like an animal - it looks like the output for aegir run is getting double-prefixed. It may be something to do with the child process inheriting stdin/out, needs a bit of investigation.

@achingbrain
Copy link
Member

Relevant: sindresorhus/execa#121

@achingbrain
Copy link
Member

I stole the way lerna does it, using strong-long-transformer.

Copy link
Member Author

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wemeetagain
Copy link
Member Author

This fails on my local machine

exec
    1) should prefix monorepo output with the project name


  50 passing (1m)
  3 pending
  1 failing

  1) exec
       should prefix monorepo output with the project name:

      AssertionError: expected '\na-workspace-project: > ls\na-worksp…' to equal '\nanother-workspace-project: > ls\nan…'
      + expected - actual

       
      +another-workspace-project: > ls
      +another-workspace-project: package.json
      +another-workspace-project: src
      +another-workspace-project: tsconfig.json
      +another-workspace-project: typedoc.json
      +
       a-workspace-project: > ls
       a-workspace-project: package.json
       a-workspace-project: src
       a-workspace-project: tsconfig.json
      -a-workspace-project: typedoc.json
      -
      -another-workspace-project: > ls
      -another-workspace-project: package.json
      -another-workspace-project: src
      -another-workspace-project: tsconfig.json
      -another-workspace-project: typedoc.json
      +a-workspace-project: typedoc.json
      
      at Context.<anonymous> (file:///home/cayman/Code/aegir/test/exec.js:32:30)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

@achingbrain
Copy link
Member

Hmm, weird that it works in CI?

@wemeetagain
Copy link
Member Author

It seems that the glob code emits directories in a different order depending on... ?.

Maybe we can add a package dependency in the monorepo test fixture to ensure the ordering.

@wemeetagain
Copy link
Member Author

ready for re-review

Copy link
Member Author

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wemeetagain wemeetagain merged commit 5ffac14 into master Dec 12, 2023
19 checks passed
@wemeetagain wemeetagain deleted the feat/prefix-output branch December 12, 2023 19:49
github-actions bot pushed a commit that referenced this pull request Dec 12, 2023
## [41.2.0](v41.1.14...v41.2.0) (2023-12-12)

### Features

* **monorepo:** prefix output with package name ([#1378](#1378)) ([5ffac14](5ffac14))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants