Gathering detailed insights and metrics for composeverter
Gathering detailed insights and metrics for composeverter
Gathering detailed insights and metrics for composeverter
Gathering detailed insights and metrics for composeverter
npm install composeverter
Typescript
Module System
Node Version
NPM Version
71.2
Supply Chain
98.4
Quality
76.9
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
17
This NPM package provides a simple and convenient way to convert Docker Compose files from one version to another. Docker Compose files allow you to define and run multi-container Docker applications, but the format has evolved over time. With this package, you can easily migrate your Compose files between different versions. It also provides some functions to check YAML and test if a given Docker volume mapping is a named one. It also provides a function to validate a Docker Compose file against Docker Compose Common Specification.
You can install this package via NPM:
1npm install composeverter
This package provides four main conversion functions, which you can use to convert Docker Compose files from one format to another. Each function takes the Docker Compose file content as input and returns the content in the target format.
Each of the following functions can take an additional configuration object, with the following properties:
expandVolumes
(optional)boolean
false
Set this parameter to true
if you want to enable expansion of short volume syntax to long volume syntax.
expandPorts
(optional)boolean
false
Set this parameter to true
if you want to enable expansion of short ports mapping syntax to long ports mapping syntax.
migrateFromV1ToV2x(composeContent: string, configuration: Configuration = null): string
Converts a Docker Compose file from V1 to version 2.x.
1const converter = require('composeverter'); 2 3const v1ComposeContent = ` 4web: 5 image: nginx:latest 6`; 7const v2ComposeContent = converter.migrateFromV1ToV2x(v1ComposeContent); 8console.log(v2ComposeContent);
migrateFromV2xToV3x(composeContent: string, configuration: Configuration = null): string
Converts a Docker Compose file from version 2.x to version 3.x.
1const converter = require('composeverter'); 2 3const v2ComposeContent = ` 4version: '2' 5services: 6 web: 7 image: nginx:latest 8`; 9const v3ComposeContent = converter.migrateFromV2xToV3x(v2ComposeContent); 10console.log(v3ComposeContent);
migrateFromV3xToV2x(composeContent: string, configuration: Configuration = null): string
Converts a Docker Compose file from version 3.x to version 2.x.
1const converter = require('composeverter'); 2 3const v3ComposeContent = ` 4version: '3' 5services: 6 web: 7 image: nginx:latest 8`; 9const v2ComposeContent = converter.migrateFromV3xToV2x(v3ComposeContent); 10console.log(v2ComposeContent);
migrateToCommonSpec(composeContent: string, configuration: Configuration = null): string
Automatically migrates a Docker Compose file to the latest version available : Common Specification.
1const converter = require('composeverter'); 2 3const composeContent = ` 4web: 5 image: nginx:latest 6`; 7const latestComposeContent = converter.migrateToCommonSpec(composeContent); 8console.log(latestComposeContent);
With configuration:
1const converter = require('composeverter'); 2 3const composeContent = ` 4web: 5 image: nginx:latest 6`; 7const latestComposeContent = converter.migrateToCommonSpec(composeContent, {expandPorts: true, expandVolumes: true}); 8console.log(latestComposeContent);
getVolumeNameFromVolumeSpec(volumeSpec: string): string
Get the volume name from a Docker Compose volume mapping.
Parameters:
volumeSpec
: A string representing the Docker Compose volume mapping (e.g., "/data2:/app/data2:ro").Returns: The extracted volume name as a string.
isNamedVolume(source: string): boolean
Tell if the given source is a named Docker volume.
Parameters:
source
: A string representing the source of the Docker volume (e.g., "data").Returns: A boolean indicating whether the source is a named Docker volume.
yamlCheck(yaml: string): any
Check YAML validity and return the parsed object if YAML is valid.
Parameters:
yaml
: A string representing the YAML content to be checked.**Throws: **
Throws YamlSyntaxError
if parsing errors occurred. This class has the following members :
message
: concatenated error messageslines
: line numbers that have errorsdetails
: array of messages with the following structure:1{ 2 line: number, 3 message: string, 4 pos: { 5 start: { line: number, col: number }, 6 end: { line: number, col: number } 7 } 8}
Returns: The parsed object if the YAML is valid.
validateDockerComposeToCommonSpec(content: string): any
Check Docker Compose validity against Docker Compose Common Specification and returns validation errors.
Parameters:
content
: A string representing the Docker Compose content to be checked.Returns:
helpLink
is a potential link to Docker Compose documentation):1{ 2 line: number, 3 message: string, 4 helpLink: string 5} 6
getDockerComposeSchemaWithoutFormats(): any
Returns the Docker Compose Common Specification schema (with formats replaced with patterns)
This package is distributed under the MIT License. See the LICENSE file for details.
If you encounter any problems or have suggestions, please open an issue on our GitHub repository.
This package was created and is maintained by ShareVB.
No vulnerabilities found.
No security vulnerabilities found.