create-cloudflare 2.9.0 → 2.9.1

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
@@ -581,12 +581,12 @@ var require_isexe = __commonJS({
581
581
  if (typeof Promise !== "function") {
582
582
  throw new TypeError("callback not provided");
583
583
  }
584
- return new Promise(function(resolve10, reject) {
584
+ return new Promise(function(resolve11, reject) {
585
585
  isexe(path3, options || {}, function(er, is) {
586
586
  if (er) {
587
587
  reject(er);
588
588
  } else {
589
- resolve10(is);
589
+ resolve11(is);
590
590
  }
591
591
  });
592
592
  });
@@ -652,27 +652,27 @@ var require_which = __commonJS({
652
652
  opt = {};
653
653
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
654
654
  const found = [];
655
- const step = (i) => new Promise((resolve10, reject) => {
655
+ const step = (i) => new Promise((resolve11, reject) => {
656
656
  if (i === pathEnv.length)
657
- return opt.all && found.length ? resolve10(found) : reject(getNotFoundError(cmd));
657
+ return opt.all && found.length ? resolve11(found) : reject(getNotFoundError(cmd));
658
658
  const ppRaw = pathEnv[i];
659
659
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
660
660
  const pCmd = path3.join(pathPart, cmd);
661
661
  const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
662
- resolve10(subStep(p2, i, 0));
662
+ resolve11(subStep(p2, i, 0));
663
663
  });
664
- const subStep = (p2, i, ii) => new Promise((resolve10, reject) => {
664
+ const subStep = (p2, i, ii) => new Promise((resolve11, reject) => {
665
665
  if (ii === pathExt.length)
666
- return resolve10(step(i + 1));
666
+ return resolve11(step(i + 1));
667
667
  const ext = pathExt[ii];
668
668
  isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
669
669
  if (!er && is) {
670
670
  if (opt.all)
671
671
  found.push(p2 + ext);
672
672
  else
673
- return resolve10(p2 + ext);
673
+ return resolve11(p2 + ext);
674
674
  }
675
- return resolve10(subStep(p2, i, ii + 1));
675
+ return resolve11(subStep(p2, i, ii + 1));
676
676
  });
677
677
  });
678
678
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -5857,8 +5857,8 @@ var require_util2 = __commonJS({
5857
5857
  function createDeferredPromise() {
5858
5858
  let res;
5859
5859
  let rej;
5860
- const promise = new Promise((resolve10, reject) => {
5861
- res = resolve10;
5860
+ const promise = new Promise((resolve11, reject) => {
5861
+ res = resolve11;
5862
5862
  rej = reject;
5863
5863
  });
5864
5864
  return { promise, resolve: res, reject: rej };
@@ -7282,8 +7282,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
7282
7282
  });
7283
7283
  }
7284
7284
  });
7285
- const busboyResolve = new Promise((resolve10, reject) => {
7286
- busboy.on("finish", resolve10);
7285
+ const busboyResolve = new Promise((resolve11, reject) => {
7286
+ busboy.on("finish", resolve11);
7287
7287
  busboy.on("error", (err) => reject(new TypeError(err)));
7288
7288
  });
7289
7289
  if (this.body !== null)
@@ -7714,9 +7714,9 @@ var require_dispatcher_base = __commonJS({
7714
7714
  }
7715
7715
  close(callback) {
7716
7716
  if (callback === void 0) {
7717
- return new Promise((resolve10, reject) => {
7717
+ return new Promise((resolve11, reject) => {
7718
7718
  this.close((err, data) => {
7719
- return err ? reject(err) : resolve10(data);
7719
+ return err ? reject(err) : resolve11(data);
7720
7720
  });
7721
7721
  });
7722
7722
  }
@@ -7754,12 +7754,12 @@ var require_dispatcher_base = __commonJS({
7754
7754
  err = null;
7755
7755
  }
7756
7756
  if (callback === void 0) {
7757
- return new Promise((resolve10, reject) => {
7757
+ return new Promise((resolve11, reject) => {
7758
7758
  this.destroy(err, (err2, data) => {
7759
7759
  return err2 ? (
7760
7760
  /* istanbul ignore next: should never error */
7761
7761
  reject(err2)
7762
- ) : resolve10(data);
7762
+ ) : resolve11(data);
7763
7763
  });
7764
7764
  });
7765
7765
  }
@@ -8751,16 +8751,16 @@ var require_client = __commonJS({
8751
8751
  return this[kNeedDrain] < 2;
8752
8752
  }
8753
8753
  async [kClose]() {
8754
- return new Promise((resolve10) => {
8754
+ return new Promise((resolve11) => {
8755
8755
  if (!this[kSize]) {
8756
- this.destroy(resolve10);
8756
+ this.destroy(resolve11);
8757
8757
  } else {
8758
- this[kClosedResolve] = resolve10;
8758
+ this[kClosedResolve] = resolve11;
8759
8759
  }
8760
8760
  });
8761
8761
  }
8762
8762
  async [kDestroy](err) {
8763
- return new Promise((resolve10) => {
8763
+ return new Promise((resolve11) => {
8764
8764
  const requests = this[kQueue].splice(this[kPendingIdx]);
8765
8765
  for (let i = 0; i < requests.length; i++) {
8766
8766
  const request2 = requests[i];
@@ -8771,7 +8771,7 @@ var require_client = __commonJS({
8771
8771
  this[kClosedResolve]();
8772
8772
  this[kClosedResolve] = null;
8773
8773
  }
8774
- resolve10();
8774
+ resolve11();
8775
8775
  };
8776
8776
  if (!this[kSocket]) {
8777
8777
  queueMicrotask(callback);
@@ -9307,7 +9307,7 @@ var require_client = __commonJS({
9307
9307
  });
9308
9308
  }
9309
9309
  try {
9310
- const socket = await new Promise((resolve10, reject) => {
9310
+ const socket = await new Promise((resolve11, reject) => {
9311
9311
  client[kConnector]({
9312
9312
  host,
9313
9313
  hostname,
@@ -9319,7 +9319,7 @@ var require_client = __commonJS({
9319
9319
  if (err) {
9320
9320
  reject(err);
9321
9321
  } else {
9322
- resolve10(socket2);
9322
+ resolve11(socket2);
9323
9323
  }
9324
9324
  });
9325
9325
  });
@@ -9698,12 +9698,12 @@ upgrade: ${upgrade}\r
9698
9698
  cb();
9699
9699
  }
9700
9700
  }
9701
- const waitForDrain = () => new Promise((resolve10, reject) => {
9701
+ const waitForDrain = () => new Promise((resolve11, reject) => {
9702
9702
  assert(callback === null);
9703
9703
  if (socket[kError]) {
9704
9704
  reject(socket[kError]);
9705
9705
  } else {
9706
- callback = resolve10;
9706
+ callback = resolve11;
9707
9707
  }
9708
9708
  });
9709
9709
  socket.on("close", onDrain).on("drain", onDrain);
@@ -10024,8 +10024,8 @@ var require_pool_base = __commonJS({
10024
10024
  if (this[kQueue].isEmpty()) {
10025
10025
  return Promise.all(this[kClients].map((c2) => c2.close()));
10026
10026
  } else {
10027
- return new Promise((resolve10) => {
10028
- this[kClosedResolve] = resolve10;
10027
+ return new Promise((resolve11) => {
10028
+ this[kClosedResolve] = resolve11;
10029
10029
  });
10030
10030
  }
10031
10031
  }
@@ -10587,11 +10587,11 @@ var require_readable = __commonJS({
10587
10587
  throw new TypeError("unusable");
10588
10588
  }
10589
10589
  assert(!stream[kConsume]);
10590
- return new Promise((resolve10, reject) => {
10590
+ return new Promise((resolve11, reject) => {
10591
10591
  stream[kConsume] = {
10592
10592
  type,
10593
10593
  stream,
10594
- resolve: resolve10,
10594
+ resolve: resolve11,
10595
10595
  reject,
10596
10596
  length: 0,
10597
10597
  body: []
@@ -10626,12 +10626,12 @@ var require_readable = __commonJS({
10626
10626
  }
10627
10627
  }
10628
10628
  function consumeEnd(consume2) {
10629
- const { type, body, resolve: resolve10, stream, length } = consume2;
10629
+ const { type, body, resolve: resolve11, stream, length } = consume2;
10630
10630
  try {
10631
10631
  if (type === "text") {
10632
- resolve10(toUSVString(Buffer.concat(body)));
10632
+ resolve11(toUSVString(Buffer.concat(body)));
10633
10633
  } else if (type === "json") {
10634
- resolve10(JSON.parse(Buffer.concat(body)));
10634
+ resolve11(JSON.parse(Buffer.concat(body)));
10635
10635
  } else if (type === "arrayBuffer") {
10636
10636
  const dst = new Uint8Array(length);
10637
10637
  let pos = 0;
@@ -10639,12 +10639,12 @@ var require_readable = __commonJS({
10639
10639
  dst.set(buf, pos);
10640
10640
  pos += buf.byteLength;
10641
10641
  }
10642
- resolve10(dst);
10642
+ resolve11(dst);
10643
10643
  } else if (type === "blob") {
10644
10644
  if (!Blob2) {
10645
10645
  Blob2 = require("buffer").Blob;
10646
10646
  }
10647
- resolve10(new Blob2(body, { type: stream[kContentType] }));
10647
+ resolve11(new Blob2(body, { type: stream[kContentType] }));
10648
10648
  }
10649
10649
  consumeFinish(consume2);
10650
10650
  } catch (err) {
@@ -10878,9 +10878,9 @@ var require_api_request = __commonJS({
10878
10878
  }
10879
10879
  function request2(opts, callback) {
10880
10880
  if (callback === void 0) {
10881
- return new Promise((resolve10, reject) => {
10881
+ return new Promise((resolve11, reject) => {
10882
10882
  request2.call(this, opts, (err, data) => {
10883
- return err ? reject(err) : resolve10(data);
10883
+ return err ? reject(err) : resolve11(data);
10884
10884
  });
10885
10885
  });
10886
10886
  }
@@ -11032,9 +11032,9 @@ var require_api_stream = __commonJS({
11032
11032
  };
11033
11033
  function stream(opts, factory, callback) {
11034
11034
  if (callback === void 0) {
11035
- return new Promise((resolve10, reject) => {
11035
+ return new Promise((resolve11, reject) => {
11036
11036
  stream.call(this, opts, factory, (err, data) => {
11037
- return err ? reject(err) : resolve10(data);
11037
+ return err ? reject(err) : resolve11(data);
11038
11038
  });
11039
11039
  });
11040
11040
  }
@@ -11315,9 +11315,9 @@ var require_api_upgrade = __commonJS({
11315
11315
  };
11316
11316
  function upgrade(opts, callback) {
11317
11317
  if (callback === void 0) {
11318
- return new Promise((resolve10, reject) => {
11318
+ return new Promise((resolve11, reject) => {
11319
11319
  upgrade.call(this, opts, (err, data) => {
11320
- return err ? reject(err) : resolve10(data);
11320
+ return err ? reject(err) : resolve11(data);
11321
11321
  });
11322
11322
  });
11323
11323
  }
@@ -11403,9 +11403,9 @@ var require_api_connect = __commonJS({
11403
11403
  };
11404
11404
  function connect(opts, callback) {
11405
11405
  if (callback === void 0) {
11406
- return new Promise((resolve10, reject) => {
11406
+ return new Promise((resolve11, reject) => {
11407
11407
  connect.call(this, opts, (err, data) => {
11408
- return err ? reject(err) : resolve10(data);
11408
+ return err ? reject(err) : resolve11(data);
11409
11409
  });
11410
11410
  });
11411
11411
  }
@@ -14720,7 +14720,7 @@ var require_fetch = __commonJS({
14720
14720
  async function dispatch({ body }) {
14721
14721
  const url = requestCurrentURL(request2);
14722
14722
  const agent = fetchParams.controller.dispatcher;
14723
- return new Promise((resolve10, reject) => agent.dispatch(
14723
+ return new Promise((resolve11, reject) => agent.dispatch(
14724
14724
  {
14725
14725
  path: url.pathname + url.search,
14726
14726
  origin: url.origin,
@@ -14776,7 +14776,7 @@ var require_fetch = __commonJS({
14776
14776
  }
14777
14777
  }
14778
14778
  }
14779
- resolve10({
14779
+ resolve11({
14780
14780
  status: status2,
14781
14781
  statusText,
14782
14782
  headersList: headers[kHeadersList],
@@ -14819,7 +14819,7 @@ var require_fetch = __commonJS({
14819
14819
  const val = headersList[n + 1].toString("latin1");
14820
14820
  headers.append(key, val);
14821
14821
  }
14822
- resolve10({
14822
+ resolve11({
14823
14823
  status: status2,
14824
14824
  statusText: STATUS_CODES[status2],
14825
14825
  headersList: headers[kHeadersList],
@@ -18100,14 +18100,14 @@ var require_open = __commonJS({
18100
18100
  }
18101
18101
  const subprocess = childProcess.spawn(command2, cliArguments, childProcessOptions);
18102
18102
  if (options.wait) {
18103
- return new Promise((resolve10, reject) => {
18103
+ return new Promise((resolve11, reject) => {
18104
18104
  subprocess.once("error", reject);
18105
18105
  subprocess.once("close", (exitCode) => {
18106
18106
  if (options.allowNonzeroExitCode && exitCode > 0) {
18107
18107
  reject(new Error(`Exited with code ${exitCode}`));
18108
18108
  return;
18109
18109
  }
18110
- resolve10(subprocess);
18110
+ resolve11(subprocess);
18111
18111
  });
18112
18112
  });
18113
18113
  }
@@ -21344,13 +21344,13 @@ var require_packet = __commonJS({
21344
21344
  let chunklen = 0;
21345
21345
  let received = false;
21346
21346
  let expected = false;
21347
- return new Promise((resolve10, reject) => {
21347
+ return new Promise((resolve11, reject) => {
21348
21348
  const processMessage = () => {
21349
21349
  if (received)
21350
21350
  return;
21351
21351
  received = true;
21352
21352
  const buffer = Buffer.concat(chunks, chunklen);
21353
- resolve10(buffer.slice(2));
21353
+ resolve11(buffer.slice(2));
21354
21354
  };
21355
21355
  socket.on("end", processMessage);
21356
21356
  socket.on("error", reject);
@@ -21412,16 +21412,16 @@ var require_udp = __commonJS({
21412
21412
  if (message instanceof Packet) {
21413
21413
  message = message.toBuffer();
21414
21414
  }
21415
- return new Promise((resolve10, reject) => {
21415
+ return new Promise((resolve11, reject) => {
21416
21416
  this.send(message, rinfo.port, rinfo.address, (err) => {
21417
21417
  if (err)
21418
21418
  return reject(err);
21419
- resolve10(message);
21419
+ resolve11(message);
21420
21420
  });
21421
21421
  });
21422
21422
  }
21423
21423
  listen(port, address) {
21424
- return new Promise((resolve10) => this.bind(port, address, resolve10));
21424
+ return new Promise((resolve11) => this.bind(port, address, resolve11));
21425
21425
  }
21426
21426
  };
21427
21427
  module2.exports = Server;
@@ -21484,11 +21484,11 @@ var require_doh = __commonJS({
21484
21484
  }
21485
21485
  return queryData;
21486
21486
  };
21487
- var readStream = (stream) => new Promise((resolve10, reject) => {
21487
+ var readStream = (stream) => new Promise((resolve11, reject) => {
21488
21488
  let buffer = "";
21489
21489
  stream.on("error", reject).on("data", (chunk) => {
21490
21490
  buffer += chunk;
21491
- }).on("end", () => resolve10(buffer));
21491
+ }).on("end", () => resolve11(buffer));
21492
21492
  });
21493
21493
  var Server = class extends EventEmitter {
21494
21494
  constructor(options) {
@@ -21614,12 +21614,12 @@ var require_dns = __commonJS({
21614
21614
  }
21615
21615
  const servers = Object.values(this.servers);
21616
21616
  this.closed = Promise.all(
21617
- servers.map((server) => new Promise((resolve10) => server.once("close", resolve10)))
21617
+ servers.map((server) => new Promise((resolve11) => server.once("close", resolve11)))
21618
21618
  ).then(() => {
21619
21619
  this.emit("close");
21620
21620
  });
21621
21621
  this.listening = Promise.all(
21622
- servers.map((server) => new Promise((resolve10) => server.once("listening", resolve10)))
21622
+ servers.map((server) => new Promise((resolve11) => server.once("listening", resolve11)))
21623
21623
  ).then(() => {
21624
21624
  const addresses = this.addresses();
21625
21625
  this.emit("listening", addresses);
@@ -21751,18 +21751,18 @@ var require_tcp2 = __commonJS({
21751
21751
  var require_doh2 = __commonJS({
21752
21752
  "../../node_modules/.pnpm/dns2@2.1.0/node_modules/dns2/client/doh.js"(exports2, module2) {
21753
21753
  var Packet = require_packet();
21754
- var defaultGet = (url) => new Promise((resolve10, reject) => {
21754
+ var defaultGet = (url) => new Promise((resolve11, reject) => {
21755
21755
  const headers = {
21756
21756
  accept: "application/dns-message"
21757
21757
  };
21758
21758
  const base = url.startsWith("https") ? require("https") : require("http");
21759
- const req = base.get(url, { headers }, resolve10);
21759
+ const req = base.get(url, { headers }, resolve11);
21760
21760
  req.on("error", reject);
21761
21761
  });
21762
21762
  var readStream = (stream) => {
21763
21763
  const buffer = [];
21764
- return new Promise((resolve10, reject) => {
21765
- stream.on("error", reject).on("data", (chunk) => buffer.push(chunk)).on("end", () => resolve10(Buffer.concat(buffer)));
21764
+ return new Promise((resolve11, reject) => {
21765
+ stream.on("error", reject).on("data", (chunk) => buffer.push(chunk)).on("end", () => resolve11(Buffer.concat(buffer)));
21766
21766
  });
21767
21767
  };
21768
21768
  var DOHClient = ({ dns, http, get = defaultGet } = {}) => {
@@ -21815,12 +21815,12 @@ var require_udp2 = __commonJS({
21815
21815
  type: Packet.TYPE[type]
21816
21816
  });
21817
21817
  const client = new udp.Socket(socketType);
21818
- return new Promise((resolve10, reject) => {
21818
+ return new Promise((resolve11, reject) => {
21819
21819
  client.once("message", function onMessage(message) {
21820
21820
  client.close();
21821
21821
  const response = Packet.parse(message);
21822
21822
  equal(response.header.id, query.header.id);
21823
- resolve10(response);
21823
+ resolve11(response);
21824
21824
  });
21825
21825
  debug2("send", dns, query.toBuffer());
21826
21826
  client.send(query.toBuffer(), port, dns, (err) => err && reject(err));
@@ -21834,13 +21834,13 @@ var require_udp2 = __commonJS({
21834
21834
  var require_google = __commonJS({
21835
21835
  "../../node_modules/.pnpm/dns2@2.1.0/node_modules/dns2/client/google.js"(exports2, module2) {
21836
21836
  var https = require("https");
21837
- var get = (url) => new Promise((resolve10) => https.get(url, resolve10));
21837
+ var get = (url) => new Promise((resolve11) => https.get(url, resolve11));
21838
21838
  var readStream = (stream) => {
21839
21839
  const buffer = [];
21840
- return new Promise((resolve10, reject) => {
21840
+ return new Promise((resolve11, reject) => {
21841
21841
  stream.on("error", reject).on("data", (chunk) => {
21842
21842
  buffer.push(chunk);
21843
- }).on("end", () => resolve10(Buffer.concat(buffer)));
21843
+ }).on("end", () => resolve11(Buffer.concat(buffer)));
21844
21844
  });
21845
21845
  };
21846
21846
  var GoogleClient = () => (name2, type = "ANY") => {
@@ -21901,8 +21901,8 @@ var require_dns2 = __commonJS({
21901
21901
  const { port, nameServers, recursive, resolverProtocol = "UDP" } = this;
21902
21902
  const createResolver = DNS[resolverProtocol + "Client"];
21903
21903
  return Promise.race(nameServers.map((address) => {
21904
- const resolve10 = createResolver({ dns: address, port, recursive });
21905
- return resolve10(name2, type, cls, clientIp);
21904
+ const resolve11 = createResolver({ dns: address, port, recursive });
21905
+ return resolve11(name2, type, cls, clientIp);
21906
21906
  }));
21907
21907
  }
21908
21908
  /**
@@ -23857,20 +23857,20 @@ var require_parse_async = __commonJS({
23857
23857
  const index = 0;
23858
23858
  const blocksize = opts.blocksize || 40960;
23859
23859
  const parser2 = new TOMLParser();
23860
- return new Promise((resolve10, reject) => {
23861
- setImmediate(parseAsyncNext, index, blocksize, resolve10, reject);
23860
+ return new Promise((resolve11, reject) => {
23861
+ setImmediate(parseAsyncNext, index, blocksize, resolve11, reject);
23862
23862
  });
23863
- function parseAsyncNext(index2, blocksize2, resolve10, reject) {
23863
+ function parseAsyncNext(index2, blocksize2, resolve11, reject) {
23864
23864
  if (index2 >= str.length) {
23865
23865
  try {
23866
- return resolve10(parser2.finish());
23866
+ return resolve11(parser2.finish());
23867
23867
  } catch (err) {
23868
23868
  return reject(prettyError(err, str));
23869
23869
  }
23870
23870
  }
23871
23871
  try {
23872
23872
  parser2.parse(str.slice(index2, index2 + blocksize2));
23873
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve10, reject);
23873
+ setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve11, reject);
23874
23874
  } catch (err) {
23875
23875
  reject(prettyError(err, str));
23876
23876
  }
@@ -23896,7 +23896,7 @@ var require_parse_stream = __commonJS({
23896
23896
  function parseReadable(stm) {
23897
23897
  const parser2 = new TOMLParser();
23898
23898
  stm.setEncoding("utf8");
23899
- return new Promise((resolve10, reject) => {
23899
+ return new Promise((resolve11, reject) => {
23900
23900
  let readable;
23901
23901
  let ended = false;
23902
23902
  let errored = false;
@@ -23905,7 +23905,7 @@ var require_parse_stream = __commonJS({
23905
23905
  if (readable)
23906
23906
  return;
23907
23907
  try {
23908
- resolve10(parser2.finish());
23908
+ resolve11(parser2.finish());
23909
23909
  } catch (err) {
23910
23910
  reject(err);
23911
23911
  }
@@ -24364,11 +24364,11 @@ function __metadata(metadataKey, metadataValue) {
24364
24364
  }
24365
24365
  function __awaiter(thisArg, _arguments, P2, generator) {
24366
24366
  function adopt(value) {
24367
- return value instanceof P2 ? value : new P2(function(resolve10) {
24368
- resolve10(value);
24367
+ return value instanceof P2 ? value : new P2(function(resolve11) {
24368
+ resolve11(value);
24369
24369
  });
24370
24370
  }
24371
- return new (P2 || (P2 = Promise))(function(resolve10, reject) {
24371
+ return new (P2 || (P2 = Promise))(function(resolve11, reject) {
24372
24372
  function fulfilled(value) {
24373
24373
  try {
24374
24374
  step(generator.next(value));
@@ -24384,7 +24384,7 @@ function __awaiter(thisArg, _arguments, P2, generator) {
24384
24384
  }
24385
24385
  }
24386
24386
  function step(result) {
24387
- result.done ? resolve10(result.value) : adopt(result.value).then(fulfilled, rejected);
24387
+ result.done ? resolve11(result.value) : adopt(result.value).then(fulfilled, rejected);
24388
24388
  }
24389
24389
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24390
24390
  });
@@ -24590,14 +24590,14 @@ function __asyncValues(o) {
24590
24590
  }, i);
24591
24591
  function verb(n) {
24592
24592
  i[n] = o[n] && function(v2) {
24593
- return new Promise(function(resolve10, reject) {
24594
- v2 = o[n](v2), settle(resolve10, reject, v2.done, v2.value);
24593
+ return new Promise(function(resolve11, reject) {
24594
+ v2 = o[n](v2), settle(resolve11, reject, v2.done, v2.value);
24595
24595
  });
24596
24596
  };
24597
24597
  }
24598
- function settle(resolve10, reject, d2, v2) {
24598
+ function settle(resolve11, reject, d2, v2) {
24599
24599
  Promise.resolve(v2).then(function(v3) {
24600
- resolve10({ value: v3, done: d2 });
24600
+ resolve11({ value: v3, done: d2 });
24601
24601
  }, reject);
24602
24602
  }
24603
24603
  }
@@ -28250,7 +28250,7 @@ var require_util6 = __commonJS({
28250
28250
  return path3;
28251
28251
  }
28252
28252
  exports2.normalize = normalize2;
28253
- function join2(aRoot, aPath) {
28253
+ function join3(aRoot, aPath) {
28254
28254
  if (aRoot === "") {
28255
28255
  aRoot = ".";
28256
28256
  }
@@ -28282,7 +28282,7 @@ var require_util6 = __commonJS({
28282
28282
  }
28283
28283
  return joined;
28284
28284
  }
28285
- exports2.join = join2;
28285
+ exports2.join = join3;
28286
28286
  exports2.isAbsolute = function(aPath) {
28287
28287
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
28288
28288
  };
@@ -28455,7 +28455,7 @@ var require_util6 = __commonJS({
28455
28455
  parsed.path = parsed.path.substring(0, index + 1);
28456
28456
  }
28457
28457
  }
28458
- sourceURL = join2(urlGenerate(parsed), sourceURL);
28458
+ sourceURL = join3(urlGenerate(parsed), sourceURL);
28459
28459
  }
28460
28460
  return normalize2(sourceURL);
28461
28461
  }
@@ -61118,12 +61118,12 @@ var YargsInstance = class {
61118
61118
  async getCompletion(args, done) {
61119
61119
  argsert("<array> [function]", [args, done], arguments.length);
61120
61120
  if (!done) {
61121
- return new Promise((resolve10, reject) => {
61121
+ return new Promise((resolve11, reject) => {
61122
61122
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
61123
61123
  if (err)
61124
61124
  reject(err);
61125
61125
  else
61126
- resolve10(completions);
61126
+ resolve11(completions);
61127
61127
  });
61128
61128
  });
61129
61129
  } else {
@@ -62163,7 +62163,7 @@ var Yargs = YargsFactory(esm_default);
62163
62163
  var yargs_default = Yargs;
62164
62164
 
62165
62165
  // package.json
62166
- var version = "2.9.0";
62166
+ var version = "2.9.1";
62167
62167
  var devDependencies = {
62168
62168
  "@babel/parser": "^7.21.3",
62169
62169
  "@babel/types": "^7.21.4",
@@ -62215,7 +62215,7 @@ var import_promises = require("node:fs/promises");
62215
62215
  var import_node_path = require("node:path");
62216
62216
 
62217
62217
  // src/helpers/command.ts
62218
- var import_fs6 = require("fs");
62218
+ var import_fs7 = require("fs");
62219
62219
  var import_path6 = __toESM(require("path"));
62220
62220
  var import_cross_spawn = __toESM(require_cross_spawn());
62221
62221
  var import_undici2 = __toESM(require_undici());
@@ -62430,7 +62430,7 @@ function secondsSince(start) {
62430
62430
  var import_shell_quote = __toESM(require_shell_quote());
62431
62431
 
62432
62432
  // ../wrangler/package.json
62433
- var version2 = "3.22.3";
62433
+ var version2 = "3.22.5";
62434
62434
 
62435
62435
  // src/common.ts
62436
62436
  var { name, npm } = detectPackageManager();
@@ -62858,6 +62858,75 @@ function quoteShellArgs(args) {
62858
62858
  }
62859
62859
  }
62860
62860
 
62861
+ // src/helpers/files.ts
62862
+ var import_fs6 = __toESM(require("fs"));
62863
+ var import_toml = __toESM(require_toml());
62864
+ var writeFile2 = (path3, content) => {
62865
+ try {
62866
+ import_fs6.default.writeFileSync(path3, content);
62867
+ } catch (error) {
62868
+ crash(error);
62869
+ }
62870
+ };
62871
+ var readFile = (path3) => {
62872
+ try {
62873
+ return import_fs6.default.readFileSync(path3, "utf-8");
62874
+ } catch (error) {
62875
+ return crash(error);
62876
+ }
62877
+ };
62878
+ var readJSON = (path3) => {
62879
+ const contents = readFile(path3);
62880
+ return contents ? JSON.parse(contents) : contents;
62881
+ };
62882
+ var writeJSON = (path3, object, stringifySpace = 2) => {
62883
+ writeFile2(path3, JSON.stringify(object, null, stringifySpace));
62884
+ };
62885
+ var probePaths = (paths) => {
62886
+ for (const path3 of paths) {
62887
+ if ((0, import_fs6.existsSync)(path3)) {
62888
+ return path3;
62889
+ }
62890
+ }
62891
+ return null;
62892
+ };
62893
+ var usesTypescript = (projectRoot = ".") => {
62894
+ return (0, import_fs6.existsSync)(`${projectRoot}/tsconfig.json`);
62895
+ };
62896
+ var eslintRcExts = ["js", "cjs", "yaml", "yml", "json"];
62897
+ var usesEslint = (ctx) => {
62898
+ for (const ext of eslintRcExts) {
62899
+ const eslintRcFilename = `.eslintrc.${ext}`;
62900
+ if ((0, import_fs6.existsSync)(`${ctx.project.path}/${eslintRcFilename}`)) {
62901
+ return {
62902
+ used: true,
62903
+ configType: eslintRcFilename
62904
+ };
62905
+ }
62906
+ }
62907
+ if ((0, import_fs6.existsSync)(`${ctx.project.path}/eslint.config.js`)) {
62908
+ return {
62909
+ used: true,
62910
+ configType: "eslint.config.js"
62911
+ };
62912
+ }
62913
+ try {
62914
+ const pkgJson = readJSON(`${ctx.project.path}/package.json`);
62915
+ if (pkgJson.eslintConfig) {
62916
+ return {
62917
+ used: true,
62918
+ configType: "package.json"
62919
+ };
62920
+ }
62921
+ } catch {
62922
+ }
62923
+ return { used: false };
62924
+ };
62925
+ var compatDateFlag = async () => {
62926
+ const workerdCompatDate = await getWorkerdCompatibilityDate();
62927
+ return `--compatibility-date=${workerdCompatDate}`;
62928
+ };
62929
+
62861
62930
  // src/helpers/command.ts
62862
62931
  var runCommand = async (command2, opts = {}) => {
62863
62932
  return printAsyncStatus({
@@ -62885,7 +62954,7 @@ var runCommand = async (command2, opts = {}) => {
62885
62954
  output += data;
62886
62955
  });
62887
62956
  }
62888
- return new Promise((resolve10, reject) => {
62957
+ return new Promise((resolvePromise, reject) => {
62889
62958
  cmd.on("close", (code) => {
62890
62959
  try {
62891
62960
  if (code !== 0) {
@@ -62893,10 +62962,10 @@ var runCommand = async (command2, opts = {}) => {
62893
62962
  }
62894
62963
  const transformOutput = opts.transformOutput ?? ((result) => result);
62895
62964
  const processedOutput = transformOutput(stripAnsi(output));
62896
- resolve10(processedOutput);
62965
+ resolvePromise(processedOutput);
62897
62966
  } catch (e) {
62898
62967
  if (opts.fallbackOutput) {
62899
- resolve10(opts.fallbackOutput(e));
62968
+ resolvePromise(opts.fallbackOutput(e));
62900
62969
  } else {
62901
62970
  reject(new Error(output, { cause: e }));
62902
62971
  }
@@ -62966,9 +63035,9 @@ var retry = async ({
62966
63035
  };
62967
63036
  var runFrameworkGenerator = async (ctx, args) => {
62968
63037
  const cli = getFrameworkCli(ctx, true);
62969
- const { npm: npm15, dlx: dlx2 } = detectPackageManager();
62970
- const cmd = [...npm15 === "yarn" ? ["npx"] : dlx2, cli, ...args];
62971
- const env3 = npm15 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
63038
+ const { npm: npm14, dlx: dlx2 } = detectPackageManager();
63039
+ const cmd = [...npm14 === "yarn" ? ["npx"] : dlx2, cli, ...args];
63040
+ const env3 = npm14 === "yarn" ? { npm_config_user_agent: "yarn" } : {};
62972
63041
  if (ctx.framework?.args?.length) {
62973
63042
  cmd.push(...ctx.framework.args);
62974
63043
  }
@@ -62983,10 +63052,10 @@ var runFrameworkGenerator = async (ctx, args) => {
62983
63052
  await runCommand(cmd, { env: env3 });
62984
63053
  };
62985
63054
  var installPackages = async (packages, config14) => {
62986
- const { npm: npm15 } = detectPackageManager();
63055
+ const { npm: npm14 } = detectPackageManager();
62987
63056
  let saveFlag;
62988
63057
  let cmd;
62989
- switch (npm15) {
63058
+ switch (npm14) {
62990
63059
  case "yarn":
62991
63060
  cmd = "add";
62992
63061
  saveFlag = config14.dev ? "-D" : "";
@@ -63002,54 +63071,54 @@ var installPackages = async (packages, config14) => {
63002
63071
  saveFlag = config14.dev ? "--save-dev" : "--save";
63003
63072
  break;
63004
63073
  }
63005
- await runCommand([npm15, cmd, saveFlag, ...packages], {
63074
+ await runCommand([npm14, cmd, saveFlag, ...packages], {
63006
63075
  ...config14,
63007
63076
  silent: true
63008
63077
  });
63009
63078
  };
63010
63079
  var resetPackageManager = async (ctx) => {
63011
- const { npm: npm15 } = detectPackageManager();
63080
+ const { npm: npm14 } = detectPackageManager();
63012
63081
  if (!needsPackageManagerReset(ctx)) {
63013
63082
  return;
63014
63083
  }
63015
63084
  const nodeModulesPath = import_path6.default.join(ctx.project.path, "node_modules");
63016
- if ((0, import_fs6.existsSync)(nodeModulesPath))
63017
- (0, import_fs6.rmSync)(nodeModulesPath, { recursive: true });
63085
+ if ((0, import_fs7.existsSync)(nodeModulesPath))
63086
+ (0, import_fs7.rmSync)(nodeModulesPath, { recursive: true });
63018
63087
  const lockfilePath = import_path6.default.join(ctx.project.path, "package-lock.json");
63019
- if ((0, import_fs6.existsSync)(lockfilePath))
63020
- (0, import_fs6.rmSync)(lockfilePath);
63021
- await runCommand([npm15, "install"], {
63088
+ if ((0, import_fs7.existsSync)(lockfilePath))
63089
+ (0, import_fs7.rmSync)(lockfilePath);
63090
+ await runCommand([npm14, "install"], {
63022
63091
  silent: true,
63023
63092
  cwd: ctx.project.path,
63024
63093
  startText: "Installing dependencies",
63025
- doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
63094
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
63026
63095
  });
63027
63096
  };
63028
63097
  var needsPackageManagerReset = (ctx) => {
63029
- const { npm: npm15 } = detectPackageManager();
63098
+ const { npm: npm14 } = detectPackageManager();
63030
63099
  const projectPath = ctx.project.path;
63031
- switch (npm15) {
63100
+ switch (npm14) {
63032
63101
  case "npm":
63033
63102
  return false;
63034
63103
  case "yarn":
63035
- return !(0, import_fs6.existsSync)(import_path6.default.join(projectPath, "yarn.lock"));
63104
+ return !(0, import_fs7.existsSync)(import_path6.default.join(projectPath, "yarn.lock"));
63036
63105
  case "pnpm":
63037
- return !(0, import_fs6.existsSync)(import_path6.default.join(projectPath, "pnpm-lock.yaml"));
63106
+ return !(0, import_fs7.existsSync)(import_path6.default.join(projectPath, "pnpm-lock.yaml"));
63038
63107
  case "bun":
63039
- return !(0, import_fs6.existsSync)(import_path6.default.join(projectPath, "bun.lockb"));
63108
+ return !(0, import_fs7.existsSync)(import_path6.default.join(projectPath, "bun.lockb"));
63040
63109
  }
63041
63110
  };
63042
63111
  var npmInstall = async () => {
63043
- const { npm: npm15 } = detectPackageManager();
63044
- await runCommand([npm15, "install"], {
63112
+ const { npm: npm14 } = detectPackageManager();
63113
+ await runCommand([npm14, "install"], {
63045
63114
  silent: true,
63046
63115
  startText: "Installing dependencies",
63047
- doneText: `${brandColor("installed")} ${dim(`via \`${npm15} install\``)}`
63116
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
63048
63117
  });
63049
63118
  };
63050
63119
  var installWrangler = async () => {
63051
- const { npm: npm15 } = detectPackageManager();
63052
- if ((0, import_fs6.existsSync)(import_path6.default.resolve("node_modules", "wrangler"))) {
63120
+ const { npm: npm14 } = detectPackageManager();
63121
+ if ((0, import_fs7.existsSync)(import_path6.default.resolve("node_modules", "wrangler"))) {
63053
63122
  return;
63054
63123
  }
63055
63124
  await installPackages([`wrangler`], {
@@ -63058,7 +63127,7 @@ var installWrangler = async () => {
63058
63127
  "A command line tool for building Cloudflare Workers"
63059
63128
  )}`,
63060
63129
  doneText: `${brandColor("installed")} ${dim(
63061
- `via \`${npm15} install wrangler --save-dev\``
63130
+ `via \`${npm14} install wrangler --save-dev\``
63062
63131
  )}`
63063
63132
  });
63064
63133
  };
@@ -63126,75 +63195,71 @@ async function getWorkerdCompatibilityDate() {
63126
63195
  });
63127
63196
  return workerdCompatibilityDate;
63128
63197
  }
63129
-
63130
- // src/helpers/files.ts
63131
- var import_fs7 = __toESM(require("fs"));
63132
- var import_toml = __toESM(require_toml());
63133
- var writeFile2 = (path3, content) => {
63134
- try {
63135
- import_fs7.default.writeFileSync(path3, content);
63136
- } catch (error) {
63137
- crash(error);
63138
- }
63139
- };
63140
- var readFile = (path3) => {
63198
+ async function installWorkersTypes(ctx) {
63199
+ const { npm: npm14 } = detectPackageManager();
63200
+ await installPackages(["@cloudflare/workers-types"], {
63201
+ dev: true,
63202
+ startText: `Installing @cloudflare/workers-types`,
63203
+ doneText: `${brandColor("installed")} ${dim(`via ${npm14}`)}`
63204
+ });
63205
+ await addWorkersTypesToTsConfig(ctx);
63206
+ }
63207
+ function getLatestTypesEntrypoint(ctx) {
63208
+ const workersTypesPath = (0, import_path6.resolve)(
63209
+ ctx.project.path,
63210
+ "node_modules",
63211
+ "@cloudflare",
63212
+ "workers-types"
63213
+ );
63141
63214
  try {
63142
- return import_fs7.default.readFileSync(path3, "utf-8");
63143
- } catch (error) {
63144
- return crash(error);
63145
- }
63146
- };
63147
- var readJSON = (path3) => {
63148
- const contents = readFile(path3);
63149
- return contents ? JSON.parse(contents) : contents;
63150
- };
63151
- var writeJSON = (path3, object, stringifySpace = 2) => {
63152
- writeFile2(path3, JSON.stringify(object, null, stringifySpace));
63153
- };
63154
- var probePaths = (paths) => {
63155
- for (const path3 of paths) {
63156
- if ((0, import_fs7.existsSync)(path3)) {
63157
- return path3;
63215
+ const entrypoints = (0, import_fs7.readdirSync)(workersTypesPath);
63216
+ const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
63217
+ if (sorted.length === 0) {
63218
+ return null;
63158
63219
  }
63220
+ return sorted[0];
63221
+ } catch (error) {
63222
+ return null;
63159
63223
  }
63160
- return null;
63161
- };
63162
- var usesTypescript = (projectRoot = ".") => {
63163
- return (0, import_fs7.existsSync)(`${projectRoot}/tsconfig.json`);
63164
- };
63165
- var eslintRcExts = ["js", "cjs", "yaml", "yml", "json"];
63166
- var usesEslint = (ctx) => {
63167
- for (const ext of eslintRcExts) {
63168
- const eslintRcFilename = `.eslintrc.${ext}`;
63169
- if ((0, import_fs7.existsSync)(`${ctx.project.path}/${eslintRcFilename}`)) {
63170
- return {
63171
- used: true,
63172
- configType: eslintRcFilename
63173
- };
63174
- }
63224
+ }
63225
+ async function addWorkersTypesToTsConfig(ctx) {
63226
+ const tsconfigPath = (0, import_path6.join)(ctx.project.path, "tsconfig.json");
63227
+ if (!(0, import_fs7.existsSync)(tsconfigPath)) {
63228
+ return;
63175
63229
  }
63176
- if ((0, import_fs7.existsSync)(`${ctx.project.path}/eslint.config.js`)) {
63177
- return {
63178
- used: true,
63179
- configType: "eslint.config.js"
63180
- };
63230
+ const s = spinner();
63231
+ s.start(`Adding latest types to \`tsconfig.json\``);
63232
+ const tsconfig = readFile(tsconfigPath);
63233
+ const entrypointVersion = getLatestTypesEntrypoint(ctx);
63234
+ if (entrypointVersion === null) {
63235
+ s.stop(
63236
+ `${brandColor(
63237
+ "skipped"
63238
+ )} couldn't find latest compatible version of @cloudflare/workers-types`
63239
+ );
63240
+ return;
63181
63241
  }
63182
- try {
63183
- const pkgJson = readJSON(`${ctx.project.path}/package.json`);
63184
- if (pkgJson.eslintConfig) {
63185
- return {
63186
- used: true,
63187
- configType: "package.json"
63188
- };
63242
+ const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
63243
+ let updated = tsconfig;
63244
+ if (tsconfig.includes("@cloudflare/workers-types")) {
63245
+ updated = tsconfig.replace("@cloudflare/workers-types", typesEntrypoint);
63246
+ } else {
63247
+ try {
63248
+ const tsConfigJson = JSON.parse(tsconfig);
63249
+ tsConfigJson.compilerOptions ??= {};
63250
+ tsConfigJson.compilerOptions.types = [
63251
+ ...tsConfigJson.compilerOptions.types ?? [],
63252
+ typesEntrypoint
63253
+ ];
63254
+ updated = JSON.stringify(tsConfigJson, null, 2);
63255
+ } catch {
63256
+ warn("Could not parse tsconfig.json file");
63257
+ updated = tsconfig;
63189
63258
  }
63190
- } catch {
63191
63259
  }
63192
- return { used: false };
63193
- };
63194
- var compatDateFlag = async () => {
63195
- const workerdCompatDate = await getWorkerdCompatibilityDate();
63196
- return `--compatibility-date=${workerdCompatDate}`;
63197
- };
63260
+ writeFile2(tsconfigPath, updated);
63261
+ s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
63262
+ }
63198
63263
 
63199
63264
  // src/frameworks/angular/index.ts
63200
63265
  var { npm: npm2 } = detectPackageManager();
@@ -63379,8 +63444,22 @@ var hono_default = config5;
63379
63444
  var import_fs8 = require("fs");
63380
63445
 
63381
63446
  // src/frameworks/next/templates.ts
63382
- var apiPagesDirHelloTs = `
63383
- // Next.js Edge API Routes: https://nextjs.org/docs/pages/building-your-application/routing/api-routes#edge-api-routes
63447
+ var handlerCode = ` let responseText = 'Hello World'
63448
+
63449
+ // In the edge runtime you can use Bindings that are available in your application
63450
+ // (for more details see:
63451
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
63452
+ // - https://developers.cloudflare.com/pages/functions/bindings/
63453
+ // )
63454
+ //
63455
+ // KV Example:
63456
+ // const myKv = process.env.MY_KV
63457
+ // await myKv.put('suffix', ' from a KV store!')
63458
+ // const suffix = await myKv.get('suffix')
63459
+ // responseText += suffix
63460
+
63461
+ return new Response(responseText)`;
63462
+ var apiPagesDirHelloTs = `// Next.js Edge API Routes: https://nextjs.org/docs/pages/building-your-application/routing/api-routes#edge-api-routes
63384
63463
 
63385
63464
  import type { NextRequest } from 'next/server'
63386
63465
 
@@ -63389,42 +63468,38 @@ export const config = {
63389
63468
  }
63390
63469
 
63391
63470
  export default async function handler(req: NextRequest) {
63392
- return new Response(JSON.stringify({ name: 'John Doe' }))
63471
+ ${handlerCode}
63393
63472
  }
63394
63473
  `;
63395
- var apiPagesDirHelloJs = `
63396
- // Next.js Edge API Routes: https://nextjs.org/docs/pages/building-your-application/routing/api-routes#edge-api-routes
63474
+ var apiPagesDirHelloJs = `// Next.js Edge API Routes: https://nextjs.org/docs/pages/building-your-application/routing/api-routes#edge-api-routes
63397
63475
 
63398
63476
  export const config = {
63399
63477
  runtime: 'edge',
63400
63478
  }
63401
63479
 
63402
63480
  export default async function handler(req) {
63403
- return new Response(JSON.stringify({ name: 'John Doe' }))
63481
+ ${handlerCode}
63404
63482
  }
63405
63483
  `;
63406
- var apiAppDirHelloTs = `
63407
- // Next.js Edge API Route Handlers: https://nextjs.org/docs/app/building-your-application/routing/router-handlers#edge-and-nodejs-runtimes
63484
+ var apiAppDirHelloTs = `// Next.js Edge API Route Handlers: https://nextjs.org/docs/app/building-your-application/routing/router-handlers#edge-and-nodejs-runtimes
63408
63485
 
63409
63486
  import type { NextRequest } from 'next/server'
63410
63487
 
63411
63488
  export const runtime = 'edge'
63412
63489
 
63413
63490
  export async function GET(request: NextRequest) {
63414
- return new Response(JSON.stringify({ name: 'John Doe' }))
63491
+ ${handlerCode}
63415
63492
  }
63416
63493
  `;
63417
- var apiAppDirHelloJs = `
63418
- // Next.js Edge API Route Handlers: https://nextjs.org/docs/app/building-your-application/routing/router-handlers#edge-and-nodejs-runtimes
63494
+ var apiAppDirHelloJs = `// Next.js Edge API Route Handlers: https://nextjs.org/docs/app/building-your-application/routing/router-handlers#edge-and-nodejs-runtimes
63419
63495
 
63420
63496
  export const runtime = 'edge'
63421
63497
 
63422
63498
  export async function GET(request) {
63423
- return new Response(JSON.stringify({ name: 'John Doe' }))
63499
+ ${handlerCode}
63424
63500
  }
63425
63501
  `;
63426
- var appDirNotFoundJs = `
63427
- export const runtime = "edge";
63502
+ var appDirNotFoundJs = `export const runtime = "edge";
63428
63503
 
63429
63504
  export default function NotFound() {
63430
63505
  return (
@@ -63483,8 +63558,7 @@ const styles = {
63483
63558
  },
63484
63559
  };
63485
63560
  `;
63486
- var appDirNotFoundTs = `
63487
- export const runtime = "edge";
63561
+ var appDirNotFoundTs = `export const runtime = "edge";
63488
63562
 
63489
63563
  export default function NotFound() {
63490
63564
  return (
@@ -63543,6 +63617,103 @@ const styles = {
63543
63617
  },
63544
63618
  } as const;
63545
63619
  `;
63620
+ var nextConfig = `/** @type {import('next').NextConfig} */
63621
+ const nextConfig = {}
63622
+
63623
+ module.exports = nextConfig
63624
+
63625
+ // Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
63626
+ // (when running the application with \`next dev\`), for more information see:
63627
+ // https://github.com/dario-piotrowicz/next-on-pages/blob/8e93067/internal-packages/next-dev/README.md
63628
+ if (process.env.NODE_ENV === 'development') {
63629
+ import('@cloudflare/next-on-pages/next-dev').then(({ setupDevBindings }) => {
63630
+ setupDevBindings({
63631
+ bindings: {
63632
+ // Add here the Cloudflare Bindings you want to have available during local development,
63633
+ // for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
63634
+ //
63635
+ // KV Example:
63636
+ // MY_KV: {
63637
+ // type: 'kv',
63638
+ // id: 'xxx',
63639
+ // }
63640
+ }
63641
+ })
63642
+ })
63643
+ }
63644
+ `;
63645
+ var envDts = `declare global {
63646
+ namespace NodeJS {
63647
+ interface ProcessEnv {
63648
+ // Add here the Cloudflare Bindings you want to have available in your application
63649
+ // (for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
63650
+ //
63651
+ // KV Example:
63652
+ // MY_KV: KVNamespace
63653
+ }
63654
+ }
63655
+ }
63656
+
63657
+ export {}
63658
+ `;
63659
+ var readme = `This is a [Next.js](https://nextjs.org/) project bootstrapped with [\`c3\`](https://developers.cloudflare.com/pages/get-started/c3).
63660
+
63661
+ ## Getting Started
63662
+
63663
+ First, run the development server:
63664
+
63665
+ \`\`\`bash
63666
+ npm run dev
63667
+ # or
63668
+ yarn dev
63669
+ # or
63670
+ pnpm dev
63671
+ # or
63672
+ bun dev
63673
+ \`\`\`
63674
+
63675
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
63676
+
63677
+ ## Cloudflare integration
63678
+
63679
+ Besides the \`dev\` script mentioned above \`c3\` has added a few extra scripts that allow you to integrate the application with the [Cloudflare Pages](https://pages.cloudflare.com/) environment, these are:
63680
+ - \`pages:build\` to build the application for Pages using the [\`@cloudflare/next-on-pages\`](https://github.com/cloudflare/next-on-pages) CLI
63681
+ - \`pages:preview\` to locally preview your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
63682
+ - \`pages:deploy\` to deploy your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
63683
+
63684
+ > __Note:__ while the \`dev\` script is optimal for local development you should preview your Pages application as well (periodically or before deployments) in order to make sure that it can properly work in the Pages environment (for more details see the [\`@cloudflare/next-on-pages\` recommended workflow](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md#recommended-workflow))
63685
+
63686
+ ### Bindings
63687
+
63688
+ Cloudflare [Bindings](https://developers.cloudflare.com/pages/functions/bindings/) are what allows you to interact with resources available in the Cloudflare Platform.
63689
+
63690
+ You can use bindings during development, when previewing locally your application and of course in the deployed application:
63691
+
63692
+ - To use bindings in dev mode you need to define them in the \`next.config.js\` file under \`setupDevBindings\`, this mode uses the \`next-dev\` \`@cloudflare/next-on-pages\` submodule. For more details see its [documentation](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md).
63693
+
63694
+ - To use bindings in the preview mode you need to add them to the \`pages:preview\` script accordingly to the \`wrangler pages dev\` command. For more details see its [documentation](https://developers.cloudflare.com/workers/wrangler/commands/#dev-1) or the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
63695
+
63696
+ - To use bindings in the deployed application you will need to configure them in the Cloudflare [dashboard](https://dash.cloudflare.com/). For more details see the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
63697
+
63698
+ #### KV Example
63699
+
63700
+ \`c3\` has added for you an example showing how you can use a KV binding, in order to enable the example, search for lines containing the following comment:
63701
+ \`\`\`ts
63702
+ // KV Example:
63703
+ \`\`\`
63704
+
63705
+ and uncomment the commented lines below it.
63706
+
63707
+ After doing this you can run the \`dev\` script and visit the \`/api/hello\` route to see the example in action.
63708
+
63709
+ To then enable such example also in preview mode add a \`kv\` in the \`pages:preview\` script like so:
63710
+ \`\`\`diff
63711
+ - "pages:preview": "npm run pages:build && wrangler pages dev .vercel/output/static --compatibility-date=2023-12-18 --compatibility-flag=nodejs_compat",
63712
+ + "pages:preview": "npm run pages:build && wrangler pages dev .vercel/output/static --compatibility-date=2023-12-18 --compatibility-flag=nodejs_compat --kv MY_KV",
63713
+ \`\`\`
63714
+
63715
+ Finally, if you also want to see the example work in the deployed application make sure to add a \`MY_KV\` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
63716
+ `;
63546
63717
 
63547
63718
  // src/frameworks/next/index.ts
63548
63719
  var { npm: npm5, npx: npx2 } = detectPackageManager();
@@ -63589,21 +63760,19 @@ var configure3 = async (ctx) => {
63589
63760
  const [handlerPath, handlerFile] = getApiTemplate(apiPath, usesTs);
63590
63761
  writeFile2(handlerPath, handlerFile);
63591
63762
  updateStatus("Created an example API route handler");
63763
+ if (usesTs) {
63764
+ writeFile2(`${projectName}/env.d.ts`, envDts);
63765
+ updateStatus("Created an env.d.ts file");
63766
+ }
63592
63767
  const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
63593
63768
  if (installEslintPlugin) {
63594
63769
  await writeEslintrc(ctx);
63595
63770
  }
63596
- process.chdir(projectName);
63597
- const packages = [
63598
- "@cloudflare/next-on-pages@1",
63599
- "vercel",
63600
- ...installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []
63601
- ];
63602
- await installPackages(packages, {
63603
- dev: true,
63604
- startText: "Adding the Cloudflare Pages adapter",
63605
- doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
63606
- });
63771
+ writeFile2(`${ctx.project.path}/next.config.js`, nextConfig);
63772
+ updateStatus("Updated the next.config.js file");
63773
+ writeFile2(`${ctx.project.path}/README.md`, readme);
63774
+ updateStatus("Updated the README file");
63775
+ await addDevDependencies(projectName, usesTs, ctx, installEslintPlugin);
63607
63776
  };
63608
63777
  var shouldInstallNextOnPagesEslintPlugin = async (ctx) => {
63609
63778
  const eslintUsage = usesEslint(ctx);
@@ -63644,12 +63813,11 @@ var config6 = {
63644
63813
  const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
63645
63814
  const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
63646
63815
  const pmCommand = isNpmOrBun ? npx2 : npm5;
63647
- const pagesDeployCommand = isNpm ? "npm run" : isBun ? "bun" : pmCommand;
63816
+ const pagesBuildRunCommand = `${isNpm ? "npm run" : isBun ? "bun" : pmCommand} pages:build`;
63648
63817
  return {
63649
63818
  "pages:build": `${pmCommand} ${nextOnPagesCommand}`,
63650
- "pages:deploy": `${pagesDeployCommand} pages:build && wrangler pages deploy .vercel/output/static`,
63651
- "pages:watch": `${pmCommand} ${nextOnPagesCommand} --watch`,
63652
- "pages:dev": `${pmCommand} wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`
63819
+ "pages:preview": `${pagesBuildRunCommand} && wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
63820
+ "pages:deploy": `${pagesBuildRunCommand} && wrangler pages deploy .vercel/output/static`
63653
63821
  };
63654
63822
  },
63655
63823
  testFlags: [
@@ -63665,6 +63833,25 @@ var config6 = {
63665
63833
  compatibilityFlags: ["nodejs_compat"]
63666
63834
  };
63667
63835
  var next_default = config6;
63836
+ var addDevDependencies = async (projectName, usesTs, ctx, installEslintPlugin) => {
63837
+ const cwd = process.cwd();
63838
+ process.chdir(projectName);
63839
+ if (usesTs) {
63840
+ await installWorkersTypes(ctx);
63841
+ }
63842
+ const packages = [
63843
+ "@cloudflare/next-on-pages@1",
63844
+ "@cloudflare/workers-types",
63845
+ "vercel",
63846
+ ...installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []
63847
+ ];
63848
+ await installPackages(packages, {
63849
+ dev: true,
63850
+ startText: "Adding the Cloudflare Pages adapter",
63851
+ doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
63852
+ });
63853
+ process.chdir(cwd);
63854
+ };
63668
63855
 
63669
63856
  // src/frameworks/nuxt/index.ts
63670
63857
  var import_node_fs = require("node:fs");
@@ -64181,12 +64368,11 @@ var createProject = async (ctx) => {
64181
64368
  };
64182
64369
 
64183
64370
  // src/workers.ts
64184
- var import_fs9 = require("fs");
64185
64371
  var import_promises2 = require("fs/promises");
64186
64372
  var import_os = require("os");
64187
64373
  var import_path9 = require("path");
64188
64374
  var import_process4 = require("process");
64189
- var { dlx, npm: npm13 } = detectPackageManager();
64375
+ var { dlx } = detectPackageManager();
64190
64376
  var runWorkersGenerator = async (args) => {
64191
64377
  const originalCWD = process.cwd();
64192
64378
  const { name: name2, path: path3 } = setupProjectDirectory(args);
@@ -64214,7 +64400,9 @@ var runWorkersGenerator = async (args) => {
64214
64400
  startSection("Installing dependencies", "Step 2 of 3");
64215
64401
  (0, import_process4.chdir)(ctx.project.path);
64216
64402
  await npmInstall();
64217
- await installWorkersTypes(ctx);
64403
+ if (ctx.args.ts) {
64404
+ await installWorkersTypes(ctx);
64405
+ }
64218
64406
  await gitCommit(ctx);
64219
64407
  endSection("Dependencies Installed");
64220
64408
  if (!preexisting) {
@@ -64312,60 +64500,6 @@ async function updateFiles(ctx) {
64312
64500
  );
64313
64501
  writeFile2(wranglerTomlPath, wranglerToml);
64314
64502
  }
64315
- async function installWorkersTypes(ctx) {
64316
- if (!ctx.args.ts) {
64317
- return;
64318
- }
64319
- await installPackages(["@cloudflare/workers-types"], {
64320
- dev: true,
64321
- startText: `Installing @cloudflare/workers-types`,
64322
- doneText: `${brandColor("installed")} ${dim(`via ${npm13}`)}`
64323
- });
64324
- await updateTsConfig(ctx);
64325
- }
64326
- async function updateTsConfig(ctx) {
64327
- const tsconfigPath = (0, import_path9.join)(ctx.project.path, "tsconfig.json");
64328
- if (!(0, import_fs9.existsSync)(tsconfigPath)) {
64329
- return;
64330
- }
64331
- const s = spinner();
64332
- s.start(`Adding latest types to \`tsconfig.json\``);
64333
- const tsconfig = readFile(tsconfigPath);
64334
- const entrypointVersion = getLatestTypesEntrypoint(ctx);
64335
- if (entrypointVersion === null) {
64336
- s.stop(
64337
- `${brandColor(
64338
- "skipped"
64339
- )} couldn't find latest compatible version of @cloudflare/workers-types`
64340
- );
64341
- return;
64342
- }
64343
- const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
64344
- const updated = tsconfig.replace(
64345
- "@cloudflare/workers-types",
64346
- typesEntrypoint
64347
- );
64348
- writeFile2(tsconfigPath, updated);
64349
- s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
64350
- }
64351
- function getLatestTypesEntrypoint(ctx) {
64352
- const workersTypesPath = (0, import_path9.resolve)(
64353
- ctx.project.path,
64354
- "node_modules",
64355
- "@cloudflare",
64356
- "workers-types"
64357
- );
64358
- try {
64359
- const entrypoints = (0, import_fs9.readdirSync)(workersTypesPath);
64360
- const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
64361
- if (sorted.length === 0) {
64362
- return null;
64363
- }
64364
- return sorted[0];
64365
- } catch (error) {
64366
- return null;
64367
- }
64368
- }
64369
64503
 
64370
64504
  // src/templateMap.ts
64371
64505
  var templateMap = {
@@ -64508,7 +64642,7 @@ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage
64508
64642
 
64509
64643
  // src/cli.ts
64510
64644
  var import_semver2 = __toESM(require_semver2());
64511
- var { npm: npm14 } = detectPackageManager();
64645
+ var { npm: npm13 } = detectPackageManager();
64512
64646
  var main = async (argv) => {
64513
64647
  const args = await parseArgs(argv);
64514
64648
  logRaw("");
@@ -64535,10 +64669,10 @@ var isUpdateAvailable = async () => {
64535
64669
  };
64536
64670
  var runLatest = async () => {
64537
64671
  const args = process.argv.slice(2);
64538
- if (npm14 === "npm") {
64672
+ if (npm13 === "npm") {
64539
64673
  args.unshift("--");
64540
64674
  }
64541
- await runCommand([npm14, "create", "cloudflare@latest", ...args]);
64675
+ await runCommand([npm13, "create", "cloudflare@latest", ...args]);
64542
64676
  };
64543
64677
  var runCli = async (args) => {
64544
64678
  printBanner();