@gunshi/shared 0.29.2 → 0.29.4
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 +10 -16
- package/package.json +7 -7
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.24.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.24.3/node_modules/args-tokens/lib/parser-D95CJBHr.d.ts
|
|
2
2
|
//#region src/parser.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of argument parser.
|
|
@@ -55,7 +55,7 @@ interface ArgToken {
|
|
|
55
55
|
* Parser Options.
|
|
56
56
|
*/
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.24.
|
|
58
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.24.3/node_modules/args-tokens/lib/resolver.d.ts
|
|
59
59
|
//#region src/resolver.d.ts
|
|
60
60
|
/**
|
|
61
61
|
* An argument schema definition for command-line argument parsing.
|
|
@@ -1084,7 +1084,7 @@ type CommandExamplesFetcher<G extends GunshiParamsConstraint = DefaultGunshiPara
|
|
|
1084
1084
|
*/
|
|
1085
1085
|
type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void>;
|
|
1086
1086
|
//#endregion
|
|
1087
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.24.
|
|
1087
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.24.3/node_modules/args-tokens/lib/utils.d.ts
|
|
1088
1088
|
//#region src/utils.d.ts
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Entry point of utils.
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.24.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.24.3/node_modules/args-tokens/lib/utils.js
|
|
2
2
|
/**
|
|
3
3
|
* Entry point of utils.
|
|
4
4
|
*
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
function kebabnize(str) {
|
|
20
20
|
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
//#endregion
|
|
24
23
|
//#region ../gunshi/src/utils.ts
|
|
25
24
|
/**
|
|
@@ -124,7 +123,6 @@ function deepFreeze(obj, ignores = []) {
|
|
|
124
123
|
}
|
|
125
124
|
return Object.freeze(obj);
|
|
126
125
|
}
|
|
127
|
-
|
|
128
126
|
//#endregion
|
|
129
127
|
//#region src/constants.ts
|
|
130
128
|
/**
|
|
@@ -135,8 +133,8 @@ const BUILT_IN_PREFIX = "_";
|
|
|
135
133
|
const PLUGIN_PREFIX = "g";
|
|
136
134
|
const ARG_PREFIX = "arg";
|
|
137
135
|
const BUILT_IN_KEY_SEPARATOR = ":";
|
|
138
|
-
const BUILD_IN_PREFIX_AND_KEY_SEPARATOR =
|
|
139
|
-
const ARG_PREFIX_AND_KEY_SEPARATOR =
|
|
136
|
+
const BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `_:`;
|
|
137
|
+
const ARG_PREFIX_AND_KEY_SEPARATOR = `arg:`;
|
|
140
138
|
const ARG_NEGATABLE_PREFIX = "no-";
|
|
141
139
|
const COMMON_ARGS = {
|
|
142
140
|
help: {
|
|
@@ -163,7 +161,6 @@ const COMMAND_BUILTIN_RESOURCE_KEYS = [
|
|
|
163
161
|
"DEFAULT",
|
|
164
162
|
"CHOICES"
|
|
165
163
|
];
|
|
166
|
-
|
|
167
164
|
//#endregion
|
|
168
165
|
//#region ../resources/locales/en-US.json
|
|
169
166
|
var NEGATABLE = "Negatable of";
|
|
@@ -182,7 +179,6 @@ var en_US_default = {
|
|
|
182
179
|
help: "Display this help message",
|
|
183
180
|
version: "Display this version"
|
|
184
181
|
};
|
|
185
|
-
|
|
186
182
|
//#endregion
|
|
187
183
|
//#region src/utils.ts
|
|
188
184
|
/**
|
|
@@ -200,7 +196,7 @@ var en_US_default = {
|
|
|
200
196
|
* @returns Prefixed built-in key.
|
|
201
197
|
*/
|
|
202
198
|
function resolveBuiltInKey(key) {
|
|
203
|
-
return
|
|
199
|
+
return `_:${key}`;
|
|
204
200
|
}
|
|
205
201
|
/**
|
|
206
202
|
* Resolve a namespaced key for argument resources.
|
|
@@ -215,7 +211,7 @@ function resolveBuiltInKey(key) {
|
|
|
215
211
|
* @returns Prefixed argument key.
|
|
216
212
|
*/
|
|
217
213
|
function resolveArgKey(key, name) {
|
|
218
|
-
return `${name ? `${name}
|
|
214
|
+
return `${name ? `${name}:` : ""}arg:${key}`;
|
|
219
215
|
}
|
|
220
216
|
/**
|
|
221
217
|
* Resolve a namespaced key for non-built-in resources.
|
|
@@ -229,7 +225,7 @@ function resolveArgKey(key, name) {
|
|
|
229
225
|
* @returns Prefixed non-built-in key.
|
|
230
226
|
*/
|
|
231
227
|
function resolveKey(key, name) {
|
|
232
|
-
return `${name ? `${name}
|
|
228
|
+
return `${name ? `${name}:` : ""}${key}`;
|
|
233
229
|
}
|
|
234
230
|
/**
|
|
235
231
|
* Resolve command examples.
|
|
@@ -252,7 +248,7 @@ async function resolveExamples(ctx, examples) {
|
|
|
252
248
|
* @returns A namespaced key for the plugin.
|
|
253
249
|
*/
|
|
254
250
|
function namespacedId(id) {
|
|
255
|
-
return
|
|
251
|
+
return `g:${id}`;
|
|
256
252
|
}
|
|
257
253
|
/**
|
|
258
254
|
* Generate a short and long option pair for command arguments.
|
|
@@ -267,7 +263,6 @@ function makeShortLongOptionPair(schema, name, toKebab) {
|
|
|
267
263
|
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
268
264
|
return key;
|
|
269
265
|
}
|
|
270
|
-
|
|
271
266
|
//#endregion
|
|
272
267
|
//#region src/localization.ts
|
|
273
268
|
/**
|
|
@@ -296,8 +291,8 @@ function localizable(ctx, cmd, translate) {
|
|
|
296
291
|
if (key.startsWith(namaspacedArgKey)) {
|
|
297
292
|
let argKey = key.slice(namaspacedArgKey.length);
|
|
298
293
|
let negatable = false;
|
|
299
|
-
if (argKey.startsWith(
|
|
300
|
-
argKey = argKey.slice(
|
|
294
|
+
if (argKey.startsWith("no-")) {
|
|
295
|
+
argKey = argKey.slice(3);
|
|
301
296
|
negatable = true;
|
|
302
297
|
}
|
|
303
298
|
const schema = ctx.args[argKey];
|
|
@@ -310,6 +305,5 @@ function localizable(ctx, cmd, translate) {
|
|
|
310
305
|
}
|
|
311
306
|
return localize;
|
|
312
307
|
}
|
|
313
|
-
|
|
314
308
|
//#endregion
|
|
315
|
-
export { ARG_NEGATABLE_PREFIX, ARG_PREFIX, ARG_PREFIX_AND_KEY_SEPARATOR, BUILD_IN_PREFIX_AND_KEY_SEPARATOR, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMON_ARGS, en_US_default as DefaultResource, PLUGIN_PREFIX, create, deepFreeze, getCommandSubCommands, isLazyCommand, kebabnize, localizable, log, makeShortLongOptionPair, namespacedId, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveKey, resolveLazyCommand };
|
|
309
|
+
export { ARG_NEGATABLE_PREFIX, ARG_PREFIX, ARG_PREFIX_AND_KEY_SEPARATOR, BUILD_IN_PREFIX_AND_KEY_SEPARATOR, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMON_ARGS, en_US_default as DefaultResource, PLUGIN_PREFIX, create, deepFreeze, getCommandSubCommands, isLazyCommand, kebabnize, localizable, log, makeShortLongOptionPair, namespacedId, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveKey, resolveLazyCommand };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/shared",
|
|
3
3
|
"description": "shared utils for gunshi",
|
|
4
|
-
"version": "0.29.
|
|
4
|
+
"version": "0.29.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"deno": "^2.
|
|
54
|
-
"jsr": "^0.
|
|
55
|
-
"jsr-exports-lint": "^0.4.
|
|
56
|
-
"publint": "^0.3.
|
|
53
|
+
"deno": "^2.7.11",
|
|
54
|
+
"jsr": "^0.14.3",
|
|
55
|
+
"jsr-exports-lint": "^0.4.2",
|
|
56
|
+
"publint": "^0.3.18",
|
|
57
57
|
"tsdown": "0.15.12",
|
|
58
|
-
"
|
|
59
|
-
"gunshi": "0.29.
|
|
58
|
+
"gunshi": "0.29.4",
|
|
59
|
+
"@gunshi/resources": "0.29.4"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|