|
1 | 1 | import {constants, open} from 'node:fs/promises'
|
2 |
| -import {dirname, join} from 'node:path' |
| 2 | +import {join} from 'node:path' |
3 | 3 |
|
4 |
| -import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli' |
5 | 4 | import {readConfig} from '@sanity/codegen'
|
6 |
| -import readPkgUp from 'read-pkg-up' |
7 | 5 | import {Worker} from 'worker_threads'
|
8 | 6 |
|
| 7 | +import {type CliCommandArguments, type CliCommandContext} from '../../types' |
| 8 | +import {getCliWorkerPath} from '../../util/cliWorker' |
9 | 9 | import {
|
10 | 10 | type TypegenGenerateTypesWorkerData,
|
11 | 11 | type TypegenGenerateTypesWorkerMessage,
|
12 |
| -} from '../../threads/typegenGenerate' |
| 12 | +} from '../../workers/typegenGenerate' |
13 | 13 | import {TypesGeneratedTrace} from './generate.telemetry'
|
14 | 14 |
|
15 | 15 | export interface TypegenGenerateTypesCommandFlags {
|
@@ -42,19 +42,7 @@ export default async function typegenGenerateAction(
|
42 | 42 |
|
43 | 43 | const codegenConfig = await readConfig(flags.configPath || 'sanity-typegen.json')
|
44 | 44 |
|
45 |
| - const rootPkgPath = readPkgUp.sync({cwd: __dirname})?.path |
46 |
| - if (!rootPkgPath) { |
47 |
| - throw new Error('Could not find the root directory for the `sanity` package') |
48 |
| - } |
49 |
| - |
50 |
| - const workerPath = join( |
51 |
| - dirname(rootPkgPath), |
52 |
| - 'lib', |
53 |
| - '_internal', |
54 |
| - 'cli', |
55 |
| - 'threads', |
56 |
| - 'typegenGenerate.js', |
57 |
| - ) |
| 45 | + const workerPath = await getCliWorkerPath('typegenGenerate') |
58 | 46 |
|
59 | 47 | const spinner = output.spinner({}).start('Generating types')
|
60 | 48 |
|
|
0 commit comments