这是indexloc提供的服务,不要输入任何密码
Skip to content

refactor: compile args + config to opts #9552

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

Merged
merged 4 commits into from
Dec 4, 2024
Merged

Conversation

NicholasLYang
Copy link
Contributor

@NicholasLYang NicholasLYang commented Dec 2, 2024

Description

Refactors our config setup to explicitly transform the Args and Config to Opts in the CommandBase constructor. This accomplishes a few things:

  • Limits our usage of args beyond cli. Args are structured according to the CLI parsing logic, so there are multiple fields that do the same thing (args.command.run_args and args.run_args). By compiling down to Opts, we can use a more normalized structure.
  • Remove the requirement that we have a Command::Run to create a Run struct. This requires us to mock out a Command::Run in places like query or ls, which is unnecessary.
  • Fix a potential nasty bug where we change the Args struct via CommandBase::args_mut but that change is not propagated to the config because it's cached via a OnceCell.
  • Finally, and most importantly, allow us to construct a Run without Args. This is very important for query.

However, this does create a change where CommandBase::new is now fallible. Overall this is fine, but it does mean that we sometimes error earlier than before. I couldn't figure out an alternative without making Config reactive on any Args change

Testing Instructions

Copy link

vercel bot commented Dec 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 7:45pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 7:45pm

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Great step to cleaning up this logic.

Only blocker is the change to turbo ls flag behavior.

filter,
packages,
output,
packages, output, ..
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a change in the wrong direction. We're now only respecting --affected if it comes from an implicit run commande.g.turbo --affected lsand ignoring the flag if it comes from thelssubcommand:turbo ls --affected`.

Plug for #9445 which prevents the former from happening

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I did this correctly, I think I moved the logic here.

Copy link
Member

Choose a reason for hiding this comment

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

Huh, looks like this is an existing bug? Not sure what's happening here:

