Skip to content

Conversation

@jzempel
Copy link
Member

@jzempel jzempel commented Nov 10, 2025

Description

This PR adds a new garden github-membership CLI, corresponding githubMembership API, and supporting documentation. See the new README for details.

Detail

Used locally to scrub the zendeskgarden membership list – so we know it works as advertised 😉

@jzempel jzempel requested a review from a team as a code owner November 10, 2025 21:23
};

(async () => {
const { success, failure } = await githubRelease(args);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { success, failure } = await githubRelease(args);
const { success, failure } = await githubMembership(args);

const org = (args.org || (await getRepository(args.path, args.spinner))?.owner)!;

if (args.users) {
const users = Array.isArray(args.users) ? args.users : [args.users];
Copy link
Contributor

@ze-flo ze-flo Nov 10, 2025

Choose a reason for hiding this comment

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

Isn't args.user always an array when defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, not when the CLI delivers a single user via garden github-membership -d jzempel


interface IGitHubMembershipArgs {
org?: string;
users?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
users?: string[];
users?: string | string[];

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah. For TS API usage, I think we want to force the developer to give us a string[]

const options = command.opts();
const results = await execute({
org: options.org,
users: options.delete,
Copy link
Contributor

Choose a reason for hiding this comment

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

About this comment.

I'm a little confused. If users only accepts string[] | undefined, TS would throw - unless options.delete is of type any. Is that the case here?

Copy link
Member Author

Choose a reason for hiding this comment

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

All commander.js options are of type any. The code we're swirling around here is simply a belt+suspenders mechanism to ensure users is being treated as the expected array and not turned into [j, z, e, m, p, e, l] for the limited corner case where the script would be used to delete one user. The intended & expected usage is bulk deletion. To say it another way:

  • CLI could naturally be used to delete one or more users (and the script ensures type safety)
  • API woud naturally be used to delete users in bulk

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like commander.js always returns an array for variadic options. I’ll leave it up to you whether it’s worth removing the defensive line on L47.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, seems like this was fixed in tj/commander.js#2410. I'll remove the over-aggressive defense.

const options = command.opts();
const results = await execute({
org: options.org,
users: options.delete,
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like commander.js always returns an array for variadic options. I’ll leave it up to you whether it’s worth removing the defensive line on L47.

@jzempel jzempel merged commit 2dfadd8 into main Nov 11, 2025
2 checks passed
@jzempel jzempel deleted the jzempel/github-membership branch November 11, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants