@contentstack/cli-cm-export 0.1.0-beta → 0.1.1-beta.11
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 +23 -13
- package/oclif.manifest.json +1 -1
- package/package.json +16 -12
- package/src/app.js +149 -66
- package/src/commands/cm/export.js +74 -50
- package/src/config/default.js +39 -1
- package/src/lib/export/assets.js +28 -9
- package/src/lib/export/content-types.js +8 -2
- package/src/lib/export/entries.js +7 -7
- package/src/lib/export/environments.js +4 -2
- package/src/lib/export/extensions.js +4 -2
- package/src/lib/export/global-fields.js +108 -82
- package/src/lib/export/labels.js +6 -4
- package/src/lib/export/locales.js +8 -6
- package/src/lib/export/stack.js +34 -16
- package/src/lib/export/webhooks.js +4 -2
- package/src/lib/export/workflows.js +60 -0
- package/src/lib/util/contentstack-management-sdk.js +7 -0
- package/src/lib/util/export-flags.js +95 -31
- package/src/lib/util/index.js +1 -5
- package/src/lib/util/log.js +0 -1
- package/src/lib/util/login.js +10 -11
- package/src/lib/util/request.js +8 -13
- package/src/lib/util/setup-branches.js +62 -0
package/README.md
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
@contentstack/cli-cm-export
|
|
2
|
-
===================
|
|
1
|
+
# @contentstack/cli-cm-export
|
|
3
2
|
|
|
4
|
-
|
|
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
|
-
[](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.
|
|
21
|
+
@contentstack/cli-cm-export/0.1.1-beta.11 linux-x64 node-v12.22.7
|
|
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
|
|
|
@@ -37,12 +41,14 @@ USAGE
|
|
|
37
41
|
|
|
38
42
|
OPTIONS
|
|
39
43
|
-A, --auth-token to use auth token
|
|
44
|
+
-B, --branch=branch [optional] branch name
|
|
40
45
|
-a, --management-token-alias=management-token-alias alias of the management token
|
|
41
46
|
-c, --config=config [optional] path of the config
|
|
42
47
|
-d, --data=data path or location to store the data
|
|
43
|
-
-l, --master-lang=master-lang code of the source stack's master Language
|
|
44
48
|
-m, --module=module [optional] specific module name
|
|
45
49
|
-s, --stack-uid=stack-uid API key of the source stack
|
|
50
|
+
-t, --content-type=content-type [optional] content type
|
|
51
|
+
--secured-assets [optional] use when assets are secured
|
|
46
52
|
|
|
47
53
|
DESCRIPTION
|
|
48
54
|
...
|
|
@@ -50,13 +56,17 @@ DESCRIPTION
|
|
|
50
56
|
|
|
51
57
|
EXAMPLES
|
|
52
58
|
csdx cm:export -A
|
|
53
|
-
csdx cm:export -A -
|
|
54
|
-
csdx cm:export -A -c
|
|
55
|
-
csdx cm:export -
|
|
56
|
-
csdx cm:export -
|
|
57
|
-
csdx cm:export -a
|
|
58
|
-
csdx cm:export -
|
|
59
|
+
csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
|
|
60
|
+
csdx cm:export -A -c <path/to/config/dir>
|
|
61
|
+
csdx cm:export -A -m <single module name>
|
|
62
|
+
csdx cm:export -A --secured-assets
|
|
63
|
+
csdx cm:export -a <management_token_alias>
|
|
64
|
+
csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>
|
|
65
|
+
csdx cm:export -a <management_token_alias> -c <path/to/config/file>
|
|
66
|
+
csdx cm:export -A -m <single module name>
|
|
67
|
+
csdx cm:export -A -m <single module name> -t <content type>
|
|
68
|
+
csdx cm:export -A -B [optional] branch name
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.
|
|
71
|
+
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.11/packages/contentstack-export/src/commands/cm/export.js)_
|
|
62
72
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.
|
|
1
|
+
{"version":"0.1.1-beta.11","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>","csdx cm:export -A -m <single module name>","csdx cm:export -A -m <single module name> -t <content type>","csdx cm:export -A -B [optional] branch name"],"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"},"content-type":{"name":"content-type","type":"option","char":"t","description":"[optional] content type"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"},"secured-assets":{"name":"secured-assets","type":"boolean","description":"[optional] use when assets are secured","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1-beta.11",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/
|
|
8
|
+
"@contentstack/cli-command": "0.1.1-beta.6",
|
|
9
|
+
"@contentstack/management": "^1.3.0",
|
|
9
10
|
"@oclif/command": "^1.6.1",
|
|
10
11
|
"@oclif/config": "^1.15.1",
|
|
11
|
-
"
|
|
12
|
-
"axios": "^0.
|
|
12
|
+
"async": "^3.2.0",
|
|
13
|
+
"axios": "^0.21.1",
|
|
13
14
|
"bluebird": "^3.7.2",
|
|
14
15
|
"cli-ux": "^5.4.6",
|
|
15
16
|
"configstore": "^5.0.1",
|
|
16
17
|
"fs": "0.0.1-security",
|
|
17
18
|
"is-valid-path": "^0.1.1",
|
|
18
|
-
"lodash": "^4.17.
|
|
19
|
+
"lodash": "^4.17.20",
|
|
19
20
|
"path": "^0.12.7",
|
|
20
21
|
"proxyquire": "^2.1.3",
|
|
21
22
|
"request": "^2.88.2",
|
|
22
23
|
"winston": "^2.2.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"assert": "^2.0.0",
|
|
26
|
-
"sinon": "^9.0.2",
|
|
27
26
|
"@oclif/dev-cli": "^1.22.2",
|
|
28
27
|
"@oclif/plugin-help": "^3.0.1",
|
|
29
28
|
"@oclif/test": "^1.2.6",
|
|
29
|
+
"assert": "^2.0.0",
|
|
30
30
|
"chai": "^4.2.0",
|
|
31
31
|
"eslint": "^5.16.0",
|
|
32
32
|
"eslint-config-oclif": "^3.1.0",
|
|
33
33
|
"globby": "^10.0.2",
|
|
34
|
-
"mocha": "^
|
|
35
|
-
"nyc": "^14.1.1"
|
|
34
|
+
"mocha": "^8.2.1",
|
|
35
|
+
"nyc": "^14.1.1",
|
|
36
|
+
"sinon": "^9.0.2"
|
|
36
37
|
},
|
|
37
38
|
"engines": {
|
|
38
39
|
"node": ">=8.0.0"
|
|
@@ -45,11 +46,12 @@
|
|
|
45
46
|
],
|
|
46
47
|
"homepage": "https://github.com/contentstack/cli",
|
|
47
48
|
"keywords": [
|
|
48
|
-
"contentstack",
|
|
49
|
+
"contentstack",
|
|
50
|
+
"cli",
|
|
51
|
+
"plugin"
|
|
49
52
|
],
|
|
50
53
|
"license": "MIT",
|
|
51
54
|
"scripts": {
|
|
52
|
-
"pack": "npm pack && mv *.tgz ../../build",
|
|
53
55
|
"postpack": "rm -f oclif.manifest.json",
|
|
54
56
|
"prepack": "oclif-dev manifest && oclif-dev readme",
|
|
55
57
|
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
@@ -60,7 +62,9 @@
|
|
|
60
62
|
"bin": "csdx",
|
|
61
63
|
"devPlugins": [
|
|
62
64
|
"@oclif/plugin-help"
|
|
63
|
-
]
|
|
65
|
+
],
|
|
66
|
+
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/contentstack-export/<%- commandPath %>"
|
|
64
67
|
},
|
|
68
|
+
"main": "./src/commands/cm/export.js",
|
|
65
69
|
"repository": "https://github.com/contentstack/cli"
|
|
66
70
|
}
|
package/src/app.js
CHANGED
|
@@ -1,74 +1,157 @@
|
|
|
1
1
|
/* eslint-disable no-redeclare */
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
const chalk = require(
|
|
7
|
-
let path = require(
|
|
2
|
+
var util = require("./lib/util");
|
|
3
|
+
var login = require("./lib/util/login");
|
|
4
|
+
var { addlogs } = require("./lib/util/log");
|
|
5
|
+
const setupBranches = require("./lib/util/setup-branches");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
let path = require("path");
|
|
8
|
+
let _ = require("lodash");
|
|
9
|
+
const cli = require("cli-ux");
|
|
8
10
|
|
|
9
|
-
exports.initial = function (config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
exports.initial = async function (config) {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
config = util.buildAppConfig(config);
|
|
14
|
+
util.validateConfig(config);
|
|
15
|
+
exports.getConfig = function () {
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
18
|
+
// try {
|
|
19
|
+
login
|
|
20
|
+
.login(config)
|
|
21
|
+
.then(async function () {
|
|
22
|
+
//setup branches
|
|
23
|
+
await setupBranches(config, config.branchName);
|
|
24
|
+
var types = config.modules.types;
|
|
25
|
+
if (Array.isArray(config.branches) && config.branches.length > 0) {
|
|
26
|
+
for (let branch of config.branches) {
|
|
27
|
+
config.branchName = branch.uid;
|
|
28
|
+
try {
|
|
29
|
+
if (config.moduleName) {
|
|
30
|
+
await singleExport(config.moduleName, types, config, branch.uid);
|
|
31
|
+
} else {
|
|
32
|
+
await allExport(config, types, branch.uid);
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.log('failed export branch', branch.uid, error)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
try {
|
|
40
|
+
if (config.moduleName) {
|
|
41
|
+
await singleExport(config.moduleName, types, config);
|
|
42
|
+
} else {
|
|
43
|
+
await allExport(config, types);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.log('failed export contents', error)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
resolve()
|
|
50
|
+
})
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
console.log("error", error);
|
|
53
|
+
if (error && error.errors && error.errors.api_key) {
|
|
54
|
+
addlogs(
|
|
55
|
+
config,
|
|
56
|
+
chalk.red(
|
|
57
|
+
"Stack Api key " + error.errors.api_key[0],
|
|
58
|
+
"Please enter valid Key",
|
|
59
|
+
"error"
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
addlogs(
|
|
63
|
+
config,
|
|
64
|
+
"The log for this is stored at " + config.data + "/export/logs",
|
|
65
|
+
"success"
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
console.log("Stack fail to export")
|
|
69
|
+
}
|
|
70
|
+
reject(error)
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
15
74
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
75
|
+
var singleExport = async (moduleName, types, config, branchName) => {
|
|
76
|
+
try {
|
|
77
|
+
if (types.indexOf(moduleName) > -1) {
|
|
78
|
+
let iterateList;
|
|
79
|
+
if (config.modules.dependency && config.modules.dependency[moduleName]) {
|
|
80
|
+
iterateList = config.modules.dependency[moduleName];
|
|
81
|
+
} else {
|
|
82
|
+
iterateList = ["stack"];
|
|
83
|
+
}
|
|
84
|
+
iterateList.push(moduleName);
|
|
85
|
+
|
|
86
|
+
for (let i = 0; i < iterateList.length; i++) {
|
|
87
|
+
|
|
88
|
+
var exportedModule = require("./lib/export/" + iterateList[i]);
|
|
89
|
+
const result = await exportedModule.start(config, branchName);
|
|
90
|
+
if (result && iterateList[i] === "stack") {
|
|
91
|
+
let master_locale = {
|
|
92
|
+
master_locale: { code: result.master_locale },
|
|
93
|
+
};
|
|
94
|
+
config = _.merge(config, master_locale);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
addlogs(config, moduleName + " was exported successfully!", "success");
|
|
98
|
+
addlogs(
|
|
99
|
+
config,
|
|
100
|
+
"The log for this is stored at " +
|
|
101
|
+
path.join(config.data, "logs", "export"),
|
|
102
|
+
"success"
|
|
103
|
+
);
|
|
27
104
|
} else {
|
|
28
|
-
|
|
29
|
-
addlogs(config, chalk.red('Stack fail to export, ' + objKey + "" + error.errors[objKey][0]), 'error')
|
|
105
|
+
addlogs(config, "Please provide valid module name.", "error");
|
|
30
106
|
}
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
addlogs(config, 'Failed to migrate ' + moduleName, 'error')
|
|
43
|
-
addlogs(config, error, 'error')
|
|
44
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'error')
|
|
45
|
-
})
|
|
46
|
-
} else {
|
|
47
|
-
addlogs(config, 'Please provide valid module name.', 'error')
|
|
107
|
+
return true
|
|
108
|
+
} catch (error) {
|
|
109
|
+
addlogs(config, "Failed to migrate " + moduleName, "error");
|
|
110
|
+
addlogs(config, error, "error");
|
|
111
|
+
addlogs(
|
|
112
|
+
config,
|
|
113
|
+
"The log for this is stored at " +
|
|
114
|
+
path.join(config.data, "logs", "export"),
|
|
115
|
+
"error"
|
|
116
|
+
);
|
|
117
|
+
throw error
|
|
48
118
|
}
|
|
49
|
-
}
|
|
119
|
+
};
|
|
50
120
|
|
|
51
|
-
var allExport = async (config, types) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
121
|
+
var allExport = async (config, types, branchName) => {
|
|
122
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
123
|
+
return new Promise(async (resolve, reject) => {
|
|
124
|
+
try {
|
|
125
|
+
for (let i = 0; i < types.length; i++) {
|
|
126
|
+
let type = types[i];
|
|
127
|
+
var exportedModule = require("./lib/export/" + type);
|
|
128
|
+
const result = await exportedModule.start(config, branchName);
|
|
129
|
+
if (result && type === "stack") {
|
|
130
|
+
let master_locale = { master_locale: { code: result.code } };
|
|
131
|
+
config = _.merge(config, master_locale);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
addlogs(
|
|
135
|
+
config,
|
|
136
|
+
chalk.green(
|
|
137
|
+
"The content of the " +
|
|
138
|
+
config.source_stack +
|
|
139
|
+
" has been exported succesfully!"
|
|
140
|
+
),
|
|
141
|
+
"success"
|
|
142
|
+
);
|
|
143
|
+
addlogs(
|
|
144
|
+
config,
|
|
145
|
+
"The log for this is stored at " +
|
|
146
|
+
path.join(config.data, "logs", "export"),
|
|
147
|
+
"success"
|
|
148
|
+
);
|
|
149
|
+
return resolve();
|
|
150
|
+
} catch (error) {
|
|
151
|
+
addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
|
|
152
|
+
addlogs(config, chalk.red(error.errorMessage), 'error')
|
|
153
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
|
|
154
|
+
return reject(error)
|
|
64
155
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}).then(function () {
|
|
68
|
-
addlogs(config, chalk.green('Stack: ' + config.source_stack + ' has been exported succesfully!'), 'success')
|
|
69
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'success')
|
|
70
|
-
}).catch(function () {
|
|
71
|
-
addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
|
|
72
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'error')
|
|
73
|
-
})
|
|
74
|
-
}
|
|
156
|
+
});
|
|
157
|
+
};
|
|
@@ -1,57 +1,66 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
-
const {Command, flags} = require('@contentstack/cli-command')
|
|
3
|
-
const {configWithMToken,
|
|
2
|
+
const { Command, flags } = require('@contentstack/cli-command')
|
|
3
|
+
const { configWithMToken,
|
|
4
4
|
parameterWithMToken,
|
|
5
5
|
withoutParameterMToken,
|
|
6
6
|
configWithAuthToken,
|
|
7
7
|
parametersWithAuthToken,
|
|
8
8
|
withoutParametersWithAuthToken,
|
|
9
9
|
} = require('../../lib/util/export-flags')
|
|
10
|
-
const Configstore
|
|
10
|
+
const Configstore = require('configstore')
|
|
11
11
|
const credStore = new Configstore('contentstack_cli')
|
|
12
12
|
|
|
13
13
|
class ExportCommand extends Command {
|
|
14
14
|
async run() {
|
|
15
|
-
const
|
|
16
|
-
const extConfig =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const data =
|
|
22
|
-
const moduleName =
|
|
15
|
+
const exportCommandFlags = this.parse(ExportCommand).flags
|
|
16
|
+
const extConfig = exportCommandFlags.config
|
|
17
|
+
let sourceStack = exportCommandFlags['stack-uid']
|
|
18
|
+
const alias = exportCommandFlags['management-token-alias']
|
|
19
|
+
const authToken = exportCommandFlags['auth-token']
|
|
20
|
+
const securedAssets = exportCommandFlags['secured-assets']
|
|
21
|
+
const data = exportCommandFlags.data
|
|
22
|
+
const moduleName = exportCommandFlags.module
|
|
23
|
+
const contentTypes = exportCommandFlags['content-type']
|
|
24
|
+
const branchName = exportCommandFlags.branch;
|
|
23
25
|
let _authToken = credStore.get('authtoken')
|
|
24
|
-
let host = this.
|
|
25
|
-
let
|
|
26
|
-
let
|
|
27
|
-
host.cma =
|
|
28
|
-
host.cda =
|
|
26
|
+
let host = this.region
|
|
27
|
+
let cmaHost = host.cma.split('//')
|
|
28
|
+
let cdaHost = host.cda.split('//')
|
|
29
|
+
host.cma = cmaHost[1]
|
|
30
|
+
host.cda = cdaHost[1]
|
|
29
31
|
|
|
30
|
-
if (alias
|
|
31
|
-
// await this.config.runHook('validateManagementTokenAlias', {alias: alias})
|
|
32
|
+
if (alias) {
|
|
32
33
|
let managementTokens = this.getToken(alias)
|
|
33
|
-
if (managementTokens
|
|
34
|
-
if (extConfig
|
|
34
|
+
if (managementTokens) {
|
|
35
|
+
if (extConfig) {
|
|
35
36
|
configWithMToken(
|
|
36
37
|
extConfig,
|
|
37
38
|
managementTokens,
|
|
38
|
-
host
|
|
39
|
+
host,
|
|
40
|
+
contentTypes,
|
|
41
|
+
branchName,
|
|
42
|
+
securedAssets
|
|
39
43
|
)
|
|
40
|
-
} else if (
|
|
41
|
-
sourceStack = managementTokens.apiKey
|
|
44
|
+
} else if (data) {
|
|
42
45
|
parameterWithMToken(
|
|
43
|
-
masterLang,
|
|
44
46
|
managementTokens,
|
|
45
|
-
sourceStack,
|
|
46
47
|
data,
|
|
47
48
|
moduleName,
|
|
48
|
-
host
|
|
49
|
+
host,
|
|
50
|
+
_authToken,
|
|
51
|
+
contentTypes,
|
|
52
|
+
branchName,
|
|
53
|
+
securedAssets
|
|
49
54
|
)
|
|
50
|
-
} else if (
|
|
55
|
+
} else if (data === undefined && sourceStack === undefined) {
|
|
51
56
|
withoutParameterMToken(
|
|
52
57
|
managementTokens,
|
|
53
58
|
moduleName,
|
|
54
|
-
host
|
|
59
|
+
host,
|
|
60
|
+
_authToken,
|
|
61
|
+
contentTypes,
|
|
62
|
+
branchName,
|
|
63
|
+
securedAssets
|
|
55
64
|
)
|
|
56
65
|
} else {
|
|
57
66
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -59,28 +68,36 @@ class ExportCommand extends Command {
|
|
|
59
68
|
} else {
|
|
60
69
|
this.log(alias + ' management token is not present, please add managment token first')
|
|
61
70
|
}
|
|
62
|
-
} else if (authToken &&
|
|
63
|
-
if (extConfig
|
|
71
|
+
} else if (authToken && _authToken) {
|
|
72
|
+
if (extConfig) {
|
|
64
73
|
configWithAuthToken(
|
|
65
74
|
extConfig,
|
|
66
75
|
_authToken,
|
|
67
76
|
moduleName,
|
|
68
|
-
host
|
|
77
|
+
host,
|
|
78
|
+
contentTypes,
|
|
79
|
+
branchName,
|
|
80
|
+
securedAssets
|
|
69
81
|
)
|
|
70
|
-
} else if (
|
|
71
|
-
parametersWithAuthToken(
|
|
72
|
-
masterLang,
|
|
82
|
+
} else if (sourceStack && data) {
|
|
83
|
+
return parametersWithAuthToken(
|
|
73
84
|
_authToken,
|
|
74
85
|
sourceStack,
|
|
75
86
|
data,
|
|
76
87
|
moduleName,
|
|
77
|
-
host
|
|
88
|
+
host,
|
|
89
|
+
contentTypes,
|
|
90
|
+
branchName,
|
|
91
|
+
securedAssets
|
|
78
92
|
)
|
|
79
|
-
} else if (
|
|
93
|
+
} else if (data === undefined && sourceStack === undefined) {
|
|
80
94
|
withoutParametersWithAuthToken(
|
|
81
95
|
_authToken,
|
|
82
96
|
moduleName,
|
|
83
|
-
host
|
|
97
|
+
host,
|
|
98
|
+
contentTypes,
|
|
99
|
+
branchName,
|
|
100
|
+
securedAssets
|
|
84
101
|
)
|
|
85
102
|
} else {
|
|
86
103
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -88,6 +105,7 @@ class ExportCommand extends Command {
|
|
|
88
105
|
} else {
|
|
89
106
|
this.log('Provide the alias for management token or auth token')
|
|
90
107
|
}
|
|
108
|
+
// return
|
|
91
109
|
}
|
|
92
110
|
}
|
|
93
111
|
|
|
@@ -97,22 +115,28 @@ Export content from one stack to another
|
|
|
97
115
|
`
|
|
98
116
|
ExportCommand.examples = [
|
|
99
117
|
'csdx cm:export -A',
|
|
100
|
-
'csdx cm:export -A -
|
|
101
|
-
'csdx cm:export -A -c
|
|
102
|
-
'csdx cm:export -
|
|
103
|
-
'csdx cm:export -
|
|
104
|
-
'csdx cm:export -a
|
|
105
|
-
'csdx cm:export -
|
|
118
|
+
'csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>',
|
|
119
|
+
'csdx cm:export -A -c <path/to/config/dir>',
|
|
120
|
+
'csdx cm:export -A -m <single module name>',
|
|
121
|
+
'csdx cm:export -A --secured-assets',
|
|
122
|
+
'csdx cm:export -a <management_token_alias>',
|
|
123
|
+
'csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>',
|
|
124
|
+
'csdx cm:export -a <management_token_alias> -c <path/to/config/file>',
|
|
125
|
+
'csdx cm:export -A -m <single module name>',
|
|
126
|
+
'csdx cm:export -A -m <single module name> -t <content type>',
|
|
127
|
+
'csdx cm:export -A -B [optional] branch name',
|
|
106
128
|
]
|
|
107
129
|
|
|
108
130
|
ExportCommand.flags = {
|
|
109
|
-
config: flags.string({char: 'c', description: '[optional] path of the config'}),
|
|
110
|
-
'
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
config: flags.string({ char: 'c', description: '[optional] path of the config' }),
|
|
132
|
+
'stack-uid': flags.string({ char: 's', description: 'API key of the source stack' }),
|
|
133
|
+
data: flags.string({ char: 'd', description: 'path or location to store the data' }),
|
|
134
|
+
'management-token-alias': flags.string({ char: 'a', description: 'alias of the management token' }),
|
|
135
|
+
'auth-token': flags.boolean({ char: 'A', description: 'to use auth token' }),
|
|
136
|
+
module: flags.string({ char: 'm', description: '[optional] specific module name' }),
|
|
137
|
+
'content-type': flags.string({ char: 't', description: '[optional] content type', multiple: true }),
|
|
138
|
+
branch: flags.string({ char: 'B', description: '[optional] branch name' }),
|
|
139
|
+
'secured-assets': flags.boolean({ description: '[optional] use when assets are secured' }),
|
|
116
140
|
}
|
|
117
141
|
|
|
118
142
|
module.exports = ExportCommand
|
package/src/config/default.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
'webhooks',
|
|
11
11
|
'global-fields',
|
|
12
12
|
'content-types',
|
|
13
|
+
'workflows',
|
|
13
14
|
'entries',
|
|
14
15
|
'labels',
|
|
15
16
|
],
|
|
@@ -20,7 +21,7 @@ module.exports = {
|
|
|
20
21
|
'code',
|
|
21
22
|
'uid',
|
|
22
23
|
'name',
|
|
23
|
-
'fallback_locale'
|
|
24
|
+
'fallback_locale'
|
|
24
25
|
],
|
|
25
26
|
},
|
|
26
27
|
environments: {
|
|
@@ -30,11 +31,45 @@ module.exports = {
|
|
|
30
31
|
labels: {
|
|
31
32
|
dirName: 'labels',
|
|
32
33
|
fileName: 'labels.json',
|
|
34
|
+
invalidKeys: [
|
|
35
|
+
'stackHeaders',
|
|
36
|
+
'uid',
|
|
37
|
+
'urlPath',
|
|
38
|
+
'created_at',
|
|
39
|
+
'updated_at',
|
|
40
|
+
'created_by',
|
|
41
|
+
'updated_by',
|
|
42
|
+
],
|
|
33
43
|
},
|
|
34
44
|
webhooks: {
|
|
35
45
|
dirName: 'webhooks',
|
|
36
46
|
fileName: 'webhooks.json',
|
|
37
47
|
},
|
|
48
|
+
releases: {
|
|
49
|
+
dirName: 'releases',
|
|
50
|
+
fileName: 'releases.json',
|
|
51
|
+
releasesList: 'releasesList.json',
|
|
52
|
+
invalidKeys: [
|
|
53
|
+
'stackHeaders',
|
|
54
|
+
'urlPath',
|
|
55
|
+
'created_at',
|
|
56
|
+
'updated_at',
|
|
57
|
+
'created_by',
|
|
58
|
+
'updated_by',
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
workflows: {
|
|
62
|
+
dirName: 'workflows',
|
|
63
|
+
fileName: 'workflows.json',
|
|
64
|
+
invalidKeys: [
|
|
65
|
+
'stackHeaders',
|
|
66
|
+
'urlPath',
|
|
67
|
+
'created_at',
|
|
68
|
+
'updated_at',
|
|
69
|
+
'created_by',
|
|
70
|
+
'updated_by',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
38
73
|
globalfields: {
|
|
39
74
|
dirName: 'global_fields',
|
|
40
75
|
fileName: 'globalfields.json',
|
|
@@ -106,6 +141,9 @@ module.exports = {
|
|
|
106
141
|
dirName: 'stack',
|
|
107
142
|
fileName: 'stack.json',
|
|
108
143
|
},
|
|
144
|
+
dependency: {
|
|
145
|
+
entries: ['stack', 'locales', 'content-types'],
|
|
146
|
+
},
|
|
109
147
|
},
|
|
110
148
|
languagesCode: [
|
|
111
149
|
'af-za',
|