create-cloudflare 2.0.10 → 2.0.12

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());
@@ -53150,7 +53152,7 @@ var status = {
53150
53152
  success: bgRed(` SUCCESS `)
53151
53153
  };
53152
53154
  var space = (n = 1) => {
53153
- return [...Array(n)].map(() => hidden("-")).join("");
53155
+ return hidden("\u200A".repeat(n));
53154
53156
  };
53155
53157
  var logRaw = (msg) => {
53156
53158
  if (process.env.VITEST)
@@ -54347,171 +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 prompt = new oD({
54354
- defaultValue,
54355
- validate,
54356
- render() {
54357
- let body = "";
54358
- switch (this.state) {
54359
- case "initial":
54360
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54361
- `;
54362
- body += `${space(2)}${gray(defaultValue)}
54363
- `;
54364
- break;
54365
- case "active":
54366
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54367
- `;
54368
- body += `${space(2)}${this.value}
54369
- `;
54370
- break;
54371
- case "submit":
54372
- body += `${leftT} ${question}
54373
- `;
54374
- body += `${grayBar} ${renderSubmitted(this.value)}
54375
- ${grayBar}`;
54376
- break;
54377
- case "error":
54378
- body += `${leftT} ${status.error} ${dim(this.error)}
54379
- `;
54380
- body += `${grayBar}
54381
- `;
54382
- body += `${blCorner} ${question} ${dim(helpText)}
54383
- `;
54384
- body += `${space(2)}${this.value}
54385
- `;
54386
- break;
54387
- default:
54388
- break;
54389
- }
54390
- return body;
54391
- }
54392
- });
54393
- let value;
54394
- if (acceptDefault) {
54395
- logRaw(`${leftT} ${question}`);
54396
- logRaw(`${grayBar} ${renderSubmitted(defaultValue)}
54397
- ${grayBar}`);
54398
- value = defaultValue;
54399
- validate?.(value);
54400
- } else {
54401
- value = await prompt.prompt();
54402
- if (eD(value)) {
54403
- cancel("Operation cancelled.");
54404
- process.exit(0);
54405
- }
54406
- }
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);
54407
54362
  return value;
54408
54363
  };
54409
- var selectInput = async (opts) => {
54410
- const { question, options, renderSubmitted, defaultValue, acceptDefault } = opts;
54411
- const helpText = opts.helpText || ``;
54412
- const prompt = new ED({
54413
- options,
54414
- initialValue: defaultValue ?? options[0].value,
54415
- render() {
54416
- const renderOption = (opt, i) => {
54417
- const { label } = opt;
54418
- const active = i === this.cursor;
54419
- const text = active ? blue.underline(label) : dim(label);
54420
- const indicator = active ? blue(shapes.radioActive) : dim(shapes.radioInactive);
54421
- return `${space(2)}${indicator} ${text}`;
54422
- };
54423
- let body = ``;
54424
- switch (this.state) {
54425
- case "submit":
54426
- body += `${leftT} ${question}
54427
- `;
54428
- body += `${grayBar} ${renderSubmitted(options[this.cursor])}`;
54429
- body += `
54430
- ${grayBar}`;
54431
- break;
54432
- default:
54433
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54434
- `;
54435
- body += `${options.map(renderOption).join(`
54436
- `)}
54437
- `;
54438
- 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);
54439
54378
  }
54440
- return body;
54441
- }
54442
- });
54443
- let value;
54444
- if (acceptDefault) {
54445
- logRaw(`${leftT} ${question}`);
54446
- logRaw(
54447
- `${grayBar} ${renderSubmitted({
54448
- label: defaultValue,
54449
- value: defaultValue
54450
- })}`
54451
- );
54452
- logRaw(`${grayBar}`);
54453
- 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
+ });
54454
54390
  } else {
54455
- value = await prompt.prompt();
54456
- if (eD(value)) {
54457
- cancel("Operation cancelled.");
54458
- process.exit(0);
54459
- }
54391
+ prompt = new oD({
54392
+ ...promptConfig,
54393
+ defaultValue: String(promptConfig.defaultValue),
54394
+ render() {
54395
+ return dispatchRender(this);
54396
+ }
54397
+ });
54398
+ }
54399
+ const input = await prompt.prompt();
54400
+ if (eD(input)) {
54401
+ cancel("Operation cancelled.");
54402
+ process.exit(0);
54403
+ }
54404
+ return input;
54405
+ };
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);
54460
54423
  }
54461
- return value;
54462
54424
  };
54463
- var confirmInput = async (opts) => {
54425
+ var getTextRenderers = (config14) => {
54464
54426
  const {
54465
- activeText,
54466
- inactiveText,
54427
+ defaultValue,
54467
54428
  question,
54468
- renderSubmitted,
54469
- defaultValue = true,
54470
- acceptDefault
54471
- } = opts;
54472
- 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 ?? "";
54473
54493
  const active = activeText || "Yes";
54474
54494
  const inactive = inactiveText || "No";
54475
- const prompt = new sD({
54476
- active,
54477
- inactive,
54478
- initialValue: defaultValue,
54479
- render() {
54480
- const yesColor = this.value ? blue : dim;
54481
- const noColor = this.value ? dim : blue;
54482
- let body = ``;
54483
- switch (this.state) {
54484
- case "submit":
54485
- body += `${leftT} ${question}
54486
- `;
54487
- body += `${grayBar} ${renderSubmitted(this.value)}`;
54488
- body += `
54489
- ${grayBar}`;
54490
- break;
54491
- default:
54492
- body += `${blCorner} ${bold(question)} ${dim(helpText)}
54493
- `;
54494
- body += `${space(2)}${yesColor(active)} / ${noColor(inactive)}
54495
- `;
54496
- break;
54497
- }
54498
- return body;
54499
- }
54500
- });
54501
- let value;
54502
- if (acceptDefault) {
54503
- logRaw(`${leftT} ${question}`);
54504
- logRaw(`${grayBar} ${renderSubmitted(defaultValue)}`);
54505
- logRaw(`${grayBar}`);
54506
- value = defaultValue;
54507
- } else {
54508
- value = Boolean(await prompt.prompt());
54509
- if (eD(value)) {
54510
- cancel("Operation cancelled.");
54511
- process.exit(0);
54512
- }
54513
- }
54514
- 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
+ };
54515
54511
  };
54516
54512
  var spinner = () => {
54517
54513
  const spinnerFrames = ["\u2524", "\u2518", "\u2534", "\u2514", "\u251C", "\u250C", "\u252C", "\u2510"];
@@ -59416,7 +59412,7 @@ var Yargs = YargsFactory(esm_default);
59416
59412
  var yargs_default = Yargs;
59417
59413
 
59418
59414
  // package.json
59419
- var version = "2.0.10";
59415
+ var version = "2.0.12";
59420
59416
 
59421
59417
  // src/common.ts
59422
59418
  var import_fs6 = require("fs");
@@ -59471,26 +59467,26 @@ var detectPackageManager = () => {
59471
59467
  };
59472
59468
 
59473
59469
  // src/helpers/command.ts
59474
- var runCommand = async (command2, opts) => {
59470
+ var runCommand = async (command2, opts = {}) => {
59475
59471
  if (typeof command2 === "string") {
59476
59472
  command2 = command2.trim().replace(/\s+/g, ` `).split(" ");
59477
59473
  }
59478
59474
  return printAsyncStatus({
59479
- useSpinner: opts?.useSpinner ?? opts?.silent,
59480
- startText: opts?.startText || command2.join(" "),
59481
- doneText: opts?.doneText,
59475
+ useSpinner: opts.useSpinner ?? opts.silent,
59476
+ startText: opts.startText || command2.join(" "),
59477
+ doneText: opts.doneText,
59482
59478
  promise() {
59483
59479
  const [executable, ...args] = command2;
59484
- const squelch = opts?.silent || process.env.VITEST;
59480
+ const squelch = opts.silent || process.env.VITEST;
59485
59481
  const cmd = (0, import_cross_spawn.spawn)(executable, [...args], {
59486
59482
  // TODO: ideally inherit stderr, but npm install uses this for warnings
59487
59483
  // stdio: [ioMode, ioMode, "inherit"],
59488
59484
  stdio: squelch ? "pipe" : "inherit",
59489
59485
  env: {
59490
59486
  ...process.env,
59491
- ...opts?.env
59487
+ ...opts.env
59492
59488
  },
59493
- cwd: opts?.cwd
59489
+ cwd: opts.cwd
59494
59490
  });
59495
59491
  let output = ``;
59496
59492
  if (opts?.captureOutput ?? squelch) {
@@ -59503,10 +59499,19 @@ var runCommand = async (command2, opts) => {
59503
59499
  }
59504
59500
  return new Promise((resolve9, reject) => {
59505
59501
  cmd.on("close", (code) => {
59506
- if (code === 0) {
59507
- resolve9(stripAnsi(output));
59508
- } else {
59509
- reject(new Error(output, { cause: code }));
59502
+ try {
59503
+ if (code !== 0) {
59504
+ throw new Error(output, { cause: code });
59505
+ }
59506
+ const transformOutput = opts.transformOutput ?? ((result) => result);
59507
+ const processedOutput = transformOutput(stripAnsi(output));
59508
+ resolve9(processedOutput);
59509
+ } catch (e) {
59510
+ if (opts.fallbackOutput) {
59511
+ resolve9(opts.fallbackOutput(e));
59512
+ } else {
59513
+ reject(new Error(output, { cause: e }));
59514
+ }
59510
59515
  }
59511
59516
  });
59512
59517
  });
@@ -59519,9 +59524,11 @@ async function runCommands({ commands, ...opts }) {
59519
59524
  startText: opts.startText,
59520
59525
  doneText: opts.doneText,
59521
59526
  async promise() {
59527
+ const results = [];
59522
59528
  for (const command2 of commands) {
59523
- await runCommand(command2, { ...opts, useSpinner: false });
59529
+ results.push(await runCommand(command2, { ...opts, useSpinner: false }));
59524
59530
  }
59531
+ return results.join("\n");
59525
59532
  }
59526
59533
  });
59527
59534
  }
@@ -59538,8 +59545,9 @@ var printAsyncStatus = async ({
59538
59545
  promise = promise();
59539
59546
  }
59540
59547
  try {
59541
- await promise;
59542
- s?.stop(opts.doneText);
59548
+ const output = await promise;
59549
+ const doneText = typeof opts.doneText === "function" ? opts.doneText(output) : opts.doneText;
59550
+ s?.stop(doneText);
59543
59551
  } catch (err) {
59544
59552
  s?.stop(err.message);
59545
59553
  } finally {
@@ -59652,6 +59660,24 @@ var listAccounts = async () => {
59652
59660
  });
59653
59661
  return accounts;
59654
59662
  };
59663
+ async function getWorkerdCompatibilityDate() {
59664
+ const { npm: npm12 } = detectPackageManager();
59665
+ return runCommand(`${npm12} info workerd dist-tags.latest`, {
59666
+ silent: true,
59667
+ captureOutput: true,
59668
+ startText: "Retrieving current workerd compatibility date",
59669
+ transformOutput: (result) => {
59670
+ const match = result.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/);
59671
+ if (!match) {
59672
+ throw new Error("Could not find workerd date");
59673
+ }
59674
+ const [, year, month, date] = match;
59675
+ return `${year}-${month}-${date}`;
59676
+ },
59677
+ fallbackOutput: () => "2023-05-18",
59678
+ doneText: (output) => `${brandColor("compatibility date")} ${dim(output)}`
59679
+ });
59680
+ }
59655
59681
 
59656
59682
  // src/helpers/poll.ts
59657
59683
  var import_promises = require("node:dns/promises");
@@ -59729,14 +59755,15 @@ var validateProjectDirectory = (relativePath) => {
59729
59755
  const existsAlready = (0, import_fs6.existsSync)(path3);
59730
59756
  const isEmpty = existsAlready && (0, import_fs6.readdirSync)(path3).length === 0;
59731
59757
  if (existsAlready && !isEmpty) {
59732
- crash(
59733
- `Directory \`${relativePath}\` already exists and is not empty. Please choose a new name.`
59734
- );
59758
+ return `Directory \`${relativePath}\` already exists and is not empty. Please choose a new name.`;
59735
59759
  }
59736
59760
  };
59737
59761
  var setupProjectDirectory = (args) => {
59738
59762
  const path3 = (0, import_path6.resolve)(args.projectName);
59739
- validateProjectDirectory(path3);
59763
+ const err = validateProjectDirectory(path3);
59764
+ if (err) {
59765
+ crash(err);
59766
+ }
59740
59767
  const directory = (0, import_path6.dirname)(path3);
59741
59768
  const name = (0, import_path6.basename)(path3);
59742
59769
  (0, import_fs6.mkdirSync)(directory, { recursive: true });
@@ -59745,14 +59772,12 @@ var setupProjectDirectory = (args) => {
59745
59772
  };
59746
59773
  var offerToDeploy = async (ctx) => {
59747
59774
  startSection(`Deploy with Cloudflare`, `Step 3 of 3`);
59748
- ctx.args.deploy = await confirmInput({
59775
+ const label = `deploy via \`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}\``;
59776
+ ctx.args.deploy = await processArgument(ctx.args, "deploy", {
59777
+ type: "confirm",
59749
59778
  question: "Do you want to deploy your application?",
59750
- renderSubmitted: (value) => `${brandColor(value ? `yes` : `no`)} ${dim(
59751
- `deploying via \`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}\``
59752
- )}`,
59753
- defaultValue: ctx.args.deploy ?? (ctx.args.wranglerDefaults ? false : true),
59754
- // if --wrangler-defaults, default to false, otherwise default to true
59755
- acceptDefault: ctx.args.wranglerDefaults
59779
+ label,
59780
+ defaultValue: C3_DEFAULTS.deploy
59756
59781
  });
59757
59782
  if (!ctx.args.deploy)
59758
59783
  return;
@@ -59806,14 +59831,12 @@ var chooseAccount = async (ctx) => {
59806
59831
  label: name,
59807
59832
  value: id
59808
59833
  }));
59809
- accountId = await selectInput({
59834
+ accountId = await inputPrompt({
59835
+ type: "select",
59810
59836
  question: "Which account do you want to use?",
59811
59837
  options: accountOptions,
59812
- renderSubmitted: (option) => {
59813
- return `${brandColor("account")} ${dim(option.label)}`;
59814
- },
59815
- defaultValue: accountOptions[0].value,
59816
- acceptDefault: ctx.args.wranglerDefaults
59838
+ label: "account",
59839
+ defaultValue: accountOptions[0].value
59817
59840
  });
59818
59841
  }
59819
59842
  const accountName = Object.keys(accounts).find(
@@ -59823,6 +59846,7 @@ var chooseAccount = async (ctx) => {
59823
59846
  };
59824
59847
  var printSummary = async (ctx) => {
59825
59848
  const nextSteps = [
59849
+ [`Navigate to the new directory:`, `cd ${ctx.project.name}`],
59826
59850
  [
59827
59851
  `Run the development server`,
59828
59852
  `${npm} run ${ctx.framework?.config.devCommand ?? "start"}`
@@ -59885,11 +59909,11 @@ var offerGit = async (ctx) => {
59885
59909
  const insideGitRepo = await isInsideGitRepo(ctx.project.path);
59886
59910
  if (insideGitRepo)
59887
59911
  return;
59888
- ctx.args.git ??= await confirmInput({
59912
+ ctx.args.git = await processArgument(ctx.args, "git", {
59913
+ type: "confirm",
59889
59914
  question: "Do you want to use git for version control?",
59890
- renderSubmitted: (value) => `${brandColor("git")} ${dim(value ? `yes` : `no`)}`,
59891
- defaultValue: true,
59892
- acceptDefault: ctx.args.wranglerDefaults
59915
+ label: "git",
59916
+ defaultValue: C3_DEFAULTS.git
59893
59917
  });
59894
59918
  if (ctx.args.git) {
59895
59919
  await printAsyncStatus({
@@ -60021,10 +60045,10 @@ var config = {
60021
60045
  displayName: "Angular",
60022
60046
  packageScripts: {
60023
60047
  process: "node ./tools/copy-worker-files.mjs && node ./tools/copy-client-files.mjs && node ./tools/bundle.mjs",
60024
- prestart: `${npm2} run build:ssr && npm run process`,
60048
+ prestart: `${npm2} run build:ssr && ${npm2} run process`,
60025
60049
  start: "wrangler pages dev dist/cloudflare --compatibility-date=2021-09-20 --experimental-local",
60026
- predeploy: `${npm2} run build:ssr && npm run process`,
60027
- deploy: "wrangler pages publish dist/cloudflare"
60050
+ predeploy: `${npm2} run build:ssr && ${npm2} run process`,
60051
+ deploy: "wrangler pages deploy dist/cloudflare"
60028
60052
  },
60029
60053
  deployCommand: "deploy",
60030
60054
  devCommand: "start"
@@ -60119,7 +60143,7 @@ var config2 = {
60119
60143
  displayName: "Astro",
60120
60144
  packageScripts: {
60121
60145
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- astro dev`,
60122
- "pages:deploy": `astro build && wrangler pages publish ./dist`
60146
+ "pages:deploy": `astro build && wrangler pages deploy ./dist`
60123
60147
  },
60124
60148
  testFlags: [
60125
60149
  "--skip-houston",
@@ -60148,7 +60172,7 @@ var config3 = {
60148
60172
  displayName: "Docusaurus",
60149
60173
  packageScripts: {
60150
60174
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm3} run start`,
60151
- "pages:deploy": `NODE_VERSION=16 ${npm3} run build && wrangler pages publish ./build`
60175
+ "pages:deploy": `NODE_VERSION=16 ${npm3} run build && wrangler pages deploy ./build`
60152
60176
  }
60153
60177
  };
60154
60178
  var docusaurus_default = config3;
@@ -60157,25 +60181,19 @@ var docusaurus_default = config3;
60157
60181
  var { npm: npm4, dlx: dlx4 } = detectPackageManager();
60158
60182
  var generate4 = async (ctx) => {
60159
60183
  const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";
60160
- const useTemplate = await confirmInput({
60184
+ const useTemplate = await inputPrompt({
60185
+ type: "confirm",
60161
60186
  question: "Would you like to use a template?",
60162
- renderSubmitted: (value) => {
60163
- const status2 = value ? "yes" : "no";
60164
- return `${brandColor(`template`)} ${status2}`;
60165
- },
60166
- defaultValue: true,
60167
- acceptDefault: false
60187
+ label: "template",
60188
+ defaultValue: true
60168
60189
  });
60169
60190
  let templateUrl = "";
60170
60191
  if (useTemplate) {
60171
- templateUrl = await textInput({
60192
+ templateUrl = await inputPrompt({
60193
+ type: "text",
60172
60194
  question: `Please specify the url of the template you'd like to use`,
60173
- renderSubmitted: (value) => {
60174
- const result = `Using template \`${value}\``;
60175
- return `${brandColor("template")} ${dim(result)}`;
60176
- },
60177
- defaultValue: defaultTemplate,
60178
- acceptDefault: false
60195
+ label: "template",
60196
+ defaultValue: defaultTemplate
60179
60197
  });
60180
60198
  }
60181
60199
  const version2 = getFrameworkVersion(ctx);
@@ -60189,7 +60207,7 @@ var config4 = {
60189
60207
  displayName: "Gatsby",
60190
60208
  packageScripts: {
60191
60209
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 8000 -- ${npm4} run develop`,
60192
- "pages:deploy": `${npm4} run build && wrangler pages publish ./public`
60210
+ "pages:deploy": `${npm4} run build && wrangler pages deploy ./public`
60193
60211
  }
60194
60212
  };
60195
60213
  var gatsby_default = config4;
@@ -60315,7 +60333,7 @@ var config6 = {
60315
60333
  displayName: "Next",
60316
60334
  packageScripts: {
60317
60335
  "pages:build": `${npx3} @cloudflare/next-on-pages@1`,
60318
- "pages:deploy": `${npm5} run pages:build && wrangler pages publish .vercel/output/static`,
60336
+ "pages:deploy": `${npm5} run pages:build && wrangler pages deploy .vercel/output/static`,
60319
60337
  "pages:watch": `${npx3} @cloudflare/next-on-pages@1 --watch`,
60320
60338
  "pages:dev": `${npx3} wrangler pages dev .vercel/output/static --compatibility-flag=nodejs_compat`
60321
60339
  },
@@ -60353,7 +60371,7 @@ var config7 = {
60353
60371
  displayName: "Nuxt",
60354
60372
  packageScripts: {
60355
60373
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- npm run dev`,
60356
- "pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages publish ./dist`
60374
+ "pages:deploy": `NODE_VERSION=17 npm run generate && wrangler pages deploy ./dist`
60357
60375
  }
60358
60376
  };
60359
60377
  var nuxt_default = config7;
@@ -60400,7 +60418,7 @@ var config9 = {
60400
60418
  displayName: "React",
60401
60419
  packageScripts: {
60402
60420
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --port 3000 -- ${npm7} start`,
60403
- "pages:deploy": `${npm7} run build && wrangler pages publish ./build`
60421
+ "pages:deploy": `${npm7} run build && wrangler pages deploy ./build`
60404
60422
  }
60405
60423
  };
60406
60424
  var react_default = config9;
@@ -60419,7 +60437,7 @@ var config10 = {
60419
60437
  generate: generate10,
60420
60438
  displayName: "Remix",
60421
60439
  packageScripts: {
60422
- "pages:deploy": `${npm8} run build && wrangler pages publish ./public`
60440
+ "pages:deploy": `${npm8} run build && wrangler pages deploy ./public`
60423
60441
  },
60424
60442
  devCommand: "dev",
60425
60443
  testFlags: ["--typescript", "--no-install"]
@@ -60468,7 +60486,7 @@ var config11 = {
60468
60486
  displayName: "Solid",
60469
60487
  packageScripts: {
60470
60488
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 3000 -- ${npm9} run dev`,
60471
- "pages:deploy": `${npm9} run build build && wrangler pages publish ./dist/public`
60489
+ "pages:deploy": `${npm9} run build build && wrangler pages deploy ./dist/public`
60472
60490
  }
60473
60491
  };
60474
60492
  var solid_default = config11;
@@ -60568,7 +60586,7 @@ var config12 = {
60568
60586
  displayName: "Svelte",
60569
60587
  packageScripts: {
60570
60588
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 5173 -- ${npm10} run dev`,
60571
- "pages:deploy": `NODE_VERSION=16 ${npm10} run build && wrangler pages publish .svelte-kit/cloudflare`
60589
+ "pages:deploy": `NODE_VERSION=16 ${npm10} run build && wrangler pages deploy .svelte-kit/cloudflare`
60572
60590
  }
60573
60591
  };
60574
60592
  var svelte_default = config12;
@@ -60579,7 +60597,7 @@ var versionMap_default = {
60579
60597
  astro: "3.1.5",
60580
60598
  docusaurus: "2.4.1",
60581
60599
  gatsby: "5.10.0",
60582
- hono: "0.2.0",
60600
+ hono: "0.2.6",
60583
60601
  next: "13.4.2",
60584
60602
  nuxt: "3.4.2",
60585
60603
  qwik: "1.1.x",
@@ -60604,7 +60622,7 @@ var config13 = {
60604
60622
  displayName: "Vue",
60605
60623
  packageScripts: {
60606
60624
  "pages:dev": `wrangler pages dev ${compatDateFlag()} --proxy 5173 -- ${npm11} run dev`,
60607
- "pages:deploy": `${npm11} run build && wrangler pages publish ./dist`
60625
+ "pages:deploy": `${npm11} run build && wrangler pages deploy ./dist`
60608
60626
  },
60609
60627
  testFlags: ["--ts"]
60610
60628
  };
@@ -60684,14 +60702,12 @@ var getFrameworkSelection = async (args) => {
60684
60702
  value: key
60685
60703
  })
60686
60704
  );
60687
- const framework = await selectInput({
60705
+ const framework = await processArgument(args, "framework", {
60706
+ type: "select",
60707
+ label: "framework",
60688
60708
  question: "Which development framework do you want to use?",
60689
60709
  options: frameworkOptions,
60690
- renderSubmitted: (option) => {
60691
- return `${brandColor("framework")} ${dim(option.label)}`;
60692
- },
60693
- defaultValue: args.framework ?? "svelte",
60694
- acceptDefault: Boolean(args.framework)
60710
+ defaultValue: C3_DEFAULTS.framework
60695
60711
  });
60696
60712
  framework || crash("A framework must be selected to continue.");
60697
60713
  if (!supportedFramework(framework)) {
@@ -60769,11 +60785,11 @@ var runWorkersGenerator = async (args) => {
60769
60785
  };
60770
60786
  async function getTemplate(ctx) {
60771
60787
  if (ctx.args.ts === void 0) {
60772
- ctx.args.ts = await confirmInput({
60788
+ ctx.args.ts = await processArgument(ctx.args, "ts", {
60789
+ type: "confirm",
60773
60790
  question: "Do you want to use TypeScript?",
60774
- renderSubmitted: (value) => `${brandColor("typescript")} ${dim(`${value ? "yes" : "no"}`)}`,
60775
- defaultValue: true,
60776
- acceptDefault: ctx.args.wranglerDefaults
60791
+ label: "typescript",
60792
+ defaultValue: C3_DEFAULTS.ts
60777
60793
  });
60778
60794
  }
60779
60795
  const preexisting = ctx.args.type === "pre-existing";
@@ -60799,12 +60815,16 @@ async function copyExistingWorkerFiles(ctx) {
60799
60815
  if (preexisting) {
60800
60816
  await chooseAccount(ctx);
60801
60817
  if (ctx.args.existingScript === void 0) {
60802
- ctx.args.existingScript = await textInput({
60803
- question: "Please specify the name of the existing worker in this account?",
60804
- renderSubmitted: (value) => `${brandColor("worker")} ${dim(`"${value}"`)}`,
60805
- defaultValue: ctx.project.name,
60806
- acceptDefault: ctx.args.wranglerDefaults
60807
- });
60818
+ ctx.args.existingScript = await processArgument(
60819
+ ctx.args,
60820
+ "existingScript",
60821
+ {
60822
+ type: "text",
60823
+ question: "Please specify the name of the existing worker in this account?",
60824
+ label: "worker",
60825
+ defaultValue: ctx.project.name
60826
+ }
60827
+ );
60808
60828
  }
60809
60829
  const tempdir = await (0, import_promises3.mkdtemp)(
60810
60830
  (0, import_path9.join)((0, import_os.tmpdir)(), "c3-wrangler-init--from-dash-")
@@ -60845,10 +60865,12 @@ async function updateFiles(ctx) {
60845
60865
  packagejson: JSON.parse(await (0, import_promises3.readFile)(paths.packagejson, "utf-8")),
60846
60866
  wranglertoml: await (0, import_promises3.readFile)(paths.wranglertoml, "utf-8")
60847
60867
  };
60848
- contents.packagejson.name = ctx.project.name;
60849
- contents.wranglertoml = contents.wranglertoml.replace(/^name = .+$/m, `name = "${ctx.project.name}"`).replace(
60850
- /^compatibility_date = .+$/m,
60851
- `compatibility_date = "${(/* @__PURE__ */ new Date()).toISOString().substring(0, 10)}"`
60868
+ if (contents.packagejson.name === "<TBD>") {
60869
+ contents.packagejson.name = ctx.project.name;
60870
+ }
60871
+ contents.wranglertoml = contents.wranglertoml.replace(/^name\s*=\s*"<TBD>"/m, `name = "${ctx.project.name}"`).replace(
60872
+ /^compatibility_date\s*=\s*"<TBD>"/m,
60873
+ `compatibility_date = "${await getWorkerdCompatibilityDate()}"`
60852
60874
  );
60853
60875
  await (0, import_promises3.writeFile)(
60854
60876
  paths.packagejson,
@@ -60858,19 +60880,55 @@ async function updateFiles(ctx) {
60858
60880
  }
60859
60881
 
60860
60882
  // src/cli.ts
60883
+ var C3_DEFAULTS = {
60884
+ projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
60885
+ type: "hello-world",
60886
+ framework: "angular",
60887
+ deploy: true,
60888
+ git: true,
60889
+ open: true,
60890
+ ts: true
60891
+ };
60892
+ var WRANGLER_DEFAULTS = {
60893
+ ...C3_DEFAULTS,
60894
+ deploy: false
60895
+ };
60861
60896
  var main = async (argv) => {
60862
- printBanner();
60863
60897
  const args = await parseArgs(argv);
60898
+ printBanner();
60899
+ const projectName = await processArgument(args, "projectName", {
60900
+ type: "text",
60901
+ question: `In which directory do you want to create your application?`,
60902
+ helpText: "also used as application name",
60903
+ defaultValue: C3_DEFAULTS.projectName,
60904
+ label: "dir",
60905
+ validate: (value) => validateProjectDirectory(String(value) || C3_DEFAULTS.projectName),
60906
+ format: (val) => `./${val}`
60907
+ });
60908
+ if (!args.type) {
60909
+ if (args.framework) {
60910
+ args.type = "webFramework";
60911
+ } else if (args.existingScript) {
60912
+ args.type = "pre-existing";
60913
+ }
60914
+ }
60915
+ const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
60916
+ const type = await processArgument(args, "type", {
60917
+ type: "select",
60918
+ question: "What type of application do you want to create?",
60919
+ label: "type",
60920
+ options: templateOptions,
60921
+ defaultValue: C3_DEFAULTS.type
60922
+ });
60923
+ if (!type || !Object.keys(templateMap).includes(type)) {
60924
+ return crash("An application type must be specified to continue.");
60925
+ }
60864
60926
  const validatedArgs = {
60865
60927
  ...args,
60866
- projectName: await validateName(args.projectName, {
60867
- acceptDefault: args.wranglerDefaults
60868
- }),
60869
- type: await validateType(args.type, {
60870
- acceptDefault: args.wranglerDefaults
60871
- })
60928
+ type,
60929
+ projectName
60872
60930
  };
60873
- const { handler } = templateMap[validatedArgs.type];
60931
+ const { handler } = templateMap[type];
60874
60932
  await handler(validatedArgs);
60875
60933
  };
60876
60934
  var printBanner = () => {
@@ -60887,41 +60945,17 @@ var parseArgs = async (argv) => {
60887
60945
  }).option("existing-script", {
60888
60946
  type: "string",
60889
60947
  hidden: templateMap["pre-existing"].hidden
60890
- }).option("wrangler-defaults", { type: "boolean", hidden: true }).help().argv;
60948
+ }).option("accept-defaults", {
60949
+ alias: "y",
60950
+ type: "boolean"
60951
+ }).option("wrangler-defaults", { type: "boolean", hidden: true }).version(version).help().argv;
60891
60952
  return {
60953
+ ...args.wranglerDefaults && WRANGLER_DEFAULTS,
60954
+ ...args.acceptDefaults && C3_DEFAULTS,
60892
60955
  projectName: args._[0],
60893
60956
  ...args
60894
60957
  };
60895
60958
  };
60896
- var validateName = async (name, { acceptDefault = false } = {}) => {
60897
- const defaultValue = name ?? new import_haikunator.default().haikunate({ tokenHex: true });
60898
- return textInput({
60899
- question: `Where do you want to create your application?`,
60900
- helpText: "also used as application name",
60901
- renderSubmitted: (value) => {
60902
- return `${brandColor("dir")} ${dim(value)}`;
60903
- },
60904
- defaultValue,
60905
- acceptDefault,
60906
- validate: (value = defaultValue) => validateProjectDirectory(value)
60907
- });
60908
- };
60909
- var validateType = async (type, { acceptDefault = false } = {}) => {
60910
- const templateOptions = Object.entries(templateMap).filter(([_3, { hidden: hidden2 }]) => !hidden2).map(([value, { label }]) => ({ value, label }));
60911
- type = await selectInput({
60912
- question: "What type of application do you want to create?",
60913
- options: templateOptions,
60914
- renderSubmitted: (option) => {
60915
- return `${brandColor("type")} ${dim(option.label)}`;
60916
- },
60917
- defaultValue: type ?? "hello-world",
60918
- acceptDefault
60919
- });
60920
- if (!type || !Object.keys(templateMap).includes(type)) {
60921
- crash("An application type must be specified to continue.");
60922
- }
60923
- return type;
60924
- };
60925
60959
  var templateMap = {
60926
60960
  webFramework: {
60927
60961
  label: "Website or web app",
@@ -60959,7 +60993,9 @@ var templateMap = {
60959
60993
  main(process.argv).catch((e) => crash(e));
60960
60994
  // Annotate the CommonJS export names for ESM import in node:
60961
60995
  0 && (module.exports = {
60962
- main
60996
+ C3_DEFAULTS,
60997
+ main,
60998
+ parseArgs
60963
60999
  });
60964
61000
  /*! Bundled license information:
60965
61001