clever-tools 3.8.3 → 3.9.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 (79) hide show
  1. package/bin/clever.js +177 -427
  2. package/package.json +10 -3
  3. package/src/command-options.js +4 -10
  4. package/src/command-promise-handler.js +5 -7
  5. package/src/commands/accesslogs.js +9 -13
  6. package/src/commands/activity.js +10 -14
  7. package/src/commands/addon.js +68 -38
  8. package/src/commands/applications.js +9 -16
  9. package/src/commands/cancel-deploy.js +5 -9
  10. package/src/commands/config.js +7 -11
  11. package/src/commands/console.js +5 -9
  12. package/src/commands/create.js +5 -9
  13. package/src/commands/curl.js +7 -11
  14. package/src/commands/database.js +13 -16
  15. package/src/commands/delete.js +4 -8
  16. package/src/commands/deploy.js +10 -14
  17. package/src/commands/diag.js +9 -11
  18. package/src/commands/domain.js +348 -17
  19. package/src/commands/drain.js +10 -20
  20. package/src/commands/env.js +13 -17
  21. package/src/commands/link.js +3 -7
  22. package/src/commands/login.js +13 -15
  23. package/src/commands/logout.js +3 -7
  24. package/src/commands/logs.js +9 -13
  25. package/src/commands/makeDefault.js +3 -7
  26. package/src/commands/notify-email.js +9 -19
  27. package/src/commands/open.js +5 -9
  28. package/src/commands/profile.js +21 -12
  29. package/src/commands/published-config.js +11 -15
  30. package/src/commands/restart.js +7 -11
  31. package/src/commands/scale.js +3 -7
  32. package/src/commands/service.js +8 -18
  33. package/src/commands/ssh.js +4 -8
  34. package/src/commands/status.js +7 -11
  35. package/src/commands/stop.js +5 -9
  36. package/src/commands/tcp-redirs.js +11 -15
  37. package/src/commands/unlink.js +4 -8
  38. package/src/commands/version.js +4 -6
  39. package/src/commands/webhooks.js +8 -16
  40. package/src/format-table.js +4 -8
  41. package/src/initial-setup.js +49 -0
  42. package/src/load-package-json.cjs +5 -0
  43. package/src/logger.js +5 -8
  44. package/src/models/activity.js +3 -7
  45. package/src/models/addon.js +37 -56
  46. package/src/models/app_configuration.js +18 -31
  47. package/src/models/application.js +37 -61
  48. package/src/models/application_configuration.js +11 -15
  49. package/src/models/configuration.js +11 -15
  50. package/src/models/deployments.js +6 -10
  51. package/src/models/domain.js +6 -10
  52. package/src/models/drain.js +5 -13
  53. package/src/models/exit-strategy-option.js +4 -8
  54. package/src/models/fs-utils.js +3 -7
  55. package/src/models/git.js +19 -34
  56. package/src/models/ids-resolver.js +6 -12
  57. package/src/models/interact.js +2 -6
  58. package/src/models/isomorphic-http-with-agent.js +3 -9
  59. package/src/models/json-array.js +1 -3
  60. package/src/models/log-v4.js +10 -12
  61. package/src/models/log.js +11 -15
  62. package/src/models/namespaces.js +7 -13
  63. package/src/models/node-dns-resolver.js +43 -0
  64. package/src/models/notification.js +8 -17
  65. package/src/models/organisation.js +4 -10
  66. package/src/models/send-to-api.js +17 -13
  67. package/src/models/user.js +16 -9
  68. package/src/models/utils.js +2 -6
  69. package/src/models/variables.js +4 -10
  70. package/src/parsers.js +21 -71
  71. package/src/commands/networkgroups/commands.js +0 -7
  72. package/src/commands/networkgroups/index.js +0 -67
  73. package/src/commands/networkgroups/members.js +0 -80
  74. package/src/commands/networkgroups/peers.js +0 -83
  75. package/src/models/format-ng-table.js +0 -115
  76. package/src/models/format-string.js +0 -44
  77. package/src/models/networkgroup.js +0 -64
  78. package/src/models/wireguard-conf.js +0 -95
  79. package/src/models/wireguard.js +0 -75
package/bin/clever.js CHANGED
@@ -1,64 +1,61 @@
1
1
  #! /usr/bin/env node
2
- 'use strict';
3
2
 
4
- function hasParam (param, paramValue) {
5
- const index = process.argv.indexOf(param);
6
- if (index === -1) {
7
- return false;
8
- }
9
- if (paramValue != null) {
10
- return process.argv[index + 1] === paramValue;
11
- }
12
- return true;
13
- }
14
-
15
- // These need to be set before Logger and other stuffs
16
- if (hasParam('-v') || hasParam('--verbose')) {
17
- process.env.CLEVER_VERBOSE = '1';
18
- }
19
-
20
- // These need to be set before Logger and other stuffs
21
- // Don't log anything in autocomplete mode
22
- if (hasParam('--autocomplete-index')) {
23
- process.env.CLEVER_QUIET = '1';
24
- }
25
-
26
- // These need to be set before other stuffs
27
- const colors = require('colors');
28
- const colorExplicitFalse = hasParam('--no-color') || hasParam('--color', 'false');
29
- const colorExplicitTrue = hasParam('--color', 'true');
30
- if (colorExplicitFalse || (!process.stdout.isTTY && !colorExplicitTrue)) {
31
- colors.disable();
32
- }
33
-
34
- // These need to be set before Logger and other stuffs
35
- const pkg = require('../package.json');
36
- const updateNotifierModule = require('update-notifier');
37
- const isRunThroughPackagedBinary = process.pkg != null;
38
- const updateNotifierExplicitFalse = hasParam('--no-update-notifier') || hasParam('--update-notifier', 'false');
39
- if (!updateNotifierExplicitFalse && !isRunThroughPackagedBinary) {
40
- updateNotifierModule({
41
- pkg,
42
- tagsUrl: 'https://api.github.com/repos/CleverCloud/clever-tools/tags',
43
- }).notify({
44
- isGlobal: true,
45
- getDetails () {
46
- const docsUrl = 'https://github.com/CleverCloud/clever-tools/tree/master/docs#how-to-use-clever-tools';
47
- return `\nPlease follow this link to update your clever-tools:\n${docsUrl}`;
48
- },
49
- });
50
- }
51
-
52
- const cliparse = require('cliparse');
53
- const cliparseCommands = require('cliparse/src/command.js');
54
- const _sortBy = require('lodash/sortBy.js');
55
-
56
- const git = require('../src/models/git.js');
57
- const Parsers = require('../src/parsers.js');
58
- const handleCommandPromise = require('../src/command-promise-handler.js');
59
- const Formatter = require('../src/models/format-string.js');
60
- const { AVAILABLE_ZONES } = require('../src/models/application.js');
61
- const { getOutputFormatOption, getSameCommitPolicyOption, getExitOnOption } = require('../src/command-options.js');
3
+ // WARNING: this needs to run before other imports
4
+ import '../src/initial-setup.js';
5
+
6
+ import cliparse from 'cliparse';
7
+ import cliparseCommands from 'cliparse/src/command.js';
8
+ import _sortBy from 'lodash/sortBy.js';
9
+
10
+ import { getPackageJson } from '../src/load-package-json.cjs';
11
+ import * as git from '../src/models/git.js';
12
+ import * as Parsers from '../src/parsers.js';
13
+ import { handleCommandPromise } from '../src/command-promise-handler.js';
14
+ import * as Application from '../src/models/application.js';
15
+ import { AVAILABLE_ZONES } from '../src/models/application.js';
16
+ import { getExitOnOption, getOutputFormatOption, getSameCommitPolicyOption } from '../src/command-options.js';
17
+
18
+ import * as Addon from '../src/models/addon.js';
19
+ import * as ApplicationConfiguration from '../src/models/application_configuration.js';
20
+ import * as Drain from '../src/models/drain.js';
21
+ import * as Notification from '../src/models/notification.js';
22
+ import * as Namespaces from '../src/models/namespaces.js';
23
+
24
+ import * as accesslogsModule from '../src/commands/accesslogs.js';
25
+ import * as activity from '../src/commands/activity.js';
26
+ import * as addon from '../src/commands/addon.js';
27
+ import * as applications from '../src/commands/applications.js';
28
+ import * as cancelDeploy from '../src/commands/cancel-deploy.js';
29
+ import * as config from '../src/commands/config.js';
30
+ import * as create from '../src/commands/create.js';
31
+ import * as deleteCommandModule from '../src/commands/delete.js';
32
+ import * as deploy from '../src/commands/deploy.js';
33
+ import * as diag from '../src/commands/diag.js';
34
+ import * as domain from '../src/commands/domain.js';
35
+ import * as drain from '../src/commands/drain.js';
36
+ import * as env from '../src/commands/env.js';
37
+ import * as link from '../src/commands/link.js';
38
+ import * as login from '../src/commands/login.js';
39
+ import * as logout from '../src/commands/logout.js';
40
+ import * as logs from '../src/commands/logs.js';
41
+ import * as makeDefault from '../src/commands/makeDefault.js';
42
+ import * as notifyEmail from '../src/commands/notify-email.js';
43
+ import * as open from '../src/commands/open.js';
44
+ import * as consoleModule from '../src/commands/console.js';
45
+ import * as profile from '../src/commands/profile.js';
46
+ import * as publishedConfig from '../src/commands/published-config.js';
47
+ import * as restart from '../src/commands/restart.js';
48
+ import * as scale from '../src/commands/scale.js';
49
+ import * as service from '../src/commands/service.js';
50
+ import * as ssh from '../src/commands/ssh.js';
51
+ import * as status from '../src/commands/status.js';
52
+ import * as stop from '../src/commands/stop.js';
53
+ import * as tcpRedirs from '../src/commands/tcp-redirs.js';
54
+ import * as unlink from '../src/commands/unlink.js';
55
+ import * as version from '../src/commands/version.js';
56
+ import * as webhooks from '../src/commands/webhooks.js';
57
+ import * as database from '../src/commands/database.js';
58
+ import { curl } from '../src/commands/curl.js';
62
59
 
