Socket
Socket
Sign inDemoInstall

debugbear

Package Overview
Dependencies
75
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.7 to 0.1.8

README.md

86

dist/runCli.js

@@ -44,7 +44,7 @@ "use strict";

var child_process_1 = require("child_process");
var ciEnv = envCi();
var callApi_1 = require("./callApi");
var version = require("../package.json").version;
function __runCli() {
return __awaiter(this, void 0, void 0, function () {
var urlValue, program, slugParts, ciEnvCommitBranch, output, commitHashRegex, commitMessage, baseUrl, repo, commit, err_1;
var urlValue, program, apiKeyInfo, inferBuildInfo, ciEnv, slugParts, ciEnvCommitBranch, output, commitHashRegex, commitMessage, baseUrl, repo, commit, err_1;
return __generator(this, function (_a) {

@@ -58,2 +58,3 @@ switch (_a.label) {

.option("--waitForResult")
.option("--inferBuildInfo")
.option("--ngrokWebPort <ngrokWebPort>")

@@ -76,33 +77,40 @@ .option("--commitHash <commitHash>")

}
if (ciEnv.slug) {
slugParts = ciEnv.slug.split("/");
if (slugParts.length === 2) {
if (!program.repoOwner) {
program.repoOwner = slugParts[0];
return [4 /*yield*/, callApi_1.callApi({ method: "GET", path: "/getApiKeyInfo" })];
case 1:
apiKeyInfo = _a.sent();
inferBuildInfo = program.inferBuildInfo || apiKeyInfo.autoInferBuildInfo;
if (inferBuildInfo) {
ciEnv = envCi();
if (ciEnv.slug) {
slugParts = ciEnv.slug.split("/");
if (slugParts.length === 2) {
if (!program.repoOwner) {
program.repoOwner = slugParts[0];
}
if (!program.repoName) {
program.repoName = slugParts[1];
}
}
if (!program.repoName) {
program.repoName = slugParts[1];
}
}
}
ciEnvCommitBranch = ciEnv.isPr ? ciEnv.prBranch : ciEnv.branch;
if (!program.commitHash && ciEnv.commit) {
program.commitHash = ciEnv.commit;
}
if (!program.commitBranch && ciEnvCommitBranch) {
program.commitBranch = ciEnvCommitBranch;
}
if (!program.baseBranch && ciEnv.isPr && ciEnv.branch) {
program.baseBranch = ciEnv.branch;
}
if (!program.buildTitle && ciEnv.isCi && program.commitHash) {
try {
output = child_process_1.execSync("git log --format=oneline -n 1 " + program.commitHash).toString();
commitHashRegex = /[0-9a-z]{20}[0-9a-z]+/;
if (commitHashRegex.test(output)) {
commitMessage = output.replace(commitHashRegex, "").trim();
program.buildTitle = commitMessage;
ciEnvCommitBranch = ciEnv.isPr ? ciEnv.prBranch : ciEnv.branch;
if (!program.commitHash && ciEnv.commit) {
program.commitHash = ciEnv.commit;
}
if (!program.commitBranch && ciEnvCommitBranch) {
program.commitBranch = ciEnvCommitBranch;
}
if (!program.baseBranch && ciEnv.isPr && ciEnv.branch) {
program.baseBranch = ciEnv.branch;
}
if (!program.buildTitle && ciEnv.isCi && program.commitHash) {
try {
output = child_process_1.execSync("git log --format=oneline -n 1 " + program.commitHash).toString();
commitHashRegex = /[0-9a-z]{20}[0-9a-z]+/;
if (commitHashRegex.test(output)) {
commitMessage = output.replace(commitHashRegex, "").trim();
program.buildTitle = commitMessage;
}
}
catch (err) { }
}
catch (err) { }
}

@@ -126,3 +134,3 @@ baseUrl = undefined;

}
if (!program.ngrokWebPort) return [3 /*break*/, 2];
if (!program.ngrokWebPort) return [3 /*break*/, 3];
if (urlValue) {

@@ -133,7 +141,7 @@ console.log("Can't take URL if getting baseUrl from ngrok");

return [4 /*yield*/, getNgrokTunnelPublicUrl_1.getNgrokTunnelPublicUrl(program.ngrokWebPort)];
case 1:
case 2:
baseUrl = _a.sent();
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
_a.label = 3;
case 3:
_a.trys.push([3, 5, , 6]);
return [4 /*yield*/, analyzePage_1.analyzePage(Object.assign({

@@ -155,6 +163,6 @@ url: urlValue,

])))];
case 3:
case 4:
_a.sent();
return [3 /*break*/, 5];
case 4:
return [3 /*break*/, 6];
case 5:
err_1 = _a.sent();

@@ -164,4 +172,4 @@ console.log("\nCLI command failed");

process.exit(1);
return [3 /*break*/, 5];
case 5: return [2 /*return*/];
return [3 /*break*/, 6];
case 6: return [2 /*return*/];
}

@@ -168,0 +176,0 @@ });

{
"name": "debugbear",
"version": "0.1.7",
"version": "0.1.8",
"description": "Analyze pages with DebugBear, on demand or as part of your Continuous Integration process.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -7,4 +7,4 @@ import * as envCi from "env-ci";

import { execSync } from "child_process";
import { callApi } from "./callApi";
const ciEnv = envCi();
const version = require("../package.json").version;

@@ -19,2 +19,3 @@

.option("--waitForResult")
.option("--inferBuildInfo")
.option("--ngrokWebPort <ngrokWebPort>")

@@ -42,35 +43,43 @@ .option("--commitHash <commitHash>")

if (ciEnv.slug) {
const slugParts = ciEnv.slug.split("/");
if (slugParts.length === 2) {
if (!program.repoOwner) {
program.repoOwner = slugParts[0];
let apiKeyInfo = await callApi({ method: "GET", path: "/getApiKeyInfo" });
const inferBuildInfo =
program.inferBuildInfo || apiKeyInfo.autoInferBuildInfo;
if (inferBuildInfo) {
const ciEnv = envCi();
if (ciEnv.slug) {
const slugParts = ciEnv.slug.split("/");
if (slugParts.length === 2) {
if (!program.repoOwner) {
program.repoOwner = slugParts[0];
}
if (!program.repoName) {
program.repoName = slugParts[1];
}
}
if (!program.repoName) {
program.repoName = slugParts[1];
}
}
let ciEnvCommitBranch = ciEnv.isPr ? ciEnv.prBranch : ciEnv.branch;
if (!program.commitHash && ciEnv.commit) {
program.commitHash = ciEnv.commit;
}
if (!program.commitBranch && ciEnvCommitBranch) {
program.commitBranch = ciEnvCommitBranch;
}
if (!program.baseBranch && ciEnv.isPr && ciEnv.branch) {
program.baseBranch = ciEnv.branch;
}
if (!program.buildTitle && ciEnv.isCi && program.commitHash) {
try {
const output = execSync(
`git log --format=oneline -n 1 ${program.commitHash}`
).toString();
const commitHashRegex = /[0-9a-z]{20}[0-9a-z]+/;
if (commitHashRegex.test(output)) {
const commitMessage = output.replace(commitHashRegex, "").trim();
program.buildTitle = commitMessage;
}
} catch (err) {}
}
}
let ciEnvCommitBranch = ciEnv.isPr ? ciEnv.prBranch : ciEnv.branch;
if (!program.commitHash && ciEnv.commit) {
program.commitHash = ciEnv.commit;
}
if (!program.commitBranch && ciEnvCommitBranch) {
program.commitBranch = ciEnvCommitBranch;
}
if (!program.baseBranch && ciEnv.isPr && ciEnv.branch) {
program.baseBranch = ciEnv.branch;
}
if (!program.buildTitle && ciEnv.isCi && program.commitHash) {
try {
const output = execSync(
`git log --format=oneline -n 1 ${program.commitHash}`
).toString();
const commitHashRegex = /[0-9a-z]{20}[0-9a-z]+/;
if (commitHashRegex.test(output)) {
const commitMessage = output.replace(commitHashRegex, "").trim();
program.buildTitle = commitMessage;
}
} catch (err) {}
}

@@ -77,0 +86,0 @@ let baseUrl = undefined;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc