@contentstack/cli-config 1.17.0 → 1.18.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 CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version)
21
- @contentstack/cli-config/1.17.0 linux-x64 node-v22.21.1
21
+ @contentstack/cli-config/1.18.0 linux-x64 node-v22.22.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -33,16 +33,19 @@ USAGE
33
33
  * [`csdx config:get:ea-header`](#csdx-configgetea-header)
34
34
  * [`csdx config:get:early-access-header`](#csdx-configgetearly-access-header)
35
35
  * [`csdx config:get:log`](#csdx-configgetlog)
36
+ * [`csdx config:get:proxy`](#csdx-configgetproxy)
36
37
  * [`csdx config:get:rate-limit`](#csdx-configgetrate-limit)
37
38
  * [`csdx config:get:region`](#csdx-configgetregion)
38
39
  * [`csdx config:remove:base-branch`](#csdx-configremovebase-branch)
39
40
  * [`csdx config:remove:ea-header`](#csdx-configremoveea-header)
40
41
  * [`csdx config:remove:early-access-header`](#csdx-configremoveearly-access-header)
42
+ * [`csdx config:remove:proxy`](#csdx-configremoveproxy)
41
43
  * [`csdx config:remove:rate-limit`](#csdx-configremoverate-limit)
42
44
  * [`csdx config:set:base-branch`](#csdx-configsetbase-branch)
43
45
  * [`csdx config:set:ea-header`](#csdx-configsetea-header)
44
46
  * [`csdx config:set:early-access-header`](#csdx-configsetearly-access-header)
45
47
  * [`csdx config:set:log`](#csdx-configsetlog)
48
+ * [`csdx config:set:proxy`](#csdx-configsetproxy)
46
49
  * [`csdx config:set:rate-limit`](#csdx-configsetrate-limit)
47
50
  * [`csdx config:set:region [REGION]`](#csdx-configsetregion-region)
48
51
 
@@ -118,6 +121,23 @@ EXAMPLES
118
121
 
119
122
  _See code: [src/commands/config/get/log.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/get/log.ts)_
120
123
 
124
+ ## `csdx config:get:proxy`
125
+
126
+ Get proxy configuration for CLI
127
+
128
+ ```
129
+ USAGE
130
+ $ csdx config:get:proxy
131
+
132
+ DESCRIPTION
133
+ Get proxy configuration for CLI
134
+
135
+ EXAMPLES
136
+ $ csdx config:get:proxy
137
+ ```
138
+
139
+ _See code: [src/commands/config/get/proxy.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/get/proxy.ts)_
140
+
121
141
  ## `csdx config:get:rate-limit`
122
142
 
123
143
  Get rate-limit of organizations
@@ -227,6 +247,23 @@ EXAMPLES
227
247
 
228
248
  _See code: [src/commands/config/remove/early-access-header.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/remove/early-access-header.ts)_
229
249
 
250
+ ## `csdx config:remove:proxy`
251
+
252
+ Remove proxy configuration from global config
253
+
254
+ ```
255
+ USAGE
256
+ $ csdx config:remove:proxy
257
+
258
+ DESCRIPTION
259
+ Remove proxy configuration from global config
260
+
261
+ EXAMPLES
262
+ $ csdx config:remove:proxy
263
+ ```
264
+
265
+ _See code: [src/commands/config/remove/proxy.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/remove/proxy.ts)_
266
+
230
267
  ## `csdx config:remove:rate-limit`
231
268
 
232
269
  Remove rate-limit of the organization
@@ -358,6 +395,34 @@ EXAMPLES
358
395
 
359
396
  _See code: [src/commands/config/set/log.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/log.ts)_
360
397
 
398
+ ## `csdx config:set:proxy`
399
+
400
+ Set proxy configuration for CLI
401
+
402
+ ```
403
+ USAGE
404
+ $ csdx config:set:proxy --host <value> --port <value> --protocol http|https [--username <value>]
405
+
406
+ FLAGS
407
+ --host=<value> (required) Proxy host address
408
+ --port=<value> (required) Proxy port number
409
+ --protocol=<option> (required) [default: http] Proxy protocol (http or https)
410
+ <options: http|https>
411
+ --username=<value> Proxy username (optional)
412
+
413
+ DESCRIPTION
414
+ Set proxy configuration for CLI
415
+
416
+ EXAMPLES
417
+ $ csdx config:set:proxy --host 127.0.0.1 --port 3128
418
+
419
+ $ csdx config:set:proxy --host proxy.example.com --port 8080 --protocol https
420
+
421
+ $ csdx config:set:proxy --host proxy.example.com --port 8080 --username user
422
+ ```
423
+
424
+ _See code: [src/commands/config/set/proxy.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/proxy.ts)_
425
+
361
426
  ## `csdx config:set:rate-limit`
362
427
 
363
428
  Set rate-limit for CLI
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class ProxyGetCommand extends BaseCommand<typeof ProxyGetCommand> {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ const base_command_1 = require("../../../base-command");
5
+ class ProxyGetCommand extends base_command_1.BaseCommand {
6
+ async run() {
7
+ var _a, _b;
8
+ try {
9
+ cli_utilities_1.log.debug('Starting proxy configuration retrieval', this.contextDetails);
10
+ const globalProxyConfig = cli_utilities_1.configHandler.get('proxy');
11
+ if (globalProxyConfig) {
12
+ cli_utilities_1.log.debug('Proxy configuration found in global config', this.contextDetails);
13
+ let usernameValue = 'Not set';
14
+ if ((_a = globalProxyConfig.auth) === null || _a === void 0 ? void 0 : _a.username) {
15
+ usernameValue = globalProxyConfig.auth.username;
16
+ }
17
+ const proxyConfigList = [
18
+ {
19
+ Setting: 'Host',
20
+ Value: globalProxyConfig.host || 'Not set',
21
+ },
22
+ {
23
+ Setting: 'Port',
24
+ Value: globalProxyConfig.port ? String(globalProxyConfig.port) : 'Not set',
25
+ },
26
+ {
27
+ Setting: 'Protocol',
28
+ Value: globalProxyConfig.protocol || 'Not set',
29
+ },
30
+ {
31
+ Setting: 'Username',
32
+ Value: usernameValue,
33
+ },
34
+ {
35
+ Setting: 'Password',
36
+ Value: ((_b = globalProxyConfig.auth) === null || _b === void 0 ? void 0 : _b.password) ? '***' : 'Not set',
37
+ },
38
+ ];
39
+ const headers = [{ value: 'Setting' }, { value: 'Value' }];
40
+ cli_utilities_1.cliux.table(headers, proxyConfigList);
41
+ cli_utilities_1.log.info('Proxy configuration displayed successfully', this.contextDetails);
42
+ }
43
+ else {
44
+ cli_utilities_1.log.debug('No proxy configuration found in global config', this.contextDetails);
45
+ }
46
+ }
47
+ catch (error) {
48
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-get-proxy' }));
49
+ }
50
+ }
51
+ }
52
+ exports.default = ProxyGetCommand;
53
+ ProxyGetCommand.description = 'Get proxy configuration for CLI';
54
+ ProxyGetCommand.examples = ['csdx config:get:proxy'];
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class ProxyRemoveCommand extends BaseCommand<typeof ProxyRemoveCommand> {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ const base_command_1 = require("../../../base-command");
5
+ class ProxyRemoveCommand extends base_command_1.BaseCommand {
6
+ async run() {
7
+ try {
8
+ cli_utilities_1.log.debug('Starting proxy configuration removal', this.contextDetails);
9
+ const currentProxy = cli_utilities_1.configHandler.get('proxy');
10
+ if (!currentProxy) {
11
+ cli_utilities_1.log.debug('No proxy configuration found in global config', this.contextDetails);
12
+ return;
13
+ }
14
+ cli_utilities_1.log.debug('Removing proxy configuration from global config', this.contextDetails);
15
+ cli_utilities_1.configHandler.delete('proxy');
16
+ cli_utilities_1.log.success('Proxy configuration removed from global config successfully', this.contextDetails);
17
+ }
18
+ catch (error) {
19
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-remove-proxy' }));
20
+ }
21
+ }
22
+ }
23
+ exports.default = ProxyRemoveCommand;
24
+ ProxyRemoveCommand.description = 'Remove proxy configuration from global config';
25
+ ProxyRemoveCommand.examples = ['csdx config:remove:proxy'];
@@ -0,0 +1,8 @@
1
+ import { FlagInput } from '@contentstack/cli-utilities';
2
+ import { BaseCommand } from '../../../base-command';
3
+ export default class ProxySetCommand extends BaseCommand<typeof ProxySetCommand> {
4
+ static description: string;
5
+ static flags: FlagInput;
6
+ static examples: string[];
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ const interactive_1 = require("../../../utils/interactive");
5
+ const base_command_1 = require("../../../base-command");
6
+ class ProxySetCommand extends base_command_1.BaseCommand {
7
+ async run() {
8
+ try {
9
+ cli_utilities_1.log.debug('Starting proxy configuration setup', this.contextDetails);
10
+ const { flags } = await this.parse(ProxySetCommand);
11
+ cli_utilities_1.log.debug('Parsed proxy configuration flags', this.contextDetails);
12
+ // Validate host - must not be empty or whitespace-only
13
+ if (!flags.host || flags.host.trim() === '') {
14
+ cli_utilities_1.log.error('Invalid host provided - host cannot be empty or whitespace-only', this.contextDetails);
15
+ cli_utilities_1.cliux.error('Invalid host address. Host cannot be empty or contain only whitespace.');
16
+ return;
17
+ }
18
+ const port = Number.parseInt(flags.port, 10);
19
+ if (Number.isNaN(port) || port < 1 || port > 65535) {
20
+ cli_utilities_1.log.error('Invalid port number provided', this.contextDetails);
21
+ cli_utilities_1.cliux.error('Invalid port number. Port must be between 1 and 65535.');
22
+ return;
23
+ }
24
+ const proxyConfig = {
25
+ protocol: flags.protocol || 'http',
26
+ host: flags.host.trim(),
27
+ port: port,
28
+ };
29
+ if (flags.username) {
30
+ cli_utilities_1.log.debug('Username provided, prompting for password', this.contextDetails);
31
+ // Prompt for password when username is provided
32
+ const password = await (0, interactive_1.askProxyPassword)();
33
+ proxyConfig.auth = {
34
+ username: flags.username,
35
+ password: password || '',
36
+ };
37
+ cli_utilities_1.log.debug('Proxy authentication configured', this.contextDetails);
38
+ }
39
+ cli_utilities_1.log.debug('Saving proxy configuration to global config', this.contextDetails);
40
+ cli_utilities_1.configHandler.set('proxy', proxyConfig);
41
+ cli_utilities_1.log.success('Proxy configuration set successfully', this.contextDetails);
42
+ }
43
+ catch (error) {
44
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-set-proxy' }));
45
+ }
46
+ }
47
+ }
48
+ exports.default = ProxySetCommand;
49
+ ProxySetCommand.description = 'Set proxy configuration for CLI';
50
+ ProxySetCommand.flags = {
51
+ host: cli_utilities_1.flags.string({
52
+ description: 'Proxy host address',
53
+ required: true,
54
+ }),
55
+ port: cli_utilities_1.flags.string({
56
+ description: 'Proxy port number',
57
+ required: true,
58
+ }),
59
+ protocol: cli_utilities_1.flags.string({
60
+ description: 'Proxy protocol (http or https)',
61
+ options: ['http', 'https'],
62
+ default: 'http',
63
+ required: true,
64
+ }),
65
+ username: cli_utilities_1.flags.string({
66
+ description: 'Proxy username (optional)',
67
+ }),
68
+ };
69
+ ProxySetCommand.examples = [
70
+ 'csdx config:set:proxy --host 127.0.0.1 --port 3128',
71
+ 'csdx config:set:proxy --host proxy.example.com --port 8080 --protocol https',
72
+ 'csdx config:set:proxy --host proxy.example.com --port 8080 --username user',
73
+ ];
@@ -9,3 +9,4 @@ export declare function askEarlyAccessHeaderAlias(): Promise<string>;
9
9
  export declare const askOrgID: () => Promise<string>;
10
10
  export declare function askLogLevel(): Promise<string>;
11
11
  export declare function askLogPath(): Promise<string>;
12
+ export declare function askProxyPassword(): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.askLogPath = exports.askLogLevel = exports.askOrgID = exports.askEarlyAccessHeaderAlias = exports.askEarlyAccessHeaderValue = exports.inquireRequireFieldValidation = exports.askConfirmation = exports.askBaseBranch = exports.askStackAPIKey = exports.askCustomRegion = exports.askRegions = void 0;
3
+ exports.askProxyPassword = exports.askLogPath = exports.askLogLevel = exports.askOrgID = exports.askEarlyAccessHeaderAlias = exports.askEarlyAccessHeaderValue = exports.inquireRequireFieldValidation = exports.askConfirmation = exports.askBaseBranch = exports.askStackAPIKey = exports.askCustomRegion = exports.askRegions = void 0;
4
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
5
  const askRegions = async () => {
6
6
  return cli_utilities_1.cliux.inquire({
@@ -127,3 +127,14 @@ async function askLogPath() {
127
127
  return logPath;
128
128
  }
129
129
  exports.askLogPath = askLogPath;
130
+ async function askProxyPassword() {
131
+ return cli_utilities_1.cliux.inquire({
132
+ type: 'input',
133
+ message: 'Enter proxy password:',
134
+ name: 'password',
135
+ transformer: (password) => {
136
+ return '*'.repeat(password.length);
137
+ },
138
+ });
139
+ }
140
+ exports.askProxyPassword = askProxyPassword;
@@ -74,6 +74,30 @@
74
74
  "log.js"
75
75
  ]
76
76
  },
77
+ "config:get:proxy": {
78
+ "aliases": [],
79
+ "args": {},
80
+ "description": "Get proxy configuration for CLI",
81
+ "examples": [
82
+ "csdx config:get:proxy"
83
+ ],
84
+ "flags": {},
85
+ "hasDynamicHelp": false,
86
+ "hiddenAliases": [],
87
+ "id": "config:get:proxy",
88
+ "pluginAlias": "@contentstack/cli-config",
89
+ "pluginName": "@contentstack/cli-config",
90
+ "pluginType": "core",
91
+ "strict": true,
92
+ "isESM": false,
93
+ "relativePath": [
94
+ "lib",
95
+ "commands",
96
+ "config",
97
+ "get",
98
+ "proxy.js"
99
+ ]
100
+ },
77
101
  "config:get:rate-limit": {
78
102
  "aliases": [],
79
103
  "args": {},
@@ -205,6 +229,30 @@
205
229
  "early-access-header.js"
206
230
  ]
207
231
  },
232
+ "config:remove:proxy": {
233
+ "aliases": [],
234
+ "args": {},
235
+ "description": "Remove proxy configuration from global config",
236
+ "examples": [
237
+ "csdx config:remove:proxy"
238
+ ],
239
+ "flags": {},
240
+ "hasDynamicHelp": false,
241
+ "hiddenAliases": [],
242
+ "id": "config:remove:proxy",
243
+ "pluginAlias": "@contentstack/cli-config",
244
+ "pluginName": "@contentstack/cli-config",
245
+ "pluginType": "core",
246
+ "strict": true,
247
+ "isESM": false,
248
+ "relativePath": [
249
+ "lib",
250
+ "commands",
251
+ "config",
252
+ "remove",
253
+ "proxy.js"
254
+ ]
255
+ },
208
256
  "config:remove:rate-limit": {
209
257
  "aliases": [],
210
258
  "args": {},
@@ -378,6 +426,69 @@
378
426
  "log.js"
379
427
  ]
380
428
  },
429
+ "config:set:proxy": {
430
+ "aliases": [],
431
+ "args": {},
432
+ "description": "Set proxy configuration for CLI",
433
+ "examples": [
434
+ "csdx config:set:proxy --host 127.0.0.1 --port 3128",
435
+ "csdx config:set:proxy --host proxy.example.com --port 8080 --protocol https",
436
+ "csdx config:set:proxy --host proxy.example.com --port 8080 --username user"
437
+ ],
438
+ "flags": {
439
+ "host": {
440
+ "description": "Proxy host address",
441
+ "name": "host",
442
+ "required": true,
443
+ "hasDynamicHelp": false,
444
+ "multiple": false,
445
+ "type": "option"
446
+ },
447
+ "port": {
448
+ "description": "Proxy port number",
449
+ "name": "port",
450
+ "required": true,
451
+ "hasDynamicHelp": false,
452
+ "multiple": false,
453
+ "type": "option"
454
+ },
455
+ "protocol": {
456
+ "description": "Proxy protocol (http or https)",
457
+ "name": "protocol",
458
+ "required": true,
459
+ "default": "http",
460
+ "hasDynamicHelp": false,
461
+ "multiple": false,
462
+ "options": [
463
+ "http",
464
+ "https"
465
+ ],
466
+ "type": "option"
467
+ },
468
+ "username": {
469
+ "description": "Proxy username (optional)",
470
+ "name": "username",
471
+ "hasDynamicHelp": false,
472
+ "multiple": false,
473
+ "type": "option"
474
+ }
475
+ },
476
+ "hasDynamicHelp": false,
477
+ "hiddenAliases": [],
478
+ "id": "config:set:proxy",
479
+ "pluginAlias": "@contentstack/cli-config",
480
+ "pluginName": "@contentstack/cli-config",
481
+ "pluginType": "core",
482
+ "strict": true,
483
+ "isESM": false,
484
+ "relativePath": [
485
+ "lib",
486
+ "commands",
487
+ "config",
488
+ "set",
489
+ "proxy.js"
490
+ ]
491
+ },
381
492
  "config:set:rate-limit": {
382
493
  "aliases": [],
383
494
  "args": {},
@@ -556,5 +667,5 @@
556
667
  ]
557
668
  }
558
669
  },
559
- "version": "1.17.0"
670
+ "version": "1.18.0"
560
671
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-config",
3
3
  "description": "Contentstack CLI plugin for configuration",
4
- "version": "1.17.0",
4
+ "version": "1.18.0",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "npm run clean && npm run compile",
@@ -21,8 +21,8 @@
21
21
  "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
22
22
  },
23
23
  "dependencies": {
24
- "@contentstack/cli-command": "~1.7.1",
25
- "@contentstack/cli-utilities": "~1.16.0",
24
+ "@contentstack/cli-command": "~1.7.2",
25
+ "@contentstack/cli-utilities": "~1.17.0",
26
26
  "@oclif/core": "^4.3.0",
27
27
  "@oclif/plugin-help": "^6.2.28",
28
28
  "lodash": "^4.17.21"
@@ -32,7 +32,7 @@
32
32
  "@types/chai": "^4.3.20",
33
33
  "@types/mocha": "^8.2.3",
34
34
  "@types/node": "^14.18.63",
35
- "@types/sinon": "^10.0.20",
35
+ "@types/sinon": "^21.0.0",
36
36
  "chai": "^4.5.0",
37
37
  "eslint": "^8.57.1",
38
38
  "eslint-config-oclif": "^6.0.62",
@@ -40,7 +40,7 @@
40
40
  "mocha": "10.8.2",
41
41
  "nyc": "^15.1.0",
42
42
  "oclif": "^4.17.46",
43
- "sinon": "^19.0.5",
43
+ "sinon": "^21.0.1",
44
44
  "ts-node": "^10.9.2",
45
45
  "typescript": "^4.9.5"
46
46
  },