Skip to content

Commit

Permalink
feat: handle d2c project naming better (#82)
Browse files Browse the repository at this point in the history
* refactor: show failed note as algolia integration already adds env keys now

* feat: handle users entering a sentence case project name be always converting to kebab case

* chore: changeset
  • Loading branch information
field123 authored Oct 2, 2023
1 parent cb6ac41 commit a15a234
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-ads-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"composable-cli": patch
---

handle users entering a sentence case project name be always converting to kebab case
1 change: 1 addition & 0 deletions packages/composable-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
createEPPaymentsCommandHandler,
isAlreadyExistsError,
} from "../../payments/ep-payments/ep-payments-command"
import { paramCase } from "change-case"

export function createD2CCommand(
ctx: CommandContext,
Expand Down Expand Up @@ -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) {
Expand All @@ -417,7 +420,7 @@ export function createD2CCommandHandler(
...gatheredOptions,
epccClientId: client_id,
epccClientSecret: client_secret,
name: resolvedName,
name: kebabCaseName,
}
}

Expand Down Expand Up @@ -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`,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6997,7 +6997,7 @@ [email protected]:
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==
Expand Down

0 comments on commit a15a234

Please sign in to comment.