clever-tools 3.8.3 → 3.10.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 +178 -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 +354 -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 +44 -59
  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 +31 -70
  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',
@@ -364,6 +342,7 @@ function run () {
364
342
  }),
365
343
  addonOptions: cliparse.option('option', {
366
344
  metavar: 'option',
345
+ parser: Parsers.addonOptions,
367
346
  description: 'Option to enable for the add-on. Multiple --option argument can be passed to enable multiple options',
368
347
  }),
369
348
  region: cliparse.option('region', {
@@ -371,7 +350,7 @@ function run () {
371
350
  default: 'par',
372
351
  metavar: 'zone',
373
352
  description: `Region, can be ${AVAILABLE_ZONES.map((name) => `'${name}'`).join(', ')}`,
374
- complete: Application('listAvailableZones'),
353
+ complete: Application.listAvailableZones,
375
354
  }),
376
355
  search: cliparse.option('search', {
377
356
  metavar: 'search',
@@ -403,7 +382,7 @@ function run () {
403
382
  required: true,
404
383
  metavar: 'type',
405
384
  description: 'Instance type',
406
- complete: Application('listAvailableTypes'),
385
+ complete: Application.listAvailableTypes,
407
386
  }),
408
387
  drainUsername: cliparse.option('username', {
409
388
  aliases: ['u'],
@@ -447,128 +426,6 @@ function run () {
447
426
  aliases: ['y'],
448
427
  description: 'Skip confirmation even if the TCP redirection is not free',
449
428
  }),
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
429
  jsonFormat: cliparse.flag('json', { aliases: ['j'], description: 'Show result in JSON format' }),
573
430
  humanJsonOutputFormat: getOutputFormatOption(),
574
431
  tag: cliparse.option('tag', {
@@ -603,107 +460,100 @@ function run () {
603
460
  };
604
461
 
605
462
  // ACCESSLOGS COMMAND
606
- const accesslogsModule = lazyRequirePromiseModule('../src/commands/accesslogs.js');
607
463
  const accesslogsCommand = cliparse.command('accesslogs', {
608
464
  description: 'Fetch access logs',
609
465
  options: [opts.alias, opts.appIdOrName, opts.logsFormat, opts.before, opts.after, opts.addonId],
610
- }, accesslogsModule('accessLogs'));
466
+ }, accesslogsModule.accessLogs);
611
467
 
612
468
  // ACTIVITY COMMAND
613
- const activity = lazyRequirePromiseModule('../src/commands/activity.js');
614
469
  const activityCommand = cliparse.command('activity', {
615
470
  description: 'Show last deployments of an application',
616
471
  options: [opts.alias, opts.appIdOrName, opts.follow, opts.showAllActivity, opts.activityFormat],
617
- }, activity('activity'));
472
+ }, activity.activity);
618
473
 
619
474
  // ADDON COMMANDS
620
- const addon = lazyRequirePromiseModule('../src/commands/addon.js');
621
475
  const addonCreateCommand = cliparse.command('create', {
622
476
  description: 'Create an add-on',
623
477
  args: [args.addonProvider, args.addonName],
624
478
  options: [opts.linkAddon, opts.confirmAddonCreation, opts.addonPlan, opts.addonRegion, opts.addonVersion, opts.addonOptions, opts.humanJsonOutputFormat],
625
- }, addon('create'));
479
+ }, addon.create);
626
480
  const addonDeleteCommand = cliparse.command('delete', {
627
481
  description: 'Delete an add-on',
628
482
  args: [args.addonIdOrName],
629
483
  options: [opts.confirmAddonDeletion],
630
- }, addon('delete'));
484
+ }, addon.deleteAddon);
631
485
  const addonRenameCommand = cliparse.command('rename', {
632
486
  description: 'Rename an add-on',
633
487
  args: [args.addonIdOrName, args.addonName],
634
- }, addon('rename'));
488
+ }, addon.rename);
635
489
  const addonShowProviderCommand = cliparse.command('show', {
636
490
  description: 'Show information about an add-on provider',
637
491
  args: [args.addonProvider],
638
- }, addon('showProvider'));
492
+ }, addon.showProvider);
639
493
  const addonProvidersCommand = cliparse.command('providers', {
640
494
  description: 'List available add-on providers',
641
495
  commands: [addonShowProviderCommand],
642
496
  options: [opts.humanJsonOutputFormat],
643
- }, addon('listProviders'));
497
+ }, addon.listProviders);
644
498
  const addonEnvCommand = cliparse.command('env', {
645
499
  description: 'List environment variables for an add-on',
646
500
  options: [opts.envFormat],
647
501
  args: [opts.addonId],
648
- }, addon('env'));
502
+ }, addon.env);
649
503
  const addonListCommand = cliparse.command('list', {
650
504
  description: 'List available add-ons',
651
505
  options: [opts.humanJsonOutputFormat],
652
- }, addon('list'));
506
+ }, addon.list);
653
507
 
