@contentstack/cli-config 1.13.0 → 1.15.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 +47 -1
- package/lib/commands/config/get/log.d.ts +6 -0
- package/lib/commands/config/get/log.js +35 -0
- package/lib/commands/config/set/log.d.ts +8 -0
- package/lib/commands/config/set/log.js +57 -0
- package/lib/commands/config/set/rate-limit.js +6 -2
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/utils/interactive.d.ts +2 -0
- package/lib/utils/interactive.js +24 -1
- package/lib/utils/rate-limit-handler.js +0 -1
- package/messages/index.json +9 -4
- package/oclif.manifest.json +78 -1
- package/package.json +3 -3
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.
|
|
21
|
+
@contentstack/cli-config/1.15.0 linux-x64 node-v22.17.1
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -32,6 +32,7 @@ USAGE
|
|
|
32
32
|
* [`csdx config:get:base-branch`](#csdx-configgetbase-branch)
|
|
33
33
|
* [`csdx config:get:ea-header`](#csdx-configgetea-header)
|
|
34
34
|
* [`csdx config:get:early-access-header`](#csdx-configgetearly-access-header)
|
|
35
|
+
* [`csdx config:get:log`](#csdx-configgetlog)
|
|
35
36
|
* [`csdx config:get:rate-limit`](#csdx-configgetrate-limit)
|
|
36
37
|
* [`csdx config:get:region`](#csdx-configgetregion)
|
|
37
38
|
* [`csdx config:remove:base-branch`](#csdx-configremovebase-branch)
|
|
@@ -41,6 +42,7 @@ USAGE
|
|
|
41
42
|
* [`csdx config:set:base-branch`](#csdx-configsetbase-branch)
|
|
42
43
|
* [`csdx config:set:ea-header`](#csdx-configsetea-header)
|
|
43
44
|
* [`csdx config:set:early-access-header`](#csdx-configsetearly-access-header)
|
|
45
|
+
* [`csdx config:set:log`](#csdx-configsetlog)
|
|
44
46
|
* [`csdx config:set:rate-limit`](#csdx-configsetrate-limit)
|
|
45
47
|
* [`csdx config:set:region [REGION]`](#csdx-configsetregion-region)
|
|
46
48
|
|
|
@@ -99,6 +101,23 @@ EXAMPLES
|
|
|
99
101
|
|
|
100
102
|
_See code: [src/commands/config/get/early-access-header.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/get/early-access-header.ts)_
|
|
101
103
|
|
|
104
|
+
## `csdx config:get:log`
|
|
105
|
+
|
|
106
|
+
Get logging configuration for CLI
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
USAGE
|
|
110
|
+
$ csdx config:get:log
|
|
111
|
+
|
|
112
|
+
DESCRIPTION
|
|
113
|
+
Get logging configuration for CLI
|
|
114
|
+
|
|
115
|
+
EXAMPLES
|
|
116
|
+
$ csdx config:get:log
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
_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
|
+
|
|
102
121
|
## `csdx config:get:rate-limit`
|
|
103
122
|
|
|
104
123
|
Get rate-limit of organizations
|
|
@@ -301,6 +320,33 @@ EXAMPLES
|
|
|
301
320
|
|
|
302
321
|
_See code: [src/commands/config/set/early-access-header.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/early-access-header.ts)_
|
|
303
322
|
|
|
323
|
+
## `csdx config:set:log`
|
|
324
|
+
|
|
325
|
+
Set logging configuration for CLI
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
USAGE
|
|
329
|
+
$ csdx config:set:log [--level debug|info|warn|error] [--path <value>] [--show-console-logs]
|
|
330
|
+
|
|
331
|
+
FLAGS
|
|
332
|
+
--level=<option> Set the log level for the CLI.
|
|
333
|
+
<options: debug|info|warn|error>
|
|
334
|
+
--path=<value> Specify the file path where logs should be saved.
|
|
335
|
+
--[no-]show-console-logs Enable console logging.
|
|
336
|
+
|
|
337
|
+
DESCRIPTION
|
|
338
|
+
Set logging configuration for CLI
|
|
339
|
+
|
|
340
|
+
EXAMPLES
|
|
341
|
+
$ csdx config:set:log
|
|
342
|
+
|
|
343
|
+
$ csdx config:set:log --level debug --path ./logs/app.log --show-console-logs
|
|
344
|
+
|
|
345
|
+
$ csdx config:set:log --no-show-console-logs
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
_See code: [src/commands/config/set/log.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/log.ts)_
|
|
349
|
+
|
|
304
350
|
## `csdx config:set:rate-limit`
|
|
305
351
|
|
|
306
352
|
Set rate-limit for CLI
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_command_1 = require("@contentstack/cli-command");
|
|
4
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
class LogGetCommand extends cli_command_1.Command {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
9
|
+
const logLevel = currentLoggingConfig === null || currentLoggingConfig === void 0 ? void 0 : currentLoggingConfig.level;
|
|
10
|
+
const logPath = currentLoggingConfig === null || currentLoggingConfig === void 0 ? void 0 : currentLoggingConfig.path;
|
|
11
|
+
if (logLevel || logPath) {
|
|
12
|
+
const logConfigList = [
|
|
13
|
+
{
|
|
14
|
+
'Log Level': logLevel || 'Not set',
|
|
15
|
+
'Log Path': logPath || 'Not set',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
const headers = [
|
|
19
|
+
{ value: 'Log Level' },
|
|
20
|
+
{ value: 'Log Path' },
|
|
21
|
+
];
|
|
22
|
+
cli_utilities_1.cliux.table(headers, logConfigList);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
cli_utilities_1.cliux.print(`error: ${cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_NO_CONFIG')}`, { color: 'red' });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
cli_utilities_1.cliux.error('error', error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = LogGetCommand;
|
|
34
|
+
LogGetCommand.description = 'Get logging configuration for CLI';
|
|
35
|
+
LogGetCommand.examples = ['csdx config:get:log'];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from '@contentstack/cli-command';
|
|
2
|
+
import { FlagInput } from '@contentstack/cli-utilities';
|
|
3
|
+
export default class LogSetCommand extends Command {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: FlagInput;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
run(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_command_1 = require("@contentstack/cli-command");
|
|
4
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
class LogSetCommand extends cli_command_1.Command {
|
|
7
|
+
async run() {
|
|
8
|
+
try {
|
|
9
|
+
const { flags } = await this.parse(LogSetCommand);
|
|
10
|
+
let logLevel = flags['level'];
|
|
11
|
+
let logPath = flags['path'];
|
|
12
|
+
const showConsoleLogs = flags['show-console-logs'];
|
|
13
|
+
// Interactive prompts if not passed via flags
|
|
14
|
+
if (!logLevel) {
|
|
15
|
+
logLevel = await utils_1.interactive.askLogLevel();
|
|
16
|
+
}
|
|
17
|
+
if (!logPath) {
|
|
18
|
+
logPath = await utils_1.interactive.askLogPath();
|
|
19
|
+
}
|
|
20
|
+
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
21
|
+
if (logLevel)
|
|
22
|
+
currentLoggingConfig.level = logLevel;
|
|
23
|
+
if (logPath)
|
|
24
|
+
currentLoggingConfig.path = logPath;
|
|
25
|
+
currentLoggingConfig['show-console-logs'] = showConsoleLogs;
|
|
26
|
+
cli_utilities_1.configHandler.set('log', currentLoggingConfig);
|
|
27
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_LEVEL_SET', logLevel));
|
|
28
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_PATH_SET', logPath));
|
|
29
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_CONSOLE_SET', String(showConsoleLogs)));
|
|
30
|
+
cli_utilities_1.cliux.print(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_SET_SUCCESS'), { color: 'green' });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
cli_utilities_1.cliux.error('error', error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = LogSetCommand;
|
|
38
|
+
LogSetCommand.description = 'Set logging configuration for CLI';
|
|
39
|
+
LogSetCommand.flags = {
|
|
40
|
+
'level': cli_utilities_1.flags.string({
|
|
41
|
+
description: 'Set the log level for the CLI.',
|
|
42
|
+
options: ['debug', 'info', 'warn', 'error'],
|
|
43
|
+
}),
|
|
44
|
+
'path': cli_utilities_1.flags.string({
|
|
45
|
+
description: 'Specify the file path where logs should be saved.',
|
|
46
|
+
}),
|
|
47
|
+
'show-console-logs': cli_utilities_1.flags.boolean({
|
|
48
|
+
description: 'Enable console logging.',
|
|
49
|
+
allowNo: true,
|
|
50
|
+
default: false,
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
LogSetCommand.examples = [
|
|
54
|
+
'csdx config:set:log',
|
|
55
|
+
'csdx config:set:log --level debug --path ./logs/app.log --show-console-logs',
|
|
56
|
+
'csdx config:set:log --no-show-console-logs',
|
|
57
|
+
];
|
|
@@ -52,8 +52,12 @@ class SetRateLimitCommand extends base_command_1.BaseCommand {
|
|
|
52
52
|
await limitHandler.setRateLimit(config);
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (error === null || error === void 0 ? void 0 : error.message) {
|
|
56
|
+
cli_utilities_1.cliux.error(error.message);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
cli_utilities_1.cliux.error(`Error: Something went wrong while setting rate limit for org: ${org}`);
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
@@ -7,3 +7,5 @@ export declare function inquireRequireFieldValidation(input: string): string | b
|
|
|
7
7
|
export declare function askEarlyAccessHeaderValue(): Promise<string>;
|
|
8
8
|
export declare function askEarlyAccessHeaderAlias(): Promise<string>;
|
|
9
9
|
export declare const askOrgID: () => Promise<string>;
|
|
10
|
+
export declare function askLogLevel(): Promise<string>;
|
|
11
|
+
export declare function askLogPath(): Promise<string>;
|
package/lib/utils/interactive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.askOrgID = exports.askEarlyAccessHeaderAlias = exports.askEarlyAccessHeaderValue = exports.inquireRequireFieldValidation = exports.askConfirmation = exports.askBaseBranch = exports.askStackAPIKey = exports.askCustomRegion = exports.askRegions = void 0;
|
|
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;
|
|
4
4
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
5
|
const askRegions = async () => {
|
|
6
6
|
return cli_utilities_1.cliux.inquire({
|
|
@@ -104,3 +104,26 @@ const askOrgID = async () => {
|
|
|
104
104
|
});
|
|
105
105
|
};
|
|
106
106
|
exports.askOrgID = askOrgID;
|
|
107
|
+
async function askLogLevel() {
|
|
108
|
+
const { logLevel } = await cli_utilities_1.cliux.inquire([
|
|
109
|
+
{
|
|
110
|
+
type: 'list',
|
|
111
|
+
name: 'logLevel',
|
|
112
|
+
message: 'Select log level:',
|
|
113
|
+
choices: ['debug', 'info', 'warn', 'error'],
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
return logLevel;
|
|
117
|
+
}
|
|
118
|
+
exports.askLogLevel = askLogLevel;
|
|
119
|
+
async function askLogPath() {
|
|
120
|
+
const { logPath } = await cli_utilities_1.cliux.inquire([
|
|
121
|
+
{
|
|
122
|
+
type: 'input',
|
|
123
|
+
name: 'logPath',
|
|
124
|
+
message: 'Enter log file path:',
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
return logPath;
|
|
128
|
+
}
|
|
129
|
+
exports.askLogPath = askLogPath;
|
package/messages/index.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"CLI_CONFIG_SET_REGION_DESCRIPTION": "Set region for CLI",
|
|
3
3
|
"CLI_CONFIG_SET_REGION_FLAG_D_DESCRIPTION": "Custom host to set for content delivery API, if this flag is added then cma and name flags are required",
|
|
4
|
-
"CLI_CONFIG_SET_REGION_FLAG_M_DESCRIPTION": "Custom host to set for content management API, if this flag is added then cda and name flags are required",
|
|
4
|
+
"CLI_CONFIG_SET_REGION_FLAG_M_DESCRIPTION": "Custom host to set for content management API, , if this flag is added then cda and name flags are required",
|
|
5
5
|
"CLI_CONFIG_SET_REGION_FLAG_N_DESCRIPTION": "Name for the region, if this flag is added then cda and cma flags are required",
|
|
6
|
-
"CLI_CONFIG_SET_REGION_DEFAULT": "No argument or custom flag provided. Setting region to default
|
|
6
|
+
"CLI_CONFIG_SET_REGION_DEFAULT": "No argument or custom flag provided. Setting region to default NA",
|
|
7
7
|
"CLI_CONFIG_GET_REGION_DESCRIPTION": "Get current region set for CLI",
|
|
8
8
|
"CLI_CONFIG_GET_REGION_NOT_FOUND": "No region found, please set by running command $ csdx config:set:region",
|
|
9
9
|
"CLI_CONFIG_INQUIRE_REGION_NAME": "Enter custom region name",
|
|
@@ -15,5 +15,10 @@
|
|
|
15
15
|
"CLI_CONFIG_BRANCH_LIST_NO_BRANCHES": "No branches are added. Use config:set:base-branch command to add base branch.",
|
|
16
16
|
"CLI_CONFIG_INQUIRE_EARLY_ACCESS_HEADER_VALUE": "Please enter Early Access header value",
|
|
17
17
|
"CLI_CONFIG_INQUIRE_EARLY_ACCESS_HEADER_ALIAS": "Please enter Early Access header alias",
|
|
18
|
-
"CLI_BRANCH_REQUIRED_FIELD": "Please enter the required field details"
|
|
19
|
-
|
|
18
|
+
"CLI_BRANCH_REQUIRED_FIELD": "Please enter the required field details",
|
|
19
|
+
"CLI_CONFIG_LOG_NO_CONFIG": "No config found, please set by running command $ csdx config:set:log",
|
|
20
|
+
"CLI_CONFIG_LOG_SET_SUCCESS": "Log config set successfully",
|
|
21
|
+
"CLI_CONFIG_LOG_LEVEL_SET": "Log level: '%s'",
|
|
22
|
+
"CLI_CONFIG_LOG_PATH_SET": "Log path: '%s'",
|
|
23
|
+
"CLI_CONFIG_LOG_CONSOLE_SET": "Log console: '%s'"
|
|
24
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -50,6 +50,30 @@
|
|
|
50
50
|
"early-access-header.js"
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
|
+
"config:get:log": {
|
|
54
|
+
"aliases": [],
|
|
55
|
+
"args": {},
|
|
56
|
+
"description": "Get logging configuration for CLI",
|
|
57
|
+
"examples": [
|
|
58
|
+
"csdx config:get:log"
|
|
59
|
+
],
|
|
60
|
+
"flags": {},
|
|
61
|
+
"hasDynamicHelp": false,
|
|
62
|
+
"hiddenAliases": [],
|
|
63
|
+
"id": "config:get:log",
|
|
64
|
+
"pluginAlias": "@contentstack/cli-config",
|
|
65
|
+
"pluginName": "@contentstack/cli-config",
|
|
66
|
+
"pluginType": "core",
|
|
67
|
+
"strict": true,
|
|
68
|
+
"isESM": false,
|
|
69
|
+
"relativePath": [
|
|
70
|
+
"lib",
|
|
71
|
+
"commands",
|
|
72
|
+
"config",
|
|
73
|
+
"get",
|
|
74
|
+
"log.js"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
53
77
|
"config:get:rate-limit": {
|
|
54
78
|
"aliases": [],
|
|
55
79
|
"args": {},
|
|
@@ -296,6 +320,59 @@
|
|
|
296
320
|
"early-access-header.js"
|
|
297
321
|
]
|
|
298
322
|
},
|
|
323
|
+
"config:set:log": {
|
|
324
|
+
"aliases": [],
|
|
325
|
+
"args": {},
|
|
326
|
+
"description": "Set logging configuration for CLI",
|
|
327
|
+
"examples": [
|
|
328
|
+
"csdx config:set:log",
|
|
329
|
+
"csdx config:set:log --level debug --path ./logs/app.log --show-console-logs",
|
|
330
|
+
"csdx config:set:log --no-show-console-logs"
|
|
331
|
+
],
|
|
332
|
+
"flags": {
|
|
333
|
+
"level": {
|
|
334
|
+
"description": "Set the log level for the CLI.",
|
|
335
|
+
"name": "level",
|
|
336
|
+
"hasDynamicHelp": false,
|
|
337
|
+
"multiple": false,
|
|
338
|
+
"options": [
|
|
339
|
+
"debug",
|
|
340
|
+
"info",
|
|
341
|
+
"warn",
|
|
342
|
+
"error"
|
|
343
|
+
],
|
|
344
|
+
"type": "option"
|
|
345
|
+
},
|
|
346
|
+
"path": {
|
|
347
|
+
"description": "Specify the file path where logs should be saved.",
|
|
348
|
+
"name": "path",
|
|
349
|
+
"hasDynamicHelp": false,
|
|
350
|
+
"multiple": false,
|
|
351
|
+
"type": "option"
|
|
352
|
+
},
|
|
353
|
+
"show-console-logs": {
|
|
354
|
+
"description": "Enable console logging.",
|
|
355
|
+
"name": "show-console-logs",
|
|
356
|
+
"allowNo": true,
|
|
357
|
+
"type": "boolean"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"hasDynamicHelp": false,
|
|
361
|
+
"hiddenAliases": [],
|
|
362
|
+
"id": "config:set:log",
|
|
363
|
+
"pluginAlias": "@contentstack/cli-config",
|
|
364
|
+
"pluginName": "@contentstack/cli-config",
|
|
365
|
+
"pluginType": "core",
|
|
366
|
+
"strict": true,
|
|
367
|
+
"isESM": false,
|
|
368
|
+
"relativePath": [
|
|
369
|
+
"lib",
|
|
370
|
+
"commands",
|
|
371
|
+
"config",
|
|
372
|
+
"set",
|
|
373
|
+
"log.js"
|
|
374
|
+
]
|
|
375
|
+
},
|
|
299
376
|
"config:set:rate-limit": {
|
|
300
377
|
"aliases": [],
|
|
301
378
|
"args": {},
|
|
@@ -466,5 +543,5 @@
|
|
|
466
543
|
]
|
|
467
544
|
}
|
|
468
545
|
},
|
|
469
|
-
"version": "1.
|
|
546
|
+
"version": "1.15.0"
|
|
470
547
|
}
|
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.
|
|
4
|
+
"version": "1.15.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.
|
|
25
|
-
"@contentstack/cli-utilities": "~1.
|
|
24
|
+
"@contentstack/cli-command": "~1.6.0",
|
|
25
|
+
"@contentstack/cli-utilities": "~1.13.1",
|
|
26
26
|
"@oclif/core": "^4.3.0",
|
|
27
27
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
28
|
"lodash": "^4.17.21"
|