gunshi 0.25.0 → 0.26.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.
@@ -1,6 +1,6 @@
1
- import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-B_QNzw5q.js";
2
- import { createCommandContext } from "./context-DT5PgSdv.js";
3
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-CTx2DsBI.js";
1
+ import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-D41C8Abf.js";
2
+ import { createCommandContext } from "./context-D_EmfRNA.js";
3
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BzRfaLdJ.js";
4
4
  import { parseArgs, resolveArgs } from "args-tokens";
5
5
 
6
6
  //#region src/cli.ts
@@ -1,4 +1,4 @@
1
- import { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-B_QNzw5q.js";
1
+ import { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-D41C8Abf.js";
2
2
 
3
3
  //#region src/locales/en-US.json
4
4
  var COMMAND = "COMMAND";
package/lib/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-B7j6WSjQ.js";
1
+ import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-DtEE4hKC.js";
2
2
  import { ArgToken, ArgValues, Args } from "args-tokens";
3
3
 
4
4
  //#region src/context.d.ts
package/lib/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-B_QNzw5q.js";
2
- import { createCommandContext } from "./context-DT5PgSdv.js";
1
+ import "./utils-D41C8Abf.js";
2
+ import { createCommandContext } from "./context-D_EmfRNA.js";
3
3
 
4
4
  export { createCommandContext };
@@ -1,4 +1,4 @@
1
- import { Command, CommandLoader, LazyCommand } from "./types-B7j6WSjQ.js";
1
+ import { Command, CommandLoader, LazyCommand } from "./types-DtEE4hKC.js";
2
2
  import { ArgSchema, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
3
3
 
4
4
  //#region src/definition.d.ts
@@ -1,3 +1,3 @@
1
- import "./types-B7j6WSjQ.js";
2
- import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-C3eTsvXE.js";
1
+ import "./types-DtEE4hKC.js";
2
+ import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-CKKX4Yvy.js";
3
3
  export { ArgSchema, ArgValues, Args, define, lazy };
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, LazyCommand } from "./types-B7j6WSjQ.js";
1
+ import { CliOptions, Command, LazyCommand } from "./types-DtEE4hKC.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/generator.d.ts
package/lib/generator.js CHANGED
@@ -1,7 +1,7 @@
1
- import { create } from "./utils-B_QNzw5q.js";
2
- import "./context-DT5PgSdv.js";
3
- import "./renderer-CTx2DsBI.js";
4
- import { cli } from "./cli-BtS9kKar.js";
1
+ import { create } from "./utils-D41C8Abf.js";
2
+ import "./context-D_EmfRNA.js";
3
+ import "./renderer-BzRfaLdJ.js";
4
+ import { cli } from "./cli-DVGNVw3h.js";
5
5
 
6
6
  //#region src/generator.ts
7
7
  /**
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-B7j6WSjQ.js";
2
- import { define$1 as define, lazy$1 as lazy } from "./definition-C3eTsvXE.js";
1
+ import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-DtEE4hKC.js";
2
+ import { define$1 as define, lazy$1 as lazy } from "./definition-CKKX4Yvy.js";
3
3
  import { ArgSchema, ArgValues, Args, Args as Args$1, parseArgs, resolveArgs } from "args-tokens";
4
4
 
5
5
  //#region src/cli.d.ts
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-B_QNzw5q.js";
2
- import { DefaultTranslation } from "./context-DT5PgSdv.js";
1
+ import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-D41C8Abf.js";
2
+ import { DefaultTranslation } from "./context-D_EmfRNA.js";
3
3
  import { define, lazy } from "./definition-wq1Kmbvq.js";
4
- import "./renderer-CTx2DsBI.js";
5
- import { cli } from "./cli-BtS9kKar.js";
4
+ import "./renderer-BzRfaLdJ.js";
5
+ import { cli } from "./cli-DVGNVw3h.js";
6
6
  import { parseArgs, resolveArgs } from "args-tokens";
7
7
 
8
8
  export { DEFAULT_LOCALE, DefaultTranslation, cli, define, lazy, parseArgs, resolveArgs };
@@ -1,4 +1,5 @@
1
- import { COMMON_ARGS, create, kebabnize, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-B_QNzw5q.js";
1
+ import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-D41C8Abf.js";
2
+ import { kebabnize } from "args-tokens/utils";
2
3
 
3
4
  //#region src/renderer/header.ts
4
5
  /**
package/lib/renderer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandContext } from "./types-B7j6WSjQ.js";
1
+ import { CommandContext } from "./types-DtEE4hKC.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/renderer/header.d.ts
package/lib/renderer.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-B_QNzw5q.js";
2
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-CTx2DsBI.js";
1
+ import "./utils-D41C8Abf.js";
2
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BzRfaLdJ.js";
3
3
 
4
4
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -281,6 +281,7 @@ interface CommandContext<A extends Args = Args, V = ArgValues<A>> {
281
281
  * If {@link CommandEnvironment.usageSilent} is true, the message is not output.
282
282
  * @param message an output message, @see {@link console.log}
283
283
  * @param optionalParams an optional parameters, @see {@link console.log}
284
+ * @internal
284
285
  */
285
286
  log: (message?: any, ...optionalParams: any[]) => void;
286
287
  /**
@@ -72,14 +72,6 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
72
72
  function resolveBuiltInKey(key) {
73
73
  return `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
74
74
  }
75
- /**
76
- * Convert a camelCase string to kebab-case
77
- * @param str The string to convert
78
- * @returns The kebab-case version of the string
79
- */
80
- function kebabnize(str) {
81
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
82
- }
83
75
  function resolveArgKey(key) {
84
76
  return `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
85
77
  }
@@ -108,4 +100,4 @@ function deepFreeze(obj) {
108
100
  }
109
101
 
110
102
  //#endregion
111
- export { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, kebabnize, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
103
+ export { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gunshi",
3
3
  "description": "Modern javascript command-line library",
4
- "version": "0.25.0",
4
+ "version": "0.26.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/kazupon/gunshi.git"
16
+ "url": "git+https://github.com/kazupon/gunshi.git",
17
+ "directory": "packages/gunshi"
17
18
  },
18
19
  "keywords": [
19
20
  "command",
@@ -78,96 +79,21 @@
78
79
  }
79
80
  },
80
81
  "dependencies": {
81
- "args-tokens": "^0.19.0"
82
+ "args-tokens": "^0.20.1"
82
83
  },
83
84
  "devDependencies": {
84
- "@eslint/markdown": "^6.4.0",
85
85
  "@intlify/core": "next",
86
- "@kazupon/eslint-config": "^0.29.0",
87
- "@kazupon/prettier-config": "^0.1.1",
88
- "@types/node": "^22.15.21",
89
- "@typescript/native-preview": "7.0.0-dev.20250526.1",
90
- "@vitest/eslint-plugin": "^1.2.1",
91
- "bumpp": "^10.1.1",
92
86
  "deno": "^2.3.3",
93
- "eslint": "^9.27.0",
94
- "eslint-config-prettier": "^10.1.5",
95
- "eslint-import-resolver-typescript": "^4.4.1",
96
- "eslint-plugin-import": "^2.31.0",
97
- "eslint-plugin-jsonc": "^2.20.1",
98
- "eslint-plugin-module-interop": "^0.3.1",
99
- "eslint-plugin-promise": "^7.2.1",
100
- "eslint-plugin-regexp": "^2.7.0",
101
- "eslint-plugin-unicorn": "^58.0.0",
102
- "eslint-plugin-unused-imports": "^4.1.4",
103
- "eslint-plugin-vue": "^10.1.0",
104
- "eslint-plugin-vue-composable": "^1.0.0",
105
- "eslint-plugin-yml": "^1.18.0",
106
- "gh-changelogen": "^0.2.8",
107
- "gunshi019": "npm:gunshi@0.19.0",
108
87
  "jsr": "^0.13.4",
109
88
  "jsr-exports-lint": "^0.4.0",
110
- "knip": "^5.58.0",
111
- "lint-staged": "^16.0.0",
112
89
  "messageformat": "4.0.0-12",
113
- "mitata": "^1.0.34",
114
- "pkg-pr-new": "^0.0.50",
115
- "prettier": "^3.5.3",
116
90
  "publint": "^0.3.12",
117
91
  "tsdown": "^0.12.3",
118
- "typedoc": "^0.28.4",
119
- "typedoc-plugin-markdown": "^4.6.3",
120
- "typedoc-vitepress-theme": "^1.1.2",
121
- "typescript-eslint": "^8.32.1",
122
- "vitepress": "^1.6.3",
123
- "vitepress-plugin-group-icons": "^1.5.5",
124
- "vitepress-plugin-llms": "^1.3.4",
125
- "vitest": "^3.1.4",
126
- "vue": "^3.5.14",
127
92
  "zod": "^3.25.28"
128
93
  },
129
- "prettier": "@kazupon/prettier-config",
130
- "lint-staged": {
131
- "*.ts?(x)": [
132
- "prettier --parser=typescript --write",
133
- "eslint --fix"
134
- ],
135
- "*.{js,mjs,cjs}": [
136
- "prettier --write",
137
- "eslint --fix"
138
- ],
139
- "*.{json,jsonc,json5,md,yml,yaml}": [
140
- "prettier --write"
141
- ]
142
- },
143
94
  "scripts": {
144
- "bench:mitata": "node --expose-gc bench/mitata.js",
145
- "bench:vitest": "vitest bench --run",
146
95
  "build": "tsdown",
147
- "changelog": "gh-changelogen --repo=kazupon/gunshi",
148
- "clean": "git clean -df",
149
- "dev": "pnpx @eslint/config-inspector --config eslint.config.ts",
150
- "dev:eslint": "pnpx @eslint/config-inspector --config eslint.config.ts",
151
- "dev:typedoc": "typedoc --watch --preserveWatchOutput",
152
- "docs:build": "pnpm run docs:build:typedoc && pnpm docs:build:vitepress",
153
- "docs:build:typedoc": "typedoc --excludeInternal",
154
- "docs:build:vitepress": "vitepress build docs",
155
- "docs:dev": "pnpm run docs:build:typedoc && pnpm docs:dev:vitepress",
156
- "docs:dev:vitepress": "vitepress dev docs",
157
- "docs:preview": "vitepress preview docs",
158
- "fix": "pnpm run --stream --color \"/^fix:/\"",
159
- "fix:eslint": "eslint . --fix",
160
- "fix:knip": "knip --fix --no-exit-code",
161
- "fix:prettier": "prettier . --write",
162
- "lint": "pnpm run --stream --color \"/^lint:/\"",
163
- "lint:eslint": "eslint .",
164
96
  "lint:jsr": "jsr publish --dry-run --allow-dirty",
165
- "lint:knip": "knip",
166
- "lint:prettier": "prettier . --check",
167
- "release": "bumpp --commit \"release: v%s\" --all --push --tag",
168
- "test": "vitest --typecheck run",
169
- "typecheck": "pnpm run --stream --color \"/^typecheck:/\"",
170
- "typecheck:deno": "deno check --all ./src",
171
- "typecheck:tsc": "tsgo --noEmit"
97
+ "typecheck:deno": "deno check --all ./src"
172
98
  }
173
99
  }
package/README.md DELETED
@@ -1,142 +0,0 @@
1
- <p align="center">
2
- <img width="196" src="./assets/logo.png">
3
- </p>
4
- <h1 align="center">🏯 Gunshi</h1>
5
-
6
- [![Version][npm-version-src]][npm-version-href]
7
- [![CI][ci-src]][ci-href]
8
- [![InstallSize][install-size-src]][install-size-src]
9
- [![JSR][jsr-src]][jsr-href]
10
-
11
- Gunshi is a modern javascript command-line library
12
-
13
- <!-- eslint-disable markdown/no-missing-label-refs -->
14
-
15
- > [!TIP]
16
- > gunshi (軍師) is a position in ancient Japanese samurai battle in which a samurai devised strategies and gave orders. That name is inspired by the word "command".
17
-
18
- <!-- eslint-enable markdown/no-missing-label-refs -->
19
-
20
- ## ✨ Features
21
-
22
- Gunshi is designed to simplify the creation of modern command-line interfaces:
23
-
24
- - 📏 **Simple & Universal**: Run the commands with simple API and support universal runtime.
25
- - ⚙️ **Declarative configuration**: Configure command modules declaratively for better organization and maintainability.
26
- - 🛡️ **Type Safe**: TypeScript support with type-safe argument parsing and option resolution by [args-tokens](https://github.com/kazupon/args-tokens)
27
- - 🧩 **Composable**: Create modular sub-commands that can be composed together for complex CLIs.
28
- - ⏳ **Lazy & Async**: Load command modules lazily and execute them asynchronously for better performance.
29
- - 📜 **Auto usage generation**: Generate helpful usage messages automatically for your commands.
30
- - 🎨 **Custom usage generation**: Customize how usage messages are generated to match your CLI's style.
31
- - 🌍 **Internationalization**: Support multiple languages with built-in i18n, locale resource lazy loading and i18n library integration.
32
-
33
- ## 💿 Installation
34
-
35
- ```sh
36
- # npm
37
- npm install --save gunshi
38
-
39
- ## pnpm
40
- pnpm add gunshi
41
-
42
- ## yarn
43
- yarn add gunshi
44
-
45
- ## deno
46
- deno add jsr:@kazupon/gunshi
47
-
48
- ## bun
49
- bun add gunshi
50
- ```
51
-
52
- ## 🚀 Usage
53
-
54
- ```js
55
- import { cli } from 'gunshi'
56
-
57
- // define a command with declarative configuration, using commandable object
58
- const command = {
59
- name: 'greet',
60
- description: 'A greeting command',
61
- options: {
62
- name: {
63
- type: 'string',
64
- short: 'n',
65
- description: 'Name to greet'
66
- },
67
- greeting: {
68
- type: 'string',
69
- short: 'g',
70
- default: 'Hello',
71
- description: 'Greeting to use (default: "Hello")'
72
- },
73
- times: {
74
- type: 'number',
75
- short: 't',
76
- default: 1,
77
- description: 'Number of times to repeat the greeting (default: 1)'
78
- }
79
- },
80
- run: ctx => {
81
- const { name = 'World', greeting, times } = ctx.values
82
- for (let i = 0; i < times; i++) {
83
- console.log(`${greeting}, ${name}!`)
84
- }
85
- }
86
- }
87
-
88
- // run a command that is defined above
89
- // (the 3rd argument of `cli` is the command option)
90
- await cli(process.argv.slice(2), command, {
91
- name: 'my-app',
92
- version: '1.0.0',
93
- description: 'My CLI application'
94
- })
95
- ```
96
-
97
- About more details and usage, see [documentations](https://gunshi.dev)
98
-
99
- ## 💁‍♀️ Showcases
100
-
101
- - [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
102
- - [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
103
- - [curxy](https://github.com/ryoppippi/curxy): An proxy worker for using ollama in cursor
104
-
105
- ## 🙌 Contributing guidelines
106
-
107
- If you are interested in contributing to `gunshi`, I highly recommend checking out [the contributing guidelines](/CONTRIBUTING.md) here. You'll find all the relevant information such as [how to make a PR](/CONTRIBUTING.md#pull-request-guidelines), [how to setup development](/CONTRIBUTING.md#development-setup)) etc., there.
108
-
109
- ## 💖 Credits
110
-
111
- This project is inspired and powered by:
112
-
113
- - [`citty`](https://github.com/unjs/citty), created by [UnJS team](https://github.com/unjs) and contributors
114
- - [`ordana`](https://github.com/sapphi-red/ordana), createdy by [sapphi-red](https://github.com/sapphi-red), inspired documentation generation
115
- - cline and claude 3.7 sonnet, examples and docs is generated
116
-
117
- Thank you!
118
-
119
- ## 🤝 Sponsors
120
-
121
- The development of Gunshi is supported by my OSS sponsors!
122
-
123
- <p align="center">
124
- <a href="https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg">
125
- <img src='https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg'/>
126
- </a>
127
- </p>
128
-
129
- ## ©️ License
130
-
131
- [MIT](http://opensource.org/licenses/MIT)
132
-
133
- <!-- Badges -->
134
-
135
- [npm-version-src]: https://img.shields.io/npm/v/gunshi?style=flat
136
- [npm-version-href]: https://npmjs.com/package/gunshi
137
- [jsr-src]: https://jsr.io/badges/@kazupon/gunshi
138
- [jsr-href]: https://jsr.io/@kazupon/gunshi
139
- [install-size-src]: https://pkg-size.dev/badge/install/72346
140
- [install-size-href]: https://pkg-size.dev/gunshi
141
- [ci-src]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml/badge.svg
142
- [ci-href]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml