MCPcopy
hub / github.com/blitz-js/blitz / MutationGenerator

Class MutationGenerator

packages/generator/src/generators/mutation-generator.ts:11–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11export class MutationGenerator extends Generator<MutationGeneratorOptions> {
12 sourceRoot: SourceRootType
13 isAppDir = false
14 constructor(options: MutationGeneratorOptions) {
15 super(options)
16 this.sourceRoot = getTemplateRoot(options.templateDir, {type: "template", path: "mutation"})
17 this.isAppDir = fs.existsSync(require("path").join(process.cwd(), "src/app/layout.tsx"))
18 }
19 static subdirectory = "mutation"
20
21 // eslint-disable-next-line require-await
22 async getTemplateValues() {
23 return {
24 name: this.options.name,
25 Name: this.options.Name,
26 }
27 }
28
29 getTargetDirectory() {
30 const context = this.options.context ? `${camelCaseToKebabCase(this.options.context)}` : ""
31 if (this.isAppDir) {
32 return `src/app/${context}/mutations`
33 }
34 return `src/${context}/mutations`
35 }
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected