Skip to content

feat: use --name as repository domain in repo create and init#180

Merged
jomifepe merged 25 commits intomainfrom
jp/repo-display-name
May 8, 2026
Merged

feat: use --name as repository domain in repo create and init#180
jomifepe merged 25 commits intomainfrom
jp/repo-display-name

Conversation

@jomifepe
Copy link
Copy Markdown
Contributor

@jomifepe jomifepe commented May 7, 2026

Summary

  • prismic repo create --name now sets the repository domain (URL slug), not just the display label. Previously the domain was a random 8-char hex string regardless of --name.
  • Adds --display-name (-d) on repo create to control the human-readable label separately, matching the dashboard's two-field model.
  • --name is required on repo create and validated against the same rule API uses: 4–63 chars, ^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$. Invalid input errors with guidance. Valid input is lowercased before submitting (API lowercases server-side).
  • prismic init --repo <name> now creates the repository if it doesn't already exist in your account (and is available). If the name is taken by another account, it errors clearly.

How to QA [^1]

  • npx prismic@pr-180 repo create --name my-test-repo → Creates a repo at my-test-repo
  • npx prismic@pr-180 repo create --name foo-bar --display-name "Foo Bar" → Sets domain foo-bar and label Foo Bar in the dashboard
  • npx prismic@pr-180 repo create --name "My Test Repo" → Errors with validation guidance (spaces are not allowed)
  • npx prismic@pr-180 repo create --name "!!" → Errors with validation guidance
  • npx prismic@pr-180 init --repo my-new-repo in a fresh project → Creates my-new-repo and writes it to prismic.config.json
  • npx prismic@pr-180 init --repo prismic → Errors (name taken by another account)
  • npx prismic@pr-180 init → Errors asking for --repo

🤖 Generated with Claude Code


Note

Medium Risk
Medium risk because it changes core CLI flows for init and repo create, including input validation and repository creation behavior, which could break existing scripts or expectations around repo naming and provisioning.

Overview
Repository creation now uses user-provided names as the domain. prismic repo create requires --name, validates it (length/charset), lowercases it, checks availability, and uses it as the repository domain; the human-friendly label is now optionally provided via --display-name.

prismic init now requires --repo and will auto-provision. The command lowercases/validates the provided repo name, creates the repository if it isn’t already in the user’s account (and is available), and improves error messages for missing/invalid/taken names. Option parsing gained optional per-flag zod schemas to enforce validation consistently, and tests were updated to cover the new behaviors and cleanup.

Reviewed by Cursor Bugbot for commit 428aab2. Bugbot is set up for automated code reviews on this repo. Configure here.

Previously `--name` was only sent as the display label while the domain
was a random 8-char hex slug. The dashboard API accepts a caller-chosen
domain, so derive it from user input (kebab-cased) and add a separate
`--display-name` flag for the label.

- `--name` is now required and defines the domain
- Adds `--display-name` to set the display label (defaults to `--name`)
- Validates the domain against the dashboard rule before POSTing
- `prismic init` requires `--name` unless `--repo` is provided

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jomifepe jomifepe self-assigned this May 7, 2026
@jomifepe jomifepe marked this pull request as ready for review May 7, 2026 14:52
@jomifepe jomifepe changed the title fix: use --name as repository domain in repo create and init feat: use --name as repository domain in repo create and init May 7, 2026
Drop the silent kebab-casing of --name. Validate it directly against
the dashboard rule and error with guidance when it doesn't match.
Users pass the exact domain they want.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment thread src/commands/repo-create.ts Outdated
jomifepe and others added 4 commits May 7, 2026 16:23
Accept uppercase letters in --name to match the server-side rule
exactly (`^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$`). Wroom lowercases
the domain server-side, so any value the CLI accepts will be accepted
by the API.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wroom lowercases the domain server-side. If the user passes `MyRepo`,
the CLI was printing `Repository created: MyRepo` and `URL: https://MyRepo.prismic.io/`,
both wrong. Lowercase after validation so the displayed output matches
what was actually created.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
init is about connecting a project to a repository. Drop the --name/--display-name
options added to init — repo creation with a custom display label belongs
on `prismic repo create`. Instead, if --repo points to a domain the user
doesn't have access to, check if it's available and create it with that name;
if it's taken by another account, error clearly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Keep the original shape of the access check; just branch on availability
when the user lacks access, and thread the name into createRepo.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment thread src/commands/init.ts Outdated
It's only used in one place (the createRepo function), so it doesn't
need its own lib file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment thread src/commands/init.ts Outdated
Comment thread src/commands/init.ts
Comment thread src/commands/init.ts Outdated
Comment thread src/commands/init.ts Outdated
Comment thread src/commands/init.ts Outdated
Comment thread src/commands/init.ts Outdated
Comment thread src/commands/init.ts Outdated
@jomifepe jomifepe force-pushed the jp/repo-display-name branch from 29d904b to 8f2be73 Compare May 8, 2026 15:53
@jomifepe jomifepe force-pushed the jp/repo-display-name branch from 8f2be73 to e28f384 Compare May 8, 2026 15:54
Comment thread test/repo-create.test.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2896d8f. Configure here.

Comment thread src/commands/init.ts
@jomifepe jomifepe merged commit 1b7e4bf into main May 8, 2026
13 checks passed
@jomifepe jomifepe deleted the jp/repo-display-name branch May 8, 2026 17:05
@github-actions github-actions Bot mentioned this pull request May 8, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants