@cloudflare/pages-shared 0.11.8 → 0.11.10
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.
|
@@ -15,13 +15,21 @@ import type {
|
|
|
15
15
|
ParsedRedirects,
|
|
16
16
|
} from "./types";
|
|
17
17
|
|
|
18
|
+
const noopLogger = {
|
|
19
|
+
debug: (_message: string) => {},
|
|
20
|
+
log: (_message: string) => {},
|
|
21
|
+
info: (_message: string) => {},
|
|
22
|
+
warn: (_message: string) => {},
|
|
23
|
+
error: (_error: Error) => {},
|
|
24
|
+
};
|
|
25
|
+
|
|
18
26
|
export function createMetadataObject({
|
|
19
27
|
redirects,
|
|
20
28
|
headers,
|
|
21
29
|
webAnalyticsToken,
|
|
22
30
|
deploymentId,
|
|
23
31
|
failOpen,
|
|
24
|
-
logger =
|
|
32
|
+
logger = noopLogger,
|
|
25
33
|
}: {
|
|
26
34
|
redirects?: ParsedRedirects;
|
|
27
35
|
headers?: ParsedHeaders;
|
|
@@ -51,15 +59,17 @@ function constructRedirects({
|
|
|
51
59
|
const num_valid = redirects.rules.length;
|
|
52
60
|
const num_invalid = redirects.invalid.length;
|
|
53
61
|
|
|
54
|
-
logger(
|
|
62
|
+
logger.log(
|
|
55
63
|
`Parsed ${num_valid} valid redirect rule${num_valid === 1 ? "" : "s"}.`
|
|
56
64
|
);
|
|
57
65
|
|
|
58
66
|
if (num_invalid > 0) {
|
|
59
|
-
logger(`Found invalid redirect lines:`);
|
|
67
|
+
logger.warn(`Found invalid redirect lines:`);
|
|
60
68
|
for (const { line, lineNumber, message } of redirects.invalid) {
|
|
61
|
-
if (line)
|
|
62
|
-
|
|
69
|
+
if (line) {
|
|
70
|
+
logger.warn(` - ${lineNumber ? `#${lineNumber}: ` : ""}${line}`);
|
|
71
|
+
}
|
|
72
|
+
logger.warn(` ${message}`);
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
|
|
@@ -81,8 +91,8 @@ function constructRedirects({
|
|
|
81
91
|
};
|
|
82
92
|
continue;
|
|
83
93
|
} else {
|
|
84
|
-
logger(
|
|
85
|
-
`
|
|
94
|
+
logger.info(
|
|
95
|
+
`The redirect rule ${rule.from} → ${rule.status} ${rule.to} could be made more performant by bringing it above any lines with splats or placeholders.`
|
|
86
96
|
);
|
|
87
97
|
}
|
|
88
98
|
}
|
|
@@ -112,13 +122,17 @@ function constructHeaders({
|
|
|
112
122
|
const num_valid = headers.rules.length;
|
|
113
123
|
const num_invalid = headers.invalid.length;
|
|
114
124
|
|
|
115
|
-
logger(
|
|
125
|
+
logger.log(
|
|
126
|
+
`Parsed ${num_valid} valid header rule${num_valid === 1 ? "" : "s"}.`
|
|
127
|
+
);
|
|
116
128
|
|
|
117
129
|
if (num_invalid > 0) {
|
|
118
|
-
logger(`Found invalid header lines:`);
|
|
130
|
+
logger.warn(`Found invalid header lines:`);
|
|
119
131
|
for (const { line, lineNumber, message } of headers.invalid) {
|
|
120
|
-
if (line)
|
|
121
|
-
|
|
132
|
+
if (line) {
|
|
133
|
+
logger.warn(` - ${lineNumber ? `#${lineNumber}: ` : ""} ${line}`);
|
|
134
|
+
}
|
|
135
|
+
logger.warn(` ${message}`);
|
|
122
136
|
}
|
|
123
137
|
}
|
|
124
138
|
|
|
@@ -87,4 +87,10 @@ export type Metadata = {
|
|
|
87
87
|
failOpen?: boolean;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
export
|
|
90
|
+
export interface Logger {
|
|
91
|
+
debug: (message: string) => void;
|
|
92
|
+
log: (message: string) => void;
|
|
93
|
+
info: (message: string) => void;
|
|
94
|
+
warn: (message: string) => void;
|
|
95
|
+
error: (error: Error) => void;
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/pages-shared",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cloudflare/workers-sdk.git",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"metadata-generator/**/*"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"miniflare": "3.
|
|
16
|
+
"miniflare": "3.20240129.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@cloudflare/workers-types": "^4.20230511.0",
|