check-dependency
Learn how to check if packages are installed.
This action checks whether required packages are installed and stores the result in a variable.
This is helpful for framework detection or conditionally enabling features based on which packages are available in the project.
Example
The following template checks whether Tailwind CSS is installed and prints the result:
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Dependency check", "description": "Checks for Tailwind CSS.", "actions": [ { "name": "check-dependency", "dependencies": [ { "name": "tailwindcss", "optional": true } ], "result": { "tailwindcss": "hasTailwind" } }, { "name": "print", "message": "Tailwind CSS: ${this.hasTailwind ? 'installed' : 'not installed'}" } ]}Custom help
Without result, the action fails for any missing non-optional dependency. The help property lets you customize the error with a message, suggestions, and links:
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Next.js check", "description": "Verifies that Next.js is installed.", "actions": [ { "name": "check-dependency", "dependencies": [ { "name": "next", "version": ">=14" } ], "help": { "message": "This template requires Next.js 14 or later.", "suggestions": [ "Install Next.js with `npx create-next-app@latest`." ], "links": [ { "label": "Next.js docs", "url": "https://nextjs.org" } ] } } ]}Properties
These are the supported properties:
- namestring
The action identifier. Always check-dependency for this action.
- dependenciesArray<object>
The list of packages to check.
- namestring
The package name to check, for example next or tailwindcss.
- version(optional)string
A version range the installed version must satisfy.
Uses the syntax supported by the project's package manager. When omitted, any installed version is accepted.
- optional(optional)boolean
Whether the dependency is optional.
When true, a missing or incompatible package does not cause the action to fail.
Default:false
- name
- result(optional)object
A map of package names to variable names.
Each variable receives a boolean indicating whether the corresponding package is installed and satisfies the version requirement.
Dependencies listed in the result never cause the action to fail, because the purpose is to let subsequent actions decide what to do rather than failing immediately.
- help(optional)object
Custom error information displayed when a required dependency is missing.
- messagestring
The error message displayed to the user.
- suggestions(optional)Array<string>
A list of actionable suggestions to resolve the issue.
Rendered as a bullet list.
- links(optional)Array<object>
- message