@contentstack/cli-cm-export 0.1.1-beta.5 → 0.1.1-beta.6
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 +12 -6
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/cm/export.js +17 -8
- package/src/lib/export/assets.js +4 -2
- package/src/lib/util/export-flags.js +12 -7
package/README.md
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
@contentstack/cli-cm-export
|
|
2
|
-
===================
|
|
1
|
+
# @contentstack/cli-cm-export
|
|
3
2
|
|
|
4
|
-
It is Contentstack’s CLI plugin to export content from the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).
|
|
3
|
+
It is Contentstack’s CLI plugin to export content from the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).
|
|
5
4
|
|
|
6
5
|
[](https://github.com/contentstack/cli/blob/main/LICENSE)
|
|
7
6
|
|
|
8
7
|
<!-- toc -->
|
|
8
|
+
* [@contentstack/cli-cm-export](#contentstackcli-cm-export)
|
|
9
9
|
* [Usage](#usage)
|
|
10
10
|
* [Commands](#commands)
|
|
11
11
|
<!-- tocstop -->
|
|
12
|
+
|
|
12
13
|
# Usage
|
|
14
|
+
|
|
13
15
|
<!-- usage -->
|
|
14
16
|
```sh-session
|
|
15
17
|
$ npm install -g @contentstack/cli-cm-export
|
|
16
18
|
$ csdx COMMAND
|
|
17
19
|
running command...
|
|
18
20
|
$ csdx (-v|--version|version)
|
|
19
|
-
@contentstack/cli-cm-export/0.1.1-beta.
|
|
21
|
+
@contentstack/cli-cm-export/0.1.1-beta.6 darwin-x64 node-v14.16.0
|
|
20
22
|
$ csdx --help [COMMAND]
|
|
21
23
|
USAGE
|
|
22
24
|
$ csdx COMMAND
|
|
23
25
|
...
|
|
24
26
|
```
|
|
25
27
|
<!-- usagestop -->
|
|
28
|
+
|
|
26
29
|
# Commands
|
|
30
|
+
|
|
27
31
|
<!-- commands -->
|
|
28
32
|
* [`csdx cm:export`](#csdx-cmexport)
|
|
29
33
|
|
|
@@ -42,6 +46,7 @@ OPTIONS
|
|
|
42
46
|
-d, --data=data path or location to store the data
|
|
43
47
|
-m, --module=module [optional] specific module name
|
|
44
48
|
-s, --stack-uid=stack-uid API key of the source stack
|
|
49
|
+
--secured-assets [optional] use when assets are secured
|
|
45
50
|
|
|
46
51
|
DESCRIPTION
|
|
47
52
|
...
|
|
@@ -51,11 +56,12 @@ EXAMPLES
|
|
|
51
56
|
csdx cm:export -A
|
|
52
57
|
csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
|
|
53
58
|
csdx cm:export -A -c <path/to/config/dir>
|
|
59
|
+
csdx cm:export -A -m <single module name>
|
|
60
|
+
csdx cm:export -A --secured-assets
|
|
54
61
|
csdx cm:export -a <management_token_alias>
|
|
55
62
|
csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>
|
|
56
63
|
csdx cm:export -a <management_token_alias> -c <path/to/config/file>
|
|
57
|
-
csdx cm:export -A -m <single module name>
|
|
58
64
|
```
|
|
59
65
|
|
|
60
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
66
|
+
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.6/packages/contentstack-export/src/commands/cm/export.js)_
|
|
61
67
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.6","commands":{"cm:export":{"id":"cm:export","description":"Export content from a stack\n...\nExport content from one stack to another\n","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":[],"examples":["csdx cm:export -A","csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:export -A -c <path/to/config/dir>","csdx cm:export -A -m <single module name>","csdx cm:export -A --secured-assets","csdx cm:export -a <management_token_alias>","csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>","csdx cm:export -a <management_token_alias> -c <path/to/config/file>"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of the config"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the source stack"},"data":{"name":"data","type":"option","char":"d","description":"path or location to store the data"},"management-token-alias":{"name":"management-token-alias","type":"option","char":"a","description":"alias of the management token"},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"secured-assets":{"name":"secured-assets","type":"boolean","description":"[optional] use when assets are secured","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "0.1.1-beta.
|
|
4
|
+
"version": "0.1.1-beta.6",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -17,6 +17,7 @@ class ExportCommand extends Command {
|
|
|
17
17
|
let sourceStack = flags['stack-uid']
|
|
18
18
|
const alias = flags['management-token-alias']
|
|
19
19
|
const authToken = flags['auth-token']
|
|
20
|
+
const securedAssets = flags['secured-assets']
|
|
20
21
|
const data = flags.data
|
|
21
22
|
const moduleName = flags.module
|
|
22
23
|
let _authToken = credStore.get('authtoken')
|
|
@@ -33,7 +34,8 @@ class ExportCommand extends Command {
|
|
|
33
34
|
configWithMToken(
|
|
34
35
|
extConfig,
|
|
35
36
|
managementTokens,
|
|
36
|
-
host
|
|
37
|
+
host,
|
|
38
|
+
securedAssets
|
|
37
39
|
)
|
|
38
40
|
} else if (data) {
|
|
39
41
|
parameterWithMToken(
|
|
@@ -41,14 +43,16 @@ class ExportCommand extends Command {
|
|
|
41
43
|
data,
|
|
42
44
|
moduleName,
|
|
43
45
|
host,
|
|
44
|
-
_authToken
|
|
46
|
+
_authToken,
|
|
47
|
+
securedAssets
|
|
45
48
|
)
|
|
46
49
|
} else if (data === undefined && sourceStack === undefined) {
|
|
47
50
|
withoutParameterMToken(
|
|
48
51
|
managementTokens,
|
|
49
52
|
moduleName,
|
|
50
53
|
host,
|
|
51
|
-
_authToken
|
|
54
|
+
_authToken,
|
|
55
|
+
securedAssets
|
|
52
56
|
)
|
|
53
57
|
} else {
|
|
54
58
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -62,7 +66,8 @@ class ExportCommand extends Command {
|
|
|
62
66
|
extConfig,
|
|
63
67
|
_authToken,
|
|
64
68
|
moduleName,
|
|
65
|
-
host
|
|
69
|
+
host,
|
|
70
|
+
securedAssets
|
|
66
71
|
)
|
|
67
72
|
} else if (sourceStack && data) {
|
|
68
73
|
return parametersWithAuthToken(
|
|
@@ -70,13 +75,15 @@ class ExportCommand extends Command {
|
|
|
70
75
|
sourceStack,
|
|
71
76
|
data,
|
|
72
77
|
moduleName,
|
|
73
|
-
host
|
|
78
|
+
host,
|
|
79
|
+
securedAssets
|
|
74
80
|
)
|
|
75
81
|
} else if (data === undefined && sourceStack === undefined) {
|
|
76
82
|
withoutParametersWithAuthToken(
|
|
77
83
|
_authToken,
|
|
78
84
|
moduleName,
|
|
79
|
-
host
|
|
85
|
+
host,
|
|
86
|
+
securedAssets
|
|
80
87
|
)
|
|
81
88
|
} else {
|
|
82
89
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -96,10 +103,11 @@ ExportCommand.examples = [
|
|
|
96
103
|
'csdx cm:export -A',
|
|
97
104
|
'csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>',
|
|
98
105
|
'csdx cm:export -A -c <path/to/config/dir>',
|
|
106
|
+
'csdx cm:export -A -m <single module name>',
|
|
107
|
+
'csdx cm:export -A --secured-assets',
|
|
99
108
|
'csdx cm:export -a <management_token_alias>',
|
|
100
109
|
'csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>',
|
|
101
|
-
'csdx cm:export -a <management_token_alias> -c <path/to/config/file>'
|
|
102
|
-
'csdx cm:export -A -m <single module name>',
|
|
110
|
+
'csdx cm:export -a <management_token_alias> -c <path/to/config/file>'
|
|
103
111
|
]
|
|
104
112
|
|
|
105
113
|
ExportCommand.flags = {
|
|
@@ -109,6 +117,7 @@ ExportCommand.flags = {
|
|
|
109
117
|
'management-token-alias': flags.string({char: 'a', description: 'alias of the management token'}),
|
|
110
118
|
'auth-token': flags.boolean({char: 'A', description: 'to use auth token'}),
|
|
111
119
|
module: flags.string({char: 'm', description: '[optional] specific module name'}),
|
|
120
|
+
'secured-assets': flags.boolean({description: '[optional] use when assets are secured'}),
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
module.exports = ExportCommand
|
package/src/lib/export/assets.js
CHANGED
|
@@ -246,8 +246,10 @@ ExportAssets.prototype = {
|
|
|
246
246
|
return resolve()
|
|
247
247
|
}
|
|
248
248
|
self.assetStream = {
|
|
249
|
-
url:
|
|
250
|
-
|
|
249
|
+
url: config.securedAssets
|
|
250
|
+
? `${asset.url}?authtoken=${config.authtoken || config.auth_token}`
|
|
251
|
+
: asset.url,
|
|
252
|
+
};
|
|
251
253
|
|
|
252
254
|
const assetStreamRequest = nativeRequest(self.assetStream)
|
|
253
255
|
assetStreamRequest.on('response', function () {
|
|
@@ -11,9 +11,9 @@ const helper = require('../util/helper');
|
|
|
11
11
|
let _ = require('lodash')
|
|
12
12
|
const {cli} = require('cli-ux')
|
|
13
13
|
|
|
14
|
-
exports.configWithMToken = function (config, managementTokens, host,
|
|
14
|
+
exports.configWithMToken = function (config, managementTokens, host, securedAssets) {
|
|
15
15
|
let externalConfig = require(config)
|
|
16
|
-
defaultConfig.
|
|
16
|
+
defaultConfig.securedAssets = securedAssets
|
|
17
17
|
defaultConfig.management_token = managementTokens.token
|
|
18
18
|
defaultConfig.host = host.cma
|
|
19
19
|
defaultConfig.cdn = host.cda
|
|
@@ -21,11 +21,12 @@ exports.configWithMToken = function (config, managementTokens, host, _authToken)
|
|
|
21
21
|
initial(defaultConfig)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
exports.parameterWithMToken = function (managementTokens, data, moduleName, host, _authToken) {
|
|
24
|
+
exports.parameterWithMToken = function (managementTokens, data, moduleName, host, _authToken, securedAssets) {
|
|
25
25
|
defaultConfig.management_token = managementTokens.token
|
|
26
26
|
defaultConfig.auth_token = _authToken
|
|
27
27
|
defaultConfig.host = host.cma
|
|
28
28
|
defaultConfig.cdn = host.cda
|
|
29
|
+
defaultConfig.securedAssets = securedAssets
|
|
29
30
|
if (moduleName && moduleName !== undefined) {
|
|
30
31
|
defaultConfig.moduleName = moduleName
|
|
31
32
|
}
|
|
@@ -35,13 +36,14 @@ exports.parameterWithMToken = function (managementTokens, data, moduleName, host
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// using ManagementToken
|
|
38
|
-
exports.withoutParameterMToken = async (managementTokens, moduleName, host, _authToken) => {
|
|
39
|
+
exports.withoutParameterMToken = async (managementTokens, moduleName, host, _authToken, securedAssets) => {
|
|
39
40
|
const stackUid = managementTokens.apiKey
|
|
40
41
|
const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)
|
|
41
42
|
defaultConfig.management_token = managementTokens.token
|
|
42
43
|
defaultConfig.host = host.cma
|
|
43
44
|
defaultConfig.cdn = host.cda
|
|
44
45
|
defaultConfig.auth_token = _authToken
|
|
46
|
+
defaultConfig.securedAssets = securedAssets
|
|
45
47
|
if (moduleName && moduleName !== undefined) {
|
|
46
48
|
defaultConfig.moduleName = moduleName
|
|
47
49
|
}
|
|
@@ -50,11 +52,12 @@ exports.withoutParameterMToken = async (managementTokens, moduleName, host, _aut
|
|
|
50
52
|
initial(defaultConfig)
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
exports.configWithAuthToken = function (config, _authToken, moduleName, host) {
|
|
55
|
+
exports.configWithAuthToken = function (config, _authToken, moduleName, host, securedAssets) {
|
|
54
56
|
let externalConfig = helper.readFile(path.resolve(config))
|
|
55
57
|
defaultConfig.auth_token = _authToken
|
|
56
58
|
defaultConfig.host = host.cma
|
|
57
59
|
defaultConfig.cdn = host.cda
|
|
60
|
+
defaultConfig.securedAssets = securedAssets
|
|
58
61
|
if (moduleName && moduleName !== undefined) {
|
|
59
62
|
defaultConfig.moduleName = moduleName
|
|
60
63
|
}
|
|
@@ -62,7 +65,7 @@ exports.configWithAuthToken = function (config, _authToken, moduleName, host) {
|
|
|
62
65
|
initial(defaultConfig)
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
exports.parametersWithAuthToken = function (_authToken, sourceStack, data, moduleName, host) {
|
|
68
|
+
exports.parametersWithAuthToken = function (_authToken, sourceStack, data, moduleName, host, securedAssets) {
|
|
66
69
|
return new Promise(async(resolve, reject) => {
|
|
67
70
|
defaultConfig.auth_token = _authToken
|
|
68
71
|
defaultConfig.source_stack = sourceStack
|
|
@@ -72,6 +75,7 @@ exports.parametersWithAuthToken = function (_authToken, sourceStack, data, modul
|
|
|
72
75
|
defaultConfig.host = host.cma
|
|
73
76
|
defaultConfig.cdn = host.cda
|
|
74
77
|
defaultConfig.data = data
|
|
78
|
+
defaultConfig.securedAssets = securedAssets
|
|
75
79
|
var exportStart = initial(defaultConfig)
|
|
76
80
|
exportStart.then(() => {
|
|
77
81
|
return resolve()
|
|
@@ -81,11 +85,12 @@ exports.parametersWithAuthToken = function (_authToken, sourceStack, data, modul
|
|
|
81
85
|
})
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host) => {
|
|
88
|
+
exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host, securedAssets) => {
|
|
85
89
|
const stackUid = await cli.prompt(message.promptMessageList.promptSourceStack)
|
|
86
90
|
const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)
|
|
87
91
|
defaultConfig.auth_token = _authToken
|
|
88
92
|
defaultConfig.source_stack = stackUid
|
|
93
|
+
defaultConfig.securedAssets = securedAssets
|
|
89
94
|
if (moduleName && moduleName !== undefined) {
|
|
90
95
|
defaultConfig.moduleName = moduleName
|
|
91
96
|
}
|