docker-composer 4.1.3 → 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 ADDED
@@ -0,0 +1,9 @@
1
+ env:
2
+ browser: true
3
+ es2021: true
4
+ extends: google
5
+ overrides: []
6
+ parserOptions:
7
+ ecmaVersion: latest
8
+ sourceType: module
9
+ rules: {}
package/README.md CHANGED
@@ -14,9 +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 4.1.3 (22.12.2022)
18
- - Remove gulp
17
+ ## Version 5.0.0 (29.12.2022)
18
+ - Reorganize code base
19
19
  - Update dependencies
20
+ - Change code style
20
21
 
21
22
  You can find all Release Notes [HERE](https://github.com/tudvari/docker-composer/blob/master/ReleaseNotes.md).
22
23
 
@@ -24,9 +25,9 @@ You can find all Release Notes [HERE](https://github.com/tudvari/docker-composer
24
25
 
25
26
  ```javascript
26
27
 
27
- const composer = require('docker-composer')
28
+ const composer = require('docker-composer');
28
29
  .
29
- var generatedYML = composer.generate( inputJSON )
30
+ const generatedYML = composer.generate(inputJSON);
30
31
  ```
31
32
 
32
33
  ## Full Example
package/ReleaseNotes.md CHANGED
@@ -1,5 +1,10 @@
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
+
3
8
  ## Version 4.1.3 (22.12.2022)
4
9
  - Remove gulp
5
10
  - Update dependencies
package/index.js CHANGED
@@ -1,18 +1,14 @@
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
- function generateCompose ( inputJSON ) {
8
- let schema = JSON.parse(fs.readFileSync(path.resolve(__dirname, './schema.json')))
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
- generate: generateCompose
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,12 +1,13 @@
1
1
  {
2
2
  "name": "docker-composer",
3
- "version": "4.1.3",
4
- "description": "NodeJS module for generating docker-compose.yml from a json document.",
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 *Test.js",
7
+ "test": "./node_modules/mocha/bin/mocha.js ./tests/*Test.js",
8
8
  "coverage": "nyc npm run test",
9
- "generate-ts-types": "node compile-ts-types.js"
9
+ "generate-ts-types": "node ./scripts/compile-ts-types.js",
10
+ "linter": "npx eslint *.js tests/*.js"
10
11
  },
11
12
  "keywords": [
12
13
  "docker",
@@ -34,7 +35,8 @@
34
35
  "jsonschema": "^1.4.0"
35
36
  },
36
37
  "devDependencies": {
37
- "eslint": "8.30.0",
38
+ "eslint": "^8.30.0",
39
+ "eslint-config-google": "^0.14.0",
38
40
  "js-yaml": "^4.0.0",
39
41
  "json-schema-to-typescript": "^11.0.0",
40
42
  "mocha": "10.2.0",
@@ -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
+
@@ -1,10 +0,0 @@
1
- const fs = require('fs')
2
- const compiler = require('json-schema-to-typescript')
3
-
4
- async function f() {
5
- const compiledTs = await compiler.compileFromFile('schema.json');
6
- fs.writeFileSync('index.d.ts', compiledTs)
7
- }
8
-
9
- f();
10
-