Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/early-lizards-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"create-cloudflare": patch
---

Minor improvements when using the `--existing-script scriptName` flag:

- Format the type as "Pre-existing Worker (from Dashboard)"
- Defaults the project name to `scriptName`
7 changes: 5 additions & 2 deletions packages/cli/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const leftT = gray(shapes.leftT);
export type Option = {
label: string;
value: string;
hidden?: boolean;
};

export type BasePromptConfig = {
Expand Down Expand Up @@ -69,7 +70,6 @@ export const inputPrompt = async (promptConfig: PromptConfig) => {
if (promptConfig.type === "select") {
prompt = new SelectPrompt({
...promptConfig,
options: (promptConfig as SelectPromptConfig).options,
initialValue: String(promptConfig.defaultValue),
render() {
return dispatchRender(this);
Expand Down Expand Up @@ -187,7 +187,10 @@ const getSelectRenderers = (config: SelectPromptConfig) => {

return [
`${blCorner} ${bold(question)} ${dim(helpText)}`,
`${options.map(renderOption).join(`\n`)}`,
`${options
.filter((o) => !o.hidden)
.map(renderOption)
.join(`\n`)}`,
``, // extra line for readability
];
};
Expand Down
10 changes: 6 additions & 4 deletions packages/create-cloudflare/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ export const runLatest = async () => {
export const runCli = async (args: Partial<C3Args>) => {
printBanner();

const defaultName = args.existingScript || C3_DEFAULTS.projectName;

const projectName = await processArgument<string>(args, "projectName", {
type: "text",
question: `In which directory do you want to create your application?`,
helpText: "also used as application name",
defaultValue: C3_DEFAULTS.projectName,
defaultValue: defaultName,
label: "dir",
validate: (value) =>
validateProjectDirectory(String(value) || C3_DEFAULTS.projectName, args),
Expand All @@ -92,9 +94,9 @@ export const runCli = async (args: Partial<C3Args>) => {
}
}

const templateOptions = Object.entries(templateMap)
.filter(([_, { hidden }]) => !hidden)
.map(([value, { label }]) => ({ value, label }));
const templateOptions = Object.entries(templateMap).map(
([value, { label, hidden }]) => ({ value, label, hidden })
);

const type = await processArgument<string>(args, "type", {
type: "select",
Expand Down