fix: a
This commit is contained in:
144
.gitignore
vendored
Normal file
144
.gitignore
vendored
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
.output
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Sveltekit cache directory
|
||||||
|
.svelte-kit/
|
||||||
|
|
||||||
|
# vitepress build output
|
||||||
|
**/.vitepress/dist
|
||||||
|
|
||||||
|
# vitepress cache directory
|
||||||
|
**/.vitepress/cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Firebase cache directory
|
||||||
|
.firebase/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
.pnpm-store
|
||||||
|
|
||||||
|
# yarn v3
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# Vite files
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
|
.vite/
|
||||||
3497
.nuxt/dev/index.mjs
3497
.nuxt/dev/index.mjs
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
4
.nuxt/dist/server/client.manifest.mjs
vendored
4
.nuxt/dist/server/client.manifest.mjs
vendored
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
import { viteNodeFetch } from "file:///home/bennet/source/vat-api/node_modules/@nuxt/vite-builder/dist/vite-node.mjs"
|
|
||||||
export default () => viteNodeFetch.getManifest()
|
|
||||||
|
|
||||||
1
.nuxt/dist/server/client.precomputed.mjs
vendored
1
.nuxt/dist/server/client.precomputed.mjs
vendored
@@ -1 +0,0 @@
|
|||||||
export default undefined
|
|
||||||
1
.nuxt/dist/server/server.mjs
vendored
1
.nuxt/dist/server/server.mjs
vendored
@@ -1 +0,0 @@
|
|||||||
export { default } from "file:///home/bennet/source/vat-api/node_modules/@nuxt/vite-builder/dist/vite-node-entry.mjs"
|
|
||||||
1
.nuxt/imports.d.ts
vendored
1
.nuxt/imports.d.ts
vendored
@@ -32,4 +32,3 @@ export { definePageMeta } from '../node_modules/nuxt/dist/pages/runtime/composab
|
|||||||
export { defineLazyHydrationComponent } from '#app/composables/lazy-hydration';
|
export { defineLazyHydrationComponent } from '#app/composables/lazy-hydration';
|
||||||
export { useScrollAnimation } from '../app/composables/useScrollAnimation';
|
export { useScrollAnimation } from '../app/composables/useScrollAnimation';
|
||||||
export { useVatRates, VatRate } from '../app/composables/useVatRates';
|
export { useVatRates, VatRate } from '../app/composables/useVatRates';
|
||||||
export { useNuxtDevTools } from '../node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"id":"dev","timestamp":1771016451182}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"id":"dev","timestamp":1771016451182,"prerendered":[]}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"date": "2026-02-13T21:00:52.602Z",
|
|
||||||
"preset": "nitro-dev",
|
|
||||||
"framework": {
|
|
||||||
"name": "nuxt",
|
|
||||||
"version": "4.3.1"
|
|
||||||
},
|
|
||||||
"versions": {
|
|
||||||
"nitro": "2.13.1"
|
|
||||||
},
|
|
||||||
"dev": {
|
|
||||||
"pid": 2054730,
|
|
||||||
"workerAddress": {
|
|
||||||
"socketPath": "\u0000nitro-worker-2054730-1-1-7828.sock"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
.nuxt/nuxt.d.ts
vendored
2
.nuxt/nuxt.d.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
/// <reference types="@nuxtjs/tailwindcss" />
|
/// <reference types="@nuxtjs/tailwindcss" />
|
||||||
|
/// <reference types="@nuxtjs/google-fonts" />
|
||||||
/// <reference types="@nuxt/devtools" />
|
/// <reference types="@nuxt/devtools" />
|
||||||
/// <reference types="@nuxt/telemetry" />
|
/// <reference types="@nuxt/telemetry" />
|
||||||
/// <reference types="@nuxtjs/google-fonts" />
|
|
||||||
/// <reference path="types/nitro-layouts.d.ts" />
|
/// <reference path="types/nitro-layouts.d.ts" />
|
||||||
/// <reference path="types/builder-env.d.ts" />
|
/// <reference path="types/builder-env.d.ts" />
|
||||||
/// <reference path="types/plugins.d.ts" />
|
/// <reference path="types/plugins.d.ts" />
|
||||||
|
|||||||
2
.nuxt/nuxt.node.d.ts
vendored
2
.nuxt/nuxt.node.d.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
/// <reference types="@nuxtjs/tailwindcss" />
|
/// <reference types="@nuxtjs/tailwindcss" />
|
||||||
|
/// <reference types="@nuxtjs/google-fonts" />
|
||||||
/// <reference types="@nuxt/devtools" />
|
/// <reference types="@nuxt/devtools" />
|
||||||
/// <reference types="@nuxt/telemetry" />
|
/// <reference types="@nuxt/telemetry" />
|
||||||
/// <reference types="@nuxtjs/google-fonts" />
|
|
||||||
/// <reference path="types/nitro-layouts.d.ts" />
|
/// <reference path="types/nitro-layouts.d.ts" />
|
||||||
/// <reference path="types/modules.d.ts" />
|
/// <reference path="types/modules.d.ts" />
|
||||||
/// <reference path="types/runtime-config.d.ts" />
|
/// <reference path="types/runtime-config.d.ts" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// generated by the @nuxtjs/tailwindcss <https://github.com/nuxt-modules/tailwindcss> module at 2/13/2026, 10:00:51 PM
|
// generated by the @nuxtjs/tailwindcss <https://github.com/nuxt-modules/tailwindcss> module at 2/13/2026, 10:13:46 PM
|
||||||
import "@nuxtjs/tailwindcss/config-ctx"
|
import "@nuxtjs/tailwindcss/config-ctx"
|
||||||
import configMerger from "@nuxtjs/tailwindcss/merger";
|
import configMerger from "@nuxtjs/tailwindcss/merger";
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
"./imports"
|
"./imports"
|
||||||
],
|
],
|
||||||
"#app-manifest": [
|
"#app-manifest": [
|
||||||
"./manifest/meta/dev.json"
|
"./manifest/meta/28eed3f6-8bb7-4ce5-bd5e-c2f1ff73389b"
|
||||||
],
|
],
|
||||||
"#components": [
|
"#components": [
|
||||||
"./components"
|
"./components"
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
"../node_modules/dist/runtime/server",
|
"../node_modules/dist/runtime/server",
|
||||||
"../node_modules/*.*",
|
"../node_modules/*.*",
|
||||||
"../node_modules/dist/*.*",
|
"../node_modules/dist/*.*",
|
||||||
"dev",
|
"../.output",
|
||||||
"../server"
|
"../server"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
"./imports"
|
"./imports"
|
||||||
],
|
],
|
||||||
"#app-manifest": [
|
"#app-manifest": [
|
||||||
"./manifest/meta/dev.json"
|
"./manifest/meta/28eed3f6-8bb7-4ce5-bd5e-c2f1ff73389b"
|
||||||
],
|
],
|
||||||
"#components": [
|
"#components": [
|
||||||
"./components"
|
"./components"
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
"./imports"
|
"./imports"
|
||||||
],
|
],
|
||||||
"#app-manifest": [
|
"#app-manifest": [
|
||||||
"./manifest/meta/dev.json"
|
"./manifest/meta/28eed3f6-8bb7-4ce5-bd5e-c2f1ff73389b"
|
||||||
],
|
],
|
||||||
"#build": [
|
"#build": [
|
||||||
"."
|
"."
|
||||||
|
|||||||
2
.nuxt/types/build.d.ts
vendored
2
.nuxt/types/build.d.ts
vendored
@@ -12,8 +12,6 @@ declare module "#build/paths.mjs";
|
|||||||
declare module "#build/root-component.mjs";
|
declare module "#build/root-component.mjs";
|
||||||
declare module "#build/plugins.server.mjs";
|
declare module "#build/plugins.server.mjs";
|
||||||
declare module "#build/test-component-wrapper.mjs";
|
declare module "#build/test-component-wrapper.mjs";
|
||||||
declare module "#build/devtools/settings.mjs";
|
|
||||||
declare module "#build/runtime.vue-devtools-client.nCg_nTMck4Vjq9J_TXBbUMCbducTRhoEa7hkWr4xMsk.js";
|
|
||||||
declare module "#build/routes.mjs";
|
declare module "#build/routes.mjs";
|
||||||
declare module "#build/pages.mjs";
|
declare module "#build/pages.mjs";
|
||||||
declare module "#build/router.options.mjs";
|
declare module "#build/router.options.mjs";
|
||||||
|
|||||||
2
.nuxt/types/imports.d.ts
vendored
2
.nuxt/types/imports.d.ts
vendored
@@ -113,7 +113,6 @@ declare global {
|
|||||||
const useModel: typeof import('vue').useModel
|
const useModel: typeof import('vue').useModel
|
||||||
const useNuxtApp: typeof import('../../node_modules/nuxt/dist/app/nuxt').useNuxtApp
|
const useNuxtApp: typeof import('../../node_modules/nuxt/dist/app/nuxt').useNuxtApp
|
||||||
const useNuxtData: typeof import('../../node_modules/nuxt/dist/app/composables/asyncData').useNuxtData
|
const useNuxtData: typeof import('../../node_modules/nuxt/dist/app/composables/asyncData').useNuxtData
|
||||||
const useNuxtDevTools: typeof import('../../node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools').useNuxtDevTools
|
|
||||||
const usePreviewMode: typeof import('../../node_modules/nuxt/dist/app/composables/preview').usePreviewMode
|
const usePreviewMode: typeof import('../../node_modules/nuxt/dist/app/composables/preview').usePreviewMode
|
||||||
const useRequestEvent: typeof import('../../node_modules/nuxt/dist/app/composables/ssr').useRequestEvent
|
const useRequestEvent: typeof import('../../node_modules/nuxt/dist/app/composables/ssr').useRequestEvent
|
||||||
const useRequestFetch: typeof import('../../node_modules/nuxt/dist/app/composables/ssr').useRequestFetch
|
const useRequestFetch: typeof import('../../node_modules/nuxt/dist/app/composables/ssr').useRequestFetch
|
||||||
@@ -303,7 +302,6 @@ declare module 'vue' {
|
|||||||
readonly useModel: UnwrapRef<typeof import('vue')['useModel']>
|
readonly useModel: UnwrapRef<typeof import('vue')['useModel']>
|
||||||
readonly useNuxtApp: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/nuxt')['useNuxtApp']>
|
readonly useNuxtApp: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/nuxt')['useNuxtApp']>
|
||||||
readonly useNuxtData: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/asyncData')['useNuxtData']>
|
readonly useNuxtData: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/asyncData')['useNuxtData']>
|
||||||
readonly useNuxtDevTools: UnwrapRef<typeof import('../../node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools')['useNuxtDevTools']>
|
|
||||||
readonly usePreviewMode: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/preview')['usePreviewMode']>
|
readonly usePreviewMode: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/preview')['usePreviewMode']>
|
||||||
readonly useRequestEvent: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/ssr')['useRequestEvent']>
|
readonly useRequestEvent: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/ssr')['useRequestEvent']>
|
||||||
readonly useRequestFetch: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/ssr')['useRequestFetch']>
|
readonly useRequestFetch: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/ssr')['useRequestFetch']>
|
||||||
|
|||||||
11
.nuxt/types/plugins.d.ts
vendored
11
.nuxt/types/plugins.d.ts
vendored
@@ -9,25 +9,18 @@ type NuxtAppInjections =
|
|||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.client.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/head/runtime/plugins/unhead.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/head/runtime/plugins/unhead.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/router.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/router.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/browser-devtools-timing.client.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/payload.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/payload.client.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/dev-server-logs.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/navigation-repaint.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/navigation-repaint.client.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/check-outdated-build.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/check-outdated-build.client.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.server.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/revive-payload.server.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/chunk-reload.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/chunk-reload.client.js")> &
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client.js")> &
|
InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client.js")>
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/pages/runtime/plugins/check-if-page-unused.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.client.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/warn.dev.server.js")> &
|
|
||||||
InjectionType<typeof import("../../node_modules/nuxt/dist/app/plugins/check-if-layout-used.js")>
|
|
||||||
|
|
||||||
declare module '#app' {
|
declare module '#app' {
|
||||||
interface NuxtApp extends NuxtAppInjections { }
|
interface NuxtApp extends NuxtAppInjections { }
|
||||||
|
|
||||||
interface NuxtAppLiterals {
|
interface NuxtAppLiterals {
|
||||||
pluginName: 'vue-devtools-client' | 'nuxt:revive-payload:client' | 'nuxt:head' | 'nuxt:router' | 'nuxt:browser-devtools-timing' | 'nuxt:payload' | 'nuxt:revive-payload:server' | 'nuxt:chunk-reload' | 'nuxt:global-components' | 'nuxt:prefetch' | 'nuxt:checkIfPageUnused' | 'nuxt:checkIfLayoutUsed'
|
pluginName: 'nuxt:revive-payload:client' | 'nuxt:head' | 'nuxt:router' | 'nuxt:payload' | 'nuxt:revive-payload:server' | 'nuxt:chunk-reload' | 'nuxt:global-components' | 'nuxt:prefetch'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ RUN mkdir -p /usr/src/app
|
|||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
RUN apk add curl
|
||||||
|
|
||||||
RUN npm cache clear --force && npm ci
|
RUN npm cache clear --force && npm ci
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.code-block {
|
.code-block {
|
||||||
@apply bg-[#0d1117] text-[#e6edf3] rounded-xl font-mono text-sm leading-relaxed overflow-x-auto;
|
@apply bg-[#0d1117] text-[#e6edf3] rounded-b-xl font-mono text-sm leading-relaxed overflow-x-auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot-grid {
|
.dot-grid {
|
||||||
|
|||||||
@@ -13,19 +13,13 @@
|
|||||||
|
|
||||||
<!-- Center -->
|
<!-- Center -->
|
||||||
<p class="text-ink-faint text-xs">
|
<p class="text-ink-faint text-xs">
|
||||||
Free EU VAT rate data
|
A project by <a href="https://bennetgallein.de" class="text-ink-muted hover:text-eu-blue transition-colors">Bennet Gallein IT Solutions</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Right -->
|
<!-- Right -->
|
||||||
<div class="flex items-center gap-5">
|
<div class="flex items-center gap-5">
|
||||||
<a href="#" class="hover:text-eu-blue transition-colors">Imprint</a>
|
<a href="https://bennetgallein.de/legal/imprint" class="hover:text-eu-blue transition-colors">Imprint</a>
|
||||||
<a href="#" class="hover:text-eu-blue transition-colors">Privacy</a>
|
<a href="https://bennetgallein.de/legal/privacy-policy" class="hover:text-eu-blue transition-colors">Privacy</a>
|
||||||
<a href="#" class="hover:text-eu-blue transition-colors flex items-center gap-1.5">
|
|
||||||
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="currentColor">
|
|
||||||
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
|
|
||||||
</svg>
|
|
||||||
GitHub
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
100
node_modules/.package-lock.json
generated
vendored
100
node_modules/.package-lock.json
generated
vendored
@@ -1373,6 +1373,22 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@oxc-minify/binding-linux-x64-musl": {
|
||||||
|
"version": "0.112.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oxc-minify/binding-linux-x64-musl/-/binding-linux-x64-musl-0.112.0.tgz",
|
||||||
|
"integrity": "sha512-HAPfmQKlkVi97/zRonVE9t/kKUG3ni+mOuU1Euw+3s37KwUuOJjmcwXdclVgXKBlTkCGO0FajPwW5dAJeIXCCw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@oxc-parser/binding-linux-x64-gnu": {
|
"node_modules/@oxc-parser/binding-linux-x64-gnu": {
|
||||||
"version": "0.112.0",
|
"version": "0.112.0",
|
||||||
"resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.112.0.tgz",
|
"resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.112.0.tgz",
|
||||||
@@ -1388,6 +1404,22 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@oxc-parser/binding-linux-x64-musl": {
|
||||||
|
"version": "0.112.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-musl/-/binding-linux-x64-musl-0.112.0.tgz",
|
||||||
|
"integrity": "sha512-TYqnuKV/p3eOc+N61E0961nA7DC+gaCeJ3+V2LcjJdTwFMdikqWL6uVk1jlrpUCBrozHDATVUKDZYH7r4FQYjQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@oxc-project/types": {
|
"node_modules/@oxc-project/types": {
|
||||||
"version": "0.112.0",
|
"version": "0.112.0",
|
||||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.112.0.tgz",
|
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.112.0.tgz",
|
||||||
@@ -1413,6 +1445,22 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@oxc-transform/binding-linux-x64-musl": {
|
||||||
|
"version": "0.112.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oxc-transform/binding-linux-x64-musl/-/binding-linux-x64-musl-0.112.0.tgz",
|
||||||
|
"integrity": "sha512-ISQoA3pD4cyTGpf9sXXeerH6pL2L6EIpdy6oAy2ttkswyVFDyQNVOVIGIdLZDgbpmqGljxZnWqt/J/N68pQaig==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@parcel/watcher": {
|
"node_modules/@parcel/watcher": {
|
||||||
"version": "2.5.6",
|
"version": "2.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz",
|
||||||
@@ -1468,6 +1516,26 @@
|
|||||||
"url": "https://opencollective.com/parcel"
|
"url": "https://opencollective.com/parcel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@parcel/watcher-linux-x64-musl": {
|
||||||
|
"version": "2.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.6.tgz",
|
||||||
|
"integrity": "sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/parcel"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@parcel/watcher-wasm": {
|
"node_modules/@parcel/watcher-wasm": {
|
||||||
"version": "2.5.6",
|
"version": "2.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.5.6.tgz",
|
||||||
@@ -1750,6 +1818,19 @@
|
|||||||
"linux"
|
"linux"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||||
|
"version": "4.57.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz",
|
||||||
|
"integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@sindresorhus/is": {
|
"node_modules/@sindresorhus/is": {
|
||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz",
|
||||||
@@ -3177,12 +3258,14 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "11.1.0",
|
"version": "13.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz",
|
||||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
"integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/commondir": {
|
"node_modules/commondir": {
|
||||||
@@ -8408,6 +8491,15 @@
|
|||||||
"url": "https://opencollective.com/svgo"
|
"url": "https://opencollective.com/svgo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/svgo/node_modules/commander": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/system-architecture": {
|
"node_modules/system-architecture": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz",
|
||||||
|
|||||||
75
node_modules/commander/Readme.md
generated
vendored
75
node_modules/commander/Readme.md
generated
vendored
@@ -37,7 +37,7 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
|
|||||||
- [.usage](#usage)
|
- [.usage](#usage)
|
||||||
- [.description and .summary](#description-and-summary)
|
- [.description and .summary](#description-and-summary)
|
||||||
- [.helpOption(flags, description)](#helpoptionflags-description)
|
- [.helpOption(flags, description)](#helpoptionflags-description)
|
||||||
- [.addHelpCommand()](#addhelpcommand)
|
- [.helpCommand()](#helpcommand)
|
||||||
- [More configuration](#more-configuration-2)
|
- [More configuration](#more-configuration-2)
|
||||||
- [Custom event listeners](#custom-event-listeners)
|
- [Custom event listeners](#custom-event-listeners)
|
||||||
- [Bits and pieces](#bits-and-pieces)
|
- [Bits and pieces](#bits-and-pieces)
|
||||||
@@ -79,7 +79,8 @@ const { program } = require('commander');
|
|||||||
|
|
||||||
program
|
program
|
||||||
.option('--first')
|
.option('--first')
|
||||||
.option('-s, --separator <char>');
|
.option('-s, --separator <char>')
|
||||||
|
.argument('<string>');
|
||||||
|
|
||||||
program.parse();
|
program.parse();
|
||||||
|
|
||||||
@@ -174,7 +175,15 @@ const program = new Command();
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|').
|
Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|'). To allow a wider range of short-ish flags than just
|
||||||
|
single characters, you may also have two long options. Examples:
|
||||||
|
|
||||||
|
```js
|
||||||
|
program
|
||||||
|
.option('-p, --port <number>', 'server port number')
|
||||||
|
.option('--trace', 'add extra debugging output')
|
||||||
|
.option('--ws, --workspace <name>', 'use a custom workspace')
|
||||||
|
```
|
||||||
|
|
||||||
The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
|
The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
|
||||||
|
|
||||||
@@ -678,8 +687,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default, it is not an error to
|
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments or excess arguments will be reported as an error. You can suppress the unknown option check with `.allowUnknownOption()`. You can suppress the excess arguments check with `.allowExcessArguments()`.
|
||||||
pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`.
|
|
||||||
|
|
||||||
### Stand-alone executable (sub)commands
|
### Stand-alone executable (sub)commands
|
||||||
|
|
||||||
@@ -696,7 +704,7 @@ Example file: [pm](./examples/pm)
|
|||||||
program
|
program
|
||||||
.name('pm')
|
.name('pm')
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.command('install [name]', 'install one or more packages')
|
.command('install [package-names...]', 'install one or more packages')
|
||||||
.command('search [query]', 'search with optional query')
|
.command('search [query]', 'search with optional query')
|
||||||
.command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })
|
.command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })
|
||||||
.command('list', 'list packages installed', { isDefault: true });
|
.command('list', 'list packages installed', { isDefault: true });
|
||||||
@@ -904,38 +912,28 @@ program
|
|||||||
.helpOption('-e, --HELP', 'read more information');
|
.helpOption('-e, --HELP', 'read more information');
|
||||||
```
|
```
|
||||||
|
|
||||||
### .addHelpCommand()
|
(Or use `.addHelpOption()` to add an option you construct yourself.)
|
||||||
|
|
||||||
A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`.
|
### .helpCommand()
|
||||||
|
|
||||||
|
A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.helpCommand(true)` and `.helpCommand(false)`.
|
||||||
|
|
||||||
You can both turn on and customise the help command by supplying the name and description:
|
You can both turn on and customise the help command by supplying the name and description:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
program.addHelpCommand('assist [command]', 'show assistance');
|
program.helpCommand('assist [command]', 'show assistance');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
(Or use `.addHelpCommand()` to add a command you construct yourself.)
|
||||||
|
|
||||||
### More configuration
|
### More configuration
|
||||||
|
|
||||||
The built-in help is formatted using the Help class.
|
The built-in help is formatted using the Help class.
|
||||||
You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer.
|
You can configure the help by modifying data properties and methods using `.configureHelp()`, or by subclassing Help using `.createHelp()` .
|
||||||
|
|
||||||
The data properties are:
|
Simple properties include `sortSubcommands`, `sortOptions`, and `showGlobalOptions`. You can add color using the style methods like `styleTitle()`.
|
||||||
|
|
||||||
- `helpWidth`: specify the wrap width, useful for unit tests
|
For more detail and examples of changing the displayed text, color, and layout see (./docs/help-in-depth.md)
|
||||||
- `sortSubcommands`: sort the subcommands alphabetically
|
|
||||||
- `sortOptions`: sort the options alphabetically
|
|
||||||
- `showGlobalOptions`: show a section with the global options from the parent command(s)
|
|
||||||
|
|
||||||
You can override any method on the [Help](./lib/help.js) class. There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used.
|
|
||||||
|
|
||||||
Example file: [configure-help.js](./examples/configure-help.js)
|
|
||||||
|
|
||||||
```js
|
|
||||||
program.configureHelp({
|
|
||||||
sortSubcommands: true,
|
|
||||||
subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage.
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Custom event listeners
|
## Custom event listeners
|
||||||
|
|
||||||
@@ -951,22 +949,24 @@ program.on('option:verbose', function () {
|
|||||||
|
|
||||||
### .parse() and .parseAsync()
|
### .parse() and .parseAsync()
|
||||||
|
|
||||||
The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`.
|
Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
||||||
|
|
||||||
If the arguments follow different conventions than node you can pass a `from` option in the second parameter:
|
Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
||||||
|
|
||||||
- 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that
|
- `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
||||||
- 'electron': `argv[1]` varies depending on whether the electron application is packaged
|
- `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
||||||
- 'user': all of the arguments from the user
|
- `'user'`: just user arguments
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
program.parse(process.argv); // Explicit, node conventions
|
program.parse(); // parse process.argv and auto-detect electron and special node flags
|
||||||
program.parse(); // Implicit, and auto-detect electron
|
program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
||||||
program.parse(['-f', 'filename'], { from: 'user' });
|
program.parse(['--port', '80'], { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use parseAsync instead of parse if any of your action handlers are async.
|
||||||
|
|
||||||
### Parsing Configuration
|
### Parsing Configuration
|
||||||
|
|
||||||
If the default parsing does not suit your needs, there are some behaviours to support other usage patterns.
|
If the default parsing does not suit your needs, there are some behaviours to support other usage patterns.
|
||||||
@@ -1092,8 +1092,9 @@ program.error('Custom processing has failed', { exitCode: 2, code: 'my.custom.er
|
|||||||
By default, Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
|
By default, Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
|
||||||
this behaviour and optionally supply a callback. The default override throws a `CommanderError`.
|
this behaviour and optionally supply a callback. The default override throws a `CommanderError`.
|
||||||
|
|
||||||
The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`. The default override behaviour is to throw the error, except for async handling of executable subcommand completion which carries on. The normal display of error messages or version or help
|
The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`.
|
||||||
is not affected by the override which is called after the display.
|
Commander expects the callback to terminate the normal program flow, and will call `process.exit` if the callback returns.
|
||||||
|
The normal display of error messages or version or help is not affected by the override which is called after the display.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
program.exitOverride();
|
program.exitOverride();
|
||||||
@@ -1136,7 +1137,7 @@ There is more information available about:
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
The current version of Commander is fully supported on Long Term Support versions of Node.js, and requires at least v16.
|
The current version of Commander is fully supported on Long Term Support versions of Node.js, and requires at least v18.
|
||||||
(For older versions of Node.js, use an older version of Commander.)
|
(For older versions of Node.js, use an older version of Commander.)
|
||||||
|
|
||||||
The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.
|
The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.
|
||||||
|
|||||||
2
node_modules/commander/esm.mjs
generated
vendored
2
node_modules/commander/esm.mjs
generated
vendored
@@ -12,5 +12,5 @@ export const {
|
|||||||
Command,
|
Command,
|
||||||
Argument,
|
Argument,
|
||||||
Option,
|
Option,
|
||||||
Help
|
Help,
|
||||||
} = commander;
|
} = commander;
|
||||||
|
|||||||
10
node_modules/commander/index.js
generated
vendored
10
node_modules/commander/index.js
generated
vendored
@@ -4,13 +4,11 @@ const { CommanderError, InvalidArgumentError } = require('./lib/error.js');
|
|||||||
const { Help } = require('./lib/help.js');
|
const { Help } = require('./lib/help.js');
|
||||||
const { Option } = require('./lib/option.js');
|
const { Option } = require('./lib/option.js');
|
||||||
|
|
||||||
/**
|
exports.program = new Command();
|
||||||
* Expose the root command.
|
|
||||||
*/
|
|
||||||
|
|
||||||
exports = module.exports = new Command();
|
exports.createCommand = (name) => new Command(name);
|
||||||
exports.program = exports; // More explicit access to global command.
|
exports.createOption = (flags, description) => new Option(flags, description);
|
||||||
// createArgument, createCommand, and createOption are implicitly available as they are methods on program.
|
exports.createArgument = (name, description) => new Argument(name, description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose classes
|
* Expose classes
|
||||||
|
|||||||
16
node_modules/commander/lib/argument.js
generated
vendored
16
node_modules/commander/lib/argument.js
generated
vendored
@@ -50,7 +50,7 @@ class Argument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api private
|
* @package
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_concatValue(value, previous) {
|
_concatValue(value, previous) {
|
||||||
@@ -98,7 +98,9 @@ class Argument {
|
|||||||
this.argChoices = values.slice();
|
this.argChoices = values.slice();
|
||||||
this.parseArg = (arg, previous) => {
|
this.parseArg = (arg, previous) => {
|
||||||
if (!this.argChoices.includes(arg)) {
|
if (!this.argChoices.includes(arg)) {
|
||||||
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
throw new InvalidArgumentError(
|
||||||
|
`Allowed choices are ${this.argChoices.join(', ')}.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (this.variadic) {
|
if (this.variadic) {
|
||||||
return this._concatValue(arg, previous);
|
return this._concatValue(arg, previous);
|
||||||
@@ -110,6 +112,8 @@ class Argument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Make argument required.
|
* Make argument required.
|
||||||
|
*
|
||||||
|
* @returns {Argument}
|
||||||
*/
|
*/
|
||||||
argRequired() {
|
argRequired() {
|
||||||
this.required = true;
|
this.required = true;
|
||||||
@@ -118,6 +122,8 @@ class Argument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Make argument optional.
|
* Make argument optional.
|
||||||
|
*
|
||||||
|
* @returns {Argument}
|
||||||
*/
|
*/
|
||||||
argOptional() {
|
argOptional() {
|
||||||
this.required = false;
|
this.required = false;
|
||||||
@@ -130,15 +136,13 @@ class Argument {
|
|||||||
*
|
*
|
||||||
* @param {Argument} arg
|
* @param {Argument} arg
|
||||||
* @return {string}
|
* @return {string}
|
||||||
* @api private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function humanReadableArgName(arg) {
|
function humanReadableArgName(arg) {
|
||||||
const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
|
const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
|
||||||
|
|
||||||
return arg.required
|
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
|
||||||
? '<' + nameOutput + '>'
|
|
||||||
: '[' + nameOutput + ']';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Argument = Argument;
|
exports.Argument = Argument;
|
||||||
|
|||||||
1191
node_modules/commander/lib/command.js
generated
vendored
1191
node_modules/commander/lib/command.js
generated
vendored
File diff suppressed because it is too large
Load Diff
4
node_modules/commander/lib/error.js
generated
vendored
4
node_modules/commander/lib/error.js
generated
vendored
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* CommanderError class
|
* CommanderError class
|
||||||
* @class
|
|
||||||
*/
|
*/
|
||||||
class CommanderError extends Error {
|
class CommanderError extends Error {
|
||||||
/**
|
/**
|
||||||
@@ -8,7 +7,6 @@ class CommanderError extends Error {
|
|||||||
* @param {number} exitCode suggested exit code which could be used with process.exit
|
* @param {number} exitCode suggested exit code which could be used with process.exit
|
||||||
* @param {string} code an id string representing the error
|
* @param {string} code an id string representing the error
|
||||||
* @param {string} message human-readable description of the error
|
* @param {string} message human-readable description of the error
|
||||||
* @constructor
|
|
||||||
*/
|
*/
|
||||||
constructor(exitCode, code, message) {
|
constructor(exitCode, code, message) {
|
||||||
super(message);
|
super(message);
|
||||||
@@ -23,13 +21,11 @@ class CommanderError extends Error {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* InvalidArgumentError class
|
* InvalidArgumentError class
|
||||||
* @class
|
|
||||||
*/
|
*/
|
||||||
class InvalidArgumentError extends CommanderError {
|
class InvalidArgumentError extends CommanderError {
|
||||||
/**
|
/**
|
||||||
* Constructs the InvalidArgumentError class
|
* Constructs the InvalidArgumentError class
|
||||||
* @param {string} [message] explanation of why argument is invalid
|
* @param {string} [message] explanation of why argument is invalid
|
||||||
* @constructor
|
|
||||||
*/
|
*/
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
super(1, 'commander.invalidArgument', message);
|
super(1, 'commander.invalidArgument', message);
|
||||||
|
|||||||
447
node_modules/commander/lib/help.js
generated
vendored
447
node_modules/commander/lib/help.js
generated
vendored
@@ -12,11 +12,24 @@ const { humanReadableArgName } = require('./argument.js');
|
|||||||
class Help {
|
class Help {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.helpWidth = undefined;
|
this.helpWidth = undefined;
|
||||||
|
this.minWidthToWrap = 40;
|
||||||
this.sortSubcommands = false;
|
this.sortSubcommands = false;
|
||||||
this.sortOptions = false;
|
this.sortOptions = false;
|
||||||
this.showGlobalOptions = false;
|
this.showGlobalOptions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
|
||||||
|
* and just before calling `formatHelp()`.
|
||||||
|
*
|
||||||
|
* Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.
|
||||||
|
*
|
||||||
|
* @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions
|
||||||
|
*/
|
||||||
|
prepareContext(contextOptions) {
|
||||||
|
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
||||||
*
|
*
|
||||||
@@ -25,19 +38,14 @@ class Help {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
visibleCommands(cmd) {
|
visibleCommands(cmd) {
|
||||||
const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);
|
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
|
||||||
if (cmd._hasImplicitHelpCommand()) {
|
const helpCommand = cmd._getHelpCommand();
|
||||||
// Create a command matching the implicit help command.
|
if (helpCommand && !helpCommand._hidden) {
|
||||||
const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
|
|
||||||
const helpCommand = cmd.createCommand(helpName)
|
|
||||||
.helpOption(false);
|
|
||||||
helpCommand.description(cmd._helpCommandDescription);
|
|
||||||
if (helpArgs) helpCommand.arguments(helpArgs);
|
|
||||||
visibleCommands.push(helpCommand);
|
visibleCommands.push(helpCommand);
|
||||||
}
|
}
|
||||||
if (this.sortSubcommands) {
|
if (this.sortSubcommands) {
|
||||||
visibleCommands.sort((a, b) => {
|
visibleCommands.sort((a, b) => {
|
||||||
// @ts-ignore: overloaded return type
|
// @ts-ignore: because overloaded return type
|
||||||
return a.name().localeCompare(b.name());
|
return a.name().localeCompare(b.name());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -49,12 +57,14 @@ class Help {
|
|||||||
*
|
*
|
||||||
* @param {Option} a
|
* @param {Option} a
|
||||||
* @param {Option} b
|
* @param {Option} b
|
||||||
* @returns number
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
compareOptions(a, b) {
|
compareOptions(a, b) {
|
||||||
const getSortKey = (option) => {
|
const getSortKey = (option) => {
|
||||||
// WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
|
// WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
|
||||||
return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
|
return option.short
|
||||||
|
? option.short.replace(/^-/, '')
|
||||||
|
: option.long.replace(/^--/, '');
|
||||||
};
|
};
|
||||||
return getSortKey(a).localeCompare(getSortKey(b));
|
return getSortKey(a).localeCompare(getSortKey(b));
|
||||||
}
|
}
|
||||||
@@ -68,19 +78,23 @@ class Help {
|
|||||||
|
|
||||||
visibleOptions(cmd) {
|
visibleOptions(cmd) {
|
||||||
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
||||||
// Implicit help
|
// Built-in help option.
|
||||||
const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
|
const helpOption = cmd._getHelpOption();
|
||||||
const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
|
if (helpOption && !helpOption.hidden) {
|
||||||
if (showShortHelpFlag || showLongHelpFlag) {
|
// Automatically hide conflicting flags. Bit dubious but a historical behaviour that is convenient for single-command programs.
|
||||||
let helpOption;
|
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
||||||
if (!showShortHelpFlag) {
|
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
||||||
helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
|
if (!removeShort && !removeLong) {
|
||||||
} else if (!showLongHelpFlag) {
|
visibleOptions.push(helpOption); // no changes needed
|
||||||
helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
|
} else if (helpOption.long && !removeLong) {
|
||||||
} else {
|
visibleOptions.push(
|
||||||
helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
|
cmd.createOption(helpOption.long, helpOption.description),
|
||||||
|
);
|
||||||
|
} else if (helpOption.short && !removeShort) {
|
||||||
|
visibleOptions.push(
|
||||||
|
cmd.createOption(helpOption.short, helpOption.description),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
visibleOptions.push(helpOption);
|
|
||||||
}
|
}
|
||||||
if (this.sortOptions) {
|
if (this.sortOptions) {
|
||||||
visibleOptions.sort(this.compareOptions);
|
visibleOptions.sort(this.compareOptions);
|
||||||
@@ -99,8 +113,14 @@ class Help {
|
|||||||
if (!this.showGlobalOptions) return [];
|
if (!this.showGlobalOptions) return [];
|
||||||
|
|
||||||
const globalOptions = [];
|
const globalOptions = [];
|
||||||
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
for (
|
||||||
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
|
let ancestorCmd = cmd.parent;
|
||||||
|
ancestorCmd;
|
||||||
|
ancestorCmd = ancestorCmd.parent
|
||||||
|
) {
|
||||||
|
const visibleOptions = ancestorCmd.options.filter(
|
||||||
|
(option) => !option.hidden,
|
||||||
|
);
|
||||||
globalOptions.push(...visibleOptions);
|
globalOptions.push(...visibleOptions);
|
||||||
}
|
}
|
||||||
if (this.sortOptions) {
|
if (this.sortOptions) {
|
||||||
@@ -119,13 +139,14 @@ class Help {
|
|||||||
visibleArguments(cmd) {
|
visibleArguments(cmd) {
|
||||||
// Side effect! Apply the legacy descriptions before the arguments are displayed.
|
// Side effect! Apply the legacy descriptions before the arguments are displayed.
|
||||||
if (cmd._argsDescription) {
|
if (cmd._argsDescription) {
|
||||||
cmd.registeredArguments.forEach(argument => {
|
cmd.registeredArguments.forEach((argument) => {
|
||||||
argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
|
argument.description =
|
||||||
|
argument.description || cmd._argsDescription[argument.name()] || '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are any arguments with a description then return all the arguments.
|
// If there are any arguments with a description then return all the arguments.
|
||||||
if (cmd.registeredArguments.find(argument => argument.description)) {
|
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
||||||
return cmd.registeredArguments;
|
return cmd.registeredArguments;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@@ -140,11 +161,15 @@ class Help {
|
|||||||
|
|
||||||
subcommandTerm(cmd) {
|
subcommandTerm(cmd) {
|
||||||
// Legacy. Ignores custom usage string, and nested commands.
|
// Legacy. Ignores custom usage string, and nested commands.
|
||||||
const args = cmd.registeredArguments.map(arg => humanReadableArgName(arg)).join(' ');
|
const args = cmd.registeredArguments
|
||||||
return cmd._name +
|
.map((arg) => humanReadableArgName(arg))
|
||||||
|
.join(' ');
|
||||||
|
return (
|
||||||
|
cmd._name +
|
||||||
(cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
|
(cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
|
||||||
(cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
|
(cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
|
||||||
(args ? ' ' + args : '');
|
(args ? ' ' + args : '')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +204,12 @@ class Help {
|
|||||||
|
|
||||||
longestSubcommandTermLength(cmd, helper) {
|
longestSubcommandTermLength(cmd, helper) {
|
||||||
return helper.visibleCommands(cmd).reduce((max, command) => {
|
return helper.visibleCommands(cmd).reduce((max, command) => {
|
||||||
return Math.max(max, helper.subcommandTerm(command).length);
|
return Math.max(
|
||||||
|
max,
|
||||||
|
this.displayWidth(
|
||||||
|
helper.styleSubcommandTerm(helper.subcommandTerm(command)),
|
||||||
|
),
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +223,10 @@ class Help {
|
|||||||
|
|
||||||
longestOptionTermLength(cmd, helper) {
|
longestOptionTermLength(cmd, helper) {
|
||||||
return helper.visibleOptions(cmd).reduce((max, option) => {
|
return helper.visibleOptions(cmd).reduce((max, option) => {
|
||||||
return Math.max(max, helper.optionTerm(option).length);
|
return Math.max(
|
||||||
|
max,
|
||||||
|
this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +240,10 @@ class Help {
|
|||||||
|
|
||||||
longestGlobalOptionTermLength(cmd, helper) {
|
longestGlobalOptionTermLength(cmd, helper) {
|
||||||
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
||||||
return Math.max(max, helper.optionTerm(option).length);
|
return Math.max(
|
||||||
|
max,
|
||||||
|
this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +257,12 @@ class Help {
|
|||||||
|
|
||||||
longestArgumentTermLength(cmd, helper) {
|
longestArgumentTermLength(cmd, helper) {
|
||||||
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
||||||
return Math.max(max, helper.argumentTerm(argument).length);
|
return Math.max(
|
||||||
|
max,
|
||||||
|
this.displayWidth(
|
||||||
|
helper.styleArgumentTerm(helper.argumentTerm(argument)),
|
||||||
|
),
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +280,11 @@ class Help {
|
|||||||
cmdName = cmdName + '|' + cmd._aliases[0];
|
cmdName = cmdName + '|' + cmd._aliases[0];
|
||||||
}
|
}
|
||||||
let ancestorCmdNames = '';
|
let ancestorCmdNames = '';
|
||||||
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
for (
|
||||||
|
let ancestorCmd = cmd.parent;
|
||||||
|
ancestorCmd;
|
||||||
|
ancestorCmd = ancestorCmd.parent
|
||||||
|
) {
|
||||||
ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
|
ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
|
||||||
}
|
}
|
||||||
return ancestorCmdNames + cmdName + ' ' + cmd.usage();
|
return ancestorCmdNames + cmdName + ' ' + cmd.usage();
|
||||||
@@ -253,7 +298,7 @@ class Help {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
commandDescription(cmd) {
|
commandDescription(cmd) {
|
||||||
// @ts-ignore: overloaded return type
|
// @ts-ignore: because overloaded return type
|
||||||
return cmd.description();
|
return cmd.description();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +311,7 @@ class Help {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
subcommandDescription(cmd) {
|
subcommandDescription(cmd) {
|
||||||
// @ts-ignore: overloaded return type
|
// @ts-ignore: because overloaded return type
|
||||||
return cmd.summary() || cmd.description();
|
return cmd.summary() || cmd.description();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,15 +328,20 @@ class Help {
|
|||||||
if (option.argChoices) {
|
if (option.argChoices) {
|
||||||
extraInfo.push(
|
extraInfo.push(
|
||||||
// use stringify to match the display of the default value
|
// use stringify to match the display of the default value
|
||||||
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
|
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (option.defaultValue !== undefined) {
|
if (option.defaultValue !== undefined) {
|
||||||
// default for boolean and negated more for programmer than end user,
|
// default for boolean and negated more for programmer than end user,
|
||||||
// but show true/false for boolean option as may be for hand-rolled env or config processing.
|
// but show true/false for boolean option as may be for hand-rolled env or config processing.
|
||||||
const showDefault = option.required || option.optional ||
|
const showDefault =
|
||||||
|
option.required ||
|
||||||
|
option.optional ||
|
||||||
(option.isBoolean() && typeof option.defaultValue === 'boolean');
|
(option.isBoolean() && typeof option.defaultValue === 'boolean');
|
||||||
if (showDefault) {
|
if (showDefault) {
|
||||||
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
|
extraInfo.push(
|
||||||
|
`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// preset for boolean and negated are more for programmer than end user
|
// preset for boolean and negated are more for programmer than end user
|
||||||
@@ -320,17 +370,20 @@ class Help {
|
|||||||
if (argument.argChoices) {
|
if (argument.argChoices) {
|
||||||
extraInfo.push(
|
extraInfo.push(
|
||||||
// use stringify to match the display of the default value
|
// use stringify to match the display of the default value
|
||||||
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
|
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (argument.defaultValue !== undefined) {
|
if (argument.defaultValue !== undefined) {
|
||||||
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
extraInfo.push(
|
||||||
|
`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (extraInfo.length > 0) {
|
if (extraInfo.length > 0) {
|
||||||
const extraDescripton = `(${extraInfo.join(', ')})`;
|
const extraDescription = `(${extraInfo.join(', ')})`;
|
||||||
if (argument.description) {
|
if (argument.description) {
|
||||||
return `${argument.description} ${extraDescripton}`;
|
return `${argument.description} ${extraDescription}`;
|
||||||
}
|
}
|
||||||
return extraDescripton;
|
return extraDescription;
|
||||||
}
|
}
|
||||||
return argument.description;
|
return argument.description;
|
||||||
}
|
}
|
||||||
@@ -345,65 +398,177 @@ class Help {
|
|||||||
|
|
||||||
formatHelp(cmd, helper) {
|
formatHelp(cmd, helper) {
|
||||||
const termWidth = helper.padWidth(cmd, helper);
|
const termWidth = helper.padWidth(cmd, helper);
|
||||||
const helpWidth = helper.helpWidth || 80;
|
const helpWidth = helper.helpWidth ?? 80; // in case prepareContext() was not called
|
||||||
const itemIndentWidth = 2;
|
|
||||||
const itemSeparatorWidth = 2; // between term and description
|
function callFormatItem(term, description) {
|
||||||
function formatItem(term, description) {
|
return helper.formatItem(term, termWidth, description, helper);
|
||||||
if (description) {
|
|
||||||
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
||||||
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
|
|
||||||
}
|
|
||||||
return term;
|
|
||||||
}
|
|
||||||
function formatList(textArray) {
|
|
||||||
return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usage
|
// Usage
|
||||||
let output = [`Usage: ${helper.commandUsage(cmd)}`, ''];
|
let output = [
|
||||||
|
`${helper.styleTitle('Usage:')} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
const commandDescription = helper.commandDescription(cmd);
|
const commandDescription = helper.commandDescription(cmd);
|
||||||
if (commandDescription.length > 0) {
|
if (commandDescription.length > 0) {
|
||||||
output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']);
|
output = output.concat([
|
||||||
|
helper.boxWrap(
|
||||||
|
helper.styleCommandDescription(commandDescription),
|
||||||
|
helpWidth,
|
||||||
|
),
|
||||||
|
'',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
||||||
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
|
return callFormatItem(
|
||||||
|
helper.styleArgumentTerm(helper.argumentTerm(argument)),
|
||||||
|
helper.styleArgumentDescription(helper.argumentDescription(argument)),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
if (argumentList.length > 0) {
|
if (argumentList.length > 0) {
|
||||||
output = output.concat(['Arguments:', formatList(argumentList), '']);
|
output = output.concat([
|
||||||
|
helper.styleTitle('Arguments:'),
|
||||||
|
...argumentList,
|
||||||
|
'',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
const optionList = helper.visibleOptions(cmd).map((option) => {
|
const optionList = helper.visibleOptions(cmd).map((option) => {
|
||||||
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
return callFormatItem(
|
||||||
|
helper.styleOptionTerm(helper.optionTerm(option)),
|
||||||
|
helper.styleOptionDescription(helper.optionDescription(option)),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
if (optionList.length > 0) {
|
if (optionList.length > 0) {
|
||||||
output = output.concat(['Options:', formatList(optionList), '']);
|
output = output.concat([
|
||||||
|
helper.styleTitle('Options:'),
|
||||||
|
...optionList,
|
||||||
|
'',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.showGlobalOptions) {
|
if (helper.showGlobalOptions) {
|
||||||
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
const globalOptionList = helper
|
||||||
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
.visibleGlobalOptions(cmd)
|
||||||
});
|
.map((option) => {
|
||||||
|
return callFormatItem(
|
||||||
|
helper.styleOptionTerm(helper.optionTerm(option)),
|
||||||
|
helper.styleOptionDescription(helper.optionDescription(option)),
|
||||||
|
);
|
||||||
|
});
|
||||||
if (globalOptionList.length > 0) {
|
if (globalOptionList.length > 0) {
|
||||||
output = output.concat(['Global Options:', formatList(globalOptionList), '']);
|
output = output.concat([
|
||||||
|
helper.styleTitle('Global Options:'),
|
||||||
|
...globalOptionList,
|
||||||
|
'',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
||||||
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
return callFormatItem(
|
||||||
|
helper.styleSubcommandTerm(helper.subcommandTerm(cmd)),
|
||||||
|
helper.styleSubcommandDescription(helper.subcommandDescription(cmd)),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
if (commandList.length > 0) {
|
if (commandList.length > 0) {
|
||||||
output = output.concat(['Commands:', formatList(commandList), '']);
|
output = output.concat([
|
||||||
|
helper.styleTitle('Commands:'),
|
||||||
|
...commandList,
|
||||||
|
'',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.join('\n');
|
return output.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
displayWidth(str) {
|
||||||
|
return stripColor(str).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
styleTitle(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
styleUsage(str) {
|
||||||
|
// Usage has lots of parts the user might like to color separately! Assume default usage string which is formed like:
|
||||||
|
// command subcommand [options] [command] <foo> [bar]
|
||||||
|
return str
|
||||||
|
.split(' ')
|
||||||
|
.map((word) => {
|
||||||
|
if (word === '[options]') return this.styleOptionText(word);
|
||||||
|
if (word === '[command]') return this.styleSubcommandText(word);
|
||||||
|
if (word[0] === '[' || word[0] === '<')
|
||||||
|
return this.styleArgumentText(word);
|
||||||
|
return this.styleCommandText(word); // Restrict to initial words?
|
||||||
|
})
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
styleCommandDescription(str) {
|
||||||
|
return this.styleDescriptionText(str);
|
||||||
|
}
|
||||||
|
styleOptionDescription(str) {
|
||||||
|
return this.styleDescriptionText(str);
|
||||||
|
}
|
||||||
|
styleSubcommandDescription(str) {
|
||||||
|
return this.styleDescriptionText(str);
|
||||||
|
}
|
||||||
|
styleArgumentDescription(str) {
|
||||||
|
return this.styleDescriptionText(str);
|
||||||
|
}
|
||||||
|
styleDescriptionText(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
styleOptionTerm(str) {
|
||||||
|
return this.styleOptionText(str);
|
||||||
|
}
|
||||||
|
styleSubcommandTerm(str) {
|
||||||
|
// This is very like usage with lots of parts! Assume default string which is formed like:
|
||||||
|
// subcommand [options] <foo> [bar]
|
||||||
|
return str
|
||||||
|
.split(' ')
|
||||||
|
.map((word) => {
|
||||||
|
if (word === '[options]') return this.styleOptionText(word);
|
||||||
|
if (word[0] === '[' || word[0] === '<')
|
||||||
|
return this.styleArgumentText(word);
|
||||||
|
return this.styleSubcommandText(word); // Restrict to initial words?
|
||||||
|
})
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
styleArgumentTerm(str) {
|
||||||
|
return this.styleArgumentText(str);
|
||||||
|
}
|
||||||
|
styleOptionText(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
styleArgumentText(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
styleSubcommandText(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
styleCommandText(str) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the pad width from the maximum term length.
|
* Calculate the pad width from the maximum term length.
|
||||||
*
|
*
|
||||||
@@ -417,46 +582,128 @@ class Help {
|
|||||||
helper.longestOptionTermLength(cmd, helper),
|
helper.longestOptionTermLength(cmd, helper),
|
||||||
helper.longestGlobalOptionTermLength(cmd, helper),
|
helper.longestGlobalOptionTermLength(cmd, helper),
|
||||||
helper.longestSubcommandTermLength(cmd, helper),
|
helper.longestSubcommandTermLength(cmd, helper),
|
||||||
helper.longestArgumentTermLength(cmd, helper)
|
helper.longestArgumentTermLength(cmd, helper),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the given string to width characters per line, with lines after the first indented.
|
* Detect manually wrapped and indented strings by checking for line break followed by whitespace.
|
||||||
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
preformatted(str) {
|
||||||
|
return /\n[^\S\r\n]/.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
||||||
|
*
|
||||||
|
* So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
|
||||||
|
* TTT DDD DDDD
|
||||||
|
* DD DDD
|
||||||
|
*
|
||||||
|
* @param {string} term
|
||||||
|
* @param {number} termWidth
|
||||||
|
* @param {string} description
|
||||||
|
* @param {Help} helper
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
formatItem(term, termWidth, description, helper) {
|
||||||
|
const itemIndent = 2;
|
||||||
|
const itemIndentStr = ' '.repeat(itemIndent);
|
||||||
|
if (!description) return itemIndentStr + term;
|
||||||
|
|
||||||
|
// Pad the term out to a consistent width, so descriptions are aligned.
|
||||||
|
const paddedTerm = term.padEnd(
|
||||||
|
termWidth + term.length - helper.displayWidth(term),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Format the description.
|
||||||
|
const spacerWidth = 2; // between term and description
|
||||||
|
const helpWidth = this.helpWidth ?? 80; // in case prepareContext() was not called
|
||||||
|
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
||||||
|
let formattedDescription;
|
||||||
|
if (
|
||||||
|
remainingWidth < this.minWidthToWrap ||
|
||||||
|
helper.preformatted(description)
|
||||||
|
) {
|
||||||
|
formattedDescription = description;
|
||||||
|
} else {
|
||||||
|
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
||||||
|
formattedDescription = wrappedDescription.replace(
|
||||||
|
/\n/g,
|
||||||
|
'\n' + ' '.repeat(termWidth + spacerWidth),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct and overall indent.
|
||||||
|
return (
|
||||||
|
itemIndentStr +
|
||||||
|
paddedTerm +
|
||||||
|
' '.repeat(spacerWidth) +
|
||||||
|
formattedDescription.replace(/\n/g, `\n${itemIndentStr}`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap a string at whitespace, preserving existing line breaks.
|
||||||
|
* Wrapping is skipped if the width is less than `minWidthToWrap`.
|
||||||
*
|
*
|
||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @param {number} width
|
* @param {number} width
|
||||||
* @param {number} indent
|
* @returns {string}
|
||||||
* @param {number} [minColumnWidth=40]
|
|
||||||
* @return {string}
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
boxWrap(str, width) {
|
||||||
|
if (width < this.minWidthToWrap) return str;
|
||||||
|
|
||||||
wrap(str, width, indent, minColumnWidth = 40) {
|
const rawLines = str.split(/\r\n|\n/);
|
||||||
// Full \s characters, minus the linefeeds.
|
// split up text by whitespace
|
||||||
const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
|
const chunkPattern = /[\s]*[^\s]+/g;
|
||||||
// Detect manually wrapped and indented strings by searching for line break followed by spaces.
|
const wrappedLines = [];
|
||||||
const manualIndent = new RegExp(`[\\n][${indents}]+`);
|
rawLines.forEach((line) => {
|
||||||
if (str.match(manualIndent)) return str;
|
const chunks = line.match(chunkPattern);
|
||||||
// Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line).
|
if (chunks === null) {
|
||||||
const columnWidth = width - indent;
|
wrappedLines.push('');
|
||||||
if (columnWidth < minColumnWidth) return str;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const leadingStr = str.slice(0, indent);
|
let sumChunks = [chunks.shift()];
|
||||||
const columnText = str.slice(indent).replace('\r\n', '\n');
|
let sumWidth = this.displayWidth(sumChunks[0]);
|
||||||
const indentString = ' '.repeat(indent);
|
chunks.forEach((chunk) => {
|
||||||
const zeroWidthSpace = '\u200B';
|
const visibleWidth = this.displayWidth(chunk);
|
||||||
const breaks = `\\s${zeroWidthSpace}`;
|
// Accumulate chunks while they fit into width.
|
||||||
// Match line end (so empty lines don't collapse),
|
if (sumWidth + visibleWidth <= width) {
|
||||||
// or as much text as will fit in column, or excess text up to first break.
|
sumChunks.push(chunk);
|
||||||
const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g');
|
sumWidth += visibleWidth;
|
||||||
const lines = columnText.match(regex) || [];
|
return;
|
||||||
return leadingStr + lines.map((line, i) => {
|
}
|
||||||
if (line === '\n') return ''; // preserve empty lines
|
wrappedLines.push(sumChunks.join(''));
|
||||||
return ((i > 0) ? indentString : '') + line.trimEnd();
|
|
||||||
}).join('\n');
|
const nextChunk = chunk.trimStart(); // trim space at line break
|
||||||
|
sumChunks = [nextChunk];
|
||||||
|
sumWidth = this.displayWidth(nextChunk);
|
||||||
|
});
|
||||||
|
wrappedLines.push(sumChunks.join(''));
|
||||||
|
});
|
||||||
|
|
||||||
|
return wrappedLines.join('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {string}
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
|
||||||
|
function stripColor(str) {
|
||||||
|
// eslint-disable-next-line no-control-regex
|
||||||
|
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
||||||
|
return str.replace(sgrPattern, '');
|
||||||
|
}
|
||||||
|
|
||||||
exports.Help = Help;
|
exports.Help = Help;
|
||||||
|
exports.stripColor = stripColor;
|
||||||
|
|||||||
84
node_modules/commander/lib/option.js
generated
vendored
84
node_modules/commander/lib/option.js
generated
vendored
@@ -18,7 +18,7 @@ class Option {
|
|||||||
this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values.
|
this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values.
|
||||||
this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
|
this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
|
||||||
const optionFlags = splitOptionFlags(flags);
|
const optionFlags = splitOptionFlags(flags);
|
||||||
this.short = optionFlags.shortFlag;
|
this.short = optionFlags.shortFlag; // May be a short flag, undefined, or even a long flag (if option has two long flags).
|
||||||
this.long = optionFlags.longFlag;
|
this.long = optionFlags.longFlag;
|
||||||
this.negate = false;
|
this.negate = false;
|
||||||
if (this.long) {
|
if (this.long) {
|
||||||
@@ -74,7 +74,7 @@ class Option {
|
|||||||
* new Option('--rgb').conflicts('cmyk');
|
* new Option('--rgb').conflicts('cmyk');
|
||||||
* new Option('--js').conflicts(['ts', 'jsx']);
|
* new Option('--js').conflicts(['ts', 'jsx']);
|
||||||
*
|
*
|
||||||
* @param {string | string[]} names
|
* @param {(string | string[])} names
|
||||||
* @return {Option}
|
* @return {Option}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ class Option {
|
|||||||
* .addOption(new Option('--log', 'write logging information to file'))
|
* .addOption(new Option('--log', 'write logging information to file'))
|
||||||
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
||||||
*
|
*
|
||||||
* @param {Object} impliedOptionValues
|
* @param {object} impliedOptionValues
|
||||||
* @return {Option}
|
* @return {Option}
|
||||||
*/
|
*/
|
||||||
implies(impliedOptionValues) {
|
implies(impliedOptionValues) {
|
||||||
@@ -158,7 +158,7 @@ class Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api private
|
* @package
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_concatValue(value, previous) {
|
_concatValue(value, previous) {
|
||||||
@@ -180,7 +180,9 @@ class Option {
|
|||||||
this.argChoices = values.slice();
|
this.argChoices = values.slice();
|
||||||
this.parseArg = (arg, previous) => {
|
this.parseArg = (arg, previous) => {
|
||||||
if (!this.argChoices.includes(arg)) {
|
if (!this.argChoices.includes(arg)) {
|
||||||
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
throw new InvalidArgumentError(
|
||||||
|
`Allowed choices are ${this.argChoices.join(', ')}.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (this.variadic) {
|
if (this.variadic) {
|
||||||
return this._concatValue(arg, previous);
|
return this._concatValue(arg, previous);
|
||||||
@@ -205,14 +207,16 @@ class Option {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return option name, in a camelcase format that can be used
|
* Return option name, in a camelcase format that can be used
|
||||||
* as a object attribute key.
|
* as an object attribute key.
|
||||||
*
|
*
|
||||||
* @return {string}
|
* @return {string}
|
||||||
* @api private
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
attributeName() {
|
attributeName() {
|
||||||
return camelcase(this.name().replace(/^no-/, ''));
|
if (this.negate) {
|
||||||
|
return camelcase(this.name().replace(/^no-/, ''));
|
||||||
|
}
|
||||||
|
return camelcase(this.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +224,7 @@ class Option {
|
|||||||
*
|
*
|
||||||
* @param {string} arg
|
* @param {string} arg
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
* @api private
|
* @package
|
||||||
*/
|
*/
|
||||||
|
|
||||||
is(arg) {
|
is(arg) {
|
||||||
@@ -233,7 +237,7 @@ class Option {
|
|||||||
* Options are one of boolean, negated, required argument, or optional argument.
|
* Options are one of boolean, negated, required argument, or optional argument.
|
||||||
*
|
*
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
* @api private
|
* @package
|
||||||
*/
|
*/
|
||||||
|
|
||||||
isBoolean() {
|
isBoolean() {
|
||||||
@@ -256,7 +260,7 @@ class DualOptions {
|
|||||||
this.positiveOptions = new Map();
|
this.positiveOptions = new Map();
|
||||||
this.negativeOptions = new Map();
|
this.negativeOptions = new Map();
|
||||||
this.dualOptions = new Set();
|
this.dualOptions = new Set();
|
||||||
options.forEach(option => {
|
options.forEach((option) => {
|
||||||
if (option.negate) {
|
if (option.negate) {
|
||||||
this.negativeOptions.set(option.attributeName(), option);
|
this.negativeOptions.set(option.attributeName(), option);
|
||||||
} else {
|
} else {
|
||||||
@@ -283,7 +287,7 @@ class DualOptions {
|
|||||||
|
|
||||||
// Use the value to deduce if (probably) came from the option.
|
// Use the value to deduce if (probably) came from the option.
|
||||||
const preset = this.negativeOptions.get(optionKey).presetArg;
|
const preset = this.negativeOptions.get(optionKey).presetArg;
|
||||||
const negativeValue = (preset !== undefined) ? preset : false;
|
const negativeValue = preset !== undefined ? preset : false;
|
||||||
return option.negate === (negativeValue === value);
|
return option.negate === (negativeValue === value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,7 +297,7 @@ class DualOptions {
|
|||||||
*
|
*
|
||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @return {string}
|
* @return {string}
|
||||||
* @api private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function camelcase(str) {
|
function camelcase(str) {
|
||||||
@@ -305,25 +309,59 @@ function camelcase(str) {
|
|||||||
/**
|
/**
|
||||||
* Split the short and long flag out of something like '-m,--mixed <value>'
|
* Split the short and long flag out of something like '-m,--mixed <value>'
|
||||||
*
|
*
|
||||||
* @api private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function splitOptionFlags(flags) {
|
function splitOptionFlags(flags) {
|
||||||
let shortFlag;
|
let shortFlag;
|
||||||
let longFlag;
|
let longFlag;
|
||||||
// Use original very loose parsing to maintain backwards compatibility for now,
|
// short flag, single dash and single character
|
||||||
// which allowed for example unintended `-sw, --short-word` [sic].
|
const shortFlagExp = /^-[^-]$/;
|
||||||
const flagParts = flags.split(/[ |,]+/);
|
// long flag, double dash and at least one character
|
||||||
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
|
const longFlagExp = /^--[^-]/;
|
||||||
longFlag = flagParts.shift();
|
|
||||||
// Add support for lone short flag without significantly changing parsing!
|
const flagParts = flags.split(/[ |,]+/).concat('guard');
|
||||||
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
// Normal is short and/or long.
|
||||||
|
if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();
|
||||||
|
if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();
|
||||||
|
// Long then short. Rarely used but fine.
|
||||||
|
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
||||||
|
shortFlag = flagParts.shift();
|
||||||
|
// Allow two long flags, like '--ws, --workspace'
|
||||||
|
// This is the supported way to have a shortish option flag.
|
||||||
|
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
||||||
shortFlag = longFlag;
|
shortFlag = longFlag;
|
||||||
longFlag = undefined;
|
longFlag = flagParts.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for unprocessed flag. Fail noisily rather than silently ignore.
|
||||||
|
if (flagParts[0].startsWith('-')) {
|
||||||
|
const unsupportedFlag = flagParts[0];
|
||||||
|
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
||||||
|
if (/^-[^-][^-]/.test(unsupportedFlag))
|
||||||
|
throw new Error(
|
||||||
|
`${baseError}
|
||||||
|
- a short flag is a single dash and a single character
|
||||||
|
- either use a single dash and a single character (for a short flag)
|
||||||
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`,
|
||||||
|
);
|
||||||
|
if (shortFlagExp.test(unsupportedFlag))
|
||||||
|
throw new Error(`${baseError}
|
||||||
|
- too many short flags`);
|
||||||
|
if (longFlagExp.test(unsupportedFlag))
|
||||||
|
throw new Error(`${baseError}
|
||||||
|
- too many long flags`);
|
||||||
|
|
||||||
|
throw new Error(`${baseError}
|
||||||
|
- unrecognised flag format`);
|
||||||
|
}
|
||||||
|
if (shortFlag === undefined && longFlag === undefined)
|
||||||
|
throw new Error(
|
||||||
|
`option creation failed due to no flags found in '${flags}'.`,
|
||||||
|
);
|
||||||
|
|
||||||
return { shortFlag, longFlag };
|
return { shortFlag, longFlag };
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Option = Option;
|
exports.Option = Option;
|
||||||
exports.splitOptionFlags = splitOptionFlags;
|
|
||||||
exports.DualOptions = DualOptions;
|
exports.DualOptions = DualOptions;
|
||||||
|
|||||||
9
node_modules/commander/lib/suggestSimilar.js
generated
vendored
9
node_modules/commander/lib/suggestSimilar.js
generated
vendored
@@ -6,7 +6,8 @@ function editDistance(a, b) {
|
|||||||
// (Simple implementation.)
|
// (Simple implementation.)
|
||||||
|
|
||||||
// Quick early exit, return worst case.
|
// Quick early exit, return worst case.
|
||||||
if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
|
if (Math.abs(a.length - b.length) > maxDistance)
|
||||||
|
return Math.max(a.length, b.length);
|
||||||
|
|
||||||
// distance between prefix substrings of a and b
|
// distance between prefix substrings of a and b
|
||||||
const d = [];
|
const d = [];
|
||||||
@@ -32,7 +33,7 @@ function editDistance(a, b) {
|
|||||||
d[i][j] = Math.min(
|
d[i][j] = Math.min(
|
||||||
d[i - 1][j] + 1, // deletion
|
d[i - 1][j] + 1, // deletion
|
||||||
d[i][j - 1] + 1, // insertion
|
d[i][j - 1] + 1, // insertion
|
||||||
d[i - 1][j - 1] + cost // substitution
|
d[i - 1][j - 1] + cost, // substitution
|
||||||
);
|
);
|
||||||
// transposition
|
// transposition
|
||||||
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
||||||
@@ -60,7 +61,7 @@ function suggestSimilar(word, candidates) {
|
|||||||
const searchingOptions = word.startsWith('--');
|
const searchingOptions = word.startsWith('--');
|
||||||
if (searchingOptions) {
|
if (searchingOptions) {
|
||||||
word = word.slice(2);
|
word = word.slice(2);
|
||||||
candidates = candidates.map(candidate => candidate.slice(2));
|
candidates = candidates.map((candidate) => candidate.slice(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
let similar = [];
|
let similar = [];
|
||||||
@@ -85,7 +86,7 @@ function suggestSimilar(word, candidates) {
|
|||||||
|
|
||||||
similar.sort((a, b) => a.localeCompare(b));
|
similar.sort((a, b) => a.localeCompare(b));
|
||||||
if (searchingOptions) {
|
if (searchingOptions) {
|
||||||
similar = similar.map(candidate => `--${candidate}`);
|
similar = similar.map((candidate) => `--${candidate}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (similar.length > 1) {
|
if (similar.length > 1) {
|
||||||
|
|||||||
48
node_modules/commander/package.json
generated
vendored
48
node_modules/commander/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "commander",
|
"name": "commander",
|
||||||
"version": "11.1.0",
|
"version": "13.1.0",
|
||||||
"description": "the complete solution for node.js command-line programs",
|
"description": "the complete solution for node.js command-line programs",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"commander",
|
"commander",
|
||||||
@@ -16,17 +16,21 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tj/commander.js.git"
|
"url": "git+https://github.com/tj/commander.js.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "npm run lint:javascript && npm run lint:typescript",
|
"check": "npm run check:type && npm run check:lint && npm run check:format",
|
||||||
"lint:javascript": "eslint index.js esm.mjs \"lib/*.js\" \"tests/**/*.js\"",
|
"check:format": "prettier --check .",
|
||||||
"lint:typescript": "eslint typings/*.ts tests/*.ts",
|
"check:lint": "eslint .",
|
||||||
"test": "jest && npm run typecheck-ts",
|
"check:type": "npm run check:type:js && npm run check:type:ts",
|
||||||
"test-esm": "node ./tests/esm-imports-test.mjs",
|
"check:type:ts": "tsd && tsc -p tsconfig.ts.json",
|
||||||
"typecheck-ts": "tsd && tsc -p tsconfig.ts.json",
|
"check:type:js": "tsc -p tsconfig.js.json",
|
||||||
"typecheck-js": "tsc -p tsconfig.js.json",
|
"fix": "npm run fix:lint && npm run fix:format",
|
||||||
"test-all": "npm run test && npm run lint && npm run typecheck-js && npm run test-esm"
|
"fix:format": "prettier --write .",
|
||||||
|
"fix:lint": "eslint --fix .",
|
||||||
|
"test": "jest && npm run check:type:ts",
|
||||||
|
"test-all": "jest && npm run test-esm && npm run check",
|
||||||
|
"test-esm": "node ./tests/esm-imports-test.mjs"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
@@ -56,25 +60,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.4.0",
|
||||||
"@types/jest": "^29.2.4",
|
"@types/jest": "^29.2.4",
|
||||||
"@types/node": "^20.2.5",
|
"@types/node": "^22.7.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
"eslint": "^9.17.0",
|
||||||
"@typescript-eslint/parser": "^5.47.1",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint": "^8.30.0",
|
"eslint-plugin-jest": "^28.3.0",
|
||||||
"eslint-config-standard": "^17.0.0",
|
"globals": "^15.7.0",
|
||||||
"eslint-config-standard-with-typescript": "^33.0.0",
|
|
||||||
"eslint-plugin-import": "^2.26.0",
|
|
||||||
"eslint-plugin-jest": "^27.1.7",
|
|
||||||
"eslint-plugin-n": "^15.6.0",
|
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.0.3",
|
||||||
"tsd": "^0.28.1",
|
"tsd": "^0.31.0",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4",
|
||||||
|
"typescript-eslint": "^8.12.2"
|
||||||
},
|
},
|
||||||
"types": "typings/index.d.ts",
|
"types": "typings/index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"support": true
|
"support": true
|
||||||
}
|
}
|
||||||
|
|||||||
273
node_modules/commander/typings/index.d.ts
generated
vendored
273
node_modules/commander/typings/index.d.ts
generated
vendored
@@ -1,8 +1,6 @@
|
|||||||
// Type definitions for commander
|
// Type definitions for commander
|
||||||
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
||||||
|
|
||||||
// Using method rather than property for method-signature-style, to document method overloads separately. Allow either.
|
|
||||||
/* eslint-disable @typescript-eslint/method-signature-style */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
// This is a trick to encourage editor to suggest the known literals while still
|
// This is a trick to encourage editor to suggest the known literals while still
|
||||||
@@ -11,7 +9,9 @@
|
|||||||
// - https://github.com/microsoft/TypeScript/issues/29729
|
// - https://github.com/microsoft/TypeScript/issues/29729
|
||||||
// - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
|
// - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
|
||||||
// - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
|
// - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
|
||||||
type LiteralUnion<LiteralType, BaseType extends string | number> = LiteralType | (BaseType & Record<never, never>);
|
type LiteralUnion<LiteralType, BaseType extends string | number> =
|
||||||
|
| LiteralType
|
||||||
|
| (BaseType & Record<never, never>);
|
||||||
|
|
||||||
export class CommanderError extends Error {
|
export class CommanderError extends Error {
|
||||||
code: string;
|
code: string;
|
||||||
@@ -24,7 +24,6 @@ export class CommanderError extends Error {
|
|||||||
* @param exitCode - suggested exit code which could be used with process.exit
|
* @param exitCode - suggested exit code which could be used with process.exit
|
||||||
* @param code - an id string representing the error
|
* @param code - an id string representing the error
|
||||||
* @param message - human-readable description of the error
|
* @param message - human-readable description of the error
|
||||||
* @constructor
|
|
||||||
*/
|
*/
|
||||||
constructor(exitCode: number, code: string, message: string);
|
constructor(exitCode: number, code: string, message: string);
|
||||||
}
|
}
|
||||||
@@ -33,13 +32,13 @@ export class InvalidArgumentError extends CommanderError {
|
|||||||
/**
|
/**
|
||||||
* Constructs the InvalidArgumentError class
|
* Constructs the InvalidArgumentError class
|
||||||
* @param message - explanation of why argument is invalid
|
* @param message - explanation of why argument is invalid
|
||||||
* @constructor
|
|
||||||
*/
|
*/
|
||||||
constructor(message: string);
|
constructor(message: string);
|
||||||
}
|
}
|
||||||
export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
|
export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
|
||||||
|
|
||||||
export interface ErrorOptions { // optional parameter for error()
|
export interface ErrorOptions {
|
||||||
|
// optional parameter for error()
|
||||||
/** an id string representing the error */
|
/** an id string representing the error */
|
||||||
code?: string;
|
code?: string;
|
||||||
/** suggested exit code which could be used with process.exit */
|
/** suggested exit code which could be used with process.exit */
|
||||||
@@ -162,11 +161,6 @@ export class Option {
|
|||||||
*/
|
*/
|
||||||
env(name: string): this;
|
env(name: string): this;
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the full description, including defaultValue etc.
|
|
||||||
*/
|
|
||||||
fullDescription(): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the custom handler for processing CLI option arguments into option values.
|
* Set the custom handler for processing CLI option arguments into option values.
|
||||||
*/
|
*/
|
||||||
@@ -194,7 +188,7 @@ export class Option {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return option name, in a camelcase format that can be used
|
* Return option name, in a camelcase format that can be used
|
||||||
* as a object attribute key.
|
* as an object attribute key.
|
||||||
*/
|
*/
|
||||||
attributeName(): string;
|
attributeName(): string;
|
||||||
|
|
||||||
@@ -209,12 +203,25 @@ export class Option {
|
|||||||
export class Help {
|
export class Help {
|
||||||
/** output helpWidth, long lines are wrapped to fit */
|
/** output helpWidth, long lines are wrapped to fit */
|
||||||
helpWidth?: number;
|
helpWidth?: number;
|
||||||
|
minWidthToWrap: number;
|
||||||
sortSubcommands: boolean;
|
sortSubcommands: boolean;
|
||||||
sortOptions: boolean;
|
sortOptions: boolean;
|
||||||
showGlobalOptions: boolean;
|
showGlobalOptions: boolean;
|
||||||
|
|
||||||
constructor();
|
constructor();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
|
||||||
|
* and just before calling `formatHelp()`.
|
||||||
|
*
|
||||||
|
* Commander just uses the helpWidth and the others are provided for subclasses.
|
||||||
|
*/
|
||||||
|
prepareContext(contextOptions: {
|
||||||
|
error?: boolean;
|
||||||
|
helpWidth?: number;
|
||||||
|
outputHasColors?: boolean;
|
||||||
|
}): void;
|
||||||
|
|
||||||
/** Get the command term to show in the list of subcommands. */
|
/** Get the command term to show in the list of subcommands. */
|
||||||
subcommandTerm(cmd: Command): string;
|
subcommandTerm(cmd: Command): string;
|
||||||
/** Get the command summary to show in the list of subcommands. */
|
/** Get the command summary to show in the list of subcommands. */
|
||||||
@@ -250,14 +257,61 @@ export class Help {
|
|||||||
longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
|
longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
|
||||||
/** Get the longest argument term length. */
|
/** Get the longest argument term length. */
|
||||||
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
||||||
|
|
||||||
|
/** Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations. */
|
||||||
|
displayWidth(str: string): number;
|
||||||
|
|
||||||
|
/** Style the titles. Called with 'Usage:', 'Options:', etc. */
|
||||||
|
styleTitle(title: string): string;
|
||||||
|
|
||||||
|
/** Usage: <str> */
|
||||||
|
styleUsage(str: string): string;
|
||||||
|
/** Style for command name in usage string. */
|
||||||
|
styleCommandText(str: string): string;
|
||||||
|
|
||||||
|
styleCommandDescription(str: string): string;
|
||||||
|
styleOptionDescription(str: string): string;
|
||||||
|
styleSubcommandDescription(str: string): string;
|
||||||
|
styleArgumentDescription(str: string): string;
|
||||||
|
/** Base style used by descriptions. */
|
||||||
|
styleDescriptionText(str: string): string;
|
||||||
|
|
||||||
|
styleOptionTerm(str: string): string;
|
||||||
|
styleSubcommandTerm(str: string): string;
|
||||||
|
styleArgumentTerm(str: string): string;
|
||||||
|
|
||||||
|
/** Base style used in terms and usage for options. */
|
||||||
|
styleOptionText(str: string): string;
|
||||||
|
/** Base style used in terms and usage for subcommands. */
|
||||||
|
styleSubcommandText(str: string): string;
|
||||||
|
/** Base style used in terms and usage for arguments. */
|
||||||
|
styleArgumentText(str: string): string;
|
||||||
|
|
||||||
/** Calculate the pad width from the maximum term length. */
|
/** Calculate the pad width from the maximum term length. */
|
||||||
padWidth(cmd: Command, helper: Help): number;
|
padWidth(cmd: Command, helper: Help): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the given string to width characters per line, with lines after the first indented.
|
* Wrap a string at whitespace, preserving existing line breaks.
|
||||||
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
* Wrapping is skipped if the width is less than `minWidthToWrap`.
|
||||||
*/
|
*/
|
||||||
wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;
|
boxWrap(str: string, width: number): string;
|
||||||
|
|
||||||
|
/** Detect manually wrapped and indented strings by checking for line break followed by whitespace. */
|
||||||
|
preformatted(str: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
||||||
|
*
|
||||||
|
* So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
|
||||||
|
* TTT DDD DDDD
|
||||||
|
* DD DDD
|
||||||
|
*/
|
||||||
|
formatItem(
|
||||||
|
term: string,
|
||||||
|
termWidth: number,
|
||||||
|
description: string,
|
||||||
|
helper: Help,
|
||||||
|
): string;
|
||||||
|
|
||||||
/** Generate the built-in help text. */
|
/** Generate the built-in help text. */
|
||||||
formatHelp(cmd: Command, helper: Help): string;
|
formatHelp(cmd: Command, helper: Help): string;
|
||||||
@@ -267,26 +321,34 @@ export type HelpConfiguration = Partial<Help>;
|
|||||||
export interface ParseOptions {
|
export interface ParseOptions {
|
||||||
from: 'node' | 'electron' | 'user';
|
from: 'node' | 'electron' | 'user';
|
||||||
}
|
}
|
||||||
export interface HelpContext { // optional parameter for .help() and .outputHelp()
|
export interface HelpContext {
|
||||||
|
// optional parameter for .help() and .outputHelp()
|
||||||
error: boolean;
|
error: boolean;
|
||||||
}
|
}
|
||||||
export interface AddHelpTextContext { // passed to text function used with .addHelpText()
|
export interface AddHelpTextContext {
|
||||||
|
// passed to text function used with .addHelpText()
|
||||||
error: boolean;
|
error: boolean;
|
||||||
command: Command;
|
command: Command;
|
||||||
}
|
}
|
||||||
export interface OutputConfiguration {
|
export interface OutputConfiguration {
|
||||||
writeOut?(str: string): void;
|
writeOut?(str: string): void;
|
||||||
writeErr?(str: string): void;
|
writeErr?(str: string): void;
|
||||||
getOutHelpWidth?(): number;
|
|
||||||
getErrHelpWidth?(): number;
|
|
||||||
outputError?(str: string, write: (str: string) => void): void;
|
outputError?(str: string, write: (str: string) => void): void;
|
||||||
|
|
||||||
|
getOutHelpWidth?(): number;
|
||||||
|
getErrHelpWidth?(): number;
|
||||||
|
|
||||||
|
getOutHasColors?(): boolean;
|
||||||
|
getErrHasColors?(): boolean;
|
||||||
|
stripColor?(str: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
||||||
export type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
|
export type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
|
||||||
// The source is a string so author can define their own too.
|
// The source is a string so author can define their own too.
|
||||||
export type OptionValueSource = LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string> | undefined;
|
export type OptionValueSource =
|
||||||
|
| LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string>
|
||||||
|
| undefined;
|
||||||
|
|
||||||
export type OptionValues = Record<string, any>;
|
export type OptionValues = Record<string, any>;
|
||||||
|
|
||||||
@@ -334,7 +396,10 @@ export class Command {
|
|||||||
* @param opts - configuration options
|
* @param opts - configuration options
|
||||||
* @returns new command
|
* @returns new command
|
||||||
*/
|
*/
|
||||||
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
|
command(
|
||||||
|
nameAndArgs: string,
|
||||||
|
opts?: CommandOptions,
|
||||||
|
): ReturnType<this['createCommand']>;
|
||||||
/**
|
/**
|
||||||
* Define a command, implemented in a separate executable file.
|
* Define a command, implemented in a separate executable file.
|
||||||
*
|
*
|
||||||
@@ -353,7 +418,11 @@ export class Command {
|
|||||||
* @param opts - configuration options
|
* @param opts - configuration options
|
||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
|
command(
|
||||||
|
nameAndArgs: string,
|
||||||
|
description: string,
|
||||||
|
opts?: ExecutableCommandOptions,
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory routine to create a new unattached command.
|
* Factory routine to create a new unattached command.
|
||||||
@@ -394,7 +463,12 @@ export class Command {
|
|||||||
*
|
*
|
||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
argument<T>(
|
||||||
|
flags: string,
|
||||||
|
description: string,
|
||||||
|
fn: (value: string, previous: T) => T,
|
||||||
|
defaultValue?: T,
|
||||||
|
): this;
|
||||||
argument(name: string, description?: string, defaultValue?: unknown): this;
|
argument(name: string, description?: string, defaultValue?: unknown): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -419,23 +493,38 @@ export class Command {
|
|||||||
arguments(names: string): this;
|
arguments(names: string): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override default decision whether to add implicit help command.
|
* Customise or override default help command. By default a help command is automatically added if your command has subcommands.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* program.helpCommand('help [cmd]');
|
||||||
|
* program.helpCommand('help [cmd]', 'show help');
|
||||||
|
* program.helpCommand(false); // suppress default help command
|
||||||
|
* program.helpCommand(true); // add help command even if no subcommands
|
||||||
* ```
|
* ```
|
||||||
* addHelpCommand() // force on
|
|
||||||
* addHelpCommand(false); // force off
|
|
||||||
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @returns `this` command for chaining
|
|
||||||
*/
|
*/
|
||||||
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
|
helpCommand(nameAndArgs: string, description?: string): this;
|
||||||
|
helpCommand(enable: boolean): this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add prepared custom help command.
|
||||||
|
*/
|
||||||
|
addHelpCommand(cmd: Command): this;
|
||||||
|
/** @deprecated since v12, instead use helpCommand */
|
||||||
|
addHelpCommand(nameAndArgs: string, description?: string): this;
|
||||||
|
/** @deprecated since v12, instead use helpCommand */
|
||||||
|
addHelpCommand(enable?: boolean): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add hook for life cycle event.
|
* Add hook for life cycle event.
|
||||||
*/
|
*/
|
||||||
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
|
hook(
|
||||||
|
event: HookEvent,
|
||||||
|
listener: (
|
||||||
|
thisCommand: Command,
|
||||||
|
actionCommand: Command,
|
||||||
|
) => void | Promise<void>,
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register callback to use as replacement for calling process.exit.
|
* Register callback to use as replacement for calling process.exit.
|
||||||
@@ -513,7 +602,7 @@ export class Command {
|
|||||||
*
|
*
|
||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
action(fn: (...args: any[]) => void | Promise<void>): this;
|
action(fn: (this: this, ...args: any[]) => void | Promise<void>): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
||||||
@@ -528,17 +617,31 @@ export class Command {
|
|||||||
* ```js
|
* ```js
|
||||||
* program
|
* program
|
||||||
* .option('-p, --pepper', 'add pepper')
|
* .option('-p, --pepper', 'add pepper')
|
||||||
* .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
* .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
||||||
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
||||||
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
option(
|
||||||
option<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
flags: string,
|
||||||
|
description?: string,
|
||||||
|
defaultValue?: string | boolean | string[],
|
||||||
|
): this;
|
||||||
|
option<T>(
|
||||||
|
flags: string,
|
||||||
|
description: string,
|
||||||
|
parseArg: (value: string, previous: T) => T,
|
||||||
|
defaultValue?: T,
|
||||||
|
): this;
|
||||||
/** @deprecated since v7, instead use choices or a custom function */
|
/** @deprecated since v7, instead use choices or a custom function */
|
||||||
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
option(
|
||||||
|
flags: string,
|
||||||
|
description: string,
|
||||||
|
regexp: RegExp,
|
||||||
|
defaultValue?: string | boolean | string[],
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a required option, which must have a value after parsing. This usually means
|
* Define a required option, which must have a value after parsing. This usually means
|
||||||
@@ -546,10 +649,24 @@ export class Command {
|
|||||||
*
|
*
|
||||||
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
||||||
*/
|
*/
|
||||||
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
requiredOption(
|
||||||
requiredOption<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
flags: string,
|
||||||
|
description?: string,
|
||||||
|
defaultValue?: string | boolean | string[],
|
||||||
|
): this;
|
||||||
|
requiredOption<T>(
|
||||||
|
flags: string,
|
||||||
|
description: string,
|
||||||
|
parseArg: (value: string, previous: T) => T,
|
||||||
|
defaultValue?: T,
|
||||||
|
): this;
|
||||||
/** @deprecated since v7, instead use choices or a custom function */
|
/** @deprecated since v7, instead use choices or a custom function */
|
||||||
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
requiredOption(
|
||||||
|
flags: string,
|
||||||
|
description: string,
|
||||||
|
regexp: RegExp,
|
||||||
|
defaultValue?: string | boolean | string[],
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory routine to create a new unattached option.
|
* Factory routine to create a new unattached option.
|
||||||
@@ -574,7 +691,9 @@ export class Command {
|
|||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
||||||
storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
|
storeOptionsAsProperties<T extends OptionValues>(
|
||||||
|
storeAsProperties: true,
|
||||||
|
): this & T;
|
||||||
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -590,7 +709,11 @@ export class Command {
|
|||||||
/**
|
/**
|
||||||
* Store option value and where the value came from.
|
* Store option value and where the value came from.
|
||||||
*/
|
*/
|
||||||
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
setOptionValueWithSource(
|
||||||
|
key: string,
|
||||||
|
value: unknown,
|
||||||
|
source: OptionValueSource,
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get source of option value.
|
* Get source of option value.
|
||||||
@@ -598,7 +721,7 @@ export class Command {
|
|||||||
getOptionValueSource(key: string): OptionValueSource | undefined;
|
getOptionValueSource(key: string): OptionValueSource | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get source of option value. See also .optsWithGlobals().
|
* Get source of option value. See also .optsWithGlobals().
|
||||||
*/
|
*/
|
||||||
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
||||||
|
|
||||||
@@ -654,43 +777,72 @@ export class Command {
|
|||||||
/**
|
/**
|
||||||
* Parse `argv`, setting options and invoking commands when defined.
|
* Parse `argv`, setting options and invoking commands when defined.
|
||||||
*
|
*
|
||||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
* Use parseAsync instead of parse if any of your action handlers are async.
|
||||||
* and the script being run in argv[1], with user parameters after that.
|
*
|
||||||
|
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
||||||
|
*
|
||||||
|
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
||||||
|
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
||||||
|
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
||||||
|
* - `'user'`: just user arguments
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```
|
* ```
|
||||||
* program.parse(process.argv);
|
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
||||||
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
||||||
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @returns `this` command for chaining
|
* @returns `this` command for chaining
|
||||||
*/
|
*/
|
||||||
parse(argv?: readonly string[], options?: ParseOptions): this;
|
parse(argv?: readonly string[], parseOptions?: ParseOptions): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse `argv`, setting options and invoking commands when defined.
|
* Parse `argv`, setting options and invoking commands when defined.
|
||||||
*
|
*
|
||||||
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
||||||
*
|
*
|
||||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
||||||
* and the script being run in argv[1], with user parameters after that.
|
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
||||||
|
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
||||||
|
* - `'user'`: just user arguments
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```
|
* ```
|
||||||
* program.parseAsync(process.argv);
|
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
||||||
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
||||||
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
parseAsync(argv?: readonly string[], options?: ParseOptions): Promise<this>;
|
parseAsync(
|
||||||
|
argv?: readonly string[],
|
||||||
|
parseOptions?: ParseOptions,
|
||||||
|
): Promise<this>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
|
||||||
|
* Not usually called directly, but available for subclasses to save their custom state.
|
||||||
|
*
|
||||||
|
* This is called in a lazy way. Only commands used in parsing chain will have state saved.
|
||||||
|
*/
|
||||||
|
saveStateBeforeParse(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore state before parse for calls after the first.
|
||||||
|
* Not usually called directly, but available for subclasses to save their custom state.
|
||||||
|
*
|
||||||
|
* This is called in a lazy way. Only commands used in parsing chain will have state restored.
|
||||||
|
*/
|
||||||
|
restoreStateBeforeParse(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse options from `argv` removing known options,
|
* Parse options from `argv` removing known options,
|
||||||
* and return argv split into operands and unknown arguments.
|
* and return argv split into operands and unknown arguments.
|
||||||
*
|
*
|
||||||
|
* Side effects: modifies command by storing options. Does not reset state if called again.
|
||||||
|
*
|
||||||
* argv => operands, unknown
|
* argv => operands, unknown
|
||||||
* --known kkk op => [op], []
|
* --known kkk op => [op], []
|
||||||
* op --known kkk => [op], []
|
* op --known kkk => [op], []
|
||||||
@@ -838,6 +990,12 @@ export class Command {
|
|||||||
*/
|
*/
|
||||||
helpOption(flags?: string | boolean, description?: string): this;
|
helpOption(flags?: string | boolean, description?: string): this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supply your own option to use for the built-in help option.
|
||||||
|
* This is an alternative to using helpOption() to customise the flags and description etc.
|
||||||
|
*/
|
||||||
|
addHelpOption(option: Option): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output help information and exit.
|
* Output help information and exit.
|
||||||
*
|
*
|
||||||
@@ -854,7 +1012,10 @@ export class Command {
|
|||||||
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
||||||
*/
|
*/
|
||||||
addHelpText(position: AddHelpTextPosition, text: string): this;
|
addHelpText(position: AddHelpTextPosition, text: string): this;
|
||||||
addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
|
addHelpText(
|
||||||
|
position: AddHelpTextPosition,
|
||||||
|
text: (context: AddHelpTextContext) => string,
|
||||||
|
): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
||||||
|
|||||||
19
package-lock.json
generated
19
package-lock.json
generated
@@ -5057,12 +5057,14 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "11.1.0",
|
"version": "13.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz",
|
||||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
"integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/commondir": {
|
"node_modules/commondir": {
|
||||||
@@ -10302,6 +10304,15 @@
|
|||||||
"url": "https://opencollective.com/svgo"
|
"url": "https://opencollective.com/svgo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/svgo/node_modules/commander": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/system-architecture": {
|
"node_modules/system-architecture": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz",
|
||||||
|
|||||||
Reference in New Issue
Block a user