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

@aomex/commander

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aomex/commander - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

4

CHANGELOG.md
# @aomex/commander
## 0.0.13
## 0.0.14
### Patch Changes
- [`d773432`](https://github.com/aomex/aomex/commit/d773432e1711d787c483553b3e2b0f667db71f01) Thanks [@geekact](https://github.com/geekact)! - feat(commander): logics can call each other
- [`2d8082e`](https://github.com/aomex/aomex/commit/2d8082e5763bdcdbdb34ccbee40ce5bb4869dab8) Thanks [@geekact](https://github.com/geekact)! - fix(commander): logics cannot call each other

@@ -9,0 +9,0 @@ ## 0.0.12

@@ -5,27 +5,27 @@ import { ConsoleMiddlewareToken, ConsoleContext, ConsoleChain } from '@aomex/console';

interface CommandDocs {
summary?: string;
description?: string;
}
type CollectArrayType<T> = T extends ConsoleMiddlewareToken<infer R> ? R : object;
interface BuilderOptions<Props extends object, T extends ConsoleMiddlewareToken[] | [], Logics extends object> {
interface BuilderOptions<Props extends object, T extends ConsoleMiddlewareToken[] | [], Logics extends Builder.LogicFunction> {
showInHelp?: boolean;
docs?: CommandDocs;
docs?: Builder.Docs;
mount?: T;
logics?: Logics & ThisType<Builder.ParsedLogicFunction<Logics>>;
action: (ctx: Props & Union2Intersection<CollectArrayType<T[number]>> & ConsoleContext, logic: Builder.ParsedLogicFunction<Logics>) => any;
logics?: Logics & ThisType<Logics & {
ctx: Builder.Context<Props, T>;
}>;
action: (ctx: Builder.Context<Props, T>, logic: Logics) => any;
}
declare namespace Builder {
interface LogicFunction<Props extends object, T extends ConsoleMiddlewareToken[] | []> {
[key: string]: (ctx: Props & Union2Intersection<CollectArrayType<T[number]>> & ConsoleContext, ...args: any[]) => any;
interface LogicFunction {
[key: string]: (...args: any[]) => any;
}
type ParsedLogicFunction<Logics extends object> = {
[K in keyof Logics]: Logics[K] extends (ctx: any, ...args: infer P) => infer R ? (...args: P) => R : never;
};
type Context<Props extends object, T extends ConsoleMiddlewareToken[] | []> = Props & Union2Intersection<CollectArrayType<T[number]>> & ConsoleContext;
interface Docs {
summary?: string;
description?: string;
}
}
declare class Builder<Props extends object = object, T extends ConsoleMiddlewareToken[] | [] = [], Logics extends Builder.LogicFunction<Props, T> = Builder.LogicFunction<Props, T>> {
declare class Builder<Props extends object = object, T extends ConsoleMiddlewareToken[] | [] = [], Logics extends Builder.LogicFunction = Builder.LogicFunction> {
readonly chain: ConsoleChain;
readonly commands: string[];
readonly showInHelp: boolean;
readonly docs: CommandDocs;
readonly docs: Builder.Docs;
constructor(prefix: string, commands: string[], options: BuilderOptions<Props, T, Logics>);

@@ -48,3 +48,3 @@ match(command: string): boolean;

constructor(options?: CommanderOptions<Props>);
create<T extends ConsoleMiddlewareToken<object>[] | [], Logics extends Builder.LogicFunction<Props, T>>(command: string | string[], options: BuilderOptions<Props, T, Logics>): void;
create<T extends ConsoleMiddlewareToken<object>[] | [], Logics extends Builder.LogicFunction>(command: string | string[], options: BuilderOptions<Props, T, Logics>): void;
protected toMiddleware(): Middleware;

@@ -58,2 +58,2 @@ }

export { Builder, BuilderOptions, CommandDocs, Commander, CommanderOptions, CommandsOptions, commanders };
export { Builder, BuilderOptions, Commander, CommanderOptions, CommandsOptions, commanders };

@@ -27,5 +27,10 @@ // src/commanders.ts

if (options.logics) {
const logicContext = {};
Object.keys(options.logics).forEach((key) => {
logics[key] = options.logics[key].bind(logics, ctx);
logicContext[key] = logics[key] = options.logics[key].bind(
logicContext,
ctx
);
});
logicContext["ctx"] = ctx;
}

@@ -32,0 +37,0 @@ options.action(ctx, logics);

{
"name": "@aomex/commander",
"version": "0.0.13",
"version": "0.0.14",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

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