next-anteater 0.2.10 → 0.2.11

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.
Files changed (2) hide show
  1. package/lib/scaffold.mjs +22 -5
  2. package/package.json +1 -1
package/lib/scaffold.mjs CHANGED
@@ -105,7 +105,12 @@ async function patchApiRouteMutationGuardIfMissing(path) {
105
105
  async function patchRunsRouteMutationGuardIfMissing(path) {
106
106
  try {
107
107
  const existing = await readFile(path, "utf-8");
108
- if (existing.includes("Same-origin guard for mutating runs endpoint")) {
108
+ if (
109
+ existing.includes("Same-origin guard for mutating runs endpoint") &&
110
+ existing.includes("export async function DELETE(request") &&
111
+ existing.indexOf("Same-origin guard for mutating runs endpoint") >
112
+ existing.indexOf("export async function DELETE(request")
113
+ ) {
109
114
  return false;
110
115
  }
111
116
 
@@ -134,10 +139,22 @@ async function patchRunsRouteMutationGuardIfMissing(path) {
134
139
  "",
135
140
  ].join("\n");
136
141
 
137
- const patched = existing.replace(
138
- " const gh = (url",
139
- `${guardBlock} const gh = (url`,
140
- );
142
+ const deleteFnPattern =
143
+ /(export async function DELETE\(request[^\n]*\) \{[\s\S]*?if \(!requestId\) \{[\s\S]*?\n \}\n\s*)/;
144
+ let patched = existing;
145
+
146
+ if (deleteFnPattern.test(existing)) {
147
+ patched = existing.replace(deleteFnPattern, `$1${guardBlock}`);
148
+ } else {
149
+ return false;
150
+ }
151
+
152
+ // Clean up buggy older patch where guard was accidentally inserted in GET.
153
+ const getGuardPattern =
154
+ /(export async function GET\(\) \{[\s\S]*?)\n \/\/ Same-origin guard for mutating runs endpoint[\s\S]*? const gh = \(url/g;
155
+ if (getGuardPattern.test(patched)) {
156
+ patched = patched.replace(getGuardPattern, "$1\n const gh = (url");
157
+ }
141
158
 
142
159
  if (patched === existing) {
143
160
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-anteater",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "AI-powered live editing for your Next.js app",
5
5
  "bin": {
6
6
  "anteater": "bin/setup-anteater.mjs",