@gunshi/plugin-renderer 0.27.5 → 0.27.6
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/lib/index.d.ts +3 -3
- package/lib/index.js +7 -7
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -67,9 +67,9 @@ type CommandBuiltinKeys = GenerateNamespacedKey<BuiltinResourceKeys>;
|
|
|
67
67
|
* Command i18n option keys.
|
|
68
68
|
* The command i18n option keys are used by the i18n plugin for translation.
|
|
69
69
|
*/
|
|
70
|
-
type CommandArgKeys<A extends Args$1, C = {}, K
|
|
70
|
+
type CommandArgKeys<A extends Args$1, C = {}, K extends string = GenerateNamespacedKey<Extract<KeyOfArgs<RemovedIndex<A>>, string>, typeof ARG_PREFIX>> = C extends {
|
|
71
71
|
name: infer N;
|
|
72
|
-
} ? (N extends string ? GenerateNamespacedKey<K
|
|
72
|
+
} ? (N extends string ? GenerateNamespacedKey<K, N> : K) : K;
|
|
73
73
|
/**
|
|
74
74
|
* Resolve translation keys for command context.
|
|
75
75
|
*/
|
|
@@ -112,7 +112,7 @@ interface UsageRendererExtension<G extends GunshiParams<any> = DefaultGunshiPara
|
|
|
112
112
|
// for CommandContext
|
|
113
113
|
E extends Record<string, string> = {},
|
|
114
114
|
// for extended resources
|
|
115
|
-
K
|
|
115
|
+
K = ResolveTranslationKeys<A, C, E>>(key: K, values?: Record<string, unknown>) => Promise<string>;
|
|
116
116
|
/**
|
|
117
117
|
* Load commands
|
|
118
118
|
*
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ANONYMOUS_COMMAND_NAME, plugin } from "@gunshi/plugin";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.23.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.23.1/node_modules/args-tokens/lib/utils-CxvkckUD.js
|
|
4
4
|
/**
|
|
5
5
|
* Entry point of utils.
|
|
6
6
|
*
|
|
@@ -201,7 +201,7 @@ function resolveKey(key, name) {
|
|
|
201
201
|
* @param examples - The examples to resolve, which can be a string or a {@linkcode CommandExamplesFetcher | function} that returns a string.
|
|
202
202
|
* @returns A resolved string of examples.
|
|
203
203
|
*/
|
|
204
|
-
async function resolveExamples(ctx, examples) {
|
|
204
|
+
async function resolveExamples$1(ctx, examples) {
|
|
205
205
|
return typeof examples === "string" ? examples : typeof examples === "function" ? await examples(ctx) : "";
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
@@ -266,7 +266,7 @@ function localizable(ctx, cmd, translate) {
|
|
|
266
266
|
return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
267
267
|
}
|
|
268
268
|
if (key === resolveKey("description", ctx.name)) return "";
|
|
269
|
-
else if (key === resolveKey("examples", ctx.name)) return await resolveExamples(ctx, cmd.examples);
|
|
269
|
+
else if (key === resolveKey("examples", ctx.name)) return await resolveExamples$1(ctx, cmd.examples);
|
|
270
270
|
else return key;
|
|
271
271
|
}
|
|
272
272
|
return localize;
|
|
@@ -355,7 +355,7 @@ async function renderOptionalArgsSection(ctx) {
|
|
|
355
355
|
*/
|
|
356
356
|
async function renderExamplesSection(ctx) {
|
|
357
357
|
const messages = [];
|
|
358
|
-
const resolvedExamples = await resolveExamples
|
|
358
|
+
const resolvedExamples = await resolveExamples(ctx);
|
|
359
359
|
if (resolvedExamples) {
|
|
360
360
|
const examples = resolvedExamples.split("\n").map((example) => example.padStart(ctx.env.leftMargin + example.length));
|
|
361
361
|
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("EXAMPLES"))}:`, ...examples);
|
|
@@ -460,11 +460,11 @@ async function resolveDescription(ctx) {
|
|
|
460
460
|
* @param ctx - A {@link CommandContext | command context}
|
|
461
461
|
* @returns resolved command examples, if not resolved, return empty string
|
|
462
462
|
*/
|
|
463
|
-
async function resolveExamples
|
|
463
|
+
async function resolveExamples(ctx) {
|
|
464
464
|
const ret = await ctx.extensions[pluginId].text(resolveKey("examples", ctx.name));
|
|
465
465
|
if (ret) return ret;
|
|
466
466
|
const command = ctx.env.subCommands?.get(ctx.name || "");
|
|
467
|
-
return await resolveExamples(ctx, command?.examples);
|
|
467
|
+
return await resolveExamples$1(ctx, command?.examples);
|
|
468
468
|
}
|
|
469
469
|
/**
|
|
470
470
|
* Check if the command has sub commands
|
|
@@ -666,7 +666,7 @@ function renderer() {
|
|
|
666
666
|
async function loadCommands() {
|
|
667
667
|
if (cachedCommands) return cachedCommands;
|
|
668
668
|
const subCommands = [...ctx.env.subCommands || []];
|
|
669
|
-
cachedCommands = (await Promise.all(subCommands.map(async ([name, cmd
|
|
669
|
+
cachedCommands = (await Promise.all(subCommands.map(async ([name, cmd]) => await resolveLazyCommand(cmd, name)))).filter((cmd) => !cmd.internal).filter(Boolean);
|
|
670
670
|
cachedCommands.sort((a, b) => {
|
|
671
671
|
if (a.entry && !b.entry) return -1;
|
|
672
672
|
if (!a.entry && b.entry) return 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/plugin-renderer",
|
|
3
3
|
"description": "usage renderer plugin for gunshi",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.6",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@gunshi/plugin": "0.27.
|
|
56
|
+
"@gunshi/plugin": "0.27.6"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@gunshi/plugin-i18n": "0.27.
|
|
59
|
+
"@gunshi/plugin-i18n": "0.27.6"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"deno": "^2.6.3",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"tsdown": "0.15.12",
|
|
67
67
|
"typedoc": "^0.28.15",
|
|
68
68
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
69
|
-
"@gunshi/shared": "0.27.
|
|
69
|
+
"@gunshi/shared": "0.27.6"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsdown",
|