63
60
  // Exit cleanly if the program we pipe to exits abruptly
64
61
  process.stdout.on('error', (error) => {
@@ -67,35 +64,15 @@ process.stdout.on('error', (error) => {
67
64
  }
68
65
  });
69
66
 
70
- // Use this alias so we get less warnings in pkg build :p
71
- const dynamicRequire = module.require.bind(module);
72
-
73
- function lazyRequirePromiseModule (modulePath) {
74
- return function (name) {
75
- return function (...args) {
76
- const module = dynamicRequire(modulePath);
77
- const promise = module[name](...args);
78
- handleCommandPromise(promise);
79
- };
80
- };
81
- }
82
-
83
- function lazyRequire (modulePath) {
84
- return function (name) {
85
- return function (...args) {
86
- const module = dynamicRequire(modulePath);
87
- return module[name].apply(this, args);
88
- };
89
- };
90
- }
67
+ // Patch cliparse.command so we can catch errors
68
+ const cliparseCommand = cliparse.command;
91
69
 
92
- const Addon = lazyRequire('../src/models/addon.js');
93
- const Application = lazyRequire('../src/models/application.js');
94
- const ApplicationConfiguration = lazyRequire('../src/models/application_configuration.js');
95
- const Drain = lazyRequire('../src/models/drain.js');
96
- const Notification = lazyRequire('../src/models/notification.js');
97
- const NetworkGroup = lazyRequire('../src/models/networkgroup.js');
98
- const Namespaces = lazyRequire('../src/models/namespaces.js');
70
+ cliparse.command = function (name, options, commandFunction) {
71
+ return cliparseCommand(name, options, (...args) => {
72
+ const promise = commandFunction(...args);
73
+ handleCommandPromise(promise);
74
+ });
75
+ };
99
76
 
100
77
  function run () {
101
78
 
@@ -121,7 +98,7 @@ function run () {
121
98
  drainId: cliparse.argument('drain-id', { description: 'Drain ID' }),
122
99
  drainType: cliparse.argument('drain-type', {
123
100
  description: 'Drain type',
124
- complete: Drain('listDrainTypes'),
101
+ complete: Drain.listDrainTypes,
125
102
  }),
126
103
  drainUrl: cliparse.argument('drain-url', { description: 'Drain URL' }),
127
104
  fqdn: cliparse.argument('fqdn', { description: 'Domain name of the application' }),
@@ -141,15 +118,10 @@ function run () {
141
118
  configurationName: cliparse.argument('configuration-name', {
142
119
  description: 'The name of the configuration to manage',
143
120
  complete () {
144
- return cliparse.autocomplete.words(ApplicationConfiguration('listAvailableIds')());
121
+ return cliparse.autocomplete.words(ApplicationConfiguration.listAvailableIds());
145
122
  },
146
123
  }),
147
124
  configurationValue: cliparse.argument('configuration-value', { description: 'The new value of the configuration' }),
148
- ngId: cliparse.argument('ng-id', { description: 'The Network Group ID' }),
149
- ngIdOrLabel: cliparse.argument('ng', {
150
- description: 'Network Group ID or label',
151
- parser: Parsers.ngIdOrLabel,
152
- }),
153
125
  };
154
126
 
155
127
  // OPTIONS
@@ -158,10 +130,6 @@ function run () {
158
130
  logsFormat: getOutputFormatOption(['json-stream']),
159
131
  activityFormat: getOutputFormatOption(['json-stream']),
160
132
  envFormat: getOutputFormatOption(['shell']),
161
- accesslogsFollow: cliparse.flag('follow', {
162
- aliases: ['f'],
163
- description: 'Display access logs continuously (ignores before/until, after/since)',
164
- }),
165
133
  importAsJson: cliparse.flag('json', {
166
134
  description: 'Import variables as JSON (an array of { "name": "THE_NAME", "value": "THE_VALUE" } objects)',
167
135
  }),
@@ -181,7 +149,17 @@ function run () {
181
149
  aliases: ['a'],
182
150
  metavar: 'alias',
183
151
  description: 'Short name for the application',
184
- complete: Application('listAvailableAliases'),
152
+ complete: Application.listAvailableAliases,
153
+ }),
154
+ domain: cliparse.option('filter', {
155
+ default: '',
156
+ metavar: 'TEXT',
157
+ description: 'Check only domains containing the provided text',
158
+ }),
159
+ domainOverviewFilter: cliparse.option('filter', {
160
+ default: '',
161
+ metavar: 'TEXT',
162
+ description: 'Get only domains containing the provided text',
185
163
  }),
186
164
  naturalName: cliparse.flag('natural-name', {
187
165
  aliases: ['n'],
@@ -224,12 +202,12 @@ function run () {
224
202
  metavar: 'namespace',
225
203
  description: 'Namespace in which the TCP redirection should be',
226
204
  required: true,
227
- complete: Namespaces('completeNamespaces'),
205
+ complete: Namespaces.completeNamespaces,
228
206
  }),
229
207
  notificationEventType: cliparse.option('event', {
230
208
  metavar: 'type',
231
209
  description: 'Restrict notifications to specific event types',
232
- complete: Notification('listMetaEvents'),
210
+ complete: Notification.listMetaEvents,
233
211
  parser: Parsers.commaSeparated,
234
212
  }),
235
213
  flavor: cliparse.option('flavor', {
@@ -237,7 +215,7 @@ function run () {
237
215
  parser: Parsers.flavor,
238
216
  description: 'The instance size of your application',
239
217
  complete () {
240
- return cliparse.autocomplete.words(Application('listAvailableFlavors')());
218
+ return cliparse.autocomplete.words(Application.listAvailableFlavors());
241
219
  },
242
220
  }),
243
221
  follow: cliparse.flag('follow', {
@@ -273,7 +251,7 @@ function run () {
273
251
  aliases: ['l'],
274
252
  metavar: 'alias',
275
253
  description: 'Link the created add-on to the app with the specified alias',
276
- complete: Application('listAvailableAliases'),
254
+ complete: Application.listAvailableAliases,
277
255
  }),
278
256
  listAllNotifications: cliparse.flag('list-all', { description: 'List all notifications for your user or for an organisation with the \'--org\' option' }),
279
257
  maxFlavor: cliparse.option('max-flavor', {
@@ -281,7 +259,7 @@ function run () {
281
259
  parser: Parsers.flavor,
282
260
  description: 'The maximum instance size of your application',
283
261
  complete () {
284
- return cliparse.autocomplete.words(Application('listAvailableFlavors')());
262
+ return cliparse.autocomplete.words(Application.listAvailableFlavors());
285
263
  },
286
264
  }),
287
265
  buildFlavor: cliparse.option('build-flavor', {
@@ -299,7 +277,7 @@ function run () {
299
277
  parser: Parsers.flavor,
300
278
  description: 'The minimum scale size of your application',
301
279
  complete () {
302
- return cliparse.autocomplete.words(Application('listAvailableFlavors')());
280
+ return cliparse.autocomplete.words(Application.listAvailableFlavors());
303
281
  },
304
282
  }),
305
283
  minInstances: cliparse.option('min-instances', {
@@ -345,7 +323,7 @@ function run () {
345
323
  default: '',
346
324
  metavar: 'plan',
347
325
  description: 'Add-on plan, depends on the provider',
348
- complete: Addon('completePlan'),
326
+ complete: Addon.completePlan,
349
327
  }),
350
328
  quiet: cliparse.flag('quiet', { aliases: ['q'], description: 'Don\'t show logs during deployment' }),
351
329
  followDeployLogs: cliparse.flag('follow', {
@@ -356,7 +334,7 @@ function run () {
356
334
  default: 'par',
357
335
  metavar: 'region',
358
336
  description: 'Region to provision the add-on in, depends on the provider',
359
- complete: Addon('completeRegion'),
337
+ complete: Addon.completeRegion,
360
338
  }),
361
339
  addonVersion: cliparse.option('addon-version', {
362
340
  metavar: 'addon-version',
@@ -371,7 +349,7 @@ function run () {
371
349
  default: 'par',
372
350
  metavar: 'zone',
373
351
  description: `Region, can be ${AVAILABLE_ZONES.map((name) => `'${name}'`).join(', ')}`,
374
- complete: Application('listAvailableZones'),
352
+ complete: Application.listAvailableZones,
375
353
  }),
376
354
  search: cliparse.option('search', {
377
355
  metavar: 'search',
@@ -403,7 +381,7 @@ function run () {
403
381
  required: true,
404
382
  metavar: 'type',
405
383
  description: 'Instance type',
406
- complete: Application('listAvailableTypes'),
384
+ complete: Application.listAvailableTypes,
407
385
  }),
408
386
  drainUsername: cliparse.option('username', {
409
387
  aliases: ['u'],
@@ -447,128 +425,6 @@ function run () {
447
425
  aliases: ['y'],
448
426
  description: 'Skip confirmation even if the TCP redirection is not free',
449
427
  }),
450
- ngLabel: cliparse.option('label', {
451
- required: true,
452
- metavar: 'ng_label',
453
- description: 'Network Group label, also used for DNS context',
454
- }),
455
- ngIdOrLabel: cliparse.option('ng', {
456
- required: true,
457
- metavar: 'ng',
458
- description: 'Network Group ID or label',
459
- parser: Parsers.ngIdOrLabel,
460
- // complete: NetworkGroup('xxx'),
461
- }),
462
- ngDescription: cliparse.option('description', {
463
- required: true,
464
- metavar: 'ng_description',
465
- description: 'Network Group description',
466
- }),
467
- ngMemberId: cliparse.option('member-id', {
468
- aliases: ['m'],
469
- required: true,
470
- metavar: 'member_id',
471
- description: `The member ID: an app ID (e.g.: ${Formatter.formatCode('app_xxx')}), add-on ID (e.g.: ${Formatter.formatCode('addon_xxx')}) or external node category ID`,
472
- // complete: NetworkGroup('xxx'),
473
- }),
474
- ngMemberDomainName: cliparse.option('domain-name', {
475
- required: true,
476
- metavar: 'domain_name',
477
- description: `Member name used in the ${Formatter.formatUrl('<memberName>.m.<ngID>.ng.clever-cloud.com', false)} domain name alias`,
478
- }),
479
- ngPeerId: cliparse.option('peer-id', {
480
- required: true,
481
- metavar: 'peer_id',
482
- description: 'The peer ID',
483
- // complete: NetworkGroup('xxx'),
484
- }),
485
- ngPeerRole: cliparse.option('role', {
486
- required: true,
487
- metavar: 'peer_role',
488
- description: `The peer role, (${Formatter.formatString('client')} or ${Formatter.formatString('server')})`,
489
- parser: Parsers.ngPeerRole,
490
- complete: NetworkGroup('listAvailablePeerRoles'),
491
- }),
492
- // FIXME: Add "internal" member type
493
- ngMemberType: cliparse.option('type', {
494
- required: true,
495
- metavar: 'member_type',
496
- description: `The member type (${Formatter.formatString('application')}, ${Formatter.formatString('addon')} or ${Formatter.formatString('external')})`,
497
- parser: Parsers.ngMemberType,
498
- complete: NetworkGroup('listAvailableMemberTypes'),
499
- }),
500
- ngMemberLabel: cliparse.option('label', {
501
- required: true,
502
- metavar: 'member_label',
503
- description: 'Network Group member label',
504
- }),
505
- ngNodeCategoryId: cliparse.option('node-category-id', {
506
- required: true,
507
- aliases: ['c'],
508
- metavar: 'node_category_id',
509
- description: 'The external node category ID',
510
- // complete: NetworkGroup('xxx'),
511
- }),
512
- ngPeerLabel: cliparse.option('label', {
513
- required: true,
514
- metavar: 'peer_label',
515
- description: 'Network Group peer label',
516
- }),
517
- ngPeerParentMemberId: cliparse.option('parent', {
518
- required: true,
519
- metavar: 'member_id',
520
- description: 'Network Group peer category ID (parent member ID)',
521
- // complete: NetworkGroup('xxx'),
522
- }),
523
- optNgIdOrLabel: cliparse.option('ng', {
524
- required: false,
525
- metavar: 'ng',
526
- description: 'Network Group ID or label',
527
- parser: Parsers.ngIdOrLabel,
528
- // complete: NetworkGroup('xxx'),
529
- }),
530
- optNgMemberLabel: cliparse.option('label', {
531
- required: false,
532
- metavar: 'member_label',
533
- description: 'The member label',
534
- }),
535
- optNgNodeCategoryId: cliparse.option('node-category-id', {
536
- required: false,
537
- aliases: ['c'],
538
- metavar: 'node_category_id',
539
- description: 'The external node category ID',
540
- // complete: NetworkGroup('xxx'),
541
- }),
542
- optNgPeerId: cliparse.option('peer-id', {
543
- required: false,
544
- metavar: 'peer_id',
545
- description: 'The peer ID',
546
- // complete: NetworkGroup('xxx'),
547
- }),
548
- optNgPeerRole: cliparse.option('role', {
549
- required: false,
550
- default: 'client',
551
- metavar: 'peer_role',
552
- description: `The peer role, (${Formatter.formatString('client')} or ${Formatter.formatString('server')})`,
553
- parser: Parsers.ngPeerRole,
554
- complete: NetworkGroup('listAvailablePeerRoles'),
555
- }),
556
- optNgSearchAppId: cliparse.option('app-id', {
557
- required: false,
558
- metavar: 'app_id',
559
- description: 'The app ID to search',
560
- // complete: NetworkGroup('xxx'),
561
- }),
562
- wgPublicKey: cliparse.option('public-key', {
563
- required: true,
564
- metavar: 'public_key',
565
- description: 'A WireGuard® public key',
566
- }),
567
- optWgPrivateKey: cliparse.option('private-key', {
568
- required: false,
569
- metavar: 'private_key',
570
- description: 'A WireGuard® private key',
571
- }),
572
428
  jsonFormat: cliparse.flag('json', { aliases: ['j'], description: 'Show result in JSON format' }),
573
429
  humanJsonOutputFormat: getOutputFormatOption(),
574
430
  tag: cliparse.option('tag', {
@@ -603,107 +459,100 @@ function run () {
603
459
  };
604
460
 
605
461
  // ACCESSLOGS COMMAND
606
- const accesslogsModule = lazyRequirePromiseModule('../src/commands/accesslogs.js');
607
462
  const accesslogsCommand = cliparse.command('accesslogs', {
608
463
  description: 'Fetch access logs',
609
464
  options: [opts.alias, opts.appIdOrName, opts.logsFormat, opts.before, opts.after, opts.addonId],
610
- }, accesslogsModule('accessLogs'));
465
+ }, accesslogsModule.accessLogs);
611
466
 
612
467
  // ACTIVITY COMMAND
613
- const activity = lazyRequirePromiseModule('../src/commands/activity.js');
614
468
  const activityCommand = cliparse.command('activity', {
615
469
  description: 'Show last deployments of an application',
616
470
  options: [opts.alias, opts.appIdOrName, opts.follow, opts.showAllActivity, opts.activityFormat],
617
- }, activity('activity'));
471
+ }, activity.activity);
618
472
 
619
473
  // ADDON COMMANDS
620
- const addon = lazyRequirePromiseModule('../src/commands/addon.js');
621
474
  const addonCreateCommand = cliparse.command('create', {
622
475
  description: 'Create an add-on',
623
476
  args: [args.addonProvider, args.addonName],
624
477
  options: [opts.linkAddon, opts.confirmAddonCreation, opts.addonPlan, opts.addonRegion, opts.addonVersion, opts.addonOptions, opts.humanJsonOutputFormat],
625
- }, addon('create'));
478
+ }, addon.create);
626
479
  const addonDeleteCommand = cliparse.command('delete', {
627
480
  description: 'Delete an add-on',
628
481
  args: [args.addonIdOrName],
629
482
  options: [opts.confirmAddonDeletion],
630
- }, addon('delete'));
483
+ }, addon.deleteAddon);
631
484
  const addonRenameCommand = cliparse.command('rename', {
632
485
  description: 'Rename an add-on',
633
486
  args: [args.addonIdOrName, args.addonName],
634
- }, addon('rename'));
487
+ }, addon.rename);
635
488
  const addonShowProviderCommand = cliparse.command('show', {
636
489
  description: 'Show information about an add-on provider',
637
490
  args: [args.addonProvider],
638
- }, addon('showProvider'));
491
+ }, addon.showProvider);
639
492
  const addonProvidersCommand = cliparse.command('providers', {
640
493
  description: 'List available add-on providers',
641
494
  commands: [addonShowProviderCommand],
642
495
  options: [opts.humanJsonOutputFormat],
643
- }, addon('listProviders'));
496
+ }, addon.listProviders);
644
497
  const addonEnvCommand = cliparse.command('env', {
645
498
  description: 'List environment variables for an add-on',
646
499
  options: [opts.envFormat],
647
500
  args: [opts.addonId],
648
- }, addon('env'));
501
+ }, addon.env);
649
502
  const addonListCommand = cliparse.command('list', {
650
503
  description: 'List available add-ons',
651
504
  options: [opts.humanJsonOutputFormat],
652
- }, addon('list'));
505
+ }, addon.list);
653
506
 
