@nexical/cli 0.1.7 → 0.11.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.
Files changed (241) hide show
  1. package/.github/workflows/deploy.yml +3 -3
  2. package/GEMINI.md +193 -0
  3. package/README.md +317 -104
  4. package/dist/chunk-JYASTIIW.js +42 -0
  5. package/dist/chunk-JYASTIIW.js.map +1 -0
  6. package/dist/chunk-LZ3YQWAR.js +2204 -0
  7. package/dist/chunk-LZ3YQWAR.js.map +1 -0
  8. package/dist/chunk-OKXOCNXP.js +105 -0
  9. package/dist/chunk-OKXOCNXP.js.map +1 -0
  10. package/dist/chunk-OYFWMYPG.js +52 -0
  11. package/dist/chunk-OYFWMYPG.js.map +1 -0
  12. package/dist/chunk-WKERTCM6.js +74 -0
  13. package/dist/chunk-WKERTCM6.js.map +1 -0
  14. package/dist/index.js +32 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/src/commands/init.d.ts +11 -0
  17. package/dist/src/commands/init.js +89 -0
  18. package/dist/src/commands/init.js.map +1 -0
  19. package/dist/src/commands/module/add.d.ts +14 -0
  20. package/dist/src/commands/module/add.js +136 -0
  21. package/dist/src/commands/module/add.js.map +1 -0
  22. package/dist/src/commands/module/list.d.ts +10 -0
  23. package/dist/src/commands/module/list.js +73 -0
  24. package/dist/src/commands/module/list.js.map +1 -0
  25. package/dist/src/commands/module/remove.d.ts +12 -0
  26. package/dist/src/commands/module/remove.js +71 -0
  27. package/dist/src/commands/module/remove.js.map +1 -0
  28. package/dist/src/commands/module/update.d.ts +11 -0
  29. package/dist/src/commands/module/update.js +52 -0
  30. package/dist/src/commands/module/update.js.map +1 -0
  31. package/dist/src/commands/run.d.ts +11 -0
  32. package/dist/src/commands/run.js +93 -0
  33. package/dist/src/commands/run.js.map +1 -0
  34. package/dist/src/commands/{login.d.ts → setup.d.ts} +2 -2
  35. package/dist/src/commands/setup.js +62 -0
  36. package/dist/src/commands/setup.js.map +1 -0
  37. package/dist/src/utils/discovery.d.ts +13 -0
  38. package/dist/src/utils/discovery.js +9 -0
  39. package/dist/src/utils/git.d.ts +16 -0
  40. package/dist/src/utils/git.js +29 -0
  41. package/dist/src/utils/git.js.map +1 -0
  42. package/dist/src/utils/url-resolver.d.ts +15 -0
  43. package/dist/src/utils/url-resolver.js +9 -0
  44. package/dist/src/utils/url-resolver.js.map +1 -0
  45. package/index.ts +29 -5
  46. package/package.json +32 -30
  47. package/src/commands/init.ts +86 -0
  48. package/src/commands/module/add.ts +169 -0
  49. package/src/commands/module/list.ts +69 -0
  50. package/src/commands/module/remove.ts +74 -0
  51. package/src/commands/module/update.ts +50 -0
  52. package/src/commands/run.ts +98 -0
  53. package/src/commands/setup.ts +74 -0
  54. package/src/utils/discovery.ts +134 -0
  55. package/src/utils/git.ts +65 -0
  56. package/src/utils/url-resolver.ts +57 -0
  57. package/test/e2e/lifecycle.e2e.test.ts +153 -0
  58. package/test/integration/commands/init.integration.test.ts +85 -0
  59. package/test/integration/commands/module.integration.test.ts +144 -0
  60. package/test/integration/commands/run.integration.test.ts +90 -0
  61. package/test/integration/utils/command-loading.integration.test.ts +80 -0
  62. package/test/unit/commands/init.test.ts +153 -0
  63. package/test/unit/commands/module/add.test.ts +262 -0
  64. package/test/unit/commands/module/list.test.ts +115 -0
  65. package/test/unit/commands/module/remove.test.ts +89 -0
  66. package/test/unit/commands/module/update.test.ts +91 -0
  67. package/test/unit/commands/run.test.ts +252 -0
  68. package/test/unit/commands/setup.test.ts +169 -0
  69. package/test/unit/utils/command-discovery.test.ts +176 -0
  70. package/test/unit/utils/git.test.ts +152 -0
  71. package/test/unit/utils/integration-helpers.test.ts +72 -0
  72. package/test/unit/utils/url-resolver.test.ts +39 -0
  73. package/test/utils/integration-helpers.ts +66 -0
  74. package/vitest.e2e.config.ts +0 -1
  75. package/dist/chunk-JDRAVUKK.js +0 -48
  76. package/dist/chunk-JDRAVUKK.js.map +0 -1
  77. package/dist/src/commands/admin/create-user.d.ts +0 -15
  78. package/dist/src/commands/admin/create-user.js +0 -49
  79. package/dist/src/commands/admin/create-user.js.map +0 -1
  80. package/dist/src/commands/branch/create.d.ts +0 -19
  81. package/dist/src/commands/branch/create.js +0 -59
  82. package/dist/src/commands/branch/create.js.map +0 -1
  83. package/dist/src/commands/branch/delete.d.ts +0 -15
  84. package/dist/src/commands/branch/delete.js +0 -50
  85. package/dist/src/commands/branch/delete.js.map +0 -1
  86. package/dist/src/commands/branch/get.d.ts +0 -15
  87. package/dist/src/commands/branch/get.js +0 -53
  88. package/dist/src/commands/branch/get.js.map +0 -1
  89. package/dist/src/commands/branch/list.d.ts +0 -15
  90. package/dist/src/commands/branch/list.js +0 -51
  91. package/dist/src/commands/branch/list.js.map +0 -1
  92. package/dist/src/commands/job/get.d.ts +0 -15
  93. package/dist/src/commands/job/get.js +0 -62
  94. package/dist/src/commands/job/get.js.map +0 -1
  95. package/dist/src/commands/job/list.d.ts +0 -15
  96. package/dist/src/commands/job/list.js +0 -57
  97. package/dist/src/commands/job/list.js.map +0 -1
  98. package/dist/src/commands/job/logs.d.ts +0 -15
  99. package/dist/src/commands/job/logs.js +0 -67
  100. package/dist/src/commands/job/logs.js.map +0 -1
  101. package/dist/src/commands/job/trigger.d.ts +0 -19
  102. package/dist/src/commands/job/trigger.js +0 -74
  103. package/dist/src/commands/job/trigger.js.map +0 -1
  104. package/dist/src/commands/login.js +0 -31
  105. package/dist/src/commands/login.js.map +0 -1
  106. package/dist/src/commands/project/create.d.ts +0 -24
  107. package/dist/src/commands/project/create.js +0 -63
  108. package/dist/src/commands/project/create.js.map +0 -1
  109. package/dist/src/commands/project/delete.d.ts +0 -20
  110. package/dist/src/commands/project/delete.js +0 -58
  111. package/dist/src/commands/project/delete.js.map +0 -1
  112. package/dist/src/commands/project/get.d.ts +0 -15
  113. package/dist/src/commands/project/get.js +0 -49
  114. package/dist/src/commands/project/get.js.map +0 -1
  115. package/dist/src/commands/project/list.d.ts +0 -15
  116. package/dist/src/commands/project/list.js +0 -45
  117. package/dist/src/commands/project/list.js.map +0 -1
  118. package/dist/src/commands/project/update.d.ts +0 -19
  119. package/dist/src/commands/project/update.js +0 -66
  120. package/dist/src/commands/project/update.js.map +0 -1
  121. package/dist/src/commands/team/create.d.ts +0 -19
  122. package/dist/src/commands/team/create.js +0 -45
  123. package/dist/src/commands/team/create.js.map +0 -1
  124. package/dist/src/commands/team/delete.d.ts +0 -20
  125. package/dist/src/commands/team/delete.js +0 -52
  126. package/dist/src/commands/team/delete.js.map +0 -1
  127. package/dist/src/commands/team/get.d.ts +0 -15
  128. package/dist/src/commands/team/get.js +0 -42
  129. package/dist/src/commands/team/get.js.map +0 -1
  130. package/dist/src/commands/team/list.d.ts +0 -8
  131. package/dist/src/commands/team/list.js +0 -30
  132. package/dist/src/commands/team/list.js.map +0 -1
  133. package/dist/src/commands/team/member/invite.d.ts +0 -20
  134. package/dist/src/commands/team/member/invite.js +0 -54
  135. package/dist/src/commands/team/member/invite.js.map +0 -1
  136. package/dist/src/commands/team/member/remove.d.ts +0 -15
  137. package/dist/src/commands/team/member/remove.js +0 -43
  138. package/dist/src/commands/team/member/remove.js.map +0 -1
  139. package/dist/src/commands/team/update.d.ts +0 -19
  140. package/dist/src/commands/team/update.js +0 -55
  141. package/dist/src/commands/team/update.js.map +0 -1
  142. package/dist/src/commands/token/generate.d.ts +0 -19
  143. package/dist/src/commands/token/generate.js +0 -48
  144. package/dist/src/commands/token/generate.js.map +0 -1
  145. package/dist/src/commands/token/list.d.ts +0 -8
  146. package/dist/src/commands/token/list.js +0 -31
  147. package/dist/src/commands/token/list.js.map +0 -1
  148. package/dist/src/commands/token/revoke.d.ts +0 -15
  149. package/dist/src/commands/token/revoke.js +0 -38
  150. package/dist/src/commands/token/revoke.js.map +0 -1
  151. package/dist/src/commands/whoami.d.ts +0 -8
  152. package/dist/src/commands/whoami.js +0 -26
  153. package/dist/src/commands/whoami.js.map +0 -1
  154. package/dist/src/utils/nexical-client.d.ts +0 -10
  155. package/dist/src/utils/nexical-client.js +0 -12
  156. package/src/commands/admin/create-user.ts +0 -46
  157. package/src/commands/branch/create.ts +0 -57
  158. package/src/commands/branch/delete.ts +0 -47
  159. package/src/commands/branch/get.ts +0 -50
  160. package/src/commands/branch/list.ts +0 -50
  161. package/src/commands/job/get.ts +0 -59
  162. package/src/commands/job/list.ts +0 -56
  163. package/src/commands/job/logs.ts +0 -67
  164. package/src/commands/job/trigger.ts +0 -73
  165. package/src/commands/login.ts +0 -31
  166. package/src/commands/project/create.ts +0 -61
  167. package/src/commands/project/delete.ts +0 -56
  168. package/src/commands/project/get.ts +0 -46
  169. package/src/commands/project/list.ts +0 -44
  170. package/src/commands/project/update.ts +0 -63
  171. package/src/commands/team/create.ts +0 -43
  172. package/src/commands/team/delete.ts +0 -50
  173. package/src/commands/team/get.ts +0 -39
  174. package/src/commands/team/list.ts +0 -26
  175. package/src/commands/team/member/invite.ts +0 -56
  176. package/src/commands/team/member/remove.ts +0 -40
  177. package/src/commands/team/update.ts +0 -53
  178. package/src/commands/token/generate.ts +0 -45
  179. package/src/commands/token/list.ts +0 -27
  180. package/src/commands/token/revoke.ts +0 -35
  181. package/src/commands/whoami.ts +0 -21
  182. package/src/utils/nexical-client.ts +0 -47
  183. package/test/e2e/auth.e2e.test.ts +0 -46
  184. package/test/e2e/job-workflow.e2e.test.ts +0 -33
  185. package/test/e2e/project-lifecycle.e2e.test.ts +0 -48
  186. package/test/e2e/setup.ts +0 -237
  187. package/test/e2e/utils.ts +0 -33
  188. package/test/integration/commands/admin/create-user.test.ts +0 -51
  189. package/test/integration/commands/branch/create.test.ts +0 -51
  190. package/test/integration/commands/branch/delete.test.ts +0 -43
  191. package/test/integration/commands/branch/get.test.ts +0 -49
  192. package/test/integration/commands/branch/list.test.ts +0 -47
  193. package/test/integration/commands/job/get.test.ts +0 -54
  194. package/test/integration/commands/job/list.test.ts +0 -47
  195. package/test/integration/commands/job/logs.test.ts +0 -47
  196. package/test/integration/commands/job/trigger.test.ts +0 -57
  197. package/test/integration/commands/login.test.ts +0 -62
  198. package/test/integration/commands/project/create.test.ts +0 -53
  199. package/test/integration/commands/project/delete.test.ts +0 -43
  200. package/test/integration/commands/project/get.test.ts +0 -51
  201. package/test/integration/commands/project/list.test.ts +0 -47
  202. package/test/integration/commands/project/update.test.ts +0 -53
  203. package/test/integration/commands/team/create.test.ts +0 -53
  204. package/test/integration/commands/team/delete.test.ts +0 -43
  205. package/test/integration/commands/team/get.test.ts +0 -50
  206. package/test/integration/commands/team/list.test.ts +0 -47
  207. package/test/integration/commands/team/member/invite.test.ts +0 -46
  208. package/test/integration/commands/team/member/remove.test.ts +0 -43
  209. package/test/integration/commands/team/update.test.ts +0 -50
  210. package/test/integration/commands/token/generate.test.ts +0 -51
  211. package/test/integration/commands/token/list.test.ts +0 -47
  212. package/test/integration/commands/token/revoke.test.ts +0 -43
  213. package/test/integration/commands/whoami.test.ts +0 -49
  214. package/test/unit/commands/admin/create-user.test.ts +0 -51
  215. package/test/unit/commands/branch/create.test.ts +0 -57
  216. package/test/unit/commands/branch/delete.test.ts +0 -49
  217. package/test/unit/commands/branch/get.test.ts +0 -67
  218. package/test/unit/commands/branch/list.test.ts +0 -62
  219. package/test/unit/commands/job/get.test.ts +0 -76
  220. package/test/unit/commands/job/list.test.ts +0 -62
  221. package/test/unit/commands/job/logs.test.ts +0 -60
  222. package/test/unit/commands/job/trigger.test.ts +0 -75
  223. package/test/unit/commands/login.test.ts +0 -64
  224. package/test/unit/commands/project/create.test.ts +0 -64
  225. package/test/unit/commands/project/delete.test.ts +0 -72
  226. package/test/unit/commands/project/get.test.ts +0 -73
  227. package/test/unit/commands/project/list.test.ts +0 -62
  228. package/test/unit/commands/project/update.test.ts +0 -58
  229. package/test/unit/commands/team/create.test.ts +0 -68
  230. package/test/unit/commands/team/delete.test.ts +0 -71
  231. package/test/unit/commands/team/get.test.ts +0 -70
  232. package/test/unit/commands/team/list.test.ts +0 -56
  233. package/test/unit/commands/team/member/invite.test.ts +0 -52
  234. package/test/unit/commands/team/member/remove.test.ts +0 -49
  235. package/test/unit/commands/team/update.test.ts +0 -63
  236. package/test/unit/commands/token/generate.test.ts +0 -65
  237. package/test/unit/commands/token/list.test.ts +0 -58
  238. package/test/unit/commands/token/revoke.test.ts +0 -49
  239. package/test/unit/commands/whoami.test.ts +0 -49
  240. package/test/unit/utils/nexical-client.test.ts +0 -113
  241. /package/dist/src/utils/{nexical-client.js.map → discovery.js.map} +0 -0
@@ -17,10 +17,10 @@ jobs:
17
17
  uses: actions/setup-node@v4
18
18
  with:
19
19
  node-version: 22
20
- registry-url: "https://registry.npmjs.org"
20
+ registry-url: 'https://registry.npmjs.org'
21
21
 
22
22
  - name: Install Dependencies
23
- run: npm ci
23
+ run: npm install
24
24
 
25
25
  - name: Build
26
26
  run: npm run build
@@ -31,4 +31,4 @@ jobs:
31
31
  - name: Publish to NPM
32
32
  run: npm publish --access public
33
33
  env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/GEMINI.md ADDED
@@ -0,0 +1,193 @@
1
+ # Nexical CLI Core Development Guide
2
+
3
+ This guide details how to build command libraries and CLIs using the `@nexical/cli-core` framework within this project.
4
+
5
+ ## Overview
6
+
7
+ The project is configured to use `@nexical/cli-core` as its CLI framework. usage entails:
8
+ 1. **Entry Point**: `index.ts` initializes the `CLI` instance.
9
+ 2. **Command Discovery**: The CLI automatically scans `src/commands` for command files.
10
+ 3. **Command Implementation**: Commands are TypeScript classes extending `BaseCommand`.
11
+
12
+ ## Directory Structure
13
+
14
+ Commands are defined in `src/commands`. The file structure directly maps to the command hierarchy.
15
+
16
+ | File Path | Command | Description |
17
+ | :--- | :--- | :--- |
18
+ | `src/commands/init.ts` | `app init` | Root level command |
19
+ | `src/commands/user/create.ts` | `app user create` | Subcommand |
20
+ | `src/commands/user/index.ts` | `app user` | Parent command handler (optional) |
21
+
22
+ > **Note**: The CLI name (`app`) is configured in `index.ts`.
23
+
24
+ ## Creating a New Command
25
+
26
+ To create a new command, add a `.ts` file in `src/commands`.
27
+
28
+ ### 1. Basic Command Template
29
+
30
+ Create `src/commands/hello.ts`:
31
+
32
+ ```typescript
33
+ import { BaseCommand } from '@nexical/cli-core';
34
+
35
+ export default class HelloCommand extends BaseCommand {
36
+ // Description displayed in help menus
37
+ static description = 'Prints a hello message';
38
+
39
+ // The main execution method
40
+ async run(options: any) {
41
+ this.success('Hello World!');
42
+ }
43
+ }
44
+ ```
45
+
46
+ **Run it:**
47
+ ```bash
48
+ npm run cli hello
49
+ ```
50
+
51
+ ### 2. Arguments and Options
52
+
53
+ Use the static `args` property to define inputs.
54
+
55
+ ```typescript
56
+ import { BaseCommand } from '@nexical/cli-core';
57
+
58
+ export default class GreetCommand extends BaseCommand {
59
+ static description = 'Greets a user';
60
+
61
+ static args = {
62
+ // Positional Arguments
63
+ args: [
64
+ {
65
+ name: 'name',
66
+ description: 'Name of the user',
67
+ required: true
68
+ }
69
+ ],
70
+ // Options (Flags)
71
+ options: [
72
+ {
73
+ name: '--loud',
74
+ description: 'Print in uppercase',
75
+ default: false
76
+ },
77
+ {
78
+ name: '-c, --count <n>',
79
+ description: 'Number of times to greet',
80
+ default: 1
81
+ }
82
+ ]
83
+ };
84
+
85
+ async run(options: any) {
86
+ // 'name' is mapped from args
87
+ // 'loud' and 'count' are mapped from options
88
+ const { name, loud, count } = options;
89
+
90
+ let message = `Hello, ${name}`;
91
+ if (loud) message = message.toUpperCase();
92
+
93
+ for(let i=0; i < count; i++) {
94
+ this.info(message);
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ **Run it:**
101
+ ```bash
102
+ npm run cli greet Adrian --loud --count 3
103
+ ```
104
+
105
+ ### 3. User Input & Prompts
106
+
107
+ `BaseCommand` provides built-in methods for interactivity.
108
+
109
+ ```typescript
110
+ export default class InteractiveCommand extends BaseCommand {
111
+ async run() {
112
+ // Simple confirmation or input
113
+ const name = await this.prompt('What is your name?');
114
+
115
+ this.success(`Nice to meet you, ${name}`);
116
+ }
117
+ }
118
+ ```
119
+
120
+ ### 4. Output Helpers
121
+
122
+ Use the built-in helper methods for consistent logging:
123
+
124
+ - `this.success(msg)`: Green checkmark (✔ Success)
125
+ - `this.error(msg)`: Red cross (✖ Error) - **Exits process**
126
+ - `this.warn(msg)`: Yellow warning (⚠ Warning)
127
+ - `this.info(msg)`: Standard log
128
+ - `this.notice(msg)`: Blue notice (📢 Note)
129
+ - `this.input(msg)`: Cyan input prompt (? Question)
130
+
131
+ ## Subcommands
132
+
133
+ To create grouped commands (e.g., `user create`, `user list`), use directories.
134
+
135
+ 1. **Create Directory**: `src/commands/user/`
136
+ 2. **Add Commands**:
137
+ * `src/commands/user/create.ts` -> `app user create`
138
+ * `src/commands/user/list.ts` -> `app user list`
139
+
140
+ ### Index Commands (Container Commands)
141
+
142
+ If you need the parent command `app user` to do something (or just provide a description for the group), create `src/commands/user/index.ts`.
143
+
144
+ ```typescript
145
+ // src/commands/user/index.ts
146
+ import { BaseCommand } from '@nexical/cli-core';
147
+
148
+ export default class UserCommand extends BaseCommand {
149
+ static description = 'Manage users';
150
+
151
+ async run() {
152
+ // This runs when user types 'app user' without a subcommand
153
+ // Often used to show help
154
+ this.cli.getRawCLI().outputHelp();
155
+ }
156
+ }
157
+ ```
158
+
159
+ ## Internal API Reference
160
+
161
+ ### `BaseCommand`
162
+
163
+ All commands inherit from `BaseCommand`.
164
+
165
+ **Properties:**
166
+ * `cli`: Access to the main `CLI` instance.
167
+ * `projectRoot`: Path to the project root (if detected).
168
+ * `config`: Loaded configuration from `{cliName}.yml`.
169
+ * `globalOptions`: Global flags passed to the CLI (e.g., `--debug`).
170
+
171
+ **Methods:**
172
+ * `init()`: Called before `run()`. Useful for setup.
173
+ * `run(options)`: Abstract method. Must be implemented.
174
+ * `prompt(message)`: Async, returns string.
175
+
176
+ **Static Properties:**
177
+ * `description`: String. Shown in help.
178
+ * `args`: Object. Defines arguments and options.
179
+ * `args`: Array of `{ name, description, required, default }`.
180
+ * `options`: Array of `{ name, description, default }`.
181
+ * `requiresProject`: Boolean. If true, command fails if not run inside a project with a config file.
182
+
183
+ ## Best Practices
184
+
185
+ 1. **Type Safety**: While `options` is `any` in `run()`, validate inputs early.
186
+ 2. **Error Handling**: Use `this.error()` for fatal errors to ensure proper exit codes.
187
+ 3. **Clean Output**: Use the helper methods (`success`, `info`, etc.) instead of `console.log` for a consistent UI.
188
+ 4. **Async**: The `run` method is async. Always `await` asynchronous operations.
189
+
190
+ ## Troubleshooting
191
+
192
+ * **Command not found**: Ensure the file exports a class leveraging `export default` and extends `BaseCommand`.
193
+ * **Changes not reflected**: If using `tsup`, ensure you are building or running in dev mode (`npm run dev`). For `npm run cli` using `ts-node` (via `cli.ts` or similar), changes should be instant.