This tool helps migrate Bookshop components to CloudCannon's new split configuration format.
- Scans for Bookshop files: Finds all
*.bookshop.{yml,yaml,json,toml}files in your project - Transforms the structure:
- Removes
specand moves its subkeys (exceptstructures) to the root - Renames
blueprinttovalue - Preserves
_inputsandpreviewas-is - Adds
_namefield to thevaluebased on the file path
- Removes
- Tracks structures: Maps which files reference which structures
- Generates CloudCannon config: Creates the necessary split config files
- Creates output files: Saves transformed files with matching extensions:
.bookshop.yml→.cloudcannon.structure-value.yml.bookshop.json→.cloudcannon.structure-value.json.bookshop.toml→.cloudcannon.structure-value.yml(converted to YAML)
cd migration-tools
npm installnpm run migrateOr run directly:
node migrate.js| Input Format | Output Format | Notes |
|---|---|---|
.bookshop.yml |
.cloudcannon.structure-value.yml |
Standard YAML format |
.bookshop.yaml |
.cloudcannon.structure-value.yml |
Alternative YAML extension |
.bookshop.json |
.cloudcannon.structure-value.json |
JSON format preserved |
.bookshop.toml |
.cloudcannon.structure-value.yml |
TOML converted to YAML |
Input (src/components/about/team/team.bookshop.yml):
spec:
structures:
- content_blocks
label: About Team
description: About Team section
icon: "groups"
tags: []
blueprint:
title: Our leadership & Team Members
team_members:
- name: Cody Fisher
designation: Co-Founder & CEO
preview:
_inputs:
image:
type: imageOutput (src/components/about/team/team.cloudcannon.structure-value.yml):
label: About Team
description: About Team section
icon: groups
tags: []
value:
title: Our leadership & Team Members
team_members:
- name: Cody Fisher
designation: Co-Founder & CEO
_name: about/team
preview:
_inputs:
image:
type: imageJSON Input Example (src/components/hero/hero.bookshop.json):
{
"spec": {
"structures": ["content_blocks"],
"label": "Hero Component",
"icon": "hero"
},
"blueprint": {
"title": "Welcome to our site"
},
"_inputs": {
"title": {
"type": "text"
}
}
}JSON Output (src/components/hero/hero.cloudcannon.structure-value.json):
{
"label": "Hero Component",
"icon": "hero",
"value": {
"title": "Welcome to our site",
"_name": "hero"
},
"_inputs": {
"title": {
"type": "text"
}
}
}The tool creates:
- Individual structure value files:
*.cloudcannon.structure-value.ymlnext to each original bookshop file - Structures configuration:
.cloudcannon/components.cloudcannon.structures.yml - Main config:
cloudcannon.config.yml(if it doesn't exist) - Migration report:
migration-tools/migration-report.json
File paths are converted to IDs by extracting the component path:
src/components/about/team/team.bookshop.yml→about/teamsrc/components/global/faq/faq.bookshop.yml→global/faq
Run the test suite:
npm testAfter migration, you'll have:
- All original
.bookshop.ymlfiles preserved - New
.cloudcannon.structure-value.ymlfiles created - CloudCannon split config files in
.cloudcannon/directory - A detailed migration report in JSON format
- Review the generated files
- Test your components in CloudCannon
- Remove original
.bookshop.ymlfiles when satisfied - Commit the new CloudCannon configuration
This tool is designed to be portable and can be:
- Copied to other projects
- Published as an npm package
- Integrated into build processes