🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

nest-commander

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-commander - npm Package Compare versions

Comparing version

to
3.14.0

168

CHANGELOG.md
# nest-commander
## 3.14.0
### Minor Changes
- 1cdac14: feat: Add option for Help Configuration using the .configureHelp()
function in commander js
## 3.13.0

@@ -7,4 +14,4 @@

- c29737c: Enhance filesystem autocomplete support for Bash and Zsh by introducing an
opt-in option based on an environment variable.
- c29737c: Enhance filesystem autocomplete support for Bash and Zsh by
introducing an opt-in option based on an environment variable.

@@ -15,4 +22,4 @@ ## 3.12.5

- 72b2a00: Move the fig completion package to an optional import to get around jest
throwing an error about esm packages
- 72b2a00: Move the fig completion package to an optional import to get around
jest throwing an error about esm packages

@@ -29,3 +36,4 @@ ## 3.12.4

- e66901a: update package @fig/complete-commander to v3.0.0 to support commander v11
- e66901a: update package @fig/complete-commander to v3.0.0 to support commander
v11

@@ -42,3 +50,4 @@ ## 3.12.2

- a3b683d: Remap the options to the name passed in the `@Options()` decorator, if provided
- a3b683d: Remap the options to the name passed in the `@Options()` decorator,
if provided

@@ -55,4 +64,4 @@ ## 3.12.0

- 8cc3109: The CommandRunnerService now re-throws the error regardless of the contents, it
just adds a new log above the error as well
- 8cc3109: The CommandRunnerService now re-throws the error regardless of the
contents, it just adds a new log above the error as well

@@ -84,6 +93,7 @@ ## 3.11.0

- 6cc1112: Add ability to pass NestApplicationContextOptions to CommandFactoryRunOptions.
- 6cc1112: Add ability to pass NestApplicationContextOptions to
CommandFactoryRunOptions.
Now CommandFactory.createWithoutRunning() can accept more options, for example,
bufferLogs to pre-save Nest startup logs.
Now CommandFactory.createWithoutRunning() can accept more options, for
example, bufferLogs to pre-save Nest startup logs.

@@ -94,4 +104,4 @@ ## 3.7.1

- 1ceab9d: Log error and stack wtih custom error message instead of just custom error
message
- 1ceab9d: Log error and stack wtih custom error message instead of just custom
error message

@@ -102,9 +112,9 @@ ## 3.7.0

- 9a5f555: Add a new method to create an application but nott run it in case of needing to
modify the logger or similar situations.
- 9a5f555: Add a new method to create an application but nott run it in case of
needing to modify the logger or similar situations.
Now the `CommandFactory.createWithoutRunning()` method can be used to create a
Nest commander application without running the `commandRunner.run()`. To run the
newly created application, `CommandFactory.runApplicaiton(app)` can be called. I
may change this to be a simple `app.run()` in the future.
Nest commander application without running the `commandRunner.run()`. To run
the newly created application, `CommandFactory.runApplicaiton(app)` can be
called. I may change this to be a simple `app.run()` in the future.

@@ -127,3 +137,4 @@ ## 3.6.3

- c35e8cc: Fixed issue with parsing serviceErrorHandler option to properly override default behaviour
- c35e8cc: Fixed issue with parsing serviceErrorHandler option to properly
override default behaviour

@@ -136,10 +147,10 @@ ## 3.6.0

This option allows for catching and handling errors at the Nest service execution level so that
lifecycle hooks still properly work. By default it is set to
`(err: Error) => process.stderr.write(err.toString())`.
This option allows for catching and handling errors at the Nest service
execution level so that lifecycle hooks still properly work. By default it is
set to `(err: Error) => process.stderr.write(err.toString())`.
- 09b6134: Add the ability to have a Root command
With the `@RootCommand()` the `-h` flag can now output the options of the default command _along
with_ the names of the other commands.
With the `@RootCommand()` the `-h` flag can now output the options of the
default command _along with_ the names of the other commands.

@@ -150,8 +161,10 @@ ## 3.5.0

- d2e5fc8: Allow for use of request scoped providers through a new module decorator
- d2e5fc8: Allow for use of request scoped providers through a new module
decorator
By making use of the `@RequestModule()` decorator for modules, as mock request object can be set
as a singleton to help the use of `REQUEST` scoped providers in a singleton context. There's now
also an error that is logged in the case of a property of `undefined` being called, as this is
usually indicative of a `REQUEST` scoped provider being called from a `SINGLETON` context.
By making use of the `@RequestModule()` decorator for modules, as mock request
object can be set as a singleton to help the use of `REQUEST` scoped providers
in a singleton context. There's now also an error that is logged in the case
of a property of `undefined` being called, as this is usually indicative of a
`REQUEST` scoped provider being called from a `SINGLETON` context.

