@contentstack/cli-config 1.13.0 → 1.14.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 +44 -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 +56 -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 +5 -1
- package/oclif.manifest.json +71 -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.14.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,30 @@ 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>]
|
|
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
|
+
|
|
336
|
+
DESCRIPTION
|
|
337
|
+
Set logging configuration for CLI
|
|
338
|
+
|
|
339
|
+
EXAMPLES
|
|
340
|
+
$ csdx config:set:log
|
|
341
|
+
|
|
342
|
+
$ csdx config:set:log --level debug --path ./logs/app.log
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
_See code: [src/commands/config/set/log.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-config/src/commands/config/set/log.ts)_
|
|
346
|
+
|
|
304
347
|
## `csdx config:set:rate-limit`
|
|
305
348
|
|
|
306
349
|
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,56 @@
|
|
|
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
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
class LogSetCommand extends cli_command_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
try {
|
|
11
|
+
const { flags } = await this.parse(LogSetCommand);
|
|
12
|
+
let logLevel = flags['level'];
|
|
13
|
+
let logPath = flags['path'];
|
|
14
|
+
// Interactive prompts if not passed via flags
|
|
15
|
+
if (!logLevel) {
|
|
16
|
+
logLevel = await utils_1.interactive.askLogLevel();
|
|
17
|
+
}
|
|
18
|
+
if (!logPath) {
|
|
19
|
+
logPath = await utils_1.interactive.askLogPath();
|
|
20
|
+
}
|
|
21
|
+
if (logPath) {
|
|
22
|
+
const logDir = (0, path_1.dirname)(logPath);
|
|
23
|
+
// Check if the directory part of the path exists and is actually a file
|
|
24
|
+
if ((0, fs_1.existsSync)(logDir) && (0, fs_1.statSync)(logDir).isFile()) {
|
|
25
|
+
throw new cli_utilities_1.CLIError({
|
|
26
|
+
message: `The directory path '${logDir}' is a file, not a directory. Please provide a valid directory path for the log file.`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const currentLoggingConfig = cli_utilities_1.configHandler.get('log') || {};
|
|
31
|
+
if (logLevel)
|
|
32
|
+
currentLoggingConfig.level = logLevel;
|
|
33
|
+
if (logPath)
|
|
34
|
+
currentLoggingConfig.path = logPath;
|
|
35
|
+
cli_utilities_1.configHandler.set('log', currentLoggingConfig);
|
|
36
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_LEVEL_SET', logLevel));
|
|
37
|
+
cli_utilities_1.cliux.success(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_PATH_SET', logPath));
|
|
38
|
+
cli_utilities_1.cliux.print(cli_utilities_1.messageHandler.parse('CLI_CONFIG_LOG_SET_SUCCESS'), { color: 'green' });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
cli_utilities_1.cliux.error('error', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = LogSetCommand;
|
|
46
|
+
LogSetCommand.description = 'Set logging configuration for CLI';
|
|
47
|
+
LogSetCommand.flags = {
|
|
48
|
+
level: cli_utilities_1.flags.string({
|
|
49
|
+
description: 'Set the log level for the CLI.',
|
|
50
|
+
options: ['debug', 'info', 'warn', 'error'],
|
|
51
|
+
}),
|
|
52
|
+
path: cli_utilities_1.flags.string({
|
|
53
|
+
description: ' Specify the file path where logs should be saved.',
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
LogSetCommand.examples = ['csdx config:set:log', 'csdx config:set:log --level debug --path ./logs/app.log'];
|
|
@@ -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
|
@@ -15,5 +15,9 @@
|
|
|
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"
|
|
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'"
|
|
19
23
|
}
|
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,52 @@
|
|
|
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"
|
|
330
|
+
],
|
|
331
|
+
"flags": {
|
|
332
|
+
"level": {
|
|
333
|
+
"description": "Set the log level for the CLI.",
|
|
334
|
+
"name": "level",
|
|
335
|
+
"hasDynamicHelp": false,
|
|
336
|
+
"multiple": false,
|
|
337
|
+
"options": [
|
|
338
|
+
"debug",
|
|
339
|
+
"info",
|
|
340
|
+
"warn",
|
|
341
|
+
"error"
|
|
342
|
+
],
|
|
343
|
+
"type": "option"
|
|
344
|
+
},
|
|
345
|
+
"path": {
|
|
346
|
+
"description": " Specify the file path where logs should be saved.",
|
|
347
|
+
"name": "path",
|
|
348
|
+
"hasDynamicHelp": false,
|
|
349
|
+
"multiple": false,
|
|
350
|
+
"type": "option"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"hasDynamicHelp": false,
|
|
354
|
+
"hiddenAliases": [],
|
|
355
|
+
"id": "config:set:log",
|
|
356
|
+
"pluginAlias": "@contentstack/cli-config",
|
|
357
|
+
"pluginName": "@contentstack/cli-config",
|
|
358
|
+
"pluginType": "core",
|
|
359
|
+
"strict": true,
|
|
360
|
+
"isESM": false,
|
|
361
|
+
"relativePath": [
|
|
362
|
+
"lib",
|
|
363
|
+
"commands",
|
|
364
|
+
"config",
|
|
365
|
+
"set",
|
|
366
|
+
"log.js"
|
|
367
|
+
]
|
|
368
|
+
},
|
|
299
369
|
"config:set:rate-limit": {
|
|
300
370
|
"aliases": [],
|
|
301
371
|
"args": {},
|
|
@@ -466,5 +536,5 @@
|
|
|
466
536
|
]
|
|
467
537
|
}
|
|
468
538
|
},
|
|
469
|
-
"version": "1.
|
|
539
|
+
"version": "1.14.0"
|
|
470
540
|
}
|
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.14.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.0",
|
|
26
26
|
"@oclif/core": "^4.3.0",
|
|
27
27
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
28
|
"lodash": "^4.17.21"
|