zudojs-cli 2.0.1 → 2.1.1

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.
Files changed (248) hide show
  1. package/README.md +59 -7
  2. package/dist/src/adapters/frontend/angular.adapter.d.ts +0 -1
  3. package/dist/src/adapters/frontend/angular.adapter.js +14 -97
  4. package/dist/src/adapters/frontend/astro.adapter.d.ts +0 -1
  5. package/dist/src/adapters/frontend/astro.adapter.js +4 -64
  6. package/dist/src/adapters/frontend/fallback/fallback.helper.d.ts +41 -0
  7. package/dist/src/adapters/frontend/fallback/fallback.helper.js +57 -0
  8. package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.d.ts +18 -0
  9. package/dist/src/adapters/frontend/fallback/framework/angular/angular.fallback.js +107 -0
  10. package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.d.ts +23 -0
  11. package/dist/src/adapters/frontend/fallback/framework/angular/angularWorkspace.fallback.js +125 -0
  12. package/dist/src/adapters/frontend/fallback/framework/angular/index.d.ts +8 -0
  13. package/dist/src/adapters/frontend/fallback/framework/angular/index.js +8 -0
  14. package/dist/src/adapters/frontend/fallback/framework/astro.fallback.d.ts +14 -0
  15. package/dist/src/adapters/frontend/fallback/framework/astro.fallback.js +76 -0
  16. package/dist/src/adapters/frontend/fallback/framework/index.d.ts +13 -0
  17. package/dist/src/adapters/frontend/fallback/framework/index.js +13 -0
  18. package/dist/src/adapters/frontend/fallback/framework/next.fallback.d.ts +13 -0
  19. package/dist/src/adapters/frontend/fallback/framework/next.fallback.js +105 -0
  20. package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.d.ts +14 -0
  21. package/dist/src/adapters/frontend/fallback/framework/nuxt.fallback.js +56 -0
  22. package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.d.ts +15 -0
  23. package/dist/src/adapters/frontend/fallback/framework/sveltekit.fallback.js +94 -0
  24. package/dist/src/adapters/frontend/fallback/index.d.ts +12 -0
  25. package/dist/src/adapters/frontend/fallback/index.js +12 -0
  26. package/dist/src/adapters/frontend/fallback/vite/index.d.ts +11 -0
  27. package/dist/src/adapters/frontend/fallback/vite/index.js +11 -0
  28. package/dist/src/adapters/frontend/fallback/vite/react.fallback.d.ts +13 -0
  29. package/dist/src/adapters/frontend/fallback/vite/react.fallback.js +77 -0
  30. package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.d.ts +14 -0
  31. package/dist/src/adapters/frontend/fallback/vite/svelte.fallback.js +95 -0
  32. package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.d.ts +13 -0
  33. package/dist/src/adapters/frontend/fallback/vite/vanilla.fallback.js +71 -0
  34. package/dist/src/adapters/frontend/fallback/vite/vue.fallback.d.ts +14 -0
  35. package/dist/src/adapters/frontend/fallback/vite/vue.fallback.js +78 -0
  36. package/dist/src/adapters/frontend/next.adapter.d.ts +0 -1
  37. package/dist/src/adapters/frontend/next.adapter.js +16 -95
  38. package/dist/src/adapters/frontend/nuxt.adapter.d.ts +1 -2
  39. package/dist/src/adapters/frontend/nuxt.adapter.js +32 -43
  40. package/dist/src/adapters/frontend/react-native.adapter.js +1 -1
  41. package/dist/src/adapters/frontend/react.adapter.d.ts +0 -1
  42. package/dist/src/adapters/frontend/react.adapter.js +7 -89
  43. package/dist/src/adapters/frontend/svelte.adapter.d.ts +0 -1
  44. package/dist/src/adapters/frontend/svelte.adapter.js +4 -86
  45. package/dist/src/adapters/frontend/sveltekit.adapter.d.ts +0 -1
  46. package/dist/src/adapters/frontend/sveltekit.adapter.js +4 -57
  47. package/dist/src/adapters/frontend/vanilla.adapter.d.ts +0 -1
  48. package/dist/src/adapters/frontend/vanilla.adapter.js +4 -47
  49. package/dist/src/adapters/frontend/vue.adapter.d.ts +0 -1
  50. package/dist/src/adapters/frontend/vue.adapter.js +4 -76
  51. package/dist/src/bin/bin.menu.d.ts +22 -0
  52. package/dist/src/bin/bin.menu.js +40 -0
  53. package/dist/src/bin/bin.runner.d.ts +38 -0
  54. package/dist/src/bin/bin.runner.js +51 -0
  55. package/dist/src/bin/index.d.ts +9 -0
  56. package/dist/src/bin/index.js +9 -0
  57. package/dist/src/bin/zudojs.js +15 -4
  58. package/dist/src/cliApplication/cliApplication.core.d.ts +4 -2
  59. package/dist/src/cliApplication/cliApplication.core.js +48 -36
  60. package/dist/src/cliApplication/cliApplication.logger.d.ts +5 -0
  61. package/dist/src/cliApplication/cliApplication.logger.js +5 -3
  62. package/dist/src/cliApplication/invocation/index.d.ts +12 -0
  63. package/dist/src/cliApplication/invocation/index.js +12 -0
  64. package/dist/src/cliApplication/invocation/invocation.hint.d.ts +30 -0
  65. package/dist/src/cliApplication/invocation/invocation.hint.js +74 -0
  66. package/dist/src/cliApplication/invocation/invocation.locate.d.ts +34 -0
  67. package/dist/src/cliApplication/invocation/invocation.locate.js +53 -0
  68. package/dist/src/cliApplication/invocation/invocation.name.d.ts +37 -0
  69. package/dist/src/cliApplication/invocation/invocation.name.js +69 -0
  70. package/dist/src/cliApplication/invocation/invocation.sanitize.d.ts +19 -0
  71. package/dist/src/cliApplication/invocation/invocation.sanitize.js +32 -0
  72. package/dist/src/cliParser/cliParser.core.js +3 -1
  73. package/dist/src/cliParser/cliParser.helper.d.ts +7 -0
  74. package/dist/src/cliParser/cliParser.helper.js +19 -2
  75. package/dist/src/cliParser/cliParser.longOption.js +2 -2
  76. package/dist/src/commands/add.command.d.ts +7 -3
  77. package/dist/src/commands/add.command.js +96 -57
  78. package/dist/src/commands/create.command.js +29 -42
  79. package/dist/src/commands/doctor.command.d.ts +2 -1
  80. package/dist/src/commands/doctor.command.js +52 -4
  81. package/dist/src/commands/generate.command.js +31 -16
  82. package/dist/src/commands/info.command.js +11 -1
  83. package/dist/src/constants/index.d.ts +21 -3
  84. package/dist/src/constants/index.js +40 -5
  85. package/dist/src/constants/zudojsVersions.generated.d.ts +9 -0
  86. package/dist/src/constants/zudojsVersions.generated.js +48 -0
  87. package/dist/src/constants/zudojsVersions.helper.d.ts +21 -0
  88. package/dist/src/constants/zudojsVersions.helper.js +29 -0
  89. package/dist/src/generators/frontend/frontendGenerator.core.js +9 -10
  90. package/dist/src/generators/frontend/frontendPipeline.d.ts +6 -1
  91. package/dist/src/generators/frontend/frontendPipeline.js +9 -1
  92. package/dist/src/generators/fullstack/fullstackComposer.core.js +7 -1
  93. package/dist/src/generators/index.d.ts +1 -2
  94. package/dist/src/generators/index.js +1 -2
  95. package/dist/src/generators/infrastructure/infrastructure.generator.js +13 -5
  96. package/dist/src/generators/integration/integrationGenerator.core.d.ts +2 -0
  97. package/dist/src/generators/integration/integrationGenerator.core.js +31 -2
  98. package/dist/src/generators/module/module.generator.js +36 -4
  99. package/dist/src/generators/resource/index.d.ts +8 -0
  100. package/dist/src/generators/resource/index.js +8 -0
  101. package/dist/src/generators/resource/resource.generator.d.ts +27 -0
  102. package/dist/src/generators/resource/resource.generator.js +87 -0
  103. package/dist/src/generators/resource/resource.layout.d.ts +26 -0
  104. package/dist/src/generators/resource/resource.layout.js +46 -0
  105. package/dist/src/generators/resource/resource.plan.d.ts +27 -0
  106. package/dist/src/generators/resource/resource.plan.js +46 -0
  107. package/dist/src/generators/resource/resource.run.d.ts +25 -0
  108. package/dist/src/generators/resource/resource.run.js +52 -0
  109. package/dist/src/prompts/cancel.prompt.d.ts +5 -1
  110. package/dist/src/prompts/cancel.prompt.js +4 -0
  111. package/dist/src/prompts/menu/index.d.ts +13 -0
  112. package/dist/src/prompts/menu/index.js +13 -0
  113. package/dist/src/prompts/menu/menu.adapter.d.ts +16 -0
  114. package/dist/src/prompts/menu/menu.adapter.js +56 -0
  115. package/dist/src/prompts/menu/menu.constant.d.ts +20 -0
  116. package/dist/src/prompts/menu/menu.constant.js +29 -0
  117. package/dist/src/prompts/menu/menu.flow.d.ts +18 -0
  118. package/dist/src/prompts/menu/menu.flow.js +82 -0
  119. package/dist/src/prompts/menu/menu.select.d.ts +26 -0
  120. package/dist/src/prompts/menu/menu.select.js +118 -0
  121. package/dist/src/prompts/menu/menu.type.d.ts +66 -0
  122. package/dist/src/prompts/menu/menu.type.js +8 -0
  123. package/dist/src/recipes/apply/index.d.ts +9 -0
  124. package/dist/src/recipes/apply/index.js +9 -0
  125. package/dist/src/recipes/apply/recipeApply.app.d.ts +20 -0
  126. package/dist/src/recipes/apply/recipeApply.app.js +79 -0
  127. package/dist/src/recipes/apply/recipeApply.context.d.ts +14 -0
  128. package/dist/src/recipes/apply/recipeApply.context.js +76 -0
  129. package/dist/src/recipes/apply/recipeApply.files.d.ts +39 -0
  130. package/dist/src/recipes/apply/recipeApply.files.js +84 -0
  131. package/dist/src/recipes/apply/recipeApply.project.d.ts +11 -0
  132. package/dist/src/recipes/apply/recipeApply.project.js +50 -0
  133. package/dist/src/recipes/apply/recipeApply.report.d.ts +20 -0
  134. package/dist/src/recipes/apply/recipeApply.report.js +51 -0
  135. package/dist/src/recipes/catalog/database/database.files.d.ts +15 -0
  136. package/dist/src/recipes/catalog/database/database.files.js +98 -0
  137. package/dist/src/recipes/catalog/database/database.recipe.d.ts +9 -0
  138. package/dist/src/recipes/catalog/database/database.recipe.js +50 -0
  139. package/dist/src/recipes/catalog/database/index.d.ts +6 -0
  140. package/dist/src/recipes/catalog/database/index.js +6 -0
  141. package/dist/src/recipes/catalog/email.recipe.d.ts +9 -0
  142. package/dist/src/recipes/catalog/email.recipe.js +122 -0
  143. package/dist/src/recipes/catalog/index.d.ts +11 -0
  144. package/dist/src/recipes/catalog/index.js +11 -0
  145. package/dist/src/recipes/catalog/openapi.recipe.d.ts +8 -0
  146. package/dist/src/recipes/catalog/openapi.recipe.js +25 -0
  147. package/dist/src/recipes/catalog/platform/cache.recipe.d.ts +7 -0
  148. package/dist/src/recipes/catalog/platform/cache.recipe.js +55 -0
  149. package/dist/src/recipes/catalog/platform/index.d.ts +9 -0
  150. package/dist/src/recipes/catalog/platform/index.js +9 -0
  151. package/dist/src/recipes/catalog/platform/messaging.recipe.d.ts +7 -0
  152. package/dist/src/recipes/catalog/platform/messaging.recipe.js +46 -0
  153. package/dist/src/recipes/catalog/platform/observability.recipe.d.ts +8 -0
  154. package/dist/src/recipes/catalog/platform/observability.recipe.js +49 -0
  155. package/dist/src/recipes/catalog/platform/queue.recipe.d.ts +7 -0
  156. package/dist/src/recipes/catalog/platform/queue.recipe.js +61 -0
  157. package/dist/src/recipes/catalog/platform/scheduler.recipe.d.ts +7 -0
  158. package/dist/src/recipes/catalog/platform/scheduler.recipe.js +56 -0
  159. package/dist/src/recipes/catalog/redis.recipe.d.ts +8 -0
  160. package/dist/src/recipes/catalog/redis.recipe.js +79 -0
  161. package/dist/src/recipes/catalog/storage.recipe.d.ts +7 -0
  162. package/dist/src/recipes/catalog/storage.recipe.js +49 -0
  163. package/dist/src/recipes/catalog/websockets.recipe.d.ts +10 -0
  164. package/dist/src/recipes/catalog/websockets.recipe.js +84 -0
  165. package/dist/src/recipes/docker/docker.compose.d.ts +19 -0
  166. package/dist/src/recipes/docker/docker.compose.js +90 -0
  167. package/dist/src/recipes/docker/docker.recipe.d.ts +10 -0
  168. package/dist/src/recipes/docker/docker.recipe.js +51 -0
  169. package/dist/src/recipes/docker/docker.refresh.d.ts +13 -0
  170. package/dist/src/recipes/docker/docker.refresh.js +37 -0
  171. package/dist/src/recipes/docker/index.d.ts +7 -0
  172. package/dist/src/recipes/docker/index.js +7 -0
  173. package/dist/src/recipes/index.d.ts +8 -0
  174. package/dist/src/recipes/index.js +8 -0
  175. package/dist/src/recipes/recipe.registry.d.ts +17 -0
  176. package/dist/src/recipes/recipe.registry.js +46 -0
  177. package/dist/src/recipes/recipe.type.d.ts +93 -0
  178. package/dist/src/recipes/recipe.type.js +12 -0
  179. package/dist/src/resolvers/dependency/dependencyVersions.constant.d.ts +100 -5
  180. package/dist/src/resolvers/dependency/dependencyVersions.constant.js +103 -34
  181. package/dist/src/resolvers/dependency/index.d.ts +1 -1
  182. package/dist/src/resolvers/dependency/index.js +1 -1
  183. package/dist/src/resolvers/project.resolver.d.ts +14 -1
  184. package/dist/src/resolvers/project.resolver.js +11 -3
  185. package/dist/src/scaffolders/scaffolder.helper.js +12 -1
  186. package/dist/src/templates/backendApp/backendApp.core.d.ts +45 -0
  187. package/dist/src/templates/backendApp/backendApp.core.js +66 -0
  188. package/dist/src/templates/backendApp/backendApp.modules.d.ts +26 -0
  189. package/dist/src/templates/backendApp/backendApp.modules.js +25 -0
  190. package/dist/src/templates/backendApp/backendApp.project.d.ts +26 -0
  191. package/dist/src/templates/backendApp/backendApp.project.js +87 -0
  192. package/dist/src/templates/backendApp/index.d.ts +8 -0
  193. package/dist/src/templates/backendApp/index.js +8 -0
  194. package/dist/src/templates/backendApp/parts/config.template.d.ts +28 -0
  195. package/dist/src/templates/backendApp/parts/config.template.js +118 -0
  196. package/dist/src/templates/backendApp/parts/httpUtils.template.d.ts +10 -0
  197. package/dist/src/templates/backendApp/parts/httpUtils.template.js +103 -0
  198. package/dist/src/templates/backendApp/parts/index.d.ts +9 -0
  199. package/dist/src/templates/backendApp/parts/index.js +9 -0
  200. package/dist/src/templates/backendApp/parts/integrations.template.d.ts +16 -0
  201. package/dist/src/templates/backendApp/parts/integrations.template.js +115 -0
  202. package/dist/src/templates/backendApp/parts/wiring.template.d.ts +26 -0
  203. package/dist/src/templates/backendApp/parts/wiring.template.js +111 -0
  204. package/dist/src/templates/microservice/microservice.template.js +61 -87
  205. package/dist/src/templates/modular-monolith/modularMonolith.template.js +25 -77
  206. package/dist/src/templates/monolith/monolith.template.d.ts +11 -26
  207. package/dist/src/templates/monolith/monolith.template.js +49 -146
  208. package/dist/src/templates/resource/index.d.ts +9 -0
  209. package/dist/src/templates/resource/index.js +9 -0
  210. package/dist/src/templates/resource/layers/index.d.ts +9 -0
  211. package/dist/src/templates/resource/layers/index.js +9 -0
  212. package/dist/src/templates/resource/layers/resourceData.template.d.ts +9 -0
  213. package/dist/src/templates/resource/layers/resourceData.template.js +108 -0
  214. package/dist/src/templates/resource/layers/resourcePrisma.template.d.ts +15 -0
  215. package/dist/src/templates/resource/layers/resourcePrisma.template.js +89 -0
  216. package/dist/src/templates/resource/layers/resourceRoutes.template.d.ts +13 -0
  217. package/dist/src/templates/resource/layers/resourceRoutes.template.js +128 -0
  218. package/dist/src/templates/resource/layers/resourceService.template.d.ts +13 -0
  219. package/dist/src/templates/resource/layers/resourceService.template.js +95 -0
  220. package/dist/src/templates/resource/resource.files.d.ts +33 -0
  221. package/dist/src/templates/resource/resource.files.js +99 -0
  222. package/dist/src/templates/resource/resource.names.d.ts +38 -0
  223. package/dist/src/templates/resource/resource.names.js +60 -0
  224. package/dist/src/templates/resource/resource.type.d.ts +19 -0
  225. package/dist/src/templates/resource/resource.type.js +15 -0
  226. package/dist/src/templates/shared/appRuntime.template.js +28 -11
  227. package/dist/src/templates/shared/capability.template.d.ts +13 -4
  228. package/dist/src/templates/shared/capability.template.js +21 -5
  229. package/dist/src/templates/shared/dockerfile.template.d.ts +12 -4
  230. package/dist/src/templates/shared/dockerfile.template.js +68 -29
  231. package/dist/src/templates/shared/pnpm.template.d.ts +8 -2
  232. package/dist/src/templates/shared/pnpm.template.js +9 -1
  233. package/dist/src/templates/shared/server.template.d.ts +23 -22
  234. package/dist/src/templates/shared/server.template.js +79 -53
  235. package/dist/src/types/scaffold.type.d.ts +6 -0
  236. package/dist/src/types/scaffold.type.js +2 -1
  237. package/dist/src/utils/utils.name.js +6 -0
  238. package/dist/src/utils/utils.writeGuard.d.ts +5 -0
  239. package/dist/src/utils/utils.writeGuard.js +23 -0
  240. package/dist/src/wiring/index.d.ts +10 -0
  241. package/dist/src/wiring/index.js +10 -0
  242. package/dist/src/wiring/wiring.dependencies.d.ts +29 -0
  243. package/dist/src/wiring/wiring.dependencies.js +83 -0
  244. package/dist/src/wiring/wiring.edits.d.ts +51 -0
  245. package/dist/src/wiring/wiring.edits.js +90 -0
  246. package/dist/src/wiring/wiring.markers.d.ts +53 -0
  247. package/dist/src/wiring/wiring.markers.js +87 -0
  248. package/package.json +20 -15
