# @c8y/toolkit

`@c8y/toolkit` is a collection of CLI tools to interact with an instance of Cumulocity. It is meant to provide its functionality without depending on a specific framework, like the [`@c8y/devkit`](https://www.npmjs.com/package/@c8y/devkit) package does regarding angular.

## Commands

The toolkit cli currently provides functionality to deploy applications/extensions to Cumulocity.

You can also list all available commands by executing `npx @c8y/toolkit -h`.
Which should result in an output like:

```
Usage: @c8y/toolkit [options] [command]

Toolkit for Cumulocity applications, allows to e.g. deploy an application to an instance of Cumulocity.

Options:
  -V, --version               output the version number
  -h, --help                  display help for command

Commands:
  deploy [options] <zipFile>  Deploy application to Cumulocity
  create-tenant [options]     Creates a new subtenant.
  delete-tenants [options]    Deletes existing subtenants.
  help [command]              display help for command
```

### Deploy

This cli provides multiple options while deploying and application/package.
To get all of the options available simply execute `npx @c8y/toolkit deploy -h`.
This should give you and output like:

```
Usage: @c8y/toolkit deploy [options] <zipFile>

Deploy application to Cumulocity

Arguments:
  zipFile                           Path to zip file

Options:
  -u, --url <URL>                   The url of the remote instance. Can also be passed via the "C8Y_URL" environment variable.
  -U, --user <user>                 Username of the Cumulocity instance. Can also be passed via the "C8Y_USER" environment variable.
  -P, --password <password>         Password of the Cumulocity instance. Can also be passed via the "C8Y_PASSWORD" environment variable.
  -t, --tenant <tenant>             Tenant of the Cumulocity instance. Can also be passed via the "C8Y_TENANT" environment variable.
  --tags <tags>                     Comma separated list of tags to apply to the uploaded version
  --rolling-tags                    Will remove tags that are already in use by previous version and adds them to the newly uploaded version
  --add-web-sdk-stable-tag          Add web SDK stable tag
  --delete-existing-tags            Delete existing tags
  -a --availability <availability>  Availability of the application, either: "PRIVATE", "MARKET" or "SHARED"
  -h, --help                        display help for command
```

To e.g. deploy a previously built zip file of a plugin package, you could e.g. execute:
`npx @c8y/toolkit deploy -u "https://demos.cumulocity.com" -U "dummyUser" -P "dummyPassword" -t "t123456" --tags "latest" --rolling-tags --add-web-sdk-stable-tag ./sample-plugin.zip`

## Create tenant

This cli can be used to create tenants. This might be used inside of CI workflows in order to create tenants to run tests against.
To get all of the options available simply execute `npx @c8y/toolkit create-tenant -h`.
This should give you and output like:

```
Usage: @c8y/toolkit create-tenant [options]

Creates a new subtenant.

Options:
  -u, --url <URL>                       The url of the remote instance. Can also be passed via the "C8Y_URL" environment variable.
  -U, --user <user>                     Username of the Cumulocity instance. Can also be passed via the "C8Y_USER" environment variable.
  -P, --password <password>             Password of the Cumulocity instance. Can also be passed via the "C8Y_PASSWORD" environment variable.
  -t, --tenant <tenant>                 Tenant of the Cumulocity instance. Can also be passed via the "C8Y_TENANT" environment variable.
  --tenantsNumber <n>                   The number of tenants to be created, default to 1.
  --tenantUser [value]                  Username of the created tenant(s).
  --tenantPassword [value]              Password of the created tenant(s).
  --domainNamePrefix [value]            The tenant name value
  --allowCreateTenants [value]          If the created tenant(s) should be allowed to create subtenants (default: true)
  --companyName [value]                 A scope is added as the company name (default: "e2eTesting tenant")
  --noTenantSuffix [value]              If set to true, there will be no number attached to the tenant name (default: false)
  --contactName [value]                 The tenants contact name. (default: "Mr. Smith")
  --contactPhone [value]                The tenants contact phone. (default: "+48123456789")
  --applicationsToBeSubscribed [value]  A comma separated list of applications names to be subscribed (default: "")
  -h, --help                            display help for command
```

## Delete tenants

This cli can be used to delete tenants. This might be used inside of CI workflows in order to delete tenants that have been previously used to run tests against.
To get all of the options available simply execute `npx @c8y/toolkit delete-tenants -h`.
This should give you and output like:

```
Usage: @c8y/toolkit delete-tenants [options]

Deletes existing subtenants.

Options:
  -u, --url <URL>            The url of the remote instance. Can also be passed via the "C8Y_URL" environment variable.
  -U, --user <user>          Username of the Cumulocity instance. Can also be passed via the "C8Y_USER" environment variable.
  -P, --password <password>  Password of the Cumulocity instance. Can also be passed via the "C8Y_PASSWORD" environment variable.
  -t, --tenant <tenant>      Tenant of the Cumulocity instance. Can also be passed via the "C8Y_TENANT" environment variable.
  -a, --age <age>            The age of the tenant in hours since it's creation time
  --companyName <value>      A scope is added as the company name. All tenants where the company name includes the provided string, will be deleted. (default: "e2eTesting tenant")
  --includeChildren          If set, all subtenants will be deleted as well
  -h, --help                 display help for command
```