wrangler 2.1.2 → 2.1.4
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/package.json +1 -1
- package/src/__tests__/api-dev.test.ts +170 -0
- package/src/__tests__/api.test.ts +80 -0
- package/src/__tests__/dev.test.tsx +2 -1
- package/src/__tests__/dialogs.test.tsx +40 -0
- package/src/__tests__/init.test.ts +127 -3
- package/src/__tests__/secret.test.ts +76 -2
- package/src/api/dev.ts +59 -13
- package/src/api/index.ts +1 -0
- package/src/cli.ts +2 -0
- package/src/create-worker-preview.ts +21 -3
- package/src/dev/dev.tsx +2 -2
- package/src/dev/local.tsx +2 -12
- package/src/dev/start-server.ts +2 -13
- package/src/dev.tsx +39 -6
- package/src/dialogs.tsx +8 -1
- package/src/index.tsx +11 -2
- package/src/init.ts +189 -121
- package/src/pages/dev.tsx +28 -4
- package/templates/init-tests/test-jest-new-worker.js +25 -0
- package/templates/init-tests/test-vitest-new-worker.js +26 -0
- package/wrangler-dist/cli.d.ts +64 -4
- package/wrangler-dist/cli.js +297 -146
package/wrangler-dist/cli.js
CHANGED
|
@@ -2262,7 +2262,7 @@ var require_request = __commonJS({
|
|
|
2262
2262
|
channels.trailers = { hasSubscribers: false };
|
|
2263
2263
|
channels.error = { hasSubscribers: false };
|
|
2264
2264
|
}
|
|
2265
|
-
var
|
|
2265
|
+
var Request2 = class {
|
|
2266
2266
|
constructor(origin, {
|
|
2267
2267
|
path: path30,
|
|
2268
2268
|
method,
|
|
@@ -2467,7 +2467,7 @@ var require_request = __commonJS({
|
|
|
2467
2467
|
`;
|
|
2468
2468
|
}
|
|
2469
2469
|
}
|
|
2470
|
-
module2.exports =
|
|
2470
|
+
module2.exports = Request2;
|
|
2471
2471
|
}
|
|
2472
2472
|
});
|
|
2473
2473
|
|
|
@@ -3238,7 +3238,7 @@ var require_client = __commonJS({
|
|
|
3238
3238
|
var assert12 = require("assert");
|
|
3239
3239
|
var net3 = require("net");
|
|
3240
3240
|
var util2 = require_util();
|
|
3241
|
-
var
|
|
3241
|
+
var Request2 = require_request();
|
|
3242
3242
|
var DispatcherBase = require_dispatcher_base();
|
|
3243
3243
|
var RedirectHandler = require_redirect();
|
|
3244
3244
|
var {
|
|
@@ -3447,7 +3447,7 @@ var require_client = __commonJS({
|
|
|
3447
3447
|
handler2 = new RedirectHandler(this, maxRedirections, opts, handler2);
|
|
3448
3448
|
}
|
|
3449
3449
|
const origin = opts.origin || this[kUrl].origin;
|
|
3450
|
-
const request = new
|
|
3450
|
+
const request = new Request2(origin, opts, handler2);
|
|
3451
3451
|
this[kQueue].push(request);
|
|
3452
3452
|
if (this[kResuming]) {
|
|
3453
3453
|
} else if (util2.bodyLength(request.body) == null && util2.isIterable(request.body)) {
|
|
@@ -7910,7 +7910,7 @@ var require_request2 = __commonJS({
|
|
|
7910
7910
|
var requestFinalizer = new FinalizationRegistry(({ signal, abort: abort2 }) => {
|
|
7911
7911
|
signal.removeEventListener("abort", abort2);
|
|
7912
7912
|
});
|
|
7913
|
-
var
|
|
7913
|
+
var Request2 = class {
|
|
7914
7914
|
constructor(input, init = {}) {
|
|
7915
7915
|
if (input === kInit) {
|
|
7916
7916
|
return;
|
|
@@ -7942,7 +7942,7 @@ var require_request2 = __commonJS({
|
|
|
7942
7942
|
request = makeRequest({ urlList: [parsedURL] });
|
|
7943
7943
|
fallbackMode = "cors";
|
|
7944
7944
|
} else {
|
|
7945
|
-
assert12(input instanceof
|
|
7945
|
+
assert12(input instanceof Request2);
|
|
7946
7946
|
request = input[kState];
|
|
7947
7947
|
signal = input[kSignal];
|
|
7948
7948
|
}
|
|
@@ -8124,7 +8124,7 @@ var require_request2 = __commonJS({
|
|
|
8124
8124
|
fillHeaders(this[kHeaders], headers);
|
|
8125
8125
|
}
|
|
8126
8126
|
}
|
|
8127
|
-
const inputBody = input instanceof
|
|
8127
|
+
const inputBody = input instanceof Request2 ? input[kState].body : null;
|
|
8128
8128
|
if ((init.body !== void 0 && init.body != null || inputBody != null) && (request.method === "GET" || request.method === "HEAD")) {
|
|
8129
8129
|
throw new TypeError("Request with GET/HEAD method cannot have body.");
|
|
8130
8130
|
}
|
|
@@ -8172,31 +8172,31 @@ var require_request2 = __commonJS({
|
|
|
8172
8172
|
return this.constructor.name;
|
|
8173
8173
|
}
|
|
8174
8174
|
get method() {
|
|
8175
|
-
if (!(this instanceof
|
|
8175
|
+
if (!(this instanceof Request2)) {
|
|
8176
8176
|
throw new TypeError("Illegal invocation");
|
|
8177
8177
|
}
|
|
8178
8178
|
return this[kState].method;
|
|
8179
8179
|
}
|
|
8180
8180
|
get url() {
|
|
8181
|
-
if (!(this instanceof
|
|
8181
|
+
if (!(this instanceof Request2)) {
|
|
8182
8182
|
throw new TypeError("Illegal invocation");
|
|
8183
8183
|
}
|
|
8184
8184
|
return this[kState].url.toString();
|
|
8185
8185
|
}
|
|
8186
8186
|
get headers() {
|
|
8187
|
-
if (!(this instanceof
|
|
8187
|
+
if (!(this instanceof Request2)) {
|
|
8188
8188
|
throw new TypeError("Illegal invocation");
|
|
8189
8189
|
}
|
|
8190
8190
|
return this[kHeaders];
|
|
8191
8191
|
}
|
|
8192
8192
|
get destination() {
|
|
8193
|
-
if (!(this instanceof
|
|
8193
|
+
if (!(this instanceof Request2)) {
|
|
8194
8194
|
throw new TypeError("Illegal invocation");
|
|
8195
8195
|
}
|
|
8196
8196
|
return this[kState].destination;
|
|
8197
8197
|
}
|
|
8198
8198
|
get referrer() {
|
|
8199
|
-
if (!(this instanceof
|
|
8199
|
+
if (!(this instanceof Request2)) {
|
|
8200
8200
|
throw new TypeError("Illegal invocation");
|
|
8201
8201
|
}
|
|
8202
8202
|
if (this[kState].referrer === "no-referrer") {
|
|
@@ -8208,13 +8208,13 @@ var require_request2 = __commonJS({
|
|
|
8208
8208
|
return this[kState].referrer.toString();
|
|
8209
8209
|
}
|
|
8210
8210
|
get referrerPolicy() {
|
|
8211
|
-
if (!(this instanceof
|
|
8211
|
+
if (!(this instanceof Request2)) {
|
|
8212
8212
|
throw new TypeError("Illegal invocation");
|
|
8213
8213
|
}
|
|
8214
8214
|
return this[kState].referrerPolicy;
|
|
8215
8215
|
}
|
|
8216
8216
|
get mode() {
|
|
8217
|
-
if (!(this instanceof
|
|
8217
|
+
if (!(this instanceof Request2)) {
|
|
8218
8218
|
throw new TypeError("Illegal invocation");
|
|
8219
8219
|
}
|
|
8220
8220
|
return this[kState].mode;
|
|
@@ -8223,56 +8223,56 @@ var require_request2 = __commonJS({
|
|
|
8223
8223
|
return this[kState].credentials;
|
|
8224
8224
|
}
|
|
8225
8225
|
get cache() {
|
|
8226
|
-
if (!(this instanceof
|
|
8226
|
+
if (!(this instanceof Request2)) {
|
|
8227
8227
|
throw new TypeError("Illegal invocation");
|
|
8228
8228
|
}
|
|
8229
8229
|
return this[kState].cache;
|
|
8230
8230
|
}
|
|
8231
8231
|
get redirect() {
|
|
8232
|
-
if (!(this instanceof
|
|
8232
|
+
if (!(this instanceof Request2)) {
|
|
8233
8233
|
throw new TypeError("Illegal invocation");
|
|
8234
8234
|
}
|
|
8235
8235
|
return this[kState].redirect;
|
|
8236
8236
|
}
|
|
8237
8237
|
get integrity() {
|
|
8238
|
-
if (!(this instanceof
|
|
8238
|
+
if (!(this instanceof Request2)) {
|
|
8239
8239
|
throw new TypeError("Illegal invocation");
|
|
8240
8240
|
}
|
|
8241
8241
|
return this[kState].integrity;
|
|
8242
8242
|
}
|
|
8243
8243
|
get keepalive() {
|
|
8244
|
-
if (!(this instanceof
|
|
8244
|
+
if (!(this instanceof Request2)) {
|
|
8245
8245
|
throw new TypeError("Illegal invocation");
|
|
8246
8246
|
}
|
|
8247
8247
|
return this[kState].keepalive;
|
|
8248
8248
|
}
|
|
8249
8249
|
get isReloadNavigation() {
|
|
8250
|
-
if (!(this instanceof
|
|
8250
|
+
if (!(this instanceof Request2)) {
|
|
8251
8251
|
throw new TypeError("Illegal invocation");
|
|
8252
8252
|
}
|
|
8253
8253
|
return this[kState].reloadNavigation;
|
|
8254
8254
|
}
|
|
8255
8255
|
get isHistoryNavigation() {
|
|
8256
|
-
if (!(this instanceof
|
|
8256
|
+
if (!(this instanceof Request2)) {
|
|
8257
8257
|
throw new TypeError("Illegal invocation");
|
|
8258
8258
|
}
|
|
8259
8259
|
return this[kState].historyNavigation;
|
|
8260
8260
|
}
|
|
8261
8261
|
get signal() {
|
|
8262
|
-
if (!(this instanceof
|
|
8262
|
+
if (!(this instanceof Request2)) {
|
|
8263
8263
|
throw new TypeError("Illegal invocation");
|
|
8264
8264
|
}
|
|
8265
8265
|
return this[kSignal];
|
|
8266
8266
|
}
|
|
8267
8267
|
clone() {
|
|
8268
|
-
if (!(this instanceof
|
|
8268
|
+
if (!(this instanceof Request2)) {
|
|
8269
8269
|
throw new TypeError("Illegal invocation");
|
|
8270
8270
|
}
|
|
8271
8271
|
if (this.bodyUsed || this.body?.locked) {
|
|
8272
8272
|
throw new TypeError("unusable");
|
|
8273
8273
|
}
|
|
8274
8274
|
const clonedRequest = cloneRequest(this[kState]);
|
|
8275
|
-
const clonedRequestObject = new
|
|
8275
|
+
const clonedRequestObject = new Request2(kInit);
|
|
8276
8276
|
clonedRequestObject[kState] = clonedRequest;
|
|
8277
8277
|
clonedRequestObject[kRealm] = this[kRealm];
|
|
8278
8278
|
clonedRequestObject[kHeaders] = new Headers2();
|
|
@@ -8295,7 +8295,7 @@ var require_request2 = __commonJS({
|
|
|
8295
8295
|
return clonedRequestObject;
|
|
8296
8296
|
}
|
|
8297
8297
|
};
|
|
8298
|
-
mixinBody(
|
|
8298
|
+
mixinBody(Request2);
|
|
8299
8299
|
function makeRequest(init) {
|
|
8300
8300
|
const request = {
|
|
8301
8301
|
method: "GET",
|
|
@@ -8346,7 +8346,7 @@ var require_request2 = __commonJS({
|
|
|
8346
8346
|
}
|
|
8347
8347
|
return newRequest;
|
|
8348
8348
|
}
|
|
8349
|
-
Object.defineProperties(
|
|
8349
|
+
Object.defineProperties(Request2.prototype, {
|
|
8350
8350
|
method: kEnumerableProperty,
|
|
8351
8351
|
url: kEnumerableProperty,
|
|
8352
8352
|
headers: kEnumerableProperty,
|
|
@@ -8355,13 +8355,13 @@ var require_request2 = __commonJS({
|
|
|
8355
8355
|
signal: kEnumerableProperty
|
|
8356
8356
|
});
|
|
8357
8357
|
webidl.converters.Request = webidl.interfaceConverter(
|
|
8358
|
-
|
|
8358
|
+
Request2
|
|
8359
8359
|
);
|
|
8360
8360
|
webidl.converters.RequestInfo = function(V) {
|
|
8361
8361
|
if (typeof V === "string") {
|
|
8362
8362
|
return webidl.converters.USVString(V);
|
|
8363
8363
|
}
|
|
8364
|
-
if (V instanceof
|
|
8364
|
+
if (V instanceof Request2) {
|
|
8365
8365
|
return webidl.converters.Request(V);
|
|
8366
8366
|
}
|
|
8367
8367
|
return webidl.converters.USVString(V);
|
|
@@ -8463,7 +8463,7 @@ var require_request2 = __commonJS({
|
|
|
8463
8463
|
converter: webidl.converters.any
|
|
8464
8464
|
}
|
|
8465
8465
|
]);
|
|
8466
|
-
module2.exports = { Request, makeRequest };
|
|
8466
|
+
module2.exports = { Request: Request2, makeRequest };
|
|
8467
8467
|
}
|
|
8468
8468
|
});
|
|
8469
8469
|
|
|
@@ -8719,7 +8719,7 @@ var require_fetch = __commonJS({
|
|
|
8719
8719
|
makeResponse
|
|
8720
8720
|
} = require_response();
|
|
8721
8721
|
var { Headers: Headers2 } = require_headers();
|
|
8722
|
-
var { Request, makeRequest } = require_request2();
|
|
8722
|
+
var { Request: Request2, makeRequest } = require_request2();
|
|
8723
8723
|
var zlib = require("zlib");
|
|
8724
8724
|
var {
|
|
8725
8725
|
matchRequestIntegrity,
|
|
@@ -8803,7 +8803,7 @@ var require_fetch = __commonJS({
|
|
|
8803
8803
|
const p = createDeferredPromise();
|
|
8804
8804
|
let requestObject;
|
|
8805
8805
|
try {
|
|
8806
|
-
requestObject = new
|
|
8806
|
+
requestObject = new Request2(input, init);
|
|
8807
8807
|
} catch (e2) {
|
|
8808
8808
|
p.reject(e2);
|
|
8809
8809
|
return p.promise;
|
|
@@ -138674,7 +138674,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
|
|
|
138674
138674
|
var wrapper_default = import_websocket.default;
|
|
138675
138675
|
|
|
138676
138676
|
// package.json
|
|
138677
|
-
var version = "2.1.
|
|
138677
|
+
var version = "2.1.4";
|
|
138678
138678
|
var package_default = {
|
|
138679
138679
|
name: "wrangler",
|
|
138680
138680
|
version,
|
|
@@ -139940,7 +139940,7 @@ function useLocalWorker({
|
|
|
139940
139940
|
port,
|
|
139941
139941
|
inspectorPort,
|
|
139942
139942
|
rules,
|
|
139943
|
-
|
|
139943
|
+
localPersistencePath,
|
|
139944
139944
|
liveReload,
|
|
139945
139945
|
ip,
|
|
139946
139946
|
crons,
|
|
@@ -139955,7 +139955,6 @@ function useLocalWorker({
|
|
|
139955
139955
|
const local = (0, import_react3.useRef)();
|
|
139956
139956
|
const removeSignalExitListener = (0, import_react3.useRef)();
|
|
139957
139957
|
const [inspectorUrl, setInspectorUrl] = (0, import_react3.useState)();
|
|
139958
|
-
const localPersistencePath = enableLocalPersistence ? import_node_path13.default.join(process.cwd(), "wrangler-local-state") : null;
|
|
139959
139958
|
(0, import_react3.useEffect)(() => {
|
|
139960
139959
|
if (bindings.services && bindings.services.length > 0) {
|
|
139961
139960
|
logger.warn(
|
|
@@ -141662,7 +141661,19 @@ async function createPreviewSession(account, ctx, abortSignal) {
|
|
|
141662
141661
|
void 0,
|
|
141663
141662
|
abortSignal
|
|
141664
141663
|
);
|
|
141665
|
-
|
|
141664
|
+
logger.debug(`-- START EXCHANGE API REQUEST: GET ${exchange_url}`);
|
|
141665
|
+
logger.debug("-- END EXCHANGE API REQUEST");
|
|
141666
|
+
const exchangeResponse = await (0, import_undici5.fetch)(exchange_url, { signal: abortSignal });
|
|
141667
|
+
const bodyText = await exchangeResponse.text();
|
|
141668
|
+
logger.debug(
|
|
141669
|
+
"-- START EXCHANGE API RESPONSE:",
|
|
141670
|
+
exchangeResponse.statusText,
|
|
141671
|
+
exchangeResponse.status
|
|
141672
|
+
);
|
|
141673
|
+
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
141674
|
+
logger.debug("RESPONSE:", bodyText);
|
|
141675
|
+
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
141676
|
+
const { inspector_websocket, prewarm, token } = parseJSON(bodyText);
|
|
141666
141677
|
const { host } = new import_node_url9.URL(inspector_websocket);
|
|
141667
141678
|
const query = `cf_workers_preview_token=${token}`;
|
|
141668
141679
|
return {
|
|
@@ -143193,7 +143204,7 @@ function DevSession(props) {
|
|
|
143193
143204
|
ip: props.ip,
|
|
143194
143205
|
rules: props.rules,
|
|
143195
143206
|
inspectorPort: props.inspectorPort,
|
|
143196
|
-
|
|
143207
|
+
localPersistencePath: props.localPersistencePath,
|
|
143197
143208
|
liveReload: props.liveReload,
|
|
143198
143209
|
crons: props.crons,
|
|
143199
143210
|
localProtocol: props.localProtocol,
|
|
@@ -143476,7 +143487,7 @@ async function startDevServer(props) {
|
|
|
143476
143487
|
ip: props.ip,
|
|
143477
143488
|
rules: props.rules,
|
|
143478
143489
|
inspectorPort: props.inspectorPort,
|
|
143479
|
-
|
|
143490
|
+
localPersistencePath: props.localPersistencePath,
|
|
143480
143491
|
liveReload: props.liveReload,
|
|
143481
143492
|
crons: props.crons,
|
|
143482
143493
|
localProtocol: props.localProtocol,
|
|
@@ -143576,7 +143587,7 @@ async function startLocalServer({
|
|
|
143576
143587
|
port,
|
|
143577
143588
|
inspectorPort,
|
|
143578
143589
|
rules,
|
|
143579
|
-
|
|
143590
|
+
localPersistencePath,
|
|
143580
143591
|
liveReload,
|
|
143581
143592
|
ip,
|
|
143582
143593
|
crons,
|
|
@@ -143594,7 +143605,6 @@ async function startLocalServer({
|
|
|
143594
143605
|
const setInspectorUrl = (url3) => {
|
|
143595
143606
|
inspectorUrl = url3;
|
|
143596
143607
|
};
|
|
143597
|
-
const localPersistencePath = enableLocalPersistence ? path20.join(process.cwd(), "wrangler-local-state") : null;
|
|
143598
143608
|
const abortController = new AbortController();
|
|
143599
143609
|
async function startLocalWorker() {
|
|
143600
143610
|
if (!bundle || !format4)
|
|
@@ -143850,6 +143860,8 @@ async function fromDashMessagePrompt(deploySource) {
|
|
|
143850
143860
|
`You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.
|
|
143851
143861
|
Edits that have been made via the dashboard will be overridden by your local code and config.`
|
|
143852
143862
|
);
|
|
143863
|
+
if (!isInteractive() || CI.isCI())
|
|
143864
|
+
return true;
|
|
143853
143865
|
return await confirm("Would you like to continue?");
|
|
143854
143866
|
}
|
|
143855
143867
|
}
|
|
@@ -147982,6 +147994,8 @@ ${err2.message ?? err2}`
|
|
|
147982
147994
|
"package.json"
|
|
147983
147995
|
);
|
|
147984
147996
|
let shouldCreatePackageJson = false;
|
|
147997
|
+
let shouldCreateTests = false;
|
|
147998
|
+
let newWorkerTestType = "jest";
|
|
147985
147999
|
if (!pathToPackageJson) {
|
|
147986
148000
|
shouldCreatePackageJson = yesFlag || await confirm("No package.json found. Would you like to create one?");
|
|
147987
148001
|
if (shouldCreatePackageJson) {
|
|
@@ -148069,28 +148083,18 @@ ${err2.message ?? err2}`
|
|
|
148069
148083
|
pathToPackageJson
|
|
148070
148084
|
);
|
|
148071
148085
|
const shouldWritePackageJsonScripts = !packageJsonContent.scripts?.start && !packageJsonContent.scripts?.publish && shouldCreatePackageJson;
|
|
148072
|
-
async function
|
|
148073
|
-
|
|
148074
|
-
|
|
148075
|
-
|
|
148076
|
-
|
|
148077
|
-
|
|
148078
|
-
|
|
148079
|
-
|
|
148080
|
-
|
|
148081
|
-
|
|
148082
|
-
logger.
|
|
148083
|
-
`\u2728 Installed ${formatter.format(
|
|
148084
|
-
versionlessPackages
|
|
148085
|
-
)} into devDependencies`
|
|
148086
|
-
);
|
|
148087
|
-
} else {
|
|
148088
|
-
if (shouldRunInstall) {
|
|
148089
|
-
await packageManager.install();
|
|
148090
|
-
}
|
|
148086
|
+
async function writePackageJsonScriptsAndUpdateWranglerToml({
|
|
148087
|
+
isWritingScripts,
|
|
148088
|
+
isAddingTests,
|
|
148089
|
+
testRunner,
|
|
148090
|
+
isCreatingWranglerToml,
|
|
148091
|
+
packagePath,
|
|
148092
|
+
scriptPath,
|
|
148093
|
+
extraToml
|
|
148094
|
+
}) {
|
|
148095
|
+
if (isAddingTests && !testRunner) {
|
|
148096
|
+
logger.error("testRunner is required if isAddingTests");
|
|
148091
148097
|
}
|
|
148092
|
-
}
|
|
148093
|
-
async function writePackageJsonScriptsAndUpdateWranglerToml(isWritingScripts, isCreatingWranglerToml, packagePath, scriptPath, extraToml) {
|
|
148094
148098
|
if (isCreatingWranglerToml) {
|
|
148095
148099
|
const parsedWranglerToml = parseTOML(
|
|
148096
148100
|
readFileSync5(wranglerTomlDestination)
|
|
@@ -148104,6 +148108,7 @@ ${err2.message ?? err2}`
|
|
|
148104
148108
|
fs7.writeFileSync(wranglerTomlDestination, import_toml4.default.stringify(newToml));
|
|
148105
148109
|
}
|
|
148106
148110
|
const isNamedWorker = isCreatingWranglerToml && import_node_path18.default.dirname(packagePath) !== process.cwd();
|
|
148111
|
+
const isAddingTestScripts = isAddingTests && !packageJsonContent.scripts?.test;
|
|
148107
148112
|
if (isWritingScripts) {
|
|
148108
148113
|
await (0, import_promises7.writeFile)(
|
|
148109
148114
|
packagePath,
|
|
@@ -148113,7 +148118,8 @@ ${err2.message ?? err2}`
|
|
|
148113
148118
|
scripts: {
|
|
148114
148119
|
...packageJsonContent.scripts,
|
|
148115
148120
|
start: isCreatingWranglerToml ? `wrangler dev` : `wrangler dev ${scriptPath}`,
|
|
148116
|
-
deploy: isCreatingWranglerToml ? `wrangler publish` : `wrangler publish ${scriptPath}
|
|
148121
|
+
deploy: isCreatingWranglerToml ? `wrangler publish` : `wrangler publish ${scriptPath}`,
|
|
148122
|
+
...isAddingTestScripts && { test: testRunner }
|
|
148117
148123
|
}
|
|
148118
148124
|
},
|
|
148119
148125
|
null,
|
|
@@ -148124,6 +148130,9 @@ ${err2.message ?? err2}`
|
|
|
148124
148130
|
`
|
|
148125
148131
|
To start developing your Worker, run \`${isNamedWorker ? `cd ${args.name} && ` : ""}npm start\``
|
|
148126
148132
|
);
|
|
148133
|
+
if (isAddingTestScripts) {
|
|
148134
|
+
instructions.push(`To start testing your Worker, run \`npm test\``);
|
|
148135
|
+
}
|
|
148127
148136
|
instructions.push(
|
|
148128
148137
|
`To publish your Worker to the Internet, run \`npm run deploy\``
|
|
148129
148138
|
);
|
|
@@ -148137,45 +148146,6 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148137
148146
|
);
|
|
148138
148147
|
}
|
|
148139
148148
|
}
|
|
148140
|
-
async function getNewWorkerType(newWorkerFilename) {
|
|
148141
|
-
return select(
|
|
148142
|
-
`Would you like to create a Worker at ${newWorkerFilename}?`,
|
|
148143
|
-
[
|
|
148144
|
-
{
|
|
148145
|
-
value: "none",
|
|
148146
|
-
label: "None"
|
|
148147
|
-
},
|
|
148148
|
-
{
|
|
148149
|
-
value: "fetch",
|
|
148150
|
-
label: "Fetch handler"
|
|
148151
|
-
},
|
|
148152
|
-
{
|
|
148153
|
-
value: "scheduled",
|
|
148154
|
-
label: "Scheduled handler"
|
|
148155
|
-
}
|
|
148156
|
-
],
|
|
148157
|
-
1
|
|
148158
|
-
);
|
|
148159
|
-
}
|
|
148160
|
-
function getNewWorkerTemplate(lang, workerType) {
|
|
148161
|
-
const templates = {
|
|
148162
|
-
"js-fetch": "new-worker.js",
|
|
148163
|
-
"js-scheduled": "new-worker-scheduled.js",
|
|
148164
|
-
"ts-fetch": "new-worker.ts",
|
|
148165
|
-
"ts-scheduled": "new-worker-scheduled.ts"
|
|
148166
|
-
};
|
|
148167
|
-
return templates[`${lang}-${workerType}`];
|
|
148168
|
-
}
|
|
148169
|
-
function getNewWorkerToml(workerType) {
|
|
148170
|
-
if (workerType === "scheduled") {
|
|
148171
|
-
return {
|
|
148172
|
-
triggers: {
|
|
148173
|
-
crons: ["1 * * * *"]
|
|
148174
|
-
}
|
|
148175
|
-
};
|
|
148176
|
-
}
|
|
148177
|
-
return {};
|
|
148178
|
-
}
|
|
148179
148149
|
if (isTypescriptProject) {
|
|
148180
148150
|
if (!fs7.existsSync(import_node_path18.default.join(creationDirectory, "./src/index.ts"))) {
|
|
148181
148151
|
const newWorkerFilename = import_node_path18.default.relative(
|
|
@@ -148203,16 +148173,16 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148203
148173
|
import_node_path18.default.join(creationDirectory, "./src/index.ts"),
|
|
148204
148174
|
dashScript
|
|
148205
148175
|
);
|
|
148206
|
-
await writePackageJsonScriptsAndUpdateWranglerToml(
|
|
148207
|
-
shouldWritePackageJsonScripts,
|
|
148208
|
-
justCreatedWranglerToml,
|
|
148209
|
-
pathToPackageJson,
|
|
148210
|
-
"src/index.ts",
|
|
148211
|
-
await getWorkerConfig(accountId, fromDashScriptName, {
|
|
148176
|
+
await writePackageJsonScriptsAndUpdateWranglerToml({
|
|
148177
|
+
isWritingScripts: shouldWritePackageJsonScripts,
|
|
148178
|
+
isCreatingWranglerToml: justCreatedWranglerToml,
|
|
148179
|
+
packagePath: pathToPackageJson,
|
|
148180
|
+
scriptPath: "src/index.ts",
|
|
148181
|
+
extraToml: await getWorkerConfig(accountId, fromDashScriptName, {
|
|
148212
148182
|
defaultEnvironment,
|
|
148213
148183
|
environments: serviceMetaData.environments
|
|
148214
148184
|
})
|
|
148215
|
-
);
|
|
148185
|
+
});
|
|
148216
148186
|
} else {
|
|
148217
148187
|
const newWorkerType = yesFlag ? "fetch" : await getNewWorkerType(newWorkerFilename);
|
|
148218
148188
|
if (newWorkerType !== "none") {
|
|
@@ -148230,13 +148200,13 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148230
148200
|
import_node_path18.default.join(creationDirectory, "./src/index.ts")
|
|
148231
148201
|
)}`
|
|
148232
148202
|
);
|
|
148233
|
-
await writePackageJsonScriptsAndUpdateWranglerToml(
|
|
148234
|
-
shouldWritePackageJsonScripts,
|
|
148235
|
-
justCreatedWranglerToml,
|
|
148236
|
-
pathToPackageJson,
|
|
148237
|
-
"src/index.ts",
|
|
148238
|
-
getNewWorkerToml(newWorkerType)
|
|
148239
|
-
);
|
|
148203
|
+
await writePackageJsonScriptsAndUpdateWranglerToml({
|
|
148204
|
+
isWritingScripts: shouldWritePackageJsonScripts,
|
|
148205
|
+
isCreatingWranglerToml: justCreatedWranglerToml,
|
|
148206
|
+
packagePath: pathToPackageJson,
|
|
148207
|
+
scriptPath: "src/index.ts",
|
|
148208
|
+
extraToml: getNewWorkerToml(newWorkerType)
|
|
148209
|
+
});
|
|
148240
148210
|
}
|
|
148241
148211
|
}
|
|
148242
148212
|
}
|
|
@@ -148267,16 +148237,16 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148267
148237
|
import_node_path18.default.join(creationDirectory, "./src/index.js"),
|
|
148268
148238
|
dashScript
|
|
148269
148239
|
);
|
|
148270
|
-
await writePackageJsonScriptsAndUpdateWranglerToml(
|
|
148271
|
-
shouldWritePackageJsonScripts,
|
|
148272
|
-
justCreatedWranglerToml,
|
|
148273
|
-
pathToPackageJson,
|
|
148274
|
-
"src/index.ts",
|
|
148275
|
-
await getWorkerConfig(accountId, fromDashScriptName, {
|
|
148240
|
+
await writePackageJsonScriptsAndUpdateWranglerToml({
|
|
148241
|
+
isWritingScripts: shouldWritePackageJsonScripts,
|
|
148242
|
+
isCreatingWranglerToml: justCreatedWranglerToml,
|
|
148243
|
+
packagePath: pathToPackageJson,
|
|
148244
|
+
scriptPath: "src/index.ts",
|
|
148245
|
+
extraToml: await getWorkerConfig(accountId, fromDashScriptName, {
|
|
148276
148246
|
defaultEnvironment,
|
|
148277
148247
|
environments: serviceMetaData.environments
|
|
148278
148248
|
})
|
|
148279
|
-
);
|
|
148249
|
+
});
|
|
148280
148250
|
} else {
|
|
148281
148251
|
const newWorkerType = yesFlag ? "fetch" : await getNewWorkerType(newWorkerFilename);
|
|
148282
148252
|
if (newWorkerType !== "none") {
|
|
@@ -148294,19 +148264,45 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148294
148264
|
import_node_path18.default.join(creationDirectory, "./src/index.js")
|
|
148295
148265
|
)}`
|
|
148296
148266
|
);
|
|
148297
|
-
await
|
|
148298
|
-
|
|
148299
|
-
|
|
148300
|
-
|
|
148301
|
-
|
|
148302
|
-
|
|
148303
|
-
|
|
148267
|
+
shouldCreateTests = yesFlag || await confirm("Would you like us to write your first test?");
|
|
148268
|
+
if (shouldCreateTests) {
|
|
148269
|
+
newWorkerTestType = await getNewWorkerTestType();
|
|
148270
|
+
devDepsToInstall.push(newWorkerTestType);
|
|
148271
|
+
await (0, import_promises7.writeFile)(
|
|
148272
|
+
import_node_path18.default.join(creationDirectory, "./src/index.test.js"),
|
|
148273
|
+
readFileSync5(
|
|
148274
|
+
import_node_path18.default.join(
|
|
148275
|
+
getBasePath(),
|
|
148276
|
+
`templates/init-tests/test-${newWorkerTestType}-new-worker.js`
|
|
148277
|
+
)
|
|
148278
|
+
)
|
|
148279
|
+
);
|
|
148280
|
+
logger.log(
|
|
148281
|
+
`\u2728 Created ${import_node_path18.default.relative(
|
|
148282
|
+
process.cwd(),
|
|
148283
|
+
import_node_path18.default.join(creationDirectory, "./src/index.test.js")
|
|
148284
|
+
)}`
|
|
148285
|
+
);
|
|
148286
|
+
}
|
|
148287
|
+
await writePackageJsonScriptsAndUpdateWranglerToml({
|
|
148288
|
+
isWritingScripts: shouldWritePackageJsonScripts,
|
|
148289
|
+
isAddingTests: shouldCreateTests,
|
|
148290
|
+
testRunner: newWorkerTestType,
|
|
148291
|
+
isCreatingWranglerToml: justCreatedWranglerToml,
|
|
148292
|
+
packagePath: pathToPackageJson,
|
|
148293
|
+
scriptPath: "src/index.js",
|
|
148294
|
+
extraToml: getNewWorkerToml(newWorkerType)
|
|
148295
|
+
});
|
|
148304
148296
|
}
|
|
148305
148297
|
}
|
|
148306
148298
|
}
|
|
148307
148299
|
}
|
|
148308
148300
|
try {
|
|
148309
|
-
await installPackages(
|
|
148301
|
+
await installPackages(
|
|
148302
|
+
shouldRunPackageManagerInstall,
|
|
148303
|
+
devDepsToInstall,
|
|
148304
|
+
packageManager
|
|
148305
|
+
);
|
|
148310
148306
|
} catch (e2) {
|
|
148311
148307
|
logger.error(e2 instanceof Error ? e2.message : e2);
|
|
148312
148308
|
instructions.push(
|
|
@@ -148315,6 +148311,82 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
|
|
|
148315
148311
|
}
|
|
148316
148312
|
instructions.forEach((instruction) => logger.log(instruction));
|
|
148317
148313
|
}
|
|
148314
|
+
async function installPackages(shouldRunInstall, depsToInstall, packageManager) {
|
|
148315
|
+
if (depsToInstall.length > 0) {
|
|
148316
|
+
const formatter = new Intl.ListFormat("en", {
|
|
148317
|
+
style: "long",
|
|
148318
|
+
type: "conjunction"
|
|
148319
|
+
});
|
|
148320
|
+
await packageManager.addDevDeps(...depsToInstall);
|
|
148321
|
+
const versionlessPackages = depsToInstall.map(
|
|
148322
|
+
(dep) => dep === `wrangler@${version}` ? "wrangler" : dep
|
|
148323
|
+
);
|
|
148324
|
+
logger.log(
|
|
148325
|
+
`\u2728 Installed ${formatter.format(
|
|
148326
|
+
versionlessPackages
|
|
148327
|
+
)} into devDependencies`
|
|
148328
|
+
);
|
|
148329
|
+
} else {
|
|
148330
|
+
if (shouldRunInstall) {
|
|
148331
|
+
await packageManager.install();
|
|
148332
|
+
}
|
|
148333
|
+
}
|
|
148334
|
+
}
|
|
148335
|
+
async function getNewWorkerType(newWorkerFilename) {
|
|
148336
|
+
return select(
|
|
148337
|
+
`Would you like to create a Worker at ${newWorkerFilename}?`,
|
|
148338
|
+
[
|
|
148339
|
+
{
|
|
148340
|
+
value: "none",
|
|
148341
|
+
label: "None"
|
|
148342
|
+
},
|
|
148343
|
+
{
|
|
148344
|
+
value: "fetch",
|
|
148345
|
+
label: "Fetch handler"
|
|
148346
|
+
},
|
|
148347
|
+
{
|
|
148348
|
+
value: "scheduled",
|
|
148349
|
+
label: "Scheduled handler"
|
|
148350
|
+
}
|
|
148351
|
+
],
|
|
148352
|
+
1
|
|
148353
|
+
);
|
|
148354
|
+
}
|
|
148355
|
+
async function getNewWorkerTestType() {
|
|
148356
|
+
return select(
|
|
148357
|
+
`Which test runner would you like to use?`,
|
|
148358
|
+
[
|
|
148359
|
+
{
|
|
148360
|
+
value: "vitest",
|
|
148361
|
+
label: "Vitest"
|
|
148362
|
+
},
|
|
148363
|
+
{
|
|
148364
|
+
value: "jest",
|
|
148365
|
+
label: "Jest"
|
|
148366
|
+
}
|
|
148367
|
+
],
|
|
148368
|
+
1
|
|
148369
|
+
);
|
|
148370
|
+
}
|
|
148371
|
+
function getNewWorkerTemplate(lang, workerType) {
|
|
148372
|
+
const templates = {
|
|
148373
|
+
"js-fetch": "new-worker.js",
|
|
148374
|
+
"js-scheduled": "new-worker-scheduled.js",
|
|
148375
|
+
"ts-fetch": "new-worker.ts",
|
|
148376
|
+
"ts-scheduled": "new-worker-scheduled.ts"
|
|
148377
|
+
};
|
|
148378
|
+
return templates[`${lang}-${workerType}`];
|
|
148379
|
+
}
|
|
148380
|
+
function getNewWorkerToml(workerType) {
|
|
148381
|
+
if (workerType === "scheduled") {
|
|
148382
|
+
return {
|
|
148383
|
+
triggers: {
|
|
148384
|
+
crons: ["1 * * * *"]
|
|
148385
|
+
}
|
|
148386
|
+
};
|
|
148387
|
+
}
|
|
148388
|
+
return {};
|
|
148389
|
+
}
|
|
148318
148390
|
async function findPath(isolatedInit, cwd2, basename4) {
|
|
148319
148391
|
if (isolatedInit) {
|
|
148320
148392
|
return fs7.existsSync(import_node_path18.default.resolve(cwd2, basename4)) ? import_node_path18.default.resolve(cwd2, basename4) : void 0;
|
|
@@ -149726,9 +149798,19 @@ function Options2(yargs) {
|
|
|
149726
149798
|
choices: ["http", "https"]
|
|
149727
149799
|
},
|
|
149728
149800
|
"experimental-enable-local-persistence": {
|
|
149801
|
+
describe: "Enable persistence for local mode (deprecated, use --persist)",
|
|
149729
149802
|
type: "boolean",
|
|
149730
|
-
|
|
149731
|
-
|
|
149803
|
+
deprecated: true,
|
|
149804
|
+
hidden: true
|
|
149805
|
+
},
|
|
149806
|
+
persist: {
|
|
149807
|
+
describe: "Enable persistence for local mode, using default path: .wrangler/state",
|
|
149808
|
+
type: "boolean"
|
|
149809
|
+
},
|
|
149810
|
+
"persist-to": {
|
|
149811
|
+
describe: "Specify directory to use for local persistence (implies --persist)",
|
|
149812
|
+
type: "string",
|
|
149813
|
+
requiresArg: true
|
|
149732
149814
|
},
|
|
149733
149815
|
"node-compat": {
|
|
149734
149816
|
describe: "Enable node.js compatibility",
|
|
@@ -149759,7 +149841,9 @@ var Handler2 = async ({
|
|
|
149759
149841
|
r2: r2s = [],
|
|
149760
149842
|
"live-reload": liveReload,
|
|
149761
149843
|
"local-protocol": localProtocol,
|
|
149762
|
-
|
|
149844
|
+
experimentalEnableLocalPersistence,
|
|
149845
|
+
persist,
|
|
149846
|
+
persistTo,
|
|
149763
149847
|
"node-compat": nodeCompat,
|
|
149764
149848
|
config,
|
|
149765
149849
|
_: [_pages, _dev, ...remaining]
|
|
@@ -149790,6 +149874,13 @@ var Handler2 = async ({
|
|
|
149790
149874
|
} else {
|
|
149791
149875
|
directory = (0, import_node_path26.resolve)(directory);
|
|
149792
149876
|
}
|
|
149877
|
+
if (experimentalEnableLocalPersistence) {
|
|
149878
|
+
logger.warn(
|
|
149879
|
+
`--experimental-enable-local-persistence is deprecated.
|
|
149880
|
+
Move any existing data to .wrangler/state and use --persist, or
|
|
149881
|
+
use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
149882
|
+
);
|
|
149883
|
+
}
|
|
149793
149884
|
let scriptReadyResolve;
|
|
149794
149885
|
const scriptReadyPromise = new Promise(
|
|
149795
149886
|
(promiseResolve) => scriptReadyResolve = promiseResolve
|
|
@@ -149928,7 +150019,8 @@ var Handler2 = async ({
|
|
|
149928
150019
|
directory
|
|
149929
150020
|
},
|
|
149930
150021
|
forceLocal: true,
|
|
149931
|
-
|
|
150022
|
+
persist,
|
|
150023
|
+
persistTo,
|
|
149932
150024
|
showInteractiveDevSession: void 0,
|
|
149933
150025
|
inspect: true,
|
|
149934
150026
|
logLevel: "error",
|
|
@@ -153822,7 +153914,7 @@ ${shouldDo}`);
|
|
|
153822
153914
|
}
|
|
153823
153915
|
}
|
|
153824
153916
|
const url3 = !secretBulkArgs.env || isLegacyEnv(config) ? `/accounts/${accountId}/workers/scripts/${scriptName}/secrets` : `/accounts/${accountId}/workers/services/${scriptName}/environments/${secretBulkArgs.env}/secrets`;
|
|
153825
|
-
await Promise.
|
|
153917
|
+
const bulkOutcomes = await Promise.all(
|
|
153826
153918
|
Object.entries(content).map(async ([key2, value]) => {
|
|
153827
153919
|
return fetchResult(url3, {
|
|
153828
153920
|
method: "PUT",
|
|
@@ -153834,15 +153926,24 @@ ${shouldDo}`);
|
|
|
153834
153926
|
})
|
|
153835
153927
|
}).then(() => {
|
|
153836
153928
|
logger.log(`\u2728 Successfully created secret for key: ${key2}`);
|
|
153929
|
+
return true;
|
|
153837
153930
|
}).catch((e2) => {
|
|
153838
153931
|
logger.error(
|
|
153839
153932
|
`\u{1F6A8} Error uploading secret for key: ${key2}:
|
|
153840
153933
|
${e2.message}`
|
|
153841
153934
|
);
|
|
153935
|
+
return false;
|
|
153842
153936
|
});
|
|
153843
153937
|
})
|
|
153844
153938
|
);
|
|
153845
|
-
|
|
153939
|
+
const successes = bulkOutcomes.filter((outcome) => outcome).length;
|
|
153940
|
+
const failures = bulkOutcomes.length - successes;
|
|
153941
|
+
logger.log("");
|
|
153942
|
+
logger.log("Finished processing secrets JSON file:");
|
|
153943
|
+
logger.log(`\u2728 ${successes} secrets successfully uploaded`);
|
|
153944
|
+
if (failures > 0) {
|
|
153945
|
+
logger.log(`\u{1F6A8} ${failures} secrets failed to upload`);
|
|
153946
|
+
}
|
|
153846
153947
|
}
|
|
153847
153948
|
);
|
|
153848
153949
|
wrangler.command(
|
|
@@ -154848,8 +154949,17 @@ function devOptions(yargs) {
|
|
|
154848
154949
|
describe: "Enable node.js compatibility",
|
|
154849
154950
|
type: "boolean"
|
|
154850
154951
|
}).option("experimental-enable-local-persistence", {
|
|
154851
|
-
describe: "Enable persistence for
|
|
154952
|
+
describe: "Enable persistence for local mode (deprecated, use --persist)",
|
|
154953
|
+
type: "boolean",
|
|
154954
|
+
deprecated: true,
|
|
154955
|
+
hidden: true
|
|
154956
|
+
}).option("persist", {
|
|
154957
|
+
describe: "Enable persistence for local mode, using default path: .wrangler/state",
|
|
154852
154958
|
type: "boolean"
|
|
154959
|
+
}).option("persist-to", {
|
|
154960
|
+
describe: "Specify directory to use for local persistence (implies --persist)",
|
|
154961
|
+
type: "string",
|
|
154962
|
+
requiresArg: true
|
|
154853
154963
|
}).option("live-reload", {
|
|
154854
154964
|
hidden: true,
|
|
154855
154965
|
type: "boolean"
|
|
@@ -154904,7 +155014,8 @@ async function startDev(args) {
|
|
|
154904
155014
|
routes,
|
|
154905
155015
|
getLocalPort,
|
|
154906
155016
|
getInspectorPort,
|
|
154907
|
-
cliDefines
|
|
155017
|
+
cliDefines,
|
|
155018
|
+
localPersistencePath
|
|
154908
155019
|
} = await validateDevServerSettings(args, config);
|
|
154909
155020
|
await sendMetricsEvent(
|
|
154910
155021
|
"run dev",
|
|
@@ -154940,7 +155051,7 @@ async function startDev(args) {
|
|
|
154940
155051
|
upstreamProtocol,
|
|
154941
155052
|
localProtocol: args.localProtocol || configParam.dev.local_protocol,
|
|
154942
155053
|
localUpstream: args["local-upstream"] || host,
|
|
154943
|
-
|
|
155054
|
+
localPersistencePath,
|
|
154944
155055
|
liveReload: args.liveReload || false,
|
|
154945
155056
|
accountId: configParam.account_id || getAccountFromCache()?.id,
|
|
154946
155057
|
assetPaths,
|
|
@@ -154998,7 +155109,8 @@ async function startApiDev(args) {
|
|
|
154998
155109
|
routes,
|
|
154999
155110
|
getLocalPort,
|
|
155000
155111
|
getInspectorPort,
|
|
155001
|
-
cliDefines
|
|
155112
|
+
cliDefines,
|
|
155113
|
+
localPersistencePath
|
|
155002
155114
|
} = await validateDevServerSettings(args, config);
|
|
155003
155115
|
await sendMetricsEvent(
|
|
155004
155116
|
"run dev (api)",
|
|
@@ -155031,7 +155143,7 @@ async function startApiDev(args) {
|
|
|
155031
155143
|
upstreamProtocol,
|
|
155032
155144
|
localProtocol: args.localProtocol || configParam.dev.local_protocol,
|
|
155033
155145
|
localUpstream: args["local-upstream"] || host,
|
|
155034
|
-
|
|
155146
|
+
localPersistencePath,
|
|
155035
155147
|
liveReload: args.liveReload || false,
|
|
155036
155148
|
accountId: configParam.account_id || getAccountFromCache()?.id,
|
|
155037
155149
|
assetPaths,
|
|
@@ -155161,6 +155273,14 @@ async function validateDevServerSettings(args, config) {
|
|
|
155161
155273
|
"Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
|
|
155162
155274
|
);
|
|
155163
155275
|
}
|
|
155276
|
+
if (args.experimentalEnableLocalPersistence) {
|
|
155277
|
+
logger.warn(
|
|
155278
|
+
`--experimental-enable-local-persistence is deprecated.
|
|
155279
|
+
Move any existing data to .wrangler/state and use --persist, or
|
|
155280
|
+
use --persist-to=./wrangler-local-state to keep using the old path.`
|
|
155281
|
+
);
|
|
155282
|
+
}
|
|
155283
|
+
const localPersistencePath = args.persistTo ? import_node_path33.default.resolve(process.cwd(), args.persistTo) : args.persist ? import_node_path33.default.resolve(config.configPath || process.cwd(), ".wrangler/state") : null;
|
|
155164
155284
|
const cliDefines = args.define?.reduce((collectDefines, d) => {
|
|
155165
155285
|
const [key2, ...value] = d.split(":");
|
|
155166
155286
|
collectDefines[key2] = value.join("");
|
|
@@ -155175,7 +155295,8 @@ async function validateDevServerSettings(args, config) {
|
|
|
155175
155295
|
zoneId,
|
|
155176
155296
|
host,
|
|
155177
155297
|
routes,
|
|
155178
|
-
cliDefines
|
|
155298
|
+
cliDefines,
|
|
155299
|
+
localPersistencePath
|
|
155179
155300
|
};
|
|
155180
155301
|
}
|
|
155181
155302
|
async function getBindingsAndAssetPaths(args, configParam) {
|
|
@@ -155291,9 +155412,16 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
|
155291
155412
|
}).then((devServer) => {
|
|
155292
155413
|
resolve14({
|
|
155293
155414
|
stop: devServer.stop,
|
|
155294
|
-
fetch: async (init) => {
|
|
155295
|
-
|
|
155296
|
-
|
|
155415
|
+
fetch: async (input, init) => {
|
|
155416
|
+
return await (0, import_undici11.fetch)(
|
|
155417
|
+
...parseRequestInput(
|
|
155418
|
+
readyAddress,
|
|
155419
|
+
readyPort,
|
|
155420
|
+
input,
|
|
155421
|
+
init,
|
|
155422
|
+
options?.localProtocol
|
|
155423
|
+
)
|
|
155424
|
+
);
|
|
155297
155425
|
},
|
|
155298
155426
|
waitUntilExit: async () => {
|
|
155299
155427
|
return;
|
|
@@ -155322,9 +155450,16 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
|
155322
155450
|
}).then((devServer) => {
|
|
155323
155451
|
resolve14({
|
|
155324
155452
|
stop: devServer.stop,
|
|
155325
|
-
fetch: async (init) => {
|
|
155326
|
-
|
|
155327
|
-
|
|
155453
|
+
fetch: async (input, init) => {
|
|
155454
|
+
return await (0, import_undici11.fetch)(
|
|
155455
|
+
...parseRequestInput(
|
|
155456
|
+
readyAddress,
|
|
155457
|
+
readyPort,
|
|
155458
|
+
input,
|
|
155459
|
+
init,
|
|
155460
|
+
options?.localProtocol
|
|
155461
|
+
)
|
|
155462
|
+
);
|
|
155328
155463
|
},
|
|
155329
155464
|
waitUntilExit: devServer.devReactElement.waitUntilExit
|
|
155330
155465
|
});
|
|
@@ -155332,6 +155467,22 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
|
155332
155467
|
});
|
|
155333
155468
|
}
|
|
155334
155469
|
}
|
|
155470
|
+
function parseRequestInput(readyAddress, readyPort, input, init, protocol = "http") {
|
|
155471
|
+
if (input instanceof import_undici11.Request) {
|
|
155472
|
+
return [input, void 0];
|
|
155473
|
+
} else if (input instanceof URL) {
|
|
155474
|
+
input = `${protocol}://${readyAddress}:${readyPort}${input.pathname}`;
|
|
155475
|
+
} else if (typeof input === "string") {
|
|
155476
|
+
try {
|
|
155477
|
+
input = `${protocol}://${readyAddress}:${readyPort}${new URL(input).pathname}`;
|
|
155478
|
+
} catch {
|
|
155479
|
+
input = `${protocol}://${readyAddress}:${readyPort}${input}`;
|
|
155480
|
+
}
|
|
155481
|
+
} else {
|
|
155482
|
+
input = `${protocol}://${readyAddress}:${readyPort}`;
|
|
155483
|
+
}
|
|
155484
|
+
return [input, init];
|
|
155485
|
+
}
|
|
155335
155486
|
|
|
155336
155487
|
// src/cli.ts
|
|
155337
155488
|
if (typeof jest === "undefined" && require.main) {
|