You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -131,6 +145,6 @@ export default async function typegenGenerateAction(
131
145
}
132
146
133
147
spinner.succeed(
134
-
`Generated TypeScript types for ${stats.schemas} schema types and ${stats.queries} queries in ${stats.files} files into: ${codegenConfig.generates}`,
148
+
`Generated TypeScript types for ${stats.schemas} schema types and ${stats.queries}GROQ queries in ${stats.files} files into: ${codegenConfig.generates}`,
Copy file name to clipboardExpand all lines: packages/sanity/src/_internal/cli/commands/typegen/generateTypesCommand.ts
+27-15
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,39 @@
1
1
import{typeCliCommandDefinition}from'@sanity/cli'
2
2
3
-
constdescription='Generates types'
3
+
constdescription='Generates TypeScript types from schema types and GROQ queries'
4
4
5
5
consthelpText=`
6
-
**Note**: This command is experimental and subject to change.
6
+
Sanity TypeGen (Beta)
7
+
This command is currently in beta and may undergo significant changes. Feedback is welcome!
7
8
8
-
Options
9
+
Usage
10
+
sanity typegen generate [options]
11
+
12
+
Options:
9
13
--help, -h
10
-
Show this help text.
14
+
Displays this help message, providing information on command usage and options.
15
+
16
+
Examples:
17
+
Generate TypeScript type definitions from a Sanity Studio schema extracted using the \`sanity schema extract\` command.
18
+
$ sanity typegen generate
19
+
20
+
Configuration:
21
+
This command can utilize configuration settings defined in a \`sanity-typegen.json\` file. These settings include:
22
+
23
+
- "path": Specifies a glob pattern to locate your TypeScript or JavaScript files.
24
+
Default: "./src/**/*.{ts,tsx,js,jsx}"
25
+
26
+
- "schema": Defines the path to your Sanity schema file. This file should be generated using the \`sanity schema extract\` command.
27
+
Default: "schema.json"
11
28
12
-
Examples
13
-
# Generate types from a schema, generate schema with "sanity schema extract" first.
14
-
sanity typegen generate
29
+
- "generates": Indicates the path where the generated TypeScript type definitions will be saved.
30
+
Default: "./sanity.types.ts"
15
31
16
-
Configuration
17
-
The command uses the following configuration properties from sanity-typegen.json:
18
-
{
19
-
"path": "'./src/**/*.{ts,tsx,js,jsx}'" // glob pattern to your typescript files
20
-
"schema": "schema.json", // path to your schema file, generated with 'sanity schema extract' command
21
-
"generates": "./sanity.types.ts" // path to the file where the types will be generated
22
-
}
32
+
The default configuration values listed above are used if not overridden in your \`sanity-typegen.json\` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.
23
33
24
-
The listed properties are the default values, and can be overridden in the configuration file.
34
+
Note:
35
+
- The \`sanity schema extract\` command is a prerequisite for extracting your Sanity Studio schema into a \`schema.json\` file, which is then used by the \`sanity typegen generate\` command to generate type definitions.
36
+
- While this tool is in beta, we encourage you to experiment with these configurations and provide feedback to help improve its functionality and usability.
0 commit comments