diff --git a/.changeset/tall-ads-lick.md b/.changeset/tall-ads-lick.md new file mode 100644 index 00000000..9fb4f99d --- /dev/null +++ b/.changeset/tall-ads-lick.md @@ -0,0 +1,5 @@ +--- +"composable-cli": patch +--- + +handle users entering a sentence case project name be always converting to kebab case diff --git a/packages/composable-cli/package.json b/packages/composable-cli/package.json index 065b7a44..42474300 100644 --- a/packages/composable-cli/package.json +++ b/packages/composable-cli/package.json @@ -28,6 +28,7 @@ "algoliasearch": "^4.20.0", "ansi-colors": "4.1.3", "boxen": "5", + "change-case": "4", "conf": "10.2.0", "find-up": "5", "ink": "3", diff --git a/packages/composable-cli/src/commands/generate/d2c/d2c-command.tsx b/packages/composable-cli/src/commands/generate/d2c/d2c-command.tsx index 2970adcb..3154450d 100644 --- a/packages/composable-cli/src/commands/generate/d2c/d2c-command.tsx +++ b/packages/composable-cli/src/commands/generate/d2c/d2c-command.tsx @@ -51,6 +51,7 @@ import { createEPPaymentsCommandHandler, isAlreadyExistsError, } from "../../payments/ep-payments/ep-payments-command" +import { paramCase } from "change-case" export function createD2CCommand( ctx: CommandContext, @@ -396,9 +397,11 @@ export function createD2CCommandHandler( } } + const kebabCaseName = paramCase(resolvedName!) + const createResult = await createApplicationKeys( ctx.requester, - `${resolvedName}-${new Date().toISOString()}`, + `${kebabCaseName}-${new Date().toISOString()}`, ) if (!createResult.success) { @@ -417,7 +420,7 @@ export function createD2CCommandHandler( ...gatheredOptions, epccClientId: client_id, epccClientSecret: client_secret, - name: resolvedName, + name: kebabCaseName, } } @@ -515,13 +518,10 @@ export function createD2CCommandHandler( ...args, }) - if (result.success) { + if (!result.success) { notes.push({ - title: "Algolia setup", - description: `Don't forget to add your Algolia index name to .env.local ${colors.bold.green( - `NEXT_PUBLIC_ALGOLIA_INDEX_NAME=${result.data.indexName}` ?? - "", - )}`, + title: "Algolia configuration failed", + description: `${result.error.code} - ${result.error.message} you can try rerunning with the composable-cli int algolia command`, }) } } diff --git a/yarn.lock b/yarn.lock index f197c0c2..0943daad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6997,7 +6997,7 @@ change-case-all@1.0.15: upper-case "^2.0.2" upper-case-first "^2.0.2" -change-case@^4.1.2: +change-case@4, change-case@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/change-case/-/change-case-4.1.2.tgz#fedfc5f136045e2398c0410ee441f95704641e12" integrity sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==