clever-tools 3.6.1 → 3.8.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.
- package/README.md +1 -7
- package/bin/clever.js +99 -47
- package/package.json +48 -50
- package/src/command-options.js +22 -3
- package/src/commands/accesslogs.js +114 -34
- package/src/commands/activity.js +70 -16
- package/src/commands/addon.js +153 -75
- package/src/commands/applications.js +83 -1
- package/src/commands/cancel-deploy.js +3 -3
- package/src/commands/config.js +6 -7
- package/src/commands/console.js +16 -4
- package/src/commands/curl.js +13 -16
- package/src/commands/delete.js +16 -6
- package/src/commands/deploy.js +9 -6
- package/src/commands/diag.js +68 -28
- package/src/commands/domain.js +13 -13
- package/src/commands/drain.js +42 -27
- package/src/commands/env.js +53 -24
- package/src/commands/logs.js +3 -3
- package/src/commands/notify-email.js +33 -18
- package/src/commands/open.js +3 -3
- package/src/commands/profile.js +29 -9
- package/src/commands/published-config.js +26 -15
- package/src/commands/restart.js +12 -5
- package/src/commands/scale.js +2 -3
- package/src/commands/service.js +42 -15
- package/src/commands/ssh.js +3 -3
- package/src/commands/status.js +72 -46
- package/src/commands/stop.js +3 -3
- package/src/commands/tcp-redirs.js +54 -18
- package/src/commands/webhooks.js +28 -13
- package/src/logger.js +9 -6
- package/src/models/addon.js +21 -12
- package/src/models/app_configuration.js +11 -3
- package/src/models/application.js +106 -7
- package/src/models/exit-strategy-option.js +24 -0
- package/src/models/json-array.js +28 -0
- package/src/models/log-v4.js +9 -29
- package/src/models/log.js +9 -2
- package/src/models/namespaces.js +20 -0
- package/src/models/organisation.js +0 -20
- package/src/models/utils.js +8 -1
- package/src/models/accesslogs.js +0 -54
- package/vendors/README_VENDORS.md +0 -18
- package/vendors/curlconverter-parse.js +0 -3709
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Clever Tools
|
|
2
2
|
|
|
3
|
-
Deploy on Clever Cloud and control
|
|
3
|
+
Deploy on Clever Cloud and control your applications, add-ons, services from command line.
|
|
4
4
|
|
|
5
5
|
- [Create a Clever Cloud account](https://console.clever-cloud.com)
|
|
6
6
|
|
|
@@ -70,9 +70,3 @@ If you want to know more or if you need to release a new version, please read [R
|
|
|
70
70
|
## License
|
|
71
71
|
|
|
72
72
|
This project is licensed under the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html).
|
|
73
|
-
|
|
74
|
-
We're using a CJS bundled version of a file from [curlconverter](https://github.com/curlconverter/curlconverter):
|
|
75
|
-
|
|
76
|
-
* The project is licensed with [MIT](https://github.com/curlconverter/curlconverter/blob/master/LICENSE)
|
|
77
|
-
* The copyright is at the top the file `vendors/curlconverter-parse`
|
|
78
|
-
* The details are explained in [README_VENDORS.md](vendors/README_VENDORS.md)
|
package/bin/clever.js
CHANGED
|
@@ -1,20 +1,55 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
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
|
+
|
|
4
15
|
// These need to be set before Logger and other stuffs
|
|
5
|
-
if (
|
|
16
|
+
if (hasParam('-v') || hasParam('--verbose')) {
|
|
6
17
|
process.env.CLEVER_VERBOSE = '1';
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
// These need to be set before Logger and other stuffs
|
|
10
21
|
// Don't log anything in autocomplete mode
|
|
11
|
-
if (
|
|
22
|
+
if (hasParam('--autocomplete-index')) {
|
|
12
23
|
process.env.CLEVER_QUIET = '1';
|
|
13
24
|
}
|
|
14
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
|
+
|
|
15
51
|
const cliparse = require('cliparse');
|
|
16
52
|
const cliparseCommands = require('cliparse/src/command.js');
|
|
17
|
-
const updateNotifier = require('update-notifier');
|
|
18
53
|
const _sortBy = require('lodash/sortBy.js');
|
|
19
54
|
|
|
20
55
|
const git = require('../src/models/git.js');
|
|
@@ -22,7 +57,7 @@ const Parsers = require('../src/parsers.js');
|
|
|
22
57
|
const handleCommandPromise = require('../src/command-promise-handler.js');
|
|
23
58
|
const Formatter = require('../src/models/format-string.js');
|
|
24
59
|
const { AVAILABLE_ZONES } = require('../src/models/application.js');
|
|
25
|
-
const { getOutputFormatOption, getSameCommitPolicyOption } = require('../src/command-options.js');
|
|
60
|
+
const { getOutputFormatOption, getSameCommitPolicyOption, getExitOnOption } = require('../src/command-options.js');
|
|
26
61
|
|
|
27
62
|
// Exit cleanly if the program we pipe to exits abruptly
|
|
28
63
|
process.stdout.on('error', (error) => {
|
|
@@ -31,20 +66,6 @@ process.stdout.on('error', (error) => {
|
|
|
31
66
|
}
|
|
32
67
|
});
|
|
33
68
|
|
|
34
|
-
const pkg = require('../package.json');
|
|
35
|
-
|
|
36
|
-
if (process.pkg == null) {
|
|
37
|
-
updateNotifier({
|
|
38
|
-
pkg,
|
|
39
|
-
tagsUrl: 'https://api.github.com/repos/CleverCloud/clever-tools/tags',
|
|
40
|
-
}).notify({
|
|
41
|
-
getDetails () {
|
|
42
|
-
const docsUrl = 'https://www.clever-cloud.com/doc/clever-tools/getting_started';
|
|
43
|
-
return `\nPlease follow this link to update your clever-tools:\n${docsUrl}`;
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
69
|
// Use this alias so we get less warnings in pkg build :p
|
|
49
70
|
const dynamicRequire = module.require.bind(module);
|
|
50
71
|
|
|
@@ -72,8 +93,8 @@ const Application = lazyRequire('../src/models/application.js');
|
|
|
72
93
|
const ApplicationConfiguration = lazyRequire('../src/models/application_configuration.js');
|
|
73
94
|
const Drain = lazyRequire('../src/models/drain.js');
|
|
74
95
|
const Notification = lazyRequire('../src/models/notification.js');
|
|
75
|
-
const Organisation = lazyRequire('../src/models/organisation.js');
|
|
76
96
|
const NetworkGroup = lazyRequire('../src/models/networkgroup.js');
|
|
97
|
+
const Namespaces = lazyRequire('../src/models/namespaces.js');
|
|
77
98
|
|
|
78
99
|
function run () {
|
|
79
100
|
|
|
@@ -133,9 +154,9 @@ function run () {
|
|
|
133
154
|
// OPTIONS
|
|
134
155
|
const opts = {
|
|
135
156
|
sourceableEnvVarsList: cliparse.flag('add-export', { description: 'Display sourceable env variables setting' }),
|
|
136
|
-
accesslogsFormat: getOutputFormatOption(['simple', 'extended', 'clf']),
|
|
137
|
-
addonEnvFormat: getOutputFormatOption(['shell']),
|
|
138
157
|
logsFormat: getOutputFormatOption(['json-stream']),
|
|
158
|
+
activityFormat: getOutputFormatOption(['json-stream']),
|
|
159
|
+
envFormat: getOutputFormatOption(['shell']),
|
|
139
160
|
accesslogsFollow: cliparse.flag('follow', {
|
|
140
161
|
aliases: ['f'],
|
|
141
162
|
description: 'Display access logs continuously (ignores before/until, after/since)',
|
|
@@ -202,7 +223,7 @@ function run () {
|
|
|
202
223
|
metavar: 'namespace',
|
|
203
224
|
description: 'Namespace in which the TCP redirection should be',
|
|
204
225
|
required: true,
|
|
205
|
-
complete:
|
|
226
|
+
complete: Namespaces('completeNamespaces'),
|
|
206
227
|
}),
|
|
207
228
|
notificationEventType: cliparse.option('event', {
|
|
208
229
|
metavar: 'type',
|
|
@@ -226,6 +247,7 @@ function run () {
|
|
|
226
247
|
aliases: ['f'],
|
|
227
248
|
description: 'Force deploy even if it\'s not fast-forwardable',
|
|
228
249
|
}),
|
|
250
|
+
exitOnDeploy: getExitOnOption(),
|
|
229
251
|
sameCommitPolicy: getSameCommitPolicyOption(),
|
|
230
252
|
webhookFormat: cliparse.option('format', {
|
|
231
253
|
metavar: 'format',
|
|
@@ -284,7 +306,10 @@ function run () {
|
|
|
284
306
|
parser: Parsers.instances,
|
|
285
307
|
description: 'The minimum number of parallel instances',
|
|
286
308
|
}),
|
|
287
|
-
|
|
309
|
+
updateNotifier: cliparse.flag('update-notifier', {
|
|
310
|
+
description: 'Choose whether to use update notifier or not. You can also use --no-update-notifier',
|
|
311
|
+
default: true,
|
|
312
|
+
}),
|
|
288
313
|
emailNotificationTarget: cliparse.option('notify', {
|
|
289
314
|
metavar: '<email_address>|<user_id>|"organisation"',
|
|
290
315
|
description: 'Notify a user, a specific email address or the whole organisation (multiple values allowed, comma separated)',
|
|
@@ -294,9 +319,15 @@ function run () {
|
|
|
294
319
|
onlyAddons: cliparse.flag('only-addons', { description: 'Only show add-on dependencies' }),
|
|
295
320
|
onlyAliases: cliparse.flag('only-aliases', { description: 'List only application aliases' }),
|
|
296
321
|
onlyApps: cliparse.flag('only-apps', { description: 'Only show app dependencies' }),
|
|
322
|
+
appIdOrName: cliparse.option('app', {
|
|
323
|
+
metavar: 'ID_OR_NAME',
|
|
324
|
+
description: 'Application to manage by its ID (or name, if unambiguous)',
|
|
325
|
+
parser: Parsers.appIdOrName,
|
|
326
|
+
}),
|
|
297
327
|
orgaIdOrName: cliparse.option('org', {
|
|
328
|
+
metavar: 'ID_OR_NAME',
|
|
298
329
|
aliases: ['o', 'owner'],
|
|
299
|
-
description: 'Organisation ID (or name, if unambiguous)',
|
|
330
|
+
description: 'Organisation to target by its ID (or name, if unambiguous)',
|
|
300
331
|
parser: Parsers.orgaIdOrName,
|
|
301
332
|
}),
|
|
302
333
|
output: cliparse.option('output', {
|
|
@@ -395,6 +426,10 @@ function run () {
|
|
|
395
426
|
description: '(TCP and UDP drains) sd-params string (e.g.: `X-OVH-TOKEN=\\"REDACTED\\"`)',
|
|
396
427
|
}),
|
|
397
428
|
verbose: cliparse.flag('verbose', { aliases: ['v'], description: 'Verbose output' }),
|
|
429
|
+
color: cliparse.flag('color', {
|
|
430
|
+
description: 'Choose whether to print colors or not. You can also use --no-color',
|
|
431
|
+
default: true,
|
|
432
|
+
}),
|
|
398
433
|
withoutCache: cliparse.flag('without-cache', { description: 'Restart the application without using cache' }),
|
|
399
434
|
confirmAddonCreation: cliparse.flag('yes', {
|
|
400
435
|
aliases: ['y'],
|
|
@@ -571,14 +606,14 @@ function run () {
|
|
|
571
606
|
const accesslogsModule = lazyRequirePromiseModule('../src/commands/accesslogs.js');
|
|
572
607
|
const accesslogsCommand = cliparse.command('accesslogs', {
|
|
573
608
|
description: 'Fetch access logs',
|
|
574
|
-
options: [opts.alias, opts.
|
|
609
|
+
options: [opts.alias, opts.appIdOrName, opts.logsFormat, opts.before, opts.after, opts.addonId],
|
|
575
610
|
}, accesslogsModule('accessLogs'));
|
|
576
611
|
|
|
577
612
|
// ACTIVITY COMMAND
|
|
578
613
|
const activity = lazyRequirePromiseModule('../src/commands/activity.js');
|
|
579
614
|
const activityCommand = cliparse.command('activity', {
|
|
580
615
|
description: 'Show last deployments of an application',
|
|
581
|
-
options: [opts.alias, opts.follow, opts.showAllActivity],
|
|
616
|
+
options: [opts.alias, opts.appIdOrName, opts.follow, opts.showAllActivity, opts.activityFormat],
|
|
582
617
|
}, activity('activity'));
|
|
583
618
|
|
|
584
619
|
// ADDON COMMANDS
|
|
@@ -604,10 +639,11 @@ function run () {
|
|
|
604
639
|
const addonProvidersCommand = cliparse.command('providers', {
|
|
605
640
|
description: 'List available add-on providers',
|
|
606
641
|
commands: [addonShowProviderCommand],
|
|
642
|
+
options: [opts.humanJsonOutputFormat],
|
|
607
643
|
}, addon('listProviders'));
|
|
608
644
|
const addonEnvCommand = cliparse.command('env', {
|
|
609
645
|
description: 'List environment variables for an add-on',
|
|
610
|
-
options: [opts.
|
|
646
|
+
options: [opts.envFormat],
|
|
611
647
|
args: [opts.addonId],
|
|
612
648
|
}, addon('env'));
|
|
613
649
|
const addonListCommand = cliparse.command('list', {
|
|
@@ -618,21 +654,27 @@ function run () {
|
|
|
618
654
|
const addonCommands = cliparse.command('addon', {
|
|
619
655
|
description: 'Manage add-ons',
|
|
620
656
|
options: [opts.orgaIdOrName],
|
|
657
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
621
658
|
commands: [addonCreateCommand, addonDeleteCommand, addonRenameCommand, addonListCommand, addonProvidersCommand, addonEnvCommand],
|
|
622
659
|
}, addon('list'));
|
|
623
660
|
|
|
624
661
|
// APPLICATIONS COMMAND
|
|
625
662
|
const applications = lazyRequirePromiseModule('../src/commands/applications.js');
|
|
663
|
+
const applicationsListRemoteCommand = cliparse.command('list', {
|
|
664
|
+
description: 'List all applications',
|
|
665
|
+
options: [opts.orgaIdOrName, opts.humanJsonOutputFormat],
|
|
666
|
+
}, applications('listAll'));
|
|
626
667
|
const applicationsCommand = cliparse.command('applications', {
|
|
627
668
|
description: 'List linked applications',
|
|
628
|
-
|
|
669
|
+
privateOptions: [opts.onlyAliases, opts.jsonFormat],
|
|
670
|
+
commands: [applicationsListRemoteCommand],
|
|
629
671
|
}, applications('list'));
|
|
630
672
|
|
|
631
673
|
// CANCEL DEPLOY COMMAND
|
|
632
674
|
const cancelDeploy = lazyRequirePromiseModule('../src/commands/cancel-deploy.js');
|
|
633
675
|
const cancelDeployCommand = cliparse.command('cancel-deploy', {
|
|
634
676
|
description: 'Cancel an ongoing deployment',
|
|
635
|
-
options: [opts.alias],
|
|
677
|
+
options: [opts.alias, opts.appIdOrName],
|
|
636
678
|
}, cancelDeploy('cancelDeploy'));
|
|
637
679
|
|
|
638
680
|
// CONFIG COMMAND
|
|
@@ -651,7 +693,7 @@ function run () {
|
|
|
651
693
|
}, config('update'));
|
|
652
694
|
const configCommands = cliparse.command('config', {
|
|
653
695
|
description: 'Display or edit the configuration of your application',
|
|
654
|
-
options: [opts.alias],
|
|
696
|
+
options: [opts.alias, opts.appIdOrName],
|
|
655
697
|
commands: [configGetCommand, configSetCommand, configUpdateCommand],
|
|
656
698
|
}, config('get'));
|
|
657
699
|
|
|
@@ -673,14 +715,14 @@ function run () {
|
|
|
673
715
|
const deleteCommandModule = lazyRequirePromiseModule('../src/commands/delete.js');
|
|
674
716
|
const deleteCommand = cliparse.command('delete', {
|
|
675
717
|
description: 'Delete an application',
|
|
676
|
-
options: [opts.alias, opts.confirmApplicationDeletion],
|
|
718
|
+
options: [opts.alias, opts.appIdOrName, opts.confirmApplicationDeletion],
|
|
677
719
|
}, deleteCommandModule('deleteApp'));
|
|
678
720
|
|
|
679
721
|
// DEPLOY COMMAND
|
|
680
722
|
const deploy = lazyRequirePromiseModule('../src/commands/deploy.js');
|
|
681
723
|
const deployCommand = cliparse.command('deploy', {
|
|
682
724
|
description: 'Deploy an application',
|
|
683
|
-
options: [opts.alias, opts.branch, opts.gitTag, opts.quiet, opts.forceDeploy, opts.followDeployLogs, opts.sameCommitPolicy],
|
|
725
|
+
options: [opts.alias, opts.branch, opts.gitTag, opts.quiet, opts.forceDeploy, opts.followDeployLogs, opts.sameCommitPolicy, opts.exitOnDeploy],
|
|
684
726
|
}, deploy('deploy'));
|
|
685
727
|
|
|
686
728
|
// DIAG COMMAND
|
|
@@ -688,6 +730,7 @@ function run () {
|
|
|
688
730
|
const diagCommand = cliparse.command('diag', {
|
|
689
731
|
description: 'Diagnose the current installation (prints various informations for support)',
|
|
690
732
|
args: [],
|
|
733
|
+
options: [opts.humanJsonOutputFormat],
|
|
691
734
|
}, diag('diag'));
|
|
692
735
|
|
|
693
736
|
// DOMAIN COMMANDS
|
|
@@ -713,7 +756,7 @@ function run () {
|
|
|
713
756
|
}, domain('getFavourite'));
|
|
714
757
|
const domainCommands = cliparse.command('domain', {
|
|
715
758
|
description: 'Manage domain names for an application',
|
|
716
|
-
options: [opts.alias],
|
|
759
|
+
options: [opts.alias, opts.appIdOrName],
|
|
717
760
|
commands: [domainCreateCommand, domainFavouriteCommands, domainRemoveCommand],
|
|
718
761
|
}, domain('list'));
|
|
719
762
|
|
|
@@ -738,7 +781,8 @@ function run () {
|
|
|
738
781
|
}, drain('disable'));
|
|
739
782
|
const drainCommands = cliparse.command('drain', {
|
|
740
783
|
description: 'Manage drains',
|
|
741
|
-
options: [opts.alias, opts.addonId],
|
|
784
|
+
options: [opts.alias, opts.appIdOrName, opts.addonId],
|
|
785
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
742
786
|
commands: [drainCreateCommand, drainRemoveCommand, drainEnableCommand, drainDisableCommand],
|
|
743
787
|
}, drain('list'));
|
|
744
788
|
|
|
@@ -762,7 +806,8 @@ function run () {
|
|
|
762
806
|
}, env('importVarsFromLocalEnv'));
|
|
763
807
|
const envCommands = cliparse.command('env', {
|
|
764
808
|
description: 'Manage environment variables of an application',
|
|
765
|
-
options: [opts.alias, opts.sourceableEnvVarsList],
|
|
809
|
+
options: [opts.alias, opts.appIdOrName, opts.sourceableEnvVarsList],
|
|
810
|
+
privateOptions: [opts.envFormat],
|
|
766
811
|
commands: [envSetCommand, envRemoveCommand, envImportCommand, envImportVarsFromLocalEnvCommand],
|
|
767
812
|
}, env('list'));
|
|
768
813
|
|
|
@@ -791,7 +836,7 @@ function run () {
|
|
|
791
836
|
const logs = lazyRequirePromiseModule('../src/commands/logs.js');
|
|
792
837
|
const logsCommand = cliparse.command('logs', {
|
|
793
838
|
description: 'Fetch application logs, continuously',
|
|
794
|
-
options: [opts.alias, opts.before, opts.after, opts.search, opts.deploymentId, opts.addonId, opts.logsFormat],
|
|
839
|
+
options: [opts.alias, opts.appIdOrName, opts.before, opts.after, opts.search, opts.deploymentId, opts.addonId, opts.logsFormat],
|
|
795
840
|
}, logs('appLogs'));
|
|
796
841
|
|
|
797
842
|
// MAKE DEFAULT COMMAND
|
|
@@ -895,6 +940,7 @@ function run () {
|
|
|
895
940
|
const emailNotificationsCommand = cliparse.command('notify-email', {
|
|
896
941
|
description: 'Manage email notifications',
|
|
897
942
|
options: [opts.orgaIdOrName, opts.listAllNotifications],
|
|
943
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
898
944
|
commands: [addEmailNotificationCommand, removeEmailNotificationCommand],
|
|
899
945
|
}, notifyEmail('list'));
|
|
900
946
|
|
|
@@ -902,20 +948,21 @@ function run () {
|
|
|
902
948
|
const open = lazyRequirePromiseModule('../src/commands/open.js');
|
|
903
949
|
const openCommand = cliparse.command('open', {
|
|
904
950
|
description: 'Open an application in your browser',
|
|
905
|
-
options: [opts.alias],
|
|
951
|
+
options: [opts.alias, opts.appIdOrName],
|
|
906
952
|
}, open('open'));
|
|
907
953
|
|
|
908
954
|
// CONSOLE COMMAND
|
|
909
955
|
const consoleModule = lazyRequirePromiseModule('../src/commands/console.js');
|
|
910
956
|
const consoleCommand = cliparse.command('console', {
|
|
911
957
|
description: 'Open an application in the Console',
|
|
912
|
-
options: [opts.alias],
|
|
958
|
+
options: [opts.alias, opts.appIdOrName],
|
|
913
959
|
}, consoleModule('openConsole'));
|
|
914
960
|
|
|
915
961
|
// PROFILE COMMAND
|
|
916
962
|
const profile = lazyRequirePromiseModule('../src/commands/profile.js');
|
|
917
963
|
const profileCommand = cliparse.command('profile', {
|
|
918
964
|
description: 'Display the profile of the current user',
|
|
965
|
+
options: [opts.humanJsonOutputFormat],
|
|
919
966
|
}, profile('profile'));
|
|
920
967
|
|
|
921
968
|
// PUBLISHED CONFIG COMMANDS
|
|
@@ -934,7 +981,8 @@ function run () {
|
|
|
934
981
|
}, publishedConfig('importEnv'));
|
|
935
982
|
const publishedConfigCommands = cliparse.command('published-config', {
|
|
936
983
|
description: 'Manage the configuration made available to other applications by this application',
|
|
937
|
-
options: [opts.alias],
|
|
984
|
+
options: [opts.alias, opts.appIdOrName],
|
|
985
|
+
privateOptions: [opts.envFormat],
|
|
938
986
|
commands: [publishedConfigSetCommand, publishedConfigRemoveCommand, publishedConfigImportCommand],
|
|
939
987
|
}, publishedConfig('list'));
|
|
940
988
|
|
|
@@ -942,14 +990,14 @@ function run () {
|
|
|
942
990
|
const restart = lazyRequirePromiseModule('../src/commands/restart.js');
|
|
943
991
|
const restartCommand = cliparse.command('restart', {
|
|
944
992
|
description: 'Start or restart an application',
|
|
945
|
-
options: [opts.alias, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs],
|
|
993
|
+
options: [opts.alias, opts.appIdOrName, opts.commit, opts.withoutCache, opts.quiet, opts.followDeployLogs, opts.exitOnDeploy],
|
|
946
994
|
}, restart('restart'));
|
|
947
995
|
|
|
948
996
|
// SCALE COMMAND
|
|
949
997
|
const scale = lazyRequirePromiseModule('../src/commands/scale.js');
|
|
950
998
|
const scaleCommand = cliparse.command('scale', {
|
|
951
999
|
description: 'Change scalability of an application',
|
|
952
|
-
options: [opts.alias, opts.flavor, opts.minFlavor, opts.maxFlavor, opts.instances, opts.minInstances, opts.maxInstances, opts.buildFlavor],
|
|
1000
|
+
options: [opts.alias, opts.appIdOrName, opts.flavor, opts.minFlavor, opts.maxFlavor, opts.instances, opts.minInstances, opts.maxInstances, opts.buildFlavor],
|
|
953
1001
|
}, scale('scale'));
|
|
954
1002
|
|
|
955
1003
|
// SERVICE COMMANDS
|
|
@@ -972,7 +1020,8 @@ function run () {
|
|
|
972
1020
|
}, service('unlinkAddon'));
|
|
973
1021
|
const serviceCommands = cliparse.command('service', {
|
|
974
1022
|
description: 'Manage service dependencies',
|
|
975
|
-
options: [opts.alias, opts.onlyApps, opts.onlyAddons, opts.showAll],
|
|
1023
|
+
options: [opts.alias, opts.appIdOrName, opts.onlyApps, opts.onlyAddons, opts.showAll],
|
|
1024
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
976
1025
|
commands: [serviceLinkAppCommand, serviceUnlinkAppCommand, serviceLinkAddonCommand, serviceUnlinkAddonCommand],
|
|
977
1026
|
}, service('list'));
|
|
978
1027
|
|
|
@@ -980,27 +1029,28 @@ function run () {
|
|
|
980
1029
|
const ssh = lazyRequirePromiseModule('../src/commands/ssh.js');
|
|
981
1030
|
const sshCommand = cliparse.command('ssh', {
|
|
982
1031
|
description: 'Connect to running instances through SSH',
|
|
983
|
-
options: [opts.alias, opts.sshIdentityFile],
|
|
1032
|
+
options: [opts.alias, opts.appIdOrName, opts.sshIdentityFile],
|
|
984
1033
|
}, ssh('ssh'));
|
|
985
1034
|
|
|
986
1035
|
// STATUS COMMAND
|
|
987
1036
|
const status = lazyRequirePromiseModule('../src/commands/status.js');
|
|
988
1037
|
const statusCommand = cliparse.command('status', {
|
|
989
1038
|
description: 'See the status of an application',
|
|
990
|
-
options: [opts.alias],
|
|
1039
|
+
options: [opts.alias, opts.appIdOrName, opts.humanJsonOutputFormat],
|
|
991
1040
|
}, status('status'));
|
|
992
1041
|
|
|
993
1042
|
// STOP COMMAND
|
|
994
1043
|
const stop = lazyRequirePromiseModule('../src/commands/stop.js');
|
|
995
1044
|
const stopCommand = cliparse.command('stop', {
|
|
996
1045
|
description: 'Stop a running application',
|
|
997
|
-
options: [opts.alias],
|
|
1046
|
+
options: [opts.alias, opts.appIdOrName],
|
|
998
1047
|
}, stop('stop'));
|
|
999
1048
|
|
|
1000
1049
|
// TCP-REDIRS COMMAND
|
|
1001
1050
|
const tcpRedirs = lazyRequirePromiseModule('../src/commands/tcp-redirs.js');
|
|
1002
1051
|
const tcpRedirsListNamespacesCommand = cliparse.command('list-namespaces', {
|
|
1003
1052
|
description: 'List the namespaces in which you can create new TCP redirections',
|
|
1053
|
+
options: [opts.humanJsonOutputFormat],
|
|
1004
1054
|
}, tcpRedirs('listNamespaces'));
|
|
1005
1055
|
const tcpRedirsAddCommand = cliparse.command('add', {
|
|
1006
1056
|
description: 'Add a new TCP redirection to the application',
|
|
@@ -1013,7 +1063,8 @@ function run () {
|
|
|
1013
1063
|
}, tcpRedirs('remove'));
|
|
1014
1064
|
const tcpRedirsCommands = cliparse.command('tcp-redirs', {
|
|
1015
1065
|
description: 'Control the TCP redirections from reverse proxies to your application',
|
|
1016
|
-
options: [opts.alias],
|
|
1066
|
+
options: [opts.alias, opts.appIdOrName],
|
|
1067
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
1017
1068
|
commands: [tcpRedirsListNamespacesCommand, tcpRedirsAddCommand, tcpRedirsRemoveCommand],
|
|
1018
1069
|
}, tcpRedirs('list'));
|
|
1019
1070
|
|
|
@@ -1045,6 +1096,7 @@ function run () {
|
|
|
1045
1096
|
const webhooksCommand = cliparse.command('webhooks', {
|
|
1046
1097
|
description: 'Manage webhooks',
|
|
1047
1098
|
options: [opts.orgaIdOrName, opts.listAllNotifications],
|
|
1099
|
+
privateOptions: [opts.humanJsonOutputFormat],
|
|
1048
1100
|
commands: [addWebhookCommand, removeWebhookCommand],
|
|
1049
1101
|
}, webhooks('list'));
|
|
1050
1102
|
|
|
@@ -1122,7 +1174,7 @@ function run () {
|
|
|
1122
1174
|
name: 'clever',
|
|
1123
1175
|
description: 'CLI tool to manage Clever Cloud\'s data and products',
|
|
1124
1176
|
version: pkg.version,
|
|
1125
|
-
options: [opts.verbose, opts.
|
|
1177
|
+
options: [opts.color, opts.verbose, opts.updateNotifier],
|
|
1126
1178
|
helpCommand: false,
|
|
1127
1179
|
commands,
|
|
1128
1180
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clever-tools",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Command Line Interface for Clever Cloud.",
|
|
5
5
|
"main": "bin/clever.js",
|
|
6
6
|
"keywords": [
|
|
@@ -22,68 +22,66 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"bin",
|
|
24
24
|
"src",
|
|
25
|
-
"scripts/*.sh"
|
|
26
|
-
"vendors"
|
|
25
|
+
"scripts/*.sh"
|
|
27
26
|
],
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@clevercloud/client": "
|
|
30
|
-
"
|
|
31
|
-
"cliparse": "^0.3.3",
|
|
28
|
+
"@clevercloud/client": "8.3.0",
|
|
29
|
+
"cliparse": "0.4.0",
|
|
32
30
|
"colors": "1.4.0",
|
|
33
|
-
"common-env": "
|
|
34
|
-
"curlconverter": "
|
|
35
|
-
"duration-js": "
|
|
36
|
-
"eventsource": "
|
|
37
|
-
"iso8601-duration": "
|
|
38
|
-
"isomorphic-git": "
|
|
39
|
-
"linux-release-info": "
|
|
40
|
-
"lodash": "
|
|
41
|
-
"mkdirp": "
|
|
42
|
-
"moment": "
|
|
43
|
-
"open": "
|
|
44
|
-
"slugify": "
|
|
45
|
-
"string-length": "
|
|
46
|
-
"superagent": "
|
|
47
|
-
"text-table": "
|
|
48
|
-
"update-notifier": "
|
|
49
|
-
"uuid": "
|
|
50
|
-
"ws": "
|
|
51
|
-
"xdg": "
|
|
31
|
+
"common-env": "6.4.0",
|
|
32
|
+
"curlconverter": "3.21.0",
|
|
33
|
+
"duration-js": "4.0.0",
|
|
34
|
+
"eventsource": "1.1.0",
|
|
35
|
+
"iso8601-duration": "2.1.2",
|
|
36
|
+
"isomorphic-git": "1.25.3",
|
|
37
|
+
"linux-release-info": "3.0.0",
|
|
38
|
+
"lodash": "4.17.21",
|
|
39
|
+
"mkdirp": "1.0.4",
|
|
40
|
+
"moment": "2.29.1",
|
|
41
|
+
"open": "8.4.0",
|
|
42
|
+
"slugify": "1.5.3",
|
|
43
|
+
"string-length": "4.0.2",
|
|
44
|
+
"superagent": "6.1.0",
|
|
45
|
+
"text-table": "0.2.0",
|
|
46
|
+
"update-notifier": "5.1.0",
|
|
47
|
+
"uuid": "8.3.2",
|
|
48
|
+
"ws": "7.4.6",
|
|
49
|
+
"xdg": "0.1.1"
|
|
52
50
|
},
|
|
53
51
|
"devDependencies": {
|
|
54
|
-
"@commitlint/cli": "
|
|
55
|
-
"@commitlint/config-conventional": "
|
|
56
|
-
"aws-sdk": "
|
|
57
|
-
"chai": "
|
|
58
|
-
"del": "
|
|
59
|
-
"eslint": "
|
|
60
|
-
"eslint-config-standard": "
|
|
61
|
-
"eslint-plugin-import": "
|
|
62
|
-
"eslint-plugin-node": "
|
|
63
|
-
"eslint-plugin-promise": "
|
|
64
|
-
"eslint-plugin-standard": "
|
|
65
|
-
"fs-extra": "
|
|
66
|
-
"glob": "
|
|
67
|
-
"grunt": "
|
|
68
|
-
"grunt-cli": "
|
|
69
|
-
"grunt-http": "
|
|
70
|
-
"grunt-mocha-test": "
|
|
71
|
-
"mime-types": "
|
|
72
|
-
"mocha": "
|
|
73
|
-
"pkg": "
|
|
74
|
-
"rollup": "
|
|
75
|
-
"semver": "
|
|
76
|
-
"text-table": "
|
|
52
|
+
"@commitlint/cli": "18.4.3",
|
|
53
|
+
"@commitlint/config-conventional": "18.4.3",
|
|
54
|
+
"aws-sdk": "2.919.0",
|
|
55
|
+
"chai": "4.3.4",
|
|
56
|
+
"del": "6.0.0",
|
|
57
|
+
"eslint": "7.27.0",
|
|
58
|
+
"eslint-config-standard": "16.0.3",
|
|
59
|
+
"eslint-plugin-import": "2.23.4",
|
|
60
|
+
"eslint-plugin-node": "11.1.0",
|
|
61
|
+
"eslint-plugin-promise": "5.1.0",
|
|
62
|
+
"eslint-plugin-standard": "5.0.0",
|
|
63
|
+
"fs-extra": "10.0.0",
|
|
64
|
+
"glob": "7.1.7",
|
|
65
|
+
"grunt": "1.4.1",
|
|
66
|
+
"grunt-cli": "1.4.3",
|
|
67
|
+
"grunt-http": "2.3.3",
|
|
68
|
+
"grunt-mocha-test": "0.13.3",
|
|
69
|
+
"mime-types": "2.1.35",
|
|
70
|
+
"mocha": "8.4.0",
|
|
71
|
+
"pkg": "5.8.1",
|
|
72
|
+
"rollup": "4.14.1",
|
|
73
|
+
"semver": "7.3.5",
|
|
74
|
+
"text-table": "0.2.0"
|
|
77
75
|
},
|
|
78
76
|
"overrides": {
|
|
79
77
|
"pkg-fetch": "3.5.2"
|
|
80
78
|
},
|
|
81
79
|
"scripts": {
|
|
82
|
-
"bundle-curlconverter": "rollup -c rollup-curlconverter.config.js",
|
|
83
80
|
"pretest": "npm run lint",
|
|
84
81
|
"test": "grunt test",
|
|
85
82
|
"lint": "eslint bin src scripts",
|
|
86
|
-
"lint:fix": "eslint --fix bin src scripts"
|
|
83
|
+
"lint:fix": "eslint --fix bin src scripts",
|
|
84
|
+
"install-local:cliparse": "(cd ../cliparse-node && npm pack) && mv ../cliparse-node/cliparse-*.tgz . && npm i -f ./cliparse-*.tgz"
|
|
87
85
|
},
|
|
88
86
|
"repository": {
|
|
89
87
|
"type": "git",
|
package/src/command-options.js
CHANGED
|
@@ -22,21 +22,40 @@ function getSameCommitPolicyOption () {
|
|
|
22
22
|
const availablePolicies = ['error', 'ignore', 'restart', 'rebuild'];
|
|
23
23
|
return cliparse.option('same-commit-policy', {
|
|
24
24
|
aliases: ['p'],
|
|
25
|
-
metavar: '
|
|
25
|
+
metavar: 'policy',
|
|
26
26
|
parser: (policy) => {
|
|
27
27
|
return availablePolicies.includes(policy)
|
|
28
28
|
? cliparse.parsers.success(policy)
|
|
29
|
-
: cliparse.parsers.error(`
|
|
29
|
+
: cliparse.parsers.error(`the policy must be one of ${availablePolicies.join(', ')}`);
|
|
30
30
|
},
|
|
31
31
|
default: 'error',
|
|
32
|
-
description: `
|
|
32
|
+
description: `What to do when local and remote commit are identical (${availablePolicies.join(', ')})`,
|
|
33
33
|
complete () {
|
|
34
34
|
return cliparse.autocomplete.words(availablePolicies);
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function getExitOnOption () {
|
|
40
|
+
const availableExitOn = ['deploy-start', 'deploy-end', 'never'];
|
|
41
|
+
return cliparse.option('exit-on', {
|
|
42
|
+
aliases: ['e'],
|
|
43
|
+
metavar: 'exiton',
|
|
44
|
+
parser: (exitOnStrategy) => {
|
|
45
|
+
return availableExitOn.includes(exitOnStrategy)
|
|
46
|
+
? cliparse.parsers.success(exitOnStrategy)
|
|
47
|
+
: cliparse.parsers.error(`The exit-on strategy must be one of ${availableExitOn.join(', ')}`);
|
|
48
|
+
},
|
|
49
|
+
default: 'deploy-end',
|
|
50
|
+
description: `Step at which the logs streaming is ended, steps are: ${availableExitOn.join(', ')}`,
|
|
51
|
+
complete () {
|
|
52
|
+
return cliparse.autocomplete.words(availableExitOn);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
module.exports = {
|
|
40
58
|
getOutputFormatOption,
|
|
41
59
|
getSameCommitPolicyOption,
|
|
60
|
+
getExitOnOption,
|
|
42
61
|
};
|