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