@@ -164,3 +177,4 @@ ## 3.4.0

- 74c88f5: Add new api registerWithSubCommand to CommandRunner Class
- abff78d: Allow for options to be parsed positionally via an option passed to CommandFactory
- abff78d: Allow for options to be parsed positionally via an option passed to
CommandFactory

@@ -171,4 +185,4 @@ ## 3.3.0

- 8c639d3: fix: update module resolution to node16 so dynamic imports are not transpiled out during
TS build
- 8c639d3: fix: update module resolution to node16 so dynamic imports are not
transpiled out during TS build

@@ -179,3 +193,4 @@ ## 3.2.1

- 5c089a6: Fixed an issue preventing use of ESM packages as plugins in the command factory
- 5c089a6: Fixed an issue preventing use of ESM packages as plugins in the
command factory

@@ -198,11 +213,13 @@ ## 3.2.0

- d6ebe0e: Migrate `CommandRunner` from interface to abstract class and add `.command`
- d6ebe0e: Migrate `CommandRunner` from interface to abstract class and add
`.command`
This change was made so that devs could access `this.command` inside the `CommandRunner` instance
and have access to the base command object from commander. This allows for access to the `help`
commands in a programatic fashion.
This change was made so that devs could access `this.command` inside the
`CommandRunner` instance and have access to the base command object from
commander. This allows for access to the `help` commands in a programatic
fashion.
To update to this version, any `implements CommandRunner` should be changed to
`extends CommandRunner`. If there is a `constructor` to the `CommandRunner` then it should also
use `super()`.
`extends CommandRunner`. If there is a `constructor` to the `CommandRunner`
then it should also use `super()`.

@@ -225,6 +242,7 @@ ### Minor Changes

Option choices are now supported either as a static string array or via the `@OptionChoicesFor()`
decorator on a class method. This decorator method approach allows for using a class's injected
providers to give the chocies, which means they could come from a database or a config file
somewhere if the CLI is set up to handle such a case
Option choices are now supported either as a static string array or via the
`@OptionChoicesFor()` decorator on a class method. This decorator method
approach allows for using a class's injected providers to give the chocies,
which means they could come from a database or a config file somewhere if the
CLI is set up to handle such a case

@@ -237,7 +255,8 @@ ## 2.4.0

There is a new `CliUtilityService` and `@InjectCommander()` decorator that allows for direct
access to the commander instance. The utility service has methods like `parseBoolean`, `parseInt`,
and `parseFloat`. The number parsing methods are just simple wrappers around `Number.parse*()`,
but the boolean parsing method handles true being `yes`, `y`, `1`, `true`, and `t` and false being
`no`, `n`, `false`, `f`, and `0`.
There is a new `CliUtilityService` and `@InjectCommander()` decorator that
allows for direct access to the commander instance. The utility service has
methods like `parseBoolean`, `parseInt`, and `parseFloat`. The number parsing
methods are just simple wrappers around `Number.parse*()`, but the boolean
parsing method handles true being `yes`, `y`, `1`, `true`, and `t` and false
being `no`, `n`, `false`, `f`, and `0`.

@@ -272,4 +291,4 @@ ## 2.3.5

- 478c0d9: Make commands built with `usePlugins: true` not exit on non-found config file, just log
extra data when an error happens
- 478c0d9: Make commands built with `usePlugins: true` not exit on non-found
config file, just log extra data when an error happens

@@ -280,14 +299,15 @@ ## 2.3.0

- 6c9eaa3: Commands can now be built with the expectation of reading in plugins to dynamically
modify the CLI
- 6c9eaa3: Commands can now be built with the expectation of reading in plugins
to dynamically modify the CLI
By using the `usePlugins` option for the `CommandFactory`, the built CLI can expect to find a
configuration file at `nest-commander.json` (or several others, check the docs) to allow for users
to plug commands in after the CLI is built.
By using the `usePlugins` option for the `CommandFactory`, the built CLI can
expect to find a configuration file at `nest-commander.json` (or several
others, check the docs) to allow for users to plug commands in after the CLI
is built.
- 13723bd: Subcommands can now be created
There's a new decorator, `@SubCommand()` for creating nested commands like `docker compose up`.
There's also a new option on `@Command()` (`subCommands`) for setting up this sub command
relationship.
There's a new decorator, `@SubCommand()` for creating nested commands like
`docker compose up`. There's also a new option on `@Command()` (`subCommands`)
for setting up this sub command relationship.

