create-cloudflare 0.0.0-6b859a45 → 0.0.0-775eb3bd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -52612,7 +52612,9 @@ var require_typescript2 = __commonJS({
52612
52612
  // src/cli.ts
52613
52613
  var cli_exports = {};
52614
52614
  __export(cli_exports, {
52615
- main: () => main
52615
+ C3_DEFAULTS: () => C3_DEFAULTS,
52616
+ main: () => main,
52617
+ parseArgs: () => parseArgs
52616
52618
  });
52617
52619
  module.exports = __toCommonJS(cli_exports);
52618
52620
  var import_haikunator = __toESM(require_dist_node());
@@ -54347,174 +54349,165 @@ var logUpdateStderr = createLogUpdate(import_node_process6.default.stderr);
54347
54349
  var grayBar = gray(shapes.bar);
54348
54350
  var blCorner = gray(shapes.corners.bl);
54349
54351
  var leftT = gray(shapes.leftT);
54350
- var textInput = async (opts) => {
54351
- const { renderSubmitted, question, defaultValue, validate, acceptDefault } = opts;
54352
- const helpText = opts.helpText || ``;
54353
- const format3 = opts.format || ((val) => val);
54354
- const prompt = new oD({
54355
- defaultValue,
54356
- validate,
54357
- render() {
54358
- let body = "";
54359
- switch (this.state) {
54360
- case "initial":
54361
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54362
- `;
54363
- body += `${space(2)}${gray(format3(defaultValue))}
54364
- `;
54365
- break;
54366
- case "active":
54367
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54368
- `;
54369
- body += `${space(2)}${format3(this.value || dim(defaultValue))}
54370
- `;
54371
- break;
54372
- case "submit":
54373
- body += `${leftT} ${question}
54374
- `;
54375
- body += `${grayBar} ${renderSubmitted(
54376
- format3(this.value)
54377
- )}
54378
- ${grayBar}`;
54379
- break;
54380
- case "error":
54381
- body += `${leftT} ${status.error} ${dim(this.error)}
54382
- `;
54383
- body += `${grayBar}
54384
- `;
54385
- body += `${blCorner} ${question} ${dim(helpText)}
54386
- `;
54387
- body += `${space(2)}${format3(this.value)}
54388
- `;
54389
- break;
54390
- default:
54391
- break;
54392
- }
54393
- return body;
54394
- }
54395
- });
54396
- let value;
54397
- if (acceptDefault) {
54398
- logRaw(`${leftT} ${question}`);
54399
- logRaw(`${grayBar} ${renderSubmitted(defaultValue)}
54400
- ${grayBar}`);
54401
- value = defaultValue;
54402
- validate?.(value);
54403
- } else {
54404
- value = await prompt.prompt();
54405
- if (eD(value)) {
54406
- cancel("Operation cancelled.");
54407
- process.exit(0);
54408
- }
54409
- }
54352
+ var processArgument = async (args, name, promptConfig) => {
54353
+ let value = args[name];
54354
+ const renderSubmitted = getRenderers(promptConfig).submit;
54355
+ if (value !== void 0) {
54356
+ promptConfig.validate?.(value);
54357
+ const lines = renderSubmitted({ value });
54358
+ logRaw(lines.join("\n"));
54359
+ return value;
54360
+ }
54361
+ value = await inputPrompt(promptConfig);
54410
54362
  return value;
54411
54363
  };
54412
- var selectInput = async (opts) => {
54413
- const { question, options, renderSubmitted, defaultValue, acceptDefault } = opts;
54414
- const helpText = opts.helpText || ``;
54415
- const prompt = new ED({
54416
- options,
54417
- initialValue: defaultValue ?? options[0].value,
54418
- render() {
54419
- const renderOption = (opt, i) => {
54420
- const { label } = opt;
54421
- const active = i === this.cursor;
54422
- const text = active ? blue.underline(label) : dim(label);
54423
- const indicator = active ? blue(shapes.radioActive) : dim(shapes.radioInactive);
54424
- return `${space(2)}${indicator} ${text}`;
54425
- };
54426
- let body = ``;
54427
- switch (this.state) {
54428
- case "submit":
54429
- body += `${leftT} ${question}
54430
- `;
54431
- body += `${grayBar} ${renderSubmitted(options[this.cursor])}`;
54432
- body += `
54433
- ${grayBar}`;
54434
- break;
54435
- default:
54436
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54437
- `;
54438
- body += `${options.map(renderOption).join(`
54439
- `)}
54440
- `;
54441
- break;
54364
+ var inputPrompt = async (promptConfig) => {
54365
+ const renderers = getRenderers(promptConfig);
54366
+ let prompt;
54367
+ const dispatchRender = (props) => {
54368
+ const renderedLines = renderers[props.state](props);
54369
+ return renderedLines.join("\n");
54370
+ };
54371
+ if (promptConfig.type === "select") {
54372
+ prompt = new ED({
54373
+ ...promptConfig,
54374
+ options: promptConfig.options,
54375
+ initialValue: String(promptConfig.defaultValue),
54376
+ render() {
54377
+ return dispatchRender(this);
54442
54378
  }
54443
- return body;
54444
- }
54445
- });
54446
- let value;
54447
- if (acceptDefault) {
54448
- logRaw(`${leftT} ${question}`);
54449
- logRaw(
54450
- `${grayBar} ${renderSubmitted({
54451
- label: defaultValue,
54452
- value: defaultValue
54453
- })}`
54454
- );
54455
- logRaw(`${grayBar}`);
54456
- value = defaultValue;
54379
+ });
54380
+ } else if (promptConfig.type === "confirm") {
54381
+ prompt = new sD({
54382
+ ...promptConfig,
54383
+ initialValue: Boolean(promptConfig.defaultValue),
54384
+ active: promptConfig.activeText || "",
54385
+ inactive: promptConfig.inactiveText || "",
54386
+ render() {
54387
+ return dispatchRender(this);
54388
+ }
54389
+ });
54457
54390
  } else {
54458
- value = await prompt.prompt();
54459
- if (eD(value)) {
54460
- cancel("Operation cancelled.");
54461
- process.exit(0);
54462
- }
54391
+ prompt = new oD({
54392
+ ...promptConfig,
54393
+ defaultValue: String(promptConfig.defaultValue),
54394
+ render() {
54395
+ return dispatchRender(this);
54396
+ }
54397
+ });
54463
54398
  }
54464
- return value;
54399
+ const input = await prompt.prompt();
54400
+ if (eD(input)) {
54401
+ cancel("Operation cancelled.");
54402
+ process.exit(0);
54403
+ }
54404
+ return input;
54465
54405
  };
54466
- var confirmInput = async (opts) => {
54406
+ var renderSubmit = (config14, value) => {
54407
+ const { question, label } = config14;
54408
+ const content = config14.type === "confirm" ? `${grayBar} ${brandColor(value)} ${dim(label)}` : `${grayBar} ${brandColor(label)} ${dim(value)}`;
54409
+ return [`${leftT} ${question}`, content, `${grayBar}`];
54410
+ };
54411
+ var handleCancel = () => {
54412
+ cancel("Operation cancelled.");
54413
+ process.exit(0);
54414
+ };
54415
+ var getRenderers = (config14) => {
54416
+ switch (config14.type) {
54417
+ case "select":
54418
+ return getSelectRenderers(config14);
54419
+ case "confirm":
54420
+ return getConfirmRenderers(config14);
54421
+ case "text":
54422
+ return getTextRenderers(config14);
54423
+ }
54424
+ };
54425
+ var getTextRenderers = (config14) => {
54467
54426
  const {
54468
- activeText,
54469
- inactiveText,
54427
+ defaultValue,
54470
54428
  question,
54471
- renderSubmitted,
54472
- defaultValue = true,
54473
- acceptDefault
54474
- } = opts;
54475
- const helpText = opts.helpText || `(y/n)`;
54429
+ helpText: _helpText,
54430
+ format: _format
54431
+ } = config14;
54432
+ const helpText = _helpText ?? "";
54433
+ const format3 = _format ?? ((val) => String(val));
54434
+ return {
54435
+ initial: () => [
54436
+ `${blCorner} ${bold(question)} ${dim(helpText)}`,
54437
+ `${space(2)}${gray(format3(defaultValue))}`,
54438
+ ``
54439
+ // extra line for readability
54440
+ ],
54441
+ active: ({ value }) => [
54442
+ `${blCorner} ${bold(question)} ${dim(helpText)}`,
54443
+ `${space(2)}${format3(value || dim(defaultValue))}`,
54444
+ ``
54445
+ // extra line for readability
54446
+ ],
54447
+ error: ({ value, error }) => [
54448
+ `${leftT} ${status.error} ${dim(error)}`,
54449
+ `${grayBar}`,
54450
+ `${blCorner} ${question} ${dim(helpText)}`,
54451
+ `${space(2)}${format3(value)}`,
54452
+ ``
54453
+ // extra line for readability
54454
+ ],
54455
+ submit: ({ value }) => renderSubmit(config14, format3(value)),
54456
+ cancel: handleCancel
54457
+ };
54458
+ };
54459
+ var getSelectRenderers = (config14) => {
54460
+ const { options, question, helpText: _helpText } = config14;
54461
+ const helpText = _helpText ?? "";
54462
+ const defaultRenderer = ({ cursor }) => {
54463
+ const renderOption = (opt, i) => {
54464
+ const { label: optionLabel } = opt;
54465
+ const active = i === cursor;
54466
+ const text = active ? blue.underline(optionLabel) : dim(optionLabel);
54467
+ const indicator = active ? blue(shapes.radioActive) : dim(shapes.radioInactive);
54468
+ return `${space(2)}${indicator} ${text}`;
54469
+ };
54470
+ return [
54471
+ `${blCorner} ${bold(question)} ${dim(helpText)}`,
54472
+ `${options.map(renderOption).join(`
54473
+ `)}`,
54474
+ ``
54475
+ // extra line for readability
54476
+ ];
54477
+ };
54478
+ return {
54479
+ initial: defaultRenderer,
54480
+ active: defaultRenderer,
54481
+ confirm: defaultRenderer,
54482
+ error: defaultRenderer,
54483
+ submit: ({ value }) => renderSubmit(
54484
+ config14,
54485
+ options.find((o2) => o2.value === value)?.label
54486
+ ),
54487
+ cancel: handleCancel
54488
+ };
54489
+ };
54490
+ var getConfirmRenderers = (config14) => {
54491
+ const { activeText, inactiveText, question, helpText: _helpText } = config14;
54492
+ const helpText = _helpText ?? "";
54476
54493
  const active = activeText || "Yes";
54477
54494
  const inactive = inactiveText || "No";
54478
- const prompt = new sD({
54479
- active,
54480
- inactive,
54481
- initialValue: defaultValue,
54482
- render() {
54483
- const yesColor = this.value ? blue : dim;
54484
- const noColor = this.value ? dim : blue;
54485
- let body = ``;
54486
- switch (this.state) {
54487
- case "submit":
54488
- body += `${leftT} ${question}
54489
- `;
54490
- body += `${grayBar} ${renderSubmitted(this.value)}`;
54491
- body += `
54492
- ${grayBar}`;
54493
- break;
54494
- default:
54495
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54496
- `;
54497
- body += `${space(2)}${yesColor(active)} / ${noColor(inactive)}
54498
- `;
54499
- break;
54500
- }
54501
- return body;
54502
- }
54503
- });
54504
- let value;
54505
- if (acceptDefault) {
54506
- logRaw(`${leftT} ${question}`);
54507
- logRaw(`${grayBar} ${renderSubmitted(defaultValue)}`);
54508
- logRaw(`${grayBar}`);
54509
- value = defaultValue;
54510
- } else {
54511
- value = Boolean(await prompt.prompt());
54512
- if (eD(value)) {
54513
- cancel("Operation cancelled.");
54514
- process.exit(0);
54515
- }
54516
- }
54517
- return value;
54495
+ const defaultRenderer = ({ value }) => {
54496
+ const yesColor = value ? blue : dim;
54497
+ const noColor = value ? dim : blue;
54498
+ return [
54499
+ `${blCorner} ${bold(question)} ${dim(helpText)}`,
54500
+ `${space(2)}${yesColor(active)} / ${noColor(inactive)}`
54501
+ ];
54502
+ };
54503
+ return {
54504
+ initial: defaultRenderer,
54505
+ active: defaultRenderer,
54506
+ confirm: defaultRenderer,
54507
+ error: defaultRenderer,
54508
+ submit: ({ value }) => renderSubmit(config14, value ? "yes" : "no"),
54509
+ cancel: handleCancel
54510
+ };
54518
54511
  };
54519
54512
  var spinner = () => {
54520
54513
  const spinnerFrames = ["\u2524", "\u2518", "\u2534", "\u2514", "\u251C", "\u250C", "\u252C", "\u2510"];
@@ -59419,7 +59412,7 @@ var Yargs = YargsFactory(esm_default);
59419
59412
  var yargs_default = Yargs;
59420
59413
 
59421
59414
  // package.json
59422
- var version = "0.0.0-6b859a45";
59415
+ var version = "0.0.0-775eb3bd";
59423
59416
 
59424
59417
  // src/common.ts
59425
59418
  var import_fs6 = require("fs");
@@ -59480,7 +59473,7 @@ var runCommand = async (command2, opts = {}) => {
59480
59473
  }
59481
59474
  return printAsyncStatus({
59482
59475
  useSpinner: opts.useSpinner ?? opts.silent,
59483
- startText: opts.startText || command2.join(" "),
59476
+ startText: opts.startText || command2.join(" ").trim(),
59484
59477
  doneText: opts.doneText,
59485
59478
  promise() {
59486
59479
  const [executable, ...args] = command2;
@@ -59521,6 +59514,9 @@ var runCommand = async (command2, opts = {}) => {
59521
59514
  }
59522
59515
  }
59523
59516
  });
59517
+ cmd.on("error", (code) => {
59518
+ reject(code);
59519
+ });
59524
59520
  });
59525
59521
  }
59526
59522
  });
