Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "fbl", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -11,6 +11,6 @@ "main": "dist/cli.js", | ||
"rimraf": "rimraf", | ||
"start": "node dist/cli.js", | ||
"start": "node dist/src/cli.js", | ||
"test": "nyc --reporter=html --reporter=text mocha", | ||
"build": "rimraf ./dist/ && tsc", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts'", | ||
"prepublish": "npm run build && npm run lint", | ||
@@ -20,3 +20,3 @@ "precommit": "npm run lint" | ||
"bin": { | ||
"fbl": "dist/cli.js" | ||
"fbl": "dist/src/cli.js" | ||
}, | ||
@@ -33,2 +33,3 @@ "author": "FireBlink LTD", | ||
"@types/node": "10.3.1", | ||
"chai-as-promised": "7.1.1", | ||
"commander": "2.15.1", | ||
@@ -40,8 +41,9 @@ "deepmerge": "2.1.1", | ||
"reflect-metadata": "0.1.12", | ||
"typedi": "0.8.0" | ||
"typedi": "0.8.0", | ||
"uuid": "3.3.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "4.0.10", | ||
"@types/chai": "4.1.4", | ||
"chai": "4.1.2", | ||
"git-pre-commit": "^2.1.4", | ||
"git-pre-commit": "2.1.4", | ||
"mocha": "5.2.0", | ||
@@ -65,3 +67,3 @@ "mocha-typescript": "1.1.12", | ||
"exclude": [ | ||
"dist/lib/**/index.js", | ||
"dist/src/lib/**/index.js", | ||
"dist/test/**/*.js" | ||
@@ -75,3 +77,7 @@ ] | ||
} | ||
] | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/FireBlinkLTD/fbl.git" | ||
} | ||
} |
# FBL or FireBlink Logistics | ||
This project is early in development and not recommended to even look at before version 0.1.0. | ||
This is a second reincarnation on internal tool that FireBlink LTD used to deploy its own projects. | ||
@@ -4,0 +6,0 @@ Original tool was vendor locked and had pretty much limited functionality. |
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
commander | ||
.version(require('../package.json').version) | ||
.version(require('../../package.json').version) | ||
.option('-p --plugin <file>', '[optional] Plugin file.', (val, list) => { | ||
@@ -38,3 +38,4 @@ list.push(val); | ||
const plugins: string[] = [ | ||
'./plugins/flow' | ||
'./plugins/flow', | ||
'./plugins/context' | ||
]; | ||
@@ -41,0 +42,0 @@ plugins.push(...commander.plugin.map((p: string) => resolve(p))); |
@@ -25,3 +25,3 @@ import * as Joi from 'joi'; | ||
if (result.error) { | ||
throw new Error(result.error.details.map(d => d.message).join('\n')); | ||
throw new Error(this.getMetadata().id + ': ' + result.error.details.map(d => d.message).join('\n')); | ||
} | ||
@@ -28,0 +28,0 @@ } |
@@ -18,3 +18,3 @@ import {ActionHandler, IHandlerMetadata} from '../../models'; | ||
// We don't want to process options as a template to avoid unexpected behaviour inside nested actions | ||
skipTemplateProcessing: false | ||
skipTemplateProcessing: true | ||
}; | ||
@@ -21,0 +21,0 @@ |
@@ -19,3 +19,3 @@ import {ActionHandler} from '../../models'; | ||
// We don't want to process options as a template to avoid unexpected behaviour inside nested actions | ||
skipTemplateProcessing: false | ||
skipTemplateProcessing: true | ||
}; | ||
@@ -22,0 +22,0 @@ |
@@ -16,3 +16,6 @@ import {ActionHandler, IHandlerMetadata} from '../../models'; | ||
'?' | ||
] | ||
], | ||
// we don't want to process templates inside options in a default way as it may cause processing of templates | ||
// inside nested actions, but we will need to process "value" as it supposed to use template. | ||
skipTemplateProcessing: true | ||
}; | ||
@@ -39,2 +42,11 @@ | ||
async validate(options: any, context: any): Promise<void> { | ||
const flowService = Container.get(FlowService); | ||
// resolve value, as it is mostly likely a template and we're not processing options as a template | ||
options.value = flowService.resolveOptionsWithNoHandlerCheck(options.value, context); | ||
await super.validate(options, context); | ||
} | ||
getValidationSchema(): SchemaLike | null { | ||
@@ -41,0 +53,0 @@ return SwitchFlowHandler.validationSchema; |
@@ -25,4 +25,5 @@ import {ActionHandlersRegistry} from './ActionHandlersRegistry'; | ||
const handler = this.actionHandlersRegistry.find(idOrAlias); | ||
options = await this.resolveOptions(handler, options, context); | ||
options = this.resolveOptions(handler, options, context); | ||
await handler.validate(options, context); | ||
@@ -37,2 +38,13 @@ | ||
/** | ||
* Read and parse yaml file | ||
* @param {string} file | ||
* @returns {Promise<any>} | ||
*/ | ||
async readYamlFromFile(file: string): Promise<any> { | ||
const source = await promisify(readFile)(file, 'utf8'); | ||
return safeLoad(source); | ||
} | ||
/** | ||
* Read flow from file | ||
@@ -43,5 +55,13 @@ * @param {string} file | ||
async readFlowFromFile(file: string): Promise<IFlow> { | ||
const source = await promisify(readFile)(file, 'utf8'); | ||
return await this.readYamlFromFile(file) as IFlow; | ||
} | ||
return safeLoad(source) as IFlow; | ||
resolveOptionsWithNoHandlerCheck(options: any, context: any): any { | ||
if (options) { | ||
const tpl = dump(options); | ||
const yaml = render(tpl, {ctx: context}); | ||
options = safeLoad(yaml); | ||
} | ||
return options; | ||
} | ||
@@ -56,3 +76,3 @@ | ||
*/ | ||
async resolveOptions(handler: ActionHandler, options: any, context: any): Promise<any> { | ||
resolveOptions(handler: ActionHandler, options: any, context: any): any { | ||
if (handler.getMetadata().skipTemplateProcessing) { | ||
@@ -62,10 +82,4 @@ return options; | ||
if (options) { | ||
const tpl = dump(options); | ||
const yaml = render(tpl, context); | ||
options = safeLoad(yaml); | ||
} | ||
return options; | ||
return this.resolveOptionsWithNoHandlerCheck(options, context); | ||
} | ||
} |
@@ -14,3 +14,4 @@ { | ||
"include": [ | ||
"src/**/*" | ||
"src/**/*", | ||
"test/**/*" | ||
], | ||
@@ -17,0 +18,0 @@ "exclude": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
191847
80
1741
27
16
1
+ Addedchai-as-promised@7.1.1
+ Addeduuid@3.3.2
+ Addedassertion-error@1.1.0(transitive)
+ Addedchai@4.5.0(transitive)
+ Addedchai-as-promised@7.1.1(transitive)
+ Addedcheck-error@1.0.3(transitive)
+ Addeddeep-eql@4.1.4(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedloupe@2.3.7(transitive)
+ Addedpathval@1.1.1(transitive)
+ Addedtype-detect@4.1.0(transitive)
+ Addeduuid@3.3.2(transitive)