@@ -300,5 +320,5 @@ ## 2.2.0

`nest-commander-testing` now also uses a `hex` instead of `utf-8` encoding when creating a random
js file name during the `CommandTestFactory` command. This is to help create more predictable
output names.
`nest-commander-testing` now also uses a `hex` instead of `utf-8` encoding
when creating a random js file name during the `CommandTestFactory` command.
This is to help create more predictable output names.

@@ -309,4 +329,4 @@ ## 2.1.0

- 6df8964: Adds in a new metadata option for the @Option() decorator to make the option required,
just like a required argument
- 6df8964: Adds in a new metadata option for the @Option() decorator to make the
option required, just like a required argument

@@ -319,4 +339,5 @@ ## 2.0.0

WHAT: Upgrade `@nestjs/` dependencies to v8 and RxJS to v7 WHY: To support the latest version of
Nest HOW: upgrading to Nest v8 should be all that's necessary (along with rxjs to v7)
WHAT: Upgrade `@nestjs/` dependencies to v8 and RxJS to v7 WHY: To support the
latest version of Nest HOW: upgrading to Nest v8 should be all that's
necessary (along with rxjs to v7)

@@ -329,5 +350,5 @@ ## 1.3.0

There is a new `runWithoutClosing` method in the `CommandFactory` class. This command allows for
not having the created Nest Application get closed immediately, which should allow for the use of
indefinitely runnable commands.
There is a new `runWithoutClosing` method in the `CommandFactory` class. This
command allows for not having the created Nest Application get closed
immediately, which should allow for the use of indefinitely runnable commands.

@@ -340,7 +361,8 @@ ## 1.2.0

Within the `CommandFactory.run()` now as a second parameter you can either keep passing just the
logger, or you can pass in an object with the logger and an `errorHandler`. Ths `errorHandler` is
a method that takes in an `Error` and returns `void`. The errorHandler will be passed to
commander's `exitOverride` method, if it exists. This is useful for better handling errors and
giving the dev more control over what is seen. There is also no longer an
Within the `CommandFactory.run()` now as a second parameter you can either
keep passing just the logger, or you can pass in an object with the logger and
an `errorHandler`. Ths `errorHandler` is a method that takes in an `Error` and
returns `void`. The errorHandler will be passed to commander's `exitOverride`
method, if it exists. This is useful for better handling errors and giving the
dev more control over what is seen. There is also no longer an
`unhandledPromiseRejection` on empty commands.
{
"name": "nest-commander",
"version": "3.13.0",
"version": "3.14.0",
"description": "A module for making CLI applications with NestJS. Decorators for running commands and separating out config parsers included. This package works on top of commander.",

@@ -27,3 +27,3 @@ "repository": {

"@fig/complete-commander": "^3.0.0",
"@golevelup/nestjs-discovery": "4.0.0",
"@golevelup/nestjs-discovery": "4.0.1",
"commander": "11.1.0",

@@ -30,0 +30,0 @@ "cosmiconfig": "8.3.6",

import { LoggerService, LogLevel } from '@nestjs/common';
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
import { OutputConfiguration } from 'commander';
import { Help, OutputConfiguration } from 'commander';
import type { CompletionFactoryOptions } from './completion.factory.interface';

@@ -20,2 +20,3 @@ export type ErrorHandler = (err: Error) => void;

outputConfiguration?: OutputConfiguration;
helpConfiguration?: Help;
version?: string;

@@ -22,0 +23,0 @@ /**

@@ -39,2 +39,5 @@ "use strict";

}
if (this.options.helpConfiguration) {
this.commander.configureHelp(this.options.helpConfiguration);
}
if (this.options.errorHandler) {

@@ -100,2 +103,5 @@ this.commander.exitOverride(this.options.errorHandler);

}
if (this.options.helpConfiguration) {
newCommand.configureHelp(this.options.helpConfiguration);
}
if (command.command.arguments) {

@@ -102,0 +108,0 @@ this.mapArgumentDescriptions(newCommand, command.command.arguments, command.command.argsDescription);

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

options.completion = options.completion || false;
options.helpConfiguration = options.helpConfiguration || undefined;
return options;

@@ -62,0 +63,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet