refactor(projects:create): usability improvements#945
Conversation
|
Claude finished @mttdnt's task in 2m 24s —— View job PR Review
Issues1. Missing changeset This PR changes user-facing behavior in
A 2. description:
'Skip prompts and use defaults (project: "My Sanity Project", dataset: production, visibility: public)',The description still mentions 3. const existingDatasets = await listDatasets(projectId) // always called
const existingDatasetNames = existingDatasets.map(...)
if (!datasetName && !this.isUnattended()) { // only needed here
// ...may call promptForDatasetName({}, existingDatasetNames)
}
if (!datasetName && !this.isUnattended()) {
const existingDatasets = await listDatasets(projectId)
const existingDatasetNames = existingDatasets.map((ds) => ds.name)
// ... rest of interactive flow
}4. The file at repo root is a design artifact / usability study. It references implementation details, describes old code (e.g. the |
📦 Bundle Stats —
|
| Metric | Value | vs main (82dbcc6) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.94 MB | - |
| Bundled (gzip) | 2.05 MB | - |
| Import time | 826ms | -1ms, -0.2% |
bin:sanity
| Metric | Value | vs main (82dbcc6) |
|---|---|---|
| Internal (raw) | 975 B | - |
| Internal (gzip) | 460 B | - |
| Bundled (raw) | 9.84 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.97s | +15ms, +0.8% |
🗺️ 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 (82dbcc60)
| Metric | Value | vs main (82dbcc6) |
|---|---|---|
| Internal (raw) | 93.8 KB | - |
| Internal (gzip) | 21.9 KB | - |
| Bundled (raw) | 21.62 MB | - |
| Bundled (gzip) | 3.42 MB | - |
| Import time | 788ms | +9ms, +1.1% |
🗺️ 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 (82dbcc60)
| Metric | Value | vs main (82dbcc6) |
|---|---|---|
| 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 4 changed files against main @ Overall Coverage
|
…imitives Extract organization resolution from the monolithic getOrganization action into reusable primitives that projects:create composes directly: - resolveOrganizationById: pure function for --organization flag lookup - promptForOrganization: prompt-layer org selection with grant-aware display - promptForNewOrganization: create-first-org flow This moves spinner/UI concerns into the command and keeps actions focused on business logic. Reverts getOrganization.ts and init.ts to main state so this change is scoped to projects:create only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
No callers remain — init imports the individual pieces directly, and projects:create now composes primitives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move resolveOrganizationById inside the spinner try/catch so the spinner shows a failure mark instead of a false checkmark when the requested organization is not found. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4414b18 to
8466e10
Compare
…itives Both `datasets create` and `projects create` now compose `determineDatasetAclMode` + `createDataset` service directly instead of going through the bundled action. Spinners and success logs live in the commands. Also fixes `projects create` not passing `forcePublic` when user picks default config — visibility prompt was shown regardless. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
--yesrequires project name — no more silent "My Sanity Project" in CI--datasetuses sharedgetDatasetFlag— consistent with other commands--dataset-visibilitydeclaresdependsOn: ['dataset']— oclif enforces the relationshipwarningsarray for partial failureslistOrganizations→resolveOrganizationById→promptForOrganizationinstead of monolithicgetOrganizationaction. Spinner lives in the command.Test plan
sanity projects createinteractive flow works end-to-endsanity projects create "My Project" --yes --organization=<org>workssanity projects create "My Project" --jsonreturns complete JSON--dataset-visibilitywithout--dataseterrors--yeswithout project name errors🤖 Generated with Claude Code