654
507
  const addonCommands = cliparse.command('addon', {
655
508
  description: 'Manage add-ons',
656
509
  options: [opts.orgaIdOrName],
657
510
  privateOptions: [opts.humanJsonOutputFormat],
658
511
  commands: [addonCreateCommand, addonDeleteCommand, addonRenameCommand, addonListCommand, addonProvidersCommand, addonEnvCommand],
659
- }, addon('list'));
512
+ }, addon.list);
660
513
 
661
514
  // APPLICATIONS COMMAND
662
- const applications = lazyRequirePromiseModule('../src/commands/applications.js');
663
515
  const applicationsListRemoteCommand = cliparse.command('list', {
664
516
  description: 'List all applications',
665
517
  options: [opts.orgaIdOrName, opts.humanJsonOutputFormat],
666
- }, applications('listAll'));
518
+ }, applications.listAll);
667
519
  const applicationsCommand = cliparse.command('applications', {
668
520
  description: 'List linked applications',
669
521
  privateOptions: [opts.onlyAliases, opts.jsonFormat],
670
522
  commands: [applicationsListRemoteCommand],
671
- }, applications('list'));
523
+ }, applications.list);
672
524
 
673
525
  // CANCEL DEPLOY COMMAND
674
- const cancelDeploy = lazyRequirePromiseModule('../src/commands/cancel-deploy.js');
675
526
  const cancelDeployCommand = cliparse.command('cancel-deploy', {
676
527
  description: 'Cancel an ongoing deployment',
677
528
  options: [opts.alias, opts.appIdOrName],
678
- }, cancelDeploy('cancelDeploy'));
529
+ }, cancelDeploy.cancelDeploy);
679
530
 