654
508
  const addonCommands = cliparse.command('addon', {
655
509
  description: 'Manage add-ons',
656
510
  options: [opts.orgaIdOrName],
657
511
  privateOptions: [opts.humanJsonOutputFormat],
658
512
  commands: [addonCreateCommand, addonDeleteCommand, addonRenameCommand, addonListCommand, addonProvidersCommand, addonEnvCommand],
659
- }, addon('list'));
513
+ }, addon.list);
660
514
 
661
515
  // APPLICATIONS COMMAND
662
- const applications = lazyRequirePromiseModule('../src/commands/applications.js');
663
516
  const applicationsListRemoteCommand = cliparse.command('list', {
664
517
  description: 'List all applications',
665
518
  options: [opts.orgaIdOrName, opts.humanJsonOutputFormat],
666
- }, applications('listAll'));
519
+ }, applications.listAll);
667
520
  const applicationsCommand = cliparse.command('applications', {
668
521
  description: 'List linked applications',
669
522
  privateOptions: [opts.onlyAliases, opts.jsonFormat],
670
523
  commands: [applicationsListRemoteCommand],
671
- }, applications('list'));
524
+ }, applications.list);
672
525
 
673
526
  // CANCEL DEPLOY COMMAND
674
- const cancelDeploy = lazyRequirePromiseModule('../src/commands/cancel-deploy.js');
675
527
  const cancelDeployCommand = cliparse.command('cancel-deploy', {
676
528
  description: 'Cancel an ongoing deployment',
677
529
  options: [opts.alias, opts.appIdOrName],
678
- }, cancelDeploy('cancelDeploy'));
530
+ }, cancelDeploy.cancelDeploy);
679
531
 
680
532
  // CONFIG COMMAND
681
- const config = lazyRequirePromiseModule('../src/commands/config.js');
682
533
  const configGetCommand = cliparse.command('get', {
683
534
  description: 'Display the current configuration',
684
535
  args: [args.configurationName],
685
- }, config('get'));
536
+ }, config.get);
686
537
  const configSetCommand = cliparse.command('set', {
687
538
  description: 'Edit one configuration setting',
688
539
  args: [args.configurationName, args.configurationValue],
689
- }, config('set'));
540
+ }, config.set);
690
541
  const configUpdateCommand = cliparse.command('update', {
691
542
  description: 'Edit multiple configuration settings at once',
692
- options: ApplicationConfiguration('getUpdateOptions')(),
693
- }, config('update'));
543
+ options: ApplicationConfiguration.getUpdateOptions(),
544
+ }, config.update);
694
545
  const configCommands = cliparse.command('config', {
695
546
  description: 'Display or edit the configuration of your application',
696
547
  options: [opts.alias, opts.appIdOrName],
697
548
  commands: [configGetCommand, configSetCommand, configUpdateCommand],
698
- }, config('get'));
549
+ }, config.get);
699
550
 
700
551
  // CREATE COMMAND
