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

@kearisp/cli

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kearisp/cli - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

lib/types/Param.d.ts

1

lib/makes/Command.d.ts

@@ -25,2 +25,3 @@ import { Option } from "../types";

get name(): string;
protected getCommandInput(args: any, options: any): CommandInput;
option(name: string, params: OptionParams): this;

@@ -27,0 +28,0 @@ protected getOptionSettings(name?: string, alias?: string): Option;

69

lib/makes/Command.js

@@ -8,2 +8,3 @@ "use strict";

const Parser_1 = require("./Parser");
const Logger_1 = require("./Logger");
const CommandInput_1 = require("./CommandInput");

@@ -20,2 +21,13 @@ class Command {

}
getCommandInput(args, options) {
const _this = this;
return new class extends CommandInput_1.CommandInput {
getParamSettings() {
return [];
}
getOptionSettings() {
return _this._options;
}
}(args, options);
}
option(name, params) {

@@ -150,3 +162,3 @@ const { type = "boolean", default: defaultValue, help = true, ...rest } = params || {};

}
return new CommandInput_1.CommandInput(args, options);
return this.getCommandInput(args, options);
}

@@ -186,6 +198,2 @@ async emit(name, input) {

async predictCommand(command, part, input) {
const comAttrReq = /^<([\w_-]+)>(.*)?$/;
const comAttrOpt = /^\[([\w_-]+)](.*)?$/;
const comSpread = /^\[\.\.\.([0-9\w_-]+)](.*)?$/;
const comSpreadReq = /^<\.\.\.([0-9\w_-]+)>(.*)?$/;
const comOther = /^([^\[\]<>{}]+)(.*)$/;

@@ -200,4 +208,4 @@ let exitCount = 0;

let stepReg;
if (comAttrReq.test(restCommand)) {
const [, name, rest] = comAttrReq.exec(restCommand);
if (Parser_1.Parser.paramRequiredRegexp.test(restCommand)) {
const [, name, rest] = Parser_1.Parser.paramRequiredRegexp.exec(restCommand);
isAction = true;

@@ -208,4 +216,4 @@ predict = name;

}
else if (comAttrOpt.test(restCommand)) {
const [, name, rest] = comAttrOpt.exec(restCommand);
else if (Parser_1.Parser.paramOptionalRegexp.test(restCommand)) {
const [, name, rest] = Parser_1.Parser.paramOptionalRegexp.exec(restCommand);
isAction = true;

@@ -216,18 +224,18 @@ predict = name;

}
else if (comSpread.test(restCommand)) {
const [, match, rest] = comSpread.exec(restCommand) || [];
else if (Parser_1.Parser.spreadRequiredRegexp.test(restCommand)) {
const [, match, rest] = Parser_1.Parser.spreadRequiredRegexp.exec(restCommand) || [];
isAction = true;
predict = match;
restCommand = rest;
stepReg = "(.+?)?";
stepReg = "(.+?)";
}
else if (comSpreadReq.test(restCommand)) {
const [, match, rest] = comSpreadReq.exec(restCommand) || [];
else if (Parser_1.Parser.spreadOptionalRegexp.test(restCommand)) {
const [, match, rest] = Parser_1.Parser.spreadOptionalRegexp.exec(restCommand) || [];
isAction = true;
predict = match;
restCommand = rest;
stepReg = "(.+?)";
stepReg = "(.+?)?";
}
else if (comOther.test(restCommand)) {
const [, match, rest] = comOther.exec(restCommand) || [];
const [, match, rest = ""] = comOther.exec(restCommand) || [];
isAction = false;

@@ -238,8 +246,4 @@ predict = match;

}
exitCount++;
if (exitCount > 100) {
console.warn("Emergency exit", {
restCommand
});
return null;
if (++exitCount > 50) {
throw new Error(`Emergency exit. Rest command: "${restCommand}"`);
}

@@ -252,3 +256,9 @@ if (stepReg) {

if (completion) {
const predicts = await Promise.resolve(completion.action(input));
let predicts = await completion.action(input);
const value = input.argument(predict);
if (Array.isArray(value)) {
predicts = predicts.filter((p) => {
return !value.includes(p);
});
}
resPredicts = predicts.reduce((res, predict) => {

@@ -302,2 +312,13 @@ return [

if (parser.isSpread(command)) {
const name = parser.parseSpreadCommand(command);
const value = [];
while (!parser.eol) {
if (parser.part) {
value.push(parser.part);
}
parser.next();
}
args[name] = value;
Logger_1.Logger.info(args);
return this.predictCommand(command, parser.part, this.getCommandInput(args, options));
}

@@ -312,3 +333,3 @@ else if (!parser.isLast && parser.isCommand(command)) {

else if (parser.isLast && parser.isCommand(command, true)) {
return this.predictCommand(command, parser.part, new CommandInput_1.CommandInput(args, options));
return this.predictCommand(command, parser.part, this.getCommandInput(args, options));
}

@@ -315,0 +336,0 @@ else {

@@ -0,1 +1,2 @@

import { Option, Param } from "../types";
export declare class CommandInput {

@@ -5,2 +6,4 @@ protected readonly _arguments: any;

constructor(_arguments: any, _options: any);
protected getParamSettings(): Param[];
protected getOptionSettings(): Option[];
argument(key: string): null | string;

@@ -7,0 +10,0 @@ arguments(): any;

@@ -9,2 +9,8 @@ "use strict";

}
getParamSettings() {
return [];
}
getOptionSettings() {
return [];
}
argument(key) {

@@ -11,0 +17,0 @@ if (key in this._arguments) {

@@ -7,3 +7,2 @@ "use strict";

const FS = require("fs");
const format_1 = require("date-fns/format");
class Logger {

@@ -31,3 +30,12 @@ static log(...args) {

const LOG_FILE = Path.join(DATA_DIR, "ws.log");
const time = (0, format_1.format)(new Date(), "yyyy-MM-dd hh:mm:ss");
const getFormatedTime = () => {
const prepareValue = (value) => {
if (value < 9) {
return `0${value}`;
}
return `${value}`;
};
const date = new Date(), year = date.getFullYear(), month = prepareValue(date.getMonth() + 1), days = prepareValue(date.getDate()), hours = prepareValue(date.getHours()), minutes = prepareValue(date.getMinutes()), seconds = prepareValue(date.getSeconds());
return `${year}-${month}-${days} ${hours}:${minutes}:${seconds}`;
};
const logData = data.map((item) => {

@@ -39,3 +47,3 @@ return typeof item !== "string" ? JSON.stringify(item) : item;

}
FS.appendFileSync(LOG_FILE, `[${time}] ${type}: ${logData}\n`);
FS.appendFileSync(LOG_FILE, `[${getFormatedTime()}] ${type}: ${logData}\n`);
}

@@ -42,0 +50,0 @@ static mute() {

export declare class Parser {
readonly parts: string[];
static readonly attrRequiredRegexp: RegExp;
static readonly attrOptionalRegexp: RegExp;
static readonly paramRequiredRegexp: RegExp;
static readonly paramOptionalRegexp: RegExp;
static readonly spreadRequiredRegexp: RegExp;
static readonly spreadOptionalRegexp: RegExp;
static readonly optionRegexp: RegExp;
static readonly optionMultipleRegexp: RegExp;
static readonly spreadRequiredRegexp: RegExp;
static readonly spreadOptionalRegexp: RegExp;
protected index: number;

@@ -10,0 +10,0 @@ constructor(parts: string[]);

@@ -17,3 +17,3 @@ "use strict";

get part() {
return this.parts[this.index];
return this.parts[this.index] || "";
}

@@ -37,5 +37,2 @@ get isLast() {

isCommand(command, partial = false) {
if (this.eol || this.isOption()) {
return false;
}
const { regex, partRegex } = this.parse(command);

@@ -135,7 +132,7 @@ if (partial) {

exports.Parser = Parser;
Parser.attrRequiredRegexp = /^<([\w_-]+)>(.*)?$/;
Parser.attrOptionalRegexp = /^\[([\w_-]+)](.*)?$/;
Parser.paramRequiredRegexp = /^<([\w_-]+)>(.*)?$/;
Parser.paramOptionalRegexp = /^\[([\w_-]+)](.*)?$/;
Parser.spreadRequiredRegexp = /^<\.\.\.([0-9\w_-]+)>(.*)?$/;
Parser.spreadOptionalRegexp = /^\[\.\.\.([0-9\w_-]+)](.*)$/;
Parser.optionRegexp = /^-(?:-(\w[\w\d_-]*)|(\w))$/;
Parser.optionMultipleRegexp = /^-(\w+)$/;
Parser.spreadRequiredRegexp = /^<\.\.\.([0-9\w_-]+)>(.*)?$/;
Parser.spreadOptionalRegexp = /^\[\.\.\.([0-9\w_-]+)](.*)$/;
export * from "./Option";
export * from "./Param";

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./Option"), exports);
__exportStar(require("./Param"), exports);
{
"name": "@kearisp/cli",
"version": "2.0.1",
"version": "2.0.2",
"license": "MIT",

@@ -38,3 +38,2 @@ "author": "Kris Papercut <krispcut@gmail.com>",

"@types/node": "^20.12.7",
"date-fns": "^3.6.0",
"fs": "^0.0.1-security",

@@ -41,0 +40,0 @@ "jest": "^29.7.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