launch-darkly-feature-builder
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "launch-darkly-feature-builder", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Builds and manages launch darkly features from code.", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -50,3 +50,8 @@ const _ = require( 'lodash' ); | ||
features[ featureKey ] = await loadFeatureAsync( filePath ); | ||
const definition = await loadFeatureAsync( filePath ); | ||
features[ featureKey ] = { | ||
path: filePath, | ||
definition | ||
}; | ||
} | ||
@@ -53,0 +58,0 @@ } ); |
@@ -11,15 +11,18 @@ const _ = require( 'lodash' ); | ||
const converters = await loadFeatureConvertersAsync( convertersDir, converterOptions ); | ||
const definitions = await featureFileLoader( definitionsDir ); | ||
const convertOptions = Object.freeze( {} ); | ||
const featureFiles = await featureFileLoader( definitionsDir ); | ||
return Promise | ||
.map( | ||
_.toPairs( definitions ), | ||
_.toPairs( featureFiles ), | ||
async pair => { | ||
const [ key, definition ] = pair; | ||
const [ key, featureFile ] = pair; | ||
const convertOptions = Object.freeze( { | ||
path: featureFile.path | ||
} ); | ||
try { | ||
const feature = await converters.convertAsync( | ||
definition, | ||
featureFile.definition, | ||
convertOptions | ||
@@ -26,0 +29,0 @@ ); |
@@ -13,2 +13,3 @@ const assert = require( './util/assert.js' ); | ||
assert.deepEqual( catalog.schemas, [ | ||
'http://test.org/echo-options', | ||
'http://test.org/simple-boolean', | ||
@@ -15,0 +16,0 @@ 'http://test.org/simple-enum' |
const assert = require( './util/assert.js' ); | ||
const featureFileLoader = require( '../src/featureFileLoader.js' ); | ||
const pathUtil = require( 'path' ); | ||
@@ -8,21 +9,33 @@ describe( 'featureFileLoader', function() { | ||
const path = `${ __dirname }/projects/example`; | ||
const features = await featureFileLoader( path ); | ||
const path = `${__dirname}/projects/example`; | ||
const features = await featureFileLoader( path ); | ||
assert.deepEqual( features, { | ||
cats: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Cats' | ||
path: pathUtil.join( path, 'mammals/cats.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Cats' | ||
} | ||
}, | ||
dogs: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Dogs' | ||
path: pathUtil.join( path, 'mammals/dogs.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Dogs' | ||
} | ||
}, | ||
frogs: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Frogs' | ||
path: pathUtil.join( path, 'amphibians/frogs.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Frogs' | ||
} | ||
}, | ||
rocks: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Rocks' | ||
path: pathUtil.join( path, 'rocks.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Rocks' | ||
} | ||
} | ||
@@ -34,21 +47,33 @@ } ); | ||
const path = `${ __dirname }/projects/validCharacters`; | ||
const features = await featureFileLoader( path ); | ||
const path = `${__dirname}/projects/validCharacters`; | ||
const features = await featureFileLoader( path ); | ||
assert.deepEqual( features, { | ||
'dash-char': { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Dashes' | ||
path: pathUtil.join( path, 'dash-char.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Dashes' | ||
} | ||
}, | ||
'period.char': { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Periods' | ||
path: pathUtil.join( path, 'period.char.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Periods' | ||
} | ||
}, | ||
underscore_char: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Underscores' | ||
path: pathUtil.join( path, 'underscore_char.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Underscores' | ||
} | ||
}, | ||
UPPER: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Uppers' | ||
path: pathUtil.join( path, 'UPPER.feature.json' ), | ||
definition: { | ||
'$schema': 'http://test.org/simple-boolean', | ||
name: 'Uppers' | ||
} | ||
} | ||
@@ -60,3 +85,3 @@ } ); | ||
const path = `${ __dirname }/projects/invalidCharacters`; | ||
const path = `${__dirname}/projects/invalidCharacters`; | ||
@@ -71,3 +96,3 @@ return assert.isRejected( | ||
const path = `${ __dirname }/projects/duplicateKeys`; | ||
const path = `${__dirname}/projects/duplicateKeys`; | ||
@@ -82,3 +107,3 @@ return assert.isRejected( | ||
const path = `${ __dirname }/projects/missingSchema`; | ||
const path = `${__dirname}/projects/missingSchema`; | ||
@@ -85,0 +110,0 @@ return assert.isRejected( |
@@ -56,3 +56,29 @@ const assert = require( './util/assert.js' ); | ||
} ); | ||
it( 'should load features', async function() { | ||
const convertersDir = pathUtil.join( | ||
__dirname, | ||
'converters' | ||
); | ||
const featuresDir = pathUtil.join( | ||
__dirname, | ||
'projects/optionsEcho' | ||
); | ||
const features = await loadFeaturesAsync( convertersDir, featuresDir ); | ||
assert.deepEqual( features, { | ||
echo: { | ||
factoryOptions: {}, | ||
convertOptions: { | ||
path: pathUtil.join( | ||
__dirname, | ||
'projects/optionsEcho/echo.feature.json' | ||
) | ||
} | ||
} | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
Sorry, the diff of this file is not supported yet
48802
53
1903