File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ async function main() {
25
25
'schema' : { type : 'string' , short : 's' } ,
26
26
'connection-source' : { type : 'string' , short : 'c' } ,
27
27
'output-dir' : { type : 'string' , short : 'o' } ,
28
+ 'output-import-ext' : { type : 'string' } ,
28
29
'remove-extraneous' : { type : 'string' } ,
29
30
'export-table-instances' : { type : 'boolean' } ,
30
31
'export-row-types' : { type : 'boolean' } ,
@@ -47,6 +48,11 @@ async function main() {
47
48
connectionSourcePath : argv [ "connection-source" ] ,
48
49
outputDirPath : argv [ "output-dir" ] ,
49
50
removeExtraneous : argv [ "remove-extraneous" ] ?? "never" ,
51
+ output : {
52
+ import : {
53
+ extension : argv [ "output-import-ext" ] ,
54
+ }
55
+ } ,
50
56
export : {
51
57
tableInstances : argv [ 'export-table-instances' ] ,
52
58
tableClasses : argv [ 'export-table-classes' ] ,
Original file line number Diff line number Diff line change @@ -297,6 +297,14 @@ export const TypeWrapperSchema = z.object({
297
297
wrapper : ImportedItemSchema
298
298
} ) ;
299
299
300
+ export const OutputImportOptionsSchema = z . object ( {
301
+ extension : z . string ( ) . nullish ( ) ,
302
+ } ) ;
303
+
304
+ export const OutputOptionsSchema = z . object ( {
305
+ import : OutputImportOptionsSchema . nullish ( ) ,
306
+ } ) ;
307
+
300
308
export const GeneratorOptsSchema = z . object ( {
301
309
/** Simulate the generation and print the outcome without actually modifying any files */
302
310
dryRun : z . boolean ( ) . nullish ( ) ,
@@ -341,6 +349,11 @@ export const GeneratorOptsSchema = z.object({
341
349
*/
342
350
tables : TableInclusionSchema . nullish ( ) ,
343
351
352
+ /**
353
+ * Shared options that affect all generated output
354
+ */
355
+ output : OutputOptionsSchema . nullish ( ) ,
356
+
344
357
/**
345
358
* Customize what all entities are exported from generated file
346
359
*
Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ export class Generator {
180
180
comment : this . formatComment ( [ table . comment ] ) ,
181
181
idPrefix,
182
182
} ,
183
+ output : this . opts . output ,
183
184
imports : [
184
185
...utilImports ,
185
186
...adapterImports ,
Original file line number Diff line number Diff line change 5
5
* This file has been auto-generated from database schema using ts-sql-codegen.
6
6
* Any changes will be overwritten.
7
7
*/
8
- import { {{ table.kind }} } from "ts-sql-query/{{ table.kind }} ";
9
- import type { DBConnection } from "{{ dbConnectionSource }} ";
8
+ import { {{ table.kind }} } from "ts-sql-query/{{ table.kind }}{{ output.import.extension }} ";
9
+ import type { DBConnection } from "{{ dbConnectionSource }}{{ output.import.extension }} ";
10
10
{{ #if importExtraTypes }}
11
11
import {
12
12
{{ #if rowTypes.insertable }}
@@ -29,13 +29,13 @@ import {
29
29
{{ #if valuesTypes.selected }}
30
30
SelectedValues,
31
31
{{ /if }}
32
- } from "ts-sql-query/extras/types";
32
+ } from "ts-sql-query/extras/types{{ output.import.extension }} ";
33
33
{{ /if }}
34
34
{{ #each imports }}
35
35
{{ #if isDefault }}
36
36
{{ #each imported }}
37
37
{{ #dedent-by 4 " level" }}
38
- import {{ . }} from "{{ ../importPath }} ";
38
+ import {{ . }} from "{{ ../importPath }}{{ output.import.extension }} ";
39
39
{{ /dedent-by }}
40
40
{{ /each }}
41
41
{{ else }}
@@ -46,7 +46,7 @@ import {
46
46
{{ . }} ,
47
47
{{ /each }}
48
48
{{ /dedent-by }}
49
- } from "{{ importPath }} ";
49
+ } from "{{ importPath }}{{ output.import.extension }} ";
50
50
{{ /dedent-by }}
51
51
{{ /if }}
52
52
{{ /each }}
You can’t perform that action at this time.
0 commit comments