701
- const create = lazyRequirePromiseModule('../src/commands/create.js');
702
552
  const appCreateCommand = cliparse.command('create', {
703
553
  description: 'Create an application',
704
554
  args: [args.appNameCreation],
705
555
  options: [opts.instanceType, opts.orgaIdOrName, opts.aliasCreation, opts.region, opts.github, opts.taskCommand, opts.humanJsonOutputFormat],
706
- }, create('create'));
556
+ }, create.create);
707
557
 
708
558
  // CURL COMMAND
709
559
  // NOTE: it's just here for documentation purposes, look at the bottom of the file for the real "clever curl" command
@@ -712,401 +562,305 @@ function run () {
712
562
  }, () => null);
713
563
 
714
564
  // DELETE COMMAND
715
- const deleteCommandModule = lazyRequirePromiseModule('../src/commands/delete.js');
716
565
  const deleteCommand = cliparse.command('delete', {
717
566
  description: 'Delete an application',
718
567
  options: [opts.alias, opts.appIdOrName, opts.confirmApplicationDeletion],
719
- }, deleteCommandModule('deleteApp'));
568
+ }, deleteCommandModule.deleteApp);
720
569
 
721
570
  // DEPLOY COMMAND
722
- const deploy = lazyRequirePromiseModule('../src/commands/deploy.js');
723
571
  const deployCommand = cliparse.command('deploy', {
724
572
  description: 'Deploy an application',
725
573
  options: [opts.alias, opts.branch, opts.gitTag, opts.quiet, opts.forceDeploy, opts.followDeployLogs, opts.sameCommitPolicy, opts.exitOnDeploy],
726
- }, deploy('deploy'));
574
+ }, deploy.deploy);
727
575
 
728
576
  // DIAG COMMAND
729
- const diag = lazyRequirePromiseModule('../src/commands/diag.js');
730
577
  const diagCommand = cliparse.command('diag', {
731
578
  description: 'Diagnose the current installation (prints various informations for support)',
732
579
  args: [],
733
580
  options: [opts.humanJsonOutputFormat],
734
- }, diag('diag'));
581
+ }, diag.diag);
735
582
 
736
583
  // DOMAIN COMMANDS
737
- const domain = lazyRequirePromiseModule('../src/commands/domain.js');
738
584
  const domainCreateCommand = cliparse.command('add', {
739
585
  description: 'Add a domain name to an application',
740
586
  args: [args.fqdn],
741
- }, domain('add'));
587
+ options: [opts.alias, opts.appIdOrName],
588
+ }, domain.add);
742
589
  const domainRemoveCommand = cliparse.command('rm', {
743
590
  description: 'Remove a domain name from an application',
744
591
  args: [args.fqdn],
745
- }, domain('rm'));
592
+ options: [opts.alias, opts.appIdOrName],
593
+ }, domain.rm);
746
594
  const domainSetFavouriteCommand = cliparse.command('set', {
747
595
  description: 'Set the favourite domain for an application',
748
596
  args: [args.fqdn],
749
- }, domain('setFavourite'));
597
+ }, domain.setFavourite);
750
598
  const domainUnsetFavouriteCommand = cliparse.command('unset', {
751
599
  description: 'Unset the favourite domain for an application',
752
- }, domain('unsetFavourite'));
600
+ }, domain.unsetFavourite);
753
601
  const domainFavouriteCommands = cliparse.command('favourite', {
754
602
  description: 'Manage the favourite domain name for an application',
603
+ options: [opts.alias, opts.appIdOrName],
755
604
  commands: [domainSetFavouriteCommand, domainUnsetFavouriteCommand],
756
- }, domain('getFavourite'));
605
+ }, domain.getFavourite);
606
+ const domainDiagApplicationCommand = cliparse.command('diag', {
607
+ description: 'Check if domains associated to a specific app are properly configured',
608
+ options: [opts.alias, opts.appIdOrName, opts.humanJsonOutputFormat, opts.domain],
609
+ }, domain.diagApplication);
610
+ const domainOverviewCommand = cliparse.command('overview', {
611
+ description: 'Get an overview of all your domains (all orgas, all apps)',
612
+ options: [opts.humanJsonOutputFormat, opts.domainOverviewFilter],
613
+ }, domain.overview);
757
614
  const domainCommands = cliparse.command('domain', {
758
615
  description: 'Manage domain names for an application',
759
- options: [opts.alias, opts.appIdOrName],
760
- commands: [domainCreateCommand, domainFavouriteCommands, domainRemoveCommand],
761
- }, domain('list'));
616
+ privateOptions: [opts.alias, opts.appIdOrName],
617
+ commands: [domainCreateCommand, domainFavouriteCommands, domainRemoveCommand, domainDiagApplicationCommand, domainOverviewCommand],
618
+ }, domain.list);
762
619
 
763
620
  // DRAIN COMMANDS
764
- const drain = lazyRequirePromiseModule('../src/commands/drain.js');
765
621
  const drainCreateCommand = cliparse.command('create', {
766
622
  description: 'Create a drain',
767
623
  args: [args.drainType, args.drainUrl],
768
624
  options: [opts.drainUsername, opts.drainPassword, opts.drainAPIKey, opts.drainIndexPrefix, opts.drainSDParameters],
769
- }, drain('create'));
625
+ }, drain.create);
770
626
  const drainRemoveCommand = cliparse.command('remove', {
771
627
  description: 'Remove a drain',
772
628
  args: [args.drainId],
773
- }, drain('rm'));
629
+ }, drain.rm);
774
630
  const drainEnableCommand = cliparse.command('enable', {
775
631
  description: 'Enable a drain',
776
632
  args: [args.drainId],
777
- }, drain('enable'));
633
+ }, drain.enable);
778
634
  const drainDisableCommand = cliparse.command('disable', {
779
635
  description: 'Disable a drain',
780
636
  args: [args.drainId],
781
- }, drain('disable'));
637
+ }, drain.disable);
782
638
  const drainCommands = cliparse.command('drain', {
783
639
  description: 'Manage drains',
784
640
  options: [opts.alias, opts.appIdOrName, opts.addonId],
785
641
  privateOptions: [opts.humanJsonOutputFormat],
786
642
  commands: [drainCreateCommand, drainRemoveCommand, drainEnableCommand, drainDisableCommand],
787
- }, drain('list'));
643
+ }, drain.list);
788
644
 
789
645
  // ENV COMMANDS
790
- const env = lazyRequirePromiseModule('../src/commands/env.js');
791
646
  const envSetCommand = cliparse.command('set', {
792
647
  description: 'Add or update an environment variable named <variable-name> with the value <variable-value>',
793
648
  args: [args.envVariableName, args.envVariableValue],
794
- }, env('set'));
649
+ }, env.set);
795
650
  const envRemoveCommand = cliparse.command('rm', {
796
651
  description: 'Remove an environment variable from an application',
797
652
  args: [args.envVariableName],
798
- }, env('rm'));
653
+ }, env.rm);
799
654
  const envImportCommand = cliparse.command('import', {
800
655
  description: 'Load environment variables from STDIN\n(WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)',
801
656
  options: [opts.importAsJson],
802
- }, env('importEnv'));
657
+ }, env.importEnv);
803
658
  const envImportVarsFromLocalEnvCommand = cliparse.command('import-vars', {
804
659
  description: 'Add or update environment variables named <variable-names> (comma-separated), taking their values from the current environment',
805
660
  args: [args.envVariableNames],
806
- }, env('importVarsFromLocalEnv'));
661
+ }, env.importVarsFromLocalEnv);
807
662
  const envCommands = cliparse.command('env', {
808
663
  description: 'Manage environment variables of an application',
809
664
  options: [opts.alias, opts.appIdOrName, opts.sourceableEnvVarsList],
810
665
  privateOptions: [opts.envFormat],
811
666
  commands: [envSetCommand, envRemoveCommand, envImportCommand, envImportVarsFromLocalEnvCommand],
812
- }, env('list'));
667
+ }, env.list);
813
668
 
814
669
  // LINK COMMAND
815
- const link = lazyRequirePromiseModule('../src/commands/link.js');
816
670
  const appLinkCommand = cliparse.command('link', {
817
671
  description: 'Link this repo to an existing application',
818
672
  args: [args.appIdOrName],
819
673
  options: [opts.aliasCreation, opts.orgaIdOrName],
820
- }, link('link'));
674
+ }, link.link);
821
675
 
822
676
  // LOGIN COMMAND
823
- const login = lazyRequirePromiseModule('../src/commands/login.js');
824
677
  const loginCommand = cliparse.command('login', {
825
678
  description: 'Login to Clever Cloud',
826
679
  options: [opts.loginToken, opts.loginSecret],
827
- }, login('login'));
680
+ }, login.login);
828
681
 
829
682
  // LOGOUT COMMAND
830
- const logout = lazyRequirePromiseModule('../src/commands/logout.js');
831
683
  const logoutCommand = cliparse.command('logout', {
832
684
  description: 'Logout from Clever Cloud',
833
- }, logout('logout'));
685
+ }, logout.logout);
834
686
 
835
687
  // LOGS COMMAND
836
- const logs = lazyRequirePromiseModule('../src/commands/logs.js');
837
688
  const logsCommand = cliparse.command('logs', {
838
689
  description: 'Fetch application logs, continuously',
839
690
  options: [opts.alias, opts.appIdOrName, opts.before, opts.after, opts.search, opts.deploymentId, opts.addonId, opts.logsFormat],
840
- }, logs('appLogs'));
691
+ }, logs.appLogs);
841
692
 
842
693
  // MAKE DEFAULT COMMAND
843
- const makeDefault = lazyRequirePromiseModule('../src/commands/makeDefault.js');
844
694
  const makeDefaultCommand = cliparse.command('make-default', {
845
695
  description: 'Make a linked application the default one',
846
696
  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
- });
697
+ }, makeDefault.makeDefault);
928
698
 
929
699
  // NOTIFY-EMAIL COMMAND
930
- const notifyEmail = lazyRequirePromiseModule('../src/commands/notify-email.js');
931
700
  const addEmailNotificationCommand = cliparse.command('add', {
932
701
  description: 'Add a new email notification',
933
702
  options: [opts.notificationEventType, opts.notificationScope, opts.emailNotificationTarget],
934
703
  args: [args.notificationName],
935
- }, notifyEmail('add'));
704
+ }, notifyEmail.add);
936
705
  const removeEmailNotificationCommand = cliparse.command('remove', {
937
706
  description: 'Remove an existing email notification',
938
707
  args: [args.notificationId],
939
- }, notifyEmail('remove'));
708
+ }, notifyEmail.remove);
940
709
  const emailNotificationsCommand = cliparse.command('notify-email', {
941
710
  description: 'Manage email notifications',
942
711
  options: [opts.orgaIdOrName, opts.listAllNotifications],
943
712
  privateOptions: [opts.humanJsonOutputFormat],
944
713
  commands: [addEmailNotificationCommand, removeEmailNotificationCommand],
945
- }, notifyEmail('list'));
714
+ }, notifyEmail.list);
946
715
 
947
716
  // OPEN COMMAND
948
- const open = lazyRequirePromiseModule('../src/commands/open.js');
949
717
  const openCommand = cliparse.command('open', {
950
718
  description: 'Open an application in your browser',
951
719
  options: [opts.alias, opts.appIdOrName],
952
- }, open('open'));
720
+ }, open.open);
953
721
 
954
722
  // CONSOLE COMMAND
955
- const consoleModule = lazyRequirePromiseModule('../src/commands/console.js');
956
723
  const consoleCommand = cliparse.command('console', {
957
724
  description: 'Open an application in the Console',
958
725
  options: [opts.alias, opts.appIdOrName],
959
- }, consoleModule('openConsole'));
726
+ }, consoleModule.openConsole);
960
727
 
961
728
  // PROFILE COMMAND
962
- const profile = lazyRequirePromiseModule('../src/commands/profile.js');
963
729
  const profileCommand = cliparse.command('profile', {
964
730
  description: 'Display the profile of the current user',
965
731
  options: [opts.humanJsonOutputFormat],
966
- }, profile('profile'));
732
+ }, profile.profile);
967
733
 
968
734
  // PUBLISHED CONFIG COMMANDS
969
- const publishedConfig = lazyRequirePromiseModule('../src/commands/published-config.js');
970
735
  const publishedConfigSetCommand = cliparse.command('set', {
971
736
  description: 'Add or update a published configuration item named <variable-name> with the value <variable-value>',
972
737
  args: [args.envVariableName, args.envVariableValue],
973
- }, publishedConfig('set'));
738
+ }, publishedConfig.set);
974
739
  const publishedConfigRemoveCommand = cliparse.command('rm', {
975
740
  description: 'Remove a published configuration variable from an application',
976
741
  args: [args.envVariableName],
977
- }, publishedConfig('rm'));
742
+ }, publishedConfig.rm);
978
743
  const publishedConfigImportCommand = cliparse.command('import', {
979
744
  description: 'Load published configuration from STDIN\n(WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)',
980
745
  options: [opts.importAsJson],
981
- }, publishedConfig('importEnv'));
746
+ }, publishedConfig.importEnv);
982
747
  const publishedConfigCommands = cliparse.command('published-config', {
983
748
  description: 'Manage the configuration made available to other applications by this application',
984
749
  options: [opts.alias, opts.appIdOrName],
985
750
  privateOptions: [opts.envFormat],
986
751
  commands: [publishedConfigSetCommand, publishedConfigRemoveCommand, publishedConfigImportCommand],
987
- }, publishedConfig('list'));
752
+ }, publishedConfig.list);
988
753
 
989
754
  // RESTART COMMAND
990
- const restart = lazyRequirePromiseModule('../src/commands/restart.js');
991
755
  const restartCommand = cliparse.command('restart', {
992
756
  description: 'Start or restart an application',
993
757
  options: [opts.alias, opts.appIdOrName, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs, opts.exitOnDeploy],
994
- }, restart('restart'));
758
+ }, restart.restart);
995
759
 
996
760
  // SCALE COMMAND
997
- const scale = lazyRequirePromiseModule('../src/commands/scale.js');
998
761
  const scaleCommand = cliparse.command('scale', {
999
762
  description: 'Change scalability of an application',
1000
763
  options: [opts.alias, opts.appIdOrName, opts.flavor, opts.minFlavor, opts.maxFlavor, opts.instances, opts.minInstances, opts.maxInstances, opts.buildFlavor],
1001
- }, scale('scale'));
764
+ }, scale.scale);
1002
765
 
1003
766
  // SERVICE COMMANDS
1004
- const service = lazyRequirePromiseModule('../src/commands/service.js');
1005
767
  const serviceLinkAppCommand = cliparse.command('link-app', {
1006
768
  description: 'Add an existing app as a dependency',
1007
769
  args: [args.appIdOrName],
1008
- }, service('linkApp'));
770
+ }, service.linkApp);
1009
771
  const serviceUnlinkAppCommand = cliparse.command('unlink-app', {
1010
772
  description: 'Remove an app from the dependencies',
1011
773
  args: [args.appIdOrName],
1012
- }, service('unlinkApp'));
774
+ }, service.unlinkApp);
1013
775
  const serviceLinkAddonCommand = cliparse.command('link-addon', {
1014
776
  description: 'Link an existing add-on to this application',
1015
777
  args: [args.addonIdOrName],
1016
- }, service('linkAddon'));
778
+ }, service.linkAddon);
1017
779
  const serviceUnlinkAddonCommand = cliparse.command('unlink-addon', {
1018
780
  description: 'Unlink an add-on from this application',
1019
781
  args: [args.addonIdOrName],
1020
- }, service('unlinkAddon'));
782
+ }, service.unlinkAddon);
1021
783
  const serviceCommands = cliparse.command('service', {
1022
784
  description: 'Manage service dependencies',
1023
785
  options: [opts.alias, opts.appIdOrName, opts.onlyApps, opts.onlyAddons, opts.showAll],
1024
786
  privateOptions: [opts.humanJsonOutputFormat],
1025
787
  commands: [serviceLinkAppCommand, serviceUnlinkAppCommand, serviceLinkAddonCommand, serviceUnlinkAddonCommand],
1026
- }, service('list'));
788
+ }, service.list);
1027
789
 
1028
790
  // SSH COMMAND
1029
- const ssh = lazyRequirePromiseModule('../src/commands/ssh.js');
1030
791
  const sshCommand = cliparse.command('ssh', {
1031
792
  description: 'Connect to running instances through SSH',
1032
793
  options: [opts.alias, opts.appIdOrName, opts.sshIdentityFile],
1033
- }, ssh('ssh'));
794
+ }, ssh.ssh);
1034
795
 
1035
796
  // STATUS COMMAND
1036
- const status = lazyRequirePromiseModule('../src/commands/status.js');
1037
797
  const statusCommand = cliparse.command('status', {
1038
798
  description: 'See the status of an application',
1039
799
  options: [opts.alias, opts.appIdOrName, opts.humanJsonOutputFormat],
1040
- }, status('status'));
800
+ }, status.status);
1041
801
 
1042
802
  // STOP COMMAND
1043
- const stop = lazyRequirePromiseModule('../src/commands/stop.js');
1044
803
  const stopCommand = cliparse.command('stop', {
1045
804
  description: 'Stop a running application',
1046
805
  options: [opts.alias, opts.appIdOrName],
1047
- }, stop('stop'));
806
+ }, stop.stop);
1048
807
 
1049
808
  // TCP-REDIRS COMMAND
1050
- const tcpRedirs = lazyRequirePromiseModule('../src/commands/tcp-redirs.js');
1051
809
  const tcpRedirsListNamespacesCommand = cliparse.command('list-namespaces', {
1052
810
  description: 'List the namespaces in which you can create new TCP redirections',
1053
811
  options: [opts.humanJsonOutputFormat],
1054
- }, tcpRedirs('listNamespaces'));
812
+ }, tcpRedirs.listNamespaces);
1055
813
  const tcpRedirsAddCommand = cliparse.command('add', {
1056
814
  description: 'Add a new TCP redirection to the application',
1057
815
  options: [opts.namespace, opts.confirmTcpRedirCreation],
1058
- }, tcpRedirs('add'));
816
+ }, tcpRedirs.add);
1059
817
  const tcpRedirsRemoveCommand = cliparse.command('remove', {
1060
818
  description: 'Remove a TCP redirection from the application',
1061
819
  options: [opts.namespace],
1062
820
  args: [args.port],
1063
- }, tcpRedirs('remove'));
821
+ }, tcpRedirs.remove);
1064
822
  const tcpRedirsCommands = cliparse.command('tcp-redirs', {
1065
823
  description: 'Control the TCP redirections from reverse proxies to your application',
1066
824
  options: [opts.alias, opts.appIdOrName],
1067
825
  privateOptions: [opts.humanJsonOutputFormat],
1068
826
  commands: [tcpRedirsListNamespacesCommand, tcpRedirsAddCommand, tcpRedirsRemoveCommand],
1069
- }, tcpRedirs('list'));
827
+ }, tcpRedirs.list);
1070
828
 
1071
829
  // UNLINK COMMAND
1072
- const unlink = lazyRequirePromiseModule('../src/commands/unlink.js');
1073
830
  const appUnlinkCommand = cliparse.command('unlink', {
1074
831
  description: 'Unlink this repo from an existing application',
1075
832
  args: [args.alias],
1076
- }, unlink('unlink'));
833
+ }, unlink.unlink);
1077
834
 
1078
835
  // VERSION COMMAND
1079
- const version = lazyRequirePromiseModule('../src/commands/version.js');
1080
836
  const versionCommand = cliparse.command('version', {
1081
837
  description: 'Display the clever-tools version',
1082
838
  args: [],
1083
- }, version('version'));
839
+ }, version.version);
1084
840
 
1085
841
  // WEBHOOKS COMMAND
1086
- const webhooks = lazyRequirePromiseModule('../src/commands/webhooks.js');
1087
842
  const addWebhookCommand = cliparse.command('add', {
1088
843
  description: 'Register webhook to be called when events happen',
1089
844
  options: [opts.webhookFormat, opts.notificationEventType, opts.notificationScope],
1090
845
  args: [args.notificationName, args.webhookUrl],
1091
- }, webhooks('add'));
846
+ }, webhooks.add);
1092
847
  const removeWebhookCommand = cliparse.command('remove', {
1093
848
  description: 'Remove an existing webhook',
1094
849
  args: [args.notificationId],
1095
- }, webhooks('remove'));
850
+ }, webhooks.remove);
1096
851
  const webhooksCommand = cliparse.command('webhooks', {
1097
852
  description: 'Manage webhooks',
1098
853
  options: [opts.orgaIdOrName, opts.listAllNotifications],
1099
854
  privateOptions: [opts.humanJsonOutputFormat],
1100
855
  commands: [addWebhookCommand, removeWebhookCommand],
1101
- }, webhooks('list'));
856
+ }, webhooks.list);
1102
857
 
1103
858
  // DATABASES COMMANDS
1104
- const database = lazyRequirePromiseModule('../src/commands/database.js');
1105
859
  const downloadBackupCommand = cliparse.command('download', {
1106
860
  description: 'Download a database backup',
1107
861
  args: [args.databaseId, args.backupId],
1108
862
  options: [opts.output],
1109
- }, database('downloadBackups'));
863
+ }, database.downloadBackups);
1110
864
  const backupsCommand = cliparse.command('backups', {
1111
865
  description: 'List available database backups',
1112
866
  args: [args.databaseId],
@@ -1114,11 +868,11 @@ function run () {
1114
868
  commands: [
1115
869
  downloadBackupCommand,
1116
870
  ],
1117
- }, database('listBackups'));
871
+ }, database.listBackups);
1118
872
  const databaseCommand = cliparse.command('database', {
1119
873
  description: 'List available databases',
1120
874
  commands: [backupsCommand],
1121
- }, () => {
875
+ }, async () => {
1122
876
  console.info('This command is not available, you can try the following commands:');
1123
877
  console.info('clever database backups');
1124
878
  console.info('clever database backups download');
@@ -1151,9 +905,6 @@ function run () {
1151
905
  logoutCommand,
1152
906
  logsCommand,
1153
907
  makeDefaultCommand,
1154
- // Not ready for stable release yet
1155
- // networkGroupsCommand,
1156
- // ngCommand,
1157
908
  openCommand,
1158
909
  consoleCommand,
1159
910
  profileCommand,
@@ -1173,7 +924,7 @@ function run () {
1173
924
  const cliParser = cliparse.cli({
1174
925
  name: 'clever',
1175
926
  description: 'CLI tool to manage Clever Cloud\'s data and products',
1176
- version: pkg.version,
927
+ version: getPackageJson().version,
1177
928
  options: [opts.color, opts.updateNotifier, opts.verbose],
1178
929
  helpCommand: false,
1179
930
  commands,
@@ -1188,7 +939,7 @@ function run () {
1188
939
  // Right now, this is the only way to do this properly
1189
940
  // cliparse doesn't allow unknown options/arguments
1190
941
  if (process.argv[2] === 'curl') {
1191
- require('../src/commands/curl.js').curl();
942
+ curl();
1192
943
  }
1193
944
  else {
1194
945
  run();