@contentstack/cli-cm-export 0.1.1-beta.7 → 1.0.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/LICENSE +21 -0
- package/README.md +44 -24
- package/oclif.manifest.json +1 -1
- package/package.json +72 -68
- package/src/app.js +120 -66
- package/src/commands/cm/stacks/export.js +177 -0
- package/src/config/default.js +18 -58
- package/src/lib/export/assets.js +325 -223
- package/src/lib/export/content-types.js +76 -66
- package/src/lib/export/entries.js +190 -135
- package/src/lib/export/environments.js +52 -45
- package/src/lib/export/extensions.js +50 -43
- package/src/lib/export/global-fields.js +92 -80
- package/src/lib/export/labels.js +52 -44
- package/src/lib/export/locales.js +74 -41
- package/src/lib/export/stack.js +72 -47
- package/src/lib/export/webhooks.js +58 -48
- package/src/lib/export/workflows.js +55 -44
- package/src/lib/util/contentstack-management-sdk.js +30 -4
- package/src/lib/util/export-flags.js +158 -87
- package/src/lib/util/helper.js +20 -20
- package/src/lib/util/index.js +32 -19
- package/src/lib/util/log.js +109 -53
- package/src/lib/util/login.js +56 -41
- package/src/lib/util/setup-branches.js +53 -0
- package/src/commands/cm/export.js +0 -123
- package/src/lib/util/request.js +0 -83
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Contentstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,6 +10,26 @@ It is Contentstack’s CLI plugin to export content from the stack. To learn how
|
|
|
10
10
|
* [Commands](#commands)
|
|
11
11
|
<!-- tocstop -->
|
|
12
12
|
|
|
13
|
+
For switching to EU region update the hosts at config/default.js
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
{
|
|
17
|
+
host:'https://eu-api.contentstack.com/v3',
|
|
18
|
+
cdn: 'https://eu-cdn.contentstack.com/v3',
|
|
19
|
+
...
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For switching to AZURE-NA region update the hosts at config/default.js
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
{
|
|
27
|
+
host:'https://azure-na-api.contentstack.com/v3',
|
|
28
|
+
cdn: 'https://azure-na-cdn.contentstack.com/v3',
|
|
29
|
+
...
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
13
33
|
# Usage
|
|
14
34
|
|
|
15
35
|
<!-- usage -->
|
|
@@ -18,7 +38,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
18
38
|
$ csdx COMMAND
|
|
19
39
|
running command...
|
|
20
40
|
$ csdx (-v|--version|version)
|
|
21
|
-
@contentstack/cli-cm-export/
|
|
41
|
+
@contentstack/cli-cm-export/1.0.0 linux-x64 node-v16.14.2
|
|
22
42
|
$ csdx --help [COMMAND]
|
|
23
43
|
USAGE
|
|
24
44
|
$ csdx COMMAND
|
|
@@ -29,39 +49,39 @@ USAGE
|
|
|
29
49
|
# Commands
|
|
30
50
|
|
|
31
51
|
<!-- commands -->
|
|
32
|
-
* [`csdx cm:export`](#csdx-
|
|
52
|
+
* [`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)
|
|
33
53
|
|
|
34
|
-
## `csdx cm:export`
|
|
54
|
+
## `csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`
|
|
35
55
|
|
|
36
56
|
Export content from a stack
|
|
37
57
|
|
|
38
58
|
```
|
|
39
59
|
USAGE
|
|
40
|
-
$ csdx cm:export
|
|
60
|
+
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types
|
|
61
|
+
<value>] [--branch <value>] [--secured-assets]
|
|
41
62
|
|
|
42
63
|
OPTIONS
|
|
43
|
-
-
|
|
44
|
-
-a, --
|
|
45
|
-
-c, --config=config
|
|
46
|
-
-d, --data=data
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
--
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
-B, --branch=branch [optional] branch name
|
|
65
|
+
-a, --alias=alias alias of the management token
|
|
66
|
+
-c, --config=config [optional] path of the config
|
|
67
|
+
-d, --data-dir=data-dir path or location to store the data
|
|
68
|
+
-k, --stack-api-key=stack-api-key API key of the source stack
|
|
69
|
+
-m, --module=module [optional] specific module name
|
|
70
|
+
-t, --content-types=content-types [optional] content type
|
|
71
|
+
--secured-assets [optional] use when assets are secured
|
|
72
|
+
|
|
73
|
+
ALIASES
|
|
74
|
+
$ csdx cm:export
|
|
54
75
|
|
|
55
76
|
EXAMPLES
|
|
56
|
-
csdx cm:export -
|
|
57
|
-
csdx cm:export
|
|
58
|
-
csdx cm:export
|
|
59
|
-
csdx cm:export
|
|
60
|
-
csdx cm:export
|
|
61
|
-
csdx cm:export
|
|
62
|
-
csdx cm:export
|
|
63
|
-
csdx cm:export -a <management_token_alias> -c <path/to/config/file>
|
|
77
|
+
csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
78
|
+
csdx cm:stacks:export --config <path/to/config/dir>
|
|
79
|
+
csdx cm:stacks:export --alias <management_token_alias>
|
|
80
|
+
csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>
|
|
81
|
+
csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>
|
|
82
|
+
csdx cm:stacks:export --module <single module name>
|
|
83
|
+
csdx cm:stacks:export --branch [optional] branch name
|
|
64
84
|
```
|
|
65
85
|
|
|
66
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/
|
|
86
|
+
_See code: [src/commands/cm/stacks/export.js](https://github.com/contentstack/cli/blob/v1.0.0/packages/contentstack-export/src/commands/cm/stacks/export.js)_
|
|
67
87
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1.0.0","commands":{"cm:stacks:export":{"id":"cm:stacks:export","description":"Export content from a stack","usage":"cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":["cm:export"],"examples":["csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>","csdx cm:stacks:export --config <path/to/config/dir>","csdx cm:stacks:export --alias <management_token_alias>","csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>","csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>","csdx cm:stacks:export --module <single module name>","csdx cm:stacks:export --branch [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","hidden":true},"stack-api-key":{"name":"stack-api-key","type":"option","char":"k","description":"API key of the source stack"},"data":{"name":"data","type":"option","description":"path or location to store the data","hidden":true},"data-dir":{"name":"data-dir","type":"option","char":"d","description":"path or location to store the data"},"alias":{"name":"alias","type":"option","char":"a","description":"alias of the management token"},"management-token-alias":{"name":"management-token-alias","type":"option","description":"alias of the management token","hidden":true},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","hidden":true,"allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"content-types":{"name":"content-types","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,70 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
"name": "@contentstack/cli-cm-export",
|
|
3
|
+
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Contentstack",
|
|
6
|
+
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@contentstack/cli-command": "^1.0.0",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.0.0",
|
|
10
|
+
"@contentstack/management": "^1.3.0",
|
|
11
|
+
"@oclif/command": "^1.8.16",
|
|
12
|
+
"@oclif/config": "^1.18.3",
|
|
13
|
+
"async": "^3.2.4",
|
|
14
|
+
"bluebird": "^3.7.2",
|
|
15
|
+
"fs": "0.0.1-security",
|
|
16
|
+
"is-valid-path": "^0.1.1",
|
|
17
|
+
"lodash": "^4.17.20",
|
|
18
|
+
"mkdirp": "^1.0.4",
|
|
19
|
+
"path": "^0.12.7",
|
|
20
|
+
"progress-stream": "^2.0.0",
|
|
21
|
+
"proxyquire": "^2.1.3",
|
|
22
|
+
"winston": "^3.7.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@oclif/dev-cli": "^1.22.2",
|
|
26
|
+
"@oclif/plugin-help": "^5.1.12",
|
|
27
|
+
"@oclif/test": "^1.2.6",
|
|
28
|
+
"assert": "^2.0.0",
|
|
29
|
+
"chai": "^4.2.0",
|
|
30
|
+
"eslint": "^8.18.0",
|
|
31
|
+
"eslint-config-oclif": "^3.1.0",
|
|
32
|
+
"globby": "^10.0.2",
|
|
33
|
+
"mocha": "^10.0.0",
|
|
34
|
+
"nyc": "^14.1.1",
|
|
35
|
+
"sinon": "^9.0.2"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=8.0.0"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"/npm-shrinkwrap.json",
|
|
42
|
+
"/oclif.manifest.json",
|
|
43
|
+
"/src",
|
|
44
|
+
"/messages"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://github.com/contentstack/cli",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"contentstack",
|
|
49
|
+
"cli",
|
|
50
|
+
"plugin"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"postpack": "rm -f oclif.manifest.json",
|
|
55
|
+
"prepack": "oclif-dev manifest && oclif-dev readme",
|
|
56
|
+
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
57
|
+
"version": "oclif-dev readme && git add README.md"
|
|
58
|
+
},
|
|
59
|
+
"oclif": {
|
|
60
|
+
"commands": "./src/commands",
|
|
61
|
+
"bin": "csdx",
|
|
62
|
+
"devPlugins": [
|
|
63
|
+
"@oclif/plugin-help"
|
|
64
|
+
],
|
|
65
|
+
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/contentstack-export/<%- commandPath %>"
|
|
66
|
+
},
|
|
67
|
+
"csdxConfig": {
|
|
68
|
+
"expiredCommands": {
|
|
69
|
+
"cm:export": "csdx cm:stacks:export"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"main": "./src/commands/cm/stacks/export.js",
|
|
73
|
+
"repository": "https://github.com/contentstack/cli"
|
|
70
74
|
}
|
package/src/app.js
CHANGED
|
@@ -1,90 +1,144 @@
|
|
|
1
1
|
/* eslint-disable no-redeclare */
|
|
2
|
-
var util = require('./lib/util')
|
|
3
|
-
var login = require('./lib/util/login')
|
|
4
|
-
var {addlogs} = require('./lib/util/log')
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
let
|
|
2
|
+
var util = require('./lib/util');
|
|
3
|
+
var login = require('./lib/util/login');
|
|
4
|
+
var { addlogs, unlinkFileLogger } = 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');
|
|
8
9
|
|
|
9
10
|
exports.initial = async function (config) {
|
|
10
|
-
return new Promise(function (resolve, reject) {
|
|
11
|
-
config = util.buildAppConfig(config)
|
|
12
|
-
util.validateConfig(config)
|
|
11
|
+
return new Promise(async function (resolve, reject) {
|
|
12
|
+
config = util.buildAppConfig(config);
|
|
13
|
+
util.validateConfig(config);
|
|
13
14
|
exports.getConfig = function () {
|
|
14
|
-
return config
|
|
15
|
+
return config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const fetchBranchAndExport = async () => {
|
|
19
|
+
await setupBranches(config, config.branchName);
|
|
20
|
+
var types = config.modules.types;
|
|
21
|
+
if (Array.isArray(config.branches) && config.branches.length > 0) {
|
|
22
|
+
for (let branch of config.branches) {
|
|
23
|
+
config.branchName = branch.uid;
|
|
24
|
+
try {
|
|
25
|
+
if (config.moduleName) {
|
|
26
|
+
await singleExport(config.moduleName, types, config, branch.uid);
|
|
27
|
+
} else {
|
|
28
|
+
await allExport(config, types, branch.uid);
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.log('failed export branch', branch.uid, error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
try {
|
|
36
|
+
if (config.moduleName) {
|
|
37
|
+
await singleExport(config.moduleName, types, config);
|
|
38
|
+
} else {
|
|
39
|
+
await allExport(config, types);
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.log('failed export contents', error && error.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
15
45
|
}
|
|
46
|
+
|
|
16
47
|
// try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
48
|
+
if (
|
|
49
|
+
(config.email && config.password) ||
|
|
50
|
+
(!config.email && !config.password && config.source_stack && config.access_token) ||
|
|
51
|
+
(config.auth_token && !config.management_token)
|
|
52
|
+
) {
|
|
53
|
+
login
|
|
54
|
+
.login(config)
|
|
55
|
+
.then(async function () {
|
|
56
|
+
// setup branches
|
|
57
|
+
await fetchBranchAndExport()
|
|
58
|
+
unlinkFileLogger();
|
|
59
|
+
resolve();
|
|
25
60
|
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
.catch((error) => {
|
|
62
|
+
console.log('error', error && error.message);
|
|
63
|
+
if (error && error.errors && error.errors.api_key) {
|
|
64
|
+
addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'));
|
|
65
|
+
addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success');
|
|
66
|
+
} else {
|
|
67
|
+
console.log('Stack fail to export');
|
|
68
|
+
}
|
|
69
|
+
reject(error);
|
|
70
|
+
});
|
|
71
|
+
} else if (config.management_token) {
|
|
72
|
+
await fetchBranchAndExport()
|
|
73
|
+
resolve();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
38
77
|
|
|
39
|
-
var singleExport = async (moduleName, types, config) => {
|
|
40
|
-
var types = config.modules.types
|
|
78
|
+
var singleExport = async (moduleName, types, config, branchName) => {
|
|
41
79
|
try {
|
|
42
80
|
if (types.indexOf(moduleName) > -1) {
|
|
43
|
-
let iterateList
|
|
81
|
+
let iterateList;
|
|
82
|
+
if (config.modules.dependency && config.modules.dependency[moduleName]) {
|
|
83
|
+
iterateList = config.modules.dependency[moduleName];
|
|
84
|
+
} else {
|
|
85
|
+
iterateList = ['stack'];
|
|
86
|
+
}
|
|
87
|
+
iterateList.push(moduleName);
|
|
88
|
+
|
|
44
89
|
for (let i = 0; i < iterateList.length; i++) {
|
|
45
|
-
var exportedModule = require('./lib/export/' + iterateList[i])
|
|
46
|
-
await exportedModule.start(config
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
90
|
+
var exportedModule = require('./lib/export/' + iterateList[i]);
|
|
91
|
+
const result = await exportedModule.start(config, branchName);
|
|
92
|
+
if (result && iterateList[i] === 'stack') {
|
|
93
|
+
let master_locale = {
|
|
94
|
+
master_locale: { code: result.code },
|
|
95
|
+
};
|
|
96
|
+
config = _.merge(config, master_locale);
|
|
97
|
+
}
|
|
52
98
|
}
|
|
53
|
-
addlogs(config, moduleName + ' was exported successfully!', 'success')
|
|
54
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success')
|
|
99
|
+
addlogs(config, moduleName + ' was exported successfully!', 'success');
|
|
100
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
55
101
|
} else {
|
|
56
|
-
addlogs(config, 'Please provide valid module name.', 'error')
|
|
102
|
+
addlogs(config, 'Please provide valid module name.', 'error');
|
|
57
103
|
}
|
|
104
|
+
return true;
|
|
58
105
|
} catch (error) {
|
|
59
|
-
addlogs(config, 'Failed to migrate ' + moduleName, 'error')
|
|
60
|
-
addlogs(config, error, 'error')
|
|
61
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
|
|
106
|
+
addlogs(config, 'Failed to migrate ' + moduleName, 'error');
|
|
107
|
+
addlogs(config, error, 'error');
|
|
108
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
109
|
+
throw error;
|
|
62
110
|
}
|
|
63
|
-
}
|
|
111
|
+
};
|
|
64
112
|
|
|
65
|
-
var allExport = async (config, types) => {
|
|
113
|
+
var allExport = async (config, types, branchName) => {
|
|
66
114
|
// eslint-disable-next-line no-async-promise-executor
|
|
67
115
|
return new Promise(async (resolve, reject) => {
|
|
68
116
|
try {
|
|
69
117
|
for (let i = 0; i < types.length; i++) {
|
|
70
|
-
let type = types[i]
|
|
71
|
-
var exportedModule = require('./lib/export/' + type)
|
|
72
|
-
await exportedModule.start(config)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
})
|
|
118
|
+
let type = types[i];
|
|
119
|
+
var exportedModule = require('./lib/export/' + type);
|
|
120
|
+
const result = await exportedModule.start(config, branchName);
|
|
121
|
+
if (result && type === 'stack') {
|
|
122
|
+
let master_locale = { master_locale: { code: result.code } };
|
|
123
|
+
config = _.merge(config, master_locale);
|
|
124
|
+
}
|
|
79
125
|
}
|
|
80
|
-
addlogs(
|
|
81
|
-
|
|
82
|
-
|
|
126
|
+
addlogs(
|
|
127
|
+
config,
|
|
128
|
+
chalk.green('The content of the ' + config.source_stack + ' has been exported successfully!'),
|
|
129
|
+
'success',
|
|
130
|
+
);
|
|
131
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
132
|
+
return resolve();
|
|
83
133
|
} catch (error) {
|
|
84
|
-
addlogs(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
134
|
+
addlogs(
|
|
135
|
+
config,
|
|
136
|
+
chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'),
|
|
137
|
+
'error',
|
|
138
|
+
);
|
|
139
|
+
addlogs(config, chalk.red(error && error.errorMessage), 'error');
|
|
140
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
141
|
+
return reject(error);
|
|
88
142
|
}
|
|
89
|
-
})
|
|
90
|
-
}
|
|
143
|
+
});
|
|
144
|
+
};
|