@elastic.io/component-build-helper
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -5,2 +5,2 @@ module.exports = { | ||
] | ||
}; | ||
} |
#!/usr/bin/env node | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const metaloader_1 = require("./metaloader"); | ||
const fs_1 = require("fs"); | ||
const [, , action, componentPath] = process.argv; | ||
console.assert(componentPath, 'Please specify the path to the component folder'); | ||
async function validate(componentPath) { | ||
const getFileFunction = async (fileRelativePath) => { | ||
const filePath = fileRelativePath.replace(/^\.\/|^\//g, ''); | ||
const buffer = await fs_1.promises.readFile(`${componentPath.replace(/\/$/g, '')}/${filePath}`); | ||
return buffer.toString('utf-8'); | ||
}; | ||
await (0, metaloader_1.validateComponentJSON)(getFileFunction); | ||
} | ||
; | ||
process | ||
.on('uncaughtException', (err) => { | ||
console.error(err, 'Got uncaught exception'); | ||
process.exit(3); | ||
}) | ||
.on('unhandledRejection', (err) => { | ||
console.error(err, 'Got unhandled rejection'); | ||
process.exit(4); | ||
}); | ||
switch (action) { | ||
case 'validate': | ||
validate(componentPath); | ||
break; | ||
case 'getComponentLogo': | ||
(0, metaloader_1.getComponentLogo)(componentPath).then(console.log); | ||
break; | ||
default: | ||
throw new Error(`Unknown action ${action} specified. Possible values: 'validate', 'getComponentLogo'`); | ||
} | ||
const yargs_1 = __importDefault(require("yargs")); | ||
const helpers_1 = require("yargs/helpers"); | ||
// eslint-disable-next-line no-unused-expressions | ||
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) | ||
.commandDir('commands') | ||
.demandCommand(1, 'You need to specify command before') | ||
.strict() | ||
.alias({ h: 'help' }) | ||
.argv; |
import { validateComponentJSON, getComponentLogo } from './metaloader'; | ||
import { DockerfileGenerator } from './DockerfileGenerator'; | ||
import { ComponentContextLoader } from './ComponentContextLoader'; | ||
import DEFAULT_ICON from '../resources/defaultIcon'; | ||
import { Component, Action, Trigger, Field, Metadata } from './interfaces'; | ||
export { DEFAULT_ICON, getComponentLogo, validateComponentJSON, Component, Action, Trigger, Field, Metadata }; | ||
import { Component, Action, Trigger, Field, Metadata, COMPONENT_LANGUAGE } from './interfaces'; | ||
export { COMPONENT_LANGUAGE, DEFAULT_ICON, getComponentLogo, validateComponentJSON, Component, Action, Trigger, Field, Metadata, DockerfileGenerator, ComponentContextLoader }; |
@@ -6,7 +6,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateComponentJSON = exports.getComponentLogo = exports.DEFAULT_ICON = void 0; | ||
exports.ComponentContextLoader = exports.DockerfileGenerator = exports.validateComponentJSON = exports.getComponentLogo = exports.DEFAULT_ICON = exports.COMPONENT_LANGUAGE = void 0; | ||
const metaloader_1 = require("./metaloader"); | ||
Object.defineProperty(exports, "validateComponentJSON", { enumerable: true, get: function () { return metaloader_1.validateComponentJSON; } }); | ||
Object.defineProperty(exports, "getComponentLogo", { enumerable: true, get: function () { return metaloader_1.getComponentLogo; } }); | ||
const DockerfileGenerator_1 = require("./DockerfileGenerator"); | ||
Object.defineProperty(exports, "DockerfileGenerator", { enumerable: true, get: function () { return DockerfileGenerator_1.DockerfileGenerator; } }); | ||
const ComponentContextLoader_1 = require("./ComponentContextLoader"); | ||
Object.defineProperty(exports, "ComponentContextLoader", { enumerable: true, get: function () { return ComponentContextLoader_1.ComponentContextLoader; } }); | ||
const defaultIcon_1 = __importDefault(require("../resources/defaultIcon")); | ||
exports.DEFAULT_ICON = defaultIcon_1.default; | ||
const interfaces_1 = require("./interfaces"); | ||
Object.defineProperty(exports, "COMPONENT_LANGUAGE", { enumerable: true, get: function () { return interfaces_1.COMPONENT_LANGUAGE; } }); |
@@ -20,2 +20,6 @@ export interface Field { | ||
} | ||
export declare enum COMPONENT_LANGUAGE { | ||
NODEJS = "nodejs", | ||
JAVA = "java" | ||
} | ||
export interface Component { | ||
@@ -33,3 +37,4 @@ version: string; | ||
sailor_version?: string; | ||
language: COMPONENT_LANGUAGE; | ||
service?: string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.COMPONENT_LANGUAGE = void 0; | ||
; | ||
var COMPONENT_LANGUAGE; | ||
(function (COMPONENT_LANGUAGE) { | ||
COMPONENT_LANGUAGE["NODEJS"] = "nodejs"; | ||
COMPONENT_LANGUAGE["JAVA"] = "java"; | ||
})(COMPONENT_LANGUAGE = exports.COMPONENT_LANGUAGE || (exports.COMPONENT_LANGUAGE = {})); |
109
package.json
{ | ||
"name": "@elastic.io/component-build-helper", | ||
"version": "0.0.4", | ||
"description": "Helpers for the component build process", | ||
"main": "dist/src/index.js", | ||
"scripts": { | ||
"lint": "eslint --ext .ts .", | ||
"license-check": "license-checker --excludePrivatePackages --excludePackages \"$(node ../../../.ignored-licenses.js)\" --onlyAllow \"$(node ../../../.allowed-licenses.js)\"", | ||
"test": "mocha --config=./spec/.mocharc.js", | ||
"build": "tsc && chmod +x ./dist/src/cli.js", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run lint && npm run test" | ||
}, | ||
"author": "elastic.io GmbH", | ||
"license": "UNLICENSED", | ||
"bin": { | ||
"component_cli": "./dist/src/cli.js", | ||
"build_component_docker": "./component/build_docker.sh" | ||
}, | ||
"devDependencies": { | ||
"@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", | ||
"@types/sinon-chai": "3.2.8", | ||
"@typescript-eslint/eslint-plugin": "1.9.0", | ||
"@typescript-eslint/parser": "1.9.0", | ||
"chai": "4.3.4", | ||
"eslint": "5.16.0", | ||
"eslint-config-standard": "12.0.0", | ||
"eslint-plugin-import": "2.14.0", | ||
"eslint-plugin-mocha": "5.2.0", | ||
"eslint-plugin-node": "8.0.0", | ||
"eslint-plugin-promise": "4.0.1", | ||
"eslint-plugin-security": "1.4.0", | ||
"eslint-plugin-standard": "4.0.0", | ||
"license-checker": "25.0.1", | ||
"mocha": "9.1.4", | ||
"sinon": "12.0.1", | ||
"sinon-chai": "3.7.0", | ||
"ts-node": "8.2.0", | ||
"typescript": "4.4.4" | ||
}, | ||
"dependencies": { | ||
"chai-as-promised": "7.1.1", | ||
"semver": "7.3.5" | ||
} | ||
"name": "@elastic.io/component-build-helper", | ||
"version": "0.0.5", | ||
"description": "Helpers for the component build process", | ||
"main": "dist/src/index.js", | ||
"scripts": { | ||
"audit": "better-npm-audit audit --level high --production", | ||
"lint": "eslint --ext .ts .", | ||
"pretest": "npm run lint", | ||
"license-check": "license-checker --excludePrivatePackages --excludePackages \"$(node ../../../.ignored-licenses.js)\" --onlyAllow \"$(node ../../../.allowed-licenses.js)\"", | ||
"test": "mocha --config=./spec/.mocharc.js", | ||
"build": "tsc && chmod +x ./dist/src/cli.js", | ||
"prepublishOnly": "npm run lint && npm run test" | ||
}, | ||
"author": "elastic.io GmbH", | ||
"license": "UNLICENSED", | ||
"bin": { | ||
"component_cli": "./dist/src/cli.js", | ||
"build_component_docker": "./component/build_docker.sh" | ||
}, | ||
"devDependencies": { | ||
"@types/bunyan": "1.8.8", | ||
"@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", | ||
"@types/sinon-chai": "3.2.8", | ||
"@types/tar": "6.1.1", | ||
"@types/uuid": "8.3.4", | ||
"@types/yargs": "17.0.10", | ||
"@typescript-eslint/eslint-plugin": "1.9.0", | ||
"@typescript-eslint/parser": "1.9.0", | ||
"better-npm-audit": "3.7.3", | ||
"chai": "4.3.4", | ||
"chai-as-promised": "7.1.1", | ||
"eslint": "5.16.0", | ||
"eslint-config-standard": "12.0.0", | ||
"eslint-plugin-import": "2.14.0", | ||
"eslint-plugin-mocha": "5.2.0", | ||
"eslint-plugin-node": "8.0.0", | ||
"eslint-plugin-promise": "4.0.1", | ||
"eslint-plugin-security": "1.4.0", | ||
"eslint-plugin-standard": "4.0.0", | ||
"license-checker": "25.0.1", | ||
"mocha": "9.1.4", | ||
"nock": "13.2.4", | ||
"sinon": "12.0.1", | ||
"sinon-chai": "3.7.0", | ||
"ts-node": "8.2.0", | ||
"typescript": "4.4.4" | ||
}, | ||
"dependencies": { | ||
"@elastic.io/bunyan-logger": "1.0.9", | ||
"axios": "0.27.2", | ||
"gradle-to-js": "2.0.1", | ||
"semver": "7.3.5", | ||
"tar": "6.1.11", | ||
"uuid": "8.3.2", | ||
"yargs": "17.5.1" | ||
} | ||
} |
@@ -5,6 +5,6 @@ # component-build-helper | ||
Example of componentcli command | ||
Example of component_cli command | ||
1. validate component.json | ||
```shell | ||
componentcli validate /path/to/component/folder | ||
component_cli validate /path/to/component/folder | ||
``` | ||
@@ -14,3 +14,16 @@ 2. get base64 representation of component logo. | ||
```shell | ||
componentcli getComponentLogo /path/to/component/folder | ||
component_cli getComponentLogo /path/to/component/folder | ||
``` | ||
3. generate dockerfile for component. | ||
```shell | ||
## from folder | ||
component_cli generateDockerfile /path/to/component/folder | ||
## from stdin | ||
git archive master | component_cli generateDockerfile - | ||
``` | ||
4. detect component language. | ||
```shell | ||
component_cli detectComponentLanguage /path/to/component/folder | ||
``` |
@@ -17,3 +17,3 @@ /* eslint-disable @typescript-eslint/camelcase */ | ||
describe('validation cli', function () { | ||
describe('cli', function () { | ||
let sandbox: SinonSandbox; | ||
@@ -26,16 +26,27 @@ beforeEach(() => { | ||
}); | ||
it('path exists', async () => { | ||
const child = exec('./dist/src/cli.js validate ./spec/fixtures/component/'); | ||
child.stdout.pipe(process.stdout); | ||
child.stderr.pipe(process.stderr); | ||
const code = await promiseFromChildProcess(child); | ||
expect(code).to.be.eq(0); | ||
describe('component_cli validate', () => { | ||
it('path exists', async () => { | ||
const child = exec('./dist/src/cli.js validate ./spec/fixtures/component/nodejs'); | ||
child.stdout.pipe(process.stdout); | ||
child.stderr.pipe(process.stderr); | ||
const code = await promiseFromChildProcess(child); | ||
expect(code).to.be.eq(0); | ||
}); | ||
it('path is not exists', async () => { | ||
const child = exec('./dist/src/cli.js validate ./spec/fixtures/not_existed_path/'); | ||
child.stdout.pipe(process.stdout); | ||
child.stderr.pipe(process.stderr); | ||
const code = await promiseFromChildProcess(child); | ||
expect(code).not.to.be.eq(0); | ||
}); | ||
}); | ||
it('path is not exists', async () => { | ||
const child = exec('./dist/src/cli.js validate ./spec/fixtures/not_existed_path/'); | ||
child.stdout.pipe(process.stdout); | ||
child.stderr.pipe(process.stderr); | ||
const code = await promiseFromChildProcess(child); | ||
expect(code).not.to.be.eq(0); | ||
describe('component_cli generateDockerfile', () => { | ||
it('should get an error in case componentDirectoryPath is empty', async () => { | ||
const child = exec('./dist/src/cli.js generateDockerfile'); | ||
child.stdout.pipe(process.stdout); | ||
child.stderr.pipe(process.stderr); | ||
const code = await promiseFromChildProcess(child); | ||
expect(code).not.to.be.eq(0); | ||
}); | ||
}); | ||
}); |
@@ -234,7 +234,7 @@ /* eslint-disable @typescript-eslint/camelcase */ | ||
it('found icon file', async () => { | ||
const icon = await getComponentLogo('./spec/fixtures/component'); | ||
expect(icon).to.be.eq(fs.readFileSync('./spec/fixtures/component/logo.png').toString('base64')); | ||
const icon = await getComponentLogo('./spec/fixtures/component/nodejs'); | ||
expect(icon).to.be.eq(fs.readFileSync('./spec/fixtures/component/nodejs/logo.png').toString('base64')); | ||
}); | ||
it('not found icon file', async () => { | ||
const icon = await getComponentLogo('./spec/fixtures'); | ||
const icon = await getComponentLogo('./spec/fixtures/nodejs'); | ||
expect(icon).to.be.eq(DEFAULT_ICON); | ||
@@ -241,0 +241,0 @@ }); |
#!/usr/bin/env node | ||
import { getComponentLogo, validateComponentJSON } from './metaloader'; | ||
import { promises } from 'fs'; | ||
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
const [, , action, componentPath] = process.argv; | ||
console.assert(componentPath, 'Please specify the path to the component folder'); | ||
async function validate(componentPath: string) { | ||
const getFileFunction = async (fileRelativePath: string) => { | ||
const filePath = fileRelativePath.replace(/^\.\/|^\//g, ''); | ||
const buffer = await promises.readFile(`${componentPath.replace(/\/$/g, '')}/${filePath}`); | ||
return buffer.toString('utf-8'); | ||
}; | ||
await validateComponentJSON(getFileFunction); | ||
}; | ||
process | ||
.on('uncaughtException', (err: Error) => { | ||
console.error(err, 'Got uncaught exception'); | ||
process.exit(3); | ||
}) | ||
.on('unhandledRejection', (err: Error) => { | ||
console.error(err, 'Got unhandled rejection'); | ||
process.exit(4); | ||
}); | ||
switch (action) { | ||
case 'validate': | ||
validate(componentPath); | ||
break; | ||
case 'getComponentLogo': | ||
getComponentLogo(componentPath).then(console.log); | ||
break; | ||
default: | ||
throw new Error(`Unknown action ${action} specified. Possible values: 'validate', 'getComponentLogo'`); | ||
} | ||
// eslint-disable-next-line no-unused-expressions | ||
yargs(hideBin(process.argv)) | ||
.commandDir('commands') | ||
.demandCommand(1, 'You need to specify command before') | ||
.strict() | ||
.alias({ h: 'help' }) | ||
.argv; |
@@ -5,2 +5,4 @@ import { | ||
} from './metaloader'; | ||
import { DockerfileGenerator } from './DockerfileGenerator'; | ||
import { ComponentContextLoader } from './ComponentContextLoader'; | ||
import DEFAULT_ICON from '../resources/defaultIcon'; | ||
@@ -12,6 +14,8 @@ import { | ||
Field, | ||
Metadata | ||
Metadata, | ||
COMPONENT_LANGUAGE | ||
} from './interfaces'; | ||
export { | ||
COMPONENT_LANGUAGE, | ||
DEFAULT_ICON, | ||
@@ -24,3 +28,5 @@ getComponentLogo, | ||
Field, | ||
Metadata | ||
Metadata, | ||
DockerfileGenerator, | ||
ComponentContextLoader | ||
}; |
@@ -22,2 +22,4 @@ export interface Field { | ||
export enum COMPONENT_LANGUAGE { NODEJS = 'nodejs', JAVA = 'java' } | ||
export interface Component { | ||
@@ -32,3 +34,4 @@ version: string; | ||
sailor_version?: string; | ||
language: COMPONENT_LANGUAGE; | ||
service?: string; | ||
} |
@@ -12,6 +12,13 @@ { | ||
"baseUrl": ".", | ||
"typeRoots": [ | ||
"./src/@types", | ||
"./node_modules/@types" | ||
], | ||
"paths": { | ||
"*": [ | ||
"node_modules/*" | ||
] | ||
], | ||
// @types/tar uses @types/minipass. But minipass already has .d.ts | ||
// fix mapping fo minipass types and resolve issue with duplicated types | ||
"minipass": ["node_modules/@types/minipass/index.d.ts"] | ||
} | ||
@@ -18,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
583389
64
2633
28
7
31
5
2
+ Addedaxios@0.27.2
+ Addedgradle-to-js@2.0.1
+ Addedtar@6.1.11
+ Addeduuid@8.3.2
+ Addedyargs@17.5.1
+ Added@elastic.io/bunyan-logger@1.0.9(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbunyan@1.8.15(transitive)
+ Addedchownr@2.0.0(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddtrace-provider@0.8.8(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedfs-minipass@2.1.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedglob@6.0.4(transitive)
+ Addedgradle-to-js@2.0.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedminipass@3.3.6(transitive)
+ Addedminizlib@2.1.2(transitive)
+ Addedmkdirp@0.5.61.0.4(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedmv@2.1.1(transitive)
+ Addednan@2.22.0(transitive)
+ Addedncp@2.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrimraf@2.4.5(transitive)
+ Addedsafe-json-stringify@1.2.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtar@6.1.11(transitive)
+ Addeduuid@8.3.2(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.5.1(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedchai-as-promised@7.1.1
- Removedassertion-error@1.1.0(transitive)
- Removedchai@4.5.0(transitive)
- Removedchai-as-promised@7.1.1(transitive)
- Removedcheck-error@1.0.3(transitive)
- Removeddeep-eql@4.1.4(transitive)
- Removedget-func-name@2.0.2(transitive)
- Removedloupe@2.3.7(transitive)
- Removedpathval@1.1.1(transitive)
- Removedtype-detect@4.1.0(transitive)