680
531
  // CONFIG COMMAND
681
- const config = lazyRequirePromiseModule('../src/commands/config.js');
682
532
  const configGetCommand = cliparse.command('get', {
683
533
  description: 'Display the current configuration',
684
534
  args: [args.configurationName],
685
- }, config('get'));
535
+ }, config.get);
686
536
  const configSetCommand = cliparse.command('set', {
687
537
  description: 'Edit one configuration setting',
688
538
  args: [args.configurationName, args.configurationValue],
689
- }, config('set'));
539
+ }, config.set);
690
540
  const configUpdateCommand = cliparse.command('update', {
691
541
  description: 'Edit multiple configuration settings at once',
692
- options: ApplicationConfiguration('getUpdateOptions')(),
693
- }, config('update'));
542
+ options: ApplicationConfiguration.getUpdateOptions(),
543
+ }, config.update);
694
544
  const configCommands = cliparse.command('config', {
695
545
  description: 'Display or edit the configuration of your application',
696
546
  options: [opts.alias, opts.appIdOrName],
697
547
  commands: [configGetCommand, configSetCommand, configUpdateCommand],
698
- }, config('get'));
548
+ }, config.get);
699
549
 
700
550
  // CREATE COMMAND
701
- const create = lazyRequirePromiseModule('../src/commands/create.js');
702
551
  const appCreateCommand = cliparse.command('create', {
703
552
  description: 'Create an application',
704
553
  args: [args.appNameCreation],
705
554
  options: [opts.instanceType, opts.orgaIdOrName, opts.aliasCreation, opts.region, opts.github, opts.taskCommand, opts.humanJsonOutputFormat],
706
- }, create('create'));
555
+ }, create.create);
707
556
 
708
557
  // CURL COMMAND
709
558
  // NOTE: it's just here for documentation purposes, look at the bottom of the file for the real "clever curl" command
@@ -712,401 +561,305 @@ function run () {
712
561
  }, () => null);
713
562
 
714
563
  // DELETE COMMAND
715
- const deleteCommandModule = lazyRequirePromiseModule('../src/commands/delete.js');
716
564
  const deleteCommand = cliparse.command('delete', {
717
565
  description: 'Delete an application',
718
566
  options: [opts.alias, opts.appIdOrName, opts.confirmApplicationDeletion],
719
- }, deleteCommandModule('deleteApp'));
567
+ }, deleteCommandModule.deleteApp);
720
568
 
721
569
  // DEPLOY COMMAND
722
- const deploy = lazyRequirePromiseModule('../src/commands/deploy.js');
723
570
  const deployCommand = cliparse.command('deploy', {
724
571
  description: 'Deploy an application',
725
572
  options: [opts.alias, opts.branch, opts.gitTag, opts.quiet, opts.forceDeploy, opts.followDeployLogs, opts.sameCommitPolicy, opts.exitOnDeploy],
726
- }, deploy('deploy'));
573
+ }, deploy.deploy);
727
574
 
728
575
  // DIAG COMMAND
729
- const diag = lazyRequirePromiseModule('../src/commands/diag.js');
730
576
  const diagCommand = cliparse.command('diag', {
731
577
  description: 'Diagnose the current installation (prints various informations for support)',
732
578
  args: [],
733
579
  options: [opts.humanJsonOutputFormat],
734
- }, diag('diag'));
580
+ }, diag.diag);
735
581
 
736
582
  // DOMAIN COMMANDS
737
- const domain = lazyRequirePromiseModule('../src/commands/domain.js');
738
583
  const domainCreateCommand = cliparse.command('add', {
739
584
  description: 'Add a domain name to an application',
740
585
  args: [args.fqdn],
741
- }, domain('add'));
586
+ options: [opts.alias, opts.appIdOrName],
587
+ }, domain.add);
742
588
  const domainRemoveCommand = cliparse.command('rm', {
743
589
  description: 'Remove a domain name from an application',
744
590
  args: [args.fqdn],
745
- }, domain('rm'));
591
+ options: [opts.alias, opts.appIdOrName],
592
+ }, domain.rm);
746
593
  const domainSetFavouriteCommand = cliparse.command('set', {
747
594
  description: 'Set the favourite domain for an application',
748
595
  args: [args.fqdn],
749
- }, domain('setFavourite'));
596
+ }, domain.setFavourite);
750
597
  const domainUnsetFavouriteCommand = cliparse.command('unset', {
751
598
  description: 'Unset the favourite domain for an application',
752
- }, domain('unsetFavourite'));
599
+ }, domain.unsetFavourite);
753
600
  const domainFavouriteCommands = cliparse.command('favourite', {
754
601
  description: 'Manage the favourite domain name for an application',
602
+ options: [opts.alias, opts.appIdOrName],
755
603
  commands: [domainSetFavouriteCommand, domainUnsetFavouriteCommand],
756
- }, domain('getFavourite'));
604
+ }, domain.getFavourite);
605
+ const domainDiagApplicationCommand = cliparse.command('diag', {
606
+ description: 'Check if domains associated to a specific app are properly configured',
607
+ options: [opts.alias, opts.appIdOrName, opts.humanJsonOutputFormat, opts.domain],
608
+ }, domain.diagApplication);
609
+ const domainOverviewCommand = cliparse.command('overview', {
610
+ description: 'Get an overview of all your domains (all orgas, all apps)',
611
+ options: [opts.humanJsonOutputFormat, opts.domainOverviewFilter],
612
+ }, domain.overview);
757
613
  const domainCommands = cliparse.command('domain', {
758
614
  description: 'Manage domain names for an application',
759
- options: [opts.alias, opts.appIdOrName],
760
- commands: [domainCreateCommand, domainFavouriteCommands, domainRemoveCommand],
761
- }, domain('list'));
615
+ privateOptions: [opts.alias, opts.appIdOrName],
616
+ commands: [domainCreateCommand, domainFavouriteCommands, domainRemoveCommand, domainDiagApplicationCommand, domainOverviewCommand],
617
+ }, domain.list);
762
618
 
763
619
  // DRAIN COMMANDS
764
- const drain = lazyRequirePromiseModule('../src/commands/drain.js');
765
620
  const drainCreateCommand = cliparse.command('create', {
766
621
  description: 'Create a drain',
767
622
  args: [args.drainType, args.drainUrl],
768
623
  options: [opts.drainUsername, opts.drainPassword, opts.drainAPIKey, opts.drainIndexPrefix, opts.drainSDParameters],
769
- }, drain('create'));
624
+ }, drain.create);
770
625
  const drainRemoveCommand = cliparse.command('remove', {
771
626
  description: 'Remove a drain',
772
627
  args: [args.drainId],
773
- }, drain('rm'));
628
+ }, drain.rm);
774
629
  const drainEnableCommand = cliparse.command('enable', {
775
630
  description: 'Enable a drain',
776
631
  args: [args.drainId],
777
- }, drain('enable'));
632
+ }, drain.enable);
778
633
  const drainDisableCommand = cliparse.command('disable', {
779
634
  description: 'Disable a drain',
780
635
  args: [args.drainId],
781
- }, drain('disable'));
636
+ }, drain.disable);
782
637
  const drainCommands = cliparse.command('drain', {
783
638
  description: 'Manage drains',
784
639
  options: [opts.alias, opts.appIdOrName, opts.addonId],
785
640
  privateOptions: [opts.humanJsonOutputFormat],
786
641
  commands: [drainCreateCommand, drainRemoveCommand, drainEnableCommand, drainDisableCommand],
787
- }, drain('list'));
642
+ }, drain.list);
788
643
 
789
644
  // ENV COMMANDS
