feat(workspaces): globs, --workspace, auto-add member (Phase 4)#29429
Merged
Conversation
73f2fc7 to
04b3856
Compare
Three ergonomics improvements for `workspace.json`-driven projects: - Glob members: entries in `workspace.json` can now be glob patterns (e.g. `programs/*`, `programs/**`) that expand to all directories containing a `program.json`. Non-package matches are silently skipped; literal entries still error on missing dirs; zero-match globs warn and continue. - `leo new --workspace`: scaffolds a fresh workspace skeleton - `<name>/workspace.json` with an empty `members` array. Conflicts with `--library` at the clap level. - Auto-add member: `leo new <name>` from within a workspace appends the new package to `workspace.json` unless the path is already covered by a literal entry or a glob. Outside-tree creations warn and skip. Adds `glob = "0.3"` to workspace deps, `Workspace::initialize_skeleton` and `Workspace::auto_register_member` to `leo-package`, plus 16 new workspace unit tests and 4 new CLI e2e tests. The shared workspace-level build directory sub-feature is deferred to a follow-up PR.
Cover the three Phase 4 ergonomics features in the workspaces guide and `leo new` reference: glob patterns in `workspace.json` (with the zero-match warning and literal-vs-glob precedence), `leo new --workspace` for scaffolding a workspace skeleton, and the auto-add behavior when `leo new` runs inside a workspace.
- pattern_matches_relative: match with require_literal_separator so `*` no longer crosses `/`, keeping it consistent with glob::glob expansion - auto_register_member: re-read workspace.json before the coverage check so a concurrently-modified manifest can't get a duplicate entry - load_member_record: reject literal member entries (e.g. `../sibling`) that canonicalize outside the workspace root, via a new workspace_member_outside_root error
…scovery - remove the now-unused `Workspace.manifest` field; its last reader went away when auto_register_member began re-reading the manifest from disk - add `discover_root` to locate a workspace root without resolving members, so auto_register_member (hence `leo new`) no longer fails when an unrelated existing member is broken; covered by a new regression test - generalize the workspace_member_outside_root help text (it also catches symlink escapes) and tighten its test to assert the specific error
`filter_stderr` normalized the per-test temp directory to `TMPDIR` with a regex that guessed the path shape, matching only a `$TMPDIR` directly under `/tmp` or the macOS `/var/folders` location. Under a nix-shell `$TMPDIR` (`/tmp/nix-shell.XXXXXX/...`) it matched nothing, leaving absolute paths in `cli_test_ambiguous_package` and `cli_test_duplicate_lib_name` output. Replace the regex with a literal substitution of the harness's known temp directory - and its canonicalized form, since leo canonicalizes paths before printing them - with `TMPDIR`.
b9f847d to
d8e9807
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three ergonomics improvements for
workspace.json-driven projects:workspace.jsoncan now be glob patterns (e.g.programs/*,programs/**) that expand to all directories containing aprogram.json. Non-package matches are silently skipped; literal entries still error on missing dirs; zero-match globs warn and continue.leo new --workspace: scaffolds a fresh workspace skeleton -<name>/workspace.jsonwith an emptymembersarray. Conflicts with--libraryat the clap level.leo new <name>from within a workspace appends the new package toworkspace.jsonunless the path is already covered by a literal entry or a glob. Outside-tree creations warn and skip.Adds
glob = "0.3"to workspace deps,Workspace::initialize_skeletonandWorkspace::auto_register_membertoleo-package, plus 16 new workspace unit tests and 4 new CLI e2e tests.The shared workspace-level build directory sub-feature is deferred to a follow-up PR.
Part of #29140