@contentstack/cli-cm-export 1.15.0 → 1.16.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 +6 -6
- package/lib/commands/cm/stacks/export.js +1 -1
- package/lib/export/modules/entries.js +12 -5
- package/lib/utils/export-config-handler.js +2 -2
- package/lib/utils/logger.js +5 -2
- package/oclif.manifest.json +69 -50
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
48
48
|
$ csdx COMMAND
|
|
49
49
|
running command...
|
|
50
50
|
$ csdx (--version)
|
|
51
|
-
@contentstack/cli-cm-export/1.
|
|
51
|
+
@contentstack/cli-cm-export/1.16.0 linux-x64 node-v22.14.0
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
|
@@ -60,7 +60,7 @@ USAGE
|
|
|
60
60
|
|
|
61
61
|
<!-- commands -->
|
|
62
62
|
* [`csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`](#csdx-cmstacksexport--c-value--k-value--d-value--a-value---module-value---content-types-value---branch-value---secured-assets)
|
|
63
|
-
* [`csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`](#csdx-cmstacksexport--c-value--k-value--d-value--a-value---module-value---content-types-value---branch-value---secured-assets
|
|
63
|
+
* [`csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`](#csdx-cmstacksexport--c-value--k-value--d-value--a-value---module-value---content-types-value---branch-value---secured-assets)
|
|
64
64
|
|
|
65
65
|
## `csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`
|
|
66
66
|
|
|
@@ -68,8 +68,8 @@ Export content from a stack
|
|
|
68
68
|
|
|
69
69
|
```
|
|
70
70
|
USAGE
|
|
71
|
-
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>]
|
|
72
|
-
<value>] [--branch <value>] [--secured-assets]
|
|
71
|
+
$ csdx cm:export cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>]
|
|
72
|
+
[--content-types <value>] [--branch <value>] [--secured-assets]
|
|
73
73
|
|
|
74
74
|
FLAGS
|
|
75
75
|
-B, --branch=<value> [optional] The name of the branch where you want to export your content. If you don't
|
|
@@ -87,7 +87,7 @@ FLAGS
|
|
|
87
87
|
-t, --content-types=<value>... [optional] The UID of the content type(s) whose content you want to export. In case
|
|
88
88
|
of multiple content types, specify the IDs separated by spaces.
|
|
89
89
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
90
|
-
|
|
90
|
+
--secured-assets [optional] Use this flag for assets that are secured.
|
|
91
91
|
|
|
92
92
|
DESCRIPTION
|
|
93
93
|
Export content from a stack
|
|
@@ -136,7 +136,7 @@ FLAGS
|
|
|
136
136
|
-t, --content-types=<value>... [optional] The UID of the content type(s) whose content you want to export. In case
|
|
137
137
|
of multiple content types, specify the IDs separated by spaces.
|
|
138
138
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
139
|
-
|
|
139
|
+
--secured-assets [optional] Use this flag for assets that are secured.
|
|
140
140
|
|
|
141
141
|
DESCRIPTION
|
|
142
142
|
Export content from a stack
|
|
@@ -19,7 +19,7 @@ class ExportCommand extends cli_command_1.Command {
|
|
|
19
19
|
exportConfig.developerHubBaseUrl = this.developerHubUrl;
|
|
20
20
|
if (this.personalizeUrl)
|
|
21
21
|
exportConfig.modules.personalize.baseURL[exportConfig.region.name] = this.personalizeUrl;
|
|
22
|
-
exportDir = exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir;
|
|
22
|
+
exportDir = (0, cli_utilities_1.sanitizePath)(exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir);
|
|
23
23
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(exportConfig);
|
|
24
24
|
const moduleExporter = new export_1.ModuleExporter(managementAPIClient, exportConfig);
|
|
25
25
|
await moduleExporter.start();
|
|
@@ -87,11 +87,18 @@ class EntriesExport extends base_class_1.default {
|
|
|
87
87
|
locale: options.locale,
|
|
88
88
|
},
|
|
89
89
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
let entriesSearchResponse;
|
|
91
|
+
try {
|
|
92
|
+
entriesSearchResponse = await this.stackAPIClient
|
|
93
|
+
.contentType(options.contentType)
|
|
94
|
+
.entry()
|
|
95
|
+
.query(requestObject)
|
|
96
|
+
.find();
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
(0, utils_1.log)(this.exportConfig, `Failed to export entries ${(0, utils_1.formatError)(error)}`, 'error');
|
|
100
|
+
throw new Error('Failed to export entries');
|
|
101
|
+
}
|
|
95
102
|
if (Array.isArray(entriesSearchResponse.items) && entriesSearchResponse.items.length > 0) {
|
|
96
103
|
if (options.skip === 0) {
|
|
97
104
|
const entryBasePath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale));
|
|
@@ -16,13 +16,13 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
16
16
|
const externalConfig = await (0, file_helper_1.readFile)(exportCmdFlags['config']);
|
|
17
17
|
config = merge_1.default.recursive(config, externalConfig);
|
|
18
18
|
}
|
|
19
|
-
config.exportDir = exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await (0, interactive_1.askExportDir)());
|
|
19
|
+
config.exportDir = (0, cli_utilities_1.sanitizePath)(exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await (0, interactive_1.askExportDir)()));
|
|
20
20
|
const pattern = /[*$%#<>{}!&?]/g;
|
|
21
21
|
if (pattern.test(config.exportDir)) {
|
|
22
22
|
cli_utilities_1.cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
|
|
23
23
|
color: 'yellow',
|
|
24
24
|
});
|
|
25
|
-
config.exportDir = await (0, interactive_1.askExportDir)();
|
|
25
|
+
config.exportDir = (0, cli_utilities_1.sanitizePath)(await (0, interactive_1.askExportDir)());
|
|
26
26
|
}
|
|
27
27
|
config.exportDir = config.exportDir.replace(/['"]/g, '');
|
|
28
28
|
config.exportDir = path.resolve(config.exportDir);
|
package/lib/utils/logger.js
CHANGED
|
@@ -23,7 +23,10 @@ function returnString(args) {
|
|
|
23
23
|
.map(function (item) {
|
|
24
24
|
if (item && typeof item === 'object') {
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
const redactedObject = (0, cli_utilities_1.redactObject)(item);
|
|
27
|
+
if (redactedObject && typeof redactedObject === 'object') {
|
|
28
|
+
return JSON.stringify(redactedObject);
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
catch (error) { }
|
|
29
32
|
return item;
|
|
@@ -123,7 +126,7 @@ function init(_logPath) {
|
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
const log = async (config, message, type) => {
|
|
126
|
-
const logsPath = config.cliLogsPath || config.data;
|
|
129
|
+
const logsPath = (0, cli_utilities_1.sanitizePath)(config.cliLogsPath || config.data);
|
|
127
130
|
// ignoring the type argument, as we are not using it to create a logfile anymore
|
|
128
131
|
if (type !== 'error') {
|
|
129
132
|
// removed type argument from init method
|
package/oclif.manifest.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.15.0",
|
|
3
2
|
"commands": {
|
|
4
3
|
"cm:stacks:export": {
|
|
5
|
-
"id": "cm:stacks:export",
|
|
6
|
-
"description": "Export content from a stack",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"usage": "cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]",
|
|
9
|
-
"pluginName": "@contentstack/cli-cm-export",
|
|
10
|
-
"pluginAlias": "@contentstack/cli-cm-export",
|
|
11
|
-
"pluginType": "core",
|
|
12
4
|
"aliases": [
|
|
13
5
|
"cm:export"
|
|
14
6
|
],
|
|
15
|
-
"
|
|
7
|
+
"args": {},
|
|
8
|
+
"description": "Export content from a stack",
|
|
16
9
|
"examples": [
|
|
17
10
|
"csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>",
|
|
18
11
|
"csdx cm:stacks:export --config <path/to/config/dir>",
|
|
@@ -24,100 +17,126 @@
|
|
|
24
17
|
],
|
|
25
18
|
"flags": {
|
|
26
19
|
"config": {
|
|
27
|
-
"name": "config",
|
|
28
|
-
"type": "option",
|
|
29
20
|
"char": "c",
|
|
30
21
|
"description": "[optional] Path of the config",
|
|
31
|
-
"
|
|
22
|
+
"name": "config",
|
|
23
|
+
"hasDynamicHelp": false,
|
|
24
|
+
"multiple": false,
|
|
25
|
+
"type": "option"
|
|
32
26
|
},
|
|
33
27
|
"stack-uid": {
|
|
34
|
-
"name": "stack-uid",
|
|
35
|
-
"type": "option",
|
|
36
28
|
"char": "s",
|
|
37
29
|
"description": "API key of the source stack",
|
|
38
30
|
"hidden": true,
|
|
39
|
-
"
|
|
31
|
+
"name": "stack-uid",
|
|
32
|
+
"hasDynamicHelp": false,
|
|
33
|
+
"multiple": false,
|
|
34
|
+
"type": "option"
|
|
40
35
|
},
|
|
41
36
|
"stack-api-key": {
|
|
42
|
-
"name": "stack-api-key",
|
|
43
|
-
"type": "option",
|
|
44
37
|
"char": "k",
|
|
45
38
|
"description": "API Key of the source stack",
|
|
46
|
-
"
|
|
39
|
+
"name": "stack-api-key",
|
|
40
|
+
"hasDynamicHelp": false,
|
|
41
|
+
"multiple": false,
|
|
42
|
+
"type": "option"
|
|
47
43
|
},
|
|
48
44
|
"data": {
|
|
49
|
-
"name": "data",
|
|
50
|
-
"type": "option",
|
|
51
45
|
"description": "path or location to store the data",
|
|
52
46
|
"hidden": true,
|
|
53
|
-
"
|
|
47
|
+
"name": "data",
|
|
48
|
+
"hasDynamicHelp": false,
|
|
49
|
+
"multiple": false,
|
|
50
|
+
"type": "option"
|
|
54
51
|
},
|
|
55
52
|
"data-dir": {
|
|
56
|
-
"name": "data-dir",
|
|
57
|
-
"type": "option",
|
|
58
53
|
"char": "d",
|
|
59
54
|
"description": "The path or the location in your file system to store the exported content. For e.g., ./content",
|
|
60
|
-
"
|
|
55
|
+
"name": "data-dir",
|
|
56
|
+
"hasDynamicHelp": false,
|
|
57
|
+
"multiple": false,
|
|
58
|
+
"type": "option"
|
|
61
59
|
},
|
|
62
60
|
"alias": {
|
|
63
|
-
"name": "alias",
|
|
64
|
-
"type": "option",
|
|
65
61
|
"char": "a",
|
|
66
62
|
"description": "The management token alias of the source stack from which you will export content.",
|
|
67
|
-
"
|
|
63
|
+
"name": "alias",
|
|
64
|
+
"hasDynamicHelp": false,
|
|
65
|
+
"multiple": false,
|
|
66
|
+
"type": "option"
|
|
68
67
|
},
|
|
69
68
|
"management-token-alias": {
|
|
70
|
-
"name": "management-token-alias",
|
|
71
|
-
"type": "option",
|
|
72
69
|
"description": "alias of the management token",
|
|
73
70
|
"hidden": true,
|
|
74
|
-
"
|
|
71
|
+
"name": "management-token-alias",
|
|
72
|
+
"hasDynamicHelp": false,
|
|
73
|
+
"multiple": false,
|
|
74
|
+
"type": "option"
|
|
75
75
|
},
|
|
76
76
|
"auth-token": {
|
|
77
|
-
"name": "auth-token",
|
|
78
|
-
"type": "boolean",
|
|
79
77
|
"char": "A",
|
|
80
78
|
"description": "to use auth token",
|
|
81
79
|
"hidden": true,
|
|
82
|
-
"
|
|
80
|
+
"name": "auth-token",
|
|
81
|
+
"allowNo": false,
|
|
82
|
+
"type": "boolean"
|
|
83
83
|
},
|
|
84
84
|
"module": {
|
|
85
|
-
"name": "module",
|
|
86
|
-
"type": "option",
|
|
87
85
|
"char": "m",
|
|
88
86
|
"description": "[optional] Specific module name. If not specified, the export command will export all the modules to the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, and taxonomies.",
|
|
89
|
-
"
|
|
87
|
+
"name": "module",
|
|
88
|
+
"hasDynamicHelp": false,
|
|
89
|
+
"multiple": false,
|
|
90
|
+
"type": "option"
|
|
90
91
|
},
|
|
91
92
|
"content-types": {
|
|
92
|
-
"name": "content-types",
|
|
93
|
-
"type": "option",
|
|
94
93
|
"char": "t",
|
|
95
94
|
"description": "[optional] The UID of the content type(s) whose content you want to export. In case of multiple content types, specify the IDs separated by spaces.",
|
|
96
|
-
"
|
|
95
|
+
"name": "content-types",
|
|
96
|
+
"hasDynamicHelp": false,
|
|
97
|
+
"multiple": true,
|
|
98
|
+
"type": "option"
|
|
97
99
|
},
|
|
98
100
|
"branch": {
|
|
99
|
-
"name": "branch",
|
|
100
|
-
"type": "option",
|
|
101
101
|
"char": "B",
|
|
102
102
|
"description": "[optional] The name of the branch where you want to export your content. If you don't mention the branch name, then by default the content will be exported from all the branches of your stack.",
|
|
103
|
-
"
|
|
103
|
+
"name": "branch",
|
|
104
|
+
"hasDynamicHelp": false,
|
|
105
|
+
"multiple": false,
|
|
106
|
+
"type": "option"
|
|
104
107
|
},
|
|
105
108
|
"secured-assets": {
|
|
106
|
-
"name": "secured-assets",
|
|
107
|
-
"type": "boolean",
|
|
108
109
|
"description": "[optional] Use this flag for assets that are secured.",
|
|
109
|
-
"
|
|
110
|
+
"name": "secured-assets",
|
|
111
|
+
"allowNo": false,
|
|
112
|
+
"type": "boolean"
|
|
110
113
|
},
|
|
111
114
|
"yes": {
|
|
112
|
-
"name": "yes",
|
|
113
|
-
"type": "boolean",
|
|
114
115
|
"char": "y",
|
|
115
116
|
"description": "[optional] Force override all Marketplace prompts.",
|
|
117
|
+
"name": "yes",
|
|
116
118
|
"required": false,
|
|
117
|
-
"allowNo": false
|
|
119
|
+
"allowNo": false,
|
|
120
|
+
"type": "boolean"
|
|
118
121
|
}
|
|
119
122
|
},
|
|
120
|
-
"
|
|
123
|
+
"hasDynamicHelp": false,
|
|
124
|
+
"hiddenAliases": [],
|
|
125
|
+
"id": "cm:stacks:export",
|
|
126
|
+
"pluginAlias": "@contentstack/cli-cm-export",
|
|
127
|
+
"pluginName": "@contentstack/cli-cm-export",
|
|
128
|
+
"pluginType": "core",
|
|
129
|
+
"strict": true,
|
|
130
|
+
"usage": "cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]",
|
|
131
|
+
"isESM": false,
|
|
132
|
+
"relativePath": [
|
|
133
|
+
"lib",
|
|
134
|
+
"commands",
|
|
135
|
+
"cm",
|
|
136
|
+
"stacks",
|
|
137
|
+
"export.js"
|
|
138
|
+
]
|
|
121
139
|
}
|
|
122
|
-
}
|
|
140
|
+
},
|
|
141
|
+
"version": "1.16.0"
|
|
123
142
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~1.
|
|
9
|
-
"@contentstack/cli-variants": "~1.
|
|
10
|
-
"@
|
|
11
|
-
"@
|
|
8
|
+
"@contentstack/cli-command": "~1.5.0",
|
|
9
|
+
"@contentstack/cli-variants": "~1.2.0",
|
|
10
|
+
"@oclif/core": "^4.2.7",
|
|
11
|
+
"@contentstack/cli-utilities": "~1.11.0",
|
|
12
12
|
"async": "^3.2.6",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"winston": "^3.17.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@contentstack/cli-auth": "~1.
|
|
25
|
-
"@contentstack/cli-config": "~1.
|
|
26
|
-
"@contentstack/cli-dev-dependencies": "~1.
|
|
27
|
-
"@oclif/plugin-help": "^
|
|
24
|
+
"@contentstack/cli-auth": "~1.4.0",
|
|
25
|
+
"@contentstack/cli-config": "~1.11.0",
|
|
26
|
+
"@contentstack/cli-dev-dependencies": "~1.3.0",
|
|
27
|
+
"@oclif/plugin-help": "^6.2.25",
|
|
28
28
|
"@oclif/test": "^4.1.6",
|
|
29
29
|
"@types/big-json": "^3.2.5",
|
|
30
30
|
"@types/mkdirp": "^1.0.2",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dotenv": "^16.4.7",
|
|
33
33
|
"dotenv-expand": "^9.0.0",
|
|
34
34
|
"eslint": "^8.57.1",
|
|
35
|
-
"eslint-config-oclif": "^
|
|
35
|
+
"eslint-config-oclif": "^6.0.15",
|
|
36
36
|
"mocha": "10.8.2",
|
|
37
37
|
"nyc": "^15.1.0",
|
|
38
|
-
"oclif": "^
|
|
38
|
+
"oclif": "^4.17.30",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"typescript": "^4.9.5"
|
|
41
41
|
},
|