Seeding
Automatically add recommended files to your Robo.
Plugins can recommend or require certain files to be present in your project. Seeding automates this process.
Seed on Install
When you install a plugin with the Robo CLI, you may be prompted to include recommended files:
robo add @robojs/server@nextFor example, the @robojs/server plugin may seed optional files in /src/api demonstrating how to use it. These are optional and can be deleted.
You can deny seeding by using the --no-seed flag or by entering n when prompted:
📦 Installing plugin
✔ @robojs/server@next
🌱 Seed files detected
- @robojs/server@next: Example API route and index page
Would you like to include these files? [Y/n]: n
✨ Plugin successfully installed and ready to use.If you opted out of seeding, you can always add the files later by running robo add again.
TypeScript
Seeds detect whether you are using TypeScript and will seed .ts files instead of .js when available.
However, this only works if the plugin developer provided TypeScript files in the seed. If they did not, you will receive JavaScript files regardless of your project's language.
If you are a plugin developer, providing .ts files in the seed is recommended even if your plugin is not written in TypeScript. The Robo Compiler automatically compiles them to JavaScript for projects that do not use TypeScript. You can also provide both .ts and .js files for finer control over the output.
Use Cases
Seeding is useful for a variety of purposes:
- Example files to get started
- Configuration files
- Database files
- Complex setups
- Boilerplate code
Plugins can seed anything they need, and you decide whether to include the files.
Plugin Developers
To seed files from your plugin, create a /seed folder in your plugin's root directory.
Files in /seed are copied to the user's /src directory. To copy files into the project root, use the /seed/_root folder:
When the user installs your plugin, these files are copied to their project if they approve.
A description of the seeded files is recommended to help users understand what they are getting. Add it to your plugin's Robo Config:
// config/robo.mjs
export default {
// ... rest of config
seed: {
description: 'Example API route and index page'
}
}When users install your plugin with robo add, they see this description before deciding to include the files.
Limitations
Seeds cannot modify existing files in the project for security reasons. They can only add new files.
Seeds can only affect the Robo project they are installed in. They cannot modify other projects or files outside of the project's directory.