790
- const env = lazyRequirePromiseModule('../src/commands/env.js');
791
645
  const envSetCommand = cliparse.command('set', {
792
646
  description: 'Add or update an environment variable named <variable-name> with the value <variable-value>',
793
647
  args: [args.envVariableName, args.envVariableValue],
794
- }, env('set'));
648
+ }, env.set);
795
649
  const envRemoveCommand = cliparse.command('rm', {
796
650
  description: 'Remove an environment variable from an application',
797
651
  args: [args.envVariableName],
798
- }, env('rm'));
652
+ }, env.rm);
799
653
  const envImportCommand = cliparse.command('import', {
800
654
  description: 'Load environment variables from STDIN\n(WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)',
801
655
  options: [opts.importAsJson],
802
- }, env('importEnv'));
656
+ }, env.importEnv);
803
657
  const envImportVarsFromLocalEnvCommand = cliparse.command('import-vars', {
804
658
  description: 'Add or update environment variables named <variable-names> (comma-separated), taking their values from the current environment',
805
659
  args: [args.envVariableNames],
806
- }, env('importVarsFromLocalEnv'));
660
+ }, env.importVarsFromLocalEnv);
807
661
  const envCommands = cliparse.command('env', {
808
662
  description: 'Manage environment variables of an application',
809
663
  options: [opts.alias, opts.appIdOrName, opts.sourceableEnvVarsList],
810
664
  privateOptions: [opts.envFormat],
811
665
  commands: [envSetCommand, envRemoveCommand, envImportCommand, envImportVarsFromLocalEnvCommand],
812
- }, env('list'));
666
+ }, env.list);
813
667
 
814
668
  // LINK COMMAND
815
- const link = lazyRequirePromiseModule('../src/commands/link.js');
816
669
  const appLinkCommand = cliparse.command('link', {
817
670
  description: 'Link this repo to an existing application',
818
671
  args: [args.appIdOrName],
819
672
  options: [opts.aliasCreation, opts.orgaIdOrName],
820
- }, link('link'));
673
+ }, link.link);
821
674
 
822
675
  // LOGIN COMMAND
823
- const login = lazyRequirePromiseModule('../src/commands/login.js');
824
676
  const loginCommand = cliparse.command('login', {
825
677
  description: 'Login to Clever Cloud',
826
678
  options: [opts.loginToken, opts.loginSecret],
827
- }, login('login'));
679
+ }, login.login);
828
680
 
829
681
  // LOGOUT COMMAND
830
- const logout = lazyRequirePromiseModule('../src/commands/logout.js');
831
682
  const logoutCommand = cliparse.command('logout', {
832
683
  description: 'Logout from Clever Cloud',
833
- }, logout('logout'));
684
+ }, logout.logout);
834
685
 
835
686
  // LOGS COMMAND
836
- const logs = lazyRequirePromiseModule('../src/commands/logs.js');
837
687
  const logsCommand = cliparse.command('logs', {
838
688
  description: 'Fetch application logs, continuously',
839
689
  options: [opts.alias, opts.appIdOrName, opts.before, opts.after, opts.search, opts.deploymentId, opts.addonId, opts.logsFormat],
840
- }, logs('appLogs'));
690
+ }, logs.appLogs);
841
691
 
842
692
  // MAKE DEFAULT COMMAND
843
- const makeDefault = lazyRequirePromiseModule('../src/commands/makeDefault.js');
844
693
  const makeDefaultCommand = cliparse.command('make-default', {
845
694
  description: 'Make a linked application the default one',
846
695
  args: [args.alias],
847
- }, makeDefault('makeDefault'));
848
-
849
- // NETWORK GROUPS COMMANDS
850
- const networkgroups = lazyRequirePromiseModule('../src/commands/networkgroups/commands.js');
851
-
852
- // network group category - start
853
- const networkGroupsListCommand = cliparse.command('list', {
854
- description: 'List Network Groups with their labels',
855
- options: [opts.jsonFormat],
856
- }, networkgroups('listNetworkGroups'));
857
- const networkGroupsCreateCommand = cliparse.command('create', {
858
- description: 'Create a Network Group',
859
- options: [opts.ngLabel, opts.ngDescription, opts.optTags, opts.jsonFormat],
860
- }, networkgroups('createNg'));
861
- const networkGroupsDeleteCommand = cliparse.command('delete', {
862
- description: 'Delete a Network Group',
863
- options: [opts.ngIdOrLabel],
864
- }, networkgroups('deleteNg'));
865
- // network group category - end
866
-
867
- // member category - start
868
- const networkGroupsMemberListCommand = cliparse.command('list', {
869
- description: 'List members of a Network Group',
870
- // Add option opts.optNgSearchAppId ?
871
- options: [opts.ngIdOrLabel, opts.naturalName, opts.jsonFormat],
872
- }, networkgroups('listMembers'));
873
- const networkGroupsMemberGetCommand = cliparse.command('get', {
874
- description: 'Get a Network Group member\'s details',
875
- options: [opts.ngIdOrLabel, opts.ngMemberId, opts.naturalName, opts.jsonFormat],
876
- }, networkgroups('getMember'));
877
- const networkGroupsMemberAddCommand = cliparse.command('add', {
878
- description: 'Add an app or add-on as a Network Group member',
879
- options: [opts.ngIdOrLabel, opts.ngMemberId, opts.ngMemberType, opts.ngMemberDomainName, opts.optNgMemberLabel],
880
- }, networkgroups('addMember'));
881
- const networkGroupsMemberRemoveCommand = cliparse.command('remove', {
882
- description: 'Remove an app or add-on from a Network Group',
883
- options: [opts.ngIdOrLabel, opts.ngMemberId],
884
- }, networkgroups('removeMember'));
885
-
886
- const networkGroupsMembersCategoryCommand = cliparse.command('members', {
887
- description: 'List commands for interacting with Network Group members',
888
- commands: [networkGroupsMemberListCommand, networkGroupsMemberGetCommand, networkGroupsMemberAddCommand, networkGroupsMemberRemoveCommand],
889
- });
890
- // member category - end
891
-
892
- // peer category - start
893
- const networkGroupsPeerListCommand = cliparse.command('list', {
894
- description: 'List peers of a Network Group',
895
- options: [opts.ngIdOrLabel, opts.jsonFormat],
896
- }, networkgroups('listPeers'));
897
- const networkGroupsPeerGetCommand = cliparse.command('get', {
898
- description: 'Get a Network Group peer\'s details',
899
- options: [opts.ngIdOrLabel, opts.ngPeerId, opts.jsonFormat],
900
- }, networkgroups('getPeer'));
901
- const networkGroupsPeerAddCommand = cliparse.command('add-external', {
902
- description: 'Add an external node as a Network Group peer',
903
- options: [opts.ngIdOrLabel, opts.ngPeerRole, opts.wgPublicKey, opts.ngPeerLabel, opts.ngPeerParentMemberId],
904
- }, networkgroups('addExternalPeer'));
905
- const networkGroupsPeerRemoveExternalCommand = cliparse.command('remove-external', {
906
- description: 'Remove an external node from a Network Group',
907
- options: [opts.ngIdOrLabel, opts.ngPeerId],
908
- }, networkgroups('removeExternalPeer'));
909
-
910
- const networkGroupsPeersCategoryCommand = cliparse.command('peers', {
911
- description: 'List commands for interacting with Network Group peers',
912
- commands: [networkGroupsPeerListCommand, networkGroupsPeerGetCommand, networkGroupsPeerAddCommand, networkGroupsPeerRemoveExternalCommand],
913
- });
914
- // peer category - end
915
-
916
- // eslint-disable-next-line no-unused-vars
917
- const networkGroupsCommand = cliparse.command('networkgroups', {
918
- description: 'List Network Group commands',
919
- options: [opts.orgaIdOrName, opts.alias],
920
- commands: [networkGroupsListCommand, networkGroupsCreateCommand, networkGroupsDeleteCommand, networkGroupsMembersCategoryCommand, networkGroupsPeersCategoryCommand],
921
- });
922
- // eslint-disable-next-line no-unused-vars
923
- const ngCommand = cliparse.command('ng', {
924
- description: `Alias for ${Formatter.formatCommand('clever networkgroups')}`,
925
- options: [opts.orgaIdOrName, opts.alias],
926
- commands: [networkGroupsListCommand, networkGroupsCreateCommand, networkGroupsDeleteCommand, networkGroupsMembersCategoryCommand, networkGroupsPeersCategoryCommand],
927
- });
696
+ }, makeDefault.makeDefault);
928
697
 
