@simbo/clirk 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/clirk.js.map +1 -1
- package/dist/clitch/clitch.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/add-flags-to-options.js.map +1 -1
- package/dist/lib/apply-sigint-handler.js.map +1 -1
- package/dist/lib/create-clirk-context.js.map +1 -1
- package/dist/lib/generate-help-message.js.map +1 -1
- package/dist/lib/generate-version-message.js.map +1 -1
- package/dist/schemas/minimist-options-schema.js.map +1 -1
- package/dist/schemas/options-defaults.js.map +1 -1
- package/dist/schemas/options-schema.js.map +1 -1
- package/dist/schemas/utils.js.map +1 -1
- package/dist/schemas/validate-options.js.map +1 -1
- package/dist/types/clirk-context.interface.js.map +1 -1
- package/dist/types/clirk-options.interface.js.map +1 -1
- package/dist/types/minimist-options.interface.js.map +1 -1
- package/package.json +14 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @simbo/clirk
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f304e0: Include the original sources in source maps (`inlineSources`), so
|
|
8
|
+
debuggers and stack traces show the TypeScript code without publishing `src`.
|
|
9
|
+
- Updated dependencies [6f304e0]
|
|
10
|
+
- @simbo/cli-output@2.0.1
|
|
11
|
+
- @simbo/find-up-package@2.0.1
|
|
12
|
+
- @simbo/graceful-exit@2.0.1
|
|
13
|
+
- @simbo/plural@2.0.1
|
|
14
|
+
- @simbo/stringify-error@2.0.1
|
|
15
|
+
- @simbo/zodpak@1.0.1
|
|
16
|
+
|
|
3
17
|
## 2.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/clirk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clirk.js","source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QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnF,iBAAiB,CAAC,aAAa,EAAE;QAC/B,IAAI,EAAE,CAAC,iBAAiB;QACxB,OAAO,EAAE,CAAC,oBAAoB;KAC/B,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAE/D,MAAM,cAAc,GAAG,GAAW,EAAE,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACzE,MAAM,iBAAiB,GAAG,GAAW,EAAE,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;IAE/E,MAAM,OAAO,GAAiB;QAC5B,GAAG,cAAc;QACjB,cAAc;QACd,iBAAiB;KAClB,CAAC;IAEF,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAChD,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,CAAC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;QAC9B,OAAO,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClD,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;QACjC,OAAO,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { log } from 'node:console';\n\nimport { gracefulExit } from '@simbo/graceful-exit';\n\nimport { addFlagsToOptions } from './lib/add-flags-to-options.js';\nimport { applySigintHandler } from './lib/apply-sigint-handler.js';\nimport { createClirkContext } from './lib/create-clirk-context.js';\nimport { generateHelpMessage } from './lib/generate-help-message.js';\nimport { generateVersionMessage } from './lib/generate-version-message.js';\nimport type { ParsedOptions } from './schemas/options-schema.js';\nimport { validateOptions } from './schemas/validate-options.js';\nimport type { ClirkContext } from './types/clirk-context.interface.js';\nimport type { ClirkOptions } from './types/clirk-options.interface.js';\n\n/**\n * clirk - The CLI Clerk.\n *\n * This function initializes a CLI with the provided options.\n * It parses arguments, provides CLI package information and takes over common\n * CLI tasks like generating help messages, displaying version information, and\n * handling SIGINT.\n *\n * @param cliOptions - The options for clirk.\n * @returns A promise that resolves to the ClirkContext, which contains the\n * parsed arguments and options as well as CLI package information.\n */\nexport async function clirk(cliOptions: ClirkOptions): Promise<ClirkContext> {\n const parsedOptions: ParsedOptions = validateOptions(cliOptions);\n\n const helpHandledByUser = parsedOptions.argsOptions.boolean.includes('help');\n const versionHandledByUser = parsedOptions.argsOptions.boolean.includes('version');\n\n addFlagsToOptions(parsedOptions, {\n help: !helpHandledByUser,\n version: !versionHandledByUser,\n });\n\n const partialContext = await createClirkContext(parsedOptions);\n\n const getHelpMessage = (): string => generateHelpMessage(partialContext);\n const getVersionMessage = (): string => generateVersionMessage(partialContext);\n\n const context: ClirkContext = {\n ...partialContext,\n getHelpMessage,\n getVersionMessage,\n };\n\n if (typeof context.sigintHandler === 'function') {\n applySigintHandler(context);\n }\n\n if (!helpHandledByUser && context.args.help) {\n log(context.getHelpMessage());\n return gracefulExit();\n }\n\n if (!versionHandledByUser && context.args.version) {\n log(context.getVersionMessage());\n return gracefulExit();\n }\n\n return context;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clitch.js","sourceRoot":"","sources":["../../src/clitch/clitch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAoD,EAAE,UAAU,GAAG,GAAG,EAAE;IACnG,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;QACxB,MAAM,YAAY,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"clitch.js","sourceRoot":"","sources":["../../src/clitch/clitch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAoD,EAAE,UAAU,GAAG,GAAG,EAAE;IACnG,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;QACxB,MAAM,YAAY,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["import { cwd } from 'node:process';\n\nimport { gracefulExit } from '@simbo/graceful-exit';\n\n/**\n * Wraps a CLI function to catch errors and handle a graceful exit.\n *\n * @param cliFn - The CLI function to wrap.\n * @param workingDir - The working directory for the CLI function.\n */\nexport async function clitch(cliFn: (workingDir?: string) => Promise<void> | void, workingDir = cwd()): Promise<void> {\n try {\n await cliFn(workingDir);\n await gracefulExit();\n } catch (error) {\n await gracefulExit(error);\n }\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC","sourcesContent":["export * from './clirk.js';\nexport type * from './types/clirk-context.interface.js';\nexport type * from './types/clirk-options.interface.js';\nexport type * from './types/minimist-options.interface.js';\n\nexport type { ParsedArgs } from 'minimist';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-flags-to-options.js","sourceRoot":"","sources":["../../src/lib/add-flags-to-options.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,SAAS,CAAU,CAAC;AAE3C,MAAM,iBAAiB,GAA6B;IAClD,IAAI,EAAE,CAAC,4BAA4B,CAAC;IACpC,OAAO,EAAE,CAAC,uCAAuC,CAAC;CACnD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAsB,EAAE,QAAiC,EAAE;IAC3F,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACjB,SAAS;QACX,CAAC;QAED,OAAO,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"add-flags-to-options.js","sourceRoot":"","sources":["../../src/lib/add-flags-to-options.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,SAAS,CAAU,CAAC;AAE3C,MAAM,iBAAiB,GAA6B;IAClD,IAAI,EAAE,CAAC,4BAA4B,CAAC;IACpC,OAAO,EAAE,CAAC,uCAAuC,CAAC;CACnD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAsB,EAAE,QAAiC,EAAE;IAC3F,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACjB,SAAS;QACX,CAAC;QAED,OAAO,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ParsedOptions } from '../schemas/options-schema.js';\n\nconst FLAGS = ['help', 'version'] as const;\n\nconst FLAG_DESCRIPTIONS: Record<string, string[]> = {\n help: ['Display this help message.'],\n version: ['Display the package name and version.'],\n};\n\n/**\n * Adds common CLI flags (e.g. --help, --version) to the Clirk options (in-place).\n *\n * This injects their flag definitions, aliases, and descriptions into the\n * minimist options and help text maps.\n *\n * @param options - The parsed Clirk options.\n * @param flags - A map of built-in flags to enable (e.g. `{ help: true }`).\n */\nexport function addFlagsToOptions(options: ParsedOptions, flags: Record<string, boolean> = {}): void {\n for (const flag of FLAGS) {\n if (!flags[flag]) {\n continue;\n }\n\n options.argsOptions.boolean = [...new Set([...options.argsOptions.boolean, flag])];\n options.argsOptions.alias[flag] = [...(options.argsOptions.alias[flag] ?? []), flag[0]];\n if (!Object.hasOwn(options.options, flag)) {\n options.options[flag] = FLAG_DESCRIPTIONS[flag];\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-sigint-handler.js","sourceRoot":"","sources":["../../src/lib/apply-sigint-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB;IACtD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,CAAC,KAAK,IAAI,EAAE;YACV,MAAO,OAAO,CAAC,aAA+B,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5B,GAAG,CAAC,OAAO,CAAC,gCAAgC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YACtE,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"apply-sigint-handler.js","sourceRoot":"","sources":["../../src/lib/apply-sigint-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB;IACtD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,CAAC,KAAK,IAAI,EAAE;YACV,MAAO,OAAO,CAAC,aAA+B,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5B,GAAG,CAAC,OAAO,CAAC,gCAAgC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YACtE,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { log } from 'node:console';\nimport process from 'node:process';\n\nimport { failure } from '@simbo/cli-output';\nimport { looseGracefulExit } from '@simbo/graceful-exit';\nimport { stringifyError } from '@simbo/stringify-error';\n\nimport type { ClirkContext, SigIntHandler } from '../types/clirk-context.interface.js';\n\n/**\n * Applies the SIGINT handler to the process.\n *\n * @param context - The Clirk context.\n */\nexport function applySigintHandler(context: ClirkContext): void {\n process.on('SIGINT', () => {\n (async () => {\n await (context.sigintHandler as SigIntHandler)(context);\n })().catch((error: unknown) => {\n log(failure(`Error while handling SIGINT: ${stringifyError(error)}`));\n looseGracefulExit(undefined, 1);\n });\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-clirk-context.js","sourceRoot":"","sources":["../../src/lib/create-clirk-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,QA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;AACH,SAAS,gBAAgB,CAAC,UAAoC;IAC5D,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC;AAED;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,WAAkC,EAAE,OAAiC;IAC1F,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC5C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAChC,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,GAAG,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { basename } from 'node:path';\nimport { argv } from 'node:process';\n\nimport { findUpPackage } from '@simbo/find-up-package';\nimport minimist from 'minimist';\n\nimport type { ParsedMinimistOptions } from '../schemas/minimist-options-schema.js';\nimport type { ParsedOptions } from '../schemas/options-schema.js';\nimport type { CliOption, CliParameter, ClirkContextWithoutMessages } from '../types/clirk-context.interface.js';\n\n/**\n * Creates a ClirkContext based on the provided CLI options.\n *\n * This sets up the runtime context needed by clirk, including:\n * - reading the CLI's own package.json\n * - parsing CLI arguments using minimist\n * - normalizing description, examples, usage, parameters, and options\n * - resolving aliases and flag types (boolean/string)\n *\n * @param parsedOptions - The parsed options for the CLI.\n * @returns A promise that resolves to a ClirkContextWithoutMessages object.\n * @throws {Error} If `importMetaDirname` is not provided.\n */\nexport async function createClirkContext(parsedOptions: ParsedOptions): Promise<ClirkContextWithoutMessages> {\n const {\n importMetaDirname: importPath,\n argsOptions,\n title,\n name: binName,\n icon,\n description,\n examples,\n usage,\n usageLabel,\n parameters: parametersArray,\n parametersLabel,\n options: optionsArray,\n optionsLabel,\n sigintHandler,\n sigintMessage,\n } = parsedOptions;\n\n const pkg = await findUpPackage({\n workingDir: importPath,\n normalize: true,\n });\n\n if (pkg === undefined) {\n throw new Error(`Could not find package for path: ${importPath}`);\n }\n\n if (description.length === 0 && pkg.packageJson.description) {\n description.push(pkg.packageJson.description);\n }\n\n const commandName = basename(argv[1]);\n\n const parameters = getParametersMap(parametersArray);\n const options = getOptionsMap(argsOptions, optionsArray);\n\n const name = binName ?? (typeof pkg.packageJson.bin === 'object' ? Object.keys(pkg.packageJson.bin)[0] : commandName);\n\n if (examples.length === 0) {\n examples.push(`${name} [OPTIONS]${parameters.size > 0 ? ` <${[...parameters.keys()].join('> <')}>` : ''}`);\n }\n\n const args = minimist(argv.slice(2), argsOptions);\n\n return {\n importPath,\n argsOptions,\n args,\n title,\n name,\n commandName,\n package: pkg,\n description,\n examples,\n usage,\n usageLabel,\n parameters,\n parametersLabel,\n options,\n optionsLabel,\n icon,\n sigintHandler,\n sigintMessage,\n };\n}\n\n/**\n * Creates the parameters map for the clirk context.\n *\n * @param parameters - The user-supplied options for the CLI definition.\n * @returns A Map of parameter names to their descriptions.\n */\nfunction getParametersMap(parameters: Record<string, string[]>): Map<string, CliParameter> {\n return new Map(Object.entries(parameters).map(([key, value]) => [key, { description: value }]));\n}\n\n/**\n * Creates the options map for the clirk context.\n *\n * @param argsOptions - The parsed arguments options.\n * @param options - The records of options descriptions.\n * @returns A Map of option names to their descriptions and properties.\n */\nfunction getOptionsMap(argsOptions: ParsedMinimistOptions, options: Record<string, string[]>): Map<string, CliOption> {\n return new Map(\n Object.entries(options).map(([key, description]) => {\n const aliases = new Set<string>(argsOptions.alias[key]);\n const type = argsOptions.boolean.includes(key)\n ? 'boolean'\n : argsOptions.string.includes(key)\n ? 'string'\n : undefined;\n if (type === undefined) {\n throw new Error(`Option not configured: \"${key}\"`);\n }\n return [key, { description, aliases, type }];\n }),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-help-message.js","sourceRoot":"","sources":["../../src/lib/generate-help-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIjE;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAoC;IACtE,MAAM,MAAM,GAAa;QACvB,GAAG,SAAS,CAAC,OAAO,CAAC;QACrB,GAAG,QAAQ,CAAC,OAAO,CAAC;QACpB,GAAG,aAAa,CAAC,OAAO,CAAC;QACzB,GAAG,UAAU,CAAC,OAAO,CAAC;KACvB,CAAC;IACF,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,OAAoC;IACrD,MAAM,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,WAAW,EACX,OAAO,EAAE,EACP,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,GACtD,GACF,GAAG,OAAO,CAAC;IAEZ,OAAO;QACL,GAAG,IAAI,CAAC,CAAC,CAAC,GA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AM,MAAM,GAAa,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC;IAEpD,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,gBAAgB,GAAG,KAAK,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,KAAK,SAAS,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5F,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,SAAS,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1G,gBAAgB,IAAI,SAAS,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC,EAAE,CAAC;QACxG,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { plural } from '@simbo/plural';\nimport { bold, cyan, dim, underline, yellow } from 'yoctocolors';\n\nimport type { ClirkContextWithoutMessages } from '../types/clirk-context.interface.js';\n\n/**\n * Generates a help message for the CLI based on the provided context.\n *\n * @param context - The context containing CLI information such as title, name,\n * description, examples, usage, parameters, and options.\n * @returns A formatted string containing the help message.\n */\nexport function generateHelpMessage(context: ClirkContextWithoutMessages): string {\n const output: string[] = [\n ...getHeader(context),\n ...getUsage(context),\n ...getParameters(context),\n ...getOptions(context),\n ];\n return `\\n${output.join('\\n\\n')}\\n`;\n}\n\n/**\n * Generates the header for the CLI help message as an array of sections that\n * will later be joined with blank lines.\n *\n * @param context - The context containing CLI information such as package name and version.\n * @returns An array of strings representing the header section.\n */\nfunction getHeader(context: ClirkContextWithoutMessages): string[] {\n const {\n icon,\n title,\n name,\n description,\n package: {\n packageJson: { name: packageName, version, homepage },\n },\n } = context;\n\n return [\n `${icon ? `${icon} ` : ''}${bold(cyan(`${name} — ${title}`))}`,\n `${packageName} v${version}${homepage ? `\\n${dim(underline(homepage))}` : ''}`,\n description.join('\\n'),\n ];\n}\n\n/**\n * Generates the usage section of the CLI help message as an array of sections\n * that will later be joined with blank lines.\n *\n * @param context - The context containing CLI information such as examples and usage.\n * @returns An array of strings representing the usage section.\n */\nfunction getUsage(context: ClirkContextWithoutMessages): string[] {\n const { examples, usage, usageLabel } = context;\n\n return [\n bold(`${usageLabel}:`),\n ` ${examples.map(example => yellow(example)).join('\\n ')}`,\n ...(usage.length > 0 ? [` ${usage.join('\\n ')}`] : []),\n ];\n}\n\n/**\n * Generates the parameters section of the CLI help message as an array of sections\n * that will later be joined with blank lines.\n *\n * @param context - The context containing CLI information such as parameters and their descriptions.\n * @returns An array of strings representing the parameters section.\n */\nfunction getParameters(context: ClirkContextWithoutMessages): string[] {\n const { parameters, parametersLabel } = context;\n\n if (parameters.size === 0) {\n return [];\n }\n\n const output: string[] = [bold(`${parametersLabel}:`)];\n\n for (const [key, { description }] of parameters) {\n output.push(` ${yellow(key)}\\n ${description.join('\\n ')}`);\n }\n\n return output;\n}\n\n/**\n * Generates the options section of the CLI help message as an array of sections\n * that will later be joined with blank lines.\n *\n * @param context - The context containing CLI information such as options and their descriptions.\n * @returns An array of strings representing the options section.\n */\nfunction getOptions(context: ClirkContextWithoutMessages): string[] {\n const { options, optionsLabel } = context;\n\n if (options.size === 0) {\n return [];\n }\n\n const output: string[] = [bold(`${optionsLabel}:`)];\n\n for (const [key, { description, aliases, type }] of options) {\n const value = type === 'string' ? dim('=<VALUE>') : '';\n let aliasDescription = ` ${yellow(`--${key}`)}${value}\\n ${description.join('\\n ')}`;\n if (aliases.size > 0) {\n const aliasList = [...aliases].map(alias => (alias.length === 1 ? `-${alias}` : `--${alias}`)).join(', ');\n aliasDescription += `\\n ${dim(`${plural(aliases.size, 'Alias', 'Aliases', '%s')}: ${aliasList}`)}`;\n }\n output.push(aliasDescription);\n }\n\n return output;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-version-message.js","sourceRoot":"","sources":["../../src/lib/generate-version-message.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoC;IACzE,MAAM,EACJ,OAAO,EAAE,EACP,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAC/B,GACF,GAAG,OAAO,CAAC;IAEZ,OAAO,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"generate-version-message.js","sourceRoot":"","sources":["../../src/lib/generate-version-message.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoC;IACzE,MAAM,EACJ,OAAO,EAAE,EACP,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAC/B,GACF,GAAG,OAAO,CAAC;IAEZ,OAAO,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { ClirkContextWithoutMessages } from '../types/clirk-context.interface.js';\n\n/**\n * Generates a version message for the CLI package.\n *\n * @param context - The context containing package information.\n * @returns A string message containing the package name and version.\n */\nexport function generateVersionMessage(context: ClirkContextWithoutMessages): string {\n const {\n package: {\n packageJson: { name, version },\n },\n } = context;\n\n return `${name} v${version}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimist-options-schema.js","sourceRoot":"","sources":["../../src/schemas/minimist-options-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD,MAAM,EAAE,oCAAoC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7F,OAAO,EAAE,oCAAoC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9F,KAAK,EAAE,CAAC;SACL,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,SAAS,CAAC,qBAAqB,CAAC;SAChC,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC9D,CAA+C,CAAC"}
|
|
1
|
+
{"version":3,"file":"minimist-options-schema.js","sourceRoot":"","sources":["../../src/schemas/minimist-options-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD,MAAM,EAAE,oCAAoC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7F,OAAO,EAAE,oCAAoC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9F,KAAK,EAAE,CAAC;SACL,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,SAAS,CAAC,qBAAqB,CAAC;SAChC,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC9D,CAA+C,CAAC","sourcesContent":["import { nonEmptyStringOrArrayOfStringsSchema, nonEmptyStringSchema } from '@simbo/zodpak';\nimport { z } from 'zod';\n\nimport type { MinimistOptions } from '../types/minimist-options.interface.js';\n\nimport { arrayifyString, arrayifyStringRecords } from './utils.js';\n\nexport const minimistOptionsSchema = z.strictObject({\n string: nonEmptyStringOrArrayOfStringsSchema.transform(arrayifyString).optional().default([]),\n boolean: nonEmptyStringOrArrayOfStringsSchema.transform(arrayifyString).optional().default([]),\n alias: z\n .record(nonEmptyStringSchema, nonEmptyStringOrArrayOfStringsSchema)\n .transform(arrayifyStringRecords)\n .optional()\n .default({}),\n default: z.record(z.string(), z.any()).optional().default({}),\n}) satisfies z.ZodType<unknown, MinimistOptions>;\n\nexport type ParsedMinimistOptions = z.output<typeof minimistOptionsSchema>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-defaults.js","sourceRoot":"","sources":["../../src/schemas/options-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CA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,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,OAAqB,EAAiB,EAAE;IACnF,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3B,MAAM,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC","sourcesContent":["import { log } from 'node:console';\n\nimport { terminated } from '@simbo/cli-output';\nimport { gracefulExit } from '@simbo/graceful-exit';\n\nimport type { ClirkContext } from '../types/clirk-context.interface.js';\n\nexport const DEFAULT_MINIMIST_OPTIONS = {\n string: [],\n boolean: [],\n alias: {},\n default: {},\n};\n\nexport const DEFAULT_USAGE_LABEL = 'USAGE';\nexport const DEFAULT_PARAMETERS_LABEL = 'PARAMETERS';\nexport const DEFAULT_OPTIONS_LABEL = 'OPTIONS';\n\nexport const DEFAULT_SIGINT_MESSAGE = terminated('Received SIGINT');\n\nexport const DEFAULT_SIGINT_HANDLER = async (context: ClirkContext): Promise<void> => {\n log(context.sigintMessage);\n await gracefulExit(undefined, 1);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-schema.js","sourceRoot":"","sources":["../../src/schemas/options-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oCAAoC,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1C,iBAAiB,EAAE,oBAAoB;IACvC,WAAW,EAAE,qBAA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UAAU,EAAE,CAAC;SACV,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,SAAS,CAAC,qBAAqB,CAAC;SAChC,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;IACd,eAAe,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC;IAClF,OAAO,EAAE,CAAC;SACP,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,SAAS,CAAC,qBAAqB,CAAC;SAChC,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;IACd,YAAY,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAC5E,aAAa,EAAE,CAAC;SACb,KAAK,CAAC,CAAC,oBAAoB,EAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;SAChE,QAAQ,EAAE;SACV,OAAO,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;IACxC,aAAa,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC;CAC/E,CAA4C,CAAC","sourcesContent":["import { createFunctionSchema, nonEmptyStringOrArrayOfStringsSchema, nonEmptyStringSchema } from '@simbo/zodpak';\nimport { z } from 'zod';\n\nimport type { SigIntHandler } from '../types/clirk-context.interface.js';\nimport type { ClirkOptions } from '../types/clirk-options.interface.js';\n\nimport { minimistOptionsSchema } from './minimist-options-schema.js';\nimport {\n DEFAULT_MINIMIST_OPTIONS,\n DEFAULT_OPTIONS_LABEL,\n DEFAULT_PARAMETERS_LABEL,\n DEFAULT_SIGINT_HANDLER,\n DEFAULT_SIGINT_MESSAGE,\n DEFAULT_USAGE_LABEL,\n} from './options-defaults.js';\nimport { arrayifyString, arrayifyStringRecords } from './utils.js';\n\nexport const optionsSchema = z.strictObject({\n importMetaDirname: nonEmptyStringSchema,\n argsOptions: minimistOptionsSchema.optional().default(DEFAULT_MINIMIST_OPTIONS),\n title: nonEmptyStringSchema,\n name: nonEmptyStringSchema.optional(),\n icon: nonEmptyStringSchema.optional(),\n description: nonEmptyStringOrArrayOfStringsSchema.transform(arrayifyString).optional().default([]),\n examples: nonEmptyStringOrArrayOfStringsSchema.transform(arrayifyString).optional().default([]),\n usage: nonEmptyStringOrArrayOfStringsSchema.transform(arrayifyString).optional().default([]),\n usageLabel: nonEmptyStringSchema.optional().default(DEFAULT_USAGE_LABEL),\n parameters: z\n .record(nonEmptyStringSchema, nonEmptyStringOrArrayOfStringsSchema)\n .transform(arrayifyStringRecords)\n .optional()\n .default({}),\n parametersLabel: nonEmptyStringSchema.optional().default(DEFAULT_PARAMETERS_LABEL),\n options: z\n .record(nonEmptyStringSchema, nonEmptyStringOrArrayOfStringsSchema)\n .transform(arrayifyStringRecords)\n .optional()\n .default({}),\n optionsLabel: nonEmptyStringSchema.optional().default(DEFAULT_OPTIONS_LABEL),\n sigintHandler: z\n .union([createFunctionSchema<SigIntHandler>(), z.literal(false)])\n .optional()\n .default(() => DEFAULT_SIGINT_HANDLER),\n sigintMessage: nonEmptyStringSchema.optional().default(DEFAULT_SIGINT_MESSAGE),\n}) satisfies z.ZodType<unknown, ClirkOptions>;\n\nexport type ParsedOptions = z.output<typeof optionsSchema>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/schemas/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAsC;IAC1E,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/schemas/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAsC;IAC1E,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC","sourcesContent":["/**\n * Converts a string or an array of strings to an array of strings.\n *\n * @param value - The input value to transform.\n * @returns An array of strings.\n */\nexport function arrayifyString(value: string | string[]): string[] {\n return typeof value === 'string' ? [value] : value;\n}\n\n/**\n * Converts a record of string or string arrays to a record of string arrays.\n *\n * @param obj - The input object to transform.\n * @returns A new object with all string values converted to arrays of strings.\n */\nexport function arrayifyStringRecords(obj: Record<string, string | string[]>): Record<string, string[]> {\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, arrayifyString(v)]));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-options.js","sourceRoot":"","sources":["../../src/schemas/validate-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"validate-options.js","sourceRoot":"","sources":["../../src/schemas/validate-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { createValidationFunction } from '@simbo/zodpak';\n\nimport { optionsSchema } from './options-schema.js';\n\n/**\n * Validates the options for the CLI.\n *\n * @param input - The options to validate.\n * @returns The validated options.\n * @throws {ValidationError} If the options are invalid.\n */\nexport const validateOptions = createValidationFunction(optionsSchema);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clirk-context.interface.js","sourceRoot":"","sources":["../../src/types/clirk-context.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"clirk-context.interface.js","sourceRoot":"","sources":["../../src/types/clirk-context.interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageNormalized } from '@simbo/find-up-package';\nimport type { ParsedArgs } from 'minimist';\n\nimport type { ParsedMinimistOptions } from '../schemas/minimist-options-schema.js';\n\n/**\n * The context for the clirk CLI.\n */\nexport interface ClirkContext {\n /**\n * The absolute path to the directory containing the CLI's package.json.\n */\n importPath: string;\n\n /**\n * The parsed options that were passed to minimist.\n */\n argsOptions: ParsedMinimistOptions;\n\n /**\n * The parsed command line arguments from minimist.\n */\n args: ParsedArgs;\n\n /**\n * The printable title of the CLI.\n */\n title: string;\n\n /**\n * The command name of the CLI.\n */\n name: string;\n\n /**\n * An optional icon for the CLI.\n */\n icon?: string;\n\n /**\n * The package information of the CLI.\n * This is derived from the package.json file in the CLI's directory.\n */\n package: PackageNormalized;\n\n /**\n * The actual command name extracted from `process.argv`.\n */\n commandName: string;\n\n /**\n * The description of the CLI.\n */\n description: string[];\n\n /**\n * Usage examples for the CLI.\n */\n examples: string[];\n\n /**\n * Usage instructions for the CLI.\n */\n usage: string[];\n\n /**\n * A label for the usage section.\n * This is used in the help message to indicate the usage section.\n */\n usageLabel: string;\n\n /**\n * The parameters for the CLI.\n * This is a map of parameter names to their descriptions.\n */\n parameters: Map<string, CliParameter>;\n\n /**\n * A label for the parameters section.\n * This is used in the help message to indicate the parameters section.\n */\n parametersLabel: string;\n\n /**\n * The options for the CLI.\n * This is a map of option names to their descriptions and properties.\n */\n options: Map<string, CliOption>;\n\n /**\n * A label for the options section.\n * This is used in the help message to indicate the options section.\n */\n optionsLabel: string;\n\n /**\n * The function to handle the SIGINT signal (Ctrl+C).\n * If undefined, clirk will not handle the SIGINT signal.\n */\n sigintHandler: SigIntHandler | false;\n\n /**\n * The message to display when the SIGINT signal (CTRL+C) is received.\n * This is either a custom message provided by the user or a default message.\n */\n sigintMessage: string;\n\n /**\n * Generates a help message for the CLI.\n * This includes the title, description, usage, examples, parameters, and options.\n */\n getHelpMessage: () => string;\n\n /**\n * Generates a version message for the CLI.\n * This includes the package name and version.\n */\n getVersionMessage: () => string;\n}\n\n/**\n * The Clirk context before handlers for help and version messages are added.\n */\nexport type ClirkContextWithoutMessages = Omit<ClirkContext, 'getHelpMessage' | 'getVersionMessage'>;\n\n/**\n * A parameter for the CLI.\n */\nexport interface CliParameter {\n /**\n * The description of the parameter.\n */\n description: string[];\n}\n\n/**\n * An option of the CLI.\n */\nexport interface CliOption {\n /**\n * The description of the option.\n */\n description: string[];\n\n /**\n * The aliases for the option.\n */\n aliases: Set<string>;\n\n /**\n * Whether the option is a boolean or a string flag.\n */\n type: 'boolean' | 'string';\n}\n\n/**\n * A function to handle the SIGINT signal (Ctrl+C).\n */\nexport type SigIntHandler = (context: ClirkContext) => void | Promise<void>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clirk-options.interface.js","sourceRoot":"","sources":["../../src/types/clirk-options.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"clirk-options.interface.js","sourceRoot":"","sources":["../../src/types/clirk-options.interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { SigIntHandler } from './clirk-context.interface.js';\nimport type { MinimistOptions } from './minimist-options.interface.js';\n\n/**\n * The options for clirk.\n */\nexport interface ClirkOptions {\n /**\n * The `import.meta.dirname` from any script within the CLI package.\n * This is used to resolve the CLI package information.\n */\n importMetaDirname: string;\n\n /**\n * The options for parsing command line arguments.\n * This is passed to the minimist library.\n * If these options do not include `--help` or `--version`, clirk will take\n * care of this and also take over if the flags are present.\n */\n argsOptions?: MinimistOptions;\n\n /**\n * The printable title of the CLI.\n */\n title: string;\n\n /**\n * The command name to run the CLI.\n */\n name?: string;\n\n /**\n * An optional icon for the CLI.\n * This will be displayed in the help message.\n */\n icon?: string;\n\n /**\n * The description of the CLI.\n * If not provided, it will be derived from the CLI's package.json.\n * Use an array of strings for multiple lines to support indentation.\n */\n description?: string | string[];\n\n /**\n * Usage examples for the CLI.\n * Use an array of strings for multiple lines to support indentation.\n * Defaults to the command name.\n */\n examples?: string | string[];\n\n /**\n * Usage instructions for the CLI. Optional, but recommended.\n * Use an array of strings for multiple lines to support indentation.\n */\n usage?: string | string[];\n\n /**\n * A label for the usage section.\n * If not provided, it will default to \"USAGE\".\n * This is used in the help message to indicate the usage section.\n */\n usageLabel?: string;\n\n /**\n * Parameters for the CLI. (Arguments that are not options.)\n * This defines the supported parameters for the CLI for help messages.\n * The keys are the names of the parameters, and the values are their descriptions.\n * Use an array of strings for multiple lines to support indentation.\n */\n parameters?: Record<string, string | string[]>;\n\n /**\n * A label for the parameters section.\n * If not provided, it will default to \"PARAMETERS\".\n * This is used in the help message to indicate the parameters section.\n */\n parametersLabel?: string;\n\n /**\n * Options for the CLI.\n * This defines the supported options for the CLI for help messages.\n * The keys are the names of the options, and the values are their descriptions.\n * Use an array of strings for multiple lines to support indentation.\n */\n options?: Record<string, string | string[]>;\n\n /**\n * A label for the options section.\n * If not provided, it will default to \"OPTIONS\".\n * This is used in the help message to indicate the options section.\n */\n optionsLabel?: string;\n\n /**\n * A function to handle the SIGINT signal (Ctrl+C).\n * If provided, this function will be called when the user presses Ctrl+C.\n * If not provided, clirk will handle the SIGINT signal and exit gracefully.\n * The default message can be customized using the `sigintMessage` option.\n * If set to `false`, clirk will not handle the SIGINT signal.\n */\n sigintHandler?: SigIntHandler | false;\n\n /**\n * The message to display when the SIGINT signal (CTRL+C) is received.\n * If not provided, a default message will be used.\n * This option is only used if `sigintHandler` is not set to `false`.\n */\n sigintMessage?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimist-options.interface.js","sourceRoot":"","sources":["../../src/types/minimist-options.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"minimist-options.interface.js","sourceRoot":"","sources":["../../src/types/minimist-options.interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { Opts } from 'minimist';\n\n/**\n * Minimist Options for Clirk\n *\n * Clirk supports all minimist options except `boolean: true` which is IMHO\n * just unnecessary complexity without benefit.\n */\nexport interface MinimistOptions extends Opts {\n boolean?: string | string[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simbo/clirk",
|
|
3
3
|
"description": "A utility that makes creating Node.js CLIs easier by providing common functionality out of the box, with excellent performance and a minimal footprint.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"framework",
|
|
@@ -42,36 +42,32 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@simbo/cli-output": "2.0.
|
|
46
|
-
"@simbo/find-up-package": "2.0.
|
|
47
|
-
"@simbo/graceful-exit": "2.0.
|
|
48
|
-
"@simbo/plural": "2.0.
|
|
49
|
-
"@simbo/stringify-error": "2.0.
|
|
50
|
-
"@simbo/zodpak": "1.0.
|
|
45
|
+
"@simbo/cli-output": "2.0.1",
|
|
46
|
+
"@simbo/find-up-package": "2.0.1",
|
|
47
|
+
"@simbo/graceful-exit": "2.0.1",
|
|
48
|
+
"@simbo/plural": "2.0.1",
|
|
49
|
+
"@simbo/stringify-error": "2.0.1",
|
|
50
|
+
"@simbo/zodpak": "1.0.1",
|
|
51
51
|
"minimist": "^1.2.8",
|
|
52
52
|
"yoctocolors": "^2.2.0",
|
|
53
53
|
"zod": "^4.6.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"@simbo/
|
|
58
|
-
"@simbo/prettier-config": "3.0.1",
|
|
59
|
-
"@simbo/tsconfig": "2.0.0",
|
|
56
|
+
"@simbo/eslint-config": "3.3.0",
|
|
57
|
+
"@simbo/tsconfig": "2.1.0",
|
|
60
58
|
"@types/minimist": "^1.2.5",
|
|
61
59
|
"@types/node": "^24.19.2",
|
|
62
|
-
"@vitest/coverage-v8": "^5.0
|
|
63
|
-
"@vitest/ui": "^5.0
|
|
64
|
-
"eslint": "^10.
|
|
60
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
61
|
+
"@vitest/ui": "^5.1.0",
|
|
62
|
+
"eslint": "^10.14.0",
|
|
65
63
|
"jiti": "^2.7.0",
|
|
66
|
-
"prettier": "^3.9.10",
|
|
67
64
|
"typescript": "^6.0.3",
|
|
68
|
-
"vitest": "^5.0
|
|
65
|
+
"vitest": "^5.1.0"
|
|
69
66
|
},
|
|
70
67
|
"scripts": {
|
|
71
68
|
"build": "tsc --project tsconfig.build.json",
|
|
72
|
-
"check": "pnpm run check:eslint && pnpm run check:
|
|
69
|
+
"check": "pnpm run check:eslint && pnpm run check:types",
|
|
73
70
|
"check:eslint": "eslint --config ./eslint.config.ts --max-warnings 0",
|
|
74
|
-
"check:format": "prettier --check .",
|
|
75
71
|
"check:types": "tsc --noEmit",
|
|
76
72
|
"clean": "pnpm run clean:dist && pnpm run clean:coverage && pnpm run clean:turbo && pnpm run clean:node_modules",
|
|
77
73
|
"clean:dist": "rm -rf dist",
|
|
@@ -79,7 +75,6 @@
|
|
|
79
75
|
"clean:turbo": "rm -rf .turbo",
|
|
80
76
|
"clean:coverage": "rm -rf coverage",
|
|
81
77
|
"fix:eslint": "pnpm run check:eslint --fix",
|
|
82
|
-
"fix:format": "prettier --write .",
|
|
83
78
|
"test": "vitest run --coverage",
|
|
84
79
|
"test:ui": "pnpm run test:watch --ui",
|
|
85
80
|
"test:watch": "vitest dev --coverage"
|