@gunshi/plugin-i18n 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +20 -35
- package/lib/index.js +2 -1
- package/package.json +10 -10
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Args, Awaitable, Command, CommandContext, DefaultGunshiParams, ExtendContext, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, PluginWithExtension, Prettify } from "@gunshi/plugin";
|
|
2
|
-
|
|
3
2
|
//#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/resolver.d.ts
|
|
4
|
-
|
|
5
3
|
//#region src/resolver.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* An argument schema definition for command-line argument parsing.
|
|
@@ -563,7 +561,6 @@ interface Args$1 {
|
|
|
563
561
|
}
|
|
564
562
|
//#endregion
|
|
565
563
|
//#region ../gunshi/src/types.d.ts
|
|
566
|
-
|
|
567
564
|
/**
|
|
568
565
|
* Extend command context type. This type is used to extend the command context with additional properties at {@linkcode CommandContext.extensions}.
|
|
569
566
|
*
|
|
@@ -630,26 +627,20 @@ type CommonArgType = {
|
|
|
630
627
|
declare const COMMON_ARGS: CommonArgType;
|
|
631
628
|
declare const COMMAND_BUILTIN_RESOURCE_KEYS: readonly ["USAGE", "COMMAND", "SUBCOMMAND", "COMMANDS", "ARGUMENTS", "OPTIONS", "EXAMPLES", "FORMORE", "NEGATABLE", "DEFAULT", "CHOICES"];
|
|
632
629
|
declare const ARG_ERROR_RESOURCE_KEYS: readonly ["err:arg:required-option", "err:arg:required-positional", "err:arg:invalid-type", "err:arg:invalid-choice", "err:arg:custom-parse", "err:arg:unknown-option", "err:arg:unexpected-value", "err:arg:missing-value", "err:arg:conflict", "err:arg:invalid-default"];
|
|
630
|
+
declare const ARG_ERROR_HINT_RESOURCE_KEYS: readonly ["err:arg:missing-value:hint"];
|
|
633
631
|
declare const COMMAND_ERROR_RESOURCE_KEYS: readonly ["err:cmd:not-found", "err:cmd:ambiguous", "err:cmd:inconsistent-options", "err:cmd:lazy-schema-mismatch"];
|
|
634
632
|
declare const SUGGESTION_ERROR_RESOURCE_KEYS: readonly ["err:suggestion:did-you-mean"];
|
|
635
|
-
//#endregion
|
|
636
|
-
//#region ../gunshi/src/index.d.ts
|
|
637
|
-
|
|
638
633
|
//#endregion
|
|
639
634
|
//#region ../shared/src/types.d.ts
|
|
640
|
-
type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
|
|
641
|
-
/**
|
|
642
|
-
* Make all properties in T deeply writeable (not readonly)
|
|
643
|
-
*/
|
|
644
|
-
|
|
635
|
+
type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
|
|
645
636
|
/**
|
|
646
637
|
* Remove index signature from object or record type.
|
|
647
638
|
*/
|
|
648
|
-
type RemovedIndex<T> = RemoveIndexSignature<{ [K in keyof T]: T[K] }>;
|
|
639
|
+
type RemovedIndex<T> = RemoveIndexSignature<{ [K in keyof T]: T[K]; }>;
|
|
649
640
|
/**
|
|
650
641
|
* Resolve a key on {@link Args}.
|
|
651
642
|
*/
|
|
652
|
-
type KeyOfArgs<A extends Args$1> = keyof A | { [K in keyof A]: A[K]['type'] extends 'boolean' ? A[K]['negatable'] extends true ? `no-${Extract<K, string>}` : never : never }[keyof A];
|
|
643
|
+
type KeyOfArgs<A extends Args$1> = keyof A | { [K in keyof A]: A[K]['type'] extends 'boolean' ? A[K]['negatable'] extends true ? `no-${Extract<K, string>}` : never : never; }[keyof A];
|
|
653
644
|
/**
|
|
654
645
|
* Generate a namespaced key.
|
|
655
646
|
*/
|
|
@@ -666,6 +657,10 @@ type CommandBuiltinResourceKeys = (typeof COMMAND_BUILTIN_RESOURCE_KEYS)[number]
|
|
|
666
657
|
* Args validation error resource keys.
|
|
667
658
|
*/
|
|
668
659
|
type ArgErrorResourceKeys = (typeof ARG_ERROR_RESOURCE_KEYS)[number];
|
|
660
|
+
/**
|
|
661
|
+
* Resource keys of the hints that follow an args validation error.
|
|
662
|
+
*/
|
|
663
|
+
type ArgErrorHintResourceKeys = (typeof ARG_ERROR_HINT_RESOURCE_KEYS)[number];
|
|
669
664
|
/**
|
|
670
665
|
* Command validation error resource keys.
|
|
671
666
|
*/
|
|
@@ -677,7 +672,7 @@ type SuggestionErrorResourceKeys = (typeof SUGGESTION_ERROR_RESOURCE_KEYS)[numbe
|
|
|
677
672
|
/**
|
|
678
673
|
* Error resource keys.
|
|
679
674
|
*/
|
|
680
|
-
type ErrorResourceKeys = ArgErrorResourceKeys | CommandErrorResourceKeys | SuggestionErrorResourceKeys;
|
|
675
|
+
type ErrorResourceKeys = ArgErrorResourceKeys | ArgErrorHintResourceKeys | CommandErrorResourceKeys | SuggestionErrorResourceKeys;
|
|
681
676
|
/**
|
|
682
677
|
* Built-in resource keys.
|
|
683
678
|
*/
|
|
@@ -700,16 +695,11 @@ type CommandArgKeys<A extends Args$1, C = {}, K extends string = GenerateNamespa
|
|
|
700
695
|
/**
|
|
701
696
|
* Resolve translation keys for command context.
|
|
702
697
|
*/
|
|
703
|
-
type ResolveTranslationKeys<A extends Args$1, C = {}
|
|
704
|
-
// for
|
|
705
|
-
|
|
706
|
-
// for extended resources
|
|
707
|
-
R extends string = keyof RemovedIndex<E>, T extends string = (C extends {
|
|
698
|
+
type ResolveTranslationKeys<A extends Args$1, C = {} // for CommandContext
|
|
699
|
+
, E extends Record<string, string> = {} // for extended resources
|
|
700
|
+
, R extends string = keyof RemovedIndex<E>, T extends string = C extends {
|
|
708
701
|
name: infer N;
|
|
709
|
-
} ? N extends string ? GenerateNamespacedKey<R, N> : R : R | CommandBuiltinKeys
|
|
710
|
-
//#endregion
|
|
711
|
-
//#region ../shared/src/localization.d.ts
|
|
712
|
-
|
|
702
|
+
} ? N extends string ? GenerateNamespacedKey<R, N> : R : R | CommandBuiltinKeys, O = CommandArgKeys<A, C>> = ErrorResourceKeys | CommandBuiltinKeys | O | T;
|
|
713
703
|
//#endregion
|
|
714
704
|
//#region ../shared/src/utils.d.ts
|
|
715
705
|
/**
|
|
@@ -747,10 +737,7 @@ declare function resolveArgKey<A extends Args$1 = DefaultGunshiParams$1['args'],
|
|
|
747
737
|
* @param name - The command name.
|
|
748
738
|
* @returns Prefixed non-built-in key.
|
|
749
739
|
*/
|
|
750
|
-
declare function resolveKey<T extends Record<string, string> = {}, K extends string =
|
|
751
|
-
//#endregion
|
|
752
|
-
//#region ../shared/src/index.d.ts
|
|
753
|
-
|
|
740
|
+
declare function resolveKey<T extends Record<string, string> = {}, K extends string = keyof T extends string ? keyof T : string>(key: K, name?: string): string;
|
|
754
741
|
//#endregion
|
|
755
742
|
//#region src/types.d.ts
|
|
756
743
|
/**
|
|
@@ -785,11 +772,9 @@ interface I18nExtension<G extends GunshiParams<any> = DefaultGunshiParams> {
|
|
|
785
772
|
* - For custom keys: returns an empty string ('')
|
|
786
773
|
* - For built-in keys (prefixed with '_:'): returns the key itself
|
|
787
774
|
*/
|
|
788
|
-
translate: <A extends Args = G['args'], C = {}
|
|
789
|
-
// for
|
|
790
|
-
E
|
|
791
|
-
// for extended resources
|
|
792
|
-
K = ResolveTranslationKeys<A, C, E>>(key: K, values?: Record<string, unknown>) => string;
|
|
775
|
+
translate: <A extends Args = G['args'], C = {} // for CommandContext
|
|
776
|
+
, E extends Record<string, string> = {} // for extended resources
|
|
777
|
+
, K = ResolveTranslationKeys<A, C, E>>(key: K, values?: Record<string, unknown>) => string;
|
|
793
778
|
/**
|
|
794
779
|
* Load command resources.
|
|
795
780
|
*
|
|
@@ -892,7 +877,7 @@ type CommandResource<G extends GunshiParamsConstraint = DefaultGunshiParams> = {
|
|
|
892
877
|
* Command description.
|
|
893
878
|
*/
|
|
894
879
|
description: string;
|
|
895
|
-
} & { [Arg in GenerateNamespacedKey<KeyOfArgs<RemovedIndex<ExtractArgs<G>>>, typeof ARG_PREFIX>]?: string } & {
|
|
880
|
+
} & { [Arg in GenerateNamespacedKey<KeyOfArgs<RemovedIndex<ExtractArgs<G>>>, typeof ARG_PREFIX>]?: string; } & {
|
|
896
881
|
[key: string]: string;
|
|
897
882
|
};
|
|
898
883
|
/**
|
|
@@ -927,7 +912,7 @@ type I18nCommandDefinitionResult<G extends GunshiParamsConstraint = DefaultGunsh
|
|
|
927
912
|
resource: CommandResourceFetcher<G>;
|
|
928
913
|
} : {
|
|
929
914
|
resource?: CommandResourceFetcher<G> | undefined;
|
|
930
|
-
}) & { [K in Exclude<keyof I18nCommand<G>, keyof C | 'resource'>]?: I18nCommand<G>[K] }>;
|
|
915
|
+
}) & { [K in Exclude<keyof I18nCommand<G>, keyof C | 'resource'>]?: I18nCommand<G>[K]; }>;
|
|
931
916
|
/**
|
|
932
917
|
* The result type of the {@linkcode withI18nResource} function
|
|
933
918
|
*
|
|
@@ -935,7 +920,7 @@ type I18nCommandDefinitionResult<G extends GunshiParamsConstraint = DefaultGunsh
|
|
|
935
920
|
*/
|
|
936
921
|
type WithI18nResourceResult<G extends GunshiParamsConstraint = DefaultGunshiParams, C extends Command<G> = Command<G>> = Prettify<C & {
|
|
937
922
|
resource: CommandResourceFetcher<G>;
|
|
938
|
-
} & { [K in Exclude<keyof I18nCommand<G>, keyof C | 'resource'>]?: I18nCommand<G>[K] }>;
|
|
923
|
+
} & { [K in Exclude<keyof I18nCommand<G>, keyof C | 'resource'>]?: I18nCommand<G>[K]; }>;
|
|
939
924
|
/**
|
|
940
925
|
* Define an i18n-aware {@link I18nCommand | command}.
|
|
941
926
|
*
|
package/lib/index.js
CHANGED
|
@@ -34,13 +34,14 @@ var en_US_default = {
|
|
|
34
34
|
help: "Display this help message",
|
|
35
35
|
version: "Display this version",
|
|
36
36
|
"err:arg:required-option": "Optional argument {$displayName} is required",
|
|
37
|
-
"err:arg:required-positional": "Positional argument {$
|
|
37
|
+
"err:arg:required-positional": "Positional argument {$displayName} is required",
|
|
38
38
|
"err:arg:invalid-type": "Invalid value for {$displayName}: expected {$expected}",
|
|
39
39
|
"err:arg:invalid-choice": "Invalid value for {$displayName}: expected one of {$choices}",
|
|
40
40
|
"err:arg:custom-parse": "Invalid value for {$displayName}: {$reason}",
|
|
41
41
|
"err:arg:unknown-option": "Unknown option: {$rawName}",
|
|
42
42
|
"err:arg:unexpected-value": "Optional argument {$displayName} does not take a value",
|
|
43
43
|
"err:arg:missing-value": "Optional argument {$displayName} requires a value",
|
|
44
|
+
"err:arg:missing-value:hint": "(to pass '{$next}' as its value, write '{$suggestion}')",
|
|
44
45
|
"err:arg:conflict": "{$displayName} conflicts with {$conflictDisplayName}",
|
|
45
46
|
"err:arg:invalid-default": "Invalid default for {$displayName}: {$actual} is not one of {$choices}",
|
|
46
47
|
"err:cmd:not-found": "Command not found: {$commandName}",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/plugin-i18n",
|
|
3
3
|
"description": "internationalization plugin for gunshi",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.2",
|
|
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": "1.0.0-beta.
|
|
56
|
+
"@gunshi/plugin": "1.0.0-beta.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@gunshi/plugin-global": "1.0.0-beta.
|
|
59
|
+
"@gunshi/plugin-global": "1.0.0-beta.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"@gunshi/plugin-global": {
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
+
"@gunshi/bone": "1.0.0-beta.2",
|
|
68
|
+
"@gunshi/plugin-global": "1.0.0-beta.2",
|
|
69
|
+
"@gunshi/plugin-renderer": "1.0.0-beta.2",
|
|
70
|
+
"@gunshi/resources": "1.0.0-beta.2",
|
|
71
|
+
"@gunshi/shared": "1.0.0-beta.2",
|
|
67
72
|
"@intlify/core-base": "12.0.0-alpha.4",
|
|
68
73
|
"deno": "^2.7.14",
|
|
74
|
+
"gunshi": "1.0.0-beta.2",
|
|
69
75
|
"jsr": "^0.14.3",
|
|
70
76
|
"jsr-exports-lint": "^0.4.2",
|
|
71
77
|
"messageformat": "4.0.0",
|
|
72
78
|
"publint": "^0.3.20",
|
|
73
|
-
"tsdown": "0.
|
|
74
|
-
"@gunshi/bone": "1.0.0-beta.0",
|
|
75
|
-
"@gunshi/plugin-global": "1.0.0-beta.0",
|
|
76
|
-
"@gunshi/plugin-renderer": "1.0.0-beta.0",
|
|
77
|
-
"@gunshi/shared": "1.0.0-beta.0",
|
|
78
|
-
"@gunshi/resources": "1.0.0-beta.0",
|
|
79
|
-
"gunshi": "1.0.0-beta.0"
|
|
79
|
+
"tsdown": "0.22.14"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsdown",
|