Management script for components, including version management and custom commands
npm install @squiz/vermgmtverMgmt is a version management script for Component Service, designed to easily increment or decrement the versions of components included in the manifest.json files. Additionally, it allows running custom commands on project components, such as deploying and listing files inside a component's folder.
All commands, including increment, decrement, and custom commands, can be executed for a single selected component or multiple selected components.
To install verMgmt, use the following command:
``sh`
npm i @squiz/verMgmt
After installation, add the following script to your package.json:
`json`
{
"scripts": {
"vermgmt": "vermgmt"
}
}
Then, verMgmt can be used by running:
`sh`
npm run vermgmt
This will start the script and present a list of options to manage components' versions or run custom commands.
[Optional] For direct use run command:
`sh `
node ./bin/verMgmt.js ./verMgmt.config.json
By default, verMgmt is configured to look for manifest files in the following path:
`json`
{
"manifestGlob": "components/*/manifest.json"
}
This configuration can be overridden by creating a verMgmt.config.json file in the project root directory. This allows customization of paths and addition of custom commands to suit the project's needs.
Example verMgmt.config.json:
`json`
{
"manifestGlob": "components/*/src/manifest.json",
"customCommands": [
{
"name": "Build and deploy",
"value": "npm run build && npx @squiz/dxp-cli-next cmp deploy ."
},
{
"name": "List root files (command: ls -l)",
"value": "ls -l"
}
]
}
The configuration file can also contain an array of configuration objects. When multiple configurations are found, the script will prompt the user to select one.
Example verMgmt.config.json with multiple configurations:
`json``
[
{
"name": "Development",
"manifestGlob": "components/dev/*/manifest.json",
"customCommands": [
{
"name": "Build and deploy",
"value": "npm run build && npx @squiz/dxp-cli-next cmp deploy ."
},
{
"name": "List root files (command: ls -l)",
"value": "ls -l"
}
]
},
{
"name": "Production",
"manifestGlob": "components/prod/*/manifest.json",
"customCommands": [
{
"name": "Build and deploy",
"value": "npm run build && npx @squiz/dxp-cli-next cmp deploy ."
},
{
"name": "List root files (command: ls -l)",
"value": "ls -l"
}
]
}
]
Additionally, it may be necessary to adjust the deployment path to match the location where the build files are stored.
When running the script, the following options are available:
- Increment version: Increments the version of the selected components.
- Decrement version: Decrements the version of the selected components.
- Set arbitrary version: Allows setting an arbitrary version for the selected components.
- Run custom command: Executes a custom command defined in the configuration file on the selected components.
- Change configuration: Allows switching between multiple configurations if more than one is defined.
- Quit: Exits the script.
Pull requests are welcome. For major changes, please open an issue first to discuss the proposed changes.
Please make sure to update tests as appropriate.