Closed angeloashmore closed 1 year ago
Merging #42 (f95689a) into main (00814a9) will decrease coverage by
0.88%
. The diff coverage is84.31%
.
:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.
@@ Coverage Diff @@
## main #42 +/- ##
==========================================
- Coverage 98.75% 97.87% -0.88%
==========================================
Files 22 23 +1
Lines 1601 1644 +43
Branches 135 136 +1
==========================================
+ Hits 1581 1609 +28
- Misses 20 35 +15
Impacted Files | Coverage Δ | |
---|---|---|
src/detectTypesProvider.ts | 53.12% <53.12%> (ø) |
|
src/lib/addInterfacePropertiesForFields.ts | 98.65% <96.55%> (ø) |
|
src/constants.ts | 100.00% <100.00%> (ø) |
|
src/generateTypes.ts | 100.00% <100.00%> (ø) |
|
src/index.ts | 100.00% <100.00%> (ø) |
|
src/lib/addTypeAliasForCustomType.ts | 100.00% <100.00%> (ø) |
|
src/lib/addTypeAliasForSharedSlice.ts | 100.00% <100.00%> (ø) |
|
src/lib/buildFieldDocs.ts | 100.00% <100.00%> (ø) |
|
src/lib/getAPIIDPath.ts | 100.00% <100.00%> (ø) |
|
src/lib/getFieldDocumentationURL.ts | 100.00% <100.00%> (ø) |
|
... and 7 more |
Types of changes
Description
This PR allows
prismic-ts-codegen
to use different type providers. The following providers are supported:@prismicio/client
(at least v7)@prismicio/types
- default@prismicio/types
is used by default for backwards compatibility, but@prismicio/client
is preferred since@prismicio/types
is now deprecated.@prismicio/types
was merged into@prismicio/client
v7.This PR also adds a
detectTypesProvider()
helper. See below for more details.prismic-ts-codegen
CLIThe
prismic-ts-codegen
CLI can be configured using aprismicCodegen.config.ts
file.A new
typesProvider
option allows for configuring the package used in the generated types file. If no value is provided, the correct provider is automatically detected. If one cannot be detected,@prismicio/types
is used.The generated file's import statement will reflect the
typesProvider
value.generateTypes()
The
generateTypes()
function accepts a newtypesProvider
option that specifies the package used in the generated types file. If no value is provided,@prismicio/types
is used.The output's import statement will reflect the
typesProvider
value.detectTypesProvider()
The
detectTypesProvider()
helper attemps to detect a Node.js project's type provider. It loads@prismicio/client
and@prismicio/types
to determine which package is available, if any.@prismicio/client
v7 and above is supported. If <6 is found, it is ignored.If no provider is detected, the helper returns
undefined
.This function can be used in combination with
generateTypes()
if automatic types provider detection is desired when generating types.Checklist:
🐃