[ ] Chore (a non-breaking change which is related to package maintenance)
[ ] Bug fix (a non-breaking change which fixes an issue)
[x] New feature (a non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
This PR adds an init command to the CLI. It bootstraps a config file.
npx prismic-ts-codegen init
By default, it will create a file at prismicCodegen.config.ts, which is the default location the CLI will read when generating types. This path can be configured using the --config (-c) flag.
npx prismic-ts-codegen init -c custom.config.ts
It will generate the following contents by default:
import type { Config } from "prismic-ts-codegen";
const config: Config = {
output: "./types.generated.ts",
};
export default config;
If the CLI detects that the project a Slice Machine project, it will generate the following contents:
This gives Slice Machine users a quick way to generate types without hiding behind Slice Machine-specific flags (e.g. config.sliceMachine: true).
In the future, this init command could be more sophisticated by reading sm.json to extract the repository name and Slice Library locations. The current simple contents will work for now.
Checklist:
[ ] My change requires an update to the official documentation.
[ ] All TSDoc comments are up-to-date and new ones have been added where necessary.
Types of changes
Description
This PR adds an
init
command to the CLI. It bootstraps a config file.By default, it will create a file at
prismicCodegen.config.ts
, which is the default location the CLI will read when generating types. This path can be configured using the--config
(-c
) flag.It will generate the following contents by default:
If the CLI detects that the project a Slice Machine project, it will generate the following contents:
This gives Slice Machine users a quick way to generate types without hiding behind Slice Machine-specific flags (e.g.
config.sliceMachine: true
).In the future, this
init
command could be more sophisticated by readingsm.json
to extract the repository name and Slice Library locations. The current simple contents will work for now.Checklist:
🚃