Skip to content

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

Open
jomifepe wants to merge 11 commits intomainfrom
jp/repo-display-name
Open

feat: use --name as repository domain in repo create and init#180
jomifepe wants to merge 11 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
Changes repository creation/selection flow in prismic init and prismic repo create, which can affect onboarding behavior and error handling when creating or attaching to repos. Risk is moderate due to new validation and availability checks against remote services.

Overview
prismic repo create now requires --name and uses it as the repository domain (lowercased), with a new --display-name to set the human-readable label separately; it validates names via a shared repositoryNameSchema and fails early if the domain is unavailable.

prismic init now requires --repo, lowercases it, and will create the repository automatically when the user doesn’t already have access (after validating the name and checking domain availability); it only enforces Type Builder being enabled when connecting to an existing accessible repo. The command framework adds optional per-option Zod schema validation, and tests are updated to cover the new required/validation behaviors and repo cleanup.

Reviewed by Cursor Bugbot for commit b163f83. 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
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 b163f83. Configure here.

Comment thread src/commands/init.ts
);
}

const available = await checkIsDomainAvailable({ domain: repo, token, host });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant domain availability check in init flow

Low Severity

When init creates a new repo, checkIsDomainAvailable is called at init.ts line 115, then createRepo at line 131 calls it a second time internally at repo-create.ts line 60. This is a redundant HTTP request on every init --repo <new-name> run. The first check provides a contextual error message, and the second is a general safety check inside createRepo — but both hit the same API endpoint with the same arguments, with getAdapter() running in between.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b163f83. Configure here.

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.

1 participant