From 66cf9ab83bf21d1ddcc926fae92136b799bf2b97 Mon Sep 17 00:00:00 2001 From: Roman Seidelsohn Date: Tue, 11 Apr 2023 11:42:04 +0200 Subject: [PATCH] refactor: Extract usageMessage into separate file --- bin/license-checker-rseidelsohn | 39 +------------------------------ lib/usageMessage.js | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 38 deletions(-) create mode 100644 lib/usageMessage.js diff --git a/bin/license-checker-rseidelsohn b/bin/license-checker-rseidelsohn index a0856e2..342947e 100755 --- a/bin/license-checker-rseidelsohn +++ b/bin/license-checker-rseidelsohn @@ -8,6 +8,7 @@ http://yuilibrary.com/license/ const licenseChecker = require('../lib/index'); const args = require('../lib/args'); +const usageMessage = require('../lib/usageMessage'); const parsedArgs = args.parse(); const mkdirp = require('mkdirp'); const path = require('path'); @@ -16,44 +17,6 @@ const fs = require('fs'); const cloneDeep = require('lodash.clonedeep'); const hasFailingArg = parsedArgs.failOn || parsedArgs.onlyAllow; -const usageMessage = [ - 'All options in alphabetical order:', - '', - ' --angularCli is just a synonym for --plainVertical', - " --clarificationsFile A file that describe the license clarifications for each package, see clarificationExample.json, any field available to the customFormat option can be clarified. Can also be used to specify a subregion of a package's license file (instead reading the entire file).", - ' --csv output in csv format.', - ' --csvComponentPrefix column prefix for components in csv file', - ' --customPath to add a custom Format file in JSON', - ' --development only show development dependencies.', - ' --direct look for direct dependencies only', - ' --excludeLicenses [list] exclude modules which licenses are in the comma-separated list from the output', - ' --excludePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") not in the semicolon-seperated list', - ' --excludePackageStartingWith [list] excludes packages starting with anything the comma-separated list', - ' --excludePrivatePackages restrict output to not include any package marked as private', - ' --failOn [list] fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list', - ' --files [path] copy all license files to path and rename them to `module-name`@`version`-LICENSE.txt.', - ' --includeLicenses [list] include only modules which licenses are in the comma-separated list from the output', - ' --includePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") in the semicolon-seperated list', - ' --json output in json format.', - ' --limitAttributes [list] limit the attributes to be output.', - ' --markdown output in markdown format.', - ' --nopeer skip peer dependencies in output.', - ' --onlyAllow [list] fail (exit with code 1) on the first occurrence of the licenses not in the semicolon-seperated list', - ' --onlyunknown only list packages with unknown or guessed licenses.', - ' --out [filepath] write the data to a specific file.', - ' --plainVertical output in plain vertical format like [Angular CLI does](https://angular.io/3rdpartylicenses.txt)', - ' --production only show production dependencies.', - ' --relativeLicensePath output the location of the license files as relative paths', - ' --relativeModulePath output the location of the module files as relative paths', - ' --start [filepath] path of the initial json to look for', - ' --summary output a summary of the license usage', - ' --unknown report guessed licenses as unknown licenses.', - '', - ' --version The current version', - ' --help The text you are reading right now :)', - '', -].join('\n'); - const kownOptions = Object.keys(args.knownOpts); const unknownArgs = Object.keys(parsedArgs).filter((arg) => !kownOptions.includes(arg)); diff --git a/lib/usageMessage.js b/lib/usageMessage.js new file mode 100644 index 0000000..3588127 --- /dev/null +++ b/lib/usageMessage.js @@ -0,0 +1,41 @@ +const usageMessage = [ + 'All options in alphabetical order:', + '', + ' --angularCli is just a synonym for --plainVertical', + " --clarificationsFile A file that describe the license clarifications for each package, see clarificationExample.json, any field available to the customFormat option can be clarified. Can also be used to specify a subregion of a package's license file (instead reading the entire file).", + ' --csv output in csv format.', + ' --csvComponentPrefix column prefix for components in csv file', + ' --customPath to add a custom Format file in JSON', + ' --development only show development dependencies.', + ' --direct look for direct dependencies only', + ' --excludeLicenses [list] exclude modules which licenses are in the comma-separated list from the output', + ' --excludePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") not in the semicolon-seperated list', + ' --excludePackageStartingWith [list] excludes packages starting with anything the comma-separated list', + ' --excludePrivatePackages restrict output to not include any package marked as private', + ' --failOn [list] fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list', + ' --files [path] copy all license files to path and rename them to `module-name`@`version`-LICENSE.txt.', + ' --includeLicenses [list] include only modules which licenses are in the comma-separated list from the output', + ' --includePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or only "package") in the semicolon-seperated list', + ' --json output in json format.', + ' --limitAttributes [list] limit the attributes to be output.', + ' --markdown output in markdown format.', + ' --nopeer skip peer dependencies in output.', + ' --onlyAllow [list] fail (exit with code 1) on the first occurrence of the licenses not in the semicolon-seperated list', + ' --onlyunknown only list packages with unknown or guessed licenses.', + ' --out [filepath] write the data to a specific file.', + ' --plainVertical output in plain vertical format like [Angular CLI does](https://angular.io/3rdpartylicenses.txt)', + ' --production only show production dependencies.', + ' --relativeLicensePath output the location of the license files as relative paths', + ' --relativeModulePath output the location of the module files as relative paths', + ' --start [filepath] path of the initial json to look for', + ' --summary output a summary of the license usage', + ' --unknown report guessed licenses as unknown licenses.', + '', + ' --version The current version', + ' --help The text you are reading right now :)', + '', +].join('\n'); + +module.exports = { + usageMessage, +};