929
698
  // NOTIFY-EMAIL COMMAND
930
- const notifyEmail = lazyRequirePromiseModule('../src/commands/notify-email.js');
931
699
  const addEmailNotificationCommand = cliparse.command('add', {
932
700
  description: 'Add a new email notification',
933
701
  options: [opts.notificationEventType, opts.notificationScope, opts.emailNotificationTarget],
934
702
  args: [args.notificationName],
935
- }, notifyEmail('add'));
703
+ }, notifyEmail.add);
936
704
  const removeEmailNotificationCommand = cliparse.command('remove', {
937
705
  description: 'Remove an existing email notification',
938
706
  args: [args.notificationId],
939
- }, notifyEmail('remove'));
707
+ }, notifyEmail.remove);
940
708
  const emailNotificationsCommand = cliparse.command('notify-email', {
941
709
  description: 'Manage email notifications',
942
710
  options: [opts.orgaIdOrName, opts.listAllNotifications],
943
711
  privateOptions: [opts.humanJsonOutputFormat],
944
712
  commands: [addEmailNotificationCommand, removeEmailNotificationCommand],
945
- }, notifyEmail('list'));
713
+ }, notifyEmail.list);
946
714
 
947
715
  // OPEN COMMAND
948
- const open = lazyRequirePromiseModule('../src/commands/open.js');
949
716
  const openCommand = cliparse.command('open', {
950
717
  description: 'Open an application in your browser',
951
718
  options: [opts.alias, opts.appIdOrName],
952
- }, open('open'));
719
+ }, open.open);
953
720
 
954
721
  // CONSOLE COMMAND
955
- const consoleModule = lazyRequirePromiseModule('../src/commands/console.js');
956
722
  const consoleCommand = cliparse.command('console', {
957
723
  description: 'Open an application in the Console',
958
724
  options: [opts.alias, opts.appIdOrName],
959
- }, consoleModule('openConsole'));
725
+ }, consoleModule.openConsole);
960
726
 
961
727
  // PROFILE COMMAND
962
- const profile = lazyRequirePromiseModule('../src/commands/profile.js');
963
728
  const profileCommand = cliparse.command('profile', {
964
729
  description: 'Display the profile of the current user',
965
730
  options: [opts.humanJsonOutputFormat],
966
- }, profile('profile'));
731
+ }, profile.profile);
967
732
 
968
733
  // PUBLISHED CONFIG COMMANDS
969
- const publishedConfig = lazyRequirePromiseModule('../src/commands/published-config.js');
970
734
  const publishedConfigSetCommand = cliparse.command('set', {
971
735
  description: 'Add or update a published configuration item named <variable-name> with the value <variable-value>',
972
736
  args: [args.envVariableName, args.envVariableValue],
973
- }, publishedConfig('set'));
737
+ }, publishedConfig.set);
974
738
  const publishedConfigRemoveCommand = cliparse.command('rm', {
975
739
  description: 'Remove a published configuration variable from an application',
976
740
  args: [args.envVariableName],
977
- }, publishedConfig('rm'));
741
+ }, publishedConfig.rm);
978
742
  const publishedConfigImportCommand = cliparse.command('import', {
979
743
  description: 'Load published configuration from STDIN\n(WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)',
980
744
  options: [opts.importAsJson],
981
- }, publishedConfig('importEnv'));
745
+ }, publishedConfig.importEnv);
982
746
  const publishedConfigCommands = cliparse.command('published-config', {
983
747
  description: 'Manage the configuration made available to other applications by this application',
984
748
  options: [opts.alias, opts.appIdOrName],
985
749
  privateOptions: [opts.envFormat],
986
750
  commands: [publishedConfigSetCommand, publishedConfigRemoveCommand, publishedConfigImportCommand],
987
- }, publishedConfig('list'));
751
+ }, publishedConfig.list);
988
752
 
989
753
  // RESTART COMMAND
990
- const restart = lazyRequirePromiseModule('../src/commands/restart.js');
991
754
  const restartCommand = cliparse.command('restart', {
992
755
  description: 'Start or restart an application',
993
756
  options: [opts.alias, opts.appIdOrName, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs, opts.exitOnDeploy],
994
- }, restart('restart'));
757
+ }, restart.restart);
995
758
 
996
759
  // SCALE COMMAND
997
- const scale = lazyRequirePromiseModule('../src/commands/scale.js');
998
760
  const scaleCommand = cliparse.command('scale', {
999
761
  description: 'Change scalability of an application',
1000
762
  options: [opts.alias, opts.appIdOrName, opts.flavor, opts.minFlavor, opts.maxFlavor, opts.instances, opts.minInstances, opts.maxInstances, opts.buildFlavor],
1001
- }, scale('scale'));
763
+ }, scale.scale);
1002
764
 
1003
765
  // SERVICE COMMANDS
1004
- const service = lazyRequirePromiseModule('../src/commands/service.js');
1005
766
  const serviceLinkAppCommand = cliparse.command('link-app', {
1006
767
  description: 'Add an existing app as a dependency',
1007
768
  args: [args.appIdOrName],
1008
- }, service('linkApp'));
769
+ }, service.linkApp);
1009
770
  const serviceUnlinkAppCommand = cliparse.command('unlink-app', {
1010
771
  description: 'Remove an app from the dependencies',
1011
772
  args: [args.appIdOrName],
1012
- }, service('unlinkApp'));
773
+ }, service.unlinkApp);
1013
774
  const serviceLinkAddonCommand = cliparse.command('link-addon', {
1014
775
  description: 'Link an existing add-on to this application',
1015
776
  args: [args.addonIdOrName],
1016
- }, service('linkAddon'));
777
+ }, service.linkAddon);
1017
778
  const serviceUnlinkAddonCommand = cliparse.command('unlink-addon', {
1018
779
  description: 'Unlink an add-on from this application',
1019
780
  args: [args.addonIdOrName],
1020
- }, service('unlinkAddon'));
781
+ }, service.unlinkAddon);
1021
782
  const serviceCommands = cliparse.command('service', {
1022
783
  description: 'Manage service dependencies',
1023
784
  options: [opts.alias, opts.appIdOrName, opts.onlyApps, opts.onlyAddons, opts.showAll],
1024
785
  privateOptions: [opts.humanJsonOutputFormat],
1025
786
  commands: [serviceLinkAppCommand, serviceUnlinkAppCommand, serviceLinkAddonCommand, serviceUnlinkAddonCommand],
1026
- }, service('list'));
787
+ }, service.list);
1027
788
 
