@patchstack/connect 0.5.4 → 0.5.5
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/AGENT-INSTALL.md +4 -4
- package/README.md +5 -5
- package/dist/cli.js +214 -125
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +50 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -18
- package/dist/index.js.map +1 -1
- package/dist/protect.cjs +88 -57
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.js +1 -1
- package/dist/{refresh-manifest-K3RT4XNH.js → refresh-manifest-2ALIJGZ3.js} +57 -26
- package/dist/refresh-manifest-2ALIJGZ3.js.map +1 -0
- package/package.json +1 -1
- package/dist/refresh-manifest-K3RT4XNH.js.map +0 -1
package/dist/protect.cjs
CHANGED
|
@@ -38,8 +38,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
38
38
|
// src/pulse-token.ts
|
|
39
39
|
function buildTokenUrl(manifestEndpoint) {
|
|
40
40
|
const url = new URL(manifestEndpoint);
|
|
41
|
-
const
|
|
42
|
-
url.pathname =
|
|
41
|
+
const path9 = url.pathname.replace(/\/$/, "");
|
|
42
|
+
url.pathname = path9.endsWith("/manifest") ? `${path9.slice(0, -"/manifest".length)}/token` : "/monitor/pulse/token";
|
|
43
43
|
url.search = "";
|
|
44
44
|
url.hash = "";
|
|
45
45
|
return url.toString();
|
|
@@ -326,19 +326,44 @@ var init_client = __esm({
|
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
// src/environment.ts
|
|
329
|
-
function
|
|
329
|
+
function detectHostedBuilder(cwd) {
|
|
330
|
+
let declared;
|
|
331
|
+
try {
|
|
332
|
+
const pkg = JSON.parse((0, import_node_fs.readFileSync)(import_node_path.default.join(cwd, "package.json"), "utf8"));
|
|
333
|
+
declared = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
334
|
+
} catch {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
const names = Object.keys(declared);
|
|
338
|
+
for (const rule of HOSTED_BUILDER_PACKAGES) {
|
|
339
|
+
const hit = names.some(
|
|
340
|
+
(name) => rule.exact.includes(name) || rule.prefixes.some((prefix) => name.startsWith(prefix))
|
|
341
|
+
);
|
|
342
|
+
if (hit) return rule.builder;
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
function inferEnvironment(env = process.env, builder = null) {
|
|
330
347
|
for (const discriminator of DISCRIMINATORS) {
|
|
331
348
|
const verdict = discriminator.read(env);
|
|
332
349
|
if (verdict !== null) {
|
|
333
350
|
return { environment: verdict.environment, evidence: [`${discriminator.platform}: ${verdict.evidence}`] };
|
|
334
351
|
}
|
|
335
352
|
}
|
|
353
|
+
if (builder !== null) {
|
|
354
|
+
return {
|
|
355
|
+
environment: "production",
|
|
356
|
+
evidence: [`${builder}: a build in a ${builder} project is its publish step`]
|
|
357
|
+
};
|
|
358
|
+
}
|
|
336
359
|
return { environment: "local", evidence: [] };
|
|
337
360
|
}
|
|
338
|
-
var set, DISCRIMINATORS;
|
|
361
|
+
var import_node_fs, import_node_path, set, DISCRIMINATORS, HOSTED_BUILDER_PACKAGES;
|
|
339
362
|
var init_environment = __esm({
|
|
340
363
|
"src/environment.ts"() {
|
|
341
364
|
"use strict";
|
|
365
|
+
import_node_fs = require("fs");
|
|
366
|
+
import_node_path = __toESM(require("path"), 1);
|
|
342
367
|
set = (value) => value !== void 0 && value !== "";
|
|
343
368
|
DISCRIMINATORS = [
|
|
344
369
|
{
|
|
@@ -370,6 +395,12 @@ var init_environment = __esm({
|
|
|
370
395
|
}
|
|
371
396
|
}
|
|
372
397
|
];
|
|
398
|
+
HOSTED_BUILDER_PACKAGES = [
|
|
399
|
+
// `lovable-tagger` covers projects from before ~Aug 2026; current templates ship the
|
|
400
|
+
// `@lovable.dev/*` scoped tooling instead.
|
|
401
|
+
{ builder: "lovable", exact: ["lovable-tagger"], prefixes: ["@lovable.dev/"] },
|
|
402
|
+
{ builder: "replit", exact: [], prefixes: ["@replit/"] }
|
|
403
|
+
];
|
|
373
404
|
}
|
|
374
405
|
});
|
|
375
406
|
|
|
@@ -477,13 +508,13 @@ async function readIfPresent(file) {
|
|
|
477
508
|
}
|
|
478
509
|
}
|
|
479
510
|
async function detectSiteName(cwd) {
|
|
480
|
-
for (const shell of ["index.html",
|
|
481
|
-
const html = await readIfPresent(
|
|
511
|
+
for (const shell of ["index.html", import_node_path2.default.join("public", "index.html")]) {
|
|
512
|
+
const html = await readIfPresent(import_node_path2.default.join(cwd, shell));
|
|
482
513
|
if (html === null) continue;
|
|
483
514
|
const name = nameFromHtmlTitle(html);
|
|
484
515
|
if (name !== null) return { name, source: "index.html" };
|
|
485
516
|
}
|
|
486
|
-
const manifest = await readIfPresent(
|
|
517
|
+
const manifest = await readIfPresent(import_node_path2.default.join(cwd, "package.json"));
|
|
487
518
|
if (manifest !== null) {
|
|
488
519
|
try {
|
|
489
520
|
const parsed = JSON.parse(manifest);
|
|
@@ -496,12 +527,12 @@ async function detectSiteName(cwd) {
|
|
|
496
527
|
}
|
|
497
528
|
return null;
|
|
498
529
|
}
|
|
499
|
-
var import_promises,
|
|
530
|
+
var import_promises, import_node_path2, NAME_MAX_LENGTH, TEMPLATE_PACKAGE_NAMES, TEMPLATE_TITLES, NAMED_ENTITIES2;
|
|
500
531
|
var init_site_name = __esm({
|
|
501
532
|
"src/site-name.ts"() {
|
|
502
533
|
"use strict";
|
|
503
534
|
import_promises = require("fs/promises");
|
|
504
|
-
|
|
535
|
+
import_node_path2 = __toESM(require("path"), 1);
|
|
505
536
|
NAME_MAX_LENGTH = 191;
|
|
506
537
|
TEMPLATE_PACKAGE_NAMES = /* @__PURE__ */ new Set([
|
|
507
538
|
// Lovable
|
|
@@ -588,7 +619,7 @@ async function resolveConfig(options) {
|
|
|
588
619
|
"CONFIG_INVALID"
|
|
589
620
|
);
|
|
590
621
|
}
|
|
591
|
-
const inferred = environmentRaw === void 0 ? inferEnvironment(process.env) : null;
|
|
622
|
+
const inferred = environmentRaw === void 0 ? inferEnvironment(process.env, detectHostedBuilder(options.cwd)) : null;
|
|
592
623
|
const environment = environmentRaw ?? inferred.environment;
|
|
593
624
|
const environmentEvidence = inferred?.evidence ?? [];
|
|
594
625
|
if (siteUuid !== null && siteUuid.length > 0 && !isUuid(siteUuid)) {
|
|
@@ -629,7 +660,7 @@ async function readConfigFile(cwd) {
|
|
|
629
660
|
return readJsonFile(cwd, CONFIG_FILENAME);
|
|
630
661
|
}
|
|
631
662
|
async function readJsonFile(cwd, filename) {
|
|
632
|
-
const target =
|
|
663
|
+
const target = import_node_path3.default.join(cwd, filename);
|
|
633
664
|
let raw;
|
|
634
665
|
try {
|
|
635
666
|
raw = await (0, import_promises2.readFile)(target, "utf8");
|
|
@@ -684,12 +715,12 @@ function isUuid(value) {
|
|
|
684
715
|
function isEnvironment(value) {
|
|
685
716
|
return value === "production" || value === "sandbox" || value === "local";
|
|
686
717
|
}
|
|
687
|
-
var import_promises2,
|
|
718
|
+
var import_promises2, import_node_path3, CONFIG_FILENAME, SECRET_FILENAME;
|
|
688
719
|
var init_config = __esm({
|
|
689
720
|
"src/config.ts"() {
|
|
690
721
|
"use strict";
|
|
691
722
|
import_promises2 = require("fs/promises");
|
|
692
|
-
|
|
723
|
+
import_node_path3 = __toESM(require("path"), 1);
|
|
693
724
|
init_types();
|
|
694
725
|
init_client();
|
|
695
726
|
init_environment();
|
|
@@ -704,7 +735,7 @@ var init_config = __esm({
|
|
|
704
735
|
async function readDeclaredDependencyNames(cwd) {
|
|
705
736
|
let raw;
|
|
706
737
|
try {
|
|
707
|
-
raw = await (0, import_promises3.readFile)(
|
|
738
|
+
raw = await (0, import_promises3.readFile)(import_node_path4.default.join(cwd, "package.json"), "utf8");
|
|
708
739
|
} catch {
|
|
709
740
|
return [];
|
|
710
741
|
}
|
|
@@ -753,12 +784,12 @@ function disagreements(packages, other) {
|
|
|
753
784
|
}
|
|
754
785
|
return conflicts;
|
|
755
786
|
}
|
|
756
|
-
var import_promises3,
|
|
787
|
+
var import_promises3, import_node_path4;
|
|
757
788
|
var init_consistency = __esm({
|
|
758
789
|
"src/parsers/consistency.ts"() {
|
|
759
790
|
"use strict";
|
|
760
791
|
import_promises3 = require("fs/promises");
|
|
761
|
-
|
|
792
|
+
import_node_path4 = __toESM(require("path"), 1);
|
|
762
793
|
}
|
|
763
794
|
});
|
|
764
795
|
|
|
@@ -976,7 +1007,7 @@ function extractFromV1(deps, acc = [], depth = 0) {
|
|
|
976
1007
|
return acc;
|
|
977
1008
|
}
|
|
978
1009
|
function extractNameFromPath(pkgPath) {
|
|
979
|
-
const segments = pkgPath.split("node_modules" +
|
|
1010
|
+
const segments = pkgPath.split("node_modules" + import_node_path5.default.sep === pkgPath ? import_node_path5.default.sep : "/");
|
|
980
1011
|
const parts = pkgPath.split("/");
|
|
981
1012
|
const nmIndex = parts.lastIndexOf("node_modules");
|
|
982
1013
|
if (nmIndex === -1 || nmIndex >= parts.length - 1) {
|
|
@@ -997,19 +1028,19 @@ function isDirectV2(pkgPath) {
|
|
|
997
1028
|
const nmCount = parts.filter((p) => p === "node_modules").length;
|
|
998
1029
|
return nmCount === 1;
|
|
999
1030
|
}
|
|
1000
|
-
var import_promises5,
|
|
1031
|
+
var import_promises5, import_node_path5;
|
|
1001
1032
|
var init_npm = __esm({
|
|
1002
1033
|
"src/parsers/npm.ts"() {
|
|
1003
1034
|
"use strict";
|
|
1004
1035
|
import_promises5 = require("fs/promises");
|
|
1005
|
-
|
|
1036
|
+
import_node_path5 = __toESM(require("path"), 1);
|
|
1006
1037
|
init_types();
|
|
1007
1038
|
}
|
|
1008
1039
|
});
|
|
1009
1040
|
|
|
1010
1041
|
// src/parsers/node_modules.ts
|
|
1011
1042
|
async function walkNodeModules(cwd) {
|
|
1012
|
-
const root =
|
|
1043
|
+
const root = import_node_path6.default.join(cwd, "node_modules");
|
|
1013
1044
|
try {
|
|
1014
1045
|
const info = await (0, import_promises6.stat)(root);
|
|
1015
1046
|
if (!info.isDirectory()) {
|
|
@@ -1052,7 +1083,7 @@ async function walk(dir, depth, seen, root) {
|
|
|
1052
1083
|
}
|
|
1053
1084
|
const perEntry = await mapLimit(names, async (name) => {
|
|
1054
1085
|
if (name.startsWith(".") && !PACKAGE_STORE_DIRS.has(name)) return [];
|
|
1055
|
-
const fullPath =
|
|
1086
|
+
const fullPath = import_node_path6.default.join(dir, name);
|
|
1056
1087
|
const resolved = await claim(fullPath, seen, depth);
|
|
1057
1088
|
if (resolved === null) return [];
|
|
1058
1089
|
if (PACKAGE_STORE_DIRS.has(name)) return walk(fullPath, depth, seen, root);
|
|
@@ -1065,7 +1096,7 @@ async function walk(dir, depth, seen, root) {
|
|
|
1065
1096
|
}
|
|
1066
1097
|
const scoped = await mapLimit(subNames, async (sub) => {
|
|
1067
1098
|
if (sub.startsWith(".")) return [];
|
|
1068
|
-
const scopedDir =
|
|
1099
|
+
const scopedDir = import_node_path6.default.join(fullPath, sub);
|
|
1069
1100
|
const scopedReal = await claim(scopedDir, seen, depth);
|
|
1070
1101
|
if (scopedReal === null) return [];
|
|
1071
1102
|
return packageAndNested(scopedDir, scopedReal, depth, seen, root);
|
|
@@ -1092,13 +1123,13 @@ async function mapLimit(items, fn) {
|
|
|
1092
1123
|
await Promise.all(workers);
|
|
1093
1124
|
return results;
|
|
1094
1125
|
}
|
|
1095
|
-
function installLocation(root, pkgDir, impl =
|
|
1126
|
+
function installLocation(root, pkgDir, impl = import_node_path6.default) {
|
|
1096
1127
|
return impl.relative(root, pkgDir).split(impl.sep).join("/");
|
|
1097
1128
|
}
|
|
1098
1129
|
async function readPackage(pkgDir, depth, root) {
|
|
1099
1130
|
let raw;
|
|
1100
1131
|
try {
|
|
1101
|
-
raw = await (0, import_promises6.readFile)(
|
|
1132
|
+
raw = await (0, import_promises6.readFile)(import_node_path6.default.join(pkgDir, "package.json"), "utf8");
|
|
1102
1133
|
} catch {
|
|
1103
1134
|
return null;
|
|
1104
1135
|
}
|
|
@@ -1117,7 +1148,7 @@ async function readPackage(pkgDir, depth, root) {
|
|
|
1117
1148
|
return { name: parsed.name, version: parsed.version, path: installLocation(root, pkgDir), direct: depth === 0 };
|
|
1118
1149
|
}
|
|
1119
1150
|
async function walkNested(pkgDir, depth, seen, root) {
|
|
1120
|
-
const nested =
|
|
1151
|
+
const nested = import_node_path6.default.join(pkgDir, "node_modules");
|
|
1121
1152
|
if (await claim(nested, seen, depth + 1) === null) {
|
|
1122
1153
|
return [];
|
|
1123
1154
|
}
|
|
@@ -1139,12 +1170,12 @@ async function claim(dir, seen, depth) {
|
|
|
1139
1170
|
seen.set(resolved, depth);
|
|
1140
1171
|
return resolved;
|
|
1141
1172
|
}
|
|
1142
|
-
var import_promises6,
|
|
1173
|
+
var import_promises6, import_node_path6, PACKAGE_STORE_DIRS, CONCURRENCY;
|
|
1143
1174
|
var init_node_modules = __esm({
|
|
1144
1175
|
"src/parsers/node_modules.ts"() {
|
|
1145
1176
|
"use strict";
|
|
1146
1177
|
import_promises6 = require("fs/promises");
|
|
1147
|
-
|
|
1178
|
+
import_node_path6 = __toESM(require("path"), 1);
|
|
1148
1179
|
init_types();
|
|
1149
1180
|
PACKAGE_STORE_DIRS = /* @__PURE__ */ new Set([".bun", ".pnpm", ".store"]);
|
|
1150
1181
|
CONCURRENCY = 32;
|
|
@@ -1431,7 +1462,7 @@ async function parseYarnLockfile(lockfilePath, report) {
|
|
|
1431
1462
|
"LOCKFILE_PARSE_ERROR"
|
|
1432
1463
|
);
|
|
1433
1464
|
}
|
|
1434
|
-
const directNames = await readDirectDepNames(
|
|
1465
|
+
const directNames = await readDirectDepNames(import_node_path7.default.dirname(lockfilePath));
|
|
1435
1466
|
const entries = [];
|
|
1436
1467
|
const seen = /* @__PURE__ */ new Set();
|
|
1437
1468
|
for (const block of blocks) {
|
|
@@ -1596,7 +1627,7 @@ async function readDirectDepNames(cwd) {
|
|
|
1596
1627
|
const names = /* @__PURE__ */ new Set();
|
|
1597
1628
|
let raw;
|
|
1598
1629
|
try {
|
|
1599
|
-
raw = await (0, import_promises8.readFile)(
|
|
1630
|
+
raw = await (0, import_promises8.readFile)(import_node_path7.default.join(cwd, "package.json"), "utf8");
|
|
1600
1631
|
} catch {
|
|
1601
1632
|
return names;
|
|
1602
1633
|
}
|
|
@@ -1621,12 +1652,12 @@ async function readDirectDepNames(cwd) {
|
|
|
1621
1652
|
}
|
|
1622
1653
|
return names;
|
|
1623
1654
|
}
|
|
1624
|
-
var import_promises8,
|
|
1655
|
+
var import_promises8, import_node_path7, NON_PACKAGE_KEYS, NON_REGISTRY_PROTOCOLS;
|
|
1625
1656
|
var init_yarn = __esm({
|
|
1626
1657
|
"src/parsers/yarn.ts"() {
|
|
1627
1658
|
"use strict";
|
|
1628
1659
|
import_promises8 = require("fs/promises");
|
|
1629
|
-
|
|
1660
|
+
import_node_path7 = __toESM(require("path"), 1);
|
|
1630
1661
|
init_types();
|
|
1631
1662
|
init_report();
|
|
1632
1663
|
NON_PACKAGE_KEYS = /* @__PURE__ */ new Set(["__metadata"]);
|
|
@@ -1638,7 +1669,7 @@ var init_yarn = __esm({
|
|
|
1638
1669
|
async function detectLockfile(cwd) {
|
|
1639
1670
|
const probed = await Promise.all(
|
|
1640
1671
|
LOCKFILE_CANDIDATES.map(async (candidate) => {
|
|
1641
|
-
const filePath =
|
|
1672
|
+
const filePath = import_node_path8.default.join(cwd, candidate.filename);
|
|
1642
1673
|
return { ...candidate, filePath, present: await exists(filePath) };
|
|
1643
1674
|
})
|
|
1644
1675
|
);
|
|
@@ -1749,7 +1780,7 @@ function staleWarning(source, missing) {
|
|
|
1749
1780
|
async function presentLockfiles(cwd) {
|
|
1750
1781
|
const probed = await Promise.all(
|
|
1751
1782
|
LOCKFILE_CANDIDATES.map(async (candidate) => {
|
|
1752
|
-
const filePath =
|
|
1783
|
+
const filePath = import_node_path8.default.join(cwd, candidate.filename);
|
|
1753
1784
|
return { ...candidate, filePath, present: await exists(filePath) };
|
|
1754
1785
|
})
|
|
1755
1786
|
);
|
|
@@ -1779,12 +1810,12 @@ async function exists(filePath) {
|
|
|
1779
1810
|
return false;
|
|
1780
1811
|
}
|
|
1781
1812
|
}
|
|
1782
|
-
var import_promises9,
|
|
1813
|
+
var import_promises9, import_node_path8, LOCKFILE_CANDIDATES;
|
|
1783
1814
|
var init_parsers = __esm({
|
|
1784
1815
|
"src/parsers/index.ts"() {
|
|
1785
1816
|
"use strict";
|
|
1786
1817
|
import_promises9 = require("fs/promises");
|
|
1787
|
-
|
|
1818
|
+
import_node_path8 = __toESM(require("path"), 1);
|
|
1788
1819
|
init_types();
|
|
1789
1820
|
init_consistency();
|
|
1790
1821
|
init_bun();
|
|
@@ -3227,12 +3258,12 @@ function isRegexForm(pattern) {
|
|
|
3227
3258
|
const parts = REGEX_FORM.exec(pattern);
|
|
3228
3259
|
return parts !== null && REGEX_SYNTAX.test(parts[1]);
|
|
3229
3260
|
}
|
|
3230
|
-
function pathMatches(pattern,
|
|
3261
|
+
function pathMatches(pattern, path9) {
|
|
3231
3262
|
if (isRegexForm(pattern)) {
|
|
3232
3263
|
const re = safeRegExp(pattern);
|
|
3233
|
-
return re ? re.test(
|
|
3264
|
+
return re ? re.test(path9) : false;
|
|
3234
3265
|
}
|
|
3235
|
-
const target = foldPathForScope(
|
|
3266
|
+
const target = foldPathForScope(path9);
|
|
3236
3267
|
const folded = foldPathForScope(pattern);
|
|
3237
3268
|
if (folded.includes("*")) {
|
|
3238
3269
|
const trailing = folded.endsWith("/*");
|
|
@@ -4875,8 +4906,8 @@ function extractHttpTarget(args) {
|
|
|
4875
4906
|
const host = normalizeHost(first.hostname || first.host) || "localhost";
|
|
4876
4907
|
const protocol = first.protocol || "http:";
|
|
4877
4908
|
const port = first.port ? `:${first.port}` : "";
|
|
4878
|
-
const
|
|
4879
|
-
return { url: `${protocol}//${host}${port}${
|
|
4909
|
+
const path9 = first.path || "/";
|
|
4910
|
+
return { url: `${protocol}//${host}${port}${path9}`, host, method: first.method || "GET" };
|
|
4880
4911
|
}
|
|
4881
4912
|
} catch {
|
|
4882
4913
|
}
|
|
@@ -5242,12 +5273,12 @@ var fsMod;
|
|
|
5242
5273
|
async function loadFs() {
|
|
5243
5274
|
if (fsMod !== void 0) return fsMod;
|
|
5244
5275
|
try {
|
|
5245
|
-
const [fs,
|
|
5276
|
+
const [fs, path9] = await Promise.all([import("fs"), import("path")]);
|
|
5246
5277
|
fsMod = {
|
|
5247
5278
|
readFileSync: fs.readFileSync,
|
|
5248
5279
|
writeFileSync: fs.writeFileSync,
|
|
5249
5280
|
mkdirSync: fs.mkdirSync,
|
|
5250
|
-
join:
|
|
5281
|
+
join: path9.join
|
|
5251
5282
|
};
|
|
5252
5283
|
} catch {
|
|
5253
5284
|
fsMod = null;
|
|
@@ -5635,13 +5666,13 @@ var MAX_CAPTURED_VALUE_CHARS = 512;
|
|
|
5635
5666
|
var MAX_QUERY_KEYS = 10;
|
|
5636
5667
|
var MAX_METHOD_CHARS = 16;
|
|
5637
5668
|
var MAX_BODY_BYTES2 = 64 * 1024;
|
|
5638
|
-
function queryKeysOf(
|
|
5639
|
-
if (typeof
|
|
5640
|
-
const start =
|
|
5669
|
+
function queryKeysOf(path9) {
|
|
5670
|
+
if (typeof path9 !== "string") return { keys: [], total: 0 };
|
|
5671
|
+
const start = path9.indexOf("?");
|
|
5641
5672
|
if (start === -1) return { keys: [], total: 0 };
|
|
5642
5673
|
let names;
|
|
5643
5674
|
try {
|
|
5644
|
-
names = [...new URLSearchParams(
|
|
5675
|
+
names = [...new URLSearchParams(path9.slice(start + 1)).keys()];
|
|
5645
5676
|
} catch {
|
|
5646
5677
|
return { keys: [], total: 0 };
|
|
5647
5678
|
}
|
|
@@ -5780,10 +5811,10 @@ function revisionOf(rule) {
|
|
|
5780
5811
|
if (typeof revision === "number" && Number.isFinite(revision)) return String(revision);
|
|
5781
5812
|
return null;
|
|
5782
5813
|
}
|
|
5783
|
-
function routeOf(
|
|
5784
|
-
if (typeof
|
|
5785
|
-
const cut =
|
|
5786
|
-
return cut === -1 ?
|
|
5814
|
+
function routeOf(path9) {
|
|
5815
|
+
if (typeof path9 !== "string" || path9 === "") return null;
|
|
5816
|
+
const cut = path9.search(/[?#]/);
|
|
5817
|
+
return cut === -1 ? path9 : path9.slice(0, cut);
|
|
5787
5818
|
}
|
|
5788
5819
|
function createDetectionReporter(opts) {
|
|
5789
5820
|
const siteUuid = opts.siteUuid ?? process.env?.PATCHSTACK_SITE_UUID;
|
|
@@ -7491,11 +7522,11 @@ function resolveMode(options, bundle) {
|
|
|
7491
7522
|
var CREDENTIAL_FILES = [".patchstackrc.local.json", ".patchstackrc.json"];
|
|
7492
7523
|
async function readCredentialField(options, field) {
|
|
7493
7524
|
if (typeof process === "undefined" || typeof process.cwd !== "function") return void 0;
|
|
7494
|
-
let
|
|
7525
|
+
let readFileSync2;
|
|
7495
7526
|
let join;
|
|
7496
7527
|
try {
|
|
7497
7528
|
const [fs, pathMod] = await Promise.all([import("fs"), import("path")]);
|
|
7498
|
-
|
|
7529
|
+
readFileSync2 = fs.readFileSync;
|
|
7499
7530
|
join = pathMod.join;
|
|
7500
7531
|
} catch {
|
|
7501
7532
|
return void 0;
|
|
@@ -7503,7 +7534,7 @@ async function readCredentialField(options, field) {
|
|
|
7503
7534
|
const cwd = options?.cwd ?? process.cwd();
|
|
7504
7535
|
for (const filename of CREDENTIAL_FILES) {
|
|
7505
7536
|
try {
|
|
7506
|
-
const value = JSON.parse(
|
|
7537
|
+
const value = JSON.parse(readFileSync2(join(cwd, filename), "utf8"))?.[field];
|
|
7507
7538
|
if (typeof value === "string" && value.length > 0) return value;
|
|
7508
7539
|
} catch {
|
|
7509
7540
|
}
|
|
@@ -7924,20 +7955,20 @@ function requestMetaFromContext(reqCtx) {
|
|
|
7924
7955
|
}
|
|
7925
7956
|
function requestMeta(shaped, request) {
|
|
7926
7957
|
const client = shaped?._clientIp ?? { ip: null, source: "unavailable" };
|
|
7927
|
-
let
|
|
7958
|
+
let path9 = null;
|
|
7928
7959
|
let method = null;
|
|
7929
7960
|
let userAgent = null;
|
|
7930
7961
|
if (request) {
|
|
7931
7962
|
try {
|
|
7932
7963
|
const u = new URL(request.url);
|
|
7933
|
-
|
|
7964
|
+
path9 = u.pathname + u.search;
|
|
7934
7965
|
} catch {
|
|
7935
|
-
|
|
7966
|
+
path9 = typeof request.url === "string" ? request.url : null;
|
|
7936
7967
|
}
|
|
7937
7968
|
method = request.method ?? null;
|
|
7938
7969
|
userAgent = request.headers?.get?.("user-agent") ?? null;
|
|
7939
7970
|
}
|
|
7940
|
-
return { method, path:
|
|
7971
|
+
return { method, path: path9, ip: client.ip, clientIpSource: client.source, userAgent, event: eventFor(request) };
|
|
7941
7972
|
}
|
|
7942
7973
|
function nodeRequestMeta(req, client) {
|
|
7943
7974
|
if (!req) return {};
|