[1 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo --version    
 WARNING  No locally installed `turbo` found. Using version: 2.3.4-canary.0.
2.3.4-canary.0
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo ls --affected
 WARNING  No locally installed `turbo` found. Using version: 2.3.4-canary.0.
turbo 2.3.4-canary.0

 WARNING  ls command is experimental and may change in the future
0 no packages (pnpm)

[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo --affected ls           
 WARNING  No locally installed `turbo` found. Using version: 2.3.4-canary.0.
turbo 2.3.4-canary.0

 WARNING  ls command is experimental and may change in the future
37 packages (pnpm)

  @turbo-internal/top-issues-gh-action packages/top-issues
  @turbo/benchmark packages/turbo-benchmark
  @turbo/codemod packages/turbo-codemod
  @turbo/eslint-config packages/eslint-config
  @turbo/exe-stub packages/turbo-exe-stub
  @turbo/gen packages/turbo-gen
  @turbo/telemetry packages/turbo-telemetry
  @turbo/test-utils packages/turbo-test-utils
  @turbo/tsconfig packages/tsconfig
  @turbo/types packages/turbo-types
  @turbo/utils packages/turbo-utils
  @turbo/workspaces packages/turbo-workspaces
  @turborepo-examples-tests/basic turborepo-tests/example-basic
  @turborepo-examples-tests/design-system turborepo-tests/example-design-system
  @turborepo-examples-tests/kitchen-sink turborepo-tests/example-kitchen-sink
  @turborepo-examples-tests/non-monorepo turborepo-tests/example-non-monorepo
  @turborepo-examples-tests/with-berry turborepo-tests/example-with-berry
  @turborepo-examples-tests/with-changesets turborepo-tests/example-with-changesets
  @turborepo-examples-tests/with-npm turborepo-tests/example-with-npm
  @turborepo-examples-tests/with-react-native-web turborepo-tests/example-with-react-native-web
  @turborepo-examples-tests/with-rollup turborepo-tests/example-with-rollup
  @turborepo-examples-tests/with-svelte turborepo-tests/example-with-svelte
  @turborepo-examples-tests/with-tailwind turborepo-tests/example-with-tailwind
  @turborepo-examples-tests/with-vite turborepo-tests/example-with-vite
  @turborepo-examples-tests/with-yarn turborepo-tests/example-with-yarn
  cargo-sweep-action .github/actions/cargo-sweep
  cli cli
  create-turbo packages/create-turbo
  eslint-config-turbo packages/eslint-config-turbo
  eslint-plugin-turbo packages/eslint-plugin-turbo
  prysk packages/prysk
  turbo-ignore packages/turbo-ignore
  turbo-vsc packages/turbo-vsc
  turborepo-examples examples
  turborepo-repository packages/turbo-repository
  turborepo-tests-helpers turborepo-tests/helpers
  turborepo-tests-integration turborepo-tests/integration
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo_dev ls --affected
 WARNING  No locally installed `turbo` found. Using version: 2.3.3.
turbo 2.3.3

 WARNING  ls command is experimental and may change in the future
0 no packages (pnpm)

[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo_dev --affected ls           
 WARNING  No locally installed `turbo` found. Using version: 2.3.3.
turbo 2.3.3

 WARNING  ls command is experimental and may change in the future
37 packages (pnpm)

  @turbo-internal/top-issues-gh-action packages/top-issues
  @turbo/benchmark packages/turbo-benchmark
  @turbo/codemod packages/turbo-codemod
  @turbo/eslint-config packages/eslint-config
  @turbo/exe-stub packages/turbo-exe-stub
  @turbo/gen packages/turbo-gen
  @turbo/telemetry packages/turbo-telemetry
  @turbo/test-utils packages/turbo-test-utils
  @turbo/tsconfig packages/tsconfig
  @turbo/types packages/turbo-types
  @turbo/utils packages/turbo-utils
  @turbo/workspaces packages/turbo-workspaces
  @turborepo-examples-tests/basic turborepo-tests/example-basic
  @turborepo-examples-tests/design-system turborepo-tests/example-design-system
  @turborepo-examples-tests/kitchen-sink turborepo-tests/example-kitchen-sink
  @turborepo-examples-tests/non-monorepo turborepo-tests/example-non-monorepo
  @turborepo-examples-tests/with-berry turborepo-tests/example-with-berry
  @turborepo-examples-tests/with-changesets turborepo-tests/example-with-changesets
  @turborepo-examples-tests/with-npm turborepo-tests/example-with-npm
  @turborepo-examples-tests/with-react-native-web turborepo-tests/example-with-react-native-web
  @turborepo-examples-tests/with-rollup turborepo-tests/example-with-rollup
  @turborepo-examples-tests/with-svelte turborepo-tests/example-with-svelte
  @turborepo-examples-tests/with-tailwind turborepo-tests/example-with-tailwind
  @turborepo-examples-tests/with-vite turborepo-tests/example-with-vite
  @turborepo-examples-tests/with-yarn turborepo-tests/example-with-yarn
  cargo-sweep-action .github/actions/cargo-sweep
  cli cli
  create-turbo packages/create-turbo
  eslint-config-turbo packages/eslint-config-turbo
  eslint-plugin-turbo packages/eslint-plugin-turbo
  prysk packages/prysk
  turbo-ignore packages/turbo-ignore
  turbo-vsc packages/turbo-vsc
  turborepo-examples examples
  turborepo-repository packages/turbo-repository
  turborepo-tests-helpers turborepo-tests/helpers
  turborepo-tests-integration turborepo-tests/integration

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Since it's an already existing bug, we can 🚢 , but very confused as to what's happening. Repro by checking out this branch and using turbo ls --affected

@NicholasLYang NicholasLYang merged commit a7516dc into main Dec 4, 2024
42 checks passed
@NicholasLYang NicholasLYang deleted the refactor/always-use-opts branch December 4, 2024 17:48
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