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

@knapsack-pro/core

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knapsack-pro/core - npm Package Compare versions

Comparing version 6.1.1 to 6.2.0

22

lib/ci-providers/unsupported-ci.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnsupportedCI = void 0;
var UnsupportedCI = (function () {
var _1 = require(".");
var UnsupportedCI = (function (_super) {
__extends(UnsupportedCI, _super);
function UnsupportedCI() {
return _super !== null && _super.apply(this, arguments) || this;
}

@@ -64,3 +82,3 @@ Object.defineProperty(UnsupportedCI, "ciNodeTotal", {

return UnsupportedCI;
}());
}(_1.CIProviderBase));
exports.UnsupportedCI = UnsupportedCI;

48

lib/config/ci-env.config.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CIEnvConfig = void 0;
exports.CIEnvConfig = exports.isCI = exports.detectCI = void 0;
var ci_providers_1 = require("../ci-providers");
var detectCI = function () {
var detected = [
ci_providers_1.AppVeyor,
ci_providers_1.Buildkite,
ci_providers_1.CircleCI,
ci_providers_1.CirrusCI,
ci_providers_1.CodefreshCI,
ci_providers_1.Codeship,
ci_providers_1.GithubActions,
ci_providers_1.GitlabCI,
ci_providers_1.HerokuCI,
ci_providers_1.SemaphoreCI,
ci_providers_1.SemaphoreCI2,
ci_providers_1.TravisCI,
]
.map(function (provider) { return provider.detect; })
.filter(Boolean)[0];
return detected || ci_providers_1.UnsupportedCI;
};
exports.detectCI = detectCI;
var isCI = function () {
return (process.env.CI || 'false').toLowerCase() === 'true' ||
(0, exports.detectCI)() !== ci_providers_1.UnsupportedCI;
};
exports.isCI = isCI;
var CIEnvConfig = (function () {

@@ -65,25 +90,6 @@ function CIEnvConfig() {

CIEnvConfig.ciEnvFor = function (functionName) {
return this.detectCi()[functionName];
return (0, exports.detectCI)()[functionName];
};
CIEnvConfig.detectCi = function () {
var detected = [
ci_providers_1.AppVeyor,
ci_providers_1.Buildkite,
ci_providers_1.CircleCI,
ci_providers_1.CirrusCI,
ci_providers_1.CodefreshCI,
ci_providers_1.Codeship,
ci_providers_1.GithubActions,
ci_providers_1.GitlabCI,
ci_providers_1.HerokuCI,
ci_providers_1.SemaphoreCI,
ci_providers_1.SemaphoreCI2,
ci_providers_1.TravisCI,
]
.map(function (provider) { return provider.detect; })
.filter(Boolean)[0];
return detected || ci_providers_1.UnsupportedCI;
};
return CIEnvConfig;
}());
exports.CIEnvConfig = CIEnvConfig;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KnapsackProEnvConfig = void 0;
exports.commitAuthors = exports.buildAuthor = exports.KnapsackProEnvConfig = void 0;
var childProcess = require("child_process");

@@ -8,3 +8,3 @@ var _1 = require(".");

var Urls = require("../urls");
var spawnSync = childProcess.spawnSync;
var spawnSync = childProcess.spawnSync, execSync = childProcess.execSync;
function logLevel() {

@@ -17,2 +17,7 @@ if (process.env.KNAPSACK_PRO_LOG_LEVEL) {

var knapsackProLogger = new knapsack_pro_logger_1.KnapsackProLogger(logLevel());
var mask = function (string) {
var regexp = /(?<=\w{2})[a-zA-Z]/g;
var maskingChar = '*';
return string.replace(regexp, maskingChar);
};
var KnapsackProEnvConfig = (function () {

@@ -195,10 +200,8 @@ function KnapsackProEnvConfig() {

get: function () {
var regexp = /(?<=\w{2})[a-zA-Z]/g;
var maskingChar = '*';
if (process.env.KNAPSACK_PRO_USER_SEAT) {
return process.env.KNAPSACK_PRO_USER_SEAT.replace(regexp, maskingChar);
return mask(process.env.KNAPSACK_PRO_USER_SEAT);
}
var userSeat = _1.CIEnvConfig.userSeat;
if (userSeat) {
userSeat.replace(regexp, maskingChar);
return mask(userSeat);
}

@@ -214,1 +217,49 @@ return undefined;

exports.KnapsackProEnvConfig = KnapsackProEnvConfig;
var $buildAuthor = function (command) {
try {
var author = command().toString().trim();
return mask(author);
}
catch (error) {
return 'no git <no.git@example.com>';
}
};
var gitBuildAuthor = function () {
return execSync('git log --format="%aN <%aE>" -1 2>/dev/null');
};
var buildAuthor = function (command) {
if (command === void 0) { command = gitBuildAuthor; }
return $buildAuthor(command);
};
exports.buildAuthor = buildAuthor;
var $commitAuthors = function (command) {
try {
return command()
.toString()
.split('\n')
.filter(function (line) { return line !== ''; })
.map(function (line) { return line.trim(); })
.map(function (line) { return line.split('\t'); })
.map(function (_a) {
var commits = _a[0], author = _a[1];
return ({
commits: parseInt(commits, 10),
author: mask(author),
});
});
}
catch (error) {
return [];
}
};
var gitCommitAuthors = function () {
if (_1.isCI) {
execSync("git fetch --shallow-since \"one month ago\" --quiet 2>/dev/null");
}
return execSync("git log --since \"one month ago\" 2>/dev/null | git shortlog --summary --email 2>/dev/null");
};
var commitAuthors = function (command) {
if (command === void 0) { command = gitCommitAuthors; }
return $commitAuthors(command);
};
exports.commitAuthors = commitAuthors;

@@ -28,4 +28,8 @@ "use strict";

var url = '/v1/queues/queue';
var shouldSendTestFilesInPayload = initializeQueue && !attemptConnectToQueue;
var data = __assign({ test_suite_token: config_1.KnapsackProEnvConfig.testSuiteToken, can_initialize_queue: initializeQueue, attempt_connect_to_queue: attemptConnectToQueue, fixed_queue_split: config_1.KnapsackProEnvConfig.fixedQueueSplit, commit_hash: config_1.KnapsackProEnvConfig.commitHash, branch: config_1.KnapsackProEnvConfig.branch, node_total: config_1.KnapsackProEnvConfig.ciNodeTotal, node_index: config_1.KnapsackProEnvConfig.ciNodeIndex, node_build_id: config_1.KnapsackProEnvConfig.ciNodeBuildId, user_seat: config_1.KnapsackProEnvConfig.maskedUserSeat }, (shouldSendTestFilesInPayload && { test_files: allTestFiles }));
var data = __assign({ test_suite_token: config_1.KnapsackProEnvConfig.testSuiteToken, can_initialize_queue: initializeQueue, attempt_connect_to_queue: attemptConnectToQueue, fixed_queue_split: config_1.KnapsackProEnvConfig.fixedQueueSplit, commit_hash: config_1.KnapsackProEnvConfig.commitHash, branch: config_1.KnapsackProEnvConfig.branch, node_total: config_1.KnapsackProEnvConfig.ciNodeTotal, node_index: config_1.KnapsackProEnvConfig.ciNodeIndex, node_build_id: config_1.KnapsackProEnvConfig.ciNodeBuildId, user_seat: config_1.KnapsackProEnvConfig.maskedUserSeat }, (initializeQueue &&
!attemptConnectToQueue && {
test_files: allTestFiles,
build_author: (0, config_1.buildAuthor)(),
commit_authors: (0, config_1.commitAuthors)(),
}));
return this.api.post(url, data);

@@ -32,0 +36,0 @@ };

{
"name": "@knapsack-pro/core",
"version": "6.1.1",
"version": "6.2.0",
"description": "Knapsack Pro Core library splits tests across CI nodes and makes sure that tests will run in optimal time on each CI node. This library gives core features like communication with KnapsackPro.com API. This library is a dependency for other projects specific for particular test runner.",

@@ -57,7 +57,7 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.18.2",
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.18.2",
"@babel/register": "^7.17.7",
"@babel/register": "^7.22.5",
"@types/jest": "^28.1.1",
"@types/node": "^17.0.41",
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^5.27.1",

@@ -64,0 +64,0 @@ "@typescript-eslint/parser": "^5.27.1",

@@ -59,67 +59,2 @@ # @knapsack-pro/core

1. `cd packages/core`
1. Sign in to the npm registry with:
```bash
npm adduser
```
1. Before releasing a new version of the package, please update `CHANGELOG.md` with [`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator):
```bash
gem install github_changelog_generator
# generate CHANGELOG.md
github_changelog_generator --user KnapsackPro --project knapsack-pro-js --pr-wo-labels --issues-wo-labels --include-labels @knapsack-pro/core --since-tag @knapsack-pro/core@5.1.0 --exclude-tags-regex "@knapsack-pro\/(jest|cypress)@.*"
git commit -am "docs(core): update CHANGELOG.md"
git push origin main
```
1. If you have added new files to the repository, and they should be part of the released npm package, please ensure they are included in the `files` array in `package.json`.
1. Compile the project:
```bash
npm run build
```
1. In order to [bump the version of the package](https://docs.npmjs.com/cli/version) run the command below. It will also create a version commit and tag for the release:
```bash
# Bump patch version 0.0.x
npm version patch --no-commit-hooks --tag-version-prefix=@knapsack-pro/core@
# Bump minor version 0.x.0
npm version minor --no-commit-hooks --tag-version-prefix=@knapsack-pro/core@
```
```bash
git commit -am @knapsack-pro/core@x.x.x
git tag @knapsack-pro/core@x.x.x
```
1. Push the commit and tag:
```bash
git push origin main --tags
```
1. When the git tag is on Github, you can update `CHANGELOG.md`:
```bash
github_changelog_generator --user KnapsackPro --project knapsack-pro-js --pr-wo-labels --issues-wo-labels --include-labels @knapsack-pro/core --since-tag @knapsack-pro/core@5.1.0 --exclude-tags-regex "@knapsack-pro\/(jest|cypress)@.*"
git commit -am "docs(core): update CHANGELOG.md"
git push origin main
```
1. Publish the package to the npm registry:
```bash
npm publish
```
1. Update:
- [@knapsack-pro/jest](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/jest)
- [@knapsack-pro/cypress](https://github.com/KnapsackPro/knapsack-pro-js/tree/main/packages/cypress)
See [Publishing](../../#publishing) in the root README.md.
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