@@ -59631,10 +59627,14 @@ var installWrangler = async () => {
59631
59627
  };
59632
59628
  var isLoggedIn = async () => {
59633
59629
  const { npx: npx6 } = detectPackageManager();
59634
- const output = await runCommand(`${npx6} wrangler whoami`, {
59635
- silent: true
59636
- });
59637
- return !/not authenticated/.test(output);
59630
+ try {
59631
+ const output = await runCommand(`${npx6} wrangler whoami`, {
59632
+ silent: true
59633
+ });
59634
+ return /You are logged in/.test(output);
59635
+ } catch (error) {
59636
+ return false;
59637
+ }
59638
59638
  };
59639
59639
  var wranglerLogin = async () => {
59640
59640
  const { npx: npx6 } = detectPackageManager();
@@ -59779,14 +59779,12 @@ var setupProjectDirectory = (args) => {
59779
59779
  };
59780
59780
  var offerToDeploy = async (ctx) => {
59781
59781
  startSection(`Deploy with Cloudflare`, `Step 3 of 3`);
59782
- ctx.args.deploy = await confirmInput({
59782
+ const label = `deploy via \`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}\``;
59783
+ ctx.args.deploy = await processArgument(ctx.args, "deploy", {
59784
+ type: "confirm",
59783
59785
  question: "Do you want to deploy your application?",
59784
- renderSubmitted: (value) => `${brandColor(value ? `yes` : `no`)} ${dim(
59785
- `deploying via \`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}\``
59786
- )}`,
59787
- defaultValue: ctx.args.deploy ?? (ctx.args.wranglerDefaults ? false : true),
59788
- // if --wrangler-defaults, default to false, otherwise default to true
59789
- acceptDefault: ctx.args.wranglerDefaults
59786
+ label,
59787
+ defaultValue: C3_DEFAULTS.deploy
59790
59788
  });
59791
59789
  if (!ctx.args.deploy)
59792
59790
  return;
@@ -59840,14 +59838,12 @@ var chooseAccount = async (ctx) => {
59840
59838
  label: name,
59841
59839
  value: id
59842
59840
  }));
59843
- accountId = await selectInput({
59841
+ accountId = await inputPrompt({
59842
+ type: "select",
59844
59843
  question: "Which account do you want to use?",
59845
59844
  options: accountOptions,
59846
- renderSubmitted: (option) => {
59847
- return `${brandColor("account")} ${dim(option.label)}`;
59848
- },
59849
- defaultValue: accountOptions[0].value,
59850
- acceptDefault: ctx.args.wranglerDefaults
59845
+ label: "account",
59846
+ defaultValue: accountOptions[0].value
59851
59847
  });
59852
59848
  }
59853
59849
  const accountName = Object.keys(accounts).find(
@@ -59857,6 +59853,7 @@ var chooseAccount = async (ctx) => {
59857
59853
  };
59858
59854
  var printSummary = async (ctx) => {
59859
59855
  const nextSteps = [
59856
+ [`Navigate to the new directory:`, `cd ${ctx.project.name}`],
59860
59857
  [
59861
59858
  `Run the development server`,
59862
59859
  `${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
@@ -59919,11 +59916,11 @@ var offerGit = async (ctx) => {
59919
59916
  const insideGitRepo = await isInsideGitRepo(ctx.project.path);
59920
59917
  if (insideGitRepo)
59921
59918
  return;
59922
- ctx.args.git ??= await confirmInput({
59919
+ ctx.args.git = await processArgument(ctx.args, "git", {
59920
+ type: "confirm",
59923
59921
  question: "Do you want to use git for version control?",
59924
- renderSubmitted: (value) => `${brandColor("git")} ${dim(value ? `yes` : `no`)}`,
59925
- defaultValue: true,
59926
- acceptDefault: ctx.args.wranglerDefaults
59922
+ label: "git",
59923
+ defaultValue: C3_DEFAULTS.git
59927
59924
  });
59928
59925
  if (ctx.args.git) {
59929
59926
  await printAsyncStatus({
@@ -59983,6 +59980,24 @@ async function initializeGit(cwd) {
59983
59980
  await runCommand(`git init`, { useSpinner: false, silent: true, cwd });
59984
59981
  }
59985
59982
  }
59983
+ async function getProductionBranch(cwd) {
59984
+ try {
59985
+ const productionBranch = await runCommand(
59986
+ // "git branch --show-current", // git@^2.22
59987
+ "git rev-parse --abbrev-ref HEAD",
59988
+ // git@^1.6.3
59989
+ {
59990
+ silent: true,
59991
+ cwd,
59992
+ useSpinner: false,
59993
+ captureOutput: true
59994
+ }
59995
+ );
59996
+ return productionBranch.trim();
59997
+ } catch (err) {
59998
+ }
59999
+ return "main";
60000
+ }
59986
60001
 
59987
60002
  // src/pages.ts
59988
60003
  var import_path8 = require("path");
@@ -60191,25 +60206,19 @@ var docusaurus_default = config3;
60191
60206
  var { npm: npm4, dlx: dlx4 } = detectPackageManager();
60192
60207
  var generate4 = async (ctx) => {
60193
60208
  const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";
60194
- const useTemplate = await confirmInput({
60209
+ const useTemplate = await inputPrompt({
60210
+ type: "confirm",
60195
60211
  question: "Would you like to use a template?",
60196
- renderSubmitted: (value) => {
60197
- const status2 = value ? "yes" : "no";
60198
- return `${brandColor(`template`)} ${status2}`;
60199
- },
60200
- defaultValue: true,
60201
- acceptDefault: false
60212
+ label: "template",
60213
+ defaultValue: true
60202
60214
  });
60203
60215
  let templateUrl = "";
60204
60216
  if (useTemplate) {
60205
- templateUrl = await textInput({
60217
+ templateUrl = await inputPrompt({
60218
+ type: "text",
60206
60219
  question: `Please specify the url of the template you'd like to use`,
60207
- renderSubmitted: (value) => {
60208
- const result = `Using template \`${value}\``;
60209
- return `${brandColor("template")} ${dim(result)}`;
60210
- },
60211
- defaultValue: defaultTemplate,
60212
- acceptDefault: false
60220
+ label: "template",
60221
+ defaultValue: defaultTemplate
60213
60222
  });
60214
60223
  }
60215
60224
  const version2 = getFrameworkVersion(ctx);
@@ -60502,7 +60511,7 @@ var config11 = {
60502
60511
  displayName: "Solid",
60503
60512
  packageScripts: {
60504
60513
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
60505
- "pages:deploy": `${npm9} run build build && wrangler pages deploy ./dist/public`
60514
+ "pages:deploy": `${npm9} run build && wrangler pages deploy ./dist/public`
60506
60515
  }
60507
60516
  };
60508
60517
  var solid_default = config11;
@@ -60613,7 +60622,7 @@ var versionMap_default = {
60613
60622
  astro: "3.1.5",
60614
60623
  docusaurus: "2.4.1",
60615
60624
  gatsby: "5.10.0",
60616
- hono: "0.2.0",
60625
+ hono: "0.2.6",
60617
60626
  next: "13.4.2",
60618
60627
  nuxt: "3.4.2",
60619
60628
  qwik: "1.1.x",
@@ -60718,14 +60727,12 @@ var getFrameworkSelection = async (args) => {
60718
60727
  value: key
60719
60728
  })
60720
60729
  );
60721
- const framework = await selectInput({
60730
+ const framework = await processArgument(args, "framework", {
60731
+ type: "select",
60732
+ label: "framework",
60722
60733
  question: "Which development framework do you want to use?",
60723
60734
  options: frameworkOptions,
60724
- renderSubmitted: (option) => {
60725
- return `${brandColor("framework")} ${dim(option.label)}`;
60726
- },
60727
- defaultValue: args.framework ?? "svelte",
60728
- acceptDefault: Boolean(args.framework)
60735
+ defaultValue: C3_DEFAULTS.framework
60729
60736
  });
60730
60737
  framework || crash("A framework must be selected to continue.");
60731
60738
  if (!supportedFramework(framework)) {
@@ -60759,7 +60766,8 @@ var createProject = async (ctx) => {
60759
60766
  const CLOUDFLARE_ACCOUNT_ID = ctx.account.id;
60760
60767
  const compatFlags = ctx.framework?.config.compatibilityFlags?.join(" ");
60761
60768
  const compatFlagsArg = compatFlags ? `--compatibility-flags ${compatFlags}` : "";
60762
- const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch main ${compatFlagsArg}`;
60769
+ const productionBranch = await getProductionBranch(ctx.project.path);
60770
+ const cmd = `${npx5} wrangler pages project create ${ctx.project.name} --production-branch ${productionBranch} ${compatFlagsArg}`;
60763
60771
  try {
60764
60772
  await retry(
60765
60773
  CREATE_PROJECT_RETRIES,
@@ -60768,7 +60776,7 @@ var createProject = async (ctx) => {
60768
60776
  cwd: ctx.project.path,
60769
60777
  env: { CLOUDFLARE_ACCOUNT_ID },
60770
60778
  startText: "Creating Pages project",
60771
- doneText: `${brandColor("created")} ${dim(`via \`${cmd}\``)}`
60779
+ doneText: `${brandColor("created")} ${dim(`via \`${cmd.trim()}\``)}`
60772
60780
  })
60773
60781
  );
60774
60782
  } catch (error) {
@@ -60803,11 +60811,11 @@ var runWorkersGenerator = async (args) => {
60803
60811
  };
60804
60812
  async function getTemplate(ctx) {
60805
60813
  if (ctx.args.ts === void 0) {
60806
- ctx.args.ts = await confirmInput({
60814
+ ctx.args.ts = await processArgument(ctx.args, "ts", {
60815
+ type: "confirm",
60807
60816
  question: "Do you want to use TypeScript?",
60808
- renderSubmitted: (value) => `${brandColor("typescript")} ${dim(`${value ? "yes" : "no"}`)}`,
60809
- defaultValue: true,
60810
- acceptDefault: ctx.args.wranglerDefaults
60817
+ label: "typescript",
60818
+ defaultValue: C3_DEFAULTS.ts
60811
60819
  });
60812
60820
  }
60813
60821
  const preexisting = ctx.args.type === "pre-existing";
@@ -60833,12 +60841,16 @@ async function copyExistingWorkerFiles(ctx) {
60833
60841
  if (preexisting) {
60834
60842
  await chooseAccount(ctx);
60835
60843
  if (ctx.args.existingScript === void 0) {
60836
- ctx.args.existingScript = await textInput({
60837
- question: "Please specify the name of the existing worker in this account?",
60838
- renderSubmitted: (value) => `${brandColor("worker")} ${dim(`"${value}"`)}`,
60839
- defaultValue: ctx.project.name,
60840
- acceptDefault: ctx.args.wranglerDefaults
60841
- });
60844
+ ctx.args.existingScript = await processArgument(
60845
+ ctx.args,
60846
+ "existingScript",
60847
+ {
60848
+ type: "text",
60849
+ question: "Please specify the name of the existing worker in this account?",
60850
+ label: "worker",
60851
+ defaultValue: ctx.project.name
60852
+ }
60853
+ );
60842
60854
  }
60843
60855
  const tempdir = await (0, import_promises3.mkdtemp)(
60844
60856
  (0, import_path9.join)((0, import_os.tmpdir)(), "c3-wrangler-init--from-dash-")
@@ -60894,19 +60906,55 @@ async function updateFiles(ctx) {
60894
60906
  }
60895
60907
 
60896
60908
  // src/cli.ts
60909
+ var C3_DEFAULTS = {
60910
+ projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
60911
+ type: "hello-world",
60912
+ framework: "angular",
60913
+ deploy: true,
60914
+ git: true,
60915
+ open: true,
60916
+ ts: true
60917
+ };
60918
+ var WRANGLER_DEFAULTS = {
60919
+ ...C3_DEFAULTS,
60920
+ deploy: false
60921
+ };
60897
60922
  var main = async (argv) => {
60898
60923
  const args = await parseArgs(argv);
60899
60924
  printBanner();
60925
+ const projectName = await processArgument(args, "projectName", {
60926
+ type: "text",
60927
+ question: `In which directory do you want to create your application?`,
60928
+ helpText: "also used as application name",
60929
+ defaultValue: C3_DEFAULTS.projectName,
60930
+ label: "dir",
60931
+ validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName),
60932
+ format: (val) => `./${val}`
60933
+ });
60934
+ if (!args.type) {
60935
+ if (args.framework) {
60936
+ args.type = "webFramework";
60937
+ } else if (args.existingScript) {
60938
+ args.type = "pre-existing";
60939
+ }
60940
+ }
60941
+ const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
60942
+ const type = await processArgument(args, "type", {
60943
+ type: "select",
60944
+ question: "What type of application do you want to create?",
60945
+ label: "type",
60946
+ options: templateOptions,
60947
+ defaultValue: C3_DEFAULTS.type
60948
+ });
60949
+ if (!type || !Object.keys(templateMap).includes(type)) {
60950
+ return crash("An application type must be specified to continue.");
60951
+ }
60900
60952
  const validatedArgs = {
60901
60953
  ...args,
60902
- projectName: await validateName(args.projectName, {
60903
- acceptDefault: args.wranglerDefaults
60904
- }),
60905
- type: await validateType(args.type, {
60906
- acceptDefault: args.wranglerDefaults
60907
- })
60954
+ type,
60955
+ projectName
60908
60956
  };
60909
- const { handler } = templateMap[validatedArgs.type];
60957
+ const { handler } = templateMap[type];
60910
60958
  await handler(validatedArgs);
60911
60959
  };
60912
60960
  var printBanner = () => {
@@ -60923,42 +60971,17 @@ var parseArgs = async (argv) => {
60923
60971
  }).option("existing-script", {
60924
60972
  type: "string",
60925
60973
  hidden: templateMap["pre-existing"].hidden
60974
+ }).option("accept-defaults", {
60975
+ alias: "y",
60976
+ type: "boolean"
60926
60977
  }).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).help().argv;
60927
60978
  return {
60979
+ ...args.wranglerDefaults && WRANGLER_DEFAULTS,
60980
+ ...args.acceptDefaults && C3_DEFAULTS,
60928
60981
  projectName: args._[0],
60929
60982
  ...args
60930
60983
  };
60931
60984
  };
60932
- var validateName = async (name, { acceptDefault = false } = {}) => {
60933
- const defaultValue = name ?? new import_haikunator.default().haikunate({ tokenHex: true });
60934
- return textInput({
60935
- question: `In which directory do you want to create your application?`,
60936
- helpText: "also used as application name",
60937
- renderSubmitted: (value) => {
60938
- return `${brandColor("dir")} ${dim(value)}`;
60939
- },
60940
- defaultValue,
60941
- acceptDefault,
60942
- validate: (value) => validateProjectDirectory(value || defaultValue),
60943
- format: (val) => `./${val}`
60944
- });
60945
- };
60946
- var validateType = async (type, { acceptDefault = false } = {}) => {
60947
- const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
60948
- type = await selectInput({
60949
- question: "What type of application do you want to create?",
60950
- options: templateOptions,
60951
- renderSubmitted: (option) => {
60952
- return `${brandColor("type")} ${dim(option.label)}`;
60953
- },
60954
- defaultValue: type ?? "hello-world",
60955
- acceptDefault
60956
- });
60957
- if (!type || !Object.keys(templateMap).includes(type)) {
60958
- crash("An application type must be specified to continue.");
60959
- }
60960
- return type;
60961
- };
60962
60985
  var templateMap = {
60963
60986
  webFramework: {
60964
60987
  label: "Website or web app",
@@ -60996,7 +61019,9 @@ var templateMap = {
60996
61019
  main(process.argv).catch((e) => crash(e));
60997
61020
  // Annotate the CommonJS export names for ESM import in node:
60998
61021
  0 && (module.exports = {
60999
- main
61022
+ C3_DEFAULTS,
61023
+ main,
61024
+ parseArgs
61000
61025
  });
61001
61026
  /*! Bundled license information:
61002
61027
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-6b859a45",
3
+ "version": "0.0.0-775eb3bd",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -7,7 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
10
  "itty-router": "^3.0.12",
12
11
  "wrangler": "^3.0.0"
13
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }
@@ -7,8 +7,6 @@
7
7
  "start": "wrangler dev"
8
8
  },
9
9
  "devDependencies": {
10
- "@cloudflare/workers-types": "^4.20230419.0",
11
- "typescript": "^5.0.4",
12
10
  "wrangler": "^3.0.0"
13
11
  }
14
12
  }