@dishantlangayan/solace-cloud-cli 0.1.1 → 0.2.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 (35) hide show
  1. package/README.md +63 -21
  2. package/dist/commands/missionctrl/broker/create.d.ts +1 -1
  3. package/dist/commands/missionctrl/broker/create.js +1 -3
  4. package/dist/commands/missionctrl/broker/delete.d.ts +1 -1
  5. package/dist/commands/missionctrl/broker/delete.js +1 -3
  6. package/dist/commands/missionctrl/broker/display.d.ts +1 -1
  7. package/dist/commands/missionctrl/broker/display.js +1 -3
  8. package/dist/commands/missionctrl/broker/list.d.ts +1 -1
  9. package/dist/commands/missionctrl/broker/list.js +1 -3
  10. package/dist/commands/missionctrl/broker/opstatus.d.ts +1 -1
  11. package/dist/commands/missionctrl/broker/opstatus.js +1 -3
  12. package/dist/commands/missionctrl/broker/state.d.ts +1 -1
  13. package/dist/commands/missionctrl/broker/state.js +1 -3
  14. package/dist/commands/missionctrl/broker/update.d.ts +1 -1
  15. package/dist/commands/missionctrl/broker/update.js +1 -3
  16. package/dist/commands/platform/env/create.d.ts +1 -1
  17. package/dist/commands/platform/env/create.js +2 -4
  18. package/dist/commands/platform/env/delete.d.ts +1 -1
  19. package/dist/commands/platform/env/delete.js +1 -2
  20. package/dist/commands/platform/env/display.d.ts +1 -1
  21. package/dist/commands/platform/env/display.js +1 -3
  22. package/dist/commands/platform/env/list.d.ts +1 -1
  23. package/dist/commands/platform/env/list.js +1 -3
  24. package/dist/commands/platform/env/update.d.ts +1 -1
  25. package/dist/commands/platform/env/update.js +3 -5
  26. package/oclif.manifest.json +4 -4
  27. package/package.json +7 -8
  28. package/dist/sc-command.d.ts +0 -22
  29. package/dist/sc-command.js +0 -54
  30. package/dist/util/internal.d.ts +0 -27
  31. package/dist/util/internal.js +0 -58
  32. package/dist/util/json.d.ts +0 -15
  33. package/dist/util/json.js +0 -19
  34. package/dist/util/sc-connection.d.ts +0 -13
  35. package/dist/util/sc-connection.js +0 -52
package/README.md CHANGED
@@ -11,10 +11,28 @@ The Solace Cloud CLI
11
11
 
12
12
 
13
13
  <!-- toc -->
