create-cloudflare 2.8.5 → 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 +550 -287
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
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(
|
|
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
|
-
|
|
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((
|
|
655
|
+
const step = (i) => new Promise((resolve11, reject) => {
|
|
656
656
|
if (i === pathEnv.length)
|
|
657
|
-
return opt.all && found.length ?
|
|
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
|
-
|
|
662
|
+
resolve11(subStep(p2, i, 0));
|
|
663
663
|
});
|
|
664
|
-
const subStep = (p2, i, ii) => new Promise((
|
|
664
|
+
const subStep = (p2, i, ii) => new Promise((resolve11, reject) => {
|
|
665
665
|
if (ii === pathExt.length)
|
|
666
|
-
return
|
|
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
|
|
673
|
+
return resolve11(p2 + ext);
|
|
674
674
|
}
|
|
675
|
-
return
|
|
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((
|
|
5861
|
-
res =
|
|
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((
|
|
7286
|
-
busboy.on("finish",
|
|
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((
|
|
7717
|
+
return new Promise((resolve11, reject) => {
|
|
7718
7718
|
this.close((err, data) => {
|
|
7719
|
-
return err ? reject(err) :
|
|
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((
|
|
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
|
-
) :
|
|
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((
|
|
8754
|
+
return new Promise((resolve11) => {
|
|
8755
8755
|
if (!this[kSize]) {
|
|
8756
|
-
this.destroy(
|
|
8756
|
+
this.destroy(resolve11);
|
|
8757
8757
|
} else {
|
|
8758
|
-
this[kClosedResolve] =
|
|
8758
|
+
this[kClosedResolve] = resolve11;
|
|
8759
8759
|
}
|
|
8760
8760
|
});
|
|
8761
8761
|
}
|
|
8762
8762
|
async [kDestroy](err) {
|
|
8763
|
-
return new Promise((
|
|
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
|
-
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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 =
|
|
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((
|
|
10028
|
-
this[kClosedResolve] =
|
|
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((
|
|
10590
|
+
return new Promise((resolve11, reject) => {
|
|
10591
10591
|
stream[kConsume] = {
|
|
10592
10592
|
type,
|
|
10593
10593
|
stream,
|
|
10594
|
-
resolve:
|
|
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:
|
|
10629
|
+
const { type, body, resolve: resolve11, stream, length } = consume2;
|
|
10630
10630
|
try {
|
|
10631
10631
|
if (type === "text") {
|
|
10632
|
-
|
|
10632
|
+
resolve11(toUSVString(Buffer.concat(body)));
|
|
10633
10633
|
} else if (type === "json") {
|
|
10634
|
-
|
|
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
|
-
|
|
10642
|
+
resolve11(dst);
|
|
10643
10643
|
} else if (type === "blob") {
|
|
10644
10644
|
if (!Blob2) {
|
|
10645
10645
|
Blob2 = require("buffer").Blob;
|
|
10646
10646
|
}
|
|
10647
|
-
|
|
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((
|
|
10881
|
+
return new Promise((resolve11, reject) => {
|
|
10882
10882
|
request2.call(this, opts, (err, data) => {
|
|
10883
|
-
return err ? reject(err) :
|
|
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((
|
|
11035
|
+
return new Promise((resolve11, reject) => {
|
|
11036
11036
|
stream.call(this, opts, factory, (err, data) => {
|
|
11037
|
-
return err ? reject(err) :
|
|
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((
|
|
11318
|
+
return new Promise((resolve11, reject) => {
|
|
11319
11319
|
upgrade.call(this, opts, (err, data) => {
|
|
11320
|
-
return err ? reject(err) :
|
|
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((
|
|
11406
|
+
return new Promise((resolve11, reject) => {
|
|
11407
11407
|
connect.call(this, opts, (err, data) => {
|
|
11408
|
-
return err ? reject(err) :
|
|
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((
|
|
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
|
-
|
|
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
|
-
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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
|
-
|
|
21419
|
+
resolve11(message);
|
|
21420
21420
|
});
|
|
21421
21421
|
});
|
|
21422
21422
|
}
|
|
21423
21423
|
listen(port, address) {
|
|
21424
|
-
return new Promise((
|
|
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((
|
|
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", () =>
|
|
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((
|
|
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((
|
|
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((
|
|
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 },
|
|
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((
|
|
21765
|
-
stream.on("error", reject).on("data", (chunk) => buffer.push(chunk)).on("end", () =>
|
|
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((
|
|
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
|
-
|
|
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((
|
|
21837
|
+
var get = (url) => new Promise((resolve11) => https.get(url, resolve11));
|
|
21838
21838
|
var readStream = (stream) => {
|
|
21839
21839
|
const buffer = [];
|
|
21840
|
-
return new Promise((
|
|
21840
|
+
return new Promise((resolve11, reject) => {
|
|
21841
21841
|
stream.on("error", reject).on("data", (chunk) => {
|
|
21842
21842
|
buffer.push(chunk);
|
|
21843
|
-
}).on("end", () =>
|
|
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
|
|
21905
|
-
return
|
|
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((
|
|
23861
|
-
setImmediate(parseAsyncNext, index, blocksize,
|
|
23860
|
+
return new Promise((resolve11, reject) => {
|
|
23861
|
+
setImmediate(parseAsyncNext, index, blocksize, resolve11, reject);
|
|
23862
23862
|
});
|
|
23863
|
-
function parseAsyncNext(index2, blocksize2,
|
|
23863
|
+
function parseAsyncNext(index2, blocksize2, resolve11, reject) {
|
|
23864
23864
|
if (index2 >= str.length) {
|
|
23865
23865
|
try {
|
|
23866
|
-
return
|
|
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,
|
|
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((
|
|
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
|
-
|
|
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(
|
|
24368
|
-
|
|
24367
|
+
return value instanceof P2 ? value : new P2(function(resolve11) {
|
|
24368
|
+
resolve11(value);
|
|
24369
24369
|
});
|
|
24370
24370
|
}
|
|
24371
|
-
return new (P2 || (P2 = Promise))(function(
|
|
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 ?
|
|
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(
|
|
24594
|
-
v2 = o[n](v2), settle(
|
|
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(
|
|
24598
|
+
function settle(resolve11, reject, d2, v2) {
|
|
24599
24599
|
Promise.resolve(v2).then(function(v3) {
|
|
24600
|
-
|
|
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
|
|
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 =
|
|
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 =
|
|
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((
|
|
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
|
-
|
|
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.
|
|
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
|
|
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.
|
|
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((
|
|
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
|
-
|
|
62965
|
+
resolvePromise(processedOutput);
|
|
62897
62966
|
} catch (e) {
|
|
62898
62967
|
if (opts.fallbackOutput) {
|
|
62899
|
-
|
|
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:
|
|
62970
|
-
const cmd = [...
|
|
62971
|
-
const env3 =
|
|
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:
|
|
63055
|
+
const { npm: npm14 } = detectPackageManager();
|
|
62987
63056
|
let saveFlag;
|
|
62988
63057
|
let cmd;
|
|
62989
|
-
switch (
|
|
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([
|
|
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:
|
|
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,
|
|
63017
|
-
(0,
|
|
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,
|
|
63020
|
-
(0,
|
|
63021
|
-
await runCommand([
|
|
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 \`${
|
|
63094
|
+
doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
|
|
63026
63095
|
});
|
|
63027
63096
|
};
|
|
63028
63097
|
var needsPackageManagerReset = (ctx) => {
|
|
63029
|
-
const { npm:
|
|
63098
|
+
const { npm: npm14 } = detectPackageManager();
|
|
63030
63099
|
const projectPath = ctx.project.path;
|
|
63031
|
-
switch (
|
|
63100
|
+
switch (npm14) {
|
|
63032
63101
|
case "npm":
|
|
63033
63102
|
return false;
|
|
63034
63103
|
case "yarn":
|
|
63035
|
-
return !(0,
|
|
63104
|
+
return !(0, import_fs7.existsSync)(import_path6.default.join(projectPath, "yarn.lock"));
|
|
63036
63105
|
case "pnpm":
|
|
63037
|
-
return !(0,
|
|
63106
|
+
return !(0, import_fs7.existsSync)(import_path6.default.join(projectPath, "pnpm-lock.yaml"));
|
|
63038
63107
|
case "bun":
|
|
63039
|
-
return !(0,
|
|
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:
|
|
63044
|
-
await runCommand([
|
|
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 \`${
|
|
63116
|
+
doneText: `${brandColor("installed")} ${dim(`via \`${npm14} install\``)}`
|
|
63048
63117
|
});
|
|
63049
63118
|
};
|
|
63050
63119
|
var installWrangler = async () => {
|
|
63051
|
-
const { npm:
|
|
63052
|
-
if ((0,
|
|
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 \`${
|
|
63130
|
+
`via \`${npm14} install wrangler --save-dev\``
|
|
63062
63131
|
)}`
|
|
63063
63132
|
});
|
|
63064
63133
|
};
|
|
@@ -63126,76 +63195,71 @@ async function getWorkerdCompatibilityDate() {
|
|
|
63126
63195
|
});
|
|
63127
63196
|
return workerdCompatibilityDate;
|
|
63128
63197
|
}
|
|
63129
|
-
|
|
63130
|
-
|
|
63131
|
-
|
|
63132
|
-
|
|
63133
|
-
|
|
63134
|
-
|
|
63135
|
-
|
|
63136
|
-
|
|
63137
|
-
|
|
63138
|
-
|
|
63139
|
-
|
|
63140
|
-
|
|
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
|
-
|
|
63143
|
-
|
|
63144
|
-
|
|
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, errorMsg = "Failed to find required file.") => {
|
|
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
|
-
|
|
63161
|
-
|
|
63162
|
-
|
|
63163
|
-
|
|
63164
|
-
|
|
63165
|
-
};
|
|
63166
|
-
var eslintRcExts = ["js", "cjs", "yaml", "yml", "json"];
|
|
63167
|
-
var usesEslint = (ctx) => {
|
|
63168
|
-
for (const ext of eslintRcExts) {
|
|
63169
|
-
const eslintRcFilename = `.eslintrc.${ext}`;
|
|
63170
|
-
if ((0, import_fs7.existsSync)(`${ctx.project.path}/${eslintRcFilename}`)) {
|
|
63171
|
-
return {
|
|
63172
|
-
used: true,
|
|
63173
|
-
configType: eslintRcFilename
|
|
63174
|
-
};
|
|
63175
|
-
}
|
|
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;
|
|
63176
63229
|
}
|
|
63177
|
-
|
|
63178
|
-
|
|
63179
|
-
|
|
63180
|
-
|
|
63181
|
-
|
|
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;
|
|
63182
63241
|
}
|
|
63183
|
-
|
|
63184
|
-
|
|
63185
|
-
|
|
63186
|
-
|
|
63187
|
-
|
|
63188
|
-
|
|
63189
|
-
|
|
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;
|
|
63190
63258
|
}
|
|
63191
|
-
} catch {
|
|
63192
63259
|
}
|
|
63193
|
-
|
|
63194
|
-
};
|
|
63195
|
-
|
|
63196
|
-
const workerdCompatDate = await getWorkerdCompatibilityDate();
|
|
63197
|
-
return `--compatibility-date=${workerdCompatDate}`;
|
|
63198
|
-
};
|
|
63260
|
+
writeFile2(tsconfigPath, updated);
|
|
63261
|
+
s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
|
|
63262
|
+
}
|
|
63199
63263
|
|
|
63200
63264
|
// src/frameworks/angular/index.ts
|
|
63201
63265
|
var { npm: npm2 } = detectPackageManager();
|
|
@@ -63380,8 +63444,22 @@ var hono_default = config5;
|
|
|
63380
63444
|
var import_fs8 = require("fs");
|
|
63381
63445
|
|
|
63382
63446
|
// src/frameworks/next/templates.ts
|
|
63383
|
-
var
|
|
63384
|
-
|
|
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
|
|
63385
63463
|
|
|
63386
63464
|
import type { NextRequest } from 'next/server'
|
|
63387
63465
|
|
|
@@ -63390,40 +63468,252 @@ export const config = {
|
|
|
63390
63468
|
}
|
|
63391
63469
|
|
|
63392
63470
|
export default async function handler(req: NextRequest) {
|
|
63393
|
-
|
|
63471
|
+
${handlerCode}
|
|
63394
63472
|
}
|
|
63395
63473
|
`;
|
|
63396
|
-
var apiPagesDirHelloJs =
|
|
63397
|
-
// 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
|
|
63398
63475
|
|
|
63399
63476
|
export const config = {
|
|
63400
63477
|
runtime: 'edge',
|
|
63401
63478
|
}
|
|
63402
63479
|
|
|
63403
63480
|
export default async function handler(req) {
|
|
63404
|
-
|
|
63481
|
+
${handlerCode}
|
|
63405
63482
|
}
|
|
63406
63483
|
`;
|
|
63407
|
-
var apiAppDirHelloTs =
|
|
63408
|
-
// 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
|
|
63409
63485
|
|
|
63410
63486
|
import type { NextRequest } from 'next/server'
|
|
63411
63487
|
|
|
63412
63488
|
export const runtime = 'edge'
|
|
63413
63489
|
|
|
63414
63490
|
export async function GET(request: NextRequest) {
|
|
63415
|
-
|
|
63491
|
+
${handlerCode}
|
|
63416
63492
|
}
|
|
63417
63493
|
`;
|
|
63418
|
-
var apiAppDirHelloJs =
|
|
63419
|
-
// 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
|
|
63420
63495
|
|
|
63421
63496
|
export const runtime = 'edge'
|
|
63422
63497
|
|
|
63423
63498
|
export async function GET(request) {
|
|
63424
|
-
|
|
63499
|
+
${handlerCode}
|
|
63500
|
+
}
|
|
63501
|
+
`;
|
|
63502
|
+
var appDirNotFoundJs = `export const runtime = "edge";
|
|
63503
|
+
|
|
63504
|
+
export default function NotFound() {
|
|
63505
|
+
return (
|
|
63506
|
+
<>
|
|
63507
|
+
<title>404: This page could not be found.</title>
|
|
63508
|
+
<div style={styles.error}>
|
|
63509
|
+
<div>
|
|
63510
|
+
<style
|
|
63511
|
+
dangerouslySetInnerHTML={{
|
|
63512
|
+
__html: \`body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\`,
|
|
63513
|
+
}}
|
|
63514
|
+
/>
|
|
63515
|
+
<h1 className="next-error-h1" style={styles.h1}>
|
|
63516
|
+
404
|
|
63517
|
+
</h1>
|
|
63518
|
+
<div style={styles.desc}>
|
|
63519
|
+
<h2 style={styles.h2}>This page could not be found.</h2>
|
|
63520
|
+
</div>
|
|
63521
|
+
</div>
|
|
63522
|
+
</div>
|
|
63523
|
+
</>
|
|
63524
|
+
);
|
|
63525
|
+
}
|
|
63526
|
+
|
|
63527
|
+
const styles = {
|
|
63528
|
+
error: {
|
|
63529
|
+
fontFamily:
|
|
63530
|
+
'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
|
|
63531
|
+
height: "100vh",
|
|
63532
|
+
textAlign: "center",
|
|
63533
|
+
display: "flex",
|
|
63534
|
+
flexDirection: "column",
|
|
63535
|
+
alignItems: "center",
|
|
63536
|
+
justifyContent: "center",
|
|
63537
|
+
},
|
|
63538
|
+
|
|
63539
|
+
desc: {
|
|
63540
|
+
display: "inline-block",
|
|
63541
|
+
},
|
|
63542
|
+
|
|
63543
|
+
h1: {
|
|
63544
|
+
display: "inline-block",
|
|
63545
|
+
margin: "0 20px 0 0",
|
|
63546
|
+
padding: "0 23px 0 0",
|
|
63547
|
+
fontSize: 24,
|
|
63548
|
+
fontWeight: 500,
|
|
63549
|
+
verticalAlign: "top",
|
|
63550
|
+
lineHeight: "49px",
|
|
63551
|
+
},
|
|
63552
|
+
|
|
63553
|
+
h2: {
|
|
63554
|
+
fontSize: 14,
|
|
63555
|
+
fontWeight: 400,
|
|
63556
|
+
lineHeight: "49px",
|
|
63557
|
+
margin: 0,
|
|
63558
|
+
},
|
|
63559
|
+
};
|
|
63560
|
+
`;
|
|
63561
|
+
var appDirNotFoundTs = `export const runtime = "edge";
|
|
63562
|
+
|
|
63563
|
+
export default function NotFound() {
|
|
63564
|
+
return (
|
|
63565
|
+
<>
|
|
63566
|
+
<title>404: This page could not be found.</title>
|
|
63567
|
+
<div style={styles.error}>
|
|
63568
|
+
<div>
|
|
63569
|
+
<style
|
|
63570
|
+
dangerouslySetInnerHTML={{
|
|
63571
|
+
__html: \`body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\`,
|
|
63572
|
+
}}
|
|
63573
|
+
/>
|
|
63574
|
+
<h1 className="next-error-h1" style={styles.h1}>
|
|
63575
|
+
404
|
|
63576
|
+
</h1>
|
|
63577
|
+
<div style={styles.desc}>
|
|
63578
|
+
<h2 style={styles.h2}>This page could not be found.</h2>
|
|
63579
|
+
</div>
|
|
63580
|
+
</div>
|
|
63581
|
+
</div>
|
|
63582
|
+
</>
|
|
63583
|
+
);
|
|
63584
|
+
}
|
|
63585
|
+
|
|
63586
|
+
const styles = {
|
|
63587
|
+
error: {
|
|
63588
|
+
fontFamily:
|
|
63589
|
+
'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
|
|
63590
|
+
height: "100vh",
|
|
63591
|
+
textAlign: "center",
|
|
63592
|
+
display: "flex",
|
|
63593
|
+
flexDirection: "column",
|
|
63594
|
+
alignItems: "center",
|
|
63595
|
+
justifyContent: "center",
|
|
63596
|
+
},
|
|
63597
|
+
|
|
63598
|
+
desc: {
|
|
63599
|
+
display: "inline-block",
|
|
63600
|
+
},
|
|
63601
|
+
|
|
63602
|
+
h1: {
|
|
63603
|
+
display: "inline-block",
|
|
63604
|
+
margin: "0 20px 0 0",
|
|
63605
|
+
padding: "0 23px 0 0",
|
|
63606
|
+
fontSize: 24,
|
|
63607
|
+
fontWeight: 500,
|
|
63608
|
+
verticalAlign: "top",
|
|
63609
|
+
lineHeight: "49px",
|
|
63610
|
+
},
|
|
63611
|
+
|
|
63612
|
+
h2: {
|
|
63613
|
+
fontSize: 14,
|
|
63614
|
+
fontWeight: 400,
|
|
63615
|
+
lineHeight: "49px",
|
|
63616
|
+
margin: 0,
|
|
63617
|
+
},
|
|
63618
|
+
} as const;
|
|
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
|
+
})
|
|
63425
63643
|
}
|
|
63426
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
|
+
`;
|
|
63427
63717
|
|
|
63428
63718
|
// src/frameworks/next/index.ts
|
|
63429
63719
|
var { npm: npm5, npx: npx2 } = detectPackageManager();
|
|
@@ -63442,39 +63732,47 @@ var getApiTemplate = (apiPath, isTypescript) => {
|
|
|
63442
63732
|
};
|
|
63443
63733
|
var configure3 = async (ctx) => {
|
|
63444
63734
|
const projectName = ctx.project.name;
|
|
63445
|
-
const path3 = probePaths(
|
|
63446
|
-
|
|
63447
|
-
|
|
63448
|
-
|
|
63449
|
-
|
|
63450
|
-
|
|
63451
|
-
|
|
63452
|
-
|
|
63453
|
-
|
|
63454
|
-
"Could not find the `/api` or `/app` directory"
|
|
63455
|
-
|
|
63735
|
+
const path3 = probePaths([
|
|
63736
|
+
`${projectName}/pages/api`,
|
|
63737
|
+
`${projectName}/src/pages/api`,
|
|
63738
|
+
`${projectName}/src/app/api`,
|
|
63739
|
+
`${projectName}/app/api`,
|
|
63740
|
+
`${projectName}/src/app`,
|
|
63741
|
+
`${projectName}/app`
|
|
63742
|
+
]);
|
|
63743
|
+
if (!path3) {
|
|
63744
|
+
crash("Could not find the `/api` or `/app` directory");
|
|
63745
|
+
}
|
|
63456
63746
|
const apiPath = path3.replace(/\/app$/, "/app/api");
|
|
63457
|
-
const
|
|
63458
|
-
|
|
63459
|
-
|
|
63460
|
-
|
|
63747
|
+
const usesTs = usesTypescript(projectName);
|
|
63748
|
+
const appDirPath = probePaths([
|
|
63749
|
+
`${projectName}/src/app`,
|
|
63750
|
+
`${projectName}/app`
|
|
63751
|
+
]);
|
|
63752
|
+
if (appDirPath) {
|
|
63753
|
+
const notFoundPath = `${appDirPath}/not-found.${usesTs ? "tsx" : "js"}`;
|
|
63754
|
+
if (!(0, import_fs8.existsSync)(notFoundPath)) {
|
|
63755
|
+
const notFoundContent = usesTs ? appDirNotFoundTs : appDirNotFoundJs;
|
|
63756
|
+
writeFile2(notFoundPath, notFoundContent);
|
|
63757
|
+
updateStatus("Created a custom edge not-found route");
|
|
63758
|
+
}
|
|
63759
|
+
}
|
|
63760
|
+
const [handlerPath, handlerFile] = getApiTemplate(apiPath, usesTs);
|
|
63461
63761
|
writeFile2(handlerPath, handlerFile);
|
|
63462
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
|
+
}
|
|
63463
63767
|
const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
|
|
63464
63768
|
if (installEslintPlugin) {
|
|
63465
63769
|
await writeEslintrc(ctx);
|
|
63466
63770
|
}
|
|
63467
|
-
|
|
63468
|
-
|
|
63469
|
-
|
|
63470
|
-
|
|
63471
|
-
|
|
63472
|
-
];
|
|
63473
|
-
await installPackages(packages, {
|
|
63474
|
-
dev: true,
|
|
63475
|
-
startText: "Adding the Cloudflare Pages adapter",
|
|
63476
|
-
doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`
|
|
63477
|
-
});
|
|
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);
|
|
63478
63776
|
};
|
|
63479
63777
|
var shouldInstallNextOnPagesEslintPlugin = async (ctx) => {
|
|
63480
63778
|
const eslintUsage = usesEslint(ctx);
|
|
@@ -63515,12 +63813,11 @@ var config6 = {
|
|
|
63515
63813
|
const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
|
|
63516
63814
|
const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
|
|
63517
63815
|
const pmCommand = isNpmOrBun ? npx2 : npm5;
|
|
63518
|
-
const
|
|
63816
|
+
const pagesBuildRunCommand = `${isNpm ? "npm run" : isBun ? "bun" : pmCommand} pages:build`;
|
|
63519
63817
|
return {
|
|
63520
63818
|
"pages:build": `${pmCommand} ${nextOnPagesCommand}`,
|
|
63521
|
-
"pages:
|
|
63522
|
-
"pages:
|
|
63523
|
-
"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`
|
|
63524
63821
|
};
|
|
63525
63822
|
},
|
|
63526
63823
|
testFlags: [
|
|
@@ -63536,6 +63833,25 @@ var config6 = {
|
|
|
63536
63833
|
compatibilityFlags: ["nodejs_compat"]
|
|
63537
63834
|
};
|
|
63538
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
|
+
};
|
|
63539
63855
|
|
|
63540
63856
|
// src/frameworks/nuxt/index.ts
|
|
63541
63857
|
var import_node_fs = require("node:fs");
|
|
@@ -63602,7 +63918,7 @@ var package_default = {
|
|
|
63602
63918
|
"create-solid": "0.3.10",
|
|
63603
63919
|
"create-svelte": "6.0.5",
|
|
63604
63920
|
"create-vue": "3.9.1",
|
|
63605
|
-
gatsby: "5.
|
|
63921
|
+
gatsby: "5.13.1",
|
|
63606
63922
|
nuxi: "3.10.0"
|
|
63607
63923
|
},
|
|
63608
63924
|
frameworkCliMap: {
|
|
@@ -63857,7 +64173,7 @@ var supportedFramework = (framework) => {
|
|
|
63857
64173
|
};
|
|
63858
64174
|
var getFrameworkCli = (ctx, withVersion = true) => {
|
|
63859
64175
|
if (!ctx.framework) {
|
|
63860
|
-
|
|
64176
|
+
crash("Framework not specified.");
|
|
63861
64177
|
}
|
|
63862
64178
|
const framework = ctx.framework.name;
|
|
63863
64179
|
const frameworkCli = package_default.frameworkCliMap[framework];
|
|
@@ -64052,12 +64368,11 @@ var createProject = async (ctx) => {
|
|
|
64052
64368
|
};
|
|
64053
64369
|
|
|
64054
64370
|
// src/workers.ts
|
|
64055
|
-
var import_fs9 = require("fs");
|
|
64056
64371
|
var import_promises2 = require("fs/promises");
|
|
64057
64372
|
var import_os = require("os");
|
|
64058
64373
|
var import_path9 = require("path");
|
|
64059
64374
|
var import_process4 = require("process");
|
|
64060
|
-
var { dlx
|
|
64375
|
+
var { dlx } = detectPackageManager();
|
|
64061
64376
|
var runWorkersGenerator = async (args) => {
|
|
64062
64377
|
const originalCWD = process.cwd();
|
|
64063
64378
|
const { name: name2, path: path3 } = setupProjectDirectory(args);
|
|
@@ -64085,7 +64400,9 @@ var runWorkersGenerator = async (args) => {
|
|
|
64085
64400
|
startSection("Installing dependencies", "Step 2 of 3");
|
|
64086
64401
|
(0, import_process4.chdir)(ctx.project.path);
|
|
64087
64402
|
await npmInstall();
|
|
64088
|
-
|
|
64403
|
+
if (ctx.args.ts) {
|
|
64404
|
+
await installWorkersTypes(ctx);
|
|
64405
|
+
}
|
|
64089
64406
|
await gitCommit(ctx);
|
|
64090
64407
|
endSection("Dependencies Installed");
|
|
64091
64408
|
if (!preexisting) {
|
|
@@ -64183,60 +64500,6 @@ async function updateFiles(ctx) {
|
|
|
64183
64500
|
);
|
|
64184
64501
|
writeFile2(wranglerTomlPath, wranglerToml);
|
|
64185
64502
|
}
|
|
64186
|
-
async function installWorkersTypes(ctx) {
|
|
64187
|
-
if (!ctx.args.ts) {
|
|
64188
|
-
return;
|
|
64189
|
-
}
|
|
64190
|
-
await installPackages(["@cloudflare/workers-types"], {
|
|
64191
|
-
dev: true,
|
|
64192
|
-
startText: `Installing @cloudflare/workers-types`,
|
|
64193
|
-
doneText: `${brandColor("installed")} ${dim(`via ${npm13}`)}`
|
|
64194
|
-
});
|
|
64195
|
-
await updateTsConfig(ctx);
|
|
64196
|
-
}
|
|
64197
|
-
async function updateTsConfig(ctx) {
|
|
64198
|
-
const tsconfigPath = (0, import_path9.join)(ctx.project.path, "tsconfig.json");
|
|
64199
|
-
if (!(0, import_fs9.existsSync)(tsconfigPath)) {
|
|
64200
|
-
return;
|
|
64201
|
-
}
|
|
64202
|
-
const s = spinner();
|
|
64203
|
-
s.start(`Adding latest types to \`tsconfig.json\``);
|
|
64204
|
-
const tsconfig = readFile(tsconfigPath);
|
|
64205
|
-
const entrypointVersion = getLatestTypesEntrypoint(ctx);
|
|
64206
|
-
if (entrypointVersion === null) {
|
|
64207
|
-
s.stop(
|
|
64208
|
-
`${brandColor(
|
|
64209
|
-
"skipped"
|
|
64210
|
-
)} couldn't find latest compatible version of @cloudflare/workers-types`
|
|
64211
|
-
);
|
|
64212
|
-
return;
|
|
64213
|
-
}
|
|
64214
|
-
const typesEntrypoint = `@cloudflare/workers-types/${entrypointVersion}`;
|
|
64215
|
-
const updated = tsconfig.replace(
|
|
64216
|
-
"@cloudflare/workers-types",
|
|
64217
|
-
typesEntrypoint
|
|
64218
|
-
);
|
|
64219
|
-
writeFile2(tsconfigPath, updated);
|
|
64220
|
-
s.stop(`${brandColor("added")} ${dim(typesEntrypoint)}`);
|
|
64221
|
-
}
|
|
64222
|
-
function getLatestTypesEntrypoint(ctx) {
|
|
64223
|
-
const workersTypesPath = (0, import_path9.resolve)(
|
|
64224
|
-
ctx.project.path,
|
|
64225
|
-
"node_modules",
|
|
64226
|
-
"@cloudflare",
|
|
64227
|
-
"workers-types"
|
|
64228
|
-
);
|
|
64229
|
-
try {
|
|
64230
|
-
const entrypoints = (0, import_fs9.readdirSync)(workersTypesPath);
|
|
64231
|
-
const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
|
|
64232
|
-
if (sorted.length === 0) {
|
|
64233
|
-
return null;
|
|
64234
|
-
}
|
|
64235
|
-
return sorted[0];
|
|
64236
|
-
} catch (error) {
|
|
64237
|
-
return null;
|
|
64238
|
-
}
|
|
64239
|
-
}
|
|
64240
64503
|
|
|
64241
64504
|
// src/templateMap.ts
|
|
64242
64505
|
var templateMap = {
|
|
@@ -64379,7 +64642,7 @@ For more information regarding how to invoke C3 please visit ${c3CliArgsDocsPage
|
|
|
64379
64642
|
|
|
64380
64643
|
// src/cli.ts
|
|
64381
64644
|
var import_semver2 = __toESM(require_semver2());
|
|
64382
|
-
var { npm:
|
|
64645
|
+
var { npm: npm13 } = detectPackageManager();
|
|
64383
64646
|
var main = async (argv) => {
|
|
64384
64647
|
const args = await parseArgs(argv);
|
|
64385
64648
|
logRaw("");
|
|
@@ -64406,10 +64669,10 @@ var isUpdateAvailable = async () => {
|
|
|
64406
64669
|
};
|
|
64407
64670
|
var runLatest = async () => {
|
|
64408
64671
|
const args = process.argv.slice(2);
|
|
64409
|
-
if (
|
|
64672
|
+
if (npm13 === "npm") {
|
|
64410
64673
|
args.unshift("--");
|
|
64411
64674
|
}
|
|
64412
|
-
await runCommand([
|
|
64675
|
+
await runCommand([npm13, "create", "cloudflare@latest", ...args]);
|
|
64413
64676
|
};
|
|
64414
64677
|
var runCli = async (args) => {
|
|
64415
64678
|
printBanner();
|
|
@@ -64441,10 +64704,10 @@ var runCli = async (args) => {
|
|
|
64441
64704
|
defaultValue: C3_DEFAULTS.type
|
|
64442
64705
|
});
|
|
64443
64706
|
if (!type) {
|
|
64444
|
-
|
|
64707
|
+
crash("An application type must be specified to continue.");
|
|
64445
64708
|
}
|
|
64446
64709
|
if (!Object.keys(templateMap).includes(type)) {
|
|
64447
|
-
|
|
64710
|
+
crash(`Unknown application type provided: ${type}.`);
|
|
64448
64711
|
}
|
|
64449
64712
|
const validatedArgs = {
|
|
64450
64713
|
...args,
|