Skip to content

Commit

Permalink
feat(genreator/cli): expose importFormat option
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Dec 22, 2024
1 parent 5b936db commit 4e8b69c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/generator/cli/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { z } from 'zod'
import { toAbsolutePath } from '../../lib/fsp.js'
import { isError, urlParseSafe } from '../../lib/prelude.js'
import { Generator } from '../__.js'
import { type ConfigInit, OutputCase } from '../config/configInit.js'
import { type ConfigInit, ImportFormat, OutputCase } from '../config/configInit.js'

const args = Command.create().description(`Generate a type safe GraphQL client.`)
.parameter(
Expand Down Expand Up @@ -57,6 +57,12 @@ const args = Command.create().description(`Generate a type safe GraphQL client.`
)
.optional(),
)
.parameter(
`importFormat`,
z.nativeEnum(ImportFormat).default(`jsExtension`).describe(
`How should import identifiers be generated? For example "tsExtension" would yield modules that import like "import ... from './foo.ts'".`,
),
)
.settings({
parameters: {
environment: false,
Expand Down Expand Up @@ -119,6 +125,8 @@ if (args.format !== undefined) input.format = args.format
if (args.name !== undefined) input.name = args.name
if (args.output !== undefined) input.outputDirPath = toAbsolutePath(process.cwd(), args.output)

input.importFormat = args.importFormat

// --- Generate ---

await Generator.generate(input)

0 comments on commit 4e8b69c

Please sign in to comment.