bob-core 2.0.0-beta.13 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +12 -16
- package/dist/cjs/{package-6GoPiEev.cjs → package-o2EGFSAP.cjs} +1 -1
- package/dist/cjs/src/Cli.d.ts +2 -4
- package/dist/cjs/src/Command.d.ts +2 -4
- package/dist/cjs/src/CommandIO.d.ts +4 -1
- package/dist/cjs/src/CommandRegistry.d.ts +9 -3
- package/dist/cjs/src/StringSimilarity.d.ts +26 -0
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/index.js +559 -786
- package/dist/esm/{package-CtFSlXKR.js → package-C-2LYcDa.js} +1 -1
- package/dist/esm/src/Cli.d.ts +2 -4
- package/dist/esm/src/Command.d.ts +2 -4
- package/dist/esm/src/CommandIO.d.ts +4 -1
- package/dist/esm/src/CommandRegistry.d.ts +9 -3
- package/dist/esm/src/StringSimilarity.d.ts +26 -0
- package/dist/esm/src/index.d.ts +1 -0
- package/package.json +2 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const t = "bob-core", e = "2.0.0-beta.
|
|
1
|
+
const t = "bob-core", e = "2.0.0-beta.15", s = "BOB Core", i = "module", m = !1, n = ["dist/**"], r = { ".": { import: "./dist/esm/index.js", require: "./dist/cjs/index.js" } }, o = { "*": { "*": ["./dist/cjs/*.d.ts"] } }, c = { start: "node -r @swc-node/register debug/main.ts", build: "rimraf ./dist && vite build", typecheck: "tsc --noEmit", prepack: "npm run build", test: "vitest run", lint: "eslint .", "lint:fix": "eslint . --fix" }, p = "Léo Hubert", d = "ISC", l = { "@eslint/js": "^9.37.0", "@faker-js/faker": "^10.0.0", "@swc-node/register": "^1.11.1", "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@types/minimist": "^1.2.5", "@types/node": "^20.14.5", "@types/prompts": "^2.4.9", "@types/string-similarity": "^4.0.2", "@vitest/coverage-v8": "^3.2.4", eslint: "^9.37.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-prettier": "^5.5.4", prettier: "^3.6.2", rimraf: "^6.0.1", tsx: "^4.20.6", typescript: "^5.7.3", "typescript-eslint": "^8.46.0", vite: "^7.1.6", "vite-plugin-dts": "^4.5.4", vitest: "^3.2.4" }, a = { chalk: "^5.6.2", minimist: "^1.2.8", prompts: "^2.4.2" }, f = {
|
|
2
2
|
name: t,
|
|
3
3
|
version: e,
|
|
4
4
|
description: s,
|
package/dist/esm/src/Cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from './Command.js';
|
|
2
|
-
import { CommandRegistry, CommandResolver, FileImporter } from './CommandRegistry.js';
|
|
2
|
+
import { CommandRegistry, CommandRegistryOptions, CommandResolver, FileImporter } from './CommandRegistry.js';
|
|
3
3
|
import { ExceptionHandler } from './ExceptionHandler.js';
|
|
4
4
|
import { Logger } from './Logger.js';
|
|
5
5
|
import { default as HelpCommand, HelpCommandOptions } from './commands/HelpCommand.js';
|
|
@@ -16,9 +16,7 @@ export declare class Cli<C extends ContextDefinition = ContextDefinition> {
|
|
|
16
16
|
readonly commandRegistry: CommandRegistry;
|
|
17
17
|
private readonly exceptionHandler;
|
|
18
18
|
private readonly helpCommand;
|
|
19
|
-
protected newCommandRegistry(opts:
|
|
20
|
-
logger: Logger;
|
|
21
|
-
}): CommandRegistry;
|
|
19
|
+
protected newCommandRegistry(opts: CommandRegistryOptions): CommandRegistry;
|
|
22
20
|
protected newHelpCommand(opts: HelpCommandOptions): HelpCommand;
|
|
23
21
|
protected newExceptionHandler(opts: {
|
|
24
22
|
logger: Logger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandIO } from './CommandIO.js';
|
|
1
|
+
import { CommandIO, CommandIOOptions } from './CommandIO.js';
|
|
2
2
|
import { CommandParser } from './CommandParser.js';
|
|
3
3
|
import { Logger } from './Logger.js';
|
|
4
4
|
import { CommandOption } from './contracts/index.js';
|
|
@@ -43,9 +43,7 @@ export declare class Command<C extends ContextDefinition = ContextDefinition, Op
|
|
|
43
43
|
options: Options;
|
|
44
44
|
arguments: Arguments;
|
|
45
45
|
}): CommandParser<Options, Arguments>;
|
|
46
|
-
protected newCommandIO(opts:
|
|
47
|
-
logger: Logger;
|
|
48
|
-
}): CommandIO;
|
|
46
|
+
protected newCommandIO(opts: CommandIOOptions): CommandIO;
|
|
49
47
|
constructor(command: string, opts?: {
|
|
50
48
|
description?: string;
|
|
51
49
|
group?: string;
|
|
@@ -6,9 +6,12 @@ export type SelectOption = {
|
|
|
6
6
|
selected?: boolean | undefined;
|
|
7
7
|
description?: string | undefined;
|
|
8
8
|
};
|
|
9
|
+
export type CommandIOOptions = {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
};
|
|
9
12
|
export declare class CommandIO {
|
|
10
13
|
private logger;
|
|
11
|
-
constructor(
|
|
14
|
+
constructor(opts: CommandIOOptions);
|
|
12
15
|
/**
|
|
13
16
|
* Logger methods
|
|
14
17
|
*/
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { Command } from './Command.js';
|
|
2
|
-
import { CommandIO } from './CommandIO.js';
|
|
2
|
+
import { CommandIO, CommandIOOptions } from './CommandIO.js';
|
|
3
3
|
import { Logger } from './Logger.js';
|
|
4
|
+
import { StringSimilarity } from './StringSimilarity.js';
|
|
4
5
|
import { ArgumentsSchema, ContextDefinition, OptionsSchema } from './lib/types.js';
|
|
5
6
|
export type CommandResolver = (path: string) => Promise<Command | null>;
|
|
6
7
|
export type FileImporter = (filePath: string) => Promise<unknown>;
|
|
8
|
+
export type CommandRegistryOptions = {
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
stringSimilarity?: StringSimilarity;
|
|
11
|
+
};
|
|
7
12
|
export declare class CommandRegistry {
|
|
8
13
|
private readonly commands;
|
|
9
14
|
protected readonly io: CommandIO;
|
|
10
15
|
protected readonly logger: Logger;
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
private readonly stringSimilarity;
|
|
17
|
+
protected newCommandIO(opts: CommandIOOptions): CommandIO;
|
|
18
|
+
constructor(opts?: CommandRegistryOptions);
|
|
13
19
|
getAvailableCommands(): string[];
|
|
14
20
|
getCommands(): Array<Command>;
|
|
15
21
|
private importFile;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface SimilarityResult {
|
|
2
|
+
rating: number;
|
|
3
|
+
target: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BestMatchResult {
|
|
6
|
+
bestMatch: SimilarityResult;
|
|
7
|
+
bestMatchIndex: number;
|
|
8
|
+
ratings: SimilarityResult[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* String similarity calculator using Dice's Coefficient algorithm
|
|
12
|
+
*/
|
|
13
|
+
export declare class StringSimilarity {
|
|
14
|
+
/**
|
|
15
|
+
* Generate bigrams (character pairs) from a string
|
|
16
|
+
*/
|
|
17
|
+
private getBigrams;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate Dice's Coefficient similarity between two strings (0-1 scale)
|
|
20
|
+
*/
|
|
21
|
+
calculateSimilarity(str1: string, str2: string): number;
|
|
22
|
+
/**
|
|
23
|
+
* Find best matching string and ratings for all candidates
|
|
24
|
+
*/
|
|
25
|
+
findBestMatch(target: string, candidates: string[]): BestMatchResult;
|
|
26
|
+
}
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './CommandRegistry.js';
|
|
|
7
7
|
export * from './Cli.js';
|
|
8
8
|
export * from './Logger.js';
|
|
9
9
|
export * from './ExceptionHandler.js';
|
|
10
|
+
export * from './StringSimilarity.js';
|
|
10
11
|
export * from './lib/types.js';
|
|
11
12
|
export * from './errors/index.js';
|
|
12
13
|
export * from './options/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bob-core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.15",
|
|
4
4
|
"description": "BOB Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"chalk": "^5.6.2",
|
|
58
58
|
"minimist": "^1.2.8",
|
|
59
|
-
"prompts": "^2.4.2"
|
|
60
|
-
"string-similarity": "^4.0.4"
|
|
59
|
+
"prompts": "^2.4.2"
|
|
61
60
|
}
|
|
62
61
|
}
|