14
+ * [Overview](#overview)
14
15
  * [Usage](#usage)
15
16
  * [Configuration](#configuration)
17
+ * [Resources](#resources)
18
+ * [Contributing](#contributing)
19
+ * [Authors](#authors)
20
+ * [License](#license)
16
21
  * [Commands](#commands)
17
22
  <!-- tocstop -->
23
+ # Overview
24
+ <!-- overview -->
25
+ The Solace Cloud CLI is a command line interface that simplifies deployment, configuration, and automation when working with your Solace Cloud org and services.
26
+
27
+ Use it to:
28
+
29
+ * Create and manage Environments
30
+ * Create and manage Mission Control and Event Broker Services
31
+ * Script deployment of Solace Cloud resources in your org
32
+
33
+ The CLI is built using the [oclif framework](https://oclif.io) that allows for plugin based development where users can add and extend the functionality of this CLI. For example, a new command can be added that can create and manage VPN Bridges, which uses the SEMP API to provision the bridges across two Message VPN on the same broker or across two brokers.
34
+
35
+ <!-- overviewstop -->
18
36
  # Usage
19
37
  <!-- usage -->
20
38
  ```sh-session
@@ -22,7 +40,7 @@ $ npm install -g @dishantlangayan/solace-cloud-cli
22
40
  $ sc COMMAND
23
41
  running command...
24
42
  $ sc (--version)
25
- @dishantlangayan/solace-cloud-cli/0.1.1 darwin-arm64 node-v24.1.0
43
+ @dishantlangayan/solace-cloud-cli/0.2.0 darwin-arm64 node-v24.1.0
26
44
  $ sc --help [COMMAND]
27
45
  USAGE
28
46
  $ sc COMMAND
@@ -42,7 +60,31 @@ The following Environment variables are optional:
42
60
  * SC_API_VERSION - The API version of the Solace Cloud REST API. Default is `v2`.
43
61
  * SC_BASE_URL - The location of your Solace Home Cloud account determines the base URL you use. Default is `https://api.solace.cloud/`
44
62
 
45
- <!-- configurationtop -->
63
+ <!-- configurationstop -->
64
+ # Resources
65
+ <!-- resources -->
66
+ This is not an officially supported Solace product.
67
+
68
+ For more information try these resources:
69
+ - Ask the [Solace Community](https://solace.community)
70
+ - The Solace Developer Portal website at: https://solace.dev
71
+
72
+ <!-- resourcesstop -->
73
+ # Contributing
74
+ <!-- contributing -->
75
+ Contributions are encouraged! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
76
+
77
+ <!-- contributingstop -->
78
+ # Authors
79
+ <!-- authors -->
80
+ See the list of [contributors](https://github.com/solacelabs/solace-cloud-cli/graphs/contributors) who participated in this project.
81
+
82
+ <!-- authorsstop -->
83
+ # License
84
+ <!-- license -->
85
+ See the [LICENSE](LICENSE) file for details.
86
+
87
+ <!-- licensestop -->
46
88
  # Commands
47
89
  <!-- commands -->
48
90
  * [`sc help [COMMAND]`](#sc-help-command)
@@ -78,7 +120,7 @@ USAGE
78
120
  $ sc help [COMMAND...] [-n]
79
121
 
80
122
  ARGUMENTS
81
- COMMAND... Command to show help for.
123
+ [COMMAND...] Command to show help for.
82
124
 
83
125
  FLAGS
84
126
  -n, --nested-commands Include all nested commands in the output.
@@ -146,7 +188,7 @@ EXAMPLES
146
188
  $ sc missionctrl broker create --name=MyBrokerName --datacenter-id=eks-ca-central-1a --service-class-id=DEVELOPER
147
189
  ```
148
190
 
149
- _See code: [src/commands/missionctrl/broker/create.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/create.ts)_
191
+ _See code: [src/commands/missionctrl/broker/create.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/create.ts)_
150
192
 
151
193
  ## `sc missionctrl broker delete`
152
194
 
@@ -178,7 +220,7 @@ EXAMPLES
178
220
  $ sc missionctrl broker delete --name=MyBrokerName
179
221
  ```
180
222
 
181
- _See code: [src/commands/missionctrl/broker/delete.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/delete.ts)_
223
+ _See code: [src/commands/missionctrl/broker/delete.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/delete.ts)_
182
224
 
183
225
  ## `sc missionctrl broker display`
184
226
 
@@ -209,7 +251,7 @@ EXAMPLES
209
251
  $ sc missionctrl broker display
210
252
  ```
211
253
 
212
- _See code: [src/commands/missionctrl/broker/display.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/display.ts)_
254
+ _See code: [src/commands/missionctrl/broker/display.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/display.ts)_
213
255
 
214
256
  ## `sc missionctrl broker list`
215
257
 
@@ -257,7 +299,7 @@ EXAMPLES
257
299
  $ sc missionctrl broker list --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc
258
300
  ```
259
301
 
260
- _See code: [src/commands/missionctrl/broker/list.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/list.ts)_
302
+ _See code: [src/commands/missionctrl/broker/list.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/list.ts)_
261
303
 
262
304
  ## `sc missionctrl broker opstatus`
263
305
 
@@ -294,7 +336,7 @@ EXAMPLES
294
336
  $ sc missionctrl broker opstatus -n <broker-name>
295
337
  ```
296
338
 
297
- _See code: [src/commands/missionctrl/broker/opstatus.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/opstatus.ts)_
339
+ _See code: [src/commands/missionctrl/broker/opstatus.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/opstatus.ts)_
298
340
 
299
341
  ## `sc missionctrl broker state`
300
342
 
@@ -328,7 +370,7 @@ EXAMPLES
328
370
  $ sc missionctrl broker state --name=MyBrokerName
329
371
  ```
330
372
 
331
- _See code: [src/commands/missionctrl/broker/state.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/state.ts)_
373
+ _See code: [src/commands/missionctrl/broker/state.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/state.ts)_
332
374
 
333
375
  ## `sc missionctrl broker update`
334
376
 
@@ -368,7 +410,7 @@ EXAMPLES
368
410
  $ sc missionctrl broker update --name <name> --new-name <new-name>
369
411
  ```
370
412
 
371
- _See code: [src/commands/missionctrl/broker/update.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/missionctrl/broker/update.ts)_
413
+ _See code: [src/commands/missionctrl/broker/update.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/missionctrl/broker/update.ts)_
372
414
 
373
415
  ## `sc platform env create`
374
416
 
@@ -399,10 +441,10 @@ DESCRIPTION
399
441
  Token Permissions: [ environments:edit ]
400
442
 
401
443
  EXAMPLES
402
- $ sc platform env create --name=MyEnvironment --desc="My environment description" --isDefault --isProduction
444
+ $ sc platform env create --name=MyEnvironment --description="My environment description" --isDefault --isProduction
403
445
  ```
404
446
 
405
- _See code: [src/commands/platform/env/create.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/platform/env/create.ts)_
447
+ _See code: [src/commands/platform/env/create.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/platform/env/create.ts)_
406
448
 
407
449
  ## `sc platform env delete`
408
450
 
@@ -432,7 +474,7 @@ EXAMPLES
432
474
  $ sc platform env delete --env-id=MyEnvId
433
475
  ```
434
476
 
435
- _See code: [src/commands/platform/env/delete.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/platform/env/delete.ts)_
477
+ _See code: [src/commands/platform/env/delete.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/platform/env/delete.ts)_
436
478
 
437
479
  ## `sc platform env display`
438
480
 
@@ -464,7 +506,7 @@ EXAMPLES
464
506
  $ sc platform env display --env-id=MyEnvId
465
507
  ```
466
508
 
467
- _See code: [src/commands/platform/env/display.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/platform/env/display.ts)_
509
+ _See code: [src/commands/platform/env/display.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/platform/env/display.ts)_
468
510
 
469
511
  ## `sc platform env list`
470
512
 
@@ -497,7 +539,7 @@ EXAMPLES
497
539
  $ sc platform env list --name=Default --pageNumber=1 --pageSize=10 --sort=name:ASC
498
540
  ```
499
541
 
500
- _See code: [src/commands/platform/env/list.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/platform/env/list.ts)_
542
+ _See code: [src/commands/platform/env/list.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/platform/env/list.ts)_
501
543
 
502
544
  ## `sc platform env update`
503
545
 
@@ -529,12 +571,12 @@ DESCRIPTION
529
571
 
530
572
 
531
573
  EXAMPLES
532
- $ sc platform env update --name=MyEnvName --new-name=MyNewEnvName --desc="My description to update" --isDefault
574
+ $ sc platform env update --name=MyEnvName --new-name=MyNewEnvName --description="My description to update" --isDefault
533
575
 
534
- $ sc platform env update --env-id=MyEnvId --new-name=MyNewEnvName --desc="My description to update" --isDefault
576
+ $ sc platform env update --env-id=MyEnvId --new-name=MyNewEnvName --description="My description to update" --isDefault
535
577
  ```
536
578
 
537
- _See code: [src/commands/platform/env/update.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.1.1/src/commands/platform/env/update.ts)_
579
+ _See code: [src/commands/platform/env/update.ts](https://github.com/dishantlangayan/solace-cloud-cli/blob/v0.2.0/src/commands/platform/env/update.ts)_
538
580
 
539
581
  ## `sc plugins`
540
582
 
@@ -722,7 +764,7 @@ USAGE
722
764
  $ sc plugins remove [PLUGIN...] [-h] [-v]
723
765
 
724
766
  ARGUMENTS
725
- PLUGIN... plugin to uninstall
767
+ [PLUGIN...] plugin to uninstall
726
768
 
727
769
  FLAGS
728
770
  -h, --help Show CLI help.
@@ -763,7 +805,7 @@ USAGE
763
805
  $ sc plugins uninstall [PLUGIN...] [-h] [-v]
764
806
 
765
807
  ARGUMENTS
766
- PLUGIN... plugin to uninstall
808
+ [PLUGIN...] plugin to uninstall
767
809
 
768
810
  FLAGS
769
811
  -h, --help Show CLI help.
@@ -791,7 +833,7 @@ USAGE
791
833
  $ sc plugins unlink [PLUGIN...] [-h] [-v]
792
834
 
793
835
  ARGUMENTS
794
- PLUGIN... plugin to uninstall
836
+ [PLUGIN...] plugin to uninstall
795
837
 
796
838
  FLAGS
797
839
  -h, --help Show CLI help.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerOperationApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerCreate extends ScCommand<typeof MissionctrlBrokerCreate> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerCreate extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Create an event broker service. You must provide a unique name and select a service class and datacenter. You can optionally define other properties for the event broker service.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerOperationApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerDelete extends ScCommand<typeof MissionctrlBrokerDelete> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerDelete extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Delete a service using its unique identifier.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerApiResponse, EventBrokerListApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerDisplay extends ScCommand<typeof MissionctrlBrokerDisplay> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerDisplay extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Get the details of an event broker service using its identifier or name.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerListApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerList extends ScCommand<typeof MissionctrlBrokerList> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { renderTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { renderTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerList extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Get a listing of event broker services.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerOperationDetail } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerOpstatus extends ScCommand<typeof MissionctrlBrokerOpstatus> {
4
4
  static args: {};
@@ -1,8 +1,6 @@
1
+ import { renderTable, ScCommand, ScConnection, sleep } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
3
  import { MultiBar, Presets } from 'cli-progress';
3
- import { ScCommand } from '../../../sc-command.js';
4
- import { renderTable, sleep } from '../../../util/internal.js';
5
- import { ScConnection } from '../../../util/sc-connection.js';
6
4
  export default class MissionctrlBrokerOpstatus extends ScCommand {
7
5
  static args = {};
8
6
  static description = `Get the status of all operations being performed on an event broker service.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerRedundancyApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerState extends ScCommand<typeof MissionctrlBrokerState> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerState extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Get the availability state of an event broker service and the name of the active messaging node using the service's unique identifier.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EventBrokerOperationApiResponse } from '../../../types/broker.js';
3
3
  export default class MissionctrlBrokerUpdate extends ScCommand<typeof MissionctrlBrokerUpdate> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class MissionctrlBrokerUpdate extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Update the configuration of an existing event broker service.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EnvironmentApiResponse } from '../../../types/environment.js';
3
3
  export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreate> {
4
4
  static args: {};
@@ -1,14 +1,12 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class PlatformEnvCreate extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Create a new environment.
8
6
 
9
7
  Token Permissions: [ environments:edit ]`;
10
8
  static examples = [
11
- '<%= config.bin %> <%= command.id %> --name=MyEnvironment --desc="My environment description" --isDefault --isProduction',
9
+ '<%= config.bin %> <%= command.id %> --name=MyEnvironment --description="My environment description" --isDefault --isProduction',
12
10
  ];
13
11
  static flags = {
14
12
  description: Flags.string({
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelete> {
3
3
  static args: {};
4
4
  static description: string;
@@ -1,6 +1,5 @@
1
+ import { ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { ScConnection } from '../../../util/sc-connection.js';
4
3
  export default class PlatformEnvDelete extends ScCommand {
5
4
  static args = {};
6
5
  static description = `Delete an environment using either its name or unique identifier. The default environment cannot be deleted.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EnvironmentApiResponse, EnvironmentListApiResponse } from '../../../types/environment.js';
3
3
  export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisplay> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class PlatformEnvDisplay extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Display information about an Environment.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EnvironmentListApiResponse } from '../../../types/environment.js';
3
3
  export default class PlatformEnvList extends ScCommand<typeof PlatformEnvList> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { renderTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { renderTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class PlatformEnvList extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Get a list of all Environments.
@@ -1,4 +1,4 @@
1
- import { ScCommand } from '../../../sc-command.js';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { EnvironmentApiResponse } from '../../../types/environment.js';
3
3
  export default class PlatformEnvUpdate extends ScCommand<typeof PlatformEnvUpdate> {
4
4
  static args: {};
@@ -1,7 +1,5 @@
1
+ import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
2
  import { Flags } from '@oclif/core';
2
- import { ScCommand } from '../../../sc-command.js';
3
- import { printObjectAsKeyValueTable } from '../../../util/internal.js';
4
- import { ScConnection } from '../../../util/sc-connection.js';
5
3
  export default class PlatformEnvUpdate extends ScCommand {
6
4
  static args = {};
7
5
  static description = `Modify an environment's attributes
@@ -11,8 +9,8 @@ export default class PlatformEnvUpdate extends ScCommand {
11
9
  Token Permissions: [ environments:edit ]
12
10
  `;
13
11
  static examples = [
14
- '<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName --desc="My description to update" --isDefault',
15
- '<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --desc="My description to update" --isDefault',
12
+ '<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName --description="My description to update" --isDefault',
13
+ '<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --description="My description to update" --isDefault',
16
14
  ];
17
15
  static flags = {
18
16
  description: Flags.string({
@@ -566,7 +566,7 @@
566
566
  "args": {},
567
567
  "description": "Create a new environment.\n\n Token Permissions: [ environments:edit ]",
568
568
  "examples": [
569
- "<%= config.bin %> <%= command.id %> --name=MyEnvironment --desc=\"My environment description\" --isDefault --isProduction"
569
+ "<%= config.bin %> <%= command.id %> --name=MyEnvironment --description=\"My environment description\" --isDefault --isProduction"
570
570
  ],
571
571
  "flags": {
572
572
  "json": {
@@ -857,8 +857,8 @@
857
857
  "args": {},
858
858
  "description": "Modify an environment's attributes\n \n Use either the Environment's ID (--env-id) or name of the Environment (--name).\n \n Token Permissions: [ environments:edit ]\n ",
859
859
  "examples": [
860
- "<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName --desc=\"My description to update\" --isDefault",
861
- "<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --desc=\"My description to update\" --isDefault"
860
+ "<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName --description=\"My description to update\" --isDefault",
861
+ "<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --description=\"My description to update\" --isDefault"
862
862
  ],
863
863
  "flags": {
864
864
  "json": {
@@ -940,5 +940,5 @@
940
940
  ]
941
941
  }
942
942
  },
943
- "version": "0.1.1"
943
+ "version": "0.2.0"
944
944
  }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@dishantlangayan/solace-cloud-cli",
3
3
  "description": "The Solace Cloud CLI",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "author": "Dishant Langayan",
6
6
  "bin": {
7
7
  "sc": "./bin/run.js"
8
8
  },
9
9
  "bugs": "https://github.com/dishantlangayan/solace-cloud-cli/issues",
10
10
  "dependencies": {
11
+ "@dishantlangayan/sc-cli-core": "^0.1.0",
11
12
  "@oclif/core": "^4",
12
13
  "@oclif/plugin-help": "^6",
13
14
  "@oclif/plugin-plugins": "^5",
@@ -45,7 +46,10 @@
45
46
  ],
46
47
  "homepage": "https://github.com/dishantlangayan/solace-cloud-cli",
47
48
  "keywords": [
48
- "oclif"
49
+ "oclif",
50
+ "solace",
51
+ "cli",
52
+ "sc"
49
53
  ],
50
54
  "license": "Apache-2.0",
51
55
  "main": "dist/index.js",
@@ -58,12 +62,7 @@
58
62
  "@oclif/plugin-help",
59
63
  "@oclif/plugin-plugins"
60
64
  ],
61
- "topicSeparator": " ",
62
- "topics": {
63
- "hello": {
64
- "description": "Say hello to the world and others"
65
- }
66
- }
65
+ "topicSeparator": " "
67
66
  },
68
67
  "repository": "dishantlangayan/solace-cloud-cli",
69
68
  "scripts": {
@@ -1,22 +0,0 @@
1
- import { Command, Interfaces } from '@oclif/core';
2
- export type Flags<T extends typeof Command> = Interfaces.InferredFlags<T['flags'] & typeof ScCommand['baseFlags']>;
3
- export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
4
- /**
5
- * A base command that provided common functionality for all sc commands.
6
- *
7
- * All implementations of this class need to implement the run() method.
8
- *
9
- */
10
- export declare abstract class ScCommand<T extends typeof Command> extends Command {
11
- static baseFlags: {
12
- 'log-level': Interfaces.OptionFlag<"error" | "warn" | "debug" | "info" | "trace", Interfaces.CustomOptions>;
13
- };
14
- static enableJsonFlag: boolean;
15
- protected args: Args<T>;
16
- protected flags: Flags<T>;
17
- protected catch(err: Error & {
18
- exitCode?: number;
19
- }): Promise<unknown>;
20
- protected finally(_: Error | undefined): Promise<unknown>;
21
- init(): Promise<void>;
22
- }
@@ -1,54 +0,0 @@
1
- import { Command, Flags } from '@oclif/core';
2
- import { DefaultBaseUrl, EnvironmentVariable, envVars } from './config/env-vars.js';
3
- /**
4
- * A base command that provided common functionality for all sc commands.
5
- *
6
- * All implementations of this class need to implement the run() method.
7
- *
8
- */
9
- export class ScCommand extends Command {
10
- // define flags that can be inherited by any command that extends BaseCommand
11
- static baseFlags = {
12
- 'log-level': Flags.option({
13
- default: 'info',
14
- helpGroup: 'GLOBAL',
15
- options: ['debug', 'warn', 'error', 'info', 'trace'],
16
- summary: 'Specify level for logging.',
17
- })(),
18
- };
19
- // add the --json flag
20
- static enableJsonFlag = true;
21
- args;
22
- flags;
23
- async catch(err) {
24
- // add any custom logic to handle errors from the command
25
- // or simply return the parent class error handling
26
- return super.catch(err);
27
- }
28
- async finally(_) {
29
- // called after run and catch regardless of whether or not the command errored
30
- return super.finally(_);
31
- }
32
- async init() {
33
- await super.init();
34
- const { args, flags } = await this.parse({
35
- args: this.ctor.args,
36
- baseFlags: super.ctor.baseFlags,
37
- enableJsonFlag: this.ctor.enableJsonFlag,
38
- flags: this.ctor.flags,
39
- strict: this.ctor.strict,
40
- });
41
- this.flags = flags;
42
- this.args = args;
43
- // set base url if not defined in environment variables
44
- if (!envVars.getString(EnvironmentVariable.SC_BASE_URL)) {
45
- this.debug(`Environment variable '${EnvironmentVariable.SC_BASE_URL}' not set, using default '${DefaultBaseUrl}'`);
46
- envVars.setString(EnvironmentVariable.SC_BASE_URL, DefaultBaseUrl);
47
- }
48
- // Check if Access Token is set
49
- const value = envVars.getString(EnvironmentVariable.SC_ACCESS_TOKEN);
50
- if (!value) {
51
- throw new Error(`Environment variable ${EnvironmentVariable.SC_ACCESS_TOKEN} is not set and required for any API operations.`);
52
- }
53
- }
54
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Formats a camel case style `string` into a title case.
3
- *
4
- * @param text Text to transform.
5
- */
6
- export declare function camelCaseToTitleCase(text: string): string;
7
- export interface ColumnConfig {
8
- width?: number;
9
- wrapWord?: boolean;
10
- }
11
- /**
12
- * Prints object data in a formatted key-value table.
13
- * @param data The object data to print
14
- * @returns Formatted table string
15
- */
16
- export declare function printObjectAsKeyValueTable<T extends Record<string, unknown>>(data: T): string;
17
- export declare function renderTable<T>(data: T[][], columnConfig?: Record<number, ColumnConfig>): string;
18
- export declare function renderKeyValueTable<T>(data: T[][], columnConfig?: Record<number, ColumnConfig>): string;
19
- /**
20
- * Sleep function.
21
- * @param ms Num of milliseconds to wait
22
- * @returns Promise that resolves after the specified time
23
- */
24
- export declare function sleep(ms: number): Promise<void>;
25
- export declare const sleepModule: {
26
- sleep: typeof sleep;
27
- };
@@ -1,58 +0,0 @@
1
- import { table } from 'table';
2
- /**
3
- * Formats a camel case style `string` into a title case.
4
- *
5
- * @param text Text to transform.
6
- */
7
- export function camelCaseToTitleCase(text) {
8
- return text
9
- .replaceAll(/(^\w|\s\w)/g, (m) => m.toUpperCase())
10
- .replaceAll(/([A-Z][a-z]+)/g, ' $1')
11
- .replaceAll(/\s{2,}/g, ' ')
12
- .trim();
13
- }
14
- /**
15
- * Prints object data in a formatted key-value table.
16
- * @param data The object data to print
17
- * @returns Formatted table string
18
- */
19
- export function printObjectAsKeyValueTable(data) {
20
- const tableRows = [
21
- ['Key', 'Value'],
22
- ...Object.entries(data).map(([key, value]) => [camelCaseToTitleCase(key), value]),
23
- ];
24
- return renderKeyValueTable(tableRows);
25
- }
26
- export function renderTable(data, columnConfig) {
27
- // Table config
28
- const tableConfig = {
29
- columns: columnConfig,
30
- };
31
- const tableStr = table(data, tableConfig);
32
- return tableStr;
33
- }
34
- export function renderKeyValueTable(data, columnConfig) {
35
- if (columnConfig === undefined) {
36
- columnConfig = { 1: { width: 50, wrapWord: true } };
37
- }
38
- // Table config
39
- const tableConfig = {
40
- columns: columnConfig,
41
- drawHorizontalLine(lineIndex, rowCount) {
42
- return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
43
- },
44
- };
45
- const tableStr = table(data, tableConfig);
46
- return tableStr;
47
- }
48
- /**
49
- * Sleep function.
50
- * @param ms Num of milliseconds to wait
51
- * @returns Promise that resolves after the specified time
52
- */
53
- export function sleep(ms) {
54
- return new Promise((resolve) => {
55
- setTimeout(resolve, ms);
56
- });
57
- }
58
- export const sleepModule = { sleep };
@@ -1,15 +0,0 @@
1
- /**
2
- * Parse JSON `string` data.
3
- *
4
- * @param data Data to parse.
5
- */
6
- export declare function parseJson(data: string, _throwOnEmpty?: boolean): unknown;
7
- /**
8
- * Finds a the key with the provided value in the JSON array and returns the JSON object.
9
- *
10
- * @param array The JSON array to search
11
- * @param key The key to lookup in the array
12
- * @param value The value of the key to match
13
- * @returns The JSON object that matches the key and value
14
- */
15
- export declare function findByKey<T>(array: T[], key: keyof T, value: unknown): T | undefined;
package/dist/util/json.js DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * Parse JSON `string` data.
3
- *
4
- * @param data Data to parse.
5
- */
6
- export function parseJson(data, _throwOnEmpty = true) {
7
- return typeof data === 'string' ? JSON.parse(data) : data;
8
- }
9
- /**
10
- * Finds a the key with the provided value in the JSON array and returns the JSON object.
11
- *
12
- * @param array The JSON array to search
13
- * @param key The key to lookup in the array
14
- * @param value The value of the key to match
15
- * @returns The JSON object that matches the key and value
16
- */
17
- export function findByKey(array, key, value) {
18
- return array.find(item => item[key] === value);
19
- }
@@ -1,13 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- export declare class ScConnection {
3
- private axiosInstance;
4
- private endpointUrl;
5
- constructor(baseURL?: string, accessToken?: string, timeout?: number);
6
- delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
7
- get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
8
- patch<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
9
- post<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
10
- put<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
11
- private joinPaths;
12
- }
13
- export default ScConnection;
@@ -1,52 +0,0 @@
1
- import axios from 'axios';
2
- import { DefaultBaseUrl, EnvironmentVariable, envVars } from '../config/env-vars.js';
3
- export class ScConnection {
4
- axiosInstance;
5
- endpointUrl = '';
6
- constructor(baseURL = envVars.getString(EnvironmentVariable.SC_BASE_URL, DefaultBaseUrl), accessToken = envVars.getString(EnvironmentVariable.SC_ACCESS_TOKEN, ''), timeout = 10_000) {
7
- const apiVersion = envVars.getString(EnvironmentVariable.SC_API_VERSION, 'v2');
8
- this.endpointUrl = this.joinPaths(baseURL, `/api/${apiVersion}`);
9
- this.axiosInstance = axios.create({
10
- baseURL: this.endpointUrl,
11
- headers: {
12
- 'Authorization': `Bearer ${accessToken}`,
13
- 'Content-Type': 'application/json',
14
- },
15
- timeout,
16
- });
17
- // Add interceptors if needed
18
- this.axiosInstance.interceptors.response.use((response) => response, (error) => {
19
- console.error('API Error:', error.response?.data || error.message);
20
- return Promise.reject(error);
21
- });
22
- }
23
- // DELETE request
24
- async delete(url, config) {
25
- const response = await this.axiosInstance.delete(url, config);
26
- return response.data;
27
- }
28
- // GET request
29
- async get(url, config) {
30
- const response = await this.axiosInstance.get(url, config);
31
- return response.data;
32
- }
33
- // PATCH request
34
- async patch(url, data, config) {
35
- const response = await this.axiosInstance.patch(url, data, config);
36
- return response.data;
37
- }
38
- // POST request
39
- async post(url, data, config) {
40
- const response = await this.axiosInstance.post(url, data, config);
41
- return response.data;
42
- }
43
- // PUT request
44
- async put(url, data, config) {
45
- const response = await this.axiosInstance.put(url, data, config);
46
- return response.data;
47
- }
48
- joinPaths(base, path) {
49
- return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
50
- }
51
- }
52
- export default ScConnection;