@codiac.io/codiac-cli 1.3.181 → 1.3.182

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 (268) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/codiac-api/gen/client.d.ts +5 -1
  3. package/dist/apis/codiac-api/gen/client.js +12 -0
  4. package/dist/apis/codiac-api/gen/client.js.map +1 -1
  5. package/dist/apis/codiac-api/gen/contracts/types.gen.d.ts +25 -0
  6. package/dist/apis/codiac-api/gen/contracts/types.gen.js.map +1 -1
  7. package/dist/apis/codiac-api/i-client.d.ts +4 -0
  8. package/dist/apis/codiac-api-nats/gen/client.d.ts +4 -0
  9. package/dist/apis/codiac-api-nats/gen/client.js +17 -1
  10. package/dist/apis/codiac-api-nats/gen/client.js.map +1 -1
  11. package/dist/apis/codiac-api-nats/gen/contracts/types.gen.d.ts +25 -0
  12. package/dist/apis/codiac-api-nats/gen/contracts/types.gen.js.map +1 -1
  13. package/dist/apis/codiac-relay/gen/client.d.ts +16 -3
  14. package/dist/apis/codiac-relay/gen/client.js +58 -1
  15. package/dist/apis/codiac-relay/gen/client.js.map +1 -1
  16. package/dist/apis/codiac-relay/gen/contracts/types.gen.d.ts +173 -7
  17. package/dist/apis/codiac-relay/gen/contracts/types.gen.js.map +1 -1
  18. package/dist/apis/codiac-relay/i-client.d.ts +8 -0
  19. package/dist/apis/codiac-relay-nats/gen/client.d.ts +15 -7
  20. package/dist/apis/codiac-relay-nats/gen/client.js +86 -19
  21. package/dist/apis/codiac-relay-nats/gen/client.js.map +1 -1
  22. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.d.ts +151 -15
  23. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js +4 -4
  24. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js.map +1 -1
  25. package/dist/apis/codiac-relay-nats/gen/contracts.ng.d.ts +6 -0
  26. package/dist/apis/codiac-relay-nats/gen/contracts.ng.js +1 -0
  27. package/dist/apis/codiac-relay-nats/gen/contracts.ng.js.map +1 -1
  28. package/dist/bootstrapper-for-api-clients.js +14 -2
  29. package/dist/bootstrapper-for-api-clients.js.map +1 -1
  30. package/dist/cli-common/built-in-cli-user-input.d.ts +2 -1
  31. package/dist/cli-common/built-in-cli-user-input.js +52 -1
  32. package/dist/cli-common/built-in-cli-user-input.js.map +1 -1
  33. package/dist/cli-common/entities/prompt-choice.d.ts +2 -7
  34. package/dist/cli-common/mock-ui.d.ts +2 -1
  35. package/dist/cli-common/mock-ui.js +3 -0
  36. package/dist/cli-common/mock-ui.js.map +1 -1
  37. package/dist/codiac-constants.d.ts +3 -0
  38. package/dist/codiac-constants.js +3 -0
  39. package/dist/codiac-constants.js.map +1 -1
  40. package/dist/command-base-enterprise.d.ts +23 -2
  41. package/dist/command-base-enterprise.js +82 -26
  42. package/dist/command-base-enterprise.js.map +1 -1
  43. package/dist/command-base-exec.js +4 -2
  44. package/dist/command-base-exec.js.map +1 -1
  45. package/dist/commands/asset/deploy.d.ts +2 -1
  46. package/dist/commands/asset/deploy.js +3 -2
  47. package/dist/commands/asset/deploy.js.map +1 -1
  48. package/dist/commands/asset/list.d.ts +26 -7
  49. package/dist/commands/asset/list.js +127 -112
  50. package/dist/commands/asset/list.js.map +1 -1
  51. package/dist/commands/asset/probe/create.d.ts +26 -5
  52. package/dist/commands/asset/probe/create.js +182 -164
  53. package/dist/commands/asset/probe/create.js.map +1 -1
  54. package/dist/commands/asset/recycle.js +3 -4
  55. package/dist/commands/asset/recycle.js.map +1 -1
  56. package/dist/commands/asset/undeploy.d.ts +24 -9
  57. package/dist/commands/asset/undeploy.js +162 -161
  58. package/dist/commands/asset/undeploy.js.map +1 -1
  59. package/dist/commands/asset/view.js +1 -1
  60. package/dist/commands/asset/view.js.map +1 -1
  61. package/dist/commands/asset/volume/create.d.ts +24 -13
  62. package/dist/commands/asset/volume/create.js +153 -158
  63. package/dist/commands/asset/volume/create.js.map +1 -1
  64. package/dist/commands/asset/volume/delete.d.ts +21 -7
  65. package/dist/commands/asset/volume/delete.js +107 -101
  66. package/dist/commands/asset/volume/delete.js.map +1 -1
  67. package/dist/commands/asset/volume/list.d.ts +23 -9
  68. package/dist/commands/asset/volume/list.js +74 -54
  69. package/dist/commands/asset/volume/list.js.map +1 -1
  70. package/dist/commands/cabinet/cluster/attach.d.ts +32 -0
  71. package/dist/commands/cabinet/cluster/attach.js +144 -0
  72. package/dist/commands/cabinet/cluster/attach.js.map +1 -0
  73. package/dist/commands/cabinet/create.d.ts +1 -0
  74. package/dist/commands/cabinet/create.js +5 -1
  75. package/dist/commands/cabinet/create.js.map +1 -1
  76. package/dist/commands/cabinet/list.d.ts +27 -6
  77. package/dist/commands/cabinet/list.js +130 -121
  78. package/dist/commands/cabinet/list.js.map +1 -1
  79. package/dist/commands/cabinet/obliterate.d.ts +1 -0
  80. package/dist/commands/cabinet/obliterate.js +5 -1
  81. package/dist/commands/cabinet/obliterate.js.map +1 -1
  82. package/dist/commands/cabinet/restore.d.ts +36 -0
  83. package/dist/commands/cabinet/restore.js +186 -0
  84. package/dist/commands/cabinet/restore.js.map +1 -0
  85. package/dist/commands/cluster/agent/configure.d.ts +47 -0
  86. package/dist/commands/cluster/agent/configure.js +320 -0
  87. package/dist/commands/cluster/agent/configure.js.map +1 -0
  88. package/dist/commands/cluster/agent/install.d.ts +32 -0
  89. package/dist/commands/cluster/agent/install.js +152 -0
  90. package/dist/commands/cluster/agent/install.js.map +1 -0
  91. package/dist/commands/cluster/agent/uninstall.d.ts +29 -0
  92. package/dist/commands/cluster/agent/uninstall.js +130 -0
  93. package/dist/commands/cluster/agent/uninstall.js.map +1 -0
  94. package/dist/commands/cluster/bootstrap.d.ts +50 -0
  95. package/dist/commands/cluster/bootstrap.js +310 -0
  96. package/dist/commands/cluster/bootstrap.js.map +1 -0
  97. package/dist/commands/cluster/connect.d.ts +0 -5
  98. package/dist/commands/cluster/connect.js +1 -26
  99. package/dist/commands/cluster/connect.js.map +1 -1
  100. package/dist/commands/cluster/install.d.ts +45 -0
  101. package/dist/commands/cluster/install.js +224 -0
  102. package/dist/commands/cluster/install.js.map +1 -0
  103. package/dist/commands/cluster/stack/capture.js +0 -2
  104. package/dist/commands/cluster/stack/capture.js.map +1 -1
  105. package/dist/commands/cluster/stack/install.d.ts +40 -0
  106. package/dist/commands/cluster/stack/install.js +196 -0
  107. package/dist/commands/cluster/stack/install.js.map +1 -0
  108. package/dist/commands/cluster/start.d.ts +0 -5
  109. package/dist/commands/cluster/start.js +1 -27
  110. package/dist/commands/cluster/start.js.map +1 -1
  111. package/dist/commands/cluster/stop.d.ts +0 -5
  112. package/dist/commands/cluster/stop.js +1 -27
  113. package/dist/commands/cluster/stop.js.map +1 -1
  114. package/dist/commands/config/add.d.ts +9 -11
  115. package/dist/commands/config/add.js +59 -125
  116. package/dist/commands/config/add.js.map +1 -1
  117. package/dist/commands/config/delete.d.ts +22 -11
  118. package/dist/commands/config/delete.js +28 -83
  119. package/dist/commands/config/delete.js.map +1 -1
  120. package/dist/commands/config/deploy.d.ts +26 -8
  121. package/dist/commands/config/deploy.js +169 -198
  122. package/dist/commands/config/deploy.js.map +1 -1
  123. package/dist/commands/config/import.d.ts +27 -22
  124. package/dist/commands/config/import.js +222 -253
  125. package/dist/commands/config/import.js.map +1 -1
  126. package/dist/commands/config/settings/get.d.ts +25 -14
  127. package/dist/commands/config/settings/get.js +30 -123
  128. package/dist/commands/config/settings/get.js.map +1 -1
  129. package/dist/commands/config/view.d.ts +26 -6
  130. package/dist/commands/config/view.js +112 -95
  131. package/dist/commands/config/view.js.map +1 -1
  132. package/dist/commands/csp/logout.d.ts +23 -6
  133. package/dist/commands/csp/logout.js +86 -63
  134. package/dist/commands/csp/logout.js.map +1 -1
  135. package/dist/commands/deploy.d.ts +31 -14
  136. package/dist/commands/deploy.js +264 -385
  137. package/dist/commands/deploy.js.map +1 -1
  138. package/dist/commands/enterprise/list.d.ts +22 -4
  139. package/dist/commands/enterprise/list.js +97 -67
  140. package/dist/commands/enterprise/list.js.map +1 -1
  141. package/dist/commands/env/add.d.ts +26 -7
  142. package/dist/commands/env/add.js +182 -179
  143. package/dist/commands/env/add.js.map +1 -1
  144. package/dist/commands/environment/cluster/attach.d.ts +1 -0
  145. package/dist/commands/environment/cluster/attach.js +5 -1
  146. package/dist/commands/environment/cluster/attach.js.map +1 -1
  147. package/dist/commands/environment/cluster/detach.d.ts +1 -0
  148. package/dist/commands/environment/cluster/detach.js +5 -1
  149. package/dist/commands/environment/cluster/detach.js.map +1 -1
  150. package/dist/commands/environment/create.d.ts +1 -0
  151. package/dist/commands/environment/create.js +5 -1
  152. package/dist/commands/environment/create.js.map +1 -1
  153. package/dist/commands/environment/delete.d.ts +39 -0
  154. package/dist/commands/environment/delete.js +135 -0
  155. package/dist/commands/environment/delete.js.map +1 -0
  156. package/dist/commands/environment/list.d.ts +28 -9
  157. package/dist/commands/environment/list.js +128 -167
  158. package/dist/commands/environment/list.js.map +1 -1
  159. package/dist/commands/host/map.d.ts +29 -19
  160. package/dist/commands/host/map.js +263 -324
  161. package/dist/commands/host/map.js.map +1 -1
  162. package/dist/commands/imageRegistry/capture.d.ts +12 -11
  163. package/dist/commands/imageRegistry/capture.js +49 -113
  164. package/dist/commands/imageRegistry/capture.js.map +1 -1
  165. package/dist/commands/imageRegistry/forget.d.ts +12 -11
  166. package/dist/commands/imageRegistry/forget.js +53 -114
  167. package/dist/commands/imageRegistry/forget.js.map +1 -1
  168. package/dist/commands/imageRegistry/pullSecret/set.d.ts +21 -11
  169. package/dist/commands/imageRegistry/pullSecret/set.js +184 -278
  170. package/dist/commands/imageRegistry/pullSecret/set.js.map +1 -1
  171. package/dist/commands/imageRegistry/pullSecret/unset.d.ts +19 -11
  172. package/dist/commands/imageRegistry/pullSecret/unset.js +117 -190
  173. package/dist/commands/imageRegistry/pullSecret/unset.js.map +1 -1
  174. package/dist/commands/images/add.d.ts +19 -6
  175. package/dist/commands/images/add.js +63 -53
  176. package/dist/commands/images/add.js.map +1 -1
  177. package/dist/commands/kit/create.d.ts +22 -10
  178. package/dist/commands/kit/create.js +119 -121
  179. package/dist/commands/kit/create.js.map +1 -1
  180. package/dist/commands/logout.d.ts +21 -5
  181. package/dist/commands/logout.js +44 -25
  182. package/dist/commands/logout.js.map +1 -1
  183. package/dist/commands/noc/cluster/create.js +22 -10
  184. package/dist/commands/noc/cluster/create.js.map +1 -1
  185. package/dist/commands/noc/cluster/credentials-set.d.ts +38 -0
  186. package/dist/commands/noc/cluster/credentials-set.js +174 -0
  187. package/dist/commands/noc/cluster/credentials-set.js.map +1 -0
  188. package/dist/commands/noc/cluster/define.d.ts +46 -0
  189. package/dist/commands/noc/cluster/define.js +305 -0
  190. package/dist/commands/noc/cluster/define.js.map +1 -0
  191. package/dist/commands/noc/cluster/deinit.d.ts +22 -5
  192. package/dist/commands/noc/cluster/deinit.js +99 -106
  193. package/dist/commands/noc/cluster/deinit.js.map +1 -1
  194. package/dist/commands/noc/cluster/forget.js +2 -4
  195. package/dist/commands/noc/cluster/forget.js.map +1 -1
  196. package/dist/commands/noc/cluster/grant.d.ts +20 -11
  197. package/dist/commands/noc/cluster/grant.js +94 -132
  198. package/dist/commands/noc/cluster/grant.js.map +1 -1
  199. package/dist/commands/noc/cluster/init.d.ts +25 -7
  200. package/dist/commands/noc/cluster/init.js +121 -133
  201. package/dist/commands/noc/cluster/init.js.map +1 -1
  202. package/dist/commands/noc/cluster/journal.d.ts +0 -5
  203. package/dist/commands/noc/cluster/journal.js +1 -26
  204. package/dist/commands/noc/cluster/journal.js.map +1 -1
  205. package/dist/commands/noc/cluster/list.d.ts +23 -5
  206. package/dist/commands/noc/cluster/list.js +107 -111
  207. package/dist/commands/noc/cluster/list.js.map +1 -1
  208. package/dist/commands/noc/cluster/restore.d.ts +36 -0
  209. package/dist/commands/noc/cluster/restore.js +196 -0
  210. package/dist/commands/noc/cluster/restore.js.map +1 -0
  211. package/dist/commands/portal.d.ts +21 -5
  212. package/dist/commands/portal.js +37 -36
  213. package/dist/commands/portal.js.map +1 -1
  214. package/dist/commands/secretStore/capture.d.ts +13 -11
  215. package/dist/commands/secretStore/capture.js +63 -123
  216. package/dist/commands/secretStore/capture.js.map +1 -1
  217. package/dist/commands/secretStore/forget.d.ts +13 -11
  218. package/dist/commands/secretStore/forget.js +55 -111
  219. package/dist/commands/secretStore/forget.js.map +1 -1
  220. package/dist/commands/shell/init.d.ts +15 -0
  221. package/dist/commands/shell/init.js +96 -0
  222. package/dist/commands/shell/init.js.map +1 -0
  223. package/dist/commands/snapshot/deploy.d.ts +22 -42
  224. package/dist/commands/snapshot/deploy.js +173 -269
  225. package/dist/commands/snapshot/deploy.js.map +1 -1
  226. package/dist/commands/snapshot/list.d.ts +26 -5
  227. package/dist/commands/snapshot/list.js +116 -109
  228. package/dist/commands/snapshot/list.js.map +1 -1
  229. package/dist/commands/tenant/create.d.ts +18 -13
  230. package/dist/commands/tenant/create.js +69 -69
  231. package/dist/commands/tenant/create.js.map +1 -1
  232. package/dist/commands/tenant/switch.d.ts +18 -12
  233. package/dist/commands/tenant/switch.js +65 -59
  234. package/dist/commands/tenant/switch.js.map +1 -1
  235. package/dist/commands/whereami.d.ts +18 -8
  236. package/dist/commands/whereami.js +67 -102
  237. package/dist/commands/whereami.js.map +1 -1
  238. package/dist/commands/whoami.d.ts +19 -3
  239. package/dist/commands/whoami.js +44 -13
  240. package/dist/commands/whoami.js.map +1 -1
  241. package/dist/ops/i-user-input-provider.d.ts +20 -1
  242. package/dist/ops/i-user-input-provider.js.map +1 -1
  243. package/dist/ops/test/mock-ui.d.ts +2 -1
  244. package/dist/ops/test/mock-ui.js +3 -0
  245. package/dist/ops/test/mock-ui.js.map +1 -1
  246. package/dist/ops/throwing-user-input-provider.d.ts +2 -1
  247. package/dist/ops/throwing-user-input-provider.js +3 -0
  248. package/dist/ops/throwing-user-input-provider.js.map +1 -1
  249. package/dist/relay/relay-container.js +1 -1
  250. package/dist/uilogic/lrp-watcher-predef.d.ts +2 -1
  251. package/dist/uilogic/lrp-watcher-predef.js +31 -17
  252. package/dist/uilogic/lrp-watcher-predef.js.map +1 -1
  253. package/dist/uilogic/lrp-watcher-utils.d.ts +2 -0
  254. package/dist/uilogic/lrp-watcher-utils.js +2 -0
  255. package/dist/uilogic/lrp-watcher-utils.js.map +1 -1
  256. package/dist/uilogic/rootmap-ui-utils.d.ts +18 -1
  257. package/dist/uilogic/rootmap-ui-utils.js +30 -0
  258. package/dist/uilogic/rootmap-ui-utils.js.map +1 -1
  259. package/dist/uilogic/tenant-contextualizer.js +11 -1
  260. package/dist/uilogic/tenant-contextualizer.js.map +1 -1
  261. package/dist/user-context-loader.d.ts +12 -7
  262. package/dist/user-context-loader.js +89 -43
  263. package/dist/user-context-loader.js.map +1 -1
  264. package/oclif.manifest.json +3981 -1450
  265. package/package.json +2 -2
  266. package/dist/commands/noc/cluster/recreate.d.ts +0 -28
  267. package/dist/commands/noc/cluster/recreate.js +0 -197
  268. package/dist/commands/noc/cluster/recreate.js.map +0 -1
@@ -3,76 +3,82 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  require("reflect-metadata");
5
5
  const core_1 = require("@oclif/core");
6
- const cli_common_1 = require("../../cli-common");
7
- const command_base_enterprise_1 = require("../../command-base-enterprise");
6
+ const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
8
7
  const uilogic_1 = require("../../uilogic");
9
8
  const ops_1 = require("../../ops");
10
- class TenantCreate extends command_base_enterprise_1.CommandBaseEnterprise {
11
- run() {
9
+ const config_ui_utils_1 = require("../../uilogic/config-ui-utils");
10
+ class TenantSwitch extends command_base_exec_tenant_1.CommandBaseExecTenant {
11
+ captureArgs() {
12
+ var _a, _b;
12
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- try {
14
- this.bootstrap();
15
- const { args, flags } = yield this.parse(TenantCreate);
16
- if (this._projCfg && this._projCfg.tenantCode !== undefined && this._projCfg.tenantCode !== ops_1.DxConstants.UNREGISTERED_TENANT_CODE) {
17
- // this._ui.userMessage(`Cannot switch tenant from within a project folder.`)
18
- throw new Error(`Current tenant [${this._styler.hilite(this._projCfg.tenantCode)}]; cannot switch tenant from this folder; it exists within a workspace declared for that tenant (see the nearest codiac.json file).`);
19
- }
20
- // this._userCntx = await this.promptForNewTenant(this._userCntx, contextor);
21
- let contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
22
- this._userCntx = yield this.establishTenantContext(this._userCntx, contextor);
23
- let newCntx;
24
- if (args.code) {
25
- newCntx = yield contextor.trySwitchTenant(this._userCntx, args.code);
26
- }
27
- newCntx = newCntx !== null && newCntx !== void 0 ? newCntx : yield contextor.trySelectFromMyTenants(this._userCntx, false);
28
- if (newCntx !== undefined) {
29
- this._userCntx = newCntx;
30
- this.bindUserInIoc(this._userCntx);
31
- if (this._userCntx.currentTenantCode) {
32
- this._ui.userMessage(`Switched to tenant [${this._styler.hilite(this._userCntx.currentTenantCode)}]`);
33
- }
34
- else {
35
- this._ui.userMessage(`Current user context is tenant-less.`);
36
- }
37
- }
14
+ const { flags } = yield this.parse(TenantSwitch);
15
+ if (this._projCfg && this._projCfg.tenantCode !== undefined && this._projCfg.tenantCode !== ops_1.DxConstants.UNREGISTERED_TENANT_CODE) {
16
+ throw new Error(`Current tenant [${this._styler.hilite(this._projCfg.tenantCode)}]; cannot switch tenant from this folder; it exists within a workspace declared for that tenant (see the nearest codiac.json file).`);
38
17
  }
39
- catch (err) {
40
- this.handleError(err);
41
- }
42
- finally {
43
- yield this.closeConnections();
44
- return;
18
+ const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
19
+ return [{}, interactionMode, false];
20
+ });
21
+ }
22
+ buildCandidate_silently(_partial, _rootMap) {
23
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ const { args } = yield this.parse(TenantSwitch);
25
+ if (!args.code)
26
+ throw new Error(`Tenant code argument is required in silent mode.`);
27
+ const contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
28
+ const newContext = yield contextor.trySwitchTenant(this._userCntx, args.code);
29
+ if (!newContext)
30
+ throw new Error(`Failed to switch to tenant [${args.code}].`);
31
+ return { newContext };
32
+ });
33
+ }
34
+ buildCandidate_interactively(_partial, _takeDefaults, _rootMap) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ const { args } = yield this.parse(TenantSwitch);
37
+ const contextor = new uilogic_1.TenantContextualizer(this.cliEnviro, this._projCfg, this.authClient, this.projCfgRepo, this._ui, this._styler, this.logger);
38
+ let newContext;
39
+ if (args.code) {
40
+ newContext = yield contextor.trySwitchTenant(this._userCntx, args.code);
45
41
  }
42
+ newContext = newContext !== null && newContext !== void 0 ? newContext : yield contextor.trySelectFromMyTenants(this._userCntx, false);
43
+ if (!newContext)
44
+ return undefined;
45
+ return { newContext };
46
46
  });
47
47
  }
48
- /** Logs the user in as needed, and persists the new context object to the local machine. */
49
- promptForNewTenant(currentContext, contextor) {
48
+ buildCommandString(candidate, cmd) {
49
+ if (candidate.newContext.currentTenantCode)
50
+ cmd.push(candidate.newContext.currentTenantCode);
51
+ cmd.push("--silent");
52
+ return cmd;
53
+ }
54
+ executeTask(candidate) {
50
55
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
- return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
52
- try {
53
- let cntx = yield contextor.tryRegisterNewTenant(currentContext);
54
- if (cntx == undefined) {
55
- // this._ui.userMessage(`${this._styler.colorCritical("ERROR")} Unable to create a new Tenant`);
56
- throw new Error(`${this._styler.colorCritical("ERROR")} Unable to create a new Tenant`);
57
- }
58
- else {
59
- if (cntx.currentToken)
60
- this._codiacApi.setUserToken(cntx.currentToken); // why isnt this being done by the contextualizer?
61
- this.bindUserInIoc(cntx);
62
- }
63
- resolve(cntx);
64
- }
65
- catch (err) {
66
- reject(err);
67
- }
68
- }));
56
+ this._userCntx = candidate.newContext;
57
+ this.bindUserInIoc(this._userCntx);
58
+ if (this._userCntx.currentTenantCode) {
59
+ this._ui.userMessage(`Switched to tenant [${this._styler.hilite(this._userCntx.currentTenantCode)}]`);
60
+ }
61
+ else {
62
+ this._ui.userMessage(`Current user context is tenant-less.`);
63
+ }
69
64
  });
70
65
  }
71
66
  }
72
- exports.default = TenantCreate;
73
- TenantCreate.description = "Sets a different tenant context from the current user's list of tenants.";
74
- TenantCreate.args = {
67
+ exports.default = TenantSwitch;
68
+ TenantSwitch.description = "Sets a different tenant context from the current user's list of tenants.";
69
+ TenantSwitch.args = {
75
70
  code: core_1.Args.string({ required: false, description: 'The unique string identifying the tenant to switch to.' })
76
71
  };
77
- TenantCreate.flags = Object.assign(Object.assign({}, cli_common_1.commandBase.globalFlags), { help: core_1.Flags.help({ char: 'h' }) });
72
+ TenantSwitch.flags = {
73
+ help: core_1.Flags.help({ char: 'h' }),
74
+ silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
75
+ echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
76
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
77
+ };
78
+ TenantSwitch.examples = [
79
+ { description: "Switch tenant interactively.", command: "<%= config.bin %> <%= command.id %>" },
80
+ { description: "Switch to a specific tenant.", command: "<%= config.bin %> <%= command.id %> my-tenant-code" },
81
+ { description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> my-tenant-code --silent" },
82
+ { description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> my-tenant-code --to-script" },
83
+ ];
78
84
  //# sourceMappingURL=switch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/tenant/switch.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,sCAA0C;AAC1C,iDAA+C;AAC/C,2EAAqE;AAErE,2CAAqD;AAErD,mCAAwC;AAExC,MAAqB,YAAa,SAAQ,+CAAqB;IAYvD,GAAG;;YACP,IAAI;gBACF,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;gBAEvD,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,iBAAW,CAAC,wBAAwB,EAAE;oBAChI,6EAA6E;oBAC7E,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,qIAAqI,CAAC,CAAC;iBACxN;gBAED,6EAA6E;gBAC7E,IAAI,SAAS,GAAG,IAAI,8BAAoB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBAChJ,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAE9E,IAAI,OAAgC,CAAC;gBACrC,IAAI,IAAI,CAAC,IAAI,EAAE;oBACb,OAAO,GAAG,MAAM,SA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enterprise';
2
- export default class Whereami extends CommandBaseEnterprise {
1
+ import { Command } from '@oclif/core';
2
+ import { RootMap } from '../apis/codiac-api/contracts';
3
+ import { CommandBaseExecTenant } from '../command-base-exec-tenant';
4
+ import { InteractionModes } from '../uilogic/config-ui-utils';
5
+ type WhereAmIRequest = {
6
+ _?: never;
7
+ };
8
+ export default class Whereami extends CommandBaseExecTenant<WhereAmIRequest> {
3
9
  static description: string;
4
10
  static flags: {
5
11
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
- name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
- force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
15
  };
9
16
  static args: {};
10
- run(): Promise<void>;
11
- /** Returns undefined if the cabinet has no environment
12
- * (undefined should never happen but if such a data issue existed, it would be VERY helpful to know about it here).
13
- * On error, this method logs the error and returns ERROR_INDICATOR as output. */
17
+ static examples: Command.Example[];
18
+ captureArgs(): Promise<[Partial<WhereAmIRequest>, InteractionModes | undefined, boolean]>;
19
+ buildCandidate_silently(partial: Partial<WhereAmIRequest>, rootMap: RootMap): Promise<WhereAmIRequest | undefined>;
20
+ buildCandidate_interactively(partial: Partial<WhereAmIRequest>, takeDefaults: boolean, rootMap: RootMap): Promise<WhereAmIRequest | undefined>;
21
+ buildCommandString(candidate: WhereAmIRequest, cmd: string[]): string[];
22
+ executeTask(candidate: WhereAmIRequest): Promise<void>;
14
23
  private getEnvironmentFor;
15
24
  }
25
+ export {};
@@ -2,114 +2,75 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
- const command_base_enterprise_1 = require("../command-base-enterprise");
5
+ const command_base_exec_tenant_1 = require("../command-base-exec-tenant");
6
6
  const codiac_constants_1 = require("../codiac-constants");
7
7
  const prettify_1 = require("../prettify");
8
- class Whereami extends command_base_enterprise_1.CommandBaseEnterprise {
9
- run() {
8
+ const config_ui_utils_1 = require("../uilogic/config-ui-utils");
9
+ class Whereami extends command_base_exec_tenant_1.CommandBaseExecTenant {
10
+ captureArgs() {
11
+ var _a, _b;
10
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- var _a, _b, _c;
13
- try {
14
- this.bootstrap();
15
- const { args, flags } = yield this.parse(Whereami);
16
- let bindings = {
17
- tenant: (_b = (_a = this._projCfg) === null || _a === void 0 ? void 0 : _a.tenantCode) !== null && _b !== void 0 ? _b : this._userCntx.currentTenantCode
18
- // , currentBranch: await this._ops.gitCurrentBranchNameFor(this._projectRoot)
19
- };
20
- if ((_c = this._projUserCfg) === null || _c === void 0 ? void 0 : _c.enterprise) {
21
- bindings.enterprise = this._projUserCfg.enterprise.enterpriseCode;
22
- if (this._projUserCfg.enterprise.cabinet) {
23
- let environment = yield this.getEnvironmentFor(this._projUserCfg.enterprise.cabinet.cabinet);
24
- bindings.environment = environment || "[unassigned]";
25
- bindings.cabinet = this._projUserCfg.enterprise.cabinet.cabinet;
26
- // bindings.cabinetBranch = this._projUserCfg.enterprise.cabinet.branch; // Support was never built for cabinet branch bindings, and now it's in the way (#wannabeagile).
27
- }
28
- if (this._projUserCfg.enterprise.assetBindings && this._projUserCfg.enterprise.assetBindings.length > 0) {
29
- bindings.assets = [];
30
- for (let assetBinding of this._projUserCfg.enterprise.assetBindings) {
31
- bindings.assets.push({
32
- asset: assetBinding.incarnation.assetName,
33
- image: assetBinding.image.name
34
- });
35
- }
36
- }
37
- }
38
- this._ui.userMessage((0, prettify_1.prettify)(bindings));
39
- /* Cheap-ass requirement doc below:
40
-
41
- Jun 4, 2020
42
- Ben 11:17 AM
43
- i need to know which enviroment im in
44
- or at least, which environment you built against
45
-
46
- Mark Freydl 11:18 AM
47
- there’s an enterprise context that gets stored in the project-user config file (edited)
48
- that states the current enterprise, cabinet and asset bindings that the user is pointing the project to (all that is based on gthe branch and cabinet-to-bramch binding, so it’s not source code 0- it’s local state)
49
-
50
- Ben 11:20 AM
51
- yeah, that works
52
- forgot we have in the domain
53
- that'd be a fun whoami
54
-
55
- Mark Freydl 11:21 AM
56
- Every time I work with Environment, I keep thinking that it doesnt have any real purpose other than being a tag
57
- good idea
58
- maybe a “whereami”
59
-
60
- Ben 11:21 AM
61
- fuck yes dude
62
-
63
- Mark Freydl 11:21 AM
64
- returns your enteprise context
65
- and branch maybe
66
-
67
- Ben 11:22 AM
68
- always right, easy to access, i like it
69
-
70
- Mark Freydl 11:27 AM
71
- You should write that one.
72
- it shd be easy - just need to use the cfgRepo to load the projectUser config and prob localOps to get the current branch info
73
-
74
- Ben 11:30 AM
75
- i'd be happy to.
76
-
77
- */
78
- resolve();
79
- }
80
- catch (err) {
81
- reject(err);
13
+ const { flags } = yield this.parse(Whereami);
14
+ const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
15
+ return [{}, interactionMode, false];
16
+ });
17
+ }
18
+ buildCandidate_silently(partial, rootMap) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ return {};
21
+ });
22
+ }
23
+ buildCandidate_interactively(partial, takeDefaults, rootMap) {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ return {};
26
+ });
27
+ }
28
+ buildCommandString(candidate, cmd) {
29
+ cmd.push("--silent");
30
+ return cmd;
31
+ }
32
+ executeTask(candidate) {
33
+ var _a, _b, _c;
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
+ let bindings = {
36
+ tenant: (_b = (_a = this._projCfg) === null || _a === void 0 ? void 0 : _a.tenantCode) !== null && _b !== void 0 ? _b : this._userCntx.currentTenantCode
37
+ };
38
+ if ((_c = this._projUserCfg) === null || _c === void 0 ? void 0 : _c.enterprise) {
39
+ bindings.enterprise = this._projUserCfg.enterprise.enterpriseCode;
40
+ if (this._projUserCfg.enterprise.cabinet) {
41
+ let environment = yield this.getEnvironmentFor(this._projUserCfg.enterprise.cabinet.cabinet);
42
+ bindings.environment = environment || "[unassigned]";
43
+ bindings.cabinet = this._projUserCfg.enterprise.cabinet.cabinet;
82
44
  }
83
- finally {
84
- yield this.closeConnections();
45
+ if (this._projUserCfg.enterprise.assetBindings && this._projUserCfg.enterprise.assetBindings.length > 0) {
46
+ bindings.assets = [];
47
+ for (let assetBinding of this._projUserCfg.enterprise.assetBindings) {
48
+ bindings.assets.push({
49
+ asset: assetBinding.incarnation.assetName,
50
+ image: assetBinding.image.name
51
+ });
52
+ }
85
53
  }
86
- }));
54
+ }
55
+ this._ui.userMessage((0, prettify_1.prettify)(bindings));
87
56
  });
88
57
  }
89
- /** Returns undefined if the cabinet has no environment
90
- * (undefined should never happen but if such a data issue existed, it would be VERY helpful to know about it here).
91
- * On error, this method logs the error and returns ERROR_INDICATOR as output. */
92
58
  getEnvironmentFor(cabinet) {
93
59
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
94
- return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
95
- let environment;
96
- try {
97
- let result = yield this._codiacApi.Cabinet.tryReadMany({ name: { $eq: cabinet } });
98
- if (result.error)
99
- throw result.error;
100
- else if (result.output && result.output.length > 0) {
101
- environment = result.output[0].environment;
102
- }
103
- }
104
- catch (err) {
105
- this.logger.debug(`Error retrieving environment for cabinet [${cabinet}, tenant: ${this._userCntx.currentTenantCode}]: ${err.name || ""} ${err.message || ""}`, err);
106
- environment = codiac_constants_1.ERROR_INDICATOR;
107
- }
108
- finally {
109
- // HACK: idkwtf we have to bam this from one TS version to another
110
- resolve(environment);
60
+ let environment;
61
+ try {
62
+ let result = yield this._codiacApi.Cabinet.tryReadMany({ name: { $eq: cabinet } });
63
+ if (result.error)
64
+ throw result.error;
65
+ else if (result.output && result.output.length > 0) {
66
+ environment = result.output[0].environment;
111
67
  }
112
- }));
68
+ }
69
+ catch (err) {
70
+ this.logger.debug(`Error retrieving environment for cabinet [${cabinet}, tenant: ${this._userCntx.currentTenantCode}]: ${err.name || ""} ${err.message || ""}`, err);
71
+ environment = codiac_constants_1.ERROR_INDICATOR;
72
+ }
73
+ return environment;
113
74
  });
114
75
  }
115
76
  }
@@ -117,10 +78,14 @@ exports.default = Whereami;
117
78
  Whereami.description = 'Renders the current cabinet context the image project is pointed to. ie: Tenant, Enterprise, Environment, Cabinet.';
118
79
  Whereami.flags = {
119
80
  help: core_1.Flags.help({ char: 'h' }),
120
- // flag with a value (-n, --name=VALUE)
121
- name: core_1.Flags.string({ char: 'n', description: 'name to print' }),
122
- // flag with no value (-f, --force)
123
- force: core_1.Flags.boolean({ char: 'f' }),
81
+ silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
82
+ echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
83
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
124
84
  };
125
85
  Whereami.args = {};
86
+ Whereami.examples = [
87
+ { description: "Show current project context.", command: "<%= config.bin %> <%= command.id %>" },
88
+ { description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> --silent" },
89
+ { description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> --to-script" },
90
+ ];
126
91
  //# sourceMappingURL=whereami.js.map
@@ -1 +1 @@
1
-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,CAAC;aACjC;YACD,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;;AAvFL,2BAwFC;AAvFU,oBAAW,GAAG,sHAAsH,CAAC;AAErI,cAAK,GAAG;IACX,IAAI,EAAE,YAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC/B,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IACzJ,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,iFAAiF,EAAE,CAAC;IAC3J,WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;CACrJ,CAAC;AAEK,aAAI,GAAG,EAAE,CAAC;AAEV,iBAAQ,GAAsB;IACjC,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAChG,EAAE,WAAW,EAAE,6BAA6B,EAAE,OAAO,EAAE,8CAA8C,EAAE;IACvG,EAAE,WAAW,EAAE,0DAA0D,EAAE,OAAO,EAAE,iDAAiD,EAAE;CAC1I,CAAC"}
@@ -1,10 +1,26 @@
1
- import { CommandBaseEnterprise } from '../command-base-enterprise';
2
- export default class Whoami extends CommandBaseEnterprise {
1
+ import { Command } from '@oclif/core';
2
+ import { RootMap } from '../apis/codiac-api/contracts';
3
+ import { CommandBaseExecTenant } from '../command-base-exec-tenant';
4
+ import { InteractionModes } from '../uilogic/config-ui-utils';
5
+ type WhoamiRequest = {
6
+ output: string;
7
+ };
8
+ export default class Whoami extends CommandBaseExecTenant<WhoamiRequest> {
3
9
  static description: string;
4
10
  static aliases: string[];
5
11
  static flags: {
12
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
13
  output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
17
  };
8
18
  static args: {};
9
- run(): Promise<void>;
19
+ static examples: Command.Example[];
20
+ captureArgs(): Promise<[Partial<WhoamiRequest>, InteractionModes | undefined, boolean]>;
21
+ buildCandidate_silently(partial: Partial<WhoamiRequest>, rootMap: RootMap): Promise<WhoamiRequest | undefined>;
22
+ buildCandidate_interactively(partial: Partial<WhoamiRequest>, takeDefaults: boolean, rootMap: RootMap): Promise<WhoamiRequest | undefined>;
23
+ buildCommandString(candidate: WhoamiRequest, cmd: string[]): string[];
24
+ executeTask(candidate: WhoamiRequest): Promise<void>;
10
25
  }
26
+ export {};
@@ -3,20 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const stringify = require("json-stringify-safe");
6
- const command_base_enterprise_1 = require("../command-base-enterprise");
7
- class Whoami extends command_base_enterprise_1.CommandBaseEnterprise {
8
- run() {
6
+ const command_base_exec_tenant_1 = require("../command-base-exec-tenant");
7
+ const config_ui_utils_1 = require("../uilogic/config-ui-utils");
8
+ class Whoami extends command_base_exec_tenant_1.CommandBaseExecTenant {
9
+ captureArgs() {
10
+ var _a, _b, _c;
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const { flags } = yield this.parse(Whoami);
13
+ const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_b = (_a = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _a !== void 0 ? _a : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _b !== void 0 ? _b : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
14
+ return [{ output: (_c = flags.output) !== null && _c !== void 0 ? _c : "text" }, interactionMode, false];
15
+ });
16
+ }
17
+ buildCandidate_silently(partial, rootMap) {
18
+ var _a;
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ return { output: (_a = partial.output) !== null && _a !== void 0 ? _a : "text" };
21
+ });
22
+ }
23
+ buildCandidate_interactively(partial, takeDefaults, rootMap) {
24
+ var _a;
25
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
+ return { output: (_a = partial.output) !== null && _a !== void 0 ? _a : "text" };
27
+ });
28
+ }
29
+ buildCommandString(candidate, cmd) {
30
+ if (candidate.output !== "text")
31
+ cmd.push("-o", candidate.output);
32
+ cmd.push("--silent");
33
+ return cmd;
34
+ }
35
+ executeTask(candidate) {
9
36
  var _a;
10
37
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- this.bootstrap();
12
- const { args, flags } = yield this.parse(Whoami);
13
- // let userContextRepo = new UserContextLoader(this.logger);
14
- // let cachedUserContext = userContextRepo.loadUserContext(this._projCfg.tenantCode);
15
38
  if (this._userCntx) {
16
- if (flags.output == "json") {
39
+ if (candidate.output === "json") {
17
40
  process.stdout.write(stringify(this._userCntx, undefined, 2));
18
41
  }
19
- else { // text
42
+ else {
20
43
  this._ui.userMessage(`${this._styler.hilite(this._userCntx.userName)} (tenant: ${this._styler.hilite(this._userCntx.currentTenantCode || "none")})`);
21
44
  if (this._userCntx.roles && (this._userCntx.roles.length > 0)) {
22
45
  this._ui.userMessage(this._styler.dim("└─ roles: ").concat((_a = this._userCntx.roles) === null || _a === void 0 ? void 0 : _a.join(", ")));
@@ -24,10 +47,10 @@ class Whoami extends command_base_enterprise_1.CommandBaseEnterprise {
24
47
  }
25
48
  }
26
49
  else {
27
- if (flags.output == "json") {
50
+ if (candidate.output === "json") {
28
51
  process.stdout.write("");
29
52
  }
30
- else { // text
53
+ else {
31
54
  this._ui.userMessage(`You are not currently logged in.`);
32
55
  }
33
56
  }
@@ -38,9 +61,17 @@ exports.default = Whoami;
38
61
  Whoami.description = 'Renders the codiac username and its current tenant.';
39
62
  Whoami.aliases = ["user:show"];
40
63
  Whoami.flags = {
41
- // help: Flags.help({ char: 'h' }),
42
- // output: Flags.custom({ char: 'o', options: ['text', 'json'], default: 'text', description: "Format for the response data." })
64
+ help: core_1.Flags.help({ char: 'h' }),
43
65
  output: core_1.Flags.string({ char: 'o', options: ['text', 'json'], default: 'text', description: 'Format for the response data.' }),
66
+ silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
67
+ echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
68
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
44
69
  };
45
70
  Whoami.args = {};
71
+ Whoami.examples = [
72
+ { description: "Show current user.", command: "<%= config.bin %> <%= command.id %>" },
73
+ { description: "Show current user as JSON.", command: "<%= config.bin %> <%= command.id %> -o json" },
74
+ { description: "Non-interactive invocation.", command: "<%= config.bin %> <%= command.id %> --silent" },
75
+ { description: "Renders the equivalent silent command without executing.", command: "<%= config.bin %> <%= command.id %> --to-script" },
76
+ ];
46
77
  //# sourceMappingURL=whoami.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AACA,sCAA4C;AAC5C,iDAAiD;AAEjD,wEAAmE;AAEnE,MAAqB,MAAO,SAAQ,+CAAqB;IAa/C,GAAG;;;YACL,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEjD,4DAA4D;YAC5D,qFAAqF;YAErF,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"inquirer";
2
- import { IEntryValidator } from "../ops/i-entry-validator";
2
+ import { IEntryValidator, ValidationResult } from "../ops/i-entry-validator";
3
3
  export type EntryValue = string | number | boolean;
4
+ /** Input object for the available options in a CLI select list.
5
+ * The `name` is what renders in the list,
6
+ * and the `value` is what actually gets returned from the selection. */
7
+ export type SelectOption<T> = {
8
+ value: T;
9
+ name: string;
10
+ };
11
+ /** Return type for fuzzy-select validation callbacks. */
12
+ export type BooleanValidationResult = boolean | ValidationResult;
4
13
  export type choice<T extends EntryValue> = T | {
5
14
  name: string;
6
15
  value?: T;
@@ -40,6 +49,16 @@ export interface IUserInputProvider {
40
49
  */
41
50
  promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean | undefined): Promise<T[] | undefined>;
42
51
  promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean | undefined, validator?: (input: T, answers?: inquirer.Answers | undefined) => boolean | string): Promise<T[] | undefined>;
52
+ /**
53
+ * Prompts for a value using fuzzy (autocomplete) search over the available choices.
54
+ * @param id Identifies the prompt for internal use, esp in mocking. This value never renders to the user.
55
+ * @param fetchChoices Async function that returns the list of choices, optionally filtered by the user's search string (for remote search). For client-side filtering pass the full list regardless of the input.
56
+ * @param suggestOnly When true the user may type a free-form value not present in the list (optional, defaults to false).
57
+ * @param defaultValue Pre-selected value shown at the top of the list (optional).
58
+ * @param searchOnRemote When true, `fetchChoices` is called on every keystroke; when false the list is fetched once and filtered client-side (optional, defaults to false).
59
+ * @param validate Optional callback to validate the selected value; return `true` / `false` or a `ValidationResult`.
60
+ */
61
+ promptSelectFuzzy<T>(id: string, prompt: string, fetchChoices: (searchString?: string) => Promise<SelectOption<T>[]>, suggestOnly?: boolean, defaultValue?: T, searchOnRemote?: boolean, validate?: (candidate: T) => BooleanValidationResult): Promise<T | undefined>;
43
62
  /** Enables the user to retrieves a reference to a single existing file on the local machine.
44
63
  * @param id Identifies the prompt for internal use, esp in mocking. This value never renders to the user. */
45
64
  promptSelectFile(id: string, prompt: string, fileOptions: FileSelectionOptions): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"i-user-input-provider.js","sourceRoot":"","sources":["../../src/ops/i-user-input-provider.ts"],"names":[],"mappings":";;;AAOA,kFAAkF;AAClF,MAAa,sBAAsB;CAQlC;AARD,wDAQC;AAED,gFAAgF;AAChF,MAAa,oBAAqB,SAAQ,sBAAsB;CAG/D;AAHD,oDAGC"}
1
+ {"version":3,"file":"i-user-input-provider.js","sourceRoot":"","sources":["../../src/ops/i-user-input-provider.ts"],"names":[],"mappings":";;;AAeA,kFAAkF;AAClF,MAAa,sBAAsB;CAQlC;AARD,wDAQC;AAED,gFAAgF;AAChF,MAAa,oBAAqB,SAAQ,sBAAsB;CAG/D;AAHD,oDAGC"}
@@ -1,4 +1,4 @@
1
- import { EntryValue, IUserInputProvider, choice, IOutputStyler, FileSelectionOptions, FolderSelectionOptions } from '../';
1
+ import { EntryValue, IUserInputProvider, choice, IOutputStyler, FileSelectionOptions, FolderSelectionOptions, SelectOption, BooleanValidationResult } from '../';
2
2
  export declare class MockUi implements IUserInputProvider, IOutputStyler {
3
3
  constructor();
4
4
  private values;
@@ -13,6 +13,7 @@ export declare class MockUi implements IUserInputProvider, IOutputStyler {
13
13
  promptPassword(id: string, prompt: string): Promise<string>;
14
14
  promptSelect<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], multiSelect?: boolean | undefined): Promise<T | undefined>;
15
15
  promptSelectMulti<T extends EntryValue>(id: string, prompt: string, choices: choice<T>[], loop?: boolean): Promise<T[] | undefined>;
16
+ promptSelectFuzzy<T>(id: string, prompt: string, fetchChoices: (searchString?: string) => Promise<SelectOption<T>[]>, suggestOnly?: boolean, defaultValue?: T, searchOnRemote?: boolean, validate?: (candidate: T) => BooleanValidationResult): Promise<T | undefined>;
16
17
  promptSelectFile(id: string, prompt: string, fileOptions: FileSelectionOptions): Promise<string>;
17
18
  promptSelectFolder(id: string, prompt: string, folderOptions: FolderSelectionOptions): Promise<string>;
18
19
  promptConfirm(id: string, prompt: string, defaultValue?: boolean): Promise<boolean>;