|
1 | 1 | import { CAC } from '@stacksjs/cli'
|
2 | 2 | import { version } from '../package.json'
|
3 | 3 | import { generate } from '../src/generate'
|
4 |
| -import type { DtsGenerationOption } from '../src/types' |
| 4 | +import type { DtsGenerationOption, DtsGenerationConfig } from '../src/types' |
5 | 5 | import { resolve } from 'node:path'
|
6 | 6 |
|
7 | 7 | const cli = new CAC('dtsx')
|
8 | 8 |
|
9 |
| -const defaultOptions: DtsGenerationOption = { |
| 9 | +const defaultOptions: DtsGenerationConfig = { |
10 | 10 | cwd: process.cwd(),
|
11 | 11 | root: './src',
|
12 | 12 | entrypoints: ['**/*.ts'],
|
|
33 | 33 | .example('dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types')
|
34 | 34 | .action(async (options: DtsGenerationOption) => {
|
35 | 35 | try {
|
36 |
| - const mergedOptions: DtsGenerationOption = { |
37 |
| - ...defaultOptions, |
38 |
| - ...options, |
39 |
| - entrypoints: options.entrypoints ? options.entrypoints.split(',') : defaultOptions.entrypoints, |
| 36 | + const config: DtsGenerationConfig = { |
| 37 | + entrypoints: options.entrypoints ? options.entrypoints : defaultOptions.entrypoints, |
40 | 38 | cwd: resolve(options.cwd || defaultOptions.cwd),
|
41 | 39 | root: resolve(options.root || defaultOptions.root),
|
42 | 40 | outdir: resolve(options.outdir || defaultOptions.outdir),
|
43 | 41 | tsconfigPath: resolve(options.tsconfigPath || defaultOptions.tsconfigPath),
|
| 42 | + keepComments: options.keepComments || defaultOptions.keepComments, |
| 43 | + clean: options.clean || defaultOptions.clean, |
44 | 44 | }
|
45 | 45 |
|
46 | 46 | // if (options.verbose) {
|
47 | 47 | // console.log('Using options:', mergedOptions)
|
48 | 48 | // }
|
49 | 49 |
|
50 |
| - await generate(mergedOptions) |
| 50 | + await generate(config) |
51 | 51 | } catch (error) {
|
52 | 52 | console.error('Error generating .d.ts files:', error)
|
53 | 53 | process.exit(1)
|
|
0 commit comments