@@ -44,13 +44,14 @@ const customTypeNames = new Map([
44
44
[ 'File' , 'FilePayload' ] ,
45
45
] ) ;
46
46
47
- const typesDir = process . argv [ 2 ] || path . join ( __dirname , 'generate_types' , 'csharp' ) ;
48
- const modelsDir = path . join ( typesDir , 'Models' ) ;
49
- const enumsDir = path . join ( typesDir , 'Enums' ) ;
50
- const optionsDir = path . join ( typesDir , 'Options' ) ;
51
- const baseDir = path . join ( typesDir , 'Base' ) ;
52
-
53
- for ( const dir of [ typesDir , modelsDir , enumsDir , optionsDir , baseDir ] )
47
+ const outputDir = process . argv [ 2 ] || path . join ( __dirname , 'generate_types' , 'csharp' ) ;
48
+ const apiDir = path . join ( outputDir , 'API' , 'Generated' ) ;
49
+ const optionsDir = path . join ( outputDir , 'API' , 'Generated' , 'Options' ) ;
50
+ const enumsDir = path . join ( outputDir , 'API' , 'Generated' , 'Enums' ) ;
51
+ const typesDir = path . join ( outputDir , 'API' , 'Generated' , 'Types' ) ;
52
+ const adaptersDir = path . join ( outputDir , 'Generated' , 'Adapters' ) ;
53
+
54
+ for ( const dir of [ apiDir , optionsDir , enumsDir , typesDir , adaptersDir ] )
54
55
fs . mkdirSync ( dir , { recursive : true } ) ;
55
56
56
57
const documentation = parseApi ( path . join ( PROJECT_DIR , 'docs' , 'src' , 'api' ) ) ;
@@ -70,8 +71,7 @@ documentation.setLinkRenderer(item => {
70
71
} ) ;
71
72
72
73
// get the template for a class
73
- const template = fs . readFileSync ( path . join ( __dirname , 'templates' , 'interface.cs' ) , 'utf-8' )
74
- . replace ( '[PW_TOOL_VERSION]' , `${ __filename . substring ( path . join ( __dirname , '..' , '..' ) . length ) . split ( path . sep ) . join ( path . posix . sep ) } ` ) ;
74
+ const template = fs . readFileSync ( path . join ( __dirname , 'templates' , 'interface.cs' ) , 'utf-8' ) ;
75
75
76
76
// we have some "predefined" types, like the mixed state enum, that we can map in advance
77
77
enumTypes . set ( "MixedState" , [ "On" , "Off" , "Mixed" ] ) ;
@@ -128,7 +128,7 @@ function writeFile(kind, name, spec, body, folder, extendsName = null) {
128
128
out . push ( '}' ) ;
129
129
130
130
let content = template . replace ( '[CONTENT]' , out . join ( EOL ) ) ;
131
- fs . writeFileSync ( path . join ( folder , name + '.generated. cs' ) , content ) ;
131
+ fs . writeFileSync ( path . join ( folder , name + '.cs' ) , content ) ;
132
132
}
133
133
134
134
/**
@@ -148,7 +148,7 @@ function renderClass(clazz) {
148
148
name ,
149
149
clazz . spec ,
150
150
body ,
151
- typesDir ,
151
+ apiDir ,
152
152
clazz . extends ? `I${ toTitleCase ( clazz . extends ) } ` : null ) ;
153
153
}
154
154
@@ -180,7 +180,7 @@ function renderBaseClass(clazz) {
180
180
name ,
181
181
[ ] ,
182
182
body ,
183
- baseDir ,
183
+ adaptersDir ,
184
184
null ) ;
185
185
}
186
186
@@ -208,7 +208,7 @@ function renderModelType(name, type) {
208
208
console . log ( type ) ;
209
209
throw new Error ( `Not sure what to do in this case.` ) ;
210
210
}
211
- writeFile ( 'public partial class' , name , null , body , modelsDir ) ;
211
+ writeFile ( 'public partial class' , name , null , body , typesDir ) ;
212
212
}
213
213
214
214
/**
@@ -261,7 +261,7 @@ for (let [name, literals] of enumTypes)
261
261
262
262
if ( process . argv [ 3 ] !== "--skip-format" ) {
263
263
// run the formatting tool for .net, to ensure the files are prepped
264
- execSync ( `dotnet format -f "${ typesDir } " --include-generated --fix-whitespace` ) ;
264
+ execSync ( `dotnet format -f "${ outputDir } " --include-generated --fix-whitespace` ) ;
265
265
}
266
266
267
267
/**
0 commit comments