@@ -0,0 +1,51 @@
1
+ /**
2
+ * zudojs-cli — Binary Runner
3
+ *
4
+ * What the `zudojs` / `zudo` executable does with its arguments: open the
5
+ * interactive menu for a bare invocation on a terminal, otherwise hand the
6
+ * arguments straight to the application.
7
+ */
8
+ import { CLI_ENVIRONMENT, CLI_EXIT_CODES, } from "../cliConstant/cliConstant.value.js";
9
+ /** Whether an environment variable is set to a truthy value. */
10
+ function isTruthy(value) {
11
+ if (value === undefined)
12
+ return false;
13
+ const normalized = value.trim().toLowerCase();
14
+ return normalized !== "" && normalized !== "0" && normalized !== "false";
15
+ }
16
+ /**
17
+ * Whether a bare invocation should open the interactive menu.
18
+ *
19
+ * Only with no arguments at all, both stdin and stdout attached to a
20
+ * terminal, and not under CI. Piped, redirected and CI runs keep printing
21
+ * the help text and exiting 0, so scripts that call `zudojs` are unchanged.
22
+ */
23
+ export function shouldShowMenu(environment) {
24
+ return (environment.argv.length === 0 &&
25
+ environment.stdin.isTTY === true &&
26
+ environment.stdout.isTTY === true &&
27
+ !isTruthy(environment.env[CLI_ENVIRONMENT.CI]));
28
+ }
29
+ /**
30
+ * Runs the binary and resolves with the process exit code.
31
+ *
32
+ * @param app - The application with every command registered.
33
+ * @param environment - The process's arguments, streams and variables.
34
+ * @param openMenu - Shows the menu; only called when `shouldShowMenu`.
35
+ */
36
+ export async function runBinary(app, environment, openMenu) {
37
+ if (!shouldShowMenu(environment)) {
38
+ return app.run([...environment.argv]);
39
+ }
40
+ const outcome = await openMenu();
41
+ switch (outcome.kind) {
42
+ case "exit":
43
+ return CLI_EXIT_CODES.SUCCESS;
44
+ case "cancel":
45
+ // Same status as every other aborted prompt (see `cancelled`).
46
+ return CLI_EXIT_CODES.INTERRUPTED;
47
+ default:
48
+ return app.run([...outcome.args]);
49
+ }
50
+ }
51
+ //# sourceMappingURL=bin.runner.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * zudojs-cli — Binary
3
+ *
4
+ * The executable's run logic. `zudojs.ts` is the entry script itself and is
5
+ * deliberately not re-exported: importing it would start the CLI.
6
+ */
7
+ export { runBinary, shouldShowMenu, type BinaryEnvironment, } from "./bin.runner.js";
8
+ export { isZudojsProject, openMainMenu } from "./bin.menu.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * zudojs-cli — Binary
3
+ *
4
+ * The executable's run logic. `zudojs.ts` is the entry script itself and is
5
+ * deliberately not re-exported: importing it would start the CLI.
6
+ */
7
+ export { runBinary, shouldShowMenu, } from "./bin.runner.js";
8
+ export { isZudojsProject, openMainMenu } from "./bin.menu.js";
9
+ //# sourceMappingURL=index.js.map
@@ -7,7 +7,7 @@
7
7
  import { createCLI } from "../cliApplication/index.js";
8
8
  import { createCommand } from "../cliCommand/index.js";
9
9
  import { CLI_VERSION, FEATURE_NAMES, SCHEMATIC_NAMES, } from "../constants/index.js";
10
- import { CLI_NAME } from "../cliConstant/cliConstant.value.js";
10
+ import { escapeControlCharacters, resolveInvokedName, } from "../cliApplication/invocation/index.js";
11
11
  import { runCreateCommand } from "../commands/create.command.js";
12
12
  import { runDevCommand } from "../commands/dev.command.js";
13
13
  import { runGenerateCommand } from "../commands/generate.command.js";
@@ -15,9 +15,14 @@ import { runAddCommand } from "../commands/add.command.js";
15
15
  import { runBuildCommand } from "../commands/build.command.js";
16
16
  import { runDoctorCommand } from "../commands/doctor.command.js";
17
17
  import { runInfoCommand } from "../commands/info.command.js";
18
+ import { runBinary } from "./bin.runner.js";
19
+ import { openMainMenu } from "./bin.menu.js";
20
+ // `zudo` and `zudojs` are the same script; help, usage and errors repeat
21
+ // whichever one was typed. Anything else falls back to `zudojs`.
22
+ const invokedName = resolveInvokedName(process.argv[1]);
18
23
  const app = createCLI({
19
24
  // The name the help output tells people to type, so it must be the binary.
20
- name: CLI_NAME,
25
+ name: invokedName,
21
26
  // Read from the CLI's own package.json, so `zudojs --version` cannot
22
27
  // drift from the published version.
23
28
  version: CLI_VERSION,
@@ -26,6 +31,7 @@ const app = createCLI({
26
31
  app.register(createCommand({
27
32
  name: "create",
28
33
  description: "Create a new Zudojs project",
34
+ aliases: ["new"],
29
35
  arguments: [
30
36
  {
31
37
  name: "project-name",
@@ -249,14 +255,19 @@ app.register(createCommand({
249
255
  },
250
256
  }));
251
257
  try {
252
- const exitCode = await app.run(process.argv.slice(2));
258
+ const exitCode = await runBinary(app, {
259
+ argv: process.argv.slice(2),
260
+ stdin: process.stdin,
261
+ stdout: process.stdout,
262
+ env: process.env,
263
+ }, () => openMainMenu(invokedName, process.cwd()));
253
264
  if (exitCode !== 0) {
254
265
  process.exit(exitCode);
255
266
  }
256
267
  }
257
268
  catch (error) {
258
269
  const message = error instanceof Error ? error.message : String(error);
259
- console.error(`Error: ${message}`);
270
+ console.error(`Error: ${escapeControlCharacters(message)}`);
260
271
  process.exit(1);
261
272
  }
262
273
  //# sourceMappingURL=zudojs.js.map
@@ -40,8 +40,10 @@ export declare class ZudojsCLI implements CLIApplication {
40
40
  * bogus` says so instead of silently printing the global help.
41
41
  */
42
42
  private resolveHelpTarget;
43
- private findCommand;
44
- private getCommandArguments;
43
+ /** Rewrites `zudojs <command>` examples to the name the user typed. */
44
+ private localize;
45
+ /** The "did you mean" / "run --help" lines printed under a usage error. */
46
+ private hintsFor;
45
47
  private createContext;
46
48
  /** Whether the application is currently running. */
47
49
  get isRunning(): boolean;
@@ -4,7 +4,7 @@
4
4
  * Main CLI application class that orchestrates command registration,
5
5
  * parsing, execution, and built-in help/version handling.
6
6
  */
7
- import { CLI_DEFAULTS, CLI_EXIT_CODES, CLI_MESSAGES, CLI_OPTION_PREFIXES, } from "../cliConstant/cliConstant.value.js";
7
+ import { CLI_DEFAULTS, CLI_EXIT_CODES, CLI_OPTION_PREFIXES, } from "../cliConstant/cliConstant.value.js";
8
8
  import { CLIExecutionError, normalizeCLIError } from "../cliError/index.js";
9
9
  import { CommandNotFoundError } from "../cliError/cliError.command.js";
10
10
  import { InvalidArgumentsError } from "../cliError/cliError.argument.js";
@@ -15,6 +15,7 @@ import { createCLIWriter } from "./cliApplication.writer.js";
15
15
  import { createCLILogger } from "./cliApplication.logger.js";
16
16
  import { isHelpFlag, isHelpRequest, isVersionRequest, printVersion, printHelp, } from "./cliApplication.builtins.js";
17
17
  import { printCommandHelp } from "./cliApplication.help.js";
18
+ import { escapeControlCharacters, failureHints, localizeCommandName, locateCommand, requireCommand, } from "./invocation/index.js";
18
19
  /* -------------------------------------------------------------------------- */
19
20
  /* Application */
20
21
  /* -------------------------------------------------------------------------- */
@@ -40,8 +41,10 @@ export class ZudojsCLI {
40
41
  this.description = options.description ?? CLI_DEFAULTS.DESCRIPTION;
41
42
  this.cwd = options.cwd ?? process.cwd();
42
43
  this.env = options.env ?? process.env;
43
- this.logger = options.logger ?? createCLILogger();
44
44
  this.commands = new CLICommandRegistry();
45
+ this.logger =
46
+ options.logger ??
47
+ createCLILogger({ transform: (line) => this.localize(line) });
45
48
  this.parser = new CLIParser();
46
49
  this.writer = createCLIWriter();
47
50
  this.hooks = {};
@@ -84,27 +87,26 @@ export class ZudojsCLI {
84
87
  return CLI_EXIT_CODES.SUCCESS;
85
88
  }
86
89
  if (isVersionRequest(args)) {
90
+ // `zudojs -v extra` used to print the version and exit 0, silently
91
+ // discarding the rest of the line.
92
+ if (args.length > 1) {
93
+ throw new InvalidArgumentsError(`Unexpected argument "${args[1]}" after "${args[0]}".`);
94
+ }
87
95
  printVersion(this.writer, this.version);
88
96
  return CLI_EXIT_CODES.SUCCESS;
89
97
  }
90
- const command = this.findCommand(args);
91
- if (!command) {
92
- if (args.length === 0) {
93
- this.printApplicationHelp();
94
- return CLI_EXIT_CODES.SUCCESS;
95
- }
96
- const first = String(args[0]);
97
- // `findCommand` skips flag-shaped tokens, so a lone `-vh` would
98
- // otherwise be reported as a command named "-vh".
99
- if (first.startsWith(CLI_OPTION_PREFIXES.SHORT)) {
100
- throw new InvalidArgumentsError(CLI_MESSAGES.MISSING_COMMAND);
101
- }
102
- throw new CommandNotFoundError(first);
98
+ if (args.length === 0) {
99
+ this.printApplicationHelp();
100
+ return CLI_EXIT_CODES.SUCCESS;
103
101
  }
104
- const commandArgs = this.getCommandArguments(args, command);
102
+ const { index, command } = requireCommand(args, this.commands.list(), this.name);
103
+ const commandArgs = args.slice(index + 1);
105
104
  // Checked before parsing: `--help` is not a declared option, so the
106
105
  // parser would reject it as invalid and exit 2.
107
- if (commandArgs.some(isHelpFlag)) {
106
+ // Tokens after `--` are opaque, so `create -- --help` is not a request.
107
+ const escape = commandArgs.indexOf("--");
108
+ const flags = escape < 0 ? commandArgs : commandArgs.slice(0, escape);
109
+ if (flags.some(isHelpFlag)) {
108
110
  printCommandHelp(this.writer, this.name, command);
109
111
  return CLI_EXIT_CODES.SUCCESS;
110
112
  }
@@ -125,10 +127,8 @@ export class ZudojsCLI {
125
127
  // error came from argument parsing, re-parsing would fail again.
126
128
  let fallbackContext;
127
129
  try {
128
- const command = this.findCommand(args);
129
- const commandArgs = command
130
- ? this.getCommandArguments(args, command)
131
- : args;
130
+ const { index, command } = locateCommand(args, this.commands.list());
131
+ const commandArgs = command ? args.slice(index + 1) : args;
132
132
  fallbackContext = this.createContext(commandArgs, command);
133
133
  }
134
134
  catch {
@@ -143,7 +143,13 @@ export class ZudojsCLI {
143
143
  }
144
144
  await this.hooks.onError(normalized, fallbackContext);
145
145
  }
146
- this.writer.errorLine(normalized.message);
146
+ const lines = [
147
+ this.localize(normalized.message),
148
+ ...this.hintsFor(args, normalized.exitCode),
149
+ ];
150
+ for (const line of lines) {
151
+ this.writer.errorLine(escapeControlCharacters(line));
152
+ }
147
153
  return normalized.exitCode;
148
154
  }
149
155
  finally {
@@ -171,21 +177,27 @@ export class ZudojsCLI {
171
177
  throw new CommandNotFoundError(target);
172
178
  return command;
173
179
  }
174
- findCommand(args) {
175
- for (const arg of args) {
176
- if (arg.startsWith("-"))
177
- continue;
178
- const command = resolveCommand(this.commands.list(), arg);
179
- if (command)
180
- return command;
181
- }
182
- return undefined;
180
+ /** Rewrites `zudojs <command>` examples to the name the user typed. */
181
+ localize(text) {
182
+ const words = this.commands
183
+ .list()
184
+ .flatMap((command) => [command.name, ...(command.aliases ?? [])]);
185
+ return localizeCommandName(text, this.name, words);
183
186
  }
184
- getCommandArguments(args, command) {
185
- const index = args.findIndex((arg) => arg === command.name || command.aliases?.includes(arg));
186
- if (index < 0)
187
- return args;
188
- return args.slice(index + 1);
187
+ /** The "did you mean" / "run --help" lines printed under a usage error. */
188
+ hintsFor(args, exitCode) {
189
+ const commands = this.commands.list();
190
+ const helpTarget = isHelpRequest(args) ? args.slice(1) : args;
191
+ const { index, command } = locateCommand(helpTarget, commands);
192
+ return failureHints({
193
+ name: this.name,
194
+ exitCode,
195
+ commands,
196
+ ...(command ? { command } : {}),
197
+ ...(index >= 0 && !command
198
+ ? { unknownCommand: helpTarget[index] }
199
+ : {}),
200
+ });
189
201
  }
190
202
  createContext(args, command) {
191
203
  const parsed = this.parser.parse(args, command);
@@ -20,6 +20,11 @@ export interface CLILoggerOptions {
20
20
  /** Line writers, overridable for tests. */
21
21
  readonly stdout?: (line: string) => void;
22
22
  readonly stderr?: (line: string) => void;
23
+ /**
24
+ * Rewrites each rendered line, e.g. to repeat the executable name the
25
+ * user typed (`zudo create`) in command examples.
26
+ */
27
+ readonly transform?: (line: string) => string;
23
28
  }
24
29
  /** Renders one entry as the single line the user sees. */
25
30
  export declare function formatCLILogLine(entry: LoggerEntry): string;
@@ -37,20 +37,22 @@ export function createCLILogger(options = {}) {
37
37
  (debug !== undefined && debug !== "" && debug !== "0");
38
38
  const stdout = options.stdout ?? ((line) => process.stdout.write(`${line}\n`));
39
39
  const stderr = options.stderr ?? ((line) => process.stderr.write(`${line}\n`));
40
+ const transform = options.transform ?? ((line) => line);
40
41
  return createLogger({
41
42
  name: CLI_NAME,
42
43
  level: verbose ? LoggerLevel.TRACE : LoggerLevel.INFO,
43
44
  // Writes must complete before a command returns; `process.exit` follows
44
45
  // an error immediately.
45
46
  asynchronous: false,
46
- formatter: (entry) => formatCLILogLine(entry),
47
+ formatter: (entry) => transform(formatCLILogLine(entry)),
47
48
  transports: [
48
49
  {
49
50
  name: "cli-stdio",
50
51
  enabled: true,
51
52
  write(entry) {
52
- // The formatter's output arrives as the entry message.
53
- const line = entry.message;
53
+ // @zudojs/logger carries the formatter's line in `formatted` and
54
+ // keeps `message` raw; older releases put the line in `message`.
55
+ const line = entry.formatted ?? entry.message;
54
56
  switch (entry.levelName) {
55
57
  case "fatal":
56
58
  case "error":
@@ -0,0 +1,12 @@
1
+ /**
2
+ * zudojs-cli — Invocation
3
+ *
4
+ * How the CLI was invoked: the executable name the user typed, where the
5
+ * command sits in the argument list, and the hints printed under a usage
6
+ * error.
7
+ */
8
+ export { CLI_BIN_NAMES, resolveInvokedName, localizeCommandName, } from "./invocation.name.js";
9
+ export { locateCommand, requireCommand, type CommandLocation, } from "./invocation.locate.js";
10
+ export { escapeControlCharacters } from "./invocation.sanitize.js";
11
+ export { suggestCommand, failureHints, type FailureHintInput, } from "./invocation.hint.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * zudojs-cli — Invocation
3
+ *
4
+ * How the CLI was invoked: the executable name the user typed, where the
5
+ * command sits in the argument list, and the hints printed under a usage
6
+ * error.
7
+ */
8
+ export { CLI_BIN_NAMES, resolveInvokedName, localizeCommandName, } from "./invocation.name.js";
9
+ export { locateCommand, requireCommand, } from "./invocation.locate.js";
10
+ export { escapeControlCharacters } from "./invocation.sanitize.js";
11
+ export { suggestCommand, failureHints, } from "./invocation.hint.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * zudojs-cli — Failure Hints
3
+ *
4
+ * The follow-up lines printed under an error: a "did you mean" for a
5
+ * mistyped command and a pointer to the right help page.
6
+ */
7
+ import type { CLICommand } from "../../cliType/cliType.type.js";
8
+ /**
9
+ * Returns the registered command a mistyped name most likely meant.
10
+ *
11
+ * @param input - What the user typed.
12
+ * @param commands - Registered commands.
13
+ */
14
+ export declare function suggestCommand(input: string, commands: readonly CLICommand[]): string | undefined;
15
+ /** What a failure hint is built from. */
16
+ export interface FailureHintInput {
17
+ readonly name: string;
18
+ readonly exitCode: number;
19
+ readonly command?: CLICommand;
20
+ readonly unknownCommand?: string;
21
+ readonly commands: readonly CLICommand[];
22
+ }
23
+ /**
24
+ * Returns the hint lines printed after an error message.
25
+ *
26
+ * Only usage errors get hints: a failure inside a command already says
27
+ * what went wrong, and a help pointer would be noise there.
28
+ */
29
+ export declare function failureHints(input: FailureHintInput): readonly string[];
30
+ //# sourceMappingURL=invocation.hint.d.ts.map
@@ -0,0 +1,74 @@
1
+ /**
2
+ * zudojs-cli — Failure Hints
3
+ *
4
+ * The follow-up lines printed under an error: a "did you mean" for a
5
+ * mistyped command and a pointer to the right help page.
6
+ */
7
+ import { CLI_EXIT_CODES } from "../../cliConstant/cliConstant.value.js";
8
+ /** The largest edit distance still offered as a suggestion. */
9
+ const MAX_SUGGESTION_DISTANCE = 2;
10
+ /** Levenshtein distance between two short strings. */
11
+ function editDistance(a, b) {
12
+ let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
13
+ for (let i = 1; i <= a.length; i += 1) {
14
+ const current = [i];
15
+ for (let j = 1; j <= b.length; j += 1) {
16
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
17
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
18
+ }
19
+ previous = current;
20
+ }
21
+ return previous[b.length];
22
+ }
23
+ /**
24
+ * Returns the registered command a mistyped name most likely meant.
25
+ *
26
+ * @param input - What the user typed.
27
+ * @param commands - Registered commands.
28
+ */
29
+ export function suggestCommand(input, commands) {
30
+ const typed = input.trim().toLowerCase();
31
+ if (typed.length < 2)
32
+ return undefined;
33
+ let best;
34
+ for (const command of commands) {
35
+ for (const word of [command.name, ...(command.aliases ?? [])]) {
36
+ // One-letter aliases (`b`, `d`, `g`) are one edit from everything.
37
+ if (word.length < 2)
38
+ continue;
39
+ const distance = word.startsWith(typed) ? 1 : editDistance(typed, word);
40
+ if (distance > MAX_SUGGESTION_DISTANCE)
41
+ continue;
42
+ if (best === undefined || distance < best.distance) {
43
+ best = { name: word, distance };
44
+ }
45
+ }
46
+ }
47
+ return best?.name;
48
+ }
49
+ /**
50
+ * Returns the hint lines printed after an error message.
51
+ *
52
+ * Only usage errors get hints: a failure inside a command already says
53
+ * what went wrong, and a help pointer would be noise there.
54
+ */
55
+ export function failureHints(input) {
56
+ if (input.exitCode === CLI_EXIT_CODES.COMMAND_NOT_FOUND) {
57
+ const suggestion = input.unknownCommand === undefined
58
+ ? undefined
59
+ : suggestCommand(input.unknownCommand, input.commands);
60
+ return [
61
+ ...(suggestion ? [`Did you mean "${input.name} ${suggestion}"?`] : []),
62
+ `Run "${input.name} --help" to see all commands.`,
63
+ ];
64
+ }
65
+ if (input.exitCode === CLI_EXIT_CODES.INVALID_ARGUMENTS) {
66
+ return [
67
+ input.command
68
+ ? `Run "${input.name} ${input.command.name} --help" for usage.`
69
+ : `Run "${input.name} --help" for usage.`,
70
+ ];
71
+ }
72
+ return [];
73
+ }
74
+ //# sourceMappingURL=invocation.hint.js.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * zudojs-cli — Command Location
3
+ *
4
+ * Finds the command token in an argument list and rejects the shapes that
5
+ * used to be silently misread.
6
+ */
7
+ import type { CLIArguments, CLICommand } from "../../cliType/cliType.type.js";
8
+ /** Where the command sits in an argument list. */
9
+ export interface CommandLocation {
10
+ /** Index of the first non-flag token, or -1 when there is none. */
11
+ readonly index: number;
12
+ /** The command that token names, when it names one. */
13
+ readonly command?: CLICommand;
14
+ }
15
+ /**
16
+ * Locates the command without throwing.
17
+ *
18
+ * Only the first non-flag token can be the command. Scanning every token
19
+ * used to run `zudojs creat dev` as `dev` and `zudojs bogus info` as `info`,
20
+ * exiting 0 for a command line that contained a typo.
21
+ */
22
+ export declare function locateCommand(args: CLIArguments, commands: readonly CLICommand[]): CommandLocation;
23
+ /**
24
+ * Locates the command and throws a usage error when the line is malformed.
25
+ *
26
+ * @param name - The invoked executable name, used in the message.
27
+ * @throws {InvalidArgumentsError} No command, or options before the command.
28
+ * @throws {CommandNotFoundError} The command token is not registered.
29
+ */
30
+ export declare function requireCommand(args: CLIArguments, commands: readonly CLICommand[], name: string): {
31
+ readonly index: number;
32
+ readonly command: CLICommand;
33
+ };
34
+ //# sourceMappingURL=invocation.locate.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * zudojs-cli — Command Location
3
+ *
4
+ * Finds the command token in an argument list and rejects the shapes that
5
+ * used to be silently misread.
6
+ */
7
+ import { CLI_MESSAGES, CLI_OPTION_PREFIXES, } from "../../cliConstant/cliConstant.value.js";
8
+ import { CommandNotFoundError } from "../../cliError/cliError.command.js";
9
+ import { InvalidArgumentsError } from "../../cliError/cliError.argument.js";
10
+ import { resolveCommand } from "../../cliParser/cliParser.helper.js";
11
+ /**
12
+ * Locates the command without throwing.
13
+ *
14
+ * Only the first non-flag token can be the command. Scanning every token
15
+ * used to run `zudojs creat dev` as `dev` and `zudojs bogus info` as `info`,
16
+ * exiting 0 for a command line that contained a typo.
17
+ */
18
+ export function locateCommand(args, commands) {
19
+ const index = args.findIndex((arg) => !arg.startsWith(CLI_OPTION_PREFIXES.SHORT));
20
+ if (index < 0)
21
+ return { index };
22
+ const command = resolveCommand(commands, args[index]);
23
+ return command ? { index, command } : { index };
24
+ }
25
+ /**
26
+ * Locates the command and throws a usage error when the line is malformed.
27
+ *
28
+ * @param name - The invoked executable name, used in the message.
29
+ * @throws {InvalidArgumentsError} No command, or options before the command.
30
+ * @throws {CommandNotFoundError} The command token is not registered.
31
+ */
32
+ export function requireCommand(args, commands, name) {
33
+ const location = locateCommand(args, commands);
34
+ if (location.index < 0) {
35
+ // Only flags: a lone `-vh` must not be reported as a command named "-vh".
36
+ throw new InvalidArgumentsError(CLI_MESSAGES.MISSING_COMMAND);
37
+ }
38
+ if (location.index > 0) {
39
+ // `zudojs --verbose info` used to drop `--verbose` without a word, and
40
+ // `zudojs -p 3000 dev` reported a command named "3000".
41
+ const leading = args[0];
42
+ const later = args
43
+ .slice(location.index)
44
+ .map((arg) => resolveCommand(commands, arg))
45
+ .find((command) => command !== undefined);
46
+ throw new InvalidArgumentsError(`Unexpected option "${leading}" before the command. Options go after the command name: "${name} ${later?.name ?? "<command>"} ${leading}".`);
47
+ }
48
+ if (!location.command) {
49
+ throw new CommandNotFoundError(args[location.index]);
50
+ }
51
+ return { index: location.index, command: location.command };
52
+ }
53
+ //# sourceMappingURL=invocation.locate.js.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * zudojs-cli — Invoked Name
3
+ *
4
+ * Works out which executable name the user typed (`zudojs` or `zudo`) so
5
+ * help, usage and error output can repeat it back.
6
+ */
7
+ /**
8
+ * Executable names the CLI is installed under.
9
+ *
10
+ * `zudojs` is the canonical name; `zudo` is the short alias both the
11
+ * `zudojs-cli` and `zudojs` packages put on the PATH.
12
+ */
13
+ export declare const CLI_BIN_NAMES: readonly string[];
14
+ /**
15
+ * Returns the executable name the CLI was started as.
16
+ *
17
+ * Reads the basename of the script path (`process.argv[1]`). Anything that
18
+ * is not a known executable name — `node dist/src/bin/zudojs.js`, a Windows
19
+ * npm shim, a bundler's `index.js` — falls back to the canonical `zudojs`.
20
+ *
21
+ * @param scriptPath - Usually `process.argv[1]`.
22
+ * @param known - Accepted executable names.
23
+ */
24
+ export declare function resolveInvokedName(scriptPath: string | undefined, known?: readonly string[]): string;
25
+ /**
26
+ * Rewrites command examples in a message to use the name the user typed.
27
+ *
28
+ * Only `zudojs` directly followed by a command word is rewritten, so
29
+ * `zudojs-cli`, `@zudojs/core` and prose such as "the zudojs block in
30
+ * package.json" are left alone.
31
+ *
32
+ * @param text - The message to rewrite.
33
+ * @param displayName - The invoked executable name.
34
+ * @param commandWords - Registered command names and aliases.
35
+ */
36
+ export declare function localizeCommandName(text: string, displayName: string, commandWords: readonly string[]): string;
37
+ //# sourceMappingURL=invocation.name.d.ts.map
@@ -0,0 +1,69 @@
1
+ /**
2
+ * zudojs-cli — Invoked Name
3
+ *
4
+ * Works out which executable name the user typed (`zudojs` or `zudo`) so
5
+ * help, usage and error output can repeat it back.
6
+ */
7
+ import { basename } from "node:path";
8
+ import { CLI_NAME } from "../../cliConstant/cliConstant.value.js";
9
+ /**
10
+ * Executable names the CLI is installed under.
11
+ *
12
+ * `zudojs` is the canonical name; `zudo` is the short alias both the
13
+ * `zudojs-cli` and `zudojs` packages put on the PATH.
14
+ */
15
+ export const CLI_BIN_NAMES = Object.freeze([
16
+ CLI_NAME,
17
+ "zudo",
18
+ ]);
19
+ /** Script extensions stripped before the name is compared. */
20
+ const SCRIPT_EXTENSION = /\.(?:[cm]?[jt]s|cmd|ps1|exe)$/i;
21
+ /** Tokens that may follow the CLI name in a command example. */
22
+ const BUILTIN_WORDS = Object.freeze([
23
+ "help",
24
+ "version",
25
+ "--help",
26
+ "-h",
27
+ "--version",
28
+ "-v",
29
+ "<command>",
30
+ ]);
31
+ /**
32
+ * Returns the executable name the CLI was started as.
33
+ *
34
+ * Reads the basename of the script path (`process.argv[1]`). Anything that
35
+ * is not a known executable name — `node dist/src/bin/zudojs.js`, a Windows
36
+ * npm shim, a bundler's `index.js` — falls back to the canonical `zudojs`.
37
+ *
38
+ * @param scriptPath - Usually `process.argv[1]`.
39
+ * @param known - Accepted executable names.
40
+ */
41
+ export function resolveInvokedName(scriptPath, known = CLI_BIN_NAMES) {
42
+ if (!scriptPath)
43
+ return CLI_NAME;
44
+ const name = basename(scriptPath.replace(/\\/g, "/")).replace(SCRIPT_EXTENSION, "");
45
+ return known.includes(name) ? name : CLI_NAME;
46
+ }
47
+ /** Escapes a string for literal use inside a regular expression. */
48
+ function escapeRegExp(value) {
49
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
50
+ }
51
+ /**
52
+ * Rewrites command examples in a message to use the name the user typed.
53
+ *
54
+ * Only `zudojs` directly followed by a command word is rewritten, so
55
+ * `zudojs-cli`, `@zudojs/core` and prose such as "the zudojs block in
56
+ * package.json" are left alone.
57
+ *
58
+ * @param text - The message to rewrite.
59
+ * @param displayName - The invoked executable name.
60
+ * @param commandWords - Registered command names and aliases.
61
+ */
62
+ export function localizeCommandName(text, displayName, commandWords) {
63
+ if (displayName === CLI_NAME || !text.includes(CLI_NAME))
64
+ return text;
65
+ const words = [...commandWords, ...BUILTIN_WORDS].map(escapeRegExp);
66
+ const pattern = new RegExp(`(?<![\\w@/.-])${CLI_NAME}(?=\\s+(?:${words.join("|")})(?![\\w-]))`, "g");
67
+ return text.replace(pattern, displayName);
68
+ }
69
+ //# sourceMappingURL=invocation.name.js.map