@ariestools/cli-kit-yargs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +25 -0
- package/dist/node/environmentToYargsConfig.d.ts +8 -0
- package/dist/node/environmentToYargsConfig.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +96 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/node/runYargsApplication.d.ts +14 -0
- package/dist/node/runYargsApplication.d.ts.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @ariestools/cli-kit-yargs
|
|
2
|
+
|
|
3
|
+
Yargs adapter for reusable actor command-line applications.
|
|
4
|
+
|
|
5
|
+
The package keeps Yargs out of `@ariestools/cli-kit` while routing parser help, version, validation errors, asynchronous failures, and exits through the core `ProcessHost` boundary. This makes a configured CLI safe to exercise with a recording host instead of allowing Yargs to write to the ambient console or terminate the test process.
|
|
6
|
+
|
|
7
|
+
Use `environmentToYargsConfig` when an application owns config-file loading and wants to replace Yargs' process-global `.env()` lookup with an explicitly supplied environment. The resulting flat dotted object preserves Yargs' environment key normalization and can be passed to `.config()` before parsing:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
await runYargsApplication({
|
|
11
|
+
host,
|
|
12
|
+
configure: parser => parser
|
|
13
|
+
.config(environmentToYargsConfig(host.environment, 'XL1'))
|
|
14
|
+
.scriptName('xl1')
|
|
15
|
+
.command(commands)
|
|
16
|
+
.help()
|
|
17
|
+
.version(version),
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This conversion preserves command-line-over-environment precedence, but it is not a general substitute for `.env()` in applications that also use Yargs-native config-file options: Yargs ranks config objects below config files, and treats a top-level `extends` key in a config object specially. Such applications should resolve those precedence and reserved-key rules before passing the object to `.config()`.
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
LGPL-3.0-only
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CliEnvironment = Readonly<Record<string, string | undefined>>;
|
|
2
|
+
/**
|
|
3
|
+
* Converts a prefixed environment into the flat dotted config shape accepted
|
|
4
|
+
* by Yargs. Values remain strings so Yargs applies its normal option typing and
|
|
5
|
+
* coercion after command-line arguments have taken precedence.
|
|
6
|
+
*/
|
|
7
|
+
export declare function environmentToYargsConfig(environment: CliEnvironment, prefix: string): Record<string, string | undefined>;
|
|
8
|
+
//# sourceMappingURL=environmentToYargsConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environmentToYargsConfig.d.ts","sourceRoot":"","sources":["../../src/environmentToYargsConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;AA8BzE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAWpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/environmentToYargsConfig.ts
|
|
2
|
+
function camelCaseEnvironmentSegment(value) {
|
|
3
|
+
const isCamelCase = value !== value.toLowerCase() && value !== value.toUpperCase();
|
|
4
|
+
const normalized = isCamelCase ? value : value.toLowerCase();
|
|
5
|
+
if (!normalized.includes("-") && !normalized.includes("_")) return normalized;
|
|
6
|
+
let result = "";
|
|
7
|
+
let isNextCharacterUpper = false;
|
|
8
|
+
const leadingHyphens = /^-+/.exec(normalized);
|
|
9
|
+
const start = leadingHyphens?.[0].length ?? 0;
|
|
10
|
+
for (let index = start; index < normalized.length; index++) {
|
|
11
|
+
let character = normalized.charAt(index);
|
|
12
|
+
if (isNextCharacterUpper) {
|
|
13
|
+
isNextCharacterUpper = false;
|
|
14
|
+
character = character.toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
if (index !== 0 && (character === "-" || character === "_")) {
|
|
17
|
+
isNextCharacterUpper = true;
|
|
18
|
+
} else if (character !== "-" && character !== "_") {
|
|
19
|
+
result += character;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
function environmentToYargsConfig(environment, prefix) {
|
|
25
|
+
const config = {};
|
|
26
|
+
for (const [environmentName, environmentValue] of Object.entries(environment)) {
|
|
27
|
+
if (!environmentName.startsWith(prefix)) continue;
|
|
28
|
+
const keys = environmentName.split("__").map((key, index) => {
|
|
29
|
+
return camelCaseEnvironmentSegment(index === 0 ? key.slice(prefix.length) : key);
|
|
30
|
+
});
|
|
31
|
+
const configKey = keys.join(".");
|
|
32
|
+
if (!Object.hasOwn(config, configKey)) config[configKey] = environmentValue;
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/runYargsApplication.ts
|
|
38
|
+
import {
|
|
39
|
+
exitProcess,
|
|
40
|
+
ProcessExitError
|
|
41
|
+
} from "@ariestools/cli-kit";
|
|
42
|
+
import yargs from "yargs";
|
|
43
|
+
import { hideBin } from "yargs/helpers";
|
|
44
|
+
async function invokeFailureHandler(handler, error) {
|
|
45
|
+
try {
|
|
46
|
+
await handler?.(error);
|
|
47
|
+
return { hasError: false };
|
|
48
|
+
} catch (failureHandlerError) {
|
|
49
|
+
return { error: failureHandlerError, hasError: true };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function reportFailureHandlerError(host, result) {
|
|
53
|
+
if (result.hasError) host.io.error("Error handling application failure:", result.error);
|
|
54
|
+
}
|
|
55
|
+
async function runYargsApplication({
|
|
56
|
+
configure,
|
|
57
|
+
host,
|
|
58
|
+
onFailure
|
|
59
|
+
}) {
|
|
60
|
+
const applicationArguments = hideBin([...host.argv]);
|
|
61
|
+
const parser = configure(yargs(applicationArguments));
|
|
62
|
+
const captured = { error: void 0, output: "" };
|
|
63
|
+
try {
|
|
64
|
+
await parser.parseAsync(applicationArguments, {}, (error, _argv, output) => {
|
|
65
|
+
captured.error = error ?? void 0;
|
|
66
|
+
captured.output = output;
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof ProcessExitError) throw error;
|
|
70
|
+
const failureHandlerResult = await invokeFailureHandler(onFailure, error);
|
|
71
|
+
host.io.error(await parser.getHelp());
|
|
72
|
+
host.io.error();
|
|
73
|
+
host.io.error(error);
|
|
74
|
+
reportFailureHandlerError(host, failureHandlerResult);
|
|
75
|
+
exitProcess(host, 1);
|
|
76
|
+
}
|
|
77
|
+
if (captured.error !== void 0) {
|
|
78
|
+
const failureHandlerResult = await invokeFailureHandler(onFailure, captured.error);
|
|
79
|
+
if (captured.output.length > 0) {
|
|
80
|
+
host.io.error(captured.output);
|
|
81
|
+
} else {
|
|
82
|
+
host.io.error(captured.error);
|
|
83
|
+
}
|
|
84
|
+
reportFailureHandlerError(host, failureHandlerResult);
|
|
85
|
+
exitProcess(host, 1);
|
|
86
|
+
}
|
|
87
|
+
if (captured.output.length > 0) {
|
|
88
|
+
host.io.log(captured.output);
|
|
89
|
+
exitProcess(host, 0);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
environmentToYargsConfig,
|
|
94
|
+
runYargsApplication
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/environmentToYargsConfig.ts", "../../src/runYargsApplication.ts"],
|
|
4
|
+
"sourcesContent": ["export type CliEnvironment = Readonly<Record<string, string | undefined>>\n\n/**\n * Matches the segment normalization used by yargs-parser for environment keys.\n * Keeping this local avoids coupling the adapter to an unexported parser helper.\n */\nfunction camelCaseEnvironmentSegment(value: string): string {\n const isCamelCase = value !== value.toLowerCase() && value !== value.toUpperCase()\n const normalized = isCamelCase ? value : value.toLowerCase()\n if (!normalized.includes('-') && !normalized.includes('_')) return normalized\n\n let result = ''\n let isNextCharacterUpper = false\n const leadingHyphens = /^-+/.exec(normalized)\n const start = leadingHyphens?.[0].length ?? 0\n for (let index = start; index < normalized.length; index++) {\n let character = normalized.charAt(index)\n if (isNextCharacterUpper) {\n isNextCharacterUpper = false\n character = character.toUpperCase()\n }\n if (index !== 0 && (character === '-' || character === '_')) {\n isNextCharacterUpper = true\n } else if (character !== '-' && character !== '_') {\n result += character\n }\n }\n return result\n}\n\n/**\n * Converts a prefixed environment into the flat dotted config shape accepted\n * by Yargs. Values remain strings so Yargs applies its normal option typing and\n * coercion after command-line arguments have taken precedence.\n */\nexport function environmentToYargsConfig(\n environment: CliEnvironment,\n prefix: string,\n): Record<string, string | undefined> {\n const config: Record<string, string | undefined> = {}\n for (const [environmentName, environmentValue] of Object.entries(environment)) {\n if (!environmentName.startsWith(prefix)) continue\n const keys = environmentName.split('__').map((key, index) => {\n return camelCaseEnvironmentSegment(index === 0 ? key.slice(prefix.length) : key)\n })\n const configKey = keys.join('.')\n if (!Object.hasOwn(config, configKey)) config[configKey] = environmentValue\n }\n return config\n}\n", "import {\n exitProcess, ProcessExitError, type ProcessHost,\n} from '@ariestools/cli-kit'\nimport type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\nexport interface RunYargsApplicationOptions {\n readonly configure: (parser: Argv) => Argv\n readonly host: ProcessHost\n readonly onFailure?: (error: unknown) => Promise<void> | void\n}\n\ninterface CapturedParseOutput {\n error: Error | undefined\n output: string\n}\n\ninterface FailureHandlerResult {\n readonly error?: unknown\n readonly hasError: boolean\n}\n\nasync function invokeFailureHandler(\n handler: RunYargsApplicationOptions['onFailure'],\n error: unknown,\n): Promise<FailureHandlerResult> {\n try {\n await handler?.(error)\n return { hasError: false }\n } catch (failureHandlerError) {\n return { error: failureHandlerError, hasError: true }\n }\n}\n\nfunction reportFailureHandlerError(host: ProcessHost, result: FailureHandlerResult): void {\n if (result.hasError) host.io.error('Error handling application failure:', result.error)\n}\n\n/**\n * Runs a configured Yargs app through the supplied process boundary.\n * Yargs' parse callback prevents its default console and process.exit calls;\n * the adapter then routes the equivalent output and exit through ProcessHost.\n */\nexport async function runYargsApplication({\n configure,\n host,\n onFailure,\n}: RunYargsApplicationOptions): Promise<void> {\n const applicationArguments = hideBin([...host.argv])\n const parser = configure(yargs(applicationArguments))\n const captured: CapturedParseOutput = { error: undefined, output: '' }\n\n try {\n await parser.parseAsync(applicationArguments, {}, (error, _argv, output) => {\n // Yargs 18 reports `null` on success at runtime despite @types/yargs\n // declaring this callback value as `Error | undefined`.\n captured.error = error ?? undefined\n captured.output = output\n })\n } catch (error) {\n if (error instanceof ProcessExitError) throw error\n const failureHandlerResult = await invokeFailureHandler(onFailure, error)\n host.io.error(await parser.getHelp())\n host.io.error()\n host.io.error(error)\n reportFailureHandlerError(host, failureHandlerResult)\n exitProcess(host, 1)\n }\n\n if (captured.error !== undefined) {\n const failureHandlerResult = await invokeFailureHandler(onFailure, captured.error)\n if (captured.output.length > 0) {\n host.io.error(captured.output)\n } else {\n host.io.error(captured.error)\n }\n reportFailureHandlerError(host, failureHandlerResult)\n exitProcess(host, 1)\n }\n\n if (captured.output.length > 0) {\n host.io.log(captured.output)\n exitProcess(host, 0)\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ProcessHost } from '@ariestools/cli-kit';
|
|
2
|
+
import type { Argv } from 'yargs';
|
|
3
|
+
export interface RunYargsApplicationOptions {
|
|
4
|
+
readonly configure: (parser: Argv) => Argv;
|
|
5
|
+
readonly host: ProcessHost;
|
|
6
|
+
readonly onFailure?: (error: unknown) => Promise<void> | void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Runs a configured Yargs app through the supplied process boundary.
|
|
10
|
+
* Yargs' parse callback prevents its default console and process.exit calls;
|
|
11
|
+
* the adapter then routes the equivalent output and exit through ProcessHost.
|
|
12
|
+
*/
|
|
13
|
+
export declare function runYargsApplication({ configure, host, onFailure, }: RunYargsApplicationOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=runYargsApplication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runYargsApplication.d.ts","sourceRoot":"","sources":["../../src/runYargsApplication.ts"],"names":[],"mappings":"AAAA,OAAO,EAC0B,KAAK,WAAW,EAChD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAC9D;AA4BD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,SAAS,EACT,IAAI,EACJ,SAAS,GACV,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC5C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariestools/cli-kit-yargs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Yargs adapter for reusable actor command-line applications",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ariestools",
|
|
7
|
+
"cli",
|
|
8
|
+
"yargs",
|
|
9
|
+
"typescript",
|
|
10
|
+
"esm"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://ariestools.ai",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ariestools/cli-kit/issues",
|
|
15
|
+
"email": "support@ariestools.ai"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ariestools/cli-kit.git",
|
|
20
|
+
"directory": "packages/cli-kit-yargs"
|
|
21
|
+
},
|
|
22
|
+
"license": "LGPL-3.0-only",
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Arie Trouw",
|
|
25
|
+
"email": "support@ariestools.ai",
|
|
26
|
+
"url": "https://ariestools.ai"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/node/index.d.ts",
|
|
33
|
+
"default": "./dist/node/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
"./README.md": "./README.md"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"!**/*.bench.*",
|
|
41
|
+
"!**/*.spec.*",
|
|
42
|
+
"!**/*.test.*",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@types/yargs": "~17.0.35",
|
|
48
|
+
"yargs": "~18.0.0",
|
|
49
|
+
"@ariestools/cli-kit": "~1.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@ariestools/toolchain": "~8.7.21",
|
|
53
|
+
"@ariestools/tsconfig": "~8.7.21",
|
|
54
|
+
"eslint": "~10.7.0",
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"vite": "~8.1.5",
|
|
57
|
+
"vitest": "~4.1.10",
|
|
58
|
+
"eslint-import-resolver-typescript": "~4.4.5"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=24"
|
|
62
|
+
},
|
|
63
|
+
"engineStrict": true,
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:ci": "vitest run"
|
|
70
|
+
}
|
|
71
|
+
}
|