@elastic.io/component-build-helper
Advanced tools
Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2
@@ -31,6 +31,3 @@ #!/usr/bin/env node | ||
case 'getComponentLogo': | ||
(0, metaloader_1.getComponentLogo)(componentPath) | ||
.then(logo => { | ||
console.log(logo); | ||
}); | ||
(0, metaloader_1.getComponentLogo)(componentPath).then(console.log); | ||
break; | ||
@@ -37,0 +34,0 @@ default: |
@@ -21,2 +21,3 @@ export interface Field { | ||
export interface Component { | ||
version: string; | ||
triggers: { | ||
@@ -23,0 +24,0 @@ [trigger: string]: Trigger; |
@@ -9,2 +9,11 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const semver_1 = __importDefault(require("semver")); | ||
function validateComponentVersion(version) { | ||
if (!version) { | ||
return; | ||
} | ||
if (!semver_1.default.valid(version)) { | ||
throw new Error('Invalid component version. Please specify the valid semantic version'); | ||
} | ||
} | ||
// Action/Trigger names should not intersect each other | ||
@@ -26,2 +35,3 @@ function validateFunctionNamesIntersection(component) { | ||
function validateFunctionsNames(component) { | ||
validateComponentVersion(component.version); | ||
const { triggers, actions } = component; | ||
@@ -28,0 +38,0 @@ // regex for valid javascript variable (except $, and starts only with letter) |
{ | ||
"name": "@elastic.io/component-build-helper", | ||
"version": "0.0.1-alpha.1", | ||
"version": "0.0.1-alpha.2", | ||
"description": "Helpers for the component build process", | ||
@@ -17,3 +17,3 @@ "main": "dist/src/index.js", | ||
"bin": { | ||
"componentcli": "./dist/src/cli.js", | ||
"component_cli": "./dist/src/cli.js", | ||
"build_component_docker": "./component/build_docker.sh" | ||
@@ -23,4 +23,6 @@ }, | ||
"@types/chai": "4.3.0", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/mocha": "9.0.0", | ||
"@types/node": "12.0.4", | ||
"@types/semver": "^7.3.9", | ||
"@types/sinon": "10.0.6", | ||
@@ -45,3 +47,7 @@ "@types/sinon-chai": "3.2.8", | ||
"typescript": "4.4.4" | ||
}, | ||
"dependencies": { | ||
"chai-as-promised": "^7.1.1", | ||
"semver": "^7.3.5" | ||
} | ||
} |
/* eslint-disable @typescript-eslint/ban-ts-comment, no-dupe-keys, @typescript-eslint/ban-ts-ignore */ | ||
export default { | ||
invalidSemverComponent: { | ||
version: 'invalidSemver' | ||
}, | ||
recursiveComponentPut: { | ||
@@ -4,0 +7,0 @@ loaded: true |
@@ -9,3 +9,7 @@ /* eslint-disable @typescript-eslint/camelcase */ | ||
import { DEFAULT_ICON } from '../../src'; | ||
chai.use(require('sinon-chai')); | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import sinonChai from 'sinon-chai'; | ||
chai.use(chaiAsPromised); | ||
chai.use(sinonChai); | ||
const { expect } = chai; | ||
@@ -25,2 +29,3 @@ | ||
'withoutTriggers./component.json': data.withoutTriggersComponent, | ||
'invalidSemver./component.json': data.invalidSemverComponent, | ||
'withoutActions./component.json': data.withoutActionsComponent, | ||
@@ -217,2 +222,11 @@ 'sameFuncNamesOneDuplicate./component.json': data.oneDuplicateSameFuncNamesComponent, | ||
}); | ||
it('should ignore if version is undefined', async () => { | ||
await validateComponentJSON(getFileFunction('flat')); | ||
}); | ||
it('should throw an error if version is invalid semver', async () => { | ||
await expect(validateComponentJSON(getFileFunction('invalidSemver'))).to.be | ||
.rejectedWith('Invalid component version. Please specify the valid semantic version'); | ||
}); | ||
}); | ||
@@ -219,0 +233,0 @@ }); |
@@ -33,6 +33,3 @@ #!/usr/bin/env node | ||
case 'getComponentLogo': | ||
getComponentLogo(componentPath) | ||
.then(logo => { | ||
console.log(logo); | ||
}); | ||
getComponentLogo(componentPath).then(console.log); | ||
break; | ||
@@ -39,0 +36,0 @@ default: |
@@ -23,2 +23,3 @@ export interface Field { | ||
export interface Component { | ||
version: string; | ||
triggers: { [trigger: string]: Trigger }; | ||
@@ -25,0 +26,0 @@ actions: { [action: string]: Action }; |
import { Action, Component, Metadata } from './interfaces'; | ||
import { DEFAULT_ICON } from './index'; | ||
import fs from 'fs'; | ||
import semver from 'semver'; | ||
function validateComponentVersion(version: string) { | ||
if (!version) { | ||
return; | ||
} | ||
if (!semver.valid(version)) { | ||
throw new Error('Invalid component version. Please specify the valid semantic version'); | ||
} | ||
} | ||
// Action/Trigger names should not intersect each other | ||
@@ -26,2 +36,4 @@ function validateFunctionNamesIntersection(component: Component) { | ||
function validateFunctionsNames(component: Component) { | ||
validateComponentVersion(component.version); | ||
const { triggers, actions } = component; | ||
@@ -28,0 +40,0 @@ // regex for valid javascript variable (except $, and starts only with letter) |
Sorry, the diff of this file is not supported yet
1297
59390
2
24
31
+ Addedchai-as-promised@^7.1.1
+ Addedsemver@^7.3.5
+ Addedassertion-error@2.0.1(transitive)
+ Addedchai@5.1.2(transitive)
+ Addedchai-as-promised@7.1.2(transitive)
+ Addedcheck-error@1.0.32.1.1(transitive)
+ Addeddeep-eql@5.0.2(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedloupe@3.1.2(transitive)
+ Addedpathval@2.0.0(transitive)
+ Addedsemver@7.6.3(transitive)