@uniformdev/next-app-router-upgrade 0.0.0-stage → 0.2.0

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/src/report.js ADDED
@@ -0,0 +1,44 @@
1
+ const ORDER = { error: 0, warning: 1, info: 2 };
2
+ const LABEL = { error: "CODE CHANGE NEEDED", warning: "REVIEW", info: "NOTE" };
3
+
4
+ export const TARGET_VERSION = "20.81.1-alpha.41.sha-adcf82dedd";
5
+
6
+ export function verdict(findings, { strict = false } = {}) {
7
+ const errors = findings.filter((f) => f.severity === "error").length;
8
+ const warnings = findings.filter((f) => f.severity === "warning").length;
9
+ if (errors || (strict && warnings)) return { safe: false, label: "CODE CHANGES NEEDED", errors, warnings };
10
+ return { safe: true, label: warnings ? "SAFE TO INSTALL (review the behavior changes)" : "SAFE TO INSTALL", errors, warnings };
11
+ }
12
+
13
+ export function formatText({ project, findings }, result, { color = true } = {}) {
14
+ const c = (code, s) => (color ? `\u001b[${code}m${s}\u001b[0m` : s);
15
+ const sev = { error: (s) => c("31;1", s), warning: (s) => c("33;1", s), info: (s) => c("36", s) };
16
+ const lines = [];
17
+
18
+ lines.push(c("1", "Uniform Next.js App Router SDK upgrade check"));
19
+ lines.push(`Target version: ${TARGET_VERSION}`);
20
+ lines.push(`Project: ${project.name ?? "(no name)"} at ${project.root}`);
21
+ lines.push(`Installed @uniformdev/next-app-router: ${project.sdkVersion ?? "not found"}`);
22
+ lines.push(`Files scanned: ${project.filesScanned}`);
23
+ lines.push("");
24
+
25
+ const sorted = [...findings].sort((a, b) => ORDER[a.severity] - ORDER[b.severity] || (a.file ?? "").localeCompare(b.file ?? "") || (a.line ?? 0) - (b.line ?? 0));
26
+ let current;
27
+ for (const f of sorted) {
28
+ if (f.severity !== current) {
29
+ current = f.severity;
30
+ lines.push(sev[current](`${LABEL[current]}`));
31
+ }
32
+ const where = f.file ? `${f.file}${f.line ? `:${f.line}` : ""}` : "";
33
+ lines.push(` ${sev[f.severity]("•")} ${f.title}${where ? c("2", ` (${where})`) : ""}`);
34
+ lines.push(` ${f.message}`);
35
+ lines.push(` Fix: ${f.fix}`);
36
+ lines.push(c("2", ` Docs: ${f.docs}`));
37
+ }
38
+ if (!findings.length) lines.push("No findings.");
39
+
40
+ lines.push("");
41
+ lines.push(`Errors: ${result.errors} Warnings: ${result.warnings} Notes: ${findings.length - result.errors - result.warnings}`);
42
+ lines.push(c(result.safe ? "32;1" : "31;1", `Verdict: ${result.label}`));
43
+ return lines.join("\n");
44
+ }
package/src/rules.js ADDED
@@ -0,0 +1,176 @@
1
+ // Each rule describes one change between the stable @uniformdev/next-app-router (20.82 to 20.85)
2
+ // and the developer preview (20.81.1-alpha.41). "error" rules fail to compile or break at
3
+ // runtime. "warning" rules change behavior. "info" rules need no change.
4
+
5
+ const DOCS = "https://docs.uniform.app/docs/sdk/nextjs-app-router";
6
+ const UPGRADE = `${DOCS}/upgrade-to-developer-preview`;
7
+
8
+ export const REMOVED_EXPORTS = {
9
+ "@uniformdev/next-app-router": {
10
+ DataClient: "Resolve the composition on the page and change it before render.",
11
+ DefaultDataClient: "Resolve the composition on the page and change it before render.",
12
+ EnhanceRouteOptions: "Resolve the composition on the page and change it before render.",
13
+ GetRouteOptions: "No replacement.",
14
+ GetRouteFromMiddlewareOptions: "No replacement.",
15
+ GetRouteFromPageStateOptions: "No replacement.",
16
+ RewriteRouteOptions: "No replacement.",
17
+ RewriteRouteResult: "No replacement.",
18
+ expireMiddlewareCacheTag: "Use the onRevalidateTags option of createPreviewPOSTRouteHandler.",
19
+ precomputeComposition: "Use edge mode: the edge chooses the variants of each visitor.",
20
+ },
21
+ "@uniformdev/next-app-router-shared": {
22
+ getRuleId: "No replacement.",
23
+ resolveComponentFromPageState: "No replacement.",
24
+ resolveRuleFromPageState: "No replacement.",
25
+ PageStateComponent: "No replacement.",
26
+ PageStateComponentFields: "No replacement.",
27
+ },
28
+ "@uniformdev/next-app-router-client": {
29
+ ClientContextTestTransfer: "No replacement.",
30
+ },
31
+ };
32
+
33
+ export const REMOVED_OPTIONS = {
34
+ dataClient: "Remove it. Resolve the composition on the page and change it before render.",
35
+ pathPatternsWithVariations: "Remove it. The middleware no longer evaluates variants.",
36
+ };
37
+
38
+ export const REMOVED_CONFIG_KEYS = {
39
+ middlewareRuntimeCache: "Remove it. The middleware makes no API calls.",
40
+ disableSwrMiddlewareCache: "Remove experimental.disableSwrMiddlewareCache. The middleware makes no API calls.",
41
+ };
42
+
43
+ export const REMOVED_PAGE_STATE_FIELDS = ["components", "rules", "quirks", "isPrefetch", "requestPath"];
44
+
45
+ export const RULES = {
46
+ "removed-export": {
47
+ severity: "error",
48
+ title: "Import of an API that the developer preview removes",
49
+ docs: `${UPGRADE}#step-5-replace-the-removed-apis`,
50
+ },
51
+ "removed-option": {
52
+ severity: "error",
53
+ title: "Option or prop that the developer preview removes",
54
+ docs: `${UPGRADE}#step-2-remove-the-removed-middleware-options`,
55
+ },
56
+ "removed-config-key": {
57
+ severity: "error",
58
+ title: "Server configuration option that the developer preview removes",
59
+ docs: `${UPGRADE}#step-4-clean-up-the-server-configuration`,
60
+ },
61
+ "removed-page-state-field": {
62
+ severity: "error",
63
+ title: "Page state field that the developer preview removes",
64
+ docs: `${UPGRADE}#step-5-replace-the-removed-apis`,
65
+ },
66
+ "result-code": {
67
+ severity: "error",
68
+ title: "Use of result.code from a route resolver",
69
+ docs: `${UPGRADE}#step-5-replace-the-removed-apis`,
70
+ },
71
+ "old-page-code": {
72
+ severity: "error",
73
+ title: "Hard-coded page code in the old format (2~)",
74
+ docs: `${UPGRADE}#behavior-changes`,
75
+ },
76
+ "next-version": {
77
+ severity: "error",
78
+ title: "Next.js version is lower than 16.0.7",
79
+ docs: `${DOCS}#prerequisites`,
80
+ },
81
+ "context-composition-metadata": {
82
+ severity: "error",
83
+ title: "compositionMetadata in a custom client context component",
84
+ docs: `${DOCS}/client-context`,
85
+ },
86
+ "context-storage-options": {
87
+ severity: "error",
88
+ title: "Visitor data option of 20.85 that the developer preview does not have",
89
+ docs: `${DOCS}/client-context`,
90
+ },
91
+ "uniform-context-props": {
92
+ severity: "error",
93
+ title: "UniformContext with result or children (changed after alpha.25)",
94
+ docs: `${DOCS}/client-context`,
95
+ },
96
+ "vercel-functions-transitive": {
97
+ severity: "error",
98
+ title: "@vercel/functions is imported but not a dependency",
99
+ docs: `${UPGRADE}#step-7-install-the-vercel-functions-package`,
100
+ },
101
+ "route-union": {
102
+ severity: "warning",
103
+ title: "Direct access to route.compositionApiResponse",
104
+ docs: `${DOCS}/resolving-compositions#the-result`,
105
+ },
106
+ "placement-props": {
107
+ severity: "warning",
108
+ title: "Use of PersonalizeProps or TestProps",
109
+ docs: `${UPGRADE}#behavior-changes`,
110
+ },
111
+ "lite-mode-flicker": {
112
+ severity: "warning",
113
+ title: "Personalizations and tests change from middleware evaluation to the browser (lite mode)",
114
+ docs: `${DOCS}/edge-personalization`,
115
+ },
116
+ "project-map-query-strings": {
117
+ severity: "warning",
118
+ title: "Project map nodes with query strings",
119
+ docs: `${DOCS}/middleware#keep-query-strings-in-the-route`,
120
+ },
121
+ "visibility-rules": {
122
+ severity: "warning",
123
+ title: "Components with visibility rules are not in the server HTML",
124
+ docs: `${DOCS}/personalization#visibility-rules`,
125
+ },
126
+ "not-found-page": {
127
+ severity: "warning",
128
+ title: "Missing routes no longer rewrite to /404",
129
+ docs: `${DOCS}/recipes/not-found`,
130
+ },
131
+ "not-found-html": {
132
+ severity: "warning",
133
+ title: "The HTML of the 404 page is empty until hydration",
134
+ docs: `${DOCS}/recipes/not-found`,
135
+ },
136
+ "per-request-consent": {
137
+ severity: "warning",
138
+ title: "defaultConsent is set for each request in the middleware",
139
+ docs: `${DOCS}/incremental-static-regeneration-isr#consent-and-edge-mode-values`,
140
+ },
141
+ "uniform-version-mismatch": {
142
+ severity: "warning",
143
+ title: "@uniformdev packages have different versions",
144
+ docs: `${UPGRADE}#step-1-install-the-packages`,
145
+ },
146
+ "prerelease-peer-range": {
147
+ severity: "warning",
148
+ title: "A package has a peer range that does not accept prerelease versions",
149
+ docs: `${UPGRADE}#step-1-install-the-packages`,
150
+ },
151
+ "cached-resolver": {
152
+ severity: "info",
153
+ title: "The 'use cache' resolver now caches only published content",
154
+ docs: `${DOCS}/caching#cache-components`,
155
+ },
156
+ "static-params": {
157
+ severity: "info",
158
+ title: "createUniformStaticParams makes one code for each path",
159
+ docs: `${DOCS}/incremental-static-regeneration-isr`,
160
+ },
161
+ "context-edge-dependency": {
162
+ severity: "info",
163
+ title: "@uniformdev/context-edge is no longer necessary",
164
+ docs: `${UPGRADE}#step-1-install-the-packages`,
165
+ },
166
+ "playground-path": {
167
+ severity: "info",
168
+ title: "The middleware accepts processPlaygroundPath",
169
+ docs: `${DOCS}/preview`,
170
+ },
171
+ "redirect-status": {
172
+ severity: "info",
173
+ title: "Uniform redirects now come from the page (308 or 307)",
174
+ docs: `${UPGRADE}#behavior-changes`,
175
+ },
176
+ };