wrangler 2.2.4 → 2.3.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/package.json +1 -1
- package/src/__tests__/pages-deployment-tail.test.ts +820 -0
- package/src/__tests__/pages.test.ts +1 -0
- package/src/metrics/send-event.ts +2 -0
- package/src/pages/build.tsx +1 -1
- package/src/pages/deployment-tails.tsx +284 -0
- package/src/pages/deployments.tsx +5 -27
- package/src/pages/dev.tsx +1 -1
- package/src/pages/functions.tsx +1 -1
- package/src/pages/index.tsx +8 -0
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +4 -19
- package/src/pages/types.ts +1 -9
- package/src/pages/upload.tsx +2 -1
- package/src/pages/utils.ts +11 -0
- package/src/tail/createTail.ts +66 -2
- package/src/yargs-types.ts +4 -0
- package/templates/d1-beta-facade.js +9 -0
- package/wrangler-dist/cli.js +570 -319
package/wrangler-dist/cli.js
CHANGED
|
@@ -15161,7 +15161,7 @@ var require_lodash = __commonJS({
|
|
|
15161
15161
|
if (typeof func2 != "function") {
|
|
15162
15162
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
15163
15163
|
}
|
|
15164
|
-
return
|
|
15164
|
+
return setTimeout4(function() {
|
|
15165
15165
|
func2.apply(undefined2, args);
|
|
15166
15166
|
}, wait);
|
|
15167
15167
|
}
|
|
@@ -16992,7 +16992,7 @@ var require_lodash = __commonJS({
|
|
|
16992
16992
|
return object[key2];
|
|
16993
16993
|
}
|
|
16994
16994
|
var setData = shortOut(baseSetData);
|
|
16995
|
-
var
|
|
16995
|
+
var setTimeout4 = ctxSetTimeout || function(func2, wait) {
|
|
16996
16996
|
return root.setTimeout(func2, wait);
|
|
16997
16997
|
};
|
|
16998
16998
|
var setToString = shortOut(baseSetToString);
|
|
@@ -17784,7 +17784,7 @@ var require_lodash = __commonJS({
|
|
|
17784
17784
|
}
|
|
17785
17785
|
function leadingEdge(time) {
|
|
17786
17786
|
lastInvokeTime = time;
|
|
17787
|
-
timerId =
|
|
17787
|
+
timerId = setTimeout4(timerExpired, wait);
|
|
17788
17788
|
return leading ? invokeFunc(time) : result2;
|
|
17789
17789
|
}
|
|
17790
17790
|
function remainingWait(time) {
|
|
@@ -17800,7 +17800,7 @@ var require_lodash = __commonJS({
|
|
|
17800
17800
|
if (shouldInvoke(time)) {
|
|
17801
17801
|
return trailingEdge(time);
|
|
17802
17802
|
}
|
|
17803
|
-
timerId =
|
|
17803
|
+
timerId = setTimeout4(timerExpired, remainingWait(time));
|
|
17804
17804
|
}
|
|
17805
17805
|
function trailingEdge(time) {
|
|
17806
17806
|
timerId = undefined2;
|
|
@@ -17831,12 +17831,12 @@ var require_lodash = __commonJS({
|
|
|
17831
17831
|
}
|
|
17832
17832
|
if (maxing) {
|
|
17833
17833
|
clearTimeout2(timerId);
|
|
17834
|
-
timerId =
|
|
17834
|
+
timerId = setTimeout4(timerExpired, wait);
|
|
17835
17835
|
return invokeFunc(lastCallTime);
|
|
17836
17836
|
}
|
|
17837
17837
|
}
|
|
17838
17838
|
if (timerId === undefined2) {
|
|
17839
|
-
timerId =
|
|
17839
|
+
timerId = setTimeout4(timerExpired, wait);
|
|
17840
17840
|
}
|
|
17841
17841
|
return result2;
|
|
17842
17842
|
}
|
|
@@ -19861,7 +19861,7 @@ var require_log_update = __commonJS({
|
|
|
19861
19861
|
let previousLineCount = 0;
|
|
19862
19862
|
let previousOutput = "";
|
|
19863
19863
|
let hasHiddenCursor = false;
|
|
19864
|
-
const
|
|
19864
|
+
const render15 = (str) => {
|
|
19865
19865
|
if (!showCursor && !hasHiddenCursor) {
|
|
19866
19866
|
cli_cursor_1.default.hide();
|
|
19867
19867
|
hasHiddenCursor = true;
|
|
@@ -19874,12 +19874,12 @@ var require_log_update = __commonJS({
|
|
|
19874
19874
|
stream2.write(ansi_escapes_1.default.eraseLines(previousLineCount) + output);
|
|
19875
19875
|
previousLineCount = output.split("\n").length;
|
|
19876
19876
|
};
|
|
19877
|
-
|
|
19877
|
+
render15.clear = () => {
|
|
19878
19878
|
stream2.write(ansi_escapes_1.default.eraseLines(previousLineCount));
|
|
19879
19879
|
previousOutput = "";
|
|
19880
19880
|
previousLineCount = 0;
|
|
19881
19881
|
};
|
|
19882
|
-
|
|
19882
|
+
render15.done = () => {
|
|
19883
19883
|
previousOutput = "";
|
|
19884
19884
|
previousLineCount = 0;
|
|
19885
19885
|
if (!showCursor) {
|
|
@@ -19887,7 +19887,7 @@ var require_log_update = __commonJS({
|
|
|
19887
19887
|
hasHiddenCursor = false;
|
|
19888
19888
|
}
|
|
19889
19889
|
};
|
|
19890
|
-
return
|
|
19890
|
+
return render15;
|
|
19891
19891
|
};
|
|
19892
19892
|
exports2.default = { create };
|
|
19893
19893
|
}
|
|
@@ -75541,7 +75541,7 @@ var require_render = __commonJS({
|
|
|
75541
75541
|
var ink_1 = __importDefault(require_ink());
|
|
75542
75542
|
var instances_1 = __importDefault(require_instances());
|
|
75543
75543
|
var stream_1 = require("stream");
|
|
75544
|
-
var
|
|
75544
|
+
var render15 = (node, options6) => {
|
|
75545
75545
|
const inkOptions = Object.assign({ stdout: process.stdout, stdin: process.stdin, stderr: process.stderr, debug: false, exitOnCtrlC: true, patchConsole: true }, getOptions(options6));
|
|
75546
75546
|
const instance = getInstance(inkOptions.stdout, () => new ink_1.default(inkOptions));
|
|
75547
75547
|
instance.render(node);
|
|
@@ -75553,7 +75553,7 @@ var require_render = __commonJS({
|
|
|
75553
75553
|
clear: instance.clear
|
|
75554
75554
|
};
|
|
75555
75555
|
};
|
|
75556
|
-
exports2.default =
|
|
75556
|
+
exports2.default = render15;
|
|
75557
75557
|
var getOptions = (stdout = {}) => {
|
|
75558
75558
|
if (stdout instanceof stream_1.Stream) {
|
|
75559
75559
|
return {
|
|
@@ -75612,7 +75612,7 @@ var require_Static = __commonJS({
|
|
|
75612
75612
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
75613
75613
|
var react_1 = __importStar(require_react());
|
|
75614
75614
|
var Static2 = (props) => {
|
|
75615
|
-
const { items, children:
|
|
75615
|
+
const { items, children: render15, style: customStyle } = props;
|
|
75616
75616
|
const [index, setIndex] = react_1.useState(0);
|
|
75617
75617
|
const itemsToRender = react_1.useMemo(() => {
|
|
75618
75618
|
return items.slice(index);
|
|
@@ -75621,7 +75621,7 @@ var require_Static = __commonJS({
|
|
|
75621
75621
|
setIndex(items.length);
|
|
75622
75622
|
}, [items.length]);
|
|
75623
75623
|
const children = itemsToRender.map((item, itemIndex) => {
|
|
75624
|
-
return
|
|
75624
|
+
return render15(item, index + itemIndex);
|
|
75625
75625
|
});
|
|
75626
75626
|
const style = react_1.useMemo(() => Object.assign({ position: "absolute", flexDirection: "column" }, customStyle), [customStyle]);
|
|
75627
75627
|
return react_1.default.createElement("ink-box", {
|
|
@@ -79332,7 +79332,7 @@ var require_kill = __commonJS({
|
|
|
79332
79332
|
"use strict";
|
|
79333
79333
|
init_import_meta_url();
|
|
79334
79334
|
var os11 = require("os");
|
|
79335
|
-
var
|
|
79335
|
+
var onExit7 = require_signal_exit();
|
|
79336
79336
|
var DEFAULT_FORCE_KILL_TIMEOUT2 = 1e3 * 5;
|
|
79337
79337
|
var spawnedKill2 = (kill, signal = "SIGTERM", options6 = {}) => {
|
|
79338
79338
|
const killResult = kill(signal);
|
|
@@ -79400,7 +79400,7 @@ var require_kill = __commonJS({
|
|
|
79400
79400
|
if (!cleanup || detached) {
|
|
79401
79401
|
return timedPromise;
|
|
79402
79402
|
}
|
|
79403
|
-
const removeExitHandler =
|
|
79403
|
+
const removeExitHandler = onExit7(() => {
|
|
79404
79404
|
spawned.kill();
|
|
79405
79405
|
});
|
|
79406
79406
|
return timedPromise.finally(() => {
|
|
@@ -80199,7 +80199,7 @@ var require_react_error_boundary_cjs = __commonJS({
|
|
|
80199
80199
|
init_import_meta_url();
|
|
80200
80200
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
80201
80201
|
var _inheritsLoose = require_inheritsLoose();
|
|
80202
|
-
var
|
|
80202
|
+
var React18 = require_react();
|
|
80203
80203
|
function _interopDefaultLegacy(e2) {
|
|
80204
80204
|
return e2 && typeof e2 === "object" && "default" in e2 ? e2 : { "default": e2 };
|
|
80205
80205
|
}
|
|
@@ -80224,7 +80224,7 @@ var require_react_error_boundary_cjs = __commonJS({
|
|
|
80224
80224
|
return Object.freeze(n);
|
|
80225
80225
|
}
|
|
80226
80226
|
var _inheritsLoose__default = /* @__PURE__ */ _interopDefaultLegacy(_inheritsLoose);
|
|
80227
|
-
var React__namespace = /* @__PURE__ */ _interopNamespace(
|
|
80227
|
+
var React__namespace = /* @__PURE__ */ _interopNamespace(React18);
|
|
80228
80228
|
var changedArray = function changedArray2(a, b) {
|
|
80229
80229
|
if (a === void 0) {
|
|
80230
80230
|
a = [];
|
|
@@ -80280,7 +80280,7 @@ var require_react_error_boundary_cjs = __commonJS({
|
|
|
80280
80280
|
this.reset();
|
|
80281
80281
|
}
|
|
80282
80282
|
};
|
|
80283
|
-
_proto.render = function
|
|
80283
|
+
_proto.render = function render15() {
|
|
80284
80284
|
var error = this.state.error;
|
|
80285
80285
|
var _this$props4 = this.props, fallbackRender = _this$props4.fallbackRender, FallbackComponent = _this$props4.FallbackComponent, fallback = _this$props4.fallback;
|
|
80286
80286
|
if (error !== null) {
|
|
@@ -101890,7 +101890,7 @@ var require_view = __commonJS({
|
|
|
101890
101890
|
}
|
|
101891
101891
|
return path39;
|
|
101892
101892
|
};
|
|
101893
|
-
View.prototype.render = function
|
|
101893
|
+
View.prototype.render = function render15(options6, callback) {
|
|
101894
101894
|
debug('render "%s"', this.path);
|
|
101895
101895
|
this.engine(this.path, options6, callback);
|
|
101896
101896
|
};
|
|
@@ -104763,7 +104763,7 @@ var require_application = __commonJS({
|
|
|
104763
104763
|
return this;
|
|
104764
104764
|
};
|
|
104765
104765
|
app.del = deprecate.function(app.delete, "app.del: Use app.delete instead");
|
|
104766
|
-
app.render = function
|
|
104766
|
+
app.render = function render15(name, options6, callback) {
|
|
104767
104767
|
var cache2 = this.cache;
|
|
104768
104768
|
var done = callback;
|
|
104769
104769
|
var engines = this.engines;
|
|
@@ -106262,7 +106262,7 @@ var require_response2 = __commonJS({
|
|
|
106262
106262
|
vary(this, field);
|
|
106263
106263
|
return this;
|
|
106264
106264
|
};
|
|
106265
|
-
res.render = function
|
|
106265
|
+
res.render = function render15(view, options6, callback) {
|
|
106266
106266
|
var app = this.req.app;
|
|
106267
106267
|
var done = callback;
|
|
106268
106268
|
var opts = options6 || {};
|
|
@@ -129321,10 +129321,10 @@ var require_Indicator = __commonJS({
|
|
|
129321
129321
|
"use strict";
|
|
129322
129322
|
init_import_meta_url();
|
|
129323
129323
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
129324
|
-
var
|
|
129324
|
+
var React18 = require_react();
|
|
129325
129325
|
var ink_1 = require_build2();
|
|
129326
129326
|
var figures = require_figures();
|
|
129327
|
-
var Indicator = ({ isSelected = false }) =>
|
|
129327
|
+
var Indicator = ({ isSelected = false }) => React18.createElement(ink_1.Box, { marginRight: 1 }, isSelected ? React18.createElement(ink_1.Text, { color: "blue" }, figures.pointer) : React18.createElement(ink_1.Text, null, " "));
|
|
129328
129328
|
exports2.default = Indicator;
|
|
129329
129329
|
}
|
|
129330
129330
|
});
|
|
@@ -129335,9 +129335,9 @@ var require_Item = __commonJS({
|
|
|
129335
129335
|
"use strict";
|
|
129336
129336
|
init_import_meta_url();
|
|
129337
129337
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
129338
|
-
var
|
|
129338
|
+
var React18 = require_react();
|
|
129339
129339
|
var ink_1 = require_build2();
|
|
129340
|
-
var Item = ({ isSelected = false, label }) =>
|
|
129340
|
+
var Item = ({ isSelected = false, label }) => React18.createElement(ink_1.Text, { color: isSelected ? "blue" : void 0 }, label);
|
|
129341
129341
|
exports2.default = Item;
|
|
129342
129342
|
}
|
|
129343
129343
|
});
|
|
@@ -129348,7 +129348,7 @@ var require_SelectInput = __commonJS({
|
|
|
129348
129348
|
"use strict";
|
|
129349
129349
|
init_import_meta_url();
|
|
129350
129350
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
129351
|
-
var
|
|
129351
|
+
var React18 = require_react();
|
|
129352
129352
|
var react_1 = require_react();
|
|
129353
129353
|
var isEqual = require_lodash2();
|
|
129354
129354
|
var arrayRotate = require_arr_rotate();
|
|
@@ -129410,14 +129410,14 @@ var require_SelectInput = __commonJS({
|
|
|
129410
129410
|
onHighlight
|
|
129411
129411
|
]), { isActive: isFocused });
|
|
129412
129412
|
const slicedItems = hasLimit ? arrayRotate(items, rotateIndex).slice(0, limit) : items;
|
|
129413
|
-
return
|
|
129413
|
+
return React18.createElement(ink_1.Box, { flexDirection: "column" }, slicedItems.map((item, index) => {
|
|
129414
129414
|
var _a2;
|
|
129415
129415
|
const isSelected = index === selectedIndex;
|
|
129416
|
-
return
|
|
129416
|
+
return React18.createElement(
|
|
129417
129417
|
ink_1.Box,
|
|
129418
129418
|
{ key: (_a2 = item.key) !== null && _a2 !== void 0 ? _a2 : item.value },
|
|
129419
|
-
|
|
129420
|
-
|
|
129419
|
+
React18.createElement(indicatorComponent, { isSelected }),
|
|
129420
|
+
React18.createElement(itemComponent, { ...item, isSelected })
|
|
129421
129421
|
);
|
|
129422
129422
|
}));
|
|
129423
129423
|
}
|
|
@@ -131277,7 +131277,7 @@ var require_build4 = __commonJS({
|
|
|
131277
131277
|
init_import_meta_url();
|
|
131278
131278
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
131279
131279
|
exports2.UncontrolledTextInput = void 0;
|
|
131280
|
-
var
|
|
131280
|
+
var React18 = require_react();
|
|
131281
131281
|
var react_1 = require_react();
|
|
131282
131282
|
var ink_1 = require_build2();
|
|
131283
131283
|
var chalk7 = require_source2();
|
|
@@ -131368,12 +131368,12 @@ var require_build4 = __commonJS({
|
|
|
131368
131368
|
onChange(nextValue);
|
|
131369
131369
|
}
|
|
131370
131370
|
}, { isActive: focus });
|
|
131371
|
-
return
|
|
131371
|
+
return React18.createElement(ink_1.Text, null, placeholder ? value.length > 0 ? renderedValue : renderedPlaceholder : renderedValue);
|
|
131372
131372
|
};
|
|
131373
131373
|
exports2.default = TextInput2;
|
|
131374
131374
|
exports2.UncontrolledTextInput = ({ initialValue = "", ...props }) => {
|
|
131375
131375
|
const [value, setValue2] = react_1.useState(initialValue);
|
|
131376
|
-
return
|
|
131376
|
+
return React18.createElement(TextInput2, Object.assign({}, props, { value, onChange: setValue2 }));
|
|
131377
131377
|
};
|
|
131378
131378
|
}
|
|
131379
131379
|
});
|
|
@@ -131569,14 +131569,14 @@ var require_realtime2 = __commonJS({
|
|
|
131569
131569
|
Object.keys(TIMER_POOL).forEach(clear);
|
|
131570
131570
|
}
|
|
131571
131571
|
exports2.cancel = cancel;
|
|
131572
|
-
function
|
|
131572
|
+
function render15(nodes, locale, opts) {
|
|
131573
131573
|
var nodeList = nodes.length ? nodes : [nodes];
|
|
131574
131574
|
nodeList.forEach(function(node) {
|
|
131575
131575
|
run2(node, dom_1.getDateAttribute(node), register_1.getLocale(locale), opts || {});
|
|
131576
131576
|
});
|
|
131577
131577
|
return nodeList;
|
|
131578
131578
|
}
|
|
131579
|
-
exports2.render =
|
|
131579
|
+
exports2.render = render15;
|
|
131580
131580
|
}
|
|
131581
131581
|
});
|
|
131582
131582
|
|
|
@@ -133048,7 +133048,7 @@ var require_build5 = __commonJS({
|
|
|
133048
133048
|
"use strict";
|
|
133049
133049
|
init_import_meta_url();
|
|
133050
133050
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
133051
|
-
var
|
|
133051
|
+
var React18 = require_react();
|
|
133052
133052
|
var react_1 = require_react();
|
|
133053
133053
|
var ink_1 = require_build2();
|
|
133054
133054
|
var spinners = require_cli_spinners();
|
|
@@ -133066,7 +133066,7 @@ var require_build5 = __commonJS({
|
|
|
133066
133066
|
clearInterval(timer);
|
|
133067
133067
|
};
|
|
133068
133068
|
}, [spinner]);
|
|
133069
|
-
return
|
|
133069
|
+
return React18.createElement(ink_1.Text, null, spinner.frames[frame]);
|
|
133070
133070
|
};
|
|
133071
133071
|
exports2.default = Spinner2;
|
|
133072
133072
|
}
|
|
@@ -136811,8 +136811,8 @@ async function getPorts(options6) {
|
|
|
136811
136811
|
}
|
|
136812
136812
|
|
|
136813
136813
|
// src/dev.tsx
|
|
136814
|
-
var
|
|
136815
|
-
var
|
|
136814
|
+
var import_ink17 = __toESM(require_build2());
|
|
136815
|
+
var import_react21 = __toESM(require_react());
|
|
136816
136816
|
|
|
136817
136817
|
// src/config/index.ts
|
|
136818
136818
|
init_import_meta_url();
|
|
@@ -141159,7 +141159,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
|
|
|
141159
141159
|
var wrapper_default = import_websocket.default;
|
|
141160
141160
|
|
|
141161
141161
|
// package.json
|
|
141162
|
-
var version = "2.
|
|
141162
|
+
var version = "2.3.1";
|
|
141163
141163
|
var package_default = {
|
|
141164
141164
|
name: "wrangler",
|
|
141165
141165
|
version,
|
|
@@ -147432,7 +147432,7 @@ async function getMetricsDispatcher(options6) {
|
|
|
147432
147432
|
}
|
|
147433
147433
|
};
|
|
147434
147434
|
async function dispatch(event) {
|
|
147435
|
-
if (
|
|
147435
|
+
if (false) {
|
|
147436
147436
|
logger.debug(
|
|
147437
147437
|
"Metrics dispatcher: Source Key not provided. Be sure to initialize before sending events.",
|
|
147438
147438
|
event
|
|
@@ -147465,7 +147465,7 @@ async function getMetricsDispatcher(options6) {
|
|
|
147465
147465
|
headers: {
|
|
147466
147466
|
Accept: "*/*",
|
|
147467
147467
|
"Content-Type": "application/json",
|
|
147468
|
-
"Sparrow-Source-Key":
|
|
147468
|
+
"Sparrow-Source-Key": "50598e014ed44c739ec8074fdc16057c"
|
|
147469
147469
|
},
|
|
147470
147470
|
mode: "cors",
|
|
147471
147471
|
keepalive: true,
|
|
@@ -157234,6 +157234,16 @@ var CLEANUP = () => {
|
|
|
157234
157234
|
RUNNING_BUILDERS.forEach((builder) => builder.stop?.());
|
|
157235
157235
|
};
|
|
157236
157236
|
var pagesBetaWarning = "\u{1F6A7} 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose";
|
|
157237
|
+
function isUrl(maybeUrl) {
|
|
157238
|
+
if (!maybeUrl)
|
|
157239
|
+
return false;
|
|
157240
|
+
try {
|
|
157241
|
+
new URL(maybeUrl);
|
|
157242
|
+
return true;
|
|
157243
|
+
} catch (e2) {
|
|
157244
|
+
return false;
|
|
157245
|
+
}
|
|
157246
|
+
}
|
|
157237
157247
|
|
|
157238
157248
|
// src/pages/build.tsx
|
|
157239
157249
|
function Options5(yargs) {
|
|
@@ -157439,13 +157449,246 @@ async function buildFunctions({
|
|
|
157439
157449
|
}
|
|
157440
157450
|
}
|
|
157441
157451
|
|
|
157442
|
-
// src/pages/
|
|
157452
|
+
// src/pages/deployment-tails.tsx
|
|
157453
|
+
init_import_meta_url();
|
|
157454
|
+
var import_promises14 = require("node:timers/promises");
|
|
157455
|
+
var import_signal_exit5 = __toESM(require_signal_exit());
|
|
157456
|
+
|
|
157457
|
+
// src/tail/createTail.ts
|
|
157458
|
+
init_import_meta_url();
|
|
157459
|
+
|
|
157460
|
+
// src/tail/filters.ts
|
|
157461
|
+
init_import_meta_url();
|
|
157462
|
+
function translateCLICommandToFilterMessage(cliFilters) {
|
|
157463
|
+
const apiFilters = [];
|
|
157464
|
+
if (cliFilters.samplingRate) {
|
|
157465
|
+
apiFilters.push(parseSamplingRate(cliFilters.samplingRate));
|
|
157466
|
+
}
|
|
157467
|
+
if (cliFilters.status) {
|
|
157468
|
+
apiFilters.push(parseOutcome(cliFilters.status));
|
|
157469
|
+
}
|
|
157470
|
+
if (cliFilters.method) {
|
|
157471
|
+
apiFilters.push(parseMethod(cliFilters.method));
|
|
157472
|
+
}
|
|
157473
|
+
if (cliFilters.header) {
|
|
157474
|
+
apiFilters.push(parseHeader(cliFilters.header));
|
|
157475
|
+
}
|
|
157476
|
+
if (cliFilters.clientIp) {
|
|
157477
|
+
apiFilters.push(parseIP(cliFilters.clientIp));
|
|
157478
|
+
}
|
|
157479
|
+
if (cliFilters.search) {
|
|
157480
|
+
apiFilters.push(parseQuery(cliFilters.search));
|
|
157481
|
+
}
|
|
157482
|
+
return {
|
|
157483
|
+
filters: apiFilters
|
|
157484
|
+
};
|
|
157485
|
+
}
|
|
157486
|
+
function parseSamplingRate(sampling_rate) {
|
|
157487
|
+
if (sampling_rate <= 0 || sampling_rate >= 1) {
|
|
157488
|
+
throw new Error(
|
|
157489
|
+
"A sampling rate must be between 0 and 1 in order to have any effect.\nFor example, a sampling rate of 0.25 means 25% of events will be logged."
|
|
157490
|
+
);
|
|
157491
|
+
}
|
|
157492
|
+
return { sampling_rate };
|
|
157493
|
+
}
|
|
157494
|
+
function parseOutcome(statuses) {
|
|
157495
|
+
const outcomes = /* @__PURE__ */ new Set();
|
|
157496
|
+
for (const status of statuses) {
|
|
157497
|
+
switch (status) {
|
|
157498
|
+
case "ok":
|
|
157499
|
+
outcomes.add("ok");
|
|
157500
|
+
break;
|
|
157501
|
+
case "canceled":
|
|
157502
|
+
outcomes.add("canceled");
|
|
157503
|
+
break;
|
|
157504
|
+
case "error":
|
|
157505
|
+
outcomes.add("exception");
|
|
157506
|
+
outcomes.add("exceededCpu");
|
|
157507
|
+
outcomes.add("exceededMemory");
|
|
157508
|
+
outcomes.add("unknown");
|
|
157509
|
+
break;
|
|
157510
|
+
default:
|
|
157511
|
+
break;
|
|
157512
|
+
}
|
|
157513
|
+
}
|
|
157514
|
+
return {
|
|
157515
|
+
outcome: Array.from(outcomes)
|
|
157516
|
+
};
|
|
157517
|
+
}
|
|
157518
|
+
function parseMethod(method) {
|
|
157519
|
+
return { method };
|
|
157520
|
+
}
|
|
157521
|
+
function parseHeader(header) {
|
|
157522
|
+
const [headerKey, headerQuery] = header.split(":", 2);
|
|
157523
|
+
return {
|
|
157524
|
+
header: {
|
|
157525
|
+
key: headerKey.trim(),
|
|
157526
|
+
query: headerQuery?.trim()
|
|
157527
|
+
}
|
|
157528
|
+
};
|
|
157529
|
+
}
|
|
157530
|
+
function parseIP(client_ip) {
|
|
157531
|
+
return { client_ip };
|
|
157532
|
+
}
|
|
157533
|
+
function parseQuery(query) {
|
|
157534
|
+
return { query };
|
|
157535
|
+
}
|
|
157536
|
+
|
|
157537
|
+
// src/tail/printing.ts
|
|
157538
|
+
init_import_meta_url();
|
|
157539
|
+
function prettyPrintLogs(data) {
|
|
157540
|
+
const eventMessage = JSON.parse(data.toString());
|
|
157541
|
+
if (isScheduledEvent(eventMessage.event)) {
|
|
157542
|
+
const cronPattern = eventMessage.event.cron;
|
|
157543
|
+
const datetime = new Date(
|
|
157544
|
+
eventMessage.event.scheduledTime
|
|
157545
|
+
).toLocaleString();
|
|
157546
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
157547
|
+
logger.log(`"${cronPattern}" @ ${datetime} - ${outcome}`);
|
|
157548
|
+
} else if (isRequestEvent(eventMessage.event)) {
|
|
157549
|
+
const requestMethod = eventMessage.event?.request.method.toUpperCase();
|
|
157550
|
+
const url3 = eventMessage.event?.request.url;
|
|
157551
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
157552
|
+
const datetime = new Date(eventMessage.eventTimestamp).toLocaleString();
|
|
157553
|
+
logger.log(
|
|
157554
|
+
url3 ? `${requestMethod} ${url3} - ${outcome} @ ${datetime}` : `[missing request] - ${outcome} @ ${datetime}`
|
|
157555
|
+
);
|
|
157556
|
+
} else if (isAlarmEvent(eventMessage.event)) {
|
|
157557
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
157558
|
+
const datetime = new Date(
|
|
157559
|
+
eventMessage.event.scheduledTime
|
|
157560
|
+
).toLocaleString();
|
|
157561
|
+
logger.log(`Alarm @ ${datetime} - ${outcome}`);
|
|
157562
|
+
} else {
|
|
157563
|
+
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
157564
|
+
const datetime = new Date(eventMessage.eventTimestamp).toLocaleString();
|
|
157565
|
+
logger.log(`Unknown Event - ${outcome} @ ${datetime}`);
|
|
157566
|
+
}
|
|
157567
|
+
if (eventMessage.logs.length > 0) {
|
|
157568
|
+
eventMessage.logs.forEach(({ level, message }) => {
|
|
157569
|
+
logger.log(` (${level})`, ...message);
|
|
157570
|
+
});
|
|
157571
|
+
}
|
|
157572
|
+
if (eventMessage.exceptions.length > 0) {
|
|
157573
|
+
eventMessage.exceptions.forEach(({ name, message }) => {
|
|
157574
|
+
logger.error(` ${name}:`, message);
|
|
157575
|
+
});
|
|
157576
|
+
}
|
|
157577
|
+
}
|
|
157578
|
+
function jsonPrintLogs(data) {
|
|
157579
|
+
console.log(JSON.stringify(JSON.parse(data.toString()), null, 2));
|
|
157580
|
+
}
|
|
157581
|
+
function isRequestEvent(event) {
|
|
157582
|
+
return Boolean(event && "request" in event);
|
|
157583
|
+
}
|
|
157584
|
+
function isScheduledEvent(event) {
|
|
157585
|
+
return Boolean(event && "cron" in event);
|
|
157586
|
+
}
|
|
157587
|
+
function isAlarmEvent(event) {
|
|
157588
|
+
return Boolean(event && "scheduledTime" in event && !("cron" in event));
|
|
157589
|
+
}
|
|
157590
|
+
function prettifyOutcome(outcome) {
|
|
157591
|
+
switch (outcome) {
|
|
157592
|
+
case "ok":
|
|
157593
|
+
return "Ok";
|
|
157594
|
+
case "canceled":
|
|
157595
|
+
return "Canceled";
|
|
157596
|
+
case "exceededCpu":
|
|
157597
|
+
return "Exceeded CPU Limit";
|
|
157598
|
+
case "exceededMemory":
|
|
157599
|
+
return "Exceeded Memory Limit";
|
|
157600
|
+
case "exception":
|
|
157601
|
+
return "Exception Thrown";
|
|
157602
|
+
case "unknown":
|
|
157603
|
+
default:
|
|
157604
|
+
return "Unknown";
|
|
157605
|
+
}
|
|
157606
|
+
}
|
|
157607
|
+
|
|
157608
|
+
// src/tail/createTail.ts
|
|
157609
|
+
var TRACE_VERSION = "trace-v1";
|
|
157610
|
+
function makeCreateTailUrl(accountId, workerName, env5) {
|
|
157611
|
+
return env5 ? `/accounts/${accountId}/workers/services/${workerName}/environments/${env5}/tails` : `/accounts/${accountId}/workers/scripts/${workerName}/tails`;
|
|
157612
|
+
}
|
|
157613
|
+
function makeDeleteTailUrl(accountId, workerName, tailId, env5) {
|
|
157614
|
+
return env5 ? `/accounts/${accountId}/workers/services/${workerName}/environments/${env5}/tails/${tailId}` : `/accounts/${accountId}/workers/scripts/${workerName}/tails/${tailId}`;
|
|
157615
|
+
}
|
|
157616
|
+
async function createPagesTail({
|
|
157617
|
+
accountId,
|
|
157618
|
+
projectName,
|
|
157619
|
+
deploymentId,
|
|
157620
|
+
filters,
|
|
157621
|
+
debug = false
|
|
157622
|
+
}) {
|
|
157623
|
+
const tailRecord = await fetchResult(
|
|
157624
|
+
`/accounts/${accountId}/pages/projects/${projectName}/deployments/${deploymentId}/tails`,
|
|
157625
|
+
{
|
|
157626
|
+
method: "POST",
|
|
157627
|
+
body: JSON.stringify(filters)
|
|
157628
|
+
}
|
|
157629
|
+
);
|
|
157630
|
+
const deleteTail = async () => fetchResult(
|
|
157631
|
+
`/accounts/${accountId}/pages/projects/${projectName}/deployments/${deploymentId}/tails/${tailRecord.id}`,
|
|
157632
|
+
{ method: "DELETE" }
|
|
157633
|
+
);
|
|
157634
|
+
const tail = new wrapper_default(tailRecord.url, TRACE_VERSION, {
|
|
157635
|
+
headers: {
|
|
157636
|
+
"Sec-WebSocket-Protocol": TRACE_VERSION,
|
|
157637
|
+
"User-Agent": `wrangler-js/${version}`
|
|
157638
|
+
}
|
|
157639
|
+
});
|
|
157640
|
+
tail.on("open", () => {
|
|
157641
|
+
tail.send(
|
|
157642
|
+
JSON.stringify({ debug }),
|
|
157643
|
+
{ binary: false, compress: false, mask: false, fin: true },
|
|
157644
|
+
(err2) => {
|
|
157645
|
+
if (err2) {
|
|
157646
|
+
throw err2;
|
|
157647
|
+
}
|
|
157648
|
+
}
|
|
157649
|
+
);
|
|
157650
|
+
});
|
|
157651
|
+
return { tail, deleteTail, expiration: tailRecord.expires_at };
|
|
157652
|
+
}
|
|
157653
|
+
async function createTail(accountId, workerName, filters, debug, env5) {
|
|
157654
|
+
const createTailUrl = makeCreateTailUrl(accountId, workerName, env5);
|
|
157655
|
+
const {
|
|
157656
|
+
id: tailId,
|
|
157657
|
+
url: websocketUrl,
|
|
157658
|
+
expires_at: expiration
|
|
157659
|
+
} = await fetchResult(createTailUrl, {
|
|
157660
|
+
method: "POST",
|
|
157661
|
+
body: JSON.stringify(filters)
|
|
157662
|
+
});
|
|
157663
|
+
const deleteUrl = makeDeleteTailUrl(accountId, workerName, tailId, env5);
|
|
157664
|
+
async function deleteTail() {
|
|
157665
|
+
await fetchResult(deleteUrl, { method: "DELETE" });
|
|
157666
|
+
}
|
|
157667
|
+
const tail = new wrapper_default(websocketUrl, TRACE_VERSION, {
|
|
157668
|
+
headers: {
|
|
157669
|
+
"Sec-WebSocket-Protocol": TRACE_VERSION,
|
|
157670
|
+
"User-Agent": `wrangler-js/${version}`
|
|
157671
|
+
}
|
|
157672
|
+
});
|
|
157673
|
+
tail.on("open", function() {
|
|
157674
|
+
tail.send(
|
|
157675
|
+
JSON.stringify({ debug }),
|
|
157676
|
+
{ binary: false, compress: false, mask: false, fin: true },
|
|
157677
|
+
(err2) => {
|
|
157678
|
+
if (err2) {
|
|
157679
|
+
throw err2;
|
|
157680
|
+
}
|
|
157681
|
+
}
|
|
157682
|
+
);
|
|
157683
|
+
});
|
|
157684
|
+
return { tail, expiration, deleteTail };
|
|
157685
|
+
}
|
|
157686
|
+
|
|
157687
|
+
// src/pages/prompt-select-project.tsx
|
|
157443
157688
|
init_import_meta_url();
|
|
157444
157689
|
var import_ink12 = __toESM(require_build2());
|
|
157445
157690
|
var import_ink_select_input3 = __toESM(require_build3());
|
|
157446
|
-
var import_ink_table7 = __toESM(require_dist2());
|
|
157447
157691
|
var import_react16 = __toESM(require_react());
|
|
157448
|
-
var import_timeago2 = __toESM(require_lib6());
|
|
157449
157692
|
|
|
157450
157693
|
// src/pages/projects.tsx
|
|
157451
157694
|
init_import_meta_url();
|
|
@@ -157575,7 +157818,233 @@ async function CreateHandler3({
|
|
|
157575
157818
|
await sendMetricsEvent("create pages project");
|
|
157576
157819
|
}
|
|
157577
157820
|
|
|
157821
|
+
// src/pages/prompt-select-project.tsx
|
|
157822
|
+
async function promptSelectProject({
|
|
157823
|
+
accountId
|
|
157824
|
+
}) {
|
|
157825
|
+
const projects = await listProjects({ accountId });
|
|
157826
|
+
return new Promise((resolve15) => {
|
|
157827
|
+
const { unmount } = (0, import_ink12.render)(
|
|
157828
|
+
/* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, /* @__PURE__ */ import_react16.default.createElement(import_ink12.Text, null, "Select a project:"), /* @__PURE__ */ import_react16.default.createElement(import_ink_select_input3.default, {
|
|
157829
|
+
items: projects.map((project) => ({
|
|
157830
|
+
key: project.name,
|
|
157831
|
+
label: project.name,
|
|
157832
|
+
value: project
|
|
157833
|
+
})),
|
|
157834
|
+
onSelect: async (selected) => {
|
|
157835
|
+
resolve15(selected.value.name);
|
|
157836
|
+
unmount();
|
|
157837
|
+
}
|
|
157838
|
+
}))
|
|
157839
|
+
);
|
|
157840
|
+
});
|
|
157841
|
+
}
|
|
157842
|
+
|
|
157843
|
+
// src/pages/deployment-tails.tsx
|
|
157844
|
+
var statusChoices = ["ok", "error", "canceled"];
|
|
157845
|
+
var isStatusChoiceList = (data) => data?.every((d) => statusChoices.includes(d)) ?? false;
|
|
157846
|
+
function Options6(yargs) {
|
|
157847
|
+
return yargs.positional("deployment", {
|
|
157848
|
+
type: "string",
|
|
157849
|
+
description: "(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown."
|
|
157850
|
+
}).options({
|
|
157851
|
+
"project-name": {
|
|
157852
|
+
type: "string",
|
|
157853
|
+
description: "The name of the project you would like to tail"
|
|
157854
|
+
},
|
|
157855
|
+
environment: {
|
|
157856
|
+
type: "string",
|
|
157857
|
+
choices: ["production", "preview"],
|
|
157858
|
+
default: "production",
|
|
157859
|
+
description: "When not providing a specific deployment ID, specifying environment will grab the latest production or preview deployment"
|
|
157860
|
+
}
|
|
157861
|
+
}).option("format", {
|
|
157862
|
+
default: process.stdout.isTTY ? "pretty" : "json",
|
|
157863
|
+
choices: ["json", "pretty"],
|
|
157864
|
+
describe: "The format of log entries"
|
|
157865
|
+
}).option("debug", {
|
|
157866
|
+
type: "boolean",
|
|
157867
|
+
hidden: true,
|
|
157868
|
+
default: false,
|
|
157869
|
+
describe: "If a log would have been filtered out, send it through anyway alongside the filter which would have blocked it."
|
|
157870
|
+
}).option("status", {
|
|
157871
|
+
choices: statusChoices,
|
|
157872
|
+
describe: "Filter by invocation status",
|
|
157873
|
+
array: true
|
|
157874
|
+
}).option("header", {
|
|
157875
|
+
type: "string",
|
|
157876
|
+
requiresArg: true,
|
|
157877
|
+
describe: "Filter by HTTP header"
|
|
157878
|
+
}).option("method", {
|
|
157879
|
+
type: "string",
|
|
157880
|
+
requiresArg: true,
|
|
157881
|
+
describe: "Filter by HTTP method",
|
|
157882
|
+
array: true
|
|
157883
|
+
}).option("search", {
|
|
157884
|
+
type: "string",
|
|
157885
|
+
requiresArg: true,
|
|
157886
|
+
describe: "Filter by a text match in console.log messages"
|
|
157887
|
+
}).option("sampling-rate", {
|
|
157888
|
+
type: "number",
|
|
157889
|
+
describe: "Adds a percentage of requests to log sampling rate"
|
|
157890
|
+
}).option("ip", {
|
|
157891
|
+
type: "string",
|
|
157892
|
+
requiresArg: true,
|
|
157893
|
+
describe: 'Filter by the IP address the request originates from. Use "self" to filter for your own IP',
|
|
157894
|
+
array: true
|
|
157895
|
+
});
|
|
157896
|
+
}
|
|
157897
|
+
async function Handler6({
|
|
157898
|
+
deployment,
|
|
157899
|
+
projectName,
|
|
157900
|
+
environment,
|
|
157901
|
+
header,
|
|
157902
|
+
ip: clientIp,
|
|
157903
|
+
method,
|
|
157904
|
+
samplingRate,
|
|
157905
|
+
search,
|
|
157906
|
+
status,
|
|
157907
|
+
format: format6 = "pretty",
|
|
157908
|
+
debug,
|
|
157909
|
+
...args
|
|
157910
|
+
}) {
|
|
157911
|
+
if (status && !isStatusChoiceList(status)) {
|
|
157912
|
+
throw new FatalError(
|
|
157913
|
+
"Invalid value for `--status`. Valid options: " + statusChoices.join(", ")
|
|
157914
|
+
);
|
|
157915
|
+
}
|
|
157916
|
+
if (format6 === "pretty") {
|
|
157917
|
+
await printWranglerBanner();
|
|
157918
|
+
}
|
|
157919
|
+
const config = readConfig(args.config, args);
|
|
157920
|
+
const pagesConfig = getConfigCache(
|
|
157921
|
+
PAGES_CONFIG_CACHE_FILENAME
|
|
157922
|
+
);
|
|
157923
|
+
const accountId = await requireAuth(pagesConfig);
|
|
157924
|
+
let deploymentId = deployment;
|
|
157925
|
+
if (!isInteractive()) {
|
|
157926
|
+
if (!deploymentId) {
|
|
157927
|
+
throw new FatalError(
|
|
157928
|
+
"Must specify a deployment in non-interactive mode.",
|
|
157929
|
+
1
|
|
157930
|
+
);
|
|
157931
|
+
}
|
|
157932
|
+
if (!projectName) {
|
|
157933
|
+
throw new FatalError(
|
|
157934
|
+
"Must specify a project name in non-interactive mode.",
|
|
157935
|
+
1
|
|
157936
|
+
);
|
|
157937
|
+
}
|
|
157938
|
+
}
|
|
157939
|
+
if (!projectName && isInteractive()) {
|
|
157940
|
+
projectName = await promptSelectProject({ accountId });
|
|
157941
|
+
}
|
|
157942
|
+
if (!deployment && !projectName) {
|
|
157943
|
+
throw new FatalError("Must specify a project name or deployment.", 1);
|
|
157944
|
+
}
|
|
157945
|
+
const deployments2 = await fetchResult(
|
|
157946
|
+
`/accounts/${accountId}/pages/projects/${projectName}/deployments`
|
|
157947
|
+
);
|
|
157948
|
+
const envDeployments = deployments2.filter(
|
|
157949
|
+
(d) => d.environment === environment
|
|
157950
|
+
);
|
|
157951
|
+
if (isUrl(deployment)) {
|
|
157952
|
+
const { hostname: deploymentHostname } = new URL(deployment);
|
|
157953
|
+
const targetDeployment = envDeployments.find(
|
|
157954
|
+
(d) => new URL(d.url).hostname === deploymentHostname
|
|
157955
|
+
);
|
|
157956
|
+
if (!targetDeployment) {
|
|
157957
|
+
throw new FatalError(
|
|
157958
|
+
"Could not find deployment match url: " + deployment,
|
|
157959
|
+
1
|
|
157960
|
+
);
|
|
157961
|
+
}
|
|
157962
|
+
deploymentId = targetDeployment.id;
|
|
157963
|
+
} else if (!deployment) {
|
|
157964
|
+
if (envDeployments.length === 0) {
|
|
157965
|
+
throw new FatalError("No deployments for environment: " + environment, 1);
|
|
157966
|
+
}
|
|
157967
|
+
if (format6 === "pretty") {
|
|
157968
|
+
logger.log(
|
|
157969
|
+
"No deployment specified. Using latest deployment for",
|
|
157970
|
+
environment,
|
|
157971
|
+
"environment."
|
|
157972
|
+
);
|
|
157973
|
+
}
|
|
157974
|
+
const latestDeployment = envDeployments.map((d) => ({ id: d.id, created_on: new Date(d.created_on) })).sort((a, b) => +b.created_on - +a.created_on)[0];
|
|
157975
|
+
deploymentId = latestDeployment.id;
|
|
157976
|
+
}
|
|
157977
|
+
if (!deploymentId || !projectName) {
|
|
157978
|
+
throw new FatalError("An unknown error occurred.", 1);
|
|
157979
|
+
}
|
|
157980
|
+
const filters = translateCLICommandToFilterMessage({
|
|
157981
|
+
header,
|
|
157982
|
+
clientIp,
|
|
157983
|
+
method,
|
|
157984
|
+
samplingRate,
|
|
157985
|
+
search,
|
|
157986
|
+
status
|
|
157987
|
+
});
|
|
157988
|
+
await sendMetricsEvent("begin pages log stream", {
|
|
157989
|
+
sendMetrics: config.send_metrics
|
|
157990
|
+
});
|
|
157991
|
+
const { tail, deleteTail } = await createPagesTail({
|
|
157992
|
+
accountId,
|
|
157993
|
+
projectName,
|
|
157994
|
+
deploymentId,
|
|
157995
|
+
filters,
|
|
157996
|
+
debug
|
|
157997
|
+
});
|
|
157998
|
+
const onCloseTail = (() => {
|
|
157999
|
+
let didTerminate = false;
|
|
158000
|
+
return async () => {
|
|
158001
|
+
if (didTerminate)
|
|
158002
|
+
return;
|
|
158003
|
+
tail.terminate();
|
|
158004
|
+
await deleteTail();
|
|
158005
|
+
await sendMetricsEvent("end pages log stream", {
|
|
158006
|
+
sendMetrics: config.send_metrics
|
|
158007
|
+
});
|
|
158008
|
+
didTerminate = true;
|
|
158009
|
+
};
|
|
158010
|
+
})();
|
|
158011
|
+
(0, import_signal_exit5.default)(onCloseTail);
|
|
158012
|
+
tail.on("message", (data) => {
|
|
158013
|
+
if (format6 === "pretty") {
|
|
158014
|
+
prettyPrintLogs(data);
|
|
158015
|
+
} else {
|
|
158016
|
+
jsonPrintLogs(data);
|
|
158017
|
+
}
|
|
158018
|
+
});
|
|
158019
|
+
tail.on("close", onCloseTail);
|
|
158020
|
+
while (tail.readyState !== tail.OPEN) {
|
|
158021
|
+
switch (tail.readyState) {
|
|
158022
|
+
case tail.CONNECTING:
|
|
158023
|
+
await (0, import_promises14.setTimeout)(100);
|
|
158024
|
+
break;
|
|
158025
|
+
case tail.CLOSING:
|
|
158026
|
+
await (0, import_promises14.setTimeout)(100);
|
|
158027
|
+
break;
|
|
158028
|
+
case tail.CLOSED:
|
|
158029
|
+
await sendMetricsEvent("end log stream", {
|
|
158030
|
+
sendMetrics: config.send_metrics
|
|
158031
|
+
});
|
|
158032
|
+
throw new Error(
|
|
158033
|
+
`Connection to deployment ${deploymentId} closed unexpectedly.`
|
|
158034
|
+
);
|
|
158035
|
+
}
|
|
158036
|
+
}
|
|
158037
|
+
if (format6 === "pretty") {
|
|
158038
|
+
logger.log(`Connected to deployment ${deploymentId}, waiting for logs...`);
|
|
158039
|
+
}
|
|
158040
|
+
}
|
|
158041
|
+
|
|
157578
158042
|
// src/pages/deployments.tsx
|
|
158043
|
+
init_import_meta_url();
|
|
158044
|
+
var import_ink13 = __toESM(require_build2());
|
|
158045
|
+
var import_ink_table7 = __toESM(require_dist2());
|
|
158046
|
+
var import_react17 = __toESM(require_react());
|
|
158047
|
+
var import_timeago2 = __toESM(require_lib6());
|
|
157579
158048
|
function ListOptions4(yargs) {
|
|
157580
158049
|
return yargs.options({
|
|
157581
158050
|
"project-name": {
|
|
@@ -157590,22 +158059,7 @@ async function ListHandler4({ projectName }) {
|
|
|
157590
158059
|
projectName ??= config.project_name;
|
|
157591
158060
|
const isInteractive2 = process.stdin.isTTY;
|
|
157592
158061
|
if (!projectName && isInteractive2) {
|
|
157593
|
-
|
|
157594
|
-
projectName = await new Promise((resolve15) => {
|
|
157595
|
-
const { unmount: unmount2 } = (0, import_ink12.render)(
|
|
157596
|
-
/* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, /* @__PURE__ */ import_react16.default.createElement(import_ink12.Text, null, "Select a project:"), /* @__PURE__ */ import_react16.default.createElement(import_ink_select_input3.default, {
|
|
157597
|
-
items: projects.map((project) => ({
|
|
157598
|
-
key: project.name,
|
|
157599
|
-
label: project.name,
|
|
157600
|
-
value: project
|
|
157601
|
-
})),
|
|
157602
|
-
onSelect: async (selected) => {
|
|
157603
|
-
resolve15(selected.value.name);
|
|
157604
|
-
unmount2();
|
|
157605
|
-
}
|
|
157606
|
-
}))
|
|
157607
|
-
);
|
|
157608
|
-
});
|
|
158062
|
+
projectName = await promptSelectProject({ accountId });
|
|
157609
158063
|
}
|
|
157610
158064
|
if (!projectName) {
|
|
157611
158065
|
throw new FatalError("Must specify a project name.", 1);
|
|
@@ -157634,7 +158088,7 @@ async function ListHandler4({ projectName }) {
|
|
|
157634
158088
|
saveToConfigCache(PAGES_CONFIG_CACHE_FILENAME, {
|
|
157635
158089
|
account_id: accountId
|
|
157636
158090
|
});
|
|
157637
|
-
const { unmount } = (0,
|
|
158091
|
+
const { unmount } = (0, import_ink13.render)(/* @__PURE__ */ import_react17.default.createElement(import_ink_table7.default, {
|
|
157638
158092
|
data
|
|
157639
158093
|
}), {
|
|
157640
158094
|
patchConsole: false
|
|
@@ -157654,7 +158108,7 @@ var esbuild3 = __toESM(require("esbuild"));
|
|
|
157654
158108
|
var DURABLE_OBJECTS_BINDING_REGEXP = new RegExp(
|
|
157655
158109
|
/^(?<binding>[^=]+)=(?<className>[^@\s]+)(@(?<scriptName>.*)$)?$/
|
|
157656
158110
|
);
|
|
157657
|
-
function
|
|
158111
|
+
function Options7(yargs) {
|
|
157658
158112
|
return yargs.positional("directory", {
|
|
157659
158113
|
type: "string",
|
|
157660
158114
|
demandOption: void 0,
|
|
@@ -157766,7 +158220,7 @@ function Options6(yargs) {
|
|
|
157766
158220
|
}
|
|
157767
158221
|
}).epilogue(pagesBetaWarning);
|
|
157768
158222
|
}
|
|
157769
|
-
var
|
|
158223
|
+
var Handler7 = async ({
|
|
157770
158224
|
local,
|
|
157771
158225
|
directory,
|
|
157772
158226
|
"compatibility-date": compatibilityDate,
|
|
@@ -158271,16 +158725,16 @@ var import_node_fs19 = require("node:fs");
|
|
|
158271
158725
|
var import_node_os13 = require("node:os");
|
|
158272
158726
|
var import_node_path34 = require("node:path");
|
|
158273
158727
|
var import_node_process7 = require("node:process");
|
|
158274
|
-
var
|
|
158728
|
+
var import_ink15 = __toESM(require_build2());
|
|
158275
158729
|
var import_ink_select_input4 = __toESM(require_build3());
|
|
158276
|
-
var
|
|
158730
|
+
var import_react19 = __toESM(require_react());
|
|
158277
158731
|
var import_undici10 = __toESM(require_undici());
|
|
158278
158732
|
|
|
158279
158733
|
// src/pages/upload.tsx
|
|
158280
158734
|
init_import_meta_url();
|
|
158281
|
-
var
|
|
158735
|
+
var import_promises15 = require("node:fs/promises");
|
|
158282
158736
|
var import_node_path33 = require("node:path");
|
|
158283
|
-
var
|
|
158737
|
+
var import_ink14 = __toESM(require_build2());
|
|
158284
158738
|
var import_ink_spinner = __toESM(require_build5());
|
|
158285
158739
|
var import_mime = __toESM(require_mime2());
|
|
158286
158740
|
var import_minimatch = __toESM(require_minimatch2());
|
|
@@ -158704,7 +159158,7 @@ _PQueue_carryoverConcurrencyCount = /* @__PURE__ */ new WeakMap(), _PQueue_isInt
|
|
|
158704
159158
|
};
|
|
158705
159159
|
|
|
158706
159160
|
// src/pages/upload.tsx
|
|
158707
|
-
var
|
|
159161
|
+
var import_react18 = __toESM(require_react());
|
|
158708
159162
|
|
|
158709
159163
|
// src/pages/hash.tsx
|
|
158710
159164
|
init_import_meta_url();
|
|
@@ -158719,7 +159173,7 @@ var hashFile = (filepath) => {
|
|
|
158719
159173
|
};
|
|
158720
159174
|
|
|
158721
159175
|
// src/pages/upload.tsx
|
|
158722
|
-
function
|
|
159176
|
+
function Options8(yargs) {
|
|
158723
159177
|
return yargs.positional("directory", {
|
|
158724
159178
|
type: "string",
|
|
158725
159179
|
demandOption: true,
|
|
@@ -158731,7 +159185,7 @@ function Options7(yargs) {
|
|
|
158731
159185
|
}
|
|
158732
159186
|
}).epilogue(pagesBetaWarning);
|
|
158733
159187
|
}
|
|
158734
|
-
var
|
|
159188
|
+
var Handler8 = async ({
|
|
158735
159189
|
directory,
|
|
158736
159190
|
outputManifestPath
|
|
158737
159191
|
}) => {
|
|
@@ -158746,8 +159200,8 @@ var Handler7 = async ({
|
|
|
158746
159200
|
jwt: process.env.CF_PAGES_UPLOAD_JWT
|
|
158747
159201
|
});
|
|
158748
159202
|
if (outputManifestPath) {
|
|
158749
|
-
await (0,
|
|
158750
|
-
await (0,
|
|
159203
|
+
await (0, import_promises15.mkdir)((0, import_node_path33.dirname)(outputManifestPath), { recursive: true });
|
|
159204
|
+
await (0, import_promises15.writeFile)(outputManifestPath, JSON.stringify(manifest));
|
|
158751
159205
|
}
|
|
158752
159206
|
logger.log(`\u2728 Upload complete!`);
|
|
158753
159207
|
};
|
|
@@ -158773,12 +159227,12 @@ var upload = async (args) => {
|
|
|
158773
159227
|
].map((pattern) => new import_minimatch.Minimatch(pattern));
|
|
158774
159228
|
const directory = (0, import_node_path33.resolve)(args.directory);
|
|
158775
159229
|
const walk = async (dir, fileMap2 = /* @__PURE__ */ new Map(), startingDir = dir) => {
|
|
158776
|
-
const files2 = await (0,
|
|
159230
|
+
const files2 = await (0, import_promises15.readdir)(dir);
|
|
158777
159231
|
await Promise.all(
|
|
158778
159232
|
files2.map(async (file) => {
|
|
158779
159233
|
const filepath = (0, import_node_path33.join)(dir, file);
|
|
158780
159234
|
const relativeFilepath = (0, import_node_path33.relative)(startingDir, filepath);
|
|
158781
|
-
const filestat = await (0,
|
|
159235
|
+
const filestat = await (0, import_promises15.stat)(filepath);
|
|
158782
159236
|
for (const minimatch of IGNORE_LIST) {
|
|
158783
159237
|
if (minimatch.match(relativeFilepath)) {
|
|
158784
159238
|
return;
|
|
@@ -158875,8 +159329,8 @@ ${name} is ${prettyBytes(filestat.size)} in size`,
|
|
|
158875
159329
|
bucketOffset++;
|
|
158876
159330
|
}
|
|
158877
159331
|
let counter = fileMap.size - sortedFiles.length;
|
|
158878
|
-
const { rerender, unmount } = (0,
|
|
158879
|
-
/* @__PURE__ */
|
|
159332
|
+
const { rerender, unmount } = (0, import_ink14.render)(
|
|
159333
|
+
/* @__PURE__ */ import_react18.default.createElement(Progress, {
|
|
158880
159334
|
done: counter,
|
|
158881
159335
|
total: fileMap.size
|
|
158882
159336
|
})
|
|
@@ -158890,7 +159344,7 @@ ${name} is ${prettyBytes(filestat.size)} in size`,
|
|
|
158890
159344
|
const payload = await Promise.all(
|
|
158891
159345
|
bucket.files.map(async (file) => ({
|
|
158892
159346
|
key: file.hash,
|
|
158893
|
-
value: (await (0,
|
|
159347
|
+
value: (await (0, import_promises15.readFile)(file.path)).toString("base64"),
|
|
158894
159348
|
metadata: {
|
|
158895
159349
|
contentType: file.contentType
|
|
158896
159350
|
},
|
|
@@ -158924,7 +159378,7 @@ ${name} is ${prettyBytes(filestat.size)} in size`,
|
|
|
158924
159378
|
() => doUpload().then(
|
|
158925
159379
|
() => {
|
|
158926
159380
|
counter += bucket.files.length;
|
|
158927
|
-
rerender(/* @__PURE__ */
|
|
159381
|
+
rerender(/* @__PURE__ */ import_react18.default.createElement(Progress, {
|
|
158928
159382
|
done: counter,
|
|
158929
159383
|
total: fileMap.size
|
|
158930
159384
|
}));
|
|
@@ -159011,14 +159465,14 @@ function formatTime(duration) {
|
|
|
159011
159465
|
return `(${(duration / 1e3).toFixed(2)} sec)`;
|
|
159012
159466
|
}
|
|
159013
159467
|
function Progress({ done, total }) {
|
|
159014
|
-
return /* @__PURE__ */
|
|
159468
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_react18.default.Fragment, null, /* @__PURE__ */ import_react18.default.createElement(import_ink14.Text, null, isInteractive() ? /* @__PURE__ */ import_react18.default.createElement(import_ink_spinner.default, {
|
|
159015
159469
|
type: "earth"
|
|
159016
159470
|
}) : null, ` Uploading... (${done}/${total})
|
|
159017
159471
|
`));
|
|
159018
159472
|
}
|
|
159019
159473
|
|
|
159020
159474
|
// src/pages/publish.tsx
|
|
159021
|
-
function
|
|
159475
|
+
function Options9(yargs) {
|
|
159022
159476
|
return yargs.positional("directory", {
|
|
159023
159477
|
type: "string",
|
|
159024
159478
|
demandOption: true,
|
|
@@ -159051,7 +159505,7 @@ function Options8(yargs) {
|
|
|
159051
159505
|
}
|
|
159052
159506
|
}).epilogue(pagesBetaWarning);
|
|
159053
159507
|
}
|
|
159054
|
-
var
|
|
159508
|
+
var Handler9 = async ({
|
|
159055
159509
|
directory,
|
|
159056
159510
|
projectName,
|
|
159057
159511
|
branch,
|
|
@@ -159077,8 +159531,8 @@ var Handler8 = async ({
|
|
|
159077
159531
|
let existingOrNew = "new";
|
|
159078
159532
|
if (projects.length > 0) {
|
|
159079
159533
|
existingOrNew = await new Promise((resolve15) => {
|
|
159080
|
-
const { unmount } = (0,
|
|
159081
|
-
/* @__PURE__ */
|
|
159534
|
+
const { unmount } = (0, import_ink15.render)(
|
|
159535
|
+
/* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(import_ink15.Text, null, "No project selected. Would you like to create one or use an existing project?"), /* @__PURE__ */ import_react19.default.createElement(import_ink_select_input4.default, {
|
|
159082
159536
|
items: [
|
|
159083
159537
|
{
|
|
159084
159538
|
key: "new",
|
|
@@ -159101,21 +159555,7 @@ var Handler8 = async ({
|
|
|
159101
159555
|
}
|
|
159102
159556
|
switch (existingOrNew) {
|
|
159103
159557
|
case "existing": {
|
|
159104
|
-
projectName = await
|
|
159105
|
-
const { unmount } = (0, import_ink14.render)(
|
|
159106
|
-
/* @__PURE__ */ import_react18.default.createElement(import_react18.default.Fragment, null, /* @__PURE__ */ import_react18.default.createElement(import_ink14.Text, null, "Select a project:"), /* @__PURE__ */ import_react18.default.createElement(import_ink_select_input4.default, {
|
|
159107
|
-
items: projects.map((project2) => ({
|
|
159108
|
-
key: project2.name,
|
|
159109
|
-
label: project2.name,
|
|
159110
|
-
value: project2
|
|
159111
|
-
})),
|
|
159112
|
-
onSelect: async (selected) => {
|
|
159113
|
-
resolve15(selected.value.name);
|
|
159114
|
-
unmount();
|
|
159115
|
-
}
|
|
159116
|
-
}))
|
|
159117
|
-
);
|
|
159118
|
-
});
|
|
159558
|
+
projectName = await promptSelectProject({ accountId });
|
|
159119
159559
|
break;
|
|
159120
159560
|
}
|
|
159121
159561
|
case "new": {
|
|
@@ -159355,8 +159795,8 @@ var pages = (yargs) => {
|
|
|
159355
159795
|
return yargs.command(
|
|
159356
159796
|
"dev [directory] [-- command..]",
|
|
159357
159797
|
"\u{1F9D1}\u200D\u{1F4BB} Develop your full-stack Pages application locally",
|
|
159358
|
-
|
|
159359
|
-
|
|
159798
|
+
Options7,
|
|
159799
|
+
Handler7
|
|
159360
159800
|
).command(
|
|
159361
159801
|
"functions",
|
|
159362
159802
|
false,
|
|
@@ -159384,7 +159824,7 @@ var pages = (yargs) => {
|
|
|
159384
159824
|
"Create a new Cloudflare Pages project",
|
|
159385
159825
|
CreateOptions3,
|
|
159386
159826
|
CreateHandler3
|
|
159387
|
-
).command("upload [directory]", false,
|
|
159827
|
+
).command("upload [directory]", false, Options8, Handler8).epilogue(pagesBetaWarning)
|
|
159388
159828
|
).command(
|
|
159389
159829
|
"deployment",
|
|
159390
159830
|
"\u{1F680} Interact with the deployments of a project",
|
|
@@ -159396,14 +159836,19 @@ var pages = (yargs) => {
|
|
|
159396
159836
|
).command(
|
|
159397
159837
|
"create [directory]",
|
|
159398
159838
|
"\u{1F199} Publish a directory of static assets as a Pages deployment",
|
|
159399
|
-
|
|
159400
|
-
|
|
159839
|
+
Options9,
|
|
159840
|
+
Handler9
|
|
159841
|
+
).command(
|
|
159842
|
+
"tail [deployment]",
|
|
159843
|
+
"Start a tailing session for a project's deployment and livestream logs from your Functions",
|
|
159844
|
+
Options6,
|
|
159845
|
+
Handler6
|
|
159401
159846
|
).epilogue(pagesBetaWarning)
|
|
159402
159847
|
).command(
|
|
159403
159848
|
"publish [directory]",
|
|
159404
159849
|
"\u{1F199} Publish a directory of static assets as a Pages deployment",
|
|
159405
|
-
|
|
159406
|
-
|
|
159850
|
+
Options9,
|
|
159851
|
+
Handler9
|
|
159407
159852
|
).epilogue(pagesBetaWarning);
|
|
159408
159853
|
};
|
|
159409
159854
|
|
|
@@ -161878,202 +162323,8 @@ var secretBulkHandler = async (secretBulkArgs) => {
|
|
|
161878
162323
|
|
|
161879
162324
|
// src/tail/index.ts
|
|
161880
162325
|
init_import_meta_url();
|
|
161881
|
-
var
|
|
161882
|
-
var
|
|
161883
|
-
|
|
161884
|
-
// src/tail/createTail.ts
|
|
161885
|
-
init_import_meta_url();
|
|
161886
|
-
|
|
161887
|
-
// src/tail/filters.ts
|
|
161888
|
-
init_import_meta_url();
|
|
161889
|
-
function translateCLICommandToFilterMessage(cliFilters) {
|
|
161890
|
-
const apiFilters = [];
|
|
161891
|
-
if (cliFilters.samplingRate) {
|
|
161892
|
-
apiFilters.push(parseSamplingRate(cliFilters.samplingRate));
|
|
161893
|
-
}
|
|
161894
|
-
if (cliFilters.status) {
|
|
161895
|
-
apiFilters.push(parseOutcome(cliFilters.status));
|
|
161896
|
-
}
|
|
161897
|
-
if (cliFilters.method) {
|
|
161898
|
-
apiFilters.push(parseMethod(cliFilters.method));
|
|
161899
|
-
}
|
|
161900
|
-
if (cliFilters.header) {
|
|
161901
|
-
apiFilters.push(parseHeader(cliFilters.header));
|
|
161902
|
-
}
|
|
161903
|
-
if (cliFilters.clientIp) {
|
|
161904
|
-
apiFilters.push(parseIP(cliFilters.clientIp));
|
|
161905
|
-
}
|
|
161906
|
-
if (cliFilters.search) {
|
|
161907
|
-
apiFilters.push(parseQuery(cliFilters.search));
|
|
161908
|
-
}
|
|
161909
|
-
return {
|
|
161910
|
-
filters: apiFilters
|
|
161911
|
-
};
|
|
161912
|
-
}
|
|
161913
|
-
function parseSamplingRate(sampling_rate) {
|
|
161914
|
-
if (sampling_rate <= 0 || sampling_rate >= 1) {
|
|
161915
|
-
throw new Error(
|
|
161916
|
-
"A sampling rate must be between 0 and 1 in order to have any effect.\nFor example, a sampling rate of 0.25 means 25% of events will be logged."
|
|
161917
|
-
);
|
|
161918
|
-
}
|
|
161919
|
-
return { sampling_rate };
|
|
161920
|
-
}
|
|
161921
|
-
function parseOutcome(statuses) {
|
|
161922
|
-
const outcomes = /* @__PURE__ */ new Set();
|
|
161923
|
-
for (const status of statuses) {
|
|
161924
|
-
switch (status) {
|
|
161925
|
-
case "ok":
|
|
161926
|
-
outcomes.add("ok");
|
|
161927
|
-
break;
|
|
161928
|
-
case "canceled":
|
|
161929
|
-
outcomes.add("canceled");
|
|
161930
|
-
break;
|
|
161931
|
-
case "error":
|
|
161932
|
-
outcomes.add("exception");
|
|
161933
|
-
outcomes.add("exceededCpu");
|
|
161934
|
-
outcomes.add("exceededMemory");
|
|
161935
|
-
outcomes.add("unknown");
|
|
161936
|
-
break;
|
|
161937
|
-
default:
|
|
161938
|
-
break;
|
|
161939
|
-
}
|
|
161940
|
-
}
|
|
161941
|
-
return {
|
|
161942
|
-
outcome: Array.from(outcomes)
|
|
161943
|
-
};
|
|
161944
|
-
}
|
|
161945
|
-
function parseMethod(method) {
|
|
161946
|
-
return { method };
|
|
161947
|
-
}
|
|
161948
|
-
function parseHeader(header) {
|
|
161949
|
-
const [headerKey, headerQuery] = header.split(":", 2);
|
|
161950
|
-
return {
|
|
161951
|
-
header: {
|
|
161952
|
-
key: headerKey.trim(),
|
|
161953
|
-
query: headerQuery?.trim()
|
|
161954
|
-
}
|
|
161955
|
-
};
|
|
161956
|
-
}
|
|
161957
|
-
function parseIP(client_ip) {
|
|
161958
|
-
return { client_ip };
|
|
161959
|
-
}
|
|
161960
|
-
function parseQuery(query) {
|
|
161961
|
-
return { query };
|
|
161962
|
-
}
|
|
161963
|
-
|
|
161964
|
-
// src/tail/printing.ts
|
|
161965
|
-
init_import_meta_url();
|
|
161966
|
-
function prettyPrintLogs(data) {
|
|
161967
|
-
const eventMessage = JSON.parse(data.toString());
|
|
161968
|
-
if (isScheduledEvent(eventMessage.event)) {
|
|
161969
|
-
const cronPattern = eventMessage.event.cron;
|
|
161970
|
-
const datetime = new Date(
|
|
161971
|
-
eventMessage.event.scheduledTime
|
|
161972
|
-
).toLocaleString();
|
|
161973
|
-
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
161974
|
-
logger.log(`"${cronPattern}" @ ${datetime} - ${outcome}`);
|
|
161975
|
-
} else if (isRequestEvent(eventMessage.event)) {
|
|
161976
|
-
const requestMethod = eventMessage.event?.request.method.toUpperCase();
|
|
161977
|
-
const url3 = eventMessage.event?.request.url;
|
|
161978
|
-
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
161979
|
-
const datetime = new Date(eventMessage.eventTimestamp).toLocaleString();
|
|
161980
|
-
logger.log(
|
|
161981
|
-
url3 ? `${requestMethod} ${url3} - ${outcome} @ ${datetime}` : `[missing request] - ${outcome} @ ${datetime}`
|
|
161982
|
-
);
|
|
161983
|
-
} else if (isAlarmEvent(eventMessage.event)) {
|
|
161984
|
-
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
161985
|
-
const datetime = new Date(
|
|
161986
|
-
eventMessage.event.scheduledTime
|
|
161987
|
-
).toLocaleString();
|
|
161988
|
-
logger.log(`Alarm @ ${datetime} - ${outcome}`);
|
|
161989
|
-
} else {
|
|
161990
|
-
const outcome = prettifyOutcome(eventMessage.outcome);
|
|
161991
|
-
const datetime = new Date(eventMessage.eventTimestamp).toLocaleString();
|
|
161992
|
-
logger.log(`Unknown Event - ${outcome} @ ${datetime}`);
|
|
161993
|
-
}
|
|
161994
|
-
if (eventMessage.logs.length > 0) {
|
|
161995
|
-
eventMessage.logs.forEach(({ level, message }) => {
|
|
161996
|
-
logger.log(` (${level})`, ...message);
|
|
161997
|
-
});
|
|
161998
|
-
}
|
|
161999
|
-
if (eventMessage.exceptions.length > 0) {
|
|
162000
|
-
eventMessage.exceptions.forEach(({ name, message }) => {
|
|
162001
|
-
logger.error(` ${name}:`, message);
|
|
162002
|
-
});
|
|
162003
|
-
}
|
|
162004
|
-
}
|
|
162005
|
-
function jsonPrintLogs(data) {
|
|
162006
|
-
console.log(JSON.stringify(JSON.parse(data.toString()), null, 2));
|
|
162007
|
-
}
|
|
162008
|
-
function isRequestEvent(event) {
|
|
162009
|
-
return Boolean(event && "request" in event);
|
|
162010
|
-
}
|
|
162011
|
-
function isScheduledEvent(event) {
|
|
162012
|
-
return Boolean(event && "cron" in event);
|
|
162013
|
-
}
|
|
162014
|
-
function isAlarmEvent(event) {
|
|
162015
|
-
return Boolean(event && "scheduledTime" in event && !("cron" in event));
|
|
162016
|
-
}
|
|
162017
|
-
function prettifyOutcome(outcome) {
|
|
162018
|
-
switch (outcome) {
|
|
162019
|
-
case "ok":
|
|
162020
|
-
return "Ok";
|
|
162021
|
-
case "canceled":
|
|
162022
|
-
return "Canceled";
|
|
162023
|
-
case "exceededCpu":
|
|
162024
|
-
return "Exceeded CPU Limit";
|
|
162025
|
-
case "exceededMemory":
|
|
162026
|
-
return "Exceeded Memory Limit";
|
|
162027
|
-
case "exception":
|
|
162028
|
-
return "Exception Thrown";
|
|
162029
|
-
case "unknown":
|
|
162030
|
-
default:
|
|
162031
|
-
return "Unknown";
|
|
162032
|
-
}
|
|
162033
|
-
}
|
|
162034
|
-
|
|
162035
|
-
// src/tail/createTail.ts
|
|
162036
|
-
function makeCreateTailUrl(accountId, workerName, env5) {
|
|
162037
|
-
return env5 ? `/accounts/${accountId}/workers/services/${workerName}/environments/${env5}/tails` : `/accounts/${accountId}/workers/scripts/${workerName}/tails`;
|
|
162038
|
-
}
|
|
162039
|
-
function makeDeleteTailUrl(accountId, workerName, tailId, env5) {
|
|
162040
|
-
return env5 ? `/accounts/${accountId}/workers/services/${workerName}/environments/${env5}/tails/${tailId}` : `/accounts/${accountId}/workers/scripts/${workerName}/tails/${tailId}`;
|
|
162041
|
-
}
|
|
162042
|
-
async function createTail(accountId, workerName, filters, debug, env5) {
|
|
162043
|
-
const createTailUrl = makeCreateTailUrl(accountId, workerName, env5);
|
|
162044
|
-
const {
|
|
162045
|
-
id: tailId,
|
|
162046
|
-
url: websocketUrl,
|
|
162047
|
-
expires_at: expiration
|
|
162048
|
-
} = await fetchResult(createTailUrl, {
|
|
162049
|
-
method: "POST",
|
|
162050
|
-
body: JSON.stringify(filters)
|
|
162051
|
-
});
|
|
162052
|
-
const deleteUrl = makeDeleteTailUrl(accountId, workerName, tailId, env5);
|
|
162053
|
-
async function deleteTail() {
|
|
162054
|
-
await fetchResult(deleteUrl, { method: "DELETE" });
|
|
162055
|
-
}
|
|
162056
|
-
const tail = new wrapper_default(websocketUrl, "trace-v1", {
|
|
162057
|
-
headers: {
|
|
162058
|
-
"Sec-WebSocket-Protocol": "trace-v1",
|
|
162059
|
-
"User-Agent": `wrangler-js/${version}`
|
|
162060
|
-
}
|
|
162061
|
-
});
|
|
162062
|
-
tail.on("open", function() {
|
|
162063
|
-
tail.send(
|
|
162064
|
-
JSON.stringify({ debug }),
|
|
162065
|
-
{ binary: false, compress: false, mask: false, fin: true },
|
|
162066
|
-
(err2) => {
|
|
162067
|
-
if (err2) {
|
|
162068
|
-
throw err2;
|
|
162069
|
-
}
|
|
162070
|
-
}
|
|
162071
|
-
);
|
|
162072
|
-
});
|
|
162073
|
-
return { tail, expiration, deleteTail };
|
|
162074
|
-
}
|
|
162075
|
-
|
|
162076
|
-
// src/tail/index.ts
|
|
162326
|
+
var import_promises16 = require("node:timers/promises");
|
|
162327
|
+
var import_signal_exit6 = __toESM(require_signal_exit());
|
|
162077
162328
|
function tailOptions(yargs) {
|
|
162078
162329
|
return yargs.positional("worker", {
|
|
162079
162330
|
describe: "Name or route of the worker to tail",
|
|
@@ -162178,7 +162429,7 @@ async function tailHandler(args) {
|
|
|
162178
162429
|
`Successfully created tail, expires at ${expiration.toLocaleString()}`
|
|
162179
162430
|
);
|
|
162180
162431
|
}
|
|
162181
|
-
(0,
|
|
162432
|
+
(0, import_signal_exit6.default)(async () => {
|
|
162182
162433
|
tail.terminate();
|
|
162183
162434
|
await deleteTail();
|
|
162184
162435
|
await sendMetricsEvent("end log stream", {
|
|
@@ -162190,10 +162441,10 @@ async function tailHandler(args) {
|
|
|
162190
162441
|
while (tail.readyState !== tail.OPEN) {
|
|
162191
162442
|
switch (tail.readyState) {
|
|
162192
162443
|
case tail.CONNECTING:
|
|
162193
|
-
await (0,
|
|
162444
|
+
await (0, import_promises16.setTimeout)(100);
|
|
162194
162445
|
break;
|
|
162195
162446
|
case tail.CLOSING:
|
|
162196
|
-
await (0,
|
|
162447
|
+
await (0, import_promises16.setTimeout)(100);
|
|
162197
162448
|
break;
|
|
162198
162449
|
case tail.CLOSED:
|
|
162199
162450
|
await sendMetricsEvent("end log stream", {
|
|
@@ -162375,45 +162626,45 @@ async function updateCheck() {
|
|
|
162375
162626
|
|
|
162376
162627
|
// src/whoami.tsx
|
|
162377
162628
|
init_import_meta_url();
|
|
162378
|
-
var
|
|
162629
|
+
var import_ink16 = __toESM(require_build2());
|
|
162379
162630
|
var import_ink_table8 = __toESM(require_dist2());
|
|
162380
|
-
var
|
|
162631
|
+
var import_react20 = __toESM(require_react());
|
|
162381
162632
|
async function whoami() {
|
|
162382
162633
|
logger.log("Getting User settings...");
|
|
162383
162634
|
const user = await getUserInfo();
|
|
162384
|
-
const { unmount } = (0,
|
|
162635
|
+
const { unmount } = (0, import_ink16.render)(/* @__PURE__ */ import_react20.default.createElement(WhoAmI, {
|
|
162385
162636
|
user
|
|
162386
162637
|
}));
|
|
162387
162638
|
unmount();
|
|
162388
162639
|
}
|
|
162389
162640
|
function WhoAmI({ user }) {
|
|
162390
|
-
return user ? /* @__PURE__ */
|
|
162641
|
+
return user ? /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(Email, {
|
|
162391
162642
|
tokenType: user.authType,
|
|
162392
162643
|
email: user.email
|
|
162393
|
-
}), /* @__PURE__ */
|
|
162644
|
+
}), /* @__PURE__ */ import_react20.default.createElement(Accounts, {
|
|
162394
162645
|
accounts: user.accounts
|
|
162395
|
-
}), /* @__PURE__ */
|
|
162646
|
+
}), /* @__PURE__ */ import_react20.default.createElement(Permissions, {
|
|
162396
162647
|
tokenType: user.authType,
|
|
162397
162648
|
tokenPermissions: user.tokenPermissions
|
|
162398
|
-
})) : /* @__PURE__ */
|
|
162649
|
+
})) : /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "You are not authenticated. Please run `wrangler login`.");
|
|
162399
162650
|
}
|
|
162400
162651
|
function Email(props) {
|
|
162401
|
-
return props.email === void 0 ? /* @__PURE__ */
|
|
162652
|
+
return props.email === void 0 ? /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "\u{1F44B} You are logged in with an ", props.tokenType, ". Unable to retrieve email for this user. Are you missing the `User->User Details->Read` permission?") : /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "\u{1F44B} You are logged in with an ", props.tokenType, ", associated with the email '", props.email, "'!");
|
|
162402
162653
|
}
|
|
162403
162654
|
function Accounts(props) {
|
|
162404
162655
|
const accounts = props.accounts.map((account) => ({
|
|
162405
162656
|
"Account Name": account.name,
|
|
162406
162657
|
"Account ID": account.id
|
|
162407
162658
|
}));
|
|
162408
|
-
return /* @__PURE__ */
|
|
162659
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_ink_table8.default, {
|
|
162409
162660
|
data: accounts
|
|
162410
162661
|
});
|
|
162411
162662
|
}
|
|
162412
162663
|
function Permissions(props) {
|
|
162413
162664
|
const permissions = props.tokenPermissions?.map((scope) => scope.split(":")) || [];
|
|
162414
|
-
return props.tokenType === "OAuth Token" ? props.tokenPermissions ? /* @__PURE__ */
|
|
162665
|
+
return props.tokenType === "OAuth Token" ? props.tokenPermissions ? /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "\u{1F513} Token Permissions: If scopes are missing, you may need to logout and re-login."), /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "Scope (Access)"), permissions.map(([scope, access3], index) => /* @__PURE__ */ import_react20.default.createElement(import_react20.Fragment, {
|
|
162415
162666
|
key: `${scope}${index}`
|
|
162416
|
-
}, /* @__PURE__ */
|
|
162667
|
+
}, /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "- ", scope, " ", access3 && `(${access3})`)))) : null : /* @__PURE__ */ import_react20.default.createElement(import_ink16.Text, null, "\u{1F513} To see token permissions visit https://dash.cloudflare.com/profile/api-tokens");
|
|
162417
162668
|
}
|
|
162418
162669
|
async function getUserInfo() {
|
|
162419
162670
|
const apiToken = getAPIToken();
|
|
@@ -163121,7 +163372,7 @@ async function startDev(args) {
|
|
|
163121
163372
|
args,
|
|
163122
163373
|
configParam
|
|
163123
163374
|
);
|
|
163124
|
-
return /* @__PURE__ */
|
|
163375
|
+
return /* @__PURE__ */ import_react21.default.createElement(dev_default, {
|
|
163125
163376
|
name: getScriptName({ name: args.name, env: args.env }, configParam),
|
|
163126
163377
|
noBundle: !(args.bundle ?? !configParam.no_bundle),
|
|
163127
163378
|
entry,
|
|
@@ -163172,7 +163423,7 @@ async function startDev(args) {
|
|
|
163172
163423
|
experimentalLocal: args.experimentalLocal
|
|
163173
163424
|
});
|
|
163174
163425
|
}
|
|
163175
|
-
const devReactElement = (0,
|
|
163426
|
+
const devReactElement = (0, import_ink17.render)(await getDevReactElement(config));
|
|
163176
163427
|
rerender = devReactElement.rerender;
|
|
163177
163428
|
return {
|
|
163178
163429
|
devReactElement,
|