Skip to content

Commit

Permalink
refactor: Extract usageMessage into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
RSeidelsohn committed Apr 11, 2023
1 parent 0c19d56 commit 66cf9ab
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
39 changes: 1 addition & 38 deletions bin/license-checker-rseidelsohn
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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));

Expand Down
41 changes: 41 additions & 0 deletions lib/usageMessage.js
Original file line number Diff line number Diff line change
@@ -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,
};

0 comments on commit 66cf9ab

Please sign in to comment.