docker-composer 4.1.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.yml +9 -0
- package/README.md +6 -4
- package/ReleaseNotes.md +9 -0
- package/index.d.ts +27 -15
- package/index.js +11 -15
- package/lib/lib.js +24 -0
- package/package.json +8 -15
- package/scripts/compile-ts-types.js +16 -0
package/.eslintrc.yml
ADDED
package/README.md
CHANGED
|
@@ -14,8 +14,10 @@ Docker Compose Reference is [HERE](https://docs.docker.com/compose/compose-file/
|
|
|
14
14
|
|
|
15
15
|
### Changes of the Latest Release
|
|
16
16
|
|
|
17
|
-
## Version
|
|
18
|
-
-
|
|
17
|
+
## Version 5.0.0 (29.12.2022)
|
|
18
|
+
- Reorganize code base
|
|
19
|
+
- Update dependencies
|
|
20
|
+
- Change code style
|
|
19
21
|
|
|
20
22
|
You can find all Release Notes [HERE](https://github.com/tudvari/docker-composer/blob/master/ReleaseNotes.md).
|
|
21
23
|
|
|
@@ -23,9 +25,9 @@ You can find all Release Notes [HERE](https://github.com/tudvari/docker-composer
|
|
|
23
25
|
|
|
24
26
|
```javascript
|
|
25
27
|
|
|
26
|
-
const composer = require('docker-composer')
|
|
28
|
+
const composer = require('docker-composer');
|
|
27
29
|
.
|
|
28
|
-
|
|
30
|
+
const generatedYML = composer.generate(inputJSON);
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
## Full Example
|
package/ReleaseNotes.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## Version 5.0.0 (29.12.2022)
|
|
4
|
+
- Reorganize code base
|
|
5
|
+
- Update dependencies
|
|
6
|
+
- Change code style
|
|
7
|
+
|
|
8
|
+
## Version 4.1.3 (22.12.2022)
|
|
9
|
+
- Remove gulp
|
|
10
|
+
- Update dependencies
|
|
11
|
+
|
|
3
12
|
## Version 4.1.2 (05.11.2022)
|
|
4
13
|
- Maintenance release, dependency updates
|
|
5
14
|
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
export type DefinitionsDeployment = {
|
|
2
9
|
mode?: string;
|
|
3
10
|
replicas?: number;
|
|
@@ -22,7 +29,17 @@ export type DefinitionsDeployment = {
|
|
|
22
29
|
placement?: {
|
|
23
30
|
constraints?: string[];
|
|
24
31
|
};
|
|
25
|
-
} &
|
|
32
|
+
} & Deployment;
|
|
33
|
+
export type Labels =
|
|
34
|
+
| {
|
|
35
|
+
/**
|
|
36
|
+
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
37
|
+
* via the `patternProperty` ".+".
|
|
38
|
+
*/
|
|
39
|
+
[k: string]: string;
|
|
40
|
+
}
|
|
41
|
+
| string[];
|
|
42
|
+
export type Deployment = {
|
|
26
43
|
mode?: string;
|
|
27
44
|
replicas?: number;
|
|
28
45
|
labels?: Labels;
|
|
@@ -46,16 +63,7 @@ export type DefinitionsDeployment = {
|
|
|
46
63
|
placement?: {
|
|
47
64
|
constraints?: string[];
|
|
48
65
|
};
|
|
49
|
-
} | null
|
|
50
|
-
export type Labels =
|
|
51
|
-
| {
|
|
52
|
-
/**
|
|
53
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
54
|
-
* via the `patternProperty` ".+".
|
|
55
|
-
*/
|
|
56
|
-
[k: string]: string;
|
|
57
|
-
}
|
|
58
|
-
| string[];
|
|
66
|
+
} | null;
|
|
59
67
|
export type ListOrDict =
|
|
60
68
|
| {
|
|
61
69
|
/**
|
|
@@ -73,6 +81,7 @@ export type StringOrList = string | ListOfStrings;
|
|
|
73
81
|
*/
|
|
74
82
|
export type DefinitionsNetwork = {
|
|
75
83
|
driver?: string;
|
|
84
|
+
name?: string;
|
|
76
85
|
driver_opts?: {
|
|
77
86
|
/**
|
|
78
87
|
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
@@ -93,8 +102,10 @@ export type DefinitionsNetwork = {
|
|
|
93
102
|
};
|
|
94
103
|
internal?: boolean;
|
|
95
104
|
labels?: Labels;
|
|
96
|
-
} &
|
|
105
|
+
} & Network;
|
|
106
|
+
export type Network = {
|
|
97
107
|
driver?: string;
|
|
108
|
+
name?: string;
|
|
98
109
|
driver_opts?: {
|
|
99
110
|
/**
|
|
100
111
|
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
@@ -115,7 +126,7 @@ export type DefinitionsNetwork = {
|
|
|
115
126
|
};
|
|
116
127
|
internal?: boolean;
|
|
117
128
|
labels?: Labels;
|
|
118
|
-
} | null
|
|
129
|
+
} | null;
|
|
119
130
|
/**
|
|
120
131
|
* This interface was referenced by `PropertiesVolumes`'s JSON-Schema definition
|
|
121
132
|
* via the `patternProperty` "^[a-zA-Z0-9._-]+$".
|
|
@@ -135,7 +146,8 @@ export type DefinitionsVolume = {
|
|
|
135
146
|
name?: string;
|
|
136
147
|
};
|
|
137
148
|
labels?: Labels;
|
|
138
|
-
} &
|
|
149
|
+
} & Volume;
|
|
150
|
+
export type Volume = {
|
|
139
151
|
driver?: string;
|
|
140
152
|
driver_opts?: {
|
|
141
153
|
/**
|
|
@@ -150,7 +162,7 @@ export type DefinitionsVolume = {
|
|
|
150
162
|
name?: string;
|
|
151
163
|
};
|
|
152
164
|
labels?: Labels;
|
|
153
|
-
} | null
|
|
165
|
+
} | null;
|
|
154
166
|
|
|
155
167
|
export interface ConfigSchemaV30Json {
|
|
156
168
|
version: string;
|
package/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if ( !v.validate(inputJSON, schema).valid )
|
|
11
|
-
throw new Error('Invalid input!')
|
|
12
|
-
|
|
13
|
-
return YAML.stringify( inputJSON )
|
|
1
|
+
const lib = require('./lib/lib.js');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate compose file from a JSON document
|
|
5
|
+
* @param {string} inputJSON - JSON document, what represent the compose file.
|
|
6
|
+
* @return {string} The generated compose file in YAML format.
|
|
7
|
+
*/
|
|
8
|
+
function generateCompose(inputJSON) {
|
|
9
|
+
return lib.generateCompose(inputJSON);
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
module.exports = {
|
|
17
|
-
|
|
18
|
-
}
|
|
13
|
+
generate: generateCompose,
|
|
14
|
+
};
|
package/lib/lib.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const YAML = require('json2yaml');
|
|
4
|
+
const Validator = require('jsonschema').Validator;
|
|
5
|
+
const v = new Validator();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate compose file from a JSON document
|
|
9
|
+
* @param {string} inputJSON - JSON document, what represent the compose file.
|
|
10
|
+
* @return {string} The generated compose file in YAML format.
|
|
11
|
+
*/
|
|
12
|
+
function generateCompose(inputJSON) {
|
|
13
|
+
const schema = JSON.parse(
|
|
14
|
+
fs.readFileSync(path.resolve(__dirname, '../schema.json')));
|
|
15
|
+
|
|
16
|
+
if (!v.validate(inputJSON, schema).valid) {
|
|
17
|
+
throw new Error('Invalid input!');
|
|
18
|
+
}
|
|
19
|
+
return YAML.stringify(inputJSON);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
generateCompose,
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docker-composer",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "Library for generating docker-compose.yml from JSON.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "./node_modules/mocha/bin/mocha.js
|
|
7
|
+
"test": "./node_modules/mocha/bin/mocha.js ./tests/*Test.js",
|
|
8
8
|
"coverage": "nyc npm run test",
|
|
9
|
-
"generate-ts-types": "./
|
|
9
|
+
"generate-ts-types": "node ./scripts/compile-ts-types.js",
|
|
10
|
+
"linter": "npx eslint *.js tests/*.js"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
|
-
"gulp",
|
|
13
13
|
"docker",
|
|
14
14
|
"compose",
|
|
15
15
|
"docker-compose.yml"
|
|
@@ -35,19 +35,12 @@
|
|
|
35
35
|
"jsonschema": "^1.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"copy-props": "^4.0.0",
|
|
41
|
-
"eslint": "8.26.0",
|
|
42
|
-
"glob-parent": "6.0.2",
|
|
43
|
-
"gulp": "^4.0.2",
|
|
44
|
-
"gulp-cli": "^2.3.0",
|
|
38
|
+
"eslint": "^8.30.0",
|
|
39
|
+
"eslint-config-google": "^0.14.0",
|
|
45
40
|
"js-yaml": "^4.0.0",
|
|
46
41
|
"json-schema-to-typescript": "^11.0.0",
|
|
47
|
-
"
|
|
48
|
-
"mocha": "10.1.0",
|
|
42
|
+
"mocha": "10.2.0",
|
|
49
43
|
"nyc": "^15.1.0",
|
|
50
|
-
"set-value": "^4.0.1",
|
|
51
44
|
"should": "13.2.3"
|
|
52
45
|
},
|
|
53
46
|
"nyc": {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const compiler = require('json-schema-to-typescript');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to generate typescript types from json schema
|
|
7
|
+
*/
|
|
8
|
+
async function runner() {
|
|
9
|
+
const compiledTs = await compiler.compileFromFile(
|
|
10
|
+
path.resolve(__dirname, '../schema.json'));
|
|
11
|
+
fs.writeFileSync('index.d.ts', compiledTs);
|
|
12
|
+
console.log('Types are generated..');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
runner();
|
|
16
|
+
|