@anthusai/papyrus 2.0.0-next.104 → 2.0.0-next.105

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 CHANGED
@@ -456,7 +456,7 @@
456
456
  "optional": true
457
457
  }
458
458
  },
459
- "version": "2.0.0-next.104",
459
+ "version": "2.0.0-next.105",
460
460
  "dependencies": {
461
461
  "@aws-amplify/adapter-nextjs": "^1.7.3",
462
462
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.0-next.104",
2
+ "version": "2.0.0-next.105",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
package/src/sync.mjs CHANGED
@@ -37,6 +37,15 @@ function shimFor(route) {
37
37
  return lines.join("\n") + "\n";
38
38
  }
39
39
 
40
+ /** Anchored .gitignore line for a literal path; escapes gitignore metacharacters (Next dynamic routes use [ ]). */
41
+ export function gitignoreEntry(rel) {
42
+ const escaped = rel
43
+ .replace(/[\\[\]*?]/g, "\\$&")
44
+ .replace(/^[#!]/, "\\$&")
45
+ .replace(/ +$/, (m) => m.replace(/ /g, "\\ "));
46
+ return "/" + escaped;
47
+ }
48
+
40
49
  export function middlewareShim(manifest) {
41
50
  const matcher = manifest.middleware.matcher ?? '["/((?!_next/static|_next/image|favicon.ico|icon).*)"]';
42
51
  return [
@@ -101,9 +110,9 @@ export function sync({ root = process.cwd(), log = console.log, manifest: manife
101
110
  // Keep generated shims out of git.
102
111
  const giFile = path.join(root, ".gitignore");
103
112
  const gi = fs.existsSync(giFile) ? fs.readFileSync(giFile, "utf8") : "";
104
- const block = [GITIGNORE_BEGIN, ...generated.map((g) => "/" + g), "/.papyrus/", GITIGNORE_END].join("\n");
113
+ const block = [GITIGNORE_BEGIN, ...generated.map(gitignoreEntry), "/.papyrus/", GITIGNORE_END].join("\n");
105
114
  const re = new RegExp(`${GITIGNORE_BEGIN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${GITIGNORE_END}`);
106
- fs.writeFileSync(giFile, re.test(gi) ? gi.replace(re, block) : `${gi}${gi.endsWith("\n") || !gi ? "" : "\n"}${block}\n`);
115
+ fs.writeFileSync(giFile, re.test(gi) ? gi.replace(re, () => block) : `${gi}${gi.endsWith("\n") || !gi ? "" : "\n"}${block}\n`);
107
116
 
108
117
  log(`papyrus-app sync: ${generated.length} shim(s) written, ${skipped.length} site-owned file(s) kept (${PKG}@${manifest.version})${readerBasePath ? `, reader mounted at ${readerBasePath}` : ""}`);
109
118
  for (const rel of skipped) log(` site-owned: ${rel}`);