clever-tools 4.5.0 → 4.5.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clever-tools",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "Command Line Interface for Clever Cloud.",
5
5
  "keywords": [
6
6
  "cli",
@@ -90,7 +90,7 @@ export const addonCreateCommand = defineCommand({
90
90
  placeholder: 'region',
91
91
  complete: completeRegion,
92
92
  }),
93
- version: defineOption({
93
+ addonVersion: defineOption({
94
94
  name: 'addon-version',
95
95
  schema: z.string().optional(),
96
96
  description: 'The version to use for the add-on',
@@ -115,7 +115,7 @@ export const addonCreateCommand = defineCommand({
115
115
  yes: skipConfirmation,
116
116
  org: orgaIdOrName,
117
117
  format,
118
- version,
118
+ addonVersion,
119
119
  option: addonOptions,
120
120
  } = options;
121
121
 
@@ -125,7 +125,7 @@ export const addonCreateCommand = defineCommand({
125
125
  planName,
126
126
  region,
127
127
  skipConfirmation,
128
- version: version,
128
+ version: addonVersion,
129
129
  addonOptions: parseAddonOptions(addonOptions),
130
130
  };
131
131
 
@@ -148,7 +148,7 @@ export const notificationScopeOption = defineOption({
148
148
  .string()
149
149
  .transform((v) => v.split(','))
150
150
  .optional(),
151
- description: 'Restrict notifications to specific applications and add-ons',
151
+ description: 'Restrict notifications to specific applications and add-ons (requires --org)',
152
152
  placeholder: 'service-id',
153
153
  });
154
154
 
@@ -48,8 +48,11 @@ export const notifyEmailAddCommand = defineCommand({
48
48
  async handler(options, name) {
49
49
  const { org, event: events, service, notify: notifTargets } = options;
50
50
 
51
- // TODO: fix alias option
52
- const { ownerId, appId } = await getOwnerAndApp(null, org, !org && !service);
51
+ if (service != null && org == null) {
52
+ throw new Error('--org is required when using --service');
53
+ }
54
+
55
+ const { ownerId, appId } = await getOwnerAndApp(org, org == null && service == null);
53
56
 
54
57
  const body = {
55
58
  name,
@@ -18,8 +18,7 @@ export const notifyEmailCommand = defineCommand({
18
18
  async handler(options) {
19
19
  const { org, listAll, format } = options;
20
20
 
21
- // TODO: fix alias option
22
- const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
21
+ const { ownerId, appId } = await getOwnerAndApp(org, org == null && !listAll);
23
22
  const hooks = await getEmailhooks({ ownerId }).then(sendToApi);
24
23
 
25
24
  const formattedHooks = hooks
@@ -37,7 +37,7 @@ clever notify-email add --notify <email-address|user-id|organisation> <name> [op
37
37
  |`--notify` `<email-address\|user-id\|organisation>`|Notify a user, a specific email address or the whole organisation (multiple values allowed, comma separated) **(required)**|
38
38
  |`--event` `<event-type>`|Restrict notifications to specific event types|
39
39
  |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
40
- |`--service` `<service-id>`|Restrict notifications to specific applications and add-ons|
40
+ |`--service` `<service-id>`|Restrict notifications to specific applications and add-ons (requires --org)|
41
41
 
42
42
  ## ➡️ `clever notify-email remove` <kbd>Since 0.6.1</kbd>
43
43
 
@@ -34,8 +34,11 @@ export const webhooksAddCommand = defineCommand({
34
34
  async handler(options, name, hookUrl) {
35
35
  const { org, format, event: events, service } = options;
36
36
 
37
- // TODO: fix alias option
38
- const { ownerId, appId } = await getOwnerAndApp(null, org, !org && !service);
37
+ if (service != null && org == null) {
38
+ throw new Error('--org is required when using --service');
39
+ }
40
+
41
+ const { ownerId, appId } = await getOwnerAndApp(org, org == null && service == null);
39
42
 
40
43
  const body = {
41
44
  name,
@@ -18,8 +18,7 @@ export const webhooksCommand = defineCommand({
18
18
  async handler(options) {
19
19
  const { org, listAll, format } = options;
20
20
 
21
- // TODO: fix alias option
22
- const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
21
+ const { ownerId, appId } = await getOwnerAndApp(org, org == null && !listAll);
23
22
  const hooks = await getWebhooks({ ownerId }).then(sendToApi);
24
23
 
25
24
  const formattedHooks = hooks
@@ -38,7 +38,7 @@ clever webhooks add <name> <url> [options]
38
38
  |`--event` `<event-type>`|Restrict notifications to specific event types|
39
39
  |`--format` `<format>`|Format of the body sent to the webhook ('raw', 'slack', 'gitter', or 'flowdock') (default: raw)|
40
40
  |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
41
- |`--service` `<service-id>`|Restrict notifications to specific applications and add-ons|
41
+ |`--service` `<service-id>`|Restrict notifications to specific applications and add-ons (requires --org)|
42
42
 
43
43
  ## ➡️ `clever webhooks remove` <kbd>Since 0.6.0</kbd>
44
44
 
@@ -76,9 +76,7 @@ function validateAddonVersionAndOptions(region, version, addonOptions, providerI
76
76
  const availableVersions = Object.keys(providerInfos.dedicated);
77
77
  const hasVersion = availableVersions.find((availableVersion) => availableVersion === version);
78
78
  if (hasVersion == null) {
79
- throw new Error(
80
- `Invalid version ${addonOptions.version}, available versions are: ${availableVersions.join(', ')}`,
81
- );
79
+ throw new Error(`Invalid version ${version}, available versions are: ${availableVersions.join(', ')}`);
82
80
  }
83
81
  }
84
82
  }
@@ -10,11 +10,12 @@ export function getOrgaIdOrUserId(orgIdOrName) {
10
10
  return orgIdOrName == null ? User.getCurrentId() : Organisation.getId(orgIdOrName);
11
11
  }
12
12
 
13
- export async function getOwnerAndApp(alias, org, useLinkedApp) {
14
- if (!useLinkedApp) {
15
- const ownerId = await getOrgaIdOrUserId(org);
16
- return { ownerId };
13
+ export async function getOwnerAndApp(org, useLinkedApp) {
14
+ if (org != null) {
15
+ return { ownerId: await Organisation.getId(org) };
17
16
  }
18
-
19
- return AppConfig.getAppDetails({ alias });
17
+ if (useLinkedApp) {
18
+ return AppConfig.getAppDetails({});
19
+ }
20
+ return { ownerId: await User.getCurrentId() };
20
21
  }