Repository navigation
feat(cli): add an audience flag to hide unreleased commands #7776
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fa02297
feat(cli): add an audience flag to hide unreleased commands
saddlepaddle 937a019
feat(cli): let a command's own audience override its group's
saddlepaddle bb15854
revert(desktop): drop the CLI audience override on plugin installs
saddlepaddle 06319bc
fix(cli): an internal node hides everything below it
saddlepaddle ae30e56
fix(desktop): run plugin CLI actions with the internal audience
saddlepaddle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import type { CommandConfig } from "./command"; | ||
| import { type CliCommand, type CliGroup, filterByAudience } from "./router"; | ||
|
|
||
| function cmd(path: string[], audience?: CommandConfig["audience"]): CliCommand { | ||
| return { | ||
| path, | ||
| command: { | ||
| description: path.join(" "), | ||
| audience, | ||
| run: async () => undefined, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| const paths = (items: { path: string[] }[]) => | ||
| items.map((item) => item.path.join(" ")); | ||
|
|
||
| describe("filterByAudience", () => { | ||
| const groups: CliGroup[] = [ | ||
| { path: ["plugins"], description: "Plugins", audience: "internal" }, | ||
| { | ||
| path: ["plugins", "author"], | ||
| description: "Authoring", | ||
| audience: "public", | ||
| }, | ||
| { path: ["tasks"], description: "Tasks" }, | ||
| { path: ["lab"], description: "Lab" }, | ||
| ]; | ||
| const commands = [ | ||
| cmd(["plugins", "list"]), | ||
| cmd(["plugins", "search"], "public"), | ||
| cmd(["plugins", "author", "init"]), | ||
| cmd(["tasks", "list"]), | ||
| cmd(["tasks", "purge"], "internal"), | ||
| cmd(["tasks", "purge", "all"]), | ||
| cmd(["lab", "try"], "internal"), | ||
| ]; | ||
| const publicView = filterByAudience(groups, commands, ["public"]); | ||
|
|
||
| it("shows only commands with no internal node in their chain", () => { | ||
| expect(paths(publicView.commands)).toEqual(["tasks list"]); | ||
| expect(paths(publicView.groups)).toEqual(["tasks"]); | ||
| }); | ||
|
|
||
| it("keeps everything under an internal group internal, even when tagged public", () => { | ||
| expect(paths(publicView.commands)).not.toContain("plugins search"); | ||
| expect(paths(publicView.commands)).not.toContain("plugins author init"); | ||
| }); | ||
|
|
||
| it("hides commands nested under an internal command", () => { | ||
| expect(paths(publicView.commands)).not.toContain("tasks purge all"); | ||
| }); | ||
|
|
||
| it("keeps everything when internal is enabled", () => { | ||
| const result = filterByAudience(groups, commands, ["internal", "public"]); | ||
| expect(paths(result.commands)).toEqual(paths(commands)); | ||
| expect(result.groups).toEqual(groups); | ||
| }); | ||
| }); |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export default { | ||
| audience: "internal", | ||
| description: "Inspect the environments cloud workspaces start from", | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export default { | ||
| audience: "internal", | ||
| description: "Inspect and call the tools your connected plugins expose", | ||
| }; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export default { | ||
| audience: "internal", | ||
| description: "Inspect the skills installed from plugins", | ||
| }; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.