feat(organizations): add CRUD commands for organizations#762
feat(organizations): add CRUD commands for organizations#762
Conversation
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…pe guard Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds `organizations update` command with --name, --slug, and --default-role flags. Includes tests for success, validation (no flags), missing arg, and API error cases. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Remove export from Organization and OrganizationDeleteResponse interfaces as they are only used internally within the service module. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Wire up topic aliases (organization, organisations, organisation, org, orgs) in topicAliases.ts and oclif.config.js. Fix linter-reported import and property ordering in org command files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @mttdnt's task in 1m 50s —— View job Review
1.
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(input) && !/^[a-z0-9]$/.test(input)) {
return 'Organization slug may only contain lowercase letters, numbers, and hyphens'
}2. Misleading "User cancelled" error in
} catch (error) {
deleteOrgDebug(`User cancelled or input error`, error)
this.error(getErrorMessage(error), {exit: 1})
}3. Falsy check in
body: {name, ...(defaultRoleName !== undefined ? {defaultRoleName} : {})},4.
|
Coverage Delta
Comparing 8 changed files against main @ Overall Coverage
|
fe45e78 to
740971e
Compare
…d patterns closer
📦 Bundle Stats —
|
| Metric | Value | vs main (133be82) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.95 MB | -120.3 KB, -1.1% |
| Bundled (gzip) | 2.06 MB | -20.4 KB, -1.0% |
| Import time | 830ms | +830ms, +0.0% |
bin:sanity
| Metric | Value | vs main (133be82) |
|---|---|---|
| Internal (raw) | 975 B | - |
| Internal (gzip) | 460 B | - |
| Bundled (raw) | 9.84 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.97s | +1.64s, +501.7% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against main (133be82f)
| Metric | Value | vs main (133be82) |
|---|---|---|
| Internal (raw) | 92.3 KB | +3.2 KB, +3.5% |
| Internal (gzip) | 21.6 KB | +822 B, +3.9% |
| Bundled (raw) | 21.53 MB | -115.9 KB, -0.5% |
| Bundled (gzip) | 3.41 MB | -19.7 KB, -0.6% |
| Import time | 786ms | +786ms, +0.0% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against main (133be82f)
| Metric | Value | vs main (133be82) |
|---|---|---|
| Internal (raw) | 976 B | - |
| Internal (gzip) | 507 B | - |
| Bundled (raw) | 50.7 KB | - |
| Bundled (gzip) | 12.6 KB | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Coverage Delta
Comparing 11 changed files against main @ Overall Coverage
|
| }) | ||
|
|
||
| for (const {id, name, slug} of organizations) { | ||
| table.addRow({id, name, slug: slug ?? '-'}) |
There was a problem hiding this comment.
Not sure if anything else is needing to be displayed
Coverage Delta
Comparing 11 changed files against main @ Overall Coverage
|
…or throwing errors
Description
Adds a new
organizationstopic to the CLI with five commands for managing organizations:sanity organizations list- list all organizations you're a member ofsanity organizations get <organizationId>- show details of a specific organizationsanity organizations create- create a new organization (interactive or--name/--default-roleflags)sanity organizations update <organizationId>- update name, slug, or default rolesanity organizations delete <organizationId>- delete an organization (with confirmation prompt)Hidden topic aliases so all of these also work:
organization,organisations,organisation,org,orgs. Uses the two-layer alias approach from #714 (hiddenAliaseson each command class +topicAliases.tsentry).What to review
src/services/organizations.ts- extended withgetOrganization,updateOrganization,deleteOrganization;createOrganizationnow accepts optionaldefaultRoleName; fixedProjectOrganization.slugto bestring | nullsrc/commands/organizations/- five command files, all thin: parse flags, call service, format outputsrc/util/apiError.ts- sharedhasStatusCodetype guard to avoidasassertions in catch blockssrc/topicAliases.tsandoclif.config.js- alias wiring for theorganizationstopicsrc/commands/organizations/__tests__/- 23 tests across all five commandsTesting
getGlobalCliClient), no service file mocksif (error) throw error; error tests asserttoBeInstanceOf(Error)+ messageNotes
--slugflag only onupdate, notcreate- the API requires theauthSAMLfeature for slugs, which a brand-new org won't havedeleteblocks server-side if the org has associated projects - the command surfaces that API error clearlyorganizations members list/invite) are deferred pending internal discussion