• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / boxcli / 5794698568

pending completion
5794698568

Pull #488

github

web-flow
Merge 96c25857d into 3bc6a83f7
Pull Request #488: docs: Update docs after release 3.9.2

1113 of 1441 branches covered (77.24%)

Branch coverage included in aggregate %.

4135 of 4633 relevant lines covered (89.25%)

468.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.63
/src/commands/configure/settings.js
1
'use strict';
2

3
const BoxCommand = require('../../box-command');
12✔
4
const { flags } = require('@oclif/command');
12✔
5
const fs = require('fs');
12✔
6
const mkdirp = require('mkdirp');
12✔
7
const BoxCLIError = require('../../cli-error');
12✔
8
const utils = require('../../util');
12✔
9

10
/* eslint-disable no-sync */
11

12
class ConfigureSettingsCommand extends BoxCommand {
13
        async run() {
14
                const { flags, args } = this.parse(ConfigureSettingsCommand);
×
15
                let settings = this.settings;
×
16

17
                if (flags['downloads-folder-path']) {
×
18
                        let downloadsPath = flags['downloads-folder-path'];
×
19
                        if (!fs.existsSync(downloadsPath)) {
×
20
                                let shouldCreate = await this.confirm(
×
21
                                        `Folder ${downloadsPath} does not exist; create it?`
22
                                );
23

24
                                if (!shouldCreate) {
×
25
                                        throw new BoxCLIError(
×
26
                                                'Could not update settings due to incorrect folder path'
27
                                        );
28
                                }
29

30
                                try {
×
31
                                        await mkdirp(downloadsPath);
×
32
                                } catch (ex) {
33
                                        throw new BoxCLIError('Could not create downloads directory', ex);
×
34
                                }
35
                        } else if (!fs.statSync(downloadsPath).isDirectory()) {
×
36
                                throw new BoxCLIError(`${downloadsPath} is not a directory!`);
×
37
                        }
38

39
                        settings.boxDownloadsFolderPath = downloadsPath;
×
40
                }
41
                if (flags['file-format']) {
×
42
                        settings.boxReportsFileFormat = flags['file-format'];
×
43
                }
44
                if (flags['reports-folder-path']) {
×
45
                        let reportsPath = flags['reports-folder-path'];
×
46
                        if (!fs.existsSync(reportsPath)) {
×
47
                                let shouldCreate = await this.confirm(
×
48
                                        `Folder ${reportsPath} does not exist; create it?`
49
                                );
50

51
                                if (!shouldCreate) {
×
52
                                        throw new BoxCLIError(
×
53
                                                'Could not update settings due to incorrect folder path'
54
                                        );
55
                                }
56

57
                                try {
×
58
                                        await mkdirp(reportsPath);
×
59
                                } catch (ex) {
60
                                        throw new BoxCLIError('Could not create downloads directory', ex);
×
61
                                }
62
                        } else if (!fs.statSync(reportsPath).isDirectory()) {
×
63
                                throw new BoxCLIError(`${reportsPath} is not a directory!`);
×
64
                        }
65
                        settings.boxReportsFolderPath = reportsPath;
×
66
                }
67
                if (flags.hasOwnProperty('output-json')) {
×
68
                        settings.outputJson = flags['output-json'];
×
69
                }
70
                if (flags.hasOwnProperty('enable-proxy')) {
×
71
                        settings.enableProxy = flags['enable-proxy'];
×
72
                }
73
                if (flags['proxy-url']) {
×
74
                        settings.proxy.url = flags['proxy-url'];
×
75
                }
76
                if (flags['proxy-username']) {
×
77
                        settings.proxy.username = flags['proxy-username'];
×
78
                }
79
                if (flags['proxy-password']) {
×
80
                        settings.proxy.password = flags['proxy-password'];
×
81
                }
82
                if (flags.hasOwnProperty(['enable-analytics-client'])) {
×
83
                        settings.enableAnalyticsClient = flags['enable-analytics-client'];
×
84
                }
85
                if (flags['analytics-client-name']) {
×
86
                        settings.analyticsClient.name = flags['analytics-client-name'];
×
87
                }
88

89
                this.updateSettings(settings);
×
90
                await this.output(settings);
×
91
        }
92
}
93

94
// @NOTE: This command does not require a client to be set up
95
ConfigureSettingsCommand.noClient = true;
12✔
96

97
ConfigureSettingsCommand.description =
12✔
98
        'View and update CLI configuration settings';
99

100
ConfigureSettingsCommand.flags = {
12✔
101
        ...BoxCommand.minFlags,
102
        json: flags.boolean({
103
                description: 'Output CLI configuration settings in JSON format'
104
        }),
105
        'enable-proxy': flags.boolean({
106
                description: 'Enable or disable proxy',
107
                allowNo: true,
108
        }),
109
        'proxy-url': flags.string({
110
                description:
111
                        'Set proxy url, which should contain the protocol, url, and port (i.e. http://sample.proxyurl.com:80)',
112
        }),
113
        'proxy-username': flags.string({
114
                description: 'Set username for proxy',
115
                dependsOn: ['proxy-password'],
116
        }),
117
        'proxy-password': flags.string({
118
                description: 'Set password for proxy',
119
                dependsOn: ['proxy-username'],
120
        }),
121
        'downloads-folder-path': flags.string({
122
                description: 'Set folder path for the downloads folder',
123
                parse: utils.parsePath,
124
        }),
125
        'file-format': flags.string({
126
                description: 'Set the file format for generated reports',
127
                options: ['csv', 'json', 'txt'],
128
        }),
129
        'output-json': flags.boolean({
130
                description: 'Default to JSON output for all commands',
131
                allowNo: true,
132
        }),
133
        'reports-folder-path': flags.string({
134
                description: 'Set folder path for the reports folder',
135
                parse: utils.parsePath,
136
        }),
137
        'enable-analytics-client': flags.boolean({
138
                description: 'Enable or disable custom analytics client',
139
                allowNo: true,
140
        }),
141
        'analytics-client-name': flags.string({
142
                description: 'Set custom analytics client header value',
143
        }),
144
};
145

146
module.exports = ConfigureSettingsCommand;
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc