Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-command-line-args

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-command-line-args - npm Package Compare versions

Comparing version 1.3.4 to 1.4.1

5

dist/contracts.d.ts

@@ -91,2 +91,7 @@ export declare type ArgumentConfig<T extends {

/**
* The header level to use for sections. Can be overridden on indicividual section definitions
* defaults to 1
*/
defaultSectionHeaderLevel?: HeaderLevel;
/**
* Heading level text to use for options section

@@ -93,0 +98,0 @@ * defaults to "Options";

2

dist/helpers/markdown.helper.d.ts
import { UsageGuideConfig, IWriteMarkDown, ArgumentConfig, CommandLineOption, ParseOptions, Content, HeaderLevel, OptionContent, SectionHeader } from '../contracts';
export declare function createUsageGuide<T = any>(config: UsageGuideConfig<T>): string;
export declare function createSection(section: Content): string;
export declare function createSection<T>(section: Content, config: UsageGuideConfig<T>): string;
export declare function createSectionContent(section: Content): string;

@@ -5,0 +5,0 @@ export declare function createSectionTable(rows: any[]): string;

@@ -19,7 +19,8 @@ "use strict";

var footerSections = options.footerContentSections || [];
return __spreadArrays(headerSections.map(createSection), createOptionsSections(config.arguments, options), footerSections.map(createSection)).join('\n');
return __spreadArrays(headerSections.map(function (section) { return createSection(section, config); }), createOptionsSections(config.arguments, options), footerSections.map(function (section) { return createSection(section, config); })).join('\n');
}
exports.createUsageGuide = createUsageGuide;
function createSection(section) {
return "\n" + createHeading(section, 1) + "\n" + createSectionContent(section) + "\n";
function createSection(section, config) {
var _a;
return "\n" + createHeading(section, ((_a = config.parseOptions) === null || _a === void 0 ? void 0 : _a.defaultSectionHeaderLevel) || 1) + "\n" + createSectionContent(section) + "\n";
}

@@ -26,0 +27,0 @@ exports.createSection = createSection;

@@ -56,3 +56,3 @@ "use strict";

optional: true,
description: "Optional message that is printed when markdown verification fails.",
description: "Optional message that is printed when markdown verification fails. Use '{fileName}' to refer to the file being processed.",
},

@@ -67,2 +67,3 @@ help: { type: Boolean, alias: 'h', description: "Show this usage guide." },

optionsHeaderLevel: 3,
defaultSectionHeaderLevel: 3,
optionsHeaderText: "write-markdown cli options",

@@ -82,3 +83,2 @@ headerContentSections: [

header: 'Default Replacement Markers',
headerLevel: 3,
content: "replaceBelow defaults to:\n{code '" + exports.replaceBelowDefault + "'}\nreplaceAbove defaults to:\n{code '" + exports.replaceAboveDefault + "'}\nNote the double spaces at the end to signify to markdown that there should be a new line.",

@@ -88,3 +88,2 @@ },

header: 'String Formatting',
headerLevel: 3,
content: "The only chalk modifiers supported when converting to markdown are {highlight bold} and {highlight italic}.\nFor example:\n{code \\{bold bold text\\} \\{italic italic text\\} \\{italic.bold bold italic text\\}}\nwill be converted to:\n{code **boldText** *italic text* ***bold italic text***}",

@@ -94,3 +93,2 @@ },

header: 'Additional Modifiers',
headerLevel: 3,
content: "Two additional style modifiers have been added that are supported when writing markdown. They are removed when printing to the console.\n{code \\{highlight someText\\}}\nsurrounds the text in backticks:\n`someText`\nand \n{code \\{code.typescript function(message: string)\\\\\\{console.log(message);\\\\\\}\\}}\nSurrounds the text in triple back ticks (with an optional language specifer, in this case typescript):\n```typescript\nfunction(message: string)\\{console.log(message);\\}\n```",

@@ -97,0 +95,0 @@ },

#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,2 +12,3 @@ var parse_1 = require("./parse");

var write_markdown_constants_1 = require("./write-markdown.constants");
var string_format_1 = __importDefault(require("string-format"));
function writeMarkdown() {

@@ -24,3 +28,5 @@ var args = parse_1.parse(write_markdown_constants_1.argumentConfig, write_markdown_constants_1.parseOptions);

case 'verify_nonMatch':
throw new Error(args.verifyMessage || "'" + args.markdownPath + "' file out of date. Rerun write-markdown to update.");
throw new Error(string_format_1.default(args.verifyMessage || "'{fileName}' file out of date. Rerun write-markdown to update.", {
fileName: args.markdownPath,
}));
case 'write_match':

@@ -27,0 +33,0 @@ console.log("'" + args.markdownPath + "' content not modified, not writing to file.");

{
"name": "ts-command-line-args",
"version": "1.3.4",
"version": "1.4.1",
"description": "A Typescript wrapper around command-line-args with additional support for markdown usage guide generation",

@@ -51,3 +51,4 @@ "bin": {

"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0"
"command-line-usage": "^6.1.0",
"string-format": "^2.0.0"
},

@@ -59,2 +60,3 @@ "devDependencies": {

"@types/jest": "^26.0.10",
"@types/string-format": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^3.10.1",

@@ -81,4 +83,4 @@ "@typescript-eslint/parser": "^3.10.1",

"jsFile": "dist/write-markdown.constants.js",
"verifyMessage": "README.MD is out of date. Please regenerate by running 'npm write-markdown'"
"verifyMessage": "'{fileName}' is out of date. Please regenerate by running 'npm run write-markdown'"
}
}

@@ -288,3 +288,3 @@ # ts-command-line-args

| **jsonPath** | **p** | string | Used in conjunction with 'configFile'. The path within the config file to load the config from. For example: 'configs.writeMarkdown' |
| **verifyMessage** | | string | Optional message that is printed when markdown verification fails. |
| **verifyMessage** | | string | Optional message that is printed when markdown verification fails. Use '{fileName}' to refer to the file being processed. |
| **help** | **h** | boolean | Show this usage guide. |

@@ -291,0 +291,0 @@

@@ -103,2 +103,8 @@ export type ArgumentConfig<T extends { [name: string]: any }> = {

/**
* The header level to use for sections. Can be overridden on indicividual section definitions
* defaults to 1
*/
defaultSectionHeaderLevel?: HeaderLevel;
/**
* Heading level text to use for options section

@@ -105,0 +111,0 @@ * defaults to "Options";

@@ -51,3 +51,3 @@ /* eslint-disable no-useless-escape */

it('should generate a simple usage guide with sections', () => {
it('should generate a usage guide with sections', () => {
const usageGuide = createUsageGuide(writeMarkdownGuideInfo);

@@ -78,3 +78,3 @@

| **jsonPath** | **p** | string | Used in conjunction with 'configFile'. The path within the config file to load the config from. For example: 'configs.writeMarkdown' |
| **verifyMessage** | | string | Optional message that is printed when markdown verification fails. |
| **verifyMessage** | | string | Optional message that is printed when markdown verification fails. Use '{fileName}' to refer to the file being processed. |
| **help** | **h** | boolean | Show this usage guide. |

@@ -81,0 +81,0 @@

@@ -24,11 +24,11 @@ import {

return [
...headerSections.map(createSection),
...headerSections.map((section) => createSection(section, config)),
...createOptionsSections(config.arguments, options),
...footerSections.map(createSection),
...footerSections.map((section) => createSection(section, config)),
].join('\n');
}
export function createSection(section: Content): string {
export function createSection<T>(section: Content, config: UsageGuideConfig<T>): string {
return `
${createHeading(section, 1)}
${createHeading(section, config.parseOptions?.defaultSectionHeaderLevel || 1)}
${createSectionContent(section)}

@@ -35,0 +35,0 @@ `;

@@ -57,3 +57,3 @@ import { ArgumentConfig, IWriteMarkDown, ParseOptions, UsageGuideConfig } from './contracts';

optional: true,
description: `Optional message that is printed when markdown verification fails.`,
description: `Optional message that is printed when markdown verification fails. Use '{fileName}' to refer to the file being processed.`,
},

@@ -69,2 +69,3 @@ help: { type: Boolean, alias: 'h', description: `Show this usage guide.` },

optionsHeaderLevel: 3,
defaultSectionHeaderLevel: 3,
optionsHeaderText: `write-markdown cli options`,

@@ -85,3 +86,2 @@ headerContentSections: [

header: 'Default Replacement Markers',
headerLevel: 3,
content: `replaceBelow defaults to:

@@ -95,3 +95,2 @@ {code '${replaceBelowDefault}'}

header: 'String Formatting',
headerLevel: 3,
content: `The only chalk modifiers supported when converting to markdown are {highlight bold} and {highlight italic}.

@@ -105,3 +104,2 @@ For example:

header: 'Additional Modifiers',
headerLevel: 3,
content: `Two additional style modifiers have been added that are supported when writing markdown. They are removed when printing to the console.

@@ -108,0 +106,0 @@ {code \\{highlight someText\\}}

@@ -9,2 +9,3 @@ #!/usr/bin/env node

import { argumentConfig, parseOptions } from './write-markdown.constants';
import format from 'string-format';

@@ -31,3 +32,5 @@ function writeMarkdown() {

throw new Error(
args.verifyMessage || `'${args.markdownPath}' file out of date. Rerun write-markdown to update.`,
format(args.verifyMessage || `'{fileName}' file out of date. Rerun write-markdown to update.`, {
fileName: args.markdownPath,
}),
);

@@ -34,0 +37,0 @@ case 'write_match':

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc