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.
- Transforms
fields
JSON files according to the new specification. - Ensures
presets
JSON files are updated and consistent with the new format. - Retains
metadata.json
andicons
folder unchanged. - Batch processing of all files in the
fields
andpresets
directories.
Install the package globally using npm:
npm install -g mapeo-config-migrate
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_config
folder will be created inside the old configuration directory.
mapeo-config-migrate /path/to/old/config /path/to/new/config
The tool performs the following transformations:
-
Rename
key
totagKey
. -
Convert
type
values:- Replace underscores with camelCase. For example,
select_one
becomesselectOne
.
- Replace underscores with camelCase. For example,
-
Rename
placeholder
tohelperText
. -
Transform
options
array:- Converts options from an array of strings to an array of objects with
label
andvalue
. - 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": false
property:- Sets
universal
tofalse
for all fields.
- Sets
- Ensure key ordering:
- Reorders keys in presets for consistency.
- Retain
metadata.json
andicons
folder unchanged.
To run the test suite and ensure everything works as expected:
npm test
The tests will verify the correctness of the transformations and ensure the script works properly.
Contributions are welcome! Please open an issue or submit a pull request.