1028
789
  // SSH COMMAND
1029
- const ssh = lazyRequirePromiseModule('../src/commands/ssh.js');
1030
790
  const sshCommand = cliparse.command('ssh', {
1031
791
  description: 'Connect to running instances through SSH',
1032
792
  options: [opts.alias, opts.appIdOrName, opts.sshIdentityFile],
1033
- }, ssh('ssh'));
793
+ }, ssh.ssh);
1034
794
 
1035
795
  // STATUS COMMAND
1036
- const status = lazyRequirePromiseModule('../src/commands/status.js');
1037
796
  const statusCommand = cliparse.command('status', {
1038
797
  description: 'See the status of an application',
1039
798
  options: [opts.alias, opts.appIdOrName, opts.humanJsonOutputFormat],
1040
- }, status('status'));
799
+ }, status.status);
1041
800
 
1042
801
  // STOP COMMAND
1043
- const stop = lazyRequirePromiseModule('../src/commands/stop.js');
1044
802
  const stopCommand = cliparse.command('stop', {
1045
803
  description: 'Stop a running application',
1046
804
  options: [opts.alias, opts.appIdOrName],
1047
- }, stop('stop'));
805
+ }, stop.stop);
1048
806
 
1049
807
  // TCP-REDIRS COMMAND
1050
- const tcpRedirs = lazyRequirePromiseModule('../src/commands/tcp-redirs.js');
1051
808
  const tcpRedirsListNamespacesCommand = cliparse.command('list-namespaces', {
1052
809
  description: 'List the namespaces in which you can create new TCP redirections',
1053
810
  options: [opts.humanJsonOutputFormat],
1054
- }, tcpRedirs('listNamespaces'));
811
+ }, tcpRedirs.listNamespaces);
1055
812
  const tcpRedirsAddCommand = cliparse.command('add', {
1056
813
  description: 'Add a new TCP redirection to the application',
1057
814
  options: [opts.namespace, opts.confirmTcpRedirCreation],
1058
- }, tcpRedirs('add'));
815
+ }, tcpRedirs.add);
1059
816
  const tcpRedirsRemoveCommand = cliparse.command('remove', {
1060
817
  description: 'Remove a TCP redirection from the application',
1061
818
  options: [opts.namespace],
1062
819
  args: [args.port],
1063
- }, tcpRedirs('remove'));
820
+ }, tcpRedirs.remove);
1064
821
  const tcpRedirsCommands = cliparse.command('tcp-redirs', {
1065
822
  description: 'Control the TCP redirections from reverse proxies to your application',
1066
823
  options: [opts.alias, opts.appIdOrName],
1067
824
  privateOptions: [opts.humanJsonOutputFormat],
1068
825
  commands: [tcpRedirsListNamespacesCommand, tcpRedirsAddCommand, tcpRedirsRemoveCommand],
1069
- }, tcpRedirs('list'));
826
+ }, tcpRedirs.list);
1070
827
 
1071
828
  // UNLINK COMMAND
1072
- const unlink = lazyRequirePromiseModule('../src/commands/unlink.js');
1073
829
  const appUnlinkCommand = cliparse.command('unlink', {
1074
830
  description: 'Unlink this repo from an existing application',
1075
831
  args: [args.alias],
1076
- }, unlink('unlink'));
832
+ }, unlink.unlink);
1077
833
 
1078
834
  // VERSION COMMAND
1079
- const version = lazyRequirePromiseModule('../src/commands/version.js');
1080
835
  const versionCommand = cliparse.command('version', {
1081
836
  description: 'Display the clever-tools version',
1082
837
  args: [],
1083
- }, version('version'));
838
+ }, version.version);
1084
839
 
1085
840
  // WEBHOOKS COMMAND
1086
- const webhooks = lazyRequirePromiseModule('../src/commands/webhooks.js');
1087
841
  const addWebhookCommand = cliparse.command('add', {
1088
842
  description: 'Register webhook to be called when events happen',
1089
843
  options: [opts.webhookFormat, opts.notificationEventType, opts.notificationScope],
1090
844
  args: [args.notificationName, args.webhookUrl],
1091
- }, webhooks('add'));
845
+ }, webhooks.add);
1092
846
  const removeWebhookCommand = cliparse.command('remove', {
1093
847
  description: 'Remove an existing webhook',
1094
848
  args: [args.notificationId],
1095
- }, webhooks('remove'));
849
+ }, webhooks.remove);
1096
850
  const webhooksCommand = cliparse.command('webhooks', {
1097
851
  description: 'Manage webhooks',
1098
852
  options: [opts.orgaIdOrName, opts.listAllNotifications],
1099
853
  privateOptions: [opts.humanJsonOutputFormat],
1100
854
  commands: [addWebhookCommand, removeWebhookCommand],
1101
- }, webhooks('list'));
855
+ }, webhooks.list);
1102
856
 
1103
857
  // DATABASES COMMANDS
1104
- const database = lazyRequirePromiseModule('../src/commands/database.js');
1105
858
  const downloadBackupCommand = cliparse.command('download', {
1106
859
  description: 'Download a database backup',
1107
860
  args: [args.databaseId, args.backupId],
1108
861
  options: [opts.output],
1109
- }, database('downloadBackups'));
862
+ }, database.downloadBackups);
1110
863
  const backupsCommand = cliparse.command('backups', {
1111
864
  description: 'List available database backups',
1112
865
  args: [args.databaseId],
@@ -1114,11 +867,11 @@ function run () {
1114
867
  commands: [
1115
868
  downloadBackupCommand,
1116
869
  ],
1117
- }, database('listBackups'));
870
+ }, database.listBackups);
1118
871
  const databaseCommand = cliparse.command('database', {
1119
872
  description: 'List available databases',
1120
873
  commands: [backupsCommand],
1121
- }, () => {
874
+ }, async () => {
1122
875
  console.info('This command is not available, you can try the following commands:');
1123
876
  console.info('clever database backups');
1124
877
  console.info('clever database backups download');
@@ -1151,9 +904,6 @@ function run () {
1151
904
  logoutCommand,
1152
905
  logsCommand,
1153
906
  makeDefaultCommand,
1154
- // Not ready for stable release yet
1155
- // networkGroupsCommand,
1156
- // ngCommand,
1157
907
  openCommand,
1158
908
  consoleCommand,
1159
909
  profileCommand,
@@ -1173,7 +923,7 @@ function run () {
1173
923
  const cliParser = cliparse.cli({
1174
924
  name: 'clever',
1175
925
  description: 'CLI tool to manage Clever Cloud\'s data and products',
1176
- version: pkg.version,
926
+ version: getPackageJson().version,
1177
927
  options: [opts.color, opts.updateNotifier, opts.verbose],
1178
928
  helpCommand: false,
1179
929
  commands,
@@ -1188,7 +938,7 @@ function run () {
1188
938
  // Right now, this is the only way to do this properly
1189
939
  // cliparse doesn't allow unknown options/arguments
1190
940
  if (process.argv[2] === 'curl') {
1191
- require('../src/commands/curl.js').curl();
941
+ curl();
1192
942
  }
1193
943
  else {
1194
944
  run();