MCPcopy Create free account
hub / github.com/callstackincubator/polygen / Codegen

Class Codegen

packages/codegen/src/codegen.ts:87–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85 * The generator is not reentrant, and should be used only once.
86 */
87export class Codegen {
88 /**
89 * The project configuration to generate code for.
90 */
91 public readonly project: Project;
92
93 /**
94 * Configuration options for the generation process.
95 */
96 public readonly options: CodegenOptions;
97
98 /**
99 * Shared context for all modules.
100 *
101 * Holds codegen state and module information.
102 */
103 public readonly context: CodegenContext;
104
105 /**
106 * Collection of plugins to dispatch.
107 */
108 public plugins: Plugin[];
109
110 /**
111 * Output generator instance used to write generated files to disk.
112 */
113 private readonly generator: OutputGenerator;
114
115 /**
116 * Creates a new W2CGenerator instance for the specified project and options.
117 *
118 * @see create
119 */
120 private constructor(
121 project: Project,
122 options: CodegenOptions = {},
123 previousWrittenFiles?: WrittenFilesMap,
124 plugins?: Plugin[]
125 ) {
126 this.project = project;
127 this.options = options;
128 this.context = new CodegenContext();
129 this.plugins = plugins ?? DEFAULT_PLUGINS;
130 this.generator = new OutputGenerator(
131 {
132 outputDirectory: this.outputDirectory,
133 assetsDirectory: ASSETS_DIR,
134 forceGenerate: options.forceGenerate,
135 },
136 previousWrittenFiles
137 );
138 }
139
140 /**
141 * Creates a new W2CGenerator instance for the specified project and options.
142 *
143 * @param project The project configuration to generate code for.
144 * @param options Optional configuration for the generation process.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected