Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cucumber/create-meta

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/create-meta - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

dist/src/createMeta.d.ts.map

4

.mocharc.json
{
"require": ["ts-node/register", "source-map-support/register"],
"require": ["tsconfig-paths/register", "ts-node/register", "source-map-support/register"],
"extension": ["ts", "tsx"],
"recursive": true,
"timeout": 10000
"timeout": 10000
}

@@ -20,1 +20,2 @@ import { messages } from '@cucumber/messages';

export declare function removeUserInfoFromUrl(value: string): string;
//# sourceMappingURL=createMeta.d.ts.map
"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -34,6 +7,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.removeUserInfoFromUrl = exports.detectCI = void 0;
var os_1 = __importDefault(require("os"));
var url_1 = require("url");
var messages_1 = require("@cucumber/messages");
var ciDict_json_1 = __importDefault(require("./ciDict.json"));
const os_1 = __importDefault(require("os"));
const url_1 = require("url");
const messages_1 = require("@cucumber/messages");
const ciDict_json_1 = __importDefault(require("./ciDict.json"));
function createMeta(toolName, toolVersion, envDict, ciDict) {

@@ -65,20 +38,9 @@ if (ciDict === undefined) {

function detectCI(ciDict, envDict) {
var e_1, _a;
var detected = [];
try {
for (var _b = __values(Object.entries(ciDict)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), ciName = _d[0], ciSystem = _d[1];
var ci = createCi(ciName, ciSystem, envDict);
if (ci) {
detected.push(ci);
}
const detected = [];
for (const [ciName, ciSystem] of Object.entries(ciDict)) {
const ci = createCi(ciName, ciSystem, envDict);
if (ci) {
detected.push(ci);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
if (detected.length !== 1) {

@@ -93,3 +55,3 @@ return undefined;

return value;
var url = url_1.parse(value);
const url = url_1.parse(value);
if (url.auth === null)

@@ -102,3 +64,3 @@ return value;

function createCi(ciName, ciSystem, envDict) {
var url = evaluate(ciSystem.url, envDict);
const url = evaluate(ciSystem.url, envDict);
if (url === undefined) {

@@ -110,3 +72,3 @@ // The url is what consumers will use as the primary key for a build

return messages_1.messages.Meta.CI.create({
url: url,
url,
name: ciName,

@@ -133,13 +95,9 @@ git: {

try {
return template.replace(/\${((refbranch|reftag)\s+)?([^\s}]+)(\s+\|\s+([^}]+))?}/g, function (substring) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var func = args[1];
var variable = args[2];
var defaultValue = args[4];
var value = envDict[variable] || defaultValue;
return template.replace(/\${((refbranch|reftag)\s+)?([^\s}]+)(\s+\|\s+([^}]+))?}/g, (substring, ...args) => {
const func = args[1];
const variable = args[2];
const defaultValue = args[4];
const value = envDict[variable] || defaultValue;
if (value === undefined) {
throw new Error("Undefined variable: " + variable);
throw new Error(`Undefined variable: ${variable}`);
}

@@ -162,3 +120,3 @@ switch (func) {

function group1(value, regexp) {
var match = value.match(regexp);
const match = value.match(regexp);
if (match === null)

@@ -165,0 +123,0 @@ throw new Error('No match');

import createMeta from './createMeta';
export default createMeta;
//# sourceMappingURL=index.d.ts.map

@@ -6,4 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var createMeta_1 = __importDefault(require("./createMeta"));
const createMeta_1 = __importDefault(require("./createMeta"));
exports.default = createMeta_1.default;
//# sourceMappingURL=index.js.map
/// <reference types="node" />
import { Writable } from 'stream';
export declare function main(envPath: string, stdout: Writable): Promise<void>;
//# sourceMappingURL=printMeta.d.ts.map

@@ -11,29 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -44,26 +17,16 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.main = void 0;
var fs_1 = require("fs");
var createMeta_1 = require("./createMeta");
var ciDict_json_1 = __importDefault(require("./ciDict.json"));
const fs_1 = require("fs");
const createMeta_1 = require("./createMeta");
const ciDict_json_1 = __importDefault(require("./ciDict.json"));
function main(envPath, stdout) {
return __awaiter(this, void 0, void 0, function () {
var envData, entries, env, ci;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fs_1.promises.readFile(envPath, 'utf-8')];
case 1:
envData = _a.sent();
entries = envData.split('\n').map(function (line) { return line.split('='); });
env = Object.fromEntries(entries);
ci = createMeta_1.detectCI(ciDict_json_1.default, env);
stdout.write(JSON.stringify(ci.toJSON(), null, 2) + '\n');
return [2 /*return*/];
}
});
return __awaiter(this, void 0, void 0, function* () {
const envData = yield fs_1.promises.readFile(envPath, 'utf-8');
const entries = envData.split('\n').map((line) => line.split('='));
const env = Object.fromEntries(entries);
const ci = createMeta_1.detectCI(ciDict_json_1.default, env);
stdout.write(JSON.stringify(ci.toJSON(), null, 2) + '\n');
});
}
exports.main = main;
main(process.argv[2], process.stdout).catch(function (err) {
return console.error(err.backtrace);
});
main(process.argv[2], process.stdout).catch((err) => console.error(err.backtrace));
//# sourceMappingURL=printMeta.js.map
export {};
//# sourceMappingURL=createMetaTest.d.ts.map

@@ -6,14 +6,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var createMeta_1 = __importDefault(require("../src/createMeta"));
var assert_1 = __importDefault(require("assert"));
var ciDict_json_1 = __importDefault(require("../src/ciDict.json"));
var messages_1 = require("@cucumber/messages");
describe('createMeta', function () {
it('defines the implementation product', function () {
var meta = createMeta_1.default('someTool', '1.2.3', {}, {});
const createMeta_1 = __importDefault(require("../src/createMeta"));
const assert_1 = __importDefault(require("assert"));
const ciDict_json_1 = __importDefault(require("../src/ciDict.json"));
const messages_1 = require("@cucumber/messages");
describe('createMeta', () => {
it('defines the implementation product', () => {
const meta = createMeta_1.default('someTool', '1.2.3', {}, {});
assert_1.default.strictEqual(meta.implementation.name, 'someTool');
assert_1.default.strictEqual(meta.implementation.version, '1.2.3');
});
it('detects CircleCI', function () {
var envDict = {
it('detects CircleCI', () => {
const envDict = {
CIRCLE_BUILD_URL: 'the-url',

@@ -25,3 +25,3 @@ CIRCLE_REPOSITORY_URL: 'the-remote',

};
var meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
const meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
assert_1.default.deepStrictEqual(meta.ci, messages_1.messages.Meta.CI.create({

@@ -38,4 +38,4 @@ name: 'CircleCI',

});
it('detects GitHub Actions', function () {
var envDict = {
it('detects GitHub Actions', () => {
const envDict = {
GITHUB_SERVER_URL: 'https://github.com',

@@ -47,3 +47,3 @@ GITHUB_REPOSITORY: 'cucumber/cucumber-ruby',

};
var meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
const meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
assert_1.default.deepStrictEqual(meta.ci, messages_1.messages.Meta.CI.create({

@@ -60,4 +60,4 @@ name: 'GitHub Actions',

});
it('detects GitHub Actions with custom base url', function () {
var envDict = {
it('detects GitHub Actions with custom base url', () => {
const envDict = {
GITHUB_SERVER_URL: 'https://github.company.com',

@@ -69,3 +69,3 @@ GITHUB_REPOSITORY: 'cucumber/cucumber-ruby',

};
var meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
const meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
assert_1.default.deepStrictEqual(meta.ci, messages_1.messages.Meta.CI.create({

@@ -82,4 +82,4 @@ name: 'GitHub Actions',

});
it('post-processes git refs to branch', function () {
var envDict = {
it('post-processes git refs to branch', () => {
const envDict = {
BUILD_URI: 'the-url',

@@ -90,3 +90,3 @@ BUILD_REPOSITORY_URI: 'the-remote',

};
var meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
const meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
assert_1.default.deepStrictEqual(meta.ci, messages_1.messages.Meta.CI.create({

@@ -103,4 +103,4 @@ name: 'Azure Pipelines',

});
it('post-processes git refs to tag', function () {
var envDict = {
it('post-processes git refs to tag', () => {
const envDict = {
BUILD_URI: 'the-url',

@@ -111,3 +111,3 @@ BUILD_REPOSITORY_URI: 'the-remote',

};
var meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
const meta = createMeta_1.default('someTool', '1.2.3', envDict, ciDict_json_1.default);
assert_1.default.deepStrictEqual(meta.ci, messages_1.messages.Meta.CI.create({

@@ -114,0 +114,0 @@ name: 'Azure Pipelines',

export {};
//# sourceMappingURL=removeUserInfoFromUrlTest.d.ts.map

@@ -6,25 +6,25 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var createMeta_1 = require("../src/createMeta");
var assert_1 = __importDefault(require("assert"));
describe('removeUserInfoFromUrl', function () {
it('returns undefined for undefined', function () {
const createMeta_1 = require("../src/createMeta");
const assert_1 = __importDefault(require("assert"));
describe('removeUserInfoFromUrl', () => {
it('returns undefined for undefined', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl(undefined), undefined);
});
it('returns null for null', function () {
it('returns null for null', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl(null), null);
});
it('returns empty string for empty string', function () {
it('returns empty string for empty string', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl(null), null);
});
it('leaves the data intact when no sensitive information is detected', function () {
it('leaves the data intact when no sensitive information is detected', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl('pretty safe'), 'pretty safe');
});
context('with URLs', function () {
it('leaves intact when no password is found', function () {
context('with URLs', () => {
it('leaves intact when no password is found', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl('https://example.com/git/repo.git'), 'https://example.com/git/repo.git');
});
it('removes credentials when found', function () {
it('removes credentials when found', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl('http://login@example.com/git/repo.git'), 'http://example.com/git/repo.git');
});
it('removes credentials and passwords when found', function () {
it('removes credentials and passwords when found', () => {
assert_1.default.strictEqual(createMeta_1.removeUserInfoFromUrl('ssh://login:password@example.com/git/repo.git'), 'ssh://example.com/git/repo.git');

@@ -31,0 +31,0 @@ });

{
"name": "@cucumber/create-meta",
"version": "3.0.0",
"version": "4.0.0",
"description": "Produce the meta message for Cucumber JavaScript",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"bin": {},
"scripts": {
"test": "mocha",
"lint": "eslint --ext ts --max-warnings 0 src test",
"lint-fix": "eslint --ext ts --max-warnings 0 --fix src test",
"coverage": "nyc --reporter=html --reporter=text mocha",
"build": "tsc",
"prepublishOnly": "npm run build"
"prepublishOnly": "tsc --build tsconfig.build.json",
"print-meta": "ts-node --require tsconfig-paths/register ./src/printMeta.ts"
},

@@ -31,25 +27,11 @@ "repository": {

"@types/glob": "^7.1.3",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.25",
"@types/stack-utils": "^2.0.0",
"@types/stream-buffers": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.37",
"mocha": "^8.3.2",
"source-map-support": "^0.5.19",
"stream-buffers": "^3.0.2",
"ts-sinon": "^2.0.1"
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
},
"dependencies": {
"@cucumber/messages": "^14.0.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"@cucumber/messages": "^15.0.0"
},

@@ -56,0 +38,0 @@ "directories": {

@@ -49,6 +49,3 @@ import os from 'os'

export function detectCI(
ciDict: CiDict,
envDict: EnvDict
): messages.Meta.CI | undefined {
export function detectCI(ciDict: CiDict, envDict: EnvDict): messages.Meta.CI | undefined {
const detected: messages.Meta.CI[] = []

@@ -55,0 +52,0 @@ for (const [ciName, ciSystem] of Object.entries(ciDict)) {

@@ -13,4 +13,2 @@ import { promises as fs } from 'fs'

}
main(process.argv[2], process.stdout).catch((err) =>
console.error(err.backtrace)
)
main(process.argv[2], process.stdout).catch((err) => console.error(err.backtrace))

@@ -78,4 +78,3 @@ import createMeta from '../src/createMeta'

name: 'GitHub Actions',
url:
'https://github.company.com/cucumber/cucumber-ruby/actions/runs/140170388',
url: 'https://github.company.com/cucumber/cucumber-ruby/actions/runs/140170388',
git: {

@@ -82,0 +81,0 @@ remote: 'https://github.company.com/cucumber/cucumber-ruby.git',

{
"compilerOptions": {
"declaration": true,
"target": "es5",
"lib": [
"es2019",
"dom"
],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"resolveJsonModule": true,
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": true,
"moduleResolution": "node",
"outDir": "dist",
"downlevelIteration": true,
"skipLibCheck": true
},
"include": [
"src/**/*",
"test/**/*",
"features/**/*"
]
"extends": "../../tsconfig.json"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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