New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@elastic.io/component-build-helper

Package Overview
Dependencies
Maintainers
12
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic.io/component-build-helper - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

dist/src/commands/detectComponentLanguage.d.ts

2

.eslintrc.js

@@ -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 = {}));
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc