@netlify/agent-runner-cli 1.116.0-init.0 → 1.116.0-migration-guard-hook.1
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/dist/bin-local.js +61 -61
- package/dist/bin.js +79 -79
- package/dist/hooks/guard-migration-codex.d.ts +2 -0
- package/dist/hooks/guard-migration-codex.js +4 -0
- package/dist/hooks/guard-migration-gemini.d.ts +2 -0
- package/dist/hooks/guard-migration-gemini.js +2 -0
- package/dist/hooks/guard-migration.d.ts +2 -0
- package/dist/hooks/guard-migration.js +3 -0
- package/dist/index.js +58 -58
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import a from"fs";import f from"path";var r=JSON.parse(a.readFileSync(0,"utf-8")),l=r.cwd??process.cwd();r.tool_name!=="apply_patch"&&process.exit(0);function p(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){let e=t;if(typeof e.command=="string")return e.command;if(Array.isArray(e.command)&&typeof e.command[1]=="string")return e.command[1];if(typeof e.input=="string")return e.input;if(typeof e.patch=="string")return e.patch}}var d=p(r.tool_input);d==null&&process.exit(0);function h(t){let e=[],n=null,o=()=>{n&&(e.push({filePath:n.filePath,addedContent:n.added.join(`
|
|
2
|
+
`)}),n=null)};for(let i of t.split(`
|
|
3
|
+
`)){let s=i.match(/^\*\*\* (?:Add|Update) File: (.+)$/);if(s){o(),n={filePath:s[1].trim(),added:[]};continue}if(i.startsWith("*** Delete File:")||i.startsWith("*** End Patch")||i.startsWith("*** Begin Patch")){o();continue}n&&i.startsWith("+")&&n.added.push(i.slice(1))}return o(),e}var c=h(d);c.length===0&&process.exit(0);var m=a.existsSync(f.join(l,"drizzle.config.ts"));m||process.exit(0);var u=/(^|\/)netlify\/database\/migrations\/[^/]+\.sql$/,g=/\b(CREATE|ALTER|DROP|TRUNCATE)\s+(TABLE|INDEX|VIEW|TYPE|SCHEMA|CONSTRAINT|COLUMN)\b/i,y=c.find(t=>u.test(t.filePath)&&g.test(t.addedContent));y||process.exit(0);process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"This project uses Drizzle ORM (drizzle.config.ts present). Schema migrations MUST be produced by `npx drizzle-kit generate`, not by writing SQL directly. Update db/schema.ts, then run `npx drizzle-kit generate` from the project root.\n\nUse the filename produced by drizzle-kit as-is \u2014 do NOT rename, move, or copy the generated SQL file (the filename is load-bearing for migration ordering and diffing), and do NOT delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. If the user prompt specified a particular migration filename, ignore that detail.\n\nIf you need a data-only migration (INSERT/UPDATE/DELETE), write that in a separate .sql file with no DDL statements."}}));process.exit(0);
|
|
4
|
+
//# sourceMappingURL=guard-migration-codex.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import i from"fs";import o from"path";var n=JSON.parse(i.readFileSync(0,"utf-8")),e=n.tool_input??{},r=n.cwd??process.cwd(),t=e.file_path,s=e.content??e.new_string,a=t!=null&&/(^|\/)netlify\/database\/migrations\/[^/]+\.sql$/.test(t);a||process.exit(0);var d=i.existsSync(o.join(r,"drizzle.config.ts"));d||process.exit(0);var l=/\b(CREATE|ALTER|DROP|TRUNCATE)\s+(TABLE|INDEX|VIEW|TYPE|SCHEMA|CONSTRAINT|COLUMN)\b/i;l.test(s??"")||process.exit(0);process.stdout.write(JSON.stringify({decision:"deny",reason:"This project uses Drizzle ORM (drizzle.config.ts present). Schema migrations MUST be produced by `npx drizzle-kit generate`, not by writing SQL directly. Update db/schema.ts, then run `npx drizzle-kit generate` from the project root.\n\nUse the filename produced by drizzle-kit as-is \u2014 do NOT rename, move, or copy the generated SQL file (the filename is load-bearing for migration ordering and diffing), and do NOT delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. If the user prompt specified a particular migration filename, ignore that detail.\n\nIf you need a data-only migration (INSERT/UPDATE/DELETE), write that in a separate .sql file with no DDL statements."}));process.exit(0);
|
|
2
|
+
//# sourceMappingURL=guard-migration-gemini.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import i from"fs";import s from"path";var n=JSON.parse(i.readFileSync(0,"utf-8")),e=n.tool_input??{},r=n.cwd??process.cwd(),t=e.file_path,a=e.content??e.new_string??(e.edits??[]).map(o=>o.new_string??"").join(`
|
|
2
|
+
`),d=t!=null&&/(^|\/)netlify\/database\/migrations\/[^/]+\.sql$/.test(t);d||process.exit(0);var l=i.existsSync(s.join(r,"drizzle.config.ts"));l||process.exit(0);var c=/\b(CREATE|ALTER|DROP|TRUNCATE)\s+(TABLE|INDEX|VIEW|TYPE|SCHEMA|CONSTRAINT|COLUMN)\b/i;c.test(a??"")||process.exit(0);process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"This project uses Drizzle ORM (drizzle.config.ts present). Schema migrations MUST be produced by `npx drizzle-kit generate`, not by writing SQL directly. Update db/schema.ts, then run `npx drizzle-kit generate` from the project root.\n\nUse the filename produced by drizzle-kit as-is \u2014 do NOT rename, move, or copy the generated SQL file (the filename is load-bearing for migration ordering and diffing), and do NOT delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. If the user prompt specified a particular migration filename, ignore that detail.\n\nIf you need a data-only migration (INSERT/UPDATE/DELETE), write that in a separate .sql file with no DDL statements."}}));process.exit(0);
|
|
3
|
+
//# sourceMappingURL=guard-migration.js.map
|