MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / patchAuditConstants

Function patchAuditConstants

apps/api/scripts/codegen/new-resource.ts:110–130  ·  view source on GitHub ↗
(
  content: string,
  auditKey: string,
  auditValue: string
)

Source from the content-addressed store, hash-verified

108const patchAuditConstants = (
109 content: string,
110 auditKey: string,
111 auditValue: string
112): string => {
113 if (content.includes(`${auditKey}:`)) {
114 return content;
115 }
116
117 // Insert ` KEY: "value",\n` immediately before the closing `} as const;`.
118 const insertion = ` ${auditKey}: "${auditValue}",\n`;
119 const patched = content.replace(/(} as const;)/, `${insertion}$1`);
120
121 if (patched === content) {
122 throw new Error(
123 "Could not auto-patch audit-log.constants.ts; AUDIT_ACTIONS block not found"
124 );
125 }
126
127 return patched;
128};
129
130const patchRelations = (content: string, filePrefix: string): string => {
131 if (content.includes(`export const ${filePrefix}Relations`)) {
132 throw new Error(
133 `Relation "${filePrefix}Relations" already exists in relations.ts`

Callers 1

new-resource.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected