From 245132128b37ff1b3f9518a7dda0ed063a5a3265 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Fri, 5 Apr 2024 10:01:21 -0300 Subject: [PATCH] feat: remove lodash dependency --- package-lock.json | 13 +++---------- package.json | 2 -- src/classy.ts | 1 - src/commander.ts | 7 ++----- src/modules.ts | 18 ++++++++---------- tsconfig.json | 3 ++- 6 files changed, 15 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3659e4a..f28b128 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "classy-commander", - "version": "3.2.17", + "version": "4.0.0", "license": "SEE LICENSE IN LICENSE", "dependencies": { "boolean": "3.0.1", @@ -14,7 +14,6 @@ "commander": "^11.1.0", "fs-extra": "8.1.0", "glob": "7.1.6", - "lodash": "^4.17.21", "reflect-metadata": "0.1.13" }, "devDependencies": { @@ -24,7 +23,6 @@ "@types/fs-extra": "8.1.0", "@types/glob": "7.1.2", "@types/jest": "^29.5.8", - "@types/lodash": "^4.14.201", "coveralls": "3.1.0", "get-root-path": "2.0.2", "husky": "4.2.5", @@ -2210,12 +2208,6 @@ "dev": true, "peer": true }, - "node_modules/@types/lodash": { - "version": "4.14.201", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.201.tgz", - "integrity": "sha512-y9euML0cim1JrykNxADLfaG0FgD1g/yTHwUs/Jg9ZIU7WKj2/4IW9Lbb1WZbvck78W/lfGXFfe+u2EGfIJXdLQ==", - "dev": true - }, "node_modules/@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -6963,7 +6955,8 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "node_modules/lodash._reinterpolate": { "version": "3.0.0", diff --git a/package.json b/package.json index 67a18c3..347fa44 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "@types/fs-extra": "8.1.0", "@types/glob": "7.1.2", "@types/jest": "^29.5.8", - "@types/lodash": "^4.14.201", "coveralls": "3.1.0", "get-root-path": "2.0.2", "husky": "4.2.5", @@ -72,7 +71,6 @@ "commander": "^11.1.0", "fs-extra": "8.1.0", "glob": "7.1.6", - "lodash": "^4.17.21", "reflect-metadata": "0.1.13" } } diff --git a/src/classy.ts b/src/classy.ts index 6feeffb..8514e7d 100644 --- a/src/classy.ts +++ b/src/classy.ts @@ -3,7 +3,6 @@ import chalk = require('chalk'); import * as cli from 'commander'; import * as fs from 'fs-extra'; import * as glob from 'glob'; -import * as _ from 'lodash'; import * as path from 'path'; import { setIocContainer } from './commander'; import { getUniqueModuleNames } from './modules'; diff --git a/src/commander.ts b/src/commander.ts index 810ac7e..7ed6cf1 100644 --- a/src/commander.ts +++ b/src/commander.ts @@ -1,5 +1,4 @@ import * as cli from 'commander'; -import * as _ from 'lodash'; import { coerceValue } from './coercion'; import { errorToString } from './errors'; import { getCommandOptions, getCommandValues } from './metadata'; @@ -132,16 +131,14 @@ function valueDefinitionToUsageString(value: CommandValueDefinition) { export function getCommandDefinitionUsage(commandDefinition: CommandDefinition) { const values = getCommandValues(commandDefinition.paramsClass.prototype); - const valuesUsage = _ - .chain(values) + const valuesUsage = values .map((value, index) => ({ value, index })) .sort((a, b) => a.value.variadic ? 1 : b.value.variadic ? -1 : a.index - b.index) .map((valueAndIndex) => valueDefinitionToUsageString(valueAndIndex.value)) - .join(' ') - .value(); + .join(' '); const usage = `${commandDefinition.name} ${valuesUsage}`.trim(); return usage; } diff --git a/src/modules.ts b/src/modules.ts index cdcf1e7..d0f64f3 100644 --- a/src/modules.ts +++ b/src/modules.ts @@ -1,5 +1,3 @@ -import * as _ from 'lodash'; - function isFileNameTypeScriptOrJavaScript(fileName: string) { return /.\.(ts|js)$/i.test(fileName); } @@ -13,13 +11,13 @@ function removeFileExtension(fileName: string) { } export function getUniqueModuleNames(fileNames: string[]) { - const moduleNames = _ - .chain(fileNames) - .filter((fileName) => !isFileNameDeclarationFile(fileName)) - .filter(isFileNameTypeScriptOrJavaScript) - .map(removeFileExtension) - .uniq() - .value(); - + const moduleNames = [ + ...new Set( + fileNames + .filter((filename) => !isFileNameDeclarationFile(filename)) + .filter(isFileNameTypeScriptOrJavaScript) + .map(removeFileExtension) + ), + ]; return moduleNames; } diff --git a/tsconfig.json b/tsconfig.json index eb9139c..b6f11b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,8 @@ "moduleResolution": "node", "outDir": "./dist", "skipLibCheck": true, - "strict": true + "strict": true, + "target": "ES2015" }, "exclude": [ "./node_modules"