mapeo-config-migrate
v1.0.0
Published
A tool to migrate Mapeo configuration files.
Readme
Mapeo Config Migrator
A command-line tool to transform old Mapeo configuration folders into the new format. This utility converts the old fields and presets JSON files to the new structure expected by Mapeo.
Features
- Transforms
fieldsJSON files according to the new specification. - Ensures
presetsJSON files are updated and consistent with the new format. - Retains
metadata.jsonandiconsfolder unchanged. - Batch processing of all files in the
fieldsandpresetsdirectories.
Installation
Install the package globally using npm:
npm install -g mapeo-config-migrateUsage
After installation, you can use the mapeo-config-migrate command in your terminal.
mapeo-config-migrate <path-to-old-config> [path-to-new-config]<path-to-old-config>: (Required) The path to your old Mapeo configuration folder.[path-to-new-config]: (Optional) The path where the new configuration will be created. If not specified, anew_configfolder will be created inside the old configuration directory.
Example
mapeo-config-migrate /path/to/old/config /path/to/new/configDetailed Explanation
The tool performs the following transformations:
Fields
Rename
keytotagKey.Convert
typevalues:- Replace underscores with camelCase. For example,
select_onebecomesselectOne.
- Replace underscores with camelCase. For example,
Rename
placeholdertohelperText.Transform
optionsarray:- Converts options from an array of strings to an array of objects with
labelandvalue. - Example:
Becomes:"options": ["Option1", "Option2"]"options": [ { "label": "Option1", "value": "Option1" }, { "label": "Option2", "value": "Option2" } ]
- Converts options from an array of strings to an array of objects with
Add
"universal": falseproperty:- Sets
universaltofalsefor all fields.
- Sets
Presets
- Ensure key ordering:
- Reorders keys in presets for consistency.
Metadata and Icons
- Retain
metadata.jsonandiconsfolder unchanged.
Running Tests
To run the test suite and ensure everything works as expected:
npm testThe tests will verify the correctness of the transformations and ensure the script works properly.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
