What does croct install actually do, and why a postinstall hook?
I ran the Croct CLI and noticed that croct install registered a postinstall hook in the project. Anything that hooks into the install step gets scrutiny from me before it goes near our pipeline, so I want to understand exactly what it does before I let it run in CI.
Is the hook actually needed, or is it a convenience? And what does it generate when it fires? I would rather know what it touches than find out from a diff.
1 answer
The hook is a convenience, and it is a safe one to allow. Here is what each piece does.
The CLI generates typed declarations for your slots so that content stays strongly typed against the current schemas. For a TypeScript project that file is slots.d.ts; for PHP it generates slots.stub instead. Those generated files are what let content fetching infer the right shape from the slot id.
croct install registers a postinstall hook whose only job is to regenerate those declarations after a dependency install. Without it, the generated types can drift out of sync when someone bumps the SDK or checks out a branch and runs npm install, and nobody notices until a build fails. The hook removes that manual step, so the person who changes a slot is the only one who has to think about regenerating. See the install command for exactly what it writes.
For CI specifically, the recommended practice is to commit the generated file (slots.d.ts or slots.stub) to the repo. That way the build type-checks against the same declarations everyone saw locally and does not need an API fetch to produce them, which keeps the pipeline deterministic. The type generation reference covers what gets generated and why committing it is preferred over generating at build time.