pshregistry-parser
Advanced tools
Comparing version 1.0.1 to 1.0.2
'use strict'; | ||
let fs = require('fs'); | ||
let psh = require('./images.js') | ||
let psh = require('./images.js'); | ||
let yml = require('js-yaml'); | ||
@@ -143,2 +144,16 @@ class InvalidRegistryError extends SyntaxError { | ||
/** | ||
* Duplicates Registry data in a YAML file. | ||
* | ||
* @param {string} registrySource | ||
* A Registry JSON source file name. | ||
*/ | ||
writeRegistryYAML(registrySource) { | ||
const registryName = registrySource.split("."); | ||
let registryData = this.parseRegistry(registrySource); | ||
fs.writeFileSync(`${registryName[0]}.yaml`, yml.safeDump(registryData, {noRefs:true}), function (err) { | ||
if (err) throw err; | ||
}); | ||
} | ||
/** | ||
* Expands registry images into properties of this instance, returning a list of those properties. | ||
@@ -154,2 +169,6 @@ * | ||
let registry = this.parseRegistry(registrySource); | ||
// For now, make an identical copy of registry data in a YAML file. | ||
this.writeRegistryYAML(registrySource); | ||
// Creates a list of Images. | ||
@@ -156,0 +175,0 @@ let images = {}; |
{ | ||
"name": "pshregistry-parser", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Helper for library for accessing image data from the Platform.sh Registry and generating configuration files.", | ||
@@ -35,4 +35,5 @@ "main": "lib/registry-parser.js", | ||
"eslint": "^5.14.1", | ||
"mocha": "^6.0.0" | ||
"mocha": "^6.0.0", | ||
"js-yaml": "^3.13.1" | ||
} | ||
} |
'use strict'; | ||
let fs = require('fs'); | ||
let psh = require('./images.js') | ||
let psh = require('./images.js'); | ||
let yml = require('js-yaml'); | ||
@@ -143,2 +144,16 @@ class InvalidRegistryError extends SyntaxError { | ||
/** | ||
* Duplicates Registry data in a YAML file. | ||
* | ||
* @param {string} registrySource | ||
* A Registry JSON source file name. | ||
*/ | ||
writeRegistryYAML(registrySource) { | ||
const registryName = registrySource.split("."); | ||
let registryData = this.parseRegistry(registrySource); | ||
fs.writeFileSync(`${registryName[0]}.yaml`, yml.safeDump(registryData, {noRefs:true}), function (err) { | ||
if (err) throw err; | ||
}); | ||
} | ||
/** | ||
* Expands registry images into properties of this instance, returning a list of those properties. | ||
@@ -154,2 +169,6 @@ * | ||
let registry = this.parseRegistry(registrySource); | ||
// For now, make an identical copy of registry data in a YAML file. | ||
this.writeRegistryYAML(registrySource); | ||
// Creates a list of Images. | ||
@@ -156,0 +175,0 @@ let images = {}; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
@@ -41,2 +42,16 @@ describe('Platform.sh Registry Parser tests', function() { | ||
describe('YAML generation', function() { | ||
it('Test that registry YAML file is generated and data is accessible', function() { | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
cg.writeRegistryYAML(registrySource); | ||
let yamlRegistry = yaml.safeLoad(fs.readFileSync('test/testdata/valid.yaml', 'utf8')); | ||
assert.equal(yamlRegistry.elasticsearch.disk, true); | ||
assert.equal(yamlRegistry.elasticsearch.endpoint, "elasticsearch"); | ||
assert.equal(yamlRegistry.golang.runtime, true); | ||
}); | ||
}) | ||
describe('Save directories', function() { | ||
@@ -43,0 +58,0 @@ |
92013
1923
4