File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,20 @@ const PLATFORMS = [
5959 "elixir" ,
6060] as const ;
6161
62+ /**
63+ * Convert a project name to its expected Sentry slug.
64+ * Sentry slugs are lowercase, with non-alphanumeric runs replaced by hyphens.
65+ *
66+ * @example slugify("My Cool App") // "my-cool-app"
67+ * @example slugify("my-app") // "my-app"
68+ */
69+ function slugify ( name : string ) : string {
70+ return name
71+ . toLowerCase ( )
72+ . replace ( / [ ^ a - z 0 - 9 ] + / g, "-" )
73+ . replace ( / ^ - | - $ / g, "" ) ;
74+ }
75+
6276/** Check whether an API error is about an invalid platform value */
6377function isPlatformError ( error : ApiError ) : boolean {
6478 const detail = error . detail ?? error . message ;
@@ -150,9 +164,10 @@ async function createProjectWithErrors(
150164 } catch ( error ) {
151165 if ( error instanceof ApiError ) {
152166 if ( error . status === 409 ) {
167+ const slug = slugify ( name ) ;
153168 throw new CliError (
154169 `A project named '${ name } ' already exists in ${ orgSlug } .\n\n` +
155- `View it: sentry project view ${ orgSlug } /${ name } `
170+ `View it: sentry project view ${ orgSlug } /${ slug } `
156171 ) ;
157172 }
158173 if ( error . status === 400 && isPlatformError ( error ) ) {
You can’t perform that action at this time.
0 commit comments