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

@sprocketbot/listodo

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sprocketbot/listodo - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

rollup.config.js

88

bin/index.js

@@ -1,5 +0,85 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lib_1 = require("./lib");
(0, lib_1.listodo)({
#!/usr/bin/env node
import { execSync } from 'child_process';
import chalk from 'chalk';
const getGrepOptions = (options) => {
let opts = " --full-name";
if (options.searchUntracked)
opts += " --untracked";
if (options.searchIgnored)
opts += " --untracked --no-exclude-standard";
if (options.lineNumbers)
opts += " -n";
if (options.columnNumbers)
opts += " --column";
if (options.ignoreCase)
opts += " --ignore-case";
return opts;
};
const parseGrep = (grep) => {
const tokens = grep.split(":");
return {
file: tokens[0],
line: parseInt(tokens[1]),
column: parseInt(tokens[2]),
content: tokens[3].trim(),
};
};
const BLAME_REGEX = /(.*) \d+ \d+ \d+\nauthor (.*)\nauthor-mail <(.*)>\nauthor-time (.*)\nauthor-tz (.*)\ncommitter (.*)\ncommitter-mail (.*)\ncommitter-time (.*)\ncommitter-tz (.*)\nsummary (.*)\nfilename (.*)\n\t(.*)\n/;
const parseBlame = (blame) => {
const match = blame.match(BLAME_REGEX);
if (!match) {
console.log(`Unable to parse blame ${blame}`);
return {};
}
const isCommitted = match[1] !== "0000000000000000000000000000000000000000" && match[1] !== "00000000";
return {
isCommitted: isCommitted,
rev: match[1],
author: match[2],
authorEmail: match[3],
timestamp: parseInt(match[4]),
timezone: parseInt(match[5]),
commitMessage: match[10],
};
};
const getTodos = (options) => {
const gitGrep = `git grep ${getGrepOptions(options)} TODO ${options.files.join(" ")}`;
let grepLines;
try {
grepLines = execSync(gitGrep).toString().split("\n").filter(l => l.length);
}
catch (err) {
// console.log("Grep Error: ", err);
throw err; // TODO handle
}
const todos = grepLines.map(parseGrep);
for (let todo of todos) {
const gitBlame = `git blame -L ${todo.line},${todo.line} -p ${todo.file}`;
try {
const blame = execSync(gitBlame, { stdio: "pipe" }).toString();
Object.assign(todo, parseBlame(blame));
}
catch (err) {
// console.error(`Blame error: Unable to find blame for ${todo.file} ${todo.line}:${todo.column}`);
continue;
}
}
return todos;
};
const todoToStr = (todo) => {
let datetime = "";
if (todo.isCommitted)
datetime = new Date(todo.timestamp * 1000).toLocaleString();
const l1 = chalk.bold.yellowBright(`${todo.file}:${todo.line}:${todo.column}`);
const l2 = todo.isCommitted ? chalk.gray(`\n ${todo.author} @ ${datetime}`) : "";
const l3 = chalk.italic.yellowBright(`\n ${todo.content}`);
return l1 + l2 + l3;
};
const listodo = (options) => {
const todos = getTodos(options);
todos.map(todoToStr).forEach(t => console.log(t + "\n"));
};
listodo({
files: ["test"],

@@ -6,0 +86,0 @@ searchUntracked: true,

7

package.json
{
"name": "@sprocketbot/listodo",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -9,3 +9,3 @@ "bin": "bin/index.js",

"dev": "nodemon src/index.ts",
"build": "rimraf bin && tsc"
"build": "rimraf bin && rollup -c"
},

@@ -24,4 +24,7 @@ "repository": {

"devDependencies": {
"@rollup/plugin-typescript": "^8.3.0",
"nodemon": "^2.0.15",
"rimraf": "^3.0.2",
"rollup": "^2.60.2",
"rollup-plugin-preserve-shebang": "^1.0.1",
"ts-node": "^10.4.0",

@@ -28,0 +31,0 @@ "typescript": "^4.5.2"

@@ -0,1 +1,3 @@

#!/usr/bin/env node
import { listodo } from "./lib";

@@ -2